changeset 371:f051d210521e

Ensure current item is visible in graph after update
author Chris Cannam
date Thu, 24 Mar 2011 10:47:03 +0000
parents b9c153e00e84
children 2d3f1e5d8638 b6d36a17899d
files src/grapher.cpp src/grapher.h src/historywidget.cpp
diffstat 3 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/grapher.cpp	Thu Mar 24 10:27:51 2011 +0000
+++ b/src/grapher.cpp	Thu Mar 24 10:47:03 2011 +0000
@@ -363,8 +363,15 @@
 ChangesetItem *
 Grapher::getItemFor(Changeset *cs)
 {
-    if (!cs || !m_items.contains(cs->id())) return 0;
-    return m_items[cs->id()];
+    if (!cs) return 0;
+    return getItemFor(cs->id());
+}
+
+ChangesetItem *
+Grapher::getItemFor(QString id)
+{
+    if (!m_items.contains(id)) return 0;
+    return m_items[id];
 }
 
 void Grapher::layout(Changesets csets,
--- a/src/grapher.h	Thu Mar 24 10:27:51 2011 +0000
+++ b/src/grapher.h	Thu Mar 24 10:47:03 2011 +0000
@@ -39,6 +39,7 @@
                 QString uncommittedBranch);
 
     ChangesetItem *getItemFor(Changeset *cs);
+    ChangesetItem *getItemFor(QString id);
 
     UncommittedItem *getUncommittedItem() { return m_uncommitted; }
 
--- a/src/historywidget.cpp	Thu Mar 24 10:27:51 2011 +0000
+++ b/src/historywidget.cpp	Thu Mar 24 10:47:03 2011 +0000
@@ -184,7 +184,11 @@
 	}
         toFocus = g.getUncommittedItem();
         if (!toFocus) {
-            toFocus = g.getItemFor(m_changesets[0]);
+            if (!m_currentIds.empty()) {
+                toFocus = g.getItemFor(m_currentIds[0]);
+            } else {
+                toFocus = g.getItemFor(m_changesets[0]);
+            }
         }
     }