comparison dateitem.cpp @ 53:3c46b2ac45d3

* Put proper labels &c in changeset items; colour branches and users; etc
author Chris Cannam
date Fri, 12 Nov 2010 16:48:18 +0000
parents
children f583e44d9d31
comparison
equal deleted inserted replaced
52:384420567575 53:3c46b2ac45d3
1
2 #include "dateitem.h"
3
4 #include <QPainter>
5 #include <QBrush>
6 #include <QFont>
7
8 void
9 DateItem::setRows(int minrow, int n)
10 {
11 m_minrow = minrow;
12 m_maxrow = minrow + n - 1;
13 setY(m_minrow * 90);
14 }
15
16 void
17 DateItem::setCols(int mincol, int n)
18 {
19 m_mincol = mincol;
20 m_maxcol = mincol + n - 1;
21 setX(m_mincol * 100);
22 }
23
24 QRectF
25 DateItem::boundingRect() const
26 {
27 return QRectF(-75, -25,
28 (m_maxcol - m_mincol + 1) * 100 + 100,
29 (m_maxrow - m_minrow + 1) * 90).normalized();
30 }
31
32 void
33 DateItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *opt, QWidget *w)
34 {
35 QBrush brush;
36
37 if (m_even) {
38 QColor c(QColor::fromRgb(240, 240, 240));
39 brush = QBrush(c);
40 } else {
41 QColor c(QColor::fromRgb(250, 250, 250));
42 brush = QBrush(c);
43 }
44
45 paint->fillRect(boundingRect(), brush);
46
47 paint->save();
48 QFont f(paint->font());
49 f.setBold(true);
50 paint->setFont(f);
51 paint->drawText(-70, -10, m_dateString);
52 paint->restore();
53 }
54
55