XlsxColor refactor
This commit is contained in:
+5
-10
@@ -9,8 +9,9 @@ namespace QXlsx {
|
|||||||
|
|
||||||
|
|
||||||
XlsxColor::XlsxColor(const QColor &color)
|
XlsxColor::XlsxColor(const QColor &color)
|
||||||
:val(color)
|
|
||||||
{
|
{
|
||||||
|
if (color.isValid())
|
||||||
|
val.setValue(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
XlsxColor::XlsxColor(const QString &theme, const QString &tint)
|
XlsxColor::XlsxColor(const QString &theme, const QString &tint)
|
||||||
@@ -44,9 +45,7 @@ bool XlsxColor::isThemeColor() const
|
|||||||
|
|
||||||
bool XlsxColor::isInvalid() const
|
bool XlsxColor::isInvalid() const
|
||||||
{
|
{
|
||||||
if (val.userType() == qMetaTypeId<QColor>() && !val.value<QColor>().isValid())
|
return !val.isValid();
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor XlsxColor::rgbColor() const
|
QColor XlsxColor::rgbColor() const
|
||||||
@@ -78,11 +77,7 @@ bool XlsxColor::saveToXml(QXmlStreamWriter &writer, const QString &node) const
|
|||||||
writer.writeEmptyElement(QStringLiteral("color"));
|
writer.writeEmptyElement(QStringLiteral("color"));
|
||||||
|
|
||||||
if (val.userType() == qMetaTypeId<QColor>()) {
|
if (val.userType() == qMetaTypeId<QColor>()) {
|
||||||
QColor color = val.value<QColor>();
|
writer.writeAttribute(QStringLiteral("rgb"), QStringLiteral("FF")+val.value<QColor>().name().mid(1));//remove #
|
||||||
if (color.isValid())
|
|
||||||
writer.writeAttribute(QStringLiteral("rgb"), QStringLiteral("FF")+color.name().mid(1));//remove #
|
|
||||||
else
|
|
||||||
writer.writeAttribute(QStringLiteral("auto"), QStringLiteral("1"));
|
|
||||||
} else if (val.userType() == QMetaType::QStringList) {
|
} else if (val.userType() == QMetaType::QStringList) {
|
||||||
QStringList themes = val.toStringList();
|
QStringList themes = val.toStringList();
|
||||||
writer.writeAttribute(QStringLiteral("theme"), themes[0]);
|
writer.writeAttribute(QStringLiteral("theme"), themes[0]);
|
||||||
@@ -91,7 +86,7 @@ bool XlsxColor::saveToXml(QXmlStreamWriter &writer, const QString &node) const
|
|||||||
} else if (val.userType() == QMetaType::Int) {
|
} else if (val.userType() == QMetaType::Int) {
|
||||||
writer.writeAttribute(QStringLiteral("indexed"), val.toString());
|
writer.writeAttribute(QStringLiteral("indexed"), val.toString());
|
||||||
} else {
|
} else {
|
||||||
return false;
|
writer.writeAttribute(QStringLiteral("auto"), QStringLiteral("1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user