changeset 139:e8a481789607

* Avoid unnecessary duplicate layout; fix off-by-one in resetting changeset children
author Chris Cannam
date Tue, 30 Nov 2010 14:27:34 +0000
parents a7dbc8e5b69d
children bad40d7e7a2b
files grapher.cpp historywidget.cpp
diffstat 2 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/grapher.cpp	Tue Nov 30 13:51:50 2010 +0000
+++ b/grapher.cpp	Tue Nov 30 14:27:34 2010 +0000
@@ -196,6 +196,7 @@
     // connection lines
 
     foreach (QString childId, cs->children()) {
+        DEBUG << "reserving connection line space" << endl;
         if (!m_changesets.contains(childId)) continue;
         Changeset *child = m_changesets[childId];
         int childRow = m_items[childId]->row();
@@ -211,7 +212,6 @@
     // branch as us: split them to a little either side of our position
 
     if (nchildren > 1) {
-
         QList<QString> special;
         foreach (QString childId, cs->children()) {
             if (!m_changesets.contains(childId)) continue;
@@ -222,6 +222,7 @@
             }
         }
         if (special.size() == 2) {
+            DEBUG << "handling split-in-two for children " << special[0] << " and " << special[1] << endl;
             for (int i = 0; i < 2; ++i) {
                 int off = i * 2 - 1; // 0 -> -1, 1 -> 1
                 ChangesetItem *it = m_items[special[i]];
@@ -324,12 +325,14 @@
     m_alloc.clear();
     m_branchHomes.clear();
 
+    DEBUG << "Grapher::layout: Have " << csets.size() << " changesets" << endl;
+
     if (csets.empty()) return;
 
     foreach (Changeset *cs, csets) {
 
         QString id = cs->id();
-        DEBUG << id.toStdString() << endl;
+//        DEBUG << id.toStdString() << endl;
 
         if (id == "") {
             throw LayoutException("Changeset has no ID");
--- a/historywidget.cpp	Tue Nov 30 13:51:50 2010 +0000
+++ b/historywidget.cpp	Tue Nov 30 14:27:34 2010 +0000
@@ -70,8 +70,15 @@
 
 void HistoryWidget::showUncommittedChanges(bool show)
 {
+    if (m_uncommittedVisible == show) return;
     m_uncommittedVisible = show;
-    layoutAll();
+    QGraphicsScene *scene = m_panned->scene();
+    if (!scene) return;
+    if (m_uncommittedVisible) {
+        scene->addItem(m_uncommitted);
+    } else {
+        scene->removeItem(m_uncommitted);
+    }
 }
     
 void HistoryWidget::parseNewLog(QString log)
@@ -185,12 +192,15 @@
 
 void HistoryWidget::setChangesetParents()
 {
-    for (int i = 0; i+1 < m_changesets.size(); ++i) {
+    for (int i = 0; i < m_changesets.size(); ++i) {
         Changeset *cs = m_changesets[i];
         // Need to reset this, as Grapher::layout will recalculate it
         // and we don't want to end up with twice the children for
         // each parent...
         cs->setChildren(QStringList());
+    }
+    for (int i = 0; i+1 < m_changesets.size(); ++i) {
+        Changeset *cs = m_changesets[i];
         if (cs->parents().empty()) {
             QStringList list;
             list.push_back(m_changesets[i+1]->id());