diff colourset.cpp @ 53:3c46b2ac45d3

* Put proper labels &c in changeset items; colour branches and users; etc
author Chris Cannam
date Fri, 12 Nov 2010 16:48:18 +0000
parents
children f583e44d9d31
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/colourset.cpp	Fri Nov 12 16:48:18 2010 +0000
@@ -0,0 +1,35 @@
+
+#include "colourset.h"
+
+ColourSet
+ColourSet::m_instance;
+
+ColourSet::ColourSet() { }
+
+ColourSet *
+ColourSet::instance()
+{
+    return &m_instance;
+}
+
+QColor
+ColourSet::getColourFor(QString n)
+{
+    if (m_defaultNames.contains(n)) return Qt::black;
+    if (m_colours.contains(n)) return m_colours[n];
+
+    QColor c;
+
+    if (m_colours.empty()) {
+	c = QColor::fromHsv(0, 200, 100);
+    } else {
+	c = QColor::fromHsv((m_lastColour.hue() + 70) % 360, 200, 100);
+    }
+
+    m_colours[n] = c;
+    m_lastColour = c;
+    return c;
+}
+
+
+