Mercurial > hg > easyhg
comparison changesetitem.cpp @ 141:e6c6b88d19b9
* Start hooking up right-button menus on changeset & uncommitted items
author | Chris Cannam |
---|---|
date | Tue, 30 Nov 2010 17:56:11 +0000 |
parents | bad40d7e7a2b |
children | 644bd31e8301 |
comparison
equal
deleted
inserted
replaced
140:bad40d7e7a2b | 141:e6c6b88d19b9 |
---|---|
37 { | 37 { |
38 m_font = QFont(); | 38 m_font = QFont(); |
39 m_font.setPixelSize(11); | 39 m_font.setPixelSize(11); |
40 m_font.setBold(false); | 40 m_font.setBold(false); |
41 m_font.setItalic(false); | 41 m_font.setItalic(false); |
42 } | |
43 | |
44 QString | |
45 ChangesetItem::getId() | |
46 { | |
47 return m_changeset->id(); | |
42 } | 48 } |
43 | 49 |
44 QRectF | 50 QRectF |
45 ChangesetItem::boundingRect() const | 51 ChangesetItem::boundingRect() const |
46 { | 52 { |
85 hideDetail(); | 91 hideDetail(); |
86 } else { | 92 } else { |
87 showDetail(); | 93 showDetail(); |
88 } | 94 } |
89 } else if (e->button() == Qt::RightButton) { | 95 } else if (e->button() == Qt::RightButton) { |
96 if (m_detail) { | |
97 hideDetail(); | |
98 } | |
90 activateMenu(); | 99 activateMenu(); |
91 } | 100 } |
92 } | 101 } |
93 | 102 |
94 void | 103 void |
95 ChangesetItem::activateMenu() | 104 ChangesetItem::activateMenu() |
96 { | 105 { |
97 QMenu *menu = new QMenu; | 106 QMenu *menu = new QMenu; |
98 QLabel *label = new QLabel(tr("<qt><b>Identifier: </b>%1</qt>") | 107 QLabel *label = new QLabel(tr("<qt><b>Revision: </b>%1</qt>") |
99 .arg(m_changeset->id())); | 108 .arg(m_changeset->id())); |
100 QWidgetAction *wa = new QWidgetAction(menu);; | 109 QWidgetAction *wa = new QWidgetAction(menu); |
101 wa->setDefaultWidget(label); | 110 wa->setDefaultWidget(label); |
102 menu->addAction(wa); | 111 menu->addAction(wa); |
103 menu->addSeparator(); | 112 menu->addSeparator(); |
113 | |
104 QAction *update = menu->addAction(tr("Update to this revision")); | 114 QAction *update = menu->addAction(tr("Update to this revision")); |
115 connect(update, SIGNAL(triggered()), this, SLOT(updateActivated())); | |
116 | |
105 menu->addSeparator(); | 117 menu->addSeparator(); |
118 | |
106 QAction *diffParent = menu->addAction(tr("Diff against previous revision")); | 119 QAction *diffParent = menu->addAction(tr("Diff against previous revision")); |
120 connect(diffParent, SIGNAL(triggered()), this, SLOT(diffToPreviousActivated())); | |
107 QAction *diffCurrent = menu->addAction(tr("Diff against current revision")); | 121 QAction *diffCurrent = menu->addAction(tr("Diff against current revision")); |
122 connect(diffCurrent, SIGNAL(triggered()), this, SLOT(diffToCurrentActivated())); | |
123 | |
108 menu->addSeparator(); | 124 menu->addSeparator(); |
125 | |
109 QAction *merge = menu->addAction(tr("Merge from here to current")); | 126 QAction *merge = menu->addAction(tr("Merge from here to current")); |
127 connect(merge, SIGNAL(triggered()), this, SLOT(mergeActivated())); | |
110 QAction *tag = menu->addAction(tr("Tag this revision")); | 128 QAction *tag = menu->addAction(tr("Tag this revision")); |
111 menu->exec(QCursor::pos()); | 129 connect(tag, SIGNAL(triggered()), this, SLOT(tagActivated())); |
112 } | 130 |
131 QAction *a = menu->exec(QCursor::pos()); | |
132 ungrabMouse(); | |
133 if (a) a->trigger(); | |
134 } | |
135 | |
136 void ChangesetItem::updateActivated() { emit updateTo(getId()); } | |
137 void ChangesetItem::diffToPreviousActivated() { emit diffToPrevious(getId()); } | |
138 void ChangesetItem::diffToCurrentActivated() { emit diffToCurrent(getId()); } | |
139 void ChangesetItem::mergeActivated() { emit mergeFrom(getId()); } | |
140 void ChangesetItem::tagActivated() { emit tag(getId()); } | |
113 | 141 |
114 void | 142 void |
115 ChangesetItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *option, | 143 ChangesetItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *option, |
116 QWidget *w) | 144 QWidget *w) |
117 { | 145 { |