diff --git a/LedOK/xlsx/xlsxchart.cpp b/LedOK/xlsx/xlsxchart.cpp index 89a51aa..1f2020f 100644 --- a/LedOK/xlsx/xlsxchart.cpp +++ b/LedOK/xlsx/xlsxchart.cpp @@ -265,7 +265,7 @@ bool ChartPrivate::loadXmlPlotArea(QXmlStreamReader &reader) bool ChartPrivate::loadXmlXxxChart(QXmlStreamReader &reader) { - QStringRef name = reader.name(); + auto name = reader.name(); if (name == QLatin1String("pieChart")) chartType = Chart::CT_Pie; else if (name == QLatin1String("pie3DChart")) @@ -314,7 +314,7 @@ bool ChartPrivate::loadXmlSer(QXmlStreamReader &reader) && !(reader.tokenType() == QXmlStreamReader::EndElement && reader.name() == QLatin1String("ser"))) { if (reader.readNextStartElement()) { - QStringRef name = reader.name(); + auto name = reader.name(); if (name == QLatin1String("cat") || name == QLatin1String("xVal")) { while (!reader.atEnd() && !(reader.tokenType() == QXmlStreamReader::EndElement @@ -613,7 +613,7 @@ bool ChartPrivate::loadXmlAxis(QXmlStreamReader &reader) if (reader.tokenType() == QXmlStreamReader::StartElement) { if (reader.name() == QLatin1String("axPos")) { QXmlStreamAttributes attrs = reader.attributes(); - QStringRef pos = attrs.value(QLatin1String("val")); + auto pos = attrs.value(QLatin1String("val")); if (pos == QLatin1String("l")) axis->axisPos = XlsxAxis::Left; else if (pos == QLatin1String("r")) diff --git a/LedOK/xlsx/xlsxcolor.cpp b/LedOK/xlsx/xlsxcolor.cpp index 0601ac8..fc9c3fe 100644 --- a/LedOK/xlsx/xlsxcolor.cpp +++ b/LedOK/xlsx/xlsxcolor.cpp @@ -111,7 +111,11 @@ bool XlsxColor::loadFromXml(QXmlStreamReader &reader) XlsxColor::operator QVariant() const { +#if(QT_VERSION_MAJOR > 5) + return QVariant::fromValue(this); +#else return QVariant(qMetaTypeId(), this); +#endif } QColor XlsxColor::fromARGBString(const QString &c) @@ -127,9 +131,7 @@ QColor XlsxColor::fromARGBString(const QString &c) QString XlsxColor::toARGBString(const QColor &c) { - QString color; - color.sprintf("%02X%02X%02X%02X", c.alpha(), c.red(), c.green(), c.blue()); - return color; + return QString::asprintf("%02X%02X%02X%02X", c.alpha(), c.red(), c.green(), c.blue()); } #if !defined(QT_NO_DATASTREAM) diff --git a/LedOK/xlsx/xlsxdocpropscore.cpp b/LedOK/xlsx/xlsxdocpropscore.cpp index b0a20aa..3c7fe35 100644 --- a/LedOK/xlsx/xlsxdocpropscore.cpp +++ b/LedOK/xlsx/xlsxdocpropscore.cpp @@ -151,8 +151,8 @@ bool DocPropsCore::loadFromXmlFile(QIODevice *device) while (!reader.atEnd()) { QXmlStreamReader::TokenType token = reader.readNext(); if (token == QXmlStreamReader::StartElement) { - const QStringRef nsUri = reader.namespaceUri(); - const QStringRef name = reader.name(); + const auto nsUri = reader.namespaceUri(); + const auto name = reader.name(); if (name == QStringLiteral("subject") && nsUri == dc) { setProperty(QStringLiteral("subject"), reader.readElementText()); } else if (name == QStringLiteral("title") && nsUri == dc) { diff --git a/LedOK/xlsx/xlsxformat.cpp b/LedOK/xlsx/xlsxformat.cpp index aa905ce..c0c710b 100644 --- a/LedOK/xlsx/xlsxformat.cpp +++ b/LedOK/xlsx/xlsxformat.cpp @@ -29,6 +29,10 @@ #include #include +#if(QT_VERSION_MAJOR < 6) +#define QIODeviceBase QIODevice +#endif + QT_BEGIN_NAMESPACE_XLSX FormatPrivate::FormatPrivate() @@ -544,7 +548,7 @@ QByteArray Format::fontKey() const if (d->font_dirty) { QByteArray key; - QDataStream stream(&key, QIODevice::WriteOnly); + QDataStream stream(&key, QIODeviceBase::WriteOnly); for (int i = FormatPrivate::P_Font_STARTID; i < FormatPrivate::P_Font_ENDID; ++i) { if (d->properties.contains(i)) stream << i << d->properties[i]; @@ -955,7 +959,7 @@ QByteArray Format::borderKey() const if (d->border_dirty) { QByteArray key; - QDataStream stream(&key, QIODevice::WriteOnly); + QDataStream stream(&key, QIODeviceBase::WriteOnly); for (int i = FormatPrivate::P_Border_STARTID; i < FormatPrivate::P_Border_ENDID; ++i) { if (d->properties.contains(i)) stream << i << d->properties[i]; @@ -1075,7 +1079,7 @@ QByteArray Format::fillKey() const if (d->fill_dirty) { QByteArray key; - QDataStream stream(&key, QIODevice::WriteOnly); + QDataStream stream(&key, QIODeviceBase::WriteOnly); for (int i = FormatPrivate::P_Fill_STARTID; i < FormatPrivate::P_Fill_ENDID; ++i) { if (d->properties.contains(i)) stream << i << d->properties[i]; @@ -1201,7 +1205,7 @@ QByteArray Format::formatKey() const if (d->dirty) { QByteArray key; - QDataStream stream(&key, QIODevice::WriteOnly); + QDataStream stream(&key, QIODeviceBase::WriteOnly); QMapIterator i(d->properties); while (i.hasNext()) { diff --git a/LedOK/xlsx/xlsxrichstring.cpp b/LedOK/xlsx/xlsxrichstring.cpp index 342ce2c..f1c962f 100644 --- a/LedOK/xlsx/xlsxrichstring.cpp +++ b/LedOK/xlsx/xlsxrichstring.cpp @@ -101,7 +101,11 @@ RichString &RichString::operator=(const RichString &other) */ RichString::operator QVariant() const { +#if(QT_VERSION_MAJOR > 5) + return QVariant::fromValue(this); +#else return QVariant(qMetaTypeId(), this); +#endif } /*! diff --git a/LedOK/xlsx/xlsxstyles.cpp b/LedOK/xlsx/xlsxstyles.cpp index f4c0c25..2b56229 100644 --- a/LedOK/xlsx/xlsxstyles.cpp +++ b/LedOK/xlsx/xlsxstyles.cpp @@ -50,6 +50,9 @@ Styles::Styles(CreateFlag flag) //! Fix me. Should the custom num fmt Id starts with 164 or 176 or others?? //! Fix me! Where should we put these register code? +#if(QT_VERSION_MAJOR > 5) + qRegisterMetaType("XlsxColor"); +#else if (QMetaType::type("XlsxColor") == QMetaType::UnknownType) { qRegisterMetaType("XlsxColor"); qRegisterMetaTypeStreamOperators("XlsxColor"); @@ -57,6 +60,7 @@ Styles::Styles(CreateFlag flag) QMetaType::registerDebugStreamOperator(); #endif } +#endif if (flag == F_NewFromScratch) { // Add default Format diff --git a/LedOK/xlsx/xlsxutility_p.h b/LedOK/xlsx/xlsxutility_p.h index 0281f41..e99006b 100644 --- a/LedOK/xlsx/xlsxutility_p.h +++ b/LedOK/xlsx/xlsxutility_p.h @@ -39,7 +39,9 @@ #include "xlsxglobal.h" class QPoint; class QString; +#if(QT_VERSION_MAJOR < 6) class QStringList; +#endif class QColor; class QDateTime; class QTime; diff --git a/LedOK/xlsx/xlsxworkbook.cpp b/LedOK/xlsx/xlsxworkbook.cpp index 7936ed6..21d95b1 100644 --- a/LedOK/xlsx/xlsxworkbook.cpp +++ b/LedOK/xlsx/xlsxworkbook.cpp @@ -578,9 +578,9 @@ bool Workbook::loadFromXmlFile(QIODevice *device) QXmlStreamAttributes attributes = reader.attributes(); const QString name = attributes.value(QLatin1String("name")).toString(); int sheetId = attributes.value(QLatin1String("sheetId")).toString().toInt(); - const QString rId = attributes.value(QLatin1String("r:id")).toString(); - const QStringRef &stateString = attributes.value(QLatin1String("state")); - AbstractSheet::SheetState state = AbstractSheet::SS_Visible; + const auto rId = attributes.value(QLatin1String("r:id")).toString(); + const auto &stateString = attributes.value(QLatin1String("state")); + auto state = AbstractSheet::SS_Visible; if (stateString == QLatin1String("hidden")) state = AbstractSheet::SS_Hidden; else if (stateString == QLatin1String("veryHidden"))