diff options
| author | 2014-12-06 17:33:25 -0500 | |
|---|---|---|
| committer | 2014-12-06 17:33:25 -0500 | |
| commit | 7167ce41b61d2ba2cdb526777a4233eb84a3b66a (patch) | |
| tree | a35c14143716e1f2c98f808c81f89426045a946f /SQLiteStudio3/guiSQLiteStudio/completer/completermodel.h | |
Imported Upstream version 2.99.6upstream/2.99.6
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/completer/completermodel.h')
| -rw-r--r-- | SQLiteStudio3/guiSQLiteStudio/completer/completermodel.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/completer/completermodel.h b/SQLiteStudio3/guiSQLiteStudio/completer/completermodel.h new file mode 100644 index 0000000..5edd46f --- /dev/null +++ b/SQLiteStudio3/guiSQLiteStudio/completer/completermodel.h @@ -0,0 +1,50 @@ +#ifndef COMPLETERMODEL_H +#define COMPLETERMODEL_H + +#include "guiSQLiteStudio_global.h" +#include "expectedtoken.h" +#include <QAbstractItemModel> +#include <QModelIndex> + +class CompleterView; +class Icon; + +class GUI_API_EXPORT CompleterModel : public QAbstractItemModel +{ + public: + using QAbstractItemModel::setData; + + enum UserRole + { + VALUE = 1000, + CONTEXT = 1001, + PREFIX = 1002, + LABEL = 1003, + TYPE = 1004 + }; + + explicit CompleterModel(QObject *parent = 0); + + QModelIndex index(int row, int column, const QModelIndex& parent) const; + QModelIndex parent(const QModelIndex& child) const; + int rowCount(const QModelIndex& parent) const; + int columnCount(const QModelIndex& parent) const; + QVariant data(const QModelIndex& index, int role) const; + + void setCompleterView(CompleterView* view); + void setData(const QList<ExpectedTokenPtr>& data); + void setFilter(const QString& filter); + QString getFilter() const; + void clear(); + ExpectedTokenPtr getToken(int index) const; + + private: + QIcon getIcon(ExpectedToken::Type type) const; + void applyFilter(); + + QList<ExpectedTokenPtr> tokens; + QString filter; + CompleterView* completerView = nullptr; +}; + +#endif // COMPLETERMODEL_H |
