8 InfoItem::InfoItem(QGraphicsItem
*parent
) : QGraphicsItem(parent
)
11 setCacheMode(QGraphicsItem::DeviceCoordinateCache
);
15 void InfoItem::updateBoundingRect()
18 font
.setPixelSize(FONT_SIZE
);
19 font
.setFamily(FONT_FAMILY
);
20 QFontMetrics
fm(font
);
21 QList
<KV
>::const_iterator i
;
24 for (i
= _list
.constBegin(); i
!= _list
.constEnd(); i
++) {
25 width
+= fm
.width(i
->key
+ ": ");
26 width
+= fm
.width(i
->value
) + ((i
== _list
.end() - 1) ? 0 : PADDING
);
29 _boundingRect
= QRectF(0, 0, width
, _list
.isEmpty() ? 0 : fm
.height());
32 void InfoItem::paint(QPainter
*painter
, const QStyleOptionGraphicsItem
*option
,
38 font
.setPixelSize(FONT_SIZE
);
39 font
.setFamily(FONT_FAMILY
);
40 painter
->setFont(font
);
41 QFontMetrics
fm(font
);
42 QList
<KV
>::const_iterator i
;
46 painter
->setRenderHint(QPainter::Antialiasing
, false);
48 for (i
= _list
.constBegin(); i
!= _list
.constEnd(); i
++) {
49 painter
->drawText(width
, fm
.height() - fm
.descent(), i
->key
+ ": ");
50 width
+= fm
.width(i
->key
+ ": ");
51 painter
->drawText(width
, fm
.height() - fm
.descent(), i
->value
);
52 width
+= fm
.width(i
->value
) + ((i
== _list
.end() - 1) ? 0 : PADDING
);
53 if (i
!= _list
.end() - 1) {
55 painter
->setPen(Qt::gray
);
56 painter
->drawLine(width
- PADDING
/2, fm
.descent(),
57 width
- PADDING
/2, fm
.height() - fm
.descent());
63 painter->setPen(Qt::red);
64 painter->drawRect(boundingRect());
68 void InfoItem::insert(const QString
&key
, const QString
&value
)
73 prepareGeometryChange();
75 if ((i
= _list
.indexOf(kv
)) < 0)
84 void InfoItem::clear()
86 prepareGeometryChange();