view colourset.cpp @ 55:261bfb9481fe

* Make changeset item boxes wider if they have no neighbours. Changeset item code is horrible -- items generally need refactoring to take out hardcoded dimensions.
author Chris Cannam
date Fri, 12 Nov 2010 17:30:53 +0000
parents 3c46b2ac45d3
children f583e44d9d31
line wrap: on
line source

#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;
}