Commit 38e0536c authored by Boudewijn Rempt's avatar Boudewijn Rempt

Add operator< to KoColor so we can use colors as keys in QMap

parent 5ab41992
......@@ -134,6 +134,15 @@ KoColor & KoColor::operator=(const KoColor & rhs)
return * this;
}
bool KoColor::operator<(const KoColor &other) const
{
QColor c = toQColor();
int gray = qGray(c.red(), c.green(), c.blue());
QColor c2 = other.toQColor();
return gray > qGray(c2.red(), c2.green(), c2.blue());
}
bool KoColor::operator==(const KoColor &other) const
{
if (!(*colorSpace() == *other.colorSpace()))
......
......@@ -67,6 +67,11 @@ public:
*/
KoColor &operator=(const KoColor &other);
/**
* @brief operator < compares the current color the other color and return true if this color is darker
*/
bool operator<(const KoColor &other) const;
bool operator==(const KoColor &other) const;
/// return the current colorSpace
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment