File: completermodel.h

package info (click to toggle)
sqlitestudio 3.4.21%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 54,880 kB
  • sloc: ansic: 406,208; cpp: 123,872; yacc: 2,692; tcl: 497; sh: 462; xml: 426; makefile: 19
file content (50 lines) | stat: -rw-r--r-- 1,382 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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