changeset 51:bf3ab0ffb559

* some preliminaries for thinking about use of date in row layout
author Chris Cannam
date Thu, 11 Nov 2010 22:27:24 +0000
parents c76782c14371
children 384420567575
files changeset.h grapher.cpp grapher.h mainwindow.cpp
diffstat 4 files changed, 29 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/changeset.h	Thu Nov 11 22:04:59 2010 +0000
+++ b/changeset.h	Thu Nov 11 22:27:24 2010 +0000
@@ -14,7 +14,7 @@
     Q_PROPERTY(QString author READ author WRITE setAuthor NOTIFY authorChanged STORED true);
     Q_PROPERTY(QString branch READ branch WRITE setBranch NOTIFY branchChanged STORED true);
     Q_PROPERTY(QString tag READ tag WRITE setTag NOTIFY tagChanged STORED true);
-    Q_PROPERTY(QString date READ date WRITE setDate NOTIFY dateChanged STORED true);
+    Q_PROPERTY(QString datetime READ datetime WRITE setdatetime NOTIFY datetimeChanged STORED true);
     Q_PROPERTY(QString age READ age WRITE setAge NOTIFY ageChanged STORED true);
     Q_PROPERTY(QStringList parents READ parents WRITE setParents NOTIFY parentsChanged STORED true);
     Q_PROPERTY(QStringList children READ children WRITE setChildren NOTIFY childrenChanged STORED true);
@@ -27,7 +27,7 @@
     QString author() const { return m_author; }
     QString branch() const { return m_branch; }
     QString tag() const { return m_tag; }
-    QString date() const { return m_date; }
+    QString datetime() const { return m_datetime; }
     QString age() const { return m_age; }
     QStringList parents() const { return m_parents; }
     QStringList children() const { return m_children; }
@@ -42,12 +42,16 @@
 	return a.replace(QRegExp("\\s*<[^>]*>"), "");
     }
 
+    QString date() const {
+        return datetime().split(' ')[0];
+    }
+
 signals:
     void idChanged(QString id);
     void authorChanged(QString author);
     void branchChanged(QString branch);
     void tagChanged(QString tag);
-    void dateChanged(QString date);
+    void datetimeChanged(QString datetime);
     void ageChanged(QString age);
     void parentsChanged(QStringList parents);
     void childrenChanged(QStringList children);
@@ -58,7 +62,7 @@
     void setAuthor(QString author) { m_author = author; emit authorChanged(author); }
     void setBranch(QString branch) { m_branch = branch; emit branchChanged(branch); }
     void setTag(QString tag) { m_tag = tag; emit tagChanged(tag); }
-    void setDate(QString date) { m_date = date; emit dateChanged(date); }
+    void setdatetime(QString datetime) { m_datetime = datetime; emit datetimeChanged(datetime); }
     void setAge(QString age) { m_age = age; emit ageChanged(age); }
     void setParents(QStringList parents) { m_parents = parents; emit parentsChanged(parents); }
     void setChildren(QStringList children) { m_children = children; emit childrenChanged(m_children); }
@@ -70,7 +74,7 @@
     QString m_author;
     QString m_branch;
     QString m_tag;
-    QString m_date;
+    QString m_datetime;
     QString m_age;
     QStringList m_parents;
     QStringList m_children;
--- a/grapher.cpp	Thu Nov 11 22:04:59 2010 +0000
+++ b/grapher.cpp	Thu Nov 11 22:27:24 2010 +0000
@@ -164,27 +164,33 @@
     item->setColumn(col);
     m_handled.insert(id);
 
+    // Normally the children will lay out themselves, but we can do
+    // a better job in some special cases:
+
     int nchildren = cs->children().size();
 
     // look for merging children and make sure nobody
-    // is going to overwrite their "merge lines"
+    // is going to overwrite their "merge lines" if they extend further
+    // than a single step
+
     foreach (QString childId, cs->children()) {
         if (!m_changesets.contains(childId)) continue;
         Changeset *child = m_changesets[childId];
         if (child->parents().size() > 1) {
             int childRow = m_items[childId]->row();
             std::cerr << "I'm at " << row << ", child with >1 parents is at " << childRow << std::endl;
-            for (int r = row; r >= childRow; --r) {
+            for (int r = row; r > childRow; --r) {
                 std::cerr << "setting row " << r << ", col " << col << std::endl;
                 m_alloc[r].insert(col);
             }
         }
     }
 
+    // look for the case where exactly two children have the same
+    // branch as us: split them to a little either side of our position
+
     if (nchildren > 1) {
-	// Normally the children will lay out themselves.  We just
-	// want to handle the case where exactly two children have the
-	// same branch as us, because we can handle that neatly
+
 	QList<QString> special;
 	foreach (QString childId, cs->children()) {
 	    if (!m_changesets.contains(childId)) continue;
@@ -312,6 +318,11 @@
     // This ensures that parents will normally be laid out before
     // their children -- though we can recurse from layout() if we
     // find any weird exceptions
+
+    //!!! changesets are not in any chronological order, necessarily:
+    // we need to sort by datetime() [or, better, numerical date]
+    // and then use m_rowDateMap
+
     m_handled.clear();
     for (int i = csets.size() - 1; i >= 0; --i) {
 	layoutRow(csets[i]->id());
--- a/grapher.h	Thu Nov 11 22:04:59 2010 +0000
+++ b/grapher.h	Thu Nov 11 22:27:24 2010 +0000
@@ -51,6 +51,9 @@
     typedef QSet<QString> IdSet;
     IdSet m_handled;
 
+    typedef QMap<int, QString> RowDateMap;
+    RowDateMap m_rowDates;
+
     void layoutRow(QString id);
     void layoutCol(QString id);
     void allocateBranchHomes(Changesets csets);
--- a/mainwindow.cpp	Thu Nov 11 22:04:59 2010 +0000
+++ b/mainwindow.cpp	Thu Nov 11 22:27:24 2010 +0000
@@ -126,7 +126,7 @@
         QStringList params;
         params << "log";
         params << "--template";
-        params << "id: {rev}:{node|short}\\nauthor: {author}\\nbranch: {branches}\\ntag: {tag}\\ndate: {date|isodate}\\nage: {date|age}\\nparents: {parents}\\ncomment: {desc|json}\\n\\n";
+        params << "id: {rev}:{node|short}\\nauthor: {author}\\nbranch: {branches}\\ntag: {tag}\\ndatetime: {date|isodate}\\nage: {date|age}\\nparents: {parents}\\ncomment: {desc|json}\\n\\n";
 
         runner -> startProc(getHgBinaryName(), workFolderPath, params);
         runningAction = ACT_LOG;