diff options
Diffstat (limited to 'rbutil/rbutilqt/gui/comboboxviewdelegate.cpp')
-rw-r--r-- | rbutil/rbutilqt/gui/comboboxviewdelegate.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/gui/comboboxviewdelegate.cpp b/rbutil/rbutilqt/gui/comboboxviewdelegate.cpp new file mode 100644 index 0000000000..189f71c95e --- /dev/null +++ b/rbutil/rbutilqt/gui/comboboxviewdelegate.cpp | |||
@@ -0,0 +1,54 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2011 by Dominik Riebeling | ||
10 | * | ||
11 | * All files in this archive are subject to the GNU General Public License. | ||
12 | * See the file COPYING in the source tree root for full license agreement. | ||
13 | * | ||
14 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
15 | * KIND, either express or implied. | ||
16 | * | ||
17 | ****************************************************************************/ | ||
18 | |||
19 | #include <QtGui> | ||
20 | #include <qdebug.h> | ||
21 | #include "comboboxviewdelegate.h" | ||
22 | |||
23 | void ComboBoxViewDelegate::paint(QPainter *painter, | ||
24 | const QStyleOptionViewItem &option, const QModelIndex &index) const | ||
25 | { | ||
26 | QPen pen; | ||
27 | QFont font; | ||
28 | pen = painter->pen(); | ||
29 | font = painter->font(); | ||
30 | |||
31 | painter->save(); | ||
32 | // paint selection | ||
33 | if(option.state & QStyle::State_Selected) { | ||
34 | painter->setPen(QPen(Qt::NoPen)); | ||
35 | painter->setBrush(QApplication::palette().highlight()); | ||
36 | painter->drawRect(option.rect); | ||
37 | painter->restore(); | ||
38 | painter->save(); | ||
39 | pen.setColor(QApplication::palette().color(QPalette::HighlightedText)); | ||
40 | } | ||
41 | else { | ||
42 | pen.setColor(QApplication::palette().color(QPalette::Text)); | ||
43 | } | ||
44 | // draw data (text) | ||
45 | painter->setPen(pen); | ||
46 | painter->drawText(option.rect, Qt::AlignLeft, index.data().toString()); | ||
47 | |||
48 | // draw user data right aligned, italic | ||
49 | font.setItalic(true); | ||
50 | painter->setFont(font); | ||
51 | painter->drawText(option.rect, Qt::AlignRight, index.data(Qt::UserRole).toString()); | ||
52 | painter->restore(); | ||
53 | } | ||
54 | |||