changeset 140:bad40d7e7a2b

* First cut at (not yet operational) right-button menu
author Chris Cannam
date Tue, 30 Nov 2010 14:59:52 +0000
parents e8a481789607
children e6c6b88d19b9
files changesetitem.cpp changesetitem.h
diffstat 2 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/changesetitem.cpp	Tue Nov 30 14:27:34 2010 +0000
+++ b/changesetitem.cpp	Tue Nov 30 14:59:52 2010 +0000
@@ -25,6 +25,10 @@
 #include <QPainter>
 #include <QGraphicsScene>
 #include <QGraphicsSceneMouseEvent>
+#include <QMenu>
+#include <QAction>
+#include <QLabel>
+#include <QWidgetAction>
 
 ChangesetItem::ChangesetItem(Changeset *cs) :
     m_changeset(cs), m_detail(0),
@@ -82,10 +86,32 @@
         } else {
             showDetail();
         }
+    } else if (e->button() == Qt::RightButton) {
+        activateMenu();
     }
 }
 
 void
+ChangesetItem::activateMenu()
+{
+    QMenu *menu = new QMenu;
+    QLabel *label = new QLabel(tr("<qt><b>Identifier: </b>%1</qt>")
+                               .arg(m_changeset->id()));
+    QWidgetAction *wa = new QWidgetAction(menu);;
+    wa->setDefaultWidget(label);
+    menu->addAction(wa);
+    menu->addSeparator();
+    QAction *update = menu->addAction(tr("Update to this revision"));
+    menu->addSeparator();
+    QAction *diffParent = menu->addAction(tr("Diff against previous revision"));
+    QAction *diffCurrent = menu->addAction(tr("Diff against current revision"));
+    menu->addSeparator();
+    QAction *merge = menu->addAction(tr("Merge from here to current"));
+    QAction *tag = menu->addAction(tr("Tag this revision"));
+    menu->exec(QCursor::pos());
+}
+
+void
 ChangesetItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *option,
                      QWidget *w)
 {
--- a/changesetitem.h	Tue Nov 30 14:27:34 2010 +0000
+++ b/changesetitem.h	Tue Nov 30 14:59:52 2010 +0000
@@ -66,6 +66,8 @@
     virtual void mousePressEvent(QGraphicsSceneMouseEvent *);
 
 private:
+    void activateMenu();
+
     QFont m_font;
     Changeset *m_changeset;
     ChangesetDetailItem *m_detail;