QPythonCompleter.cpp
Go to the documentation of this file.
1 // QCodeEditor
2 #include <QPythonCompleter>
3 #include <QLanguage>
4 
5 // Qt
6 #include <QStringListModel>
7 #include <QFile>
8 
10  QCompleter(parent)
11 {
12  // Setting up Python types
13  QStringList list;
14 
15  Q_INIT_RESOURCE(qcodeeditor_resources);
16  QFile fl(":/languages/python.xml");
17 
18  if (!fl.open(QIODevice::ReadOnly))
19  {
20  return;
21  }
22 
23  QLanguage language(&fl);
24 
25  if (!language.isLoaded())
26  {
27  return;
28  }
29 
30  auto keys = language.keys();
31  for (auto&& key : keys)
32  {
33  auto names = language.names(key);
34  list.append(names);
35  }
36 
37  setModel(new QStringListModel(list, this));
38  setCompletionColumn(0);
39  setModelSorting(QCompleter::CaseInsensitivelySortedModel);
40  setCaseSensitivity(Qt::CaseSensitive);
41  setWrapAround(true);
42 }
QLanguage::names
QStringList names(const QString &key)
Method for getting names from key.
Definition: QLanguage.cpp:74
QPythonCompleter::QPythonCompleter
QPythonCompleter(QObject *parent=nullptr)
Constructor.
Definition: QPythonCompleter.cpp:9
QLanguage::keys
QStringList keys()
Method for getting available keys.
Definition: QLanguage.cpp:69
QLanguage::isLoaded
bool isLoaded() const
Method for getting is object loaded.
Definition: QLanguage.cpp:79
QLanguage
Definition: QLanguage.hpp:14


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:45