# HG changeset patch # User Chris Cannam # Date 1300963623 0 # Node ID f051d210521ee35a60313420162b46592716cdfa # Parent b9c153e00e84f63ccbd0b630c4d74601c208ccc2 Ensure current item is visible in graph after update diff -r b9c153e00e84 -r f051d210521e src/grapher.cpp --- 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, diff -r b9c153e00e84 -r f051d210521e src/grapher.h --- 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; } diff -r b9c153e00e84 -r f051d210521e src/historywidget.cpp --- 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]); + } } }