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