diff options
| author | 2015-04-04 14:41:10 -0400 | |
|---|---|---|
| committer | 2015-04-04 14:41:10 -0400 | |
| commit | b5f93b05578293d1d233b4920a28a5c2fd826f94 (patch) | |
| tree | 82332679f647e9c76e331206786d07a58dcfa9b8 /SQLiteStudio3/guiSQLiteStudio/completer/completeritemdelegate.cpp | |
| parent | af8a7a3e3dccf9c9ad257e3952173d180c8a7421 (diff) | |
| parent | a5b034d4a9c44f9bc1e83b01de82530f8fc63013 (diff) | |
Merge tag 'upstream/3.0.4'
Upstream version 3.0.4
# gpg: Signature made Sat 04 Apr 2015 02:41:09 PM EDT using RSA key ID EBE9BD91
# gpg: Good signature from "Unit 193 <unit193@gmail.com>"
# gpg: aka "Unit 193 <unit193@ninthfloor.org>"
# gpg: aka "Unit 193 <unit193@ubuntu.com>"
# gpg: aka "Unit 193 <unit193@ninthfloor.com>"
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/completer/completeritemdelegate.cpp')
| -rw-r--r-- | SQLiteStudio3/guiSQLiteStudio/completer/completeritemdelegate.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/completer/completeritemdelegate.cpp b/SQLiteStudio3/guiSQLiteStudio/completer/completeritemdelegate.cpp index a0da399..3268960 100644 --- a/SQLiteStudio3/guiSQLiteStudio/completer/completeritemdelegate.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/completer/completeritemdelegate.cpp @@ -1,5 +1,6 @@ #include "completeritemdelegate.h" #include "completermodel.h" +#include "common/unused.h" #include <QPainter> #include <QIcon> #include <QApplication> @@ -21,8 +22,7 @@ void CompleterItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& QStyleOptionViewItem opt = option; initStyleOption(&opt, index); - QApplication::style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget); - + paintBackground(painter, opt, index); paintIcon(painter, opt, index); paintText(painter, opt, index); } @@ -36,6 +36,25 @@ QSize CompleterItemDelegate::sizeHint(const QStyleOptionViewItem& option, const return size; } +void CompleterItemDelegate::paintBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const +{ + UNUSED(index); + + painter->save(); + QPalette::ColorGroup cg = (option.state & QStyle::State_Enabled) ? QPalette::Normal : QPalette::Disabled; + if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)) + cg = QPalette::Inactive; + + QColor bg = option.palette.color(cg, QPalette::Base); + if (option.state & QStyle::State_Selected) + bg = option.palette.color(cg, QPalette::Highlight); + + painter->setPen(Qt::NoPen); + painter->setBrush(bg); + painter->drawRect(option.rect); + painter->restore(); +} + void CompleterItemDelegate::paintIcon(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { QIcon icon = index.data(Qt::DecorationRole).value<QIcon>(); @@ -69,15 +88,9 @@ void CompleterItemDelegate::paintText(QPainter* painter, const QStyleOptionViewI QColor labelColor = option.palette.color(cg, QPalette::Link); if (option.state & QStyle::State_Selected) { -#ifdef Q_OS_WIN32 - prefixColor = option.palette.color(cg, QPalette::Text); - valueColor = option.palette.color(cg, QPalette::Text); - labelColor = option.palette.color(cg, QPalette::Text); -#else prefixColor = option.palette.color(cg, QPalette::HighlightedText); valueColor = option.palette.color(cg, QPalette::HighlightedText); labelColor = option.palette.color(cg, QPalette::HighlightedText); -#endif } // Using ascent() to measure usual height of the font, excluding anything below baseline. |
