diff --git a/src/abstractstringserialiser.cpp b/src/abstractstringserialiser.cpp index e426eec..48adb25 100644 --- a/src/abstractstringserialiser.cpp +++ b/src/abstractstringserialiser.cpp @@ -47,32 +47,28 @@ QString AbstractStringSerialiserPrivate::guessDecimalsString(double val, QLocale return QString::number(val, 'f', guessDecimals(val)); } -QString AbstractStringSerialiserPrivate::variantToString(const QVariant &val) +QString AbstractStringSerialiserPrivate::variantToString(const QVariant &val) const { QByteArray data; QDataStream outStream(&data, QIODevice::WriteOnly); -#ifdef MS_DATASTREAM_VERSION - outStream.setVersion(MS_DATASTREAM_VERSION); -#endif // MS_DATASTREAM_VERSION + outStream.setVersion(m_streamVersion); outStream << val; data = qCompress(data); return QString::fromLatin1(data.toBase64()); } -QVariant AbstractStringSerialiserPrivate::stringToVariant(const QString &val) +QVariant AbstractStringSerialiserPrivate::stringToVariant(const QString &val) const { QByteArray data = QByteArray::fromBase64(val.toLatin1()); data = qUncompress(data); QDataStream inStream(data); -#ifdef MS_DATASTREAM_VERSION - inStream.setVersion(MS_DATASTREAM_VERSION); -#endif // MS_DATASTREAM_VERSION + inStream.setVersion(m_streamVersion); QVariant result; inStream >> result; return result; } -QVariant AbstractStringSerialiserPrivate::loadVariant(int type, const QString &val) +QVariant AbstractStringSerialiserPrivate::loadVariant(int type, const QString &val) const { if (val.isEmpty()) return QVariant(); @@ -150,7 +146,7 @@ QImage AbstractStringSerialiserPrivate::loadImageVariant(int type, const QString } #endif -QString AbstractStringSerialiserPrivate::saveVariant(const QVariant &val) +QString AbstractStringSerialiserPrivate::saveVariant(const QVariant &val) const { if (val.isNull()) return QString(); diff --git a/src/htmlmodelserialiser.cpp b/src/htmlmodelserialiser.cpp index 27ca57f..2f6c2f3 100644 --- a/src/htmlmodelserialiser.cpp +++ b/src/htmlmodelserialiser.cpp @@ -266,7 +266,7 @@ bool HtmlModelSerialiserPrivate::readHtml(QXmlStreamReader &reader) return true; } -void HtmlModelSerialiserPrivate::writeHtmlVariant(QXmlStreamWriter &writer, const QVariant &val) +void HtmlModelSerialiserPrivate::writeHtmlVariant(QXmlStreamWriter &writer, const QVariant &val) const { if (isImageType(val.userType())) { writer.writeEmptyElement(QStringLiteral("img")); @@ -277,7 +277,7 @@ void HtmlModelSerialiserPrivate::writeHtmlVariant(QXmlStreamWriter &writer, cons writer.writeCharacters(saveVariant(val)); } -QVariant HtmlModelSerialiserPrivate::readHtmlVariant(QXmlStreamReader &reader, int valType) +QVariant HtmlModelSerialiserPrivate::readHtmlVariant(QXmlStreamReader &reader, int valType) const { if (isImageType(valType)) { if (!reader.readNextStartElement()) diff --git a/src/private/abstractstringserialiser_p.h b/src/private/abstractstringserialiser_p.h index 2cb8180..c7ab029 100644 --- a/src/private/abstractstringserialiser_p.h +++ b/src/private/abstractstringserialiser_p.h @@ -21,18 +21,18 @@ class QTextCodec; #endif class AbstractStringSerialiserPrivate : public AbstractModelSerialiserPrivate { - Q_DISABLE_COPY(AbstractStringSerialiserPrivate); + Q_DISABLE_COPY(AbstractStringSerialiserPrivate) Q_DECLARE_PUBLIC(AbstractStringSerialiser) protected: AbstractStringSerialiserPrivate(AbstractStringSerialiser *q); - static QString variantToString(const QVariant &val); - static QVariant stringToVariant(const QString &val); + QString variantToString(const QVariant &val) const; + QVariant stringToVariant(const QString &val) const; #ifdef QT_GUI_LIB static QImage loadImageVariant(int type, const QString &val); static QString saveImageVariant(const QImage &val); #endif - static QVariant loadVariant(int type, const QString &val); - static QString saveVariant(const QVariant &val); + QVariant loadVariant(int type, const QString &val) const; + QString saveVariant(const QVariant &val) const; static int guessDecimals(double val); static QString guessDecimalsString(double val, QLocale *loca = Q_NULLPTR); #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) diff --git a/src/private/htmlmodelserialiser_p.h b/src/private/htmlmodelserialiser_p.h index 5a07301..a9ad89a 100644 --- a/src/private/htmlmodelserialiser_p.h +++ b/src/private/htmlmodelserialiser_p.h @@ -33,8 +33,8 @@ class HtmlModelSerialiserPrivate : public AbstractStringSerialiserPrivate { return val == QMetaType::QImage || val == QMetaType::QPixmap || val == QMetaType::QBitmap; } - static void writeHtmlVariant(QXmlStreamWriter &writer, const QVariant &val); - static QVariant readHtmlVariant(QXmlStreamReader &reader, int valType); + void writeHtmlVariant(QXmlStreamWriter &writer, const QVariant &val) const; + QVariant readHtmlVariant(QXmlStreamReader &reader, int valType) const; bool m_printStartDocument; }; #endif // htmlmodelserialiser_p_h__