|
1 #include "brownevenviewitem.h" |
|
2 |
|
3 #include "QPainter" |
|
4 #include "QStyleOptionGraphicsItem" |
|
5 #include "QWidget" |
|
6 #include "QDebug" |
|
7 |
|
8 BrownEvenViewItem::BrownEvenViewItem(QGraphicsItem* parent) : |
|
9 HbListViewItem(parent) |
|
10 { |
|
11 } |
|
12 |
|
13 BrownEvenViewItem::~BrownEvenViewItem() |
|
14 { |
|
15 } |
|
16 |
|
17 |
|
18 HbAbstractViewItem* BrownEvenViewItem::createItem() |
|
19 { |
|
20 return new BrownEvenViewItem(*this); |
|
21 } |
|
22 |
|
23 bool BrownEvenViewItem::canSetModelIndex(const QModelIndex &index) const |
|
24 { |
|
25 int itemType(index.data(Hb::ItemTypeRole).toInt()); |
|
26 if (itemType == Hb::StandardItem) { |
|
27 QVariant displayRole = index.data(Qt::DisplayRole); |
|
28 QString firstValue; |
|
29 QStringList stringList; |
|
30 if (displayRole.isValid()) { |
|
31 if (displayRole.canConvert<QString>()) { |
|
32 firstValue = displayRole.toString(); |
|
33 } else if ( displayRole.canConvert<QStringList>() |
|
34 && displayRole.toStringList().count()) { |
|
35 firstValue = displayRole.toStringList().at(0); |
|
36 } |
|
37 } |
|
38 |
|
39 //qDebug() << "BrownEvenViewItem::canSetModelIndex: value" << firstValue; |
|
40 //int value = index.row(); |
|
41 int value = firstValue.toInt(); |
|
42 if ( value > 0 |
|
43 && value % 2 == 0) { |
|
44 return true; |
|
45 } |
|
46 } |
|
47 return false; |
|
48 } |
|
49 |
|
50 void BrownEvenViewItem::paint( QPainter *painter, |
|
51 const QStyleOptionGraphicsItem *option, |
|
52 QWidget *widget) |
|
53 { |
|
54 HbAbstractViewItem::paint( painter, option, widget ); |
|
55 if (painter){ |
|
56 QRectF drawRect = boundingRect(); |
|
57 drawRect.adjust(1,1,-1,-1); |
|
58 //QColor brown(141,92,7); |
|
59 //QColor brown(106,57,10); |
|
60 QColor brown(87,45,11); |
|
61 painter->fillRect( drawRect, brown); |
|
62 } |
|
63 } |
|
64 |
|
65 int BrownEvenViewItem::type() const |
|
66 { |
|
67 return BrownEvenViewItem::Type; |
|
68 } |
|
69 |
|
70 |