diff grapher.h @ 45:4286836bb3c9

* Some more work on graph layout; ensure LANG is set for parseable UTF8 output when running Hg
author Chris Cannam <cannam@all-day-breakfast.com>
date Wed, 10 Nov 2010 12:44:11 +0000
parents bed7ab59f62e
children bd3accba9b3f
line wrap: on
line diff
--- a/grapher.h	Tue Nov 09 17:51:12 2010 +0000
+++ b/grapher.h	Wed Nov 10 12:44:11 2010 +0000
@@ -4,12 +4,48 @@
 #include "changeset.h"
 #include "changesetitem.h"
 
-typedef QMap<Changeset *, ChangesetItem *> ChangesetItemMap;
+#include <QSet>
+#include <QMap>
+
+#include <exception>
 
 class Grapher
 {
 public:
-    void layout(Changesets csets, ChangesetItemMap items);
+    Grapher(QGraphicsScene *scene) { m_scene = scene; }
+
+    void layout(Changesets csets);
+
+    class LayoutException : public std::exception {
+    public:
+	LayoutException(QString message) throw() : m_message(message) { }
+	virtual ~LayoutException() throw() { }
+	virtual const char *what() const throw() {
+	    return m_message.toLocal8Bit().data();
+	}
+    protected:
+	QString m_message;
+    };
+
+private:
+    void layoutRow(QString id);
+    void layoutCol(QString id);
+    int findAvailableColumn(int row, int parent, bool preferParentCol);
+
+    QGraphicsScene *m_scene;
+
+    typedef QMap<QString, Changeset *> IdChangesetMap;
+    IdChangesetMap m_idCsetMap;
+
+    typedef QMap<QString, ChangesetItem *> IdItemMap;
+    IdItemMap m_items;
+
+    typedef QSet<int> ColumnSet;
+    typedef QMap<int, ColumnSet> GridAlloc;
+    GridAlloc m_alloc;
+
+    typedef QSet<QString> IdSet;
+    IdSet m_handled;
 };
 
 #endif