66
|
1 |
#include "greenoddviewitem.h"
|
|
2 |
|
|
3 |
#include "QPainter"
|
|
4 |
#include "QStyleOptionGraphicsItem"
|
|
5 |
#include "QWidget"
|
|
6 |
#include "QDebug"
|
|
7 |
|
|
8 |
GreenOddViewItem::GreenOddViewItem(QGraphicsItem* parent) :
|
|
9 |
HbListViewItem(parent)
|
|
10 |
{
|
|
11 |
}
|
|
12 |
|
|
13 |
GreenOddViewItem::~GreenOddViewItem()
|
|
14 |
{
|
|
15 |
}
|
|
16 |
|
|
17 |
|
|
18 |
HbAbstractViewItem* GreenOddViewItem::createItem()
|
|
19 |
{
|
|
20 |
return new GreenOddViewItem(*this);
|
|
21 |
}
|
|
22 |
|
|
23 |
bool GreenOddViewItem::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() << "GreenOddViewItem::canSetModelIndex: value" << firstValue;
|
|
40 |
int value = firstValue.toInt();
|
|
41 |
//int value = index.row();
|
|
42 |
if ( value > 0
|
|
43 |
&& value % 2) {
|
|
44 |
return true;
|
|
45 |
}
|
|
46 |
}
|
|
47 |
return false;
|
|
48 |
}
|
|
49 |
|
|
50 |
void GreenOddViewItem::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, Qt::darkGreen);
|
|
62 |
}
|
|
63 |
}
|
|
64 |
|
|
65 |
int GreenOddViewItem::type() const
|
|
66 |
{
|
|
67 |
return GreenOddViewItem::Type;
|
|
68 |
}
|
|
69 |
|
|
70 |
|
|
71 |
|