src/colors.cc

changeset 806
4240f47aa2d4
parent 797
4bd154b5d0bd
child 840
d077dd19bf9a
--- a/src/colors.cc	Mon Jun 16 18:31:13 2014 +0300
+++ b/src/colors.cc	Sun Jun 22 03:55:56 2014 +0300
@@ -28,7 +28,7 @@
 
 void initColors()
 {
-	LDColor col;
+	LDColorData* col;
 	print ("Initializing color information.\n");
 
 	// Always make sure there's 16 and 24 available. They're special like that.
@@ -79,18 +79,43 @@
 		if (index > 0x3000000)
 			col.setAlpha (128);
 
-		LDColor color (new LDColorData);
+		LDColorData* color = new LDColorData;
 		color->_name = "0x" + QString::number (index, 16).toUpper();
 		color->_faceColor = col;
 		color->_edgeColor = luma(col) < 48 ? Qt::white : Qt::black;
 		color->_hexcode = col.name();
 		color->_index = index;
-		return color;
+		return LDColor (color);
 	}
 
 	return null;
 }
 
+QString LDColor::indexString() const
+{
+	if (isDirect())
+		return "0x" + QString::number (index(), 16).toUpper();
+
+	return QString::number (index());
+}
+
+bool LDColor::isDirect() const
+{
+	return index() >= 0x02000000;
+}
+
+bool LDColor::operator== (LDColor const& other)
+{
+	if ((data() == nullptr) ^ (other == nullptr))
+		return false;
+
+	if (data() != nullptr)
+		return index() == other.index();
+
+	// both are null
+	return true;
+}
+
 int luma (const QColor& col)
 {
 	return (0.2126f * col.red()) +
@@ -102,16 +127,3 @@
 {
 	return countof (g_LDConfigColors);
 }
-
-QString LDColorData::indexString() const
-{
-	if (isDirect())
-		return "0x" + QString::number (_index, 16).toUpper();
-
-	return QString::number (_index);
-}
-
-bool LDColorData::isDirect() const
-{
-	return _index >= 0x02000000;
-}

mercurial