diff --git a/src/xlsx/xlsxcolor.cpp b/src/xlsx/xlsxcolor.cpp index c34470b..6be2ae7 100644 --- a/src/xlsx/xlsxcolor.cpp +++ b/src/xlsx/xlsxcolor.cpp @@ -4,6 +4,7 @@ #include #include +#include namespace QXlsx { @@ -176,4 +177,21 @@ QDataStream &operator>>(QDataStream &s, XlsxColor &color) #endif +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug dbg, const XlsxColor &c) +{ + if (c.isInvalid()) + dbg.nospace() << "XlsxColor(invalid)"; + else if (c.isRgbColor()) + dbg.nospace() << c.rgbColor(); + else if (c.isIndexedColor()) + dbg.nospace() << "XlsxColor(indexed," << c.indexedColor() << ")"; + else if (c.isThemeColor()) + dbg.nospace() << "XlsxColor(theme," << c.themeColor().join(QLatin1Char(':')) << ")"; + + return dbg.space(); +} + +#endif + } // namespace QXlsx diff --git a/src/xlsx/xlsxcolor_p.h b/src/xlsx/xlsxcolor_p.h index a4081ae..9b4b3dc 100644 --- a/src/xlsx/xlsxcolor_p.h +++ b/src/xlsx/xlsxcolor_p.h @@ -48,7 +48,7 @@ namespace QXlsx { class Styles; -class XlsxColor +class Q_XLSX_EXPORT XlsxColor { public: explicit XlsxColor(const QColor &color = QColor()); @@ -77,8 +77,12 @@ private: }; #if !defined(QT_NO_DATASTREAM) -QDataStream &operator<<(QDataStream &, const XlsxColor &); -QDataStream &operator>>(QDataStream &, XlsxColor &); +Q_XLSX_EXPORT QDataStream &operator<<(QDataStream &, const XlsxColor &); +Q_XLSX_EXPORT QDataStream &operator>>(QDataStream &, XlsxColor &); +#endif + +#ifndef QT_NO_DEBUG_STREAM +Q_XLSX_EXPORT QDebug operator<<(QDebug dbg, const XlsxColor &c); #endif } // namespace QXlsx diff --git a/src/xlsx/xlsxformat.cpp b/src/xlsx/xlsxformat.cpp index 8d81c70..56e34f2 100755 --- a/src/xlsx/xlsxformat.cpp +++ b/src/xlsx/xlsxformat.cpp @@ -180,7 +180,14 @@ FormatPrivate::~FormatPrivate() */ Format::Format() { - qRegisterMetaTypeStreamOperators("XlsxColor"); + if (QMetaType::type("XlsxColor") == QMetaType::UnknownType) { + //Fix me! Where should we put these register code? + qRegisterMetaType("XlsxColor"); + qRegisterMetaTypeStreamOperators("XlsxColor"); +#if QT_VERSION >= 0x050200 + QMetaType::registerDebugStreamOperator(); +#endif + } //The d pointer is initialized with a null pointer }