annotate 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
rev   line source
Chris@53 1
Chris@53 2 #include "dateitem.h"
Chris@53 3
Chris@53 4 #include <QPainter>
Chris@53 5 #include <QBrush>
Chris@53 6 #include <QFont>
Chris@53 7
Chris@53 8 void
Chris@53 9 DateItem::setRows(int minrow, int n)
Chris@53 10 {
Chris@53 11 m_minrow = minrow;
Chris@53 12 m_maxrow = minrow + n - 1;
Chris@53 13 setY(m_minrow * 90);
Chris@53 14 }
Chris@53 15
Chris@53 16 void
Chris@53 17 DateItem::setCols(int mincol, int n)
Chris@53 18 {
Chris@53 19 m_mincol = mincol;
Chris@53 20 m_maxcol = mincol + n - 1;
Chris@53 21 setX(m_mincol * 100);
Chris@53 22 }
Chris@53 23
Chris@53 24 QRectF
Chris@53 25 DateItem::boundingRect() const
Chris@53 26 {
Chris@53 27 return QRectF(-75, -25,
Chris@53 28 (m_maxcol - m_mincol + 1) * 100 + 100,
Chris@53 29 (m_maxrow - m_minrow + 1) * 90).normalized();
Chris@53 30 }
Chris@53 31
Chris@53 32 void
Chris@53 33 DateItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *opt, QWidget *w)
Chris@53 34 {
Chris@53 35 QBrush brush;
Chris@53 36
Chris@53 37 if (m_even) {
Chris@53 38 QColor c(QColor::fromRgb(240, 240, 240));
Chris@53 39 brush = QBrush(c);
Chris@53 40 } else {
Chris@53 41 QColor c(QColor::fromRgb(250, 250, 250));
Chris@53 42 brush = QBrush(c);
Chris@53 43 }
Chris@53 44
Chris@53 45 paint->fillRect(boundingRect(), brush);
Chris@53 46
Chris@53 47 paint->save();
Chris@53 48 QFont f(paint->font());
Chris@53 49 f.setBold(true);
Chris@53 50 paint->setFont(f);
Chris@53 51 paint->drawText(-70, -10, m_dateString);
Chris@53 52 paint->restore();
Chris@53 53 }
Chris@53 54
Chris@53 55