1 | /*************************************************************************** |
---|---|
2 | phraselistitem.cpp - description |
3 | ------------------- |
4 | begin : Fre Sep 6 2002 |
5 | copyright : (C) 2002 by Gunnar Schmi Dt |
6 | email : kmouth@schmi-dt.de |
7 | ***************************************************************************/ |
8 | |
9 | /*************************************************************************** |
10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * |
15 | * * |
16 | ***************************************************************************/ |
17 | |
18 | #include "phraselistitem.h" |
19 | |
20 | #include <QtGui/QStyle> |
21 | #include <QtGui/QStyleOptionFocusRect> |
22 | #include <QtGui/QPainter> |
23 | |
24 | PhraseListItem::PhraseListItem (const QString & text) |
25 | : Q3ListBoxText(text) { |
26 | } |
27 | |
28 | PhraseListItem::~PhraseListItem() { |
29 | } |
30 | |
31 | bool PhraseListItem::drawCursor() const { |
32 | if ((Q3ListBoxItem *)this != listBox()->item (listBox()->currentItem())) |
33 | return false; |
34 | |
35 | for (Q3ListBoxItem *item = listBox()->firstItem(); item != 0; item = item->next() ) { |
36 | if (item->isSelected()) |
37 | return true; |
38 | } |
39 | return false; |
40 | } |
41 | |
42 | int PhraseListItem::rtti() const { |
43 | return RTTI; |
44 | } |
45 | |
46 | void PhraseListItem::paint (QPainter *p) { |
47 | Q3ListBoxText::paint (p); |
48 | |
49 | if (drawCursor()) { |
50 | QRect r (0, 0, listBox()->maxItemWidth(), height (listBox())); |
51 | QStyleOptionFocusRect option; |
52 | option.rect = r; |
53 | listBox()->style()->drawPrimitive ( QStyle::PE_FrameFocusRect, &option, p); |
54 | } |
55 | } |
56 |