changeset 508:c43880dfdb78

Show closing commits as simple squares
author Chris Cannam
date Tue, 18 Oct 2011 11:10:20 +0100
parents 459aa20d3eee
children 6f371814509d
files src/changesetitem.cpp src/changesetitem.h src/grapher.cpp
diffstat 3 files changed, 32 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/changesetitem.cpp	Tue Oct 18 09:54:21 2011 +0100
+++ b/src/changesetitem.cpp	Tue Oct 18 11:10:20 2011 +0100
@@ -38,7 +38,7 @@
 ChangesetItem::ChangesetItem(Changeset *cs) :
     m_changeset(cs), m_detail(0),
     m_showBranch(false), m_column(0), m_row(0), m_wide(false),
-    m_current(false), m_closed(false), m_new(false)
+    m_current(false), m_closed(false), m_closing(false), m_new(false)
 {
     m_font = QFont();
     m_font.setPixelSize(11);
@@ -72,7 +72,7 @@
     scene()->addItem(m_detail);
     int w = 100;
     if (m_wide) w = 180;
-    if (isMerge()) w = 60;
+    if (isMerge() || isClosingCommit()) w = 60;
     int h = 80;
 //    m_detail->moveBy(x() - (m_detail->boundingRect().width() - 50) / 2,
 //                     y() + 60);
@@ -244,8 +244,8 @@
 void
 ChangesetItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *, QWidget *)
 {
-    if (isMerge()) {
-        paintMerge(paint);
+    if (isClosingCommit() || isMerge()) {
+        paintSimple(paint);
     } else {
         paintNormal(paint);
     }
@@ -433,12 +433,12 @@
 }
 
 void
-ChangesetItem::paintMerge(QPainter *paint)
+ChangesetItem::paintSimple(QPainter *paint)
 {
     paint->save();
 
     int alpha = 255;
-    if (m_closed) alpha = 40;
+    if (m_closed) alpha = 90;
     
     ColourSet *colourSet = ColourSet::instance();
     QColor branchColour = colourSet->getColourFor(m_changeset->branch());
@@ -481,19 +481,31 @@
     if (showProperLines) {
 
         if (m_current) {
-            paint->drawEllipse(QRectF(x0 - 4, fh - 4, size + 8, size + 8));
-
+            if (isClosingCommit()) {
+                paint->drawRect(QRectF(x0 - 4, fh - 4, size + 8, size + 8));
+            } else {
+                paint->drawEllipse(QRectF(x0 - 4, fh - 4, size + 8, size + 8));
+            }
+            
             if (m_new) {
                 paint->save();
                 paint->setPen(Qt::yellow);
                 paint->setBrush(Qt::NoBrush);
-                paint->drawEllipse(QRectF(x0 - 2, fh - 2, size + 4, size + 4));
+                if (isClosingCommit()) {
+                    paint->drawRect(QRectF(x0 - 2, fh - 2, size + 4, size + 4));
+                } else {
+                    paint->drawEllipse(QRectF(x0 - 2, fh - 2, size + 4, size + 4));
+                }
                 paint->restore();
             }
         }
     }
 
-    paint->drawEllipse(QRectF(x0, fh, size, size));
+    if (isClosingCommit()) {
+        paint->drawRect(QRectF(x0, fh, size, size));
+    } else {
+        paint->drawEllipse(QRectF(x0, fh, size, size));
+    }
 
     if (m_showBranch) {
 	// write branch name
--- a/src/changesetitem.h	Tue Oct 18 09:54:21 2011 +0100
+++ b/src/changesetitem.h	Tue Oct 18 11:10:20 2011 +0100
@@ -51,9 +51,15 @@
     bool isCurrent() const { return m_current; }
     void setCurrent(bool c) { m_current = c; }
 
+    // Closed is true if this changeset is on a closed branch
     bool isClosed() const { return m_closed; }
     void setClosed(bool c) { m_closed = c; }
 
+    // Closing is true if this changeset is the commit that closed its
+    // branch (i.e. is at the end of a closed branch)
+    bool isClosingCommit() const { return m_closing; }
+    void setClosingCommit(bool c) { m_closing = c; }
+
     bool isNew() const { return m_new; }
     void setNew(bool n) { m_new = n; }
 
@@ -102,6 +108,7 @@
     bool m_wide;
     bool m_current;
     bool m_closed;
+    bool m_closing;
     bool m_new;
 
     QMap<QAction *, QString> m_parentDiffActions;
@@ -111,7 +118,7 @@
 
     bool isMerge() const;
     void paintNormal(QPainter *);
-    void paintMerge(QPainter *);
+    void paintSimple(QPainter *);
 };
 
 #endif // CHANGESETITEM_H
--- a/src/grapher.cpp	Tue Oct 18 09:54:21 2011 +0100
+++ b/src/grapher.cpp	Tue Oct 18 11:10:20 2011 +0100
@@ -444,6 +444,8 @@
         Changeset *cs = m_changesets[closedId];
         ChangesetItem *item = m_items[closedId];
 
+        item->setClosingCommit(true);
+
         while (cs && item) {
 
             if (cs->children().size() > 1) {