annotate dateitem.cpp @ 109:1721c580c10e

* Add a queueing mechanism for Hg actions, instead of refusing to start an action if something else is already happening. This is essential now that actions can be prompted by asynchronous events (e.g. filesystem watcher). * Make Revert behave sensibly
author Chris Cannam
date Fri, 26 Nov 2010 12:48:29 +0000
parents f583e44d9d31
children 4bad3c5c053a
rev   line source
Chris@57 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@57 2
Chris@57 3 /*
Chris@57 4 EasyMercurial
Chris@57 5
Chris@57 6 Based on HgExplorer by Jari Korhonen
Chris@57 7 Copyright (c) 2010 Jari Korhonen
Chris@57 8 Copyright (c) 2010 Chris Cannam
Chris@57 9 Copyright (c) 2010 Queen Mary, University of London
Chris@57 10
Chris@57 11 This program is free software; you can redistribute it and/or
Chris@57 12 modify it under the terms of the GNU General Public License as
Chris@57 13 published by the Free Software Foundation; either version 2 of the
Chris@57 14 License, or (at your option) any later version. See the file
Chris@57 15 COPYING included with this distribution for more information.
Chris@57 16 */
Chris@53 17
Chris@53 18 #include "dateitem.h"
Chris@53 19
Chris@53 20 #include <QPainter>
Chris@53 21 #include <QBrush>
Chris@53 22 #include <QFont>
Chris@53 23
Chris@53 24 void
Chris@53 25 DateItem::setRows(int minrow, int n)
Chris@53 26 {
Chris@53 27 m_minrow = minrow;
Chris@53 28 m_maxrow = minrow + n - 1;
Chris@53 29 setY(m_minrow * 90);
Chris@53 30 }
Chris@53 31
Chris@53 32 void
Chris@53 33 DateItem::setCols(int mincol, int n)
Chris@53 34 {
Chris@53 35 m_mincol = mincol;
Chris@53 36 m_maxcol = mincol + n - 1;
Chris@53 37 setX(m_mincol * 100);
Chris@53 38 }
Chris@53 39
Chris@53 40 QRectF
Chris@53 41 DateItem::boundingRect() const
Chris@53 42 {
Chris@53 43 return QRectF(-75, -25,
Chris@53 44 (m_maxcol - m_mincol + 1) * 100 + 100,
Chris@53 45 (m_maxrow - m_minrow + 1) * 90).normalized();
Chris@53 46 }
Chris@53 47
Chris@53 48 void
Chris@53 49 DateItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *opt, QWidget *w)
Chris@53 50 {
Chris@53 51 QBrush brush;
Chris@53 52
Chris@53 53 if (m_even) {
Chris@53 54 QColor c(QColor::fromRgb(240, 240, 240));
Chris@53 55 brush = QBrush(c);
Chris@53 56 } else {
Chris@53 57 QColor c(QColor::fromRgb(250, 250, 250));
Chris@53 58 brush = QBrush(c);
Chris@53 59 }
Chris@53 60
Chris@53 61 paint->fillRect(boundingRect(), brush);
Chris@53 62
Chris@53 63 paint->save();
Chris@53 64 QFont f(paint->font());
Chris@53 65 f.setBold(true);
Chris@53 66 paint->setFont(f);
Chris@53 67 paint->drawText(-70, -10, m_dateString);
Chris@53 68 paint->restore();
Chris@53 69 }
Chris@53 70
Chris@53 71