LUACompleter.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include "LUACompleter.hxx"
  9. #include <Source/LUA/CodeCompletion/moc_LUACompleter.cpp>
  10. #include <QRegularExpression>
  11. namespace LUAEditor
  12. {
  13. Completer::Completer(QAbstractItemModel* model, QObject* pParent)
  14. : QCompleter(model, pParent)
  15. {
  16. setCaseSensitivity(Qt::CaseInsensitive);
  17. setCompletionMode(QCompleter::CompletionMode::PopupCompletion);
  18. setModelSorting(QCompleter::ModelSorting::CaseSensitivelySortedModel);
  19. }
  20. Completer::~Completer()
  21. {
  22. }
  23. QStringList Completer::splitPath(const QString& path) const
  24. {
  25. auto result = path.split(QRegularExpression(c_luaSplit));
  26. return result;
  27. }
  28. int Completer::GetCompletionPrefixTailLength()
  29. {
  30. auto result = completionPrefix().split(QRegularExpression(c_luaSplit));
  31. return result.back().length();
  32. }
  33. }