comparison changesetitem.cpp @ 117:d5db15bf250c

* Start to sketch thing that shows the details of a changeset in the history view
author Chris Cannam
date Fri, 26 Nov 2010 22:46:29 +0000
parents 10eb97683aa9
children 9734fb0d6fff
comparison
equal deleted inserted replaced
116:807c79350bf1 117:d5db15bf250c
14 License, or (at your option) any later version. See the file 14 License, or (at your option) any later version. See the file
15 COPYING included with this distribution for more information. 15 COPYING included with this distribution for more information.
16 */ 16 */
17 17
18 #include "changesetitem.h" 18 #include "changesetitem.h"
19 #include "changesetdetailitem.h"
19 #include "changeset.h" 20 #include "changeset.h"
20 #include "textabbrev.h" 21 #include "textabbrev.h"
21 #include "colourset.h" 22 #include "colourset.h"
23 #include "debug.h"
22 24
23 #include <QPainter> 25 #include <QPainter>
26 #include <QGraphicsScene>
24 27
25 ChangesetItem::ChangesetItem(Changeset *cs) : 28 ChangesetItem::ChangesetItem(Changeset *cs) :
26 m_changeset(cs), m_showBranch(false), m_column(0), m_row(0), m_wide(false) 29 m_changeset(cs), m_detail(0),
30 m_showBranch(false), m_column(0), m_row(0), m_wide(false)
27 { 31 {
28 m_font = QFont(); 32 m_font = QFont();
29 m_font.setPixelSize(11); 33 m_font.setPixelSize(11);
30 m_font.setBold(false); 34 m_font.setBold(false);
31 m_font.setItalic(false); 35 m_font.setItalic(false);
35 ChangesetItem::boundingRect() const 39 ChangesetItem::boundingRect() const
36 { 40 {
37 int w = 100; 41 int w = 100;
38 if (m_wide) w = 180; 42 if (m_wide) w = 180;
39 return QRectF(-((w-50)/2 - 1), -30, w - 3, 79); 43 return QRectF(-((w-50)/2 - 1), -30, w - 3, 79);
44 }
45
46 void
47 ChangesetItem::mousePressEvent(QGraphicsSceneMouseEvent *e)
48 {
49 DEBUG << "ChangesetItem::mousePressEvent" << endl;
50 //!!! how best to handle this?
51 if (m_detail) return;
52 m_detail = new ChangesetDetailItem(m_changeset);
53 m_detail->setZValue(zValue() + 1);
54 scene()->addItem(m_detail);
55 int w = 100;
56 if (m_wide) w = 180;
57 m_detail->moveBy(x() - (m_detail->boundingRect().width() - 50) / 2,
58 y() + 60);
40 } 59 }
41 60
42 void 61 void
43 ChangesetItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *option, 62 ChangesetItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *option,
44 QWidget *w) 63 QWidget *w)