diff --git a/templates/defaultfilters/datetime.cpp b/templates/defaultfilters/datetime.cpp index 444e374..e888f00 100644 --- a/templates/defaultfilters/datetime.cpp +++ b/templates/defaultfilters/datetime.cpp @@ -89,11 +89,11 @@ QVariant DateFilter::doFilter(const QVariant &input, const QVariant &argument, { Q_UNUSED(autoescape) QDateTime d; - if (input.type() == QVariant::DateTime) { + if (input.userType() == QMetaType::QDateTime) { d = input.toDateTime(); - } else if (input.type() == QVariant::Date) { + } else if (input.userType() == QMetaType::QDate) { d.setDate(input.toDate()); - } else if (input.type() == QVariant::Time) { + } else if (input.userType() == QMetaType::QTime) { d.setTime(input.toTime()); } else { #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) @@ -116,11 +116,11 @@ QVariant TimeFilter::doFilter(const QVariant &input, const QVariant &argument, { Q_UNUSED(autoescape) QDateTime d; - if (input.type() == QVariant::DateTime) { + if (input.userType() == QMetaType::QDateTime) { d = input.toDateTime(); - } else if (input.type() == QVariant::Date) { + } else if (input.userType() == QMetaType::QDate) { d.setDate(input.toDate()); - } else if (input.type() == QVariant::Time) { + } else if (input.userType() == QMetaType::QTime) { d.setTime(input.toTime()); } else { #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) diff --git a/templates/defaultfilters/integers.cpp b/templates/defaultfilters/integers.cpp index 48cea93..7c2d217 100644 --- a/templates/defaultfilters/integers.cpp +++ b/templates/defaultfilters/integers.cpp @@ -40,7 +40,7 @@ QVariant AddFilter::doFilter(const QVariant &input, const QVariant &argument, } if (input.userType() == qMetaTypeId()) { - if (argument == QVariant::StringList) + if (argument.userType() == QMetaType::QStringList) return input.toStringList() + argument.toStringList(); return input; } diff --git a/templates/defaultfilters/lists.cpp b/templates/defaultfilters/lists.cpp index a3f327c..09796db 100644 --- a/templates/defaultfilters/lists.cpp +++ b/templates/defaultfilters/lists.cpp @@ -179,8 +179,13 @@ QVariant MakeListFilter::doFilter(const QVariant &_input, auto input = _input; - if (input.userType() == qMetaTypeId()) - input.convert(QVariant::String); + if (input.userType() == qMetaTypeId()) { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + input.convert(QMetaType::QString); +#else + input.convert(QMetaType(QMetaType::QString)); +#endif + } if (input.userType() == qMetaTypeId() || input.userType() == qMetaTypeId()) { @@ -260,27 +265,27 @@ struct DictSortLessThan { const auto l = lp.first; const auto r = rp.first; switch (l.userType()) { - case QVariant::Invalid: + case QMetaType::UnknownType: return (r.isValid()); - case QVariant::Int: + case QMetaType::Int: return l.value() < r.value(); - case QVariant::UInt: + case QMetaType::UInt: return l.value() < r.value(); - case QVariant::LongLong: + case QMetaType::LongLong: return l.value() < r.value(); - case QVariant::ULongLong: + case QMetaType::ULongLong: return l.value() < r.value(); case QMetaType::Float: return l.value() < r.value(); - case QVariant::Double: + case QMetaType::Double: return l.value() < r.value(); - case QVariant::Char: + case QMetaType::Char: return l.toChar() < r.toChar(); - case QVariant::Date: + case QMetaType::QDate: return l.toDate() < r.toDate(); - case QVariant::Time: + case QMetaType::QTime: return l.toTime() < r.toTime(); - case QVariant::DateTime: + case QMetaType::QDateTime: return l.toDateTime() < r.toDateTime(); case QMetaType::QObjectStar: return l.value() < r.value(); diff --git a/templates/defaultfilters/stringfilters.cpp b/templates/defaultfilters/stringfilters.cpp index abbc491..96924db 100644 --- a/templates/defaultfilters/stringfilters.cpp +++ b/templates/defaultfilters/stringfilters.cpp @@ -388,12 +388,12 @@ QVariant FloatFormatFilter::doFilter(const QVariant &input, { Q_UNUSED(autoescape) double inputDouble; - switch (input.type()) { - case QVariant::Int: - case QVariant::UInt: - case QVariant::LongLong: - case QVariant::ULongLong: - case QVariant::Double: + switch (input.userType()) { + case QMetaType::Int: + case QMetaType::UInt: + case QMetaType::LongLong: + case QMetaType::ULongLong: + case QMetaType::Double: inputDouble = input.toDouble(); break; default: diff --git a/templates/lib/customtyperegistry.cpp b/templates/lib/customtyperegistry.cpp index f7f29f9..bdeaf98 100644 --- a/templates/lib/customtyperegistry.cpp +++ b/templates/lib/customtyperegistry.cpp @@ -62,7 +62,11 @@ QVariant CustomTypeRegistry::lookup(const QVariant &object, auto it = types.constFind(id); if (it == types.constEnd()) { qCWarning(CUTELEE_CUSTOMTYPE) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) << "Don't know how to handle metatype" << QMetaType::typeName(id); +#else + << "Don't know how to handle metatype" << QMetaType(id).name(); +#endif // :TODO: Print out error message return QVariant(); } @@ -70,7 +74,11 @@ QVariant CustomTypeRegistry::lookup(const QVariant &object, const CustomTypeInfo &info = it.value(); if (!info.lookupFunction) { qCWarning(CUTELEE_CUSTOMTYPE) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) << "No lookup function for metatype" << QMetaType::typeName(id); +#else + << "No lookup function for metatype" << QMetaType(id).name(); +#endif lf = 0; // :TODO: Print out error message return QVariant(); diff --git a/templates/lib/metatype.cpp b/templates/lib/metatype.cpp index cb36d43..29e4c6d 100644 --- a/templates/lib/metatype.cpp +++ b/templates/lib/metatype.cpp @@ -261,7 +261,11 @@ QVariant Cutelee::MetaType::lookup(const QVariant &object, return QVariant(); } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) auto mo = QMetaType::metaObjectForType(object.userType()); +#else + auto mo = QMetaType(object.userType()).metaObject(); +#endif if (mo) { QMetaType mt(object.userType()); if (mt.flags().testFlag(QMetaType::IsGadget)) { @@ -302,4 +306,4 @@ QVariant Cutelee::MetaType::lookup(const QVariant &object, bool Cutelee::MetaType::lookupAlreadyRegistered(int id) { return customTypes()->lookupAlreadyRegistered(id); -} \ No newline at end of file +} diff --git a/templates/lib/qtlocalizer.cpp b/templates/lib/qtlocalizer.cpp index 5495dec..d5d8a89 100644 --- a/templates/lib/qtlocalizer.cpp +++ b/templates/lib/qtlocalizer.cpp @@ -305,7 +305,11 @@ void QtLocalizer::pushLocale(const QString &localeName) localeStruct = new Locale(QLocale(localeName)); auto qtTranslator = new QTranslator; qtTranslator->load(QStringLiteral("qt_") + localeName, +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QLibraryInfo::location(QLibraryInfo::TranslationsPath)); +#else + QLibraryInfo::path(QLibraryInfo::TranslationsPath)); +#endif localeStruct->systemTranslators.append(qtTranslator); auto appTranslator = new QTranslator; appTranslator->load(d->m_appTranslatorPrefix + localeName, diff --git a/templates/lib/util.cpp b/templates/lib/util.cpp index 4666d69..2e9cb95 100644 --- a/templates/lib/util.cpp +++ b/templates/lib/util.cpp @@ -40,22 +40,22 @@ bool Cutelee::variantIsTrue(const QVariant &variant) if (!variant.isValid()) return false; switch (variant.userType()) { - case QVariant::Bool: { + case QMetaType::Bool: { return variant.toBool(); } - case QVariant::Int: { + case QMetaType::Int: { return variant.value() > 0; } - case QVariant::UInt: { + case QMetaType::UInt: { return variant.value() > 0; } - case QVariant::LongLong: { + case QMetaType::LongLong: { return variant.value() > 0; } - case QVariant::ULongLong: { + case QMetaType::ULongLong: { return variant.value() > 0; } - case QVariant::Double: { + case QMetaType::Double: { return variant.value() > 0; } case QMetaType::Float: { @@ -74,10 +74,10 @@ bool Cutelee::variantIsTrue(const QVariant &variant) } return true; } - case QVariant::List: { + case QMetaType::QVariantList: { return !variant.value().isEmpty(); } - case QVariant::Hash: { + case QMetaType::QVariantHash: { return !variant.value().isEmpty(); } } @@ -116,16 +116,16 @@ bool Cutelee::isSafeString(const QVariant &input) { const auto type = input.userType(); return ((type == qMetaTypeId()) - || type == QVariant::String); + || type == QMetaType::QString); } static QList getPrimitives() { QList primitives; - primitives << qMetaTypeId() << QVariant::String - << QVariant::Bool << QVariant::Int << QVariant::Double - << QMetaType::Float << QVariant::Date << QVariant::Time - << QVariant::DateTime; + primitives << qMetaTypeId() << QMetaType::QString + << QMetaType::Bool << QMetaType::Int << QMetaType::Double + << QMetaType::Float << QMetaType::QDate << QMetaType::QTime + << QMetaType::QDateTime; return primitives; } @@ -146,11 +146,11 @@ bool Cutelee::equals(const QVariant &lhs, const QVariant &rhs) if (rhs.userType() == qMetaTypeId()) { equal = (lhs.value() == rhs.value()); - } else if (rhs.userType() == QVariant::String) { + } else if (rhs.userType() == QMetaType::QString) { equal = (lhs.value() == rhs.toString()); } } else if (rhs.userType() == qMetaTypeId() - && lhs.userType() == QVariant::String) { + && lhs.userType() == QMetaType::QString) { equal = (rhs.value() == lhs.toString()); } else if (rhs.userType() == qMetaTypeId()) { if (lhs.userType() == qMetaTypeId()) { diff --git a/templates/tests/testbuiltins.cpp b/templates/tests/testbuiltins.cpp index 862f533..d4e20e7 100644 --- a/templates/tests/testbuiltins.cpp +++ b/templates/tests/testbuiltins.cpp @@ -293,7 +293,11 @@ void TestBuiltinSyntax::testObjects() SafeString s3(s1); Q_UNUSED(s3); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QMetaType::construct(qMetaTypeId(), 0, 0); +#else + QMetaType(qMetaTypeId()).construct(0, 0); +#endif } void TestBuiltinSyntax::testTruthiness_data() diff --git a/textdocument/lib/markupdirector.cpp b/textdocument/lib/markupdirector.cpp index 7cfd29c..0f93174 100644 --- a/textdocument/lib/markupdirector.cpp +++ b/textdocument/lib/markupdirector.cpp @@ -590,8 +590,12 @@ void MarkupDirector::processOpeningElements(QTextBlock::iterator it) d->m_openFontPointSize = fragmentFormat.font().pointSize(); break; case SpanFontFamily: - m_builder->beginFontFamily(fragmentFormat.fontFamily()); +#if QT_VERSION < QT_VERSION_CHECK(6, 1, 0) d->m_openFontFamily = fragmentFormat.fontFamily(); +#else + d->m_openFontFamily = fragmentFormat.fontFamilies().toStringList().first(); +#endif + m_builder->beginFontFamily(d->m_openFontFamily); break; case SpanBackground: m_builder->beginBackground(fragmentFormat.background()); @@ -669,7 +673,11 @@ QSet MarkupDirector::getElementsToClose(QTextBlock::iterator it) const auto fontForeground = fragmentFormat.foreground(); auto fontBackground = fragmentFormat.background(); +#if QT_VERSION < QT_VERSION_CHECK(6, 1, 0) auto fontFamily = fragmentFormat.fontFamily(); +#else + auto fontFamily = fragmentFormat.fontFamilies().toStringList().first(); +#endif auto fontPointSize = fragmentFormat.font().pointSize(); auto anchorHref = fragmentFormat.anchorHref(); @@ -767,7 +775,11 @@ QList MarkupDirector::getElementsToOpen(QTextBlock::iterator it) auto fontForeground = fragmentFormat.foreground(); auto fontBackground = fragmentFormat.background(); +#if QT_VERSION < QT_VERSION_CHECK(6, 1, 0) auto fontFamily = fragmentFormat.fontFamily(); +#else + auto fontFamily = fragmentFormat.fontFamilies().toStringList().first(); +#endif auto fontPointSize = fragmentFormat.font().pointSize(); auto anchorHref = fragmentFormat.anchorHref(); diff --git a/textdocument/tests/CMakeLists.txt b/textdocument/tests/CMakeLists.txt index e51fe6c..311b349 100644 --- a/textdocument/tests/CMakeLists.txt +++ b/textdocument/tests/CMakeLists.txt @@ -22,4 +22,3 @@ cutelee_textdocument_unit_tests( htmlbuildertest plainmarkupbuildertest ) -target_compile_definitions(plainmarkupbuildertest_exec PRIVATE QT_TESTCASE_BUILDDIR="${CMAKE_BINARY_DIR}")