Properly export sleep_timer_call from main_menu.c in exported_menus.h
[kugel-rb.git] / rbutil / rbutilqt / comboboxviewdelegate.cpp
blob74e3dc76e166f36344f43a48d0e4fc91b62f7d31
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2011 by Dominik Riebeling
10 * $Id$
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include <QtGui>
21 #include <qdebug.h>
22 #include "comboboxviewdelegate.h"
24 void ComboBoxViewDelegate::paint(QPainter *painter,
25 const QStyleOptionViewItem &option, const QModelIndex &index) const
27 QPen pen;
28 QFont font;
29 pen = painter->pen();
30 font = painter->font();
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));
42 else {
43 pen.setColor(QApplication::palette().color(QPalette::Text));
45 // draw data (text)
46 painter->setPen(pen);
47 painter->drawText(option.rect, Qt::AlignLeft, index.data().toString());
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();