Made QColor wrapper class so that Servatrice will compile without QtGui

This commit is contained in:
Max-Wilhelm Bruker 2010-10-09 18:50:06 +02:00
parent ee0a010add
commit b1d8c7bda0
19 changed files with 226 additions and 184 deletions

View file

@ -116,29 +116,19 @@ void SerializableItem_Bool::writeElement(QXmlStreamWriter *xml)
xml->writeCharacters(data ? "1" : "0");
}
int SerializableItem_Color::colorToInt(const QColor &color) const
{
return color.red() * 65536 + color.green() * 256 + color.blue();
}
QColor SerializableItem_Color::colorFromInt(int colorValue) const
{
return QColor(colorValue / 65536, (colorValue % 65536) / 256, colorValue % 256);
}
bool SerializableItem_Color::readElement(QXmlStreamReader *xml)
{
if (xml->isCharacters() && !xml->isWhitespace()) {
bool ok;
int colorValue = xml->text().toString().toInt(&ok);
data = ok ? colorFromInt(colorValue) : Qt::black;
data = ok ? Color(colorValue) : Color();
}
return SerializableItem::readElement(xml);
}
void SerializableItem_Color::writeElement(QXmlStreamWriter *xml)
{
xml->writeCharacters(QString::number(colorToInt(data)));
xml->writeCharacters(QString::number(data.getValue()));
}
bool SerializableItem_DateTime::readElement(QXmlStreamReader *xml)