File: sqlqueryitemdelegate.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 (58 lines) | stat: -rw-r--r-- 2,594 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
51
52
53
54
55
56
57
58
#ifndef SQLQUERYITEMDELEGATE_H
#define SQLQUERYITEMDELEGATE_H

#include "guiSQLiteStudio_global.h"
#include "db/sqlquery.h"
#include <QStyledItemDelegate>
#include <QSet>

class FkComboBox;
class SqlQueryItem;
class QComboBox;
class QStandardItemModel;
class SqlQueryModel;
class SqlQueryView;

class GUI_API_EXPORT SqlQueryItemDelegate : public QStyledItemDelegate
{
        Q_OBJECT
    public:
        explicit SqlQueryItemDelegate(QObject *parent = 0);

        void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
        QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
        void destroyEditor(QWidget *editor, const QModelIndex &index) const;
        QString	displayText(const QVariant & value, const QLocale & locale) const;
        void setEditorData(QWidget * editor, const QModelIndex & index) const;
        void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const;
        void mouseLeftIndex(const QModelIndex& index);

    private:
        class FkComboShowFilter : public QObject
        {
            public:
                explicit FkComboShowFilter(const SqlQueryItemDelegate* delegate, SqlQueryView* comboView, QObject* parent = 0);
                bool eventFilter(QObject *obj, QEvent *event);

            private:
                const SqlQueryItemDelegate* delegate = nullptr;
                SqlQueryView* comboView = nullptr;
        };

        SqlQueryItem* getItem(const QModelIndex &index) const;
        QWidget* getEditor(int type, bool shouldSkipInitialSelection, QWidget* parent) const;
        QWidget* getFkEditor(SqlQueryItem* item, bool shouldSkipInitialSelection, QWidget* parent, const SqlQueryModel *model) const;
        void setEditorDataForLineEdit(QLineEdit* le, const QModelIndex& index) const;
        void setEditorDataForFk(QComboBox* cb, const QModelIndex& index) const;
        void setModelDataForFk(FkComboBox* editor, QAbstractItemModel* model, const QModelIndex& index) const;
        void setModelDataForLineEdit(QLineEdit* editor, QAbstractItemModel* model, const QModelIndex& index) const;
        qlonglong getRowCountForFkEditor(Db* db, const QString& query, bool *isError) const;
        int getFkViewHeaderWidth(SqlQueryView* fkView, bool includeScrollBar) const;

        QSet<QWidget*> editorsWithAsyncExecution;

        static bool warnedAboutHugeContents;
        static const int HUGE_CONTENTS_WARNING_LIMIT = 32767; // pow(2, 16) / 2 - 1
};

#endif // SQLQUERYITEMDELEGATE_H