File: completeritemdelegate.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 (31 lines) | stat: -rw-r--r-- 1,357 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
#ifndef COMPLETERITEMDELEGATE_H
#define COMPLETERITEMDELEGATE_H

#include "guiSQLiteStudio_global.h"
#include "expectedtoken.h"
#include <QStyledItemDelegate>

class QIcon;

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

        void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
        QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;

    private:
        QIcon* getIcon(ExpectedToken::Type type) const;
        void paintBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
        void paintIcon(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
        void paintText(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
        void paintPrefix(QPainter* painter, const QFontMetrics& metrics, int& x, int y, const QString& text) const;
        void paintValue(QPainter* painter, const QFontMetrics& metrics, int& x, int y, const QString& text) const;
        void paintLabel(QPainter* painter, int& x, int y, const QString& text, bool emptyValue) const;

        const static int spacer = 1;
};

#endif // COMPLETERITEMDELEGATE_H