diff options
Diffstat (limited to 'src/corelib')
27 files changed, 181 insertions, 188 deletions
diff --git a/src/corelib/Qt5Config.cmake.in b/src/corelib/Qt5Config.cmake.in index 75b53485b7..6b6544f932 100644 --- a/src/corelib/Qt5Config.cmake.in +++ b/src/corelib/Qt5Config.cmake.in @@ -1,6 +1,6 @@ -if (CMAKE_VERSION VERSION_LESS 2.8.9) - message(FATAL_ERROR \"Qt5 requires at least CMake version 2.8.9\") +if (CMAKE_VERSION VERSION_LESS 3.1.0) + message(FATAL_ERROR \"Qt5 requires at least CMake version 3.1.0\") endif() if (NOT Qt5_FIND_COMPONENTS) diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in index 545b9a3d1e..e0652fdcf9 100644 --- a/src/corelib/Qt5CoreConfigExtras.cmake.in +++ b/src/corelib/Qt5CoreConfigExtras.cmake.in @@ -78,27 +78,10 @@ set(Qt5_POSITION_INDEPENDENT_CODE True) # Applications now need to be compiled with the -fPIC option if the Qt option # \"reduce relocations\" is active. For backward compatibility only, Qt accepts # the use of -fPIE for GCC 4.x versions. -if (CMAKE_VERSION VERSION_LESS 2.8.12 - AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\" - OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)) - set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE \"ON\") -else() - set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_OPTIONS $$QMAKE_CXXFLAGS_APP) -endif() +set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_OPTIONS $$QMAKE_CXXFLAGS_APP) -# Applications using qmake or cmake >= 2.8.12 as their build system will -# adapt automatically. Applications using an older release of cmake in -# combination with GCC 5.x need to change their CMakeLists.txt to add -# Qt5Core_EXECUTABLE_COMPILE_FLAGS to CMAKE_CXX_FLAGS. In particular, -# applications using cmake >= 2.8.9 and < 2.8.11 will continue to build -# with the -fPIE option and invoke the special compatibility mode if using -# GCC 4.x. +# TODO Qt6: Remove set(Qt5Core_EXECUTABLE_COMPILE_FLAGS \"\") -if (CMAKE_VERSION VERSION_LESS 2.8.12 - AND (CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\" - AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)) - set(Qt5Core_EXECUTABLE_COMPILE_FLAGS \"-fPIC\") -endif() !!IF !isEmpty(QT_NAMESPACE) list(APPEND Qt5Core_DEFINITIONS -DQT_NAMESPACE=$$QT_NAMESPACE) @@ -157,7 +140,7 @@ if (NOT TARGET Qt5::WinMain) ) !!ENDIF - if (NOT CMAKE_VERSION VERSION_LESS 2.8.11 AND NOT Qt5_NO_LINK_QTMAIN) + if (NOT Qt5_NO_LINK_QTMAIN) set(_isExe $<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>) set(_isWin32 $<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>) set(_isNotExcluded $<NOT:$<BOOL:$<TARGET_PROPERTY:Qt5_NO_LINK_QTMAIN>>>) diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index 8d3dbe3ecf..1627de4002 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -152,9 +152,6 @@ function(QT5_GENERATE_MOC infile outfile ) set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}") endif() if ("x${ARGV2}" STREQUAL "xTARGET") - if (CMAKE_VERSION VERSION_LESS 2.8.12) - message(FATAL_ERROR "The TARGET parameter to qt5_generate_moc is only available when using CMake 2.8.12 or later.") - endif() set(moc_target ${ARGV3}) endif() qt5_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}" "") @@ -178,9 +175,6 @@ function(QT5_WRAP_CPP outfiles ) set(moc_target ${_WRAP_CPP_TARGET}) set(moc_depends ${_WRAP_CPP_DEPENDS}) - if (moc_target AND CMAKE_VERSION VERSION_LESS 2.8.12) - message(FATAL_ERROR "The TARGET parameter to qt5_wrap_cpp is only available when using CMake 2.8.12 or later.") - endif() foreach(it ${moc_files}) get_filename_component(it ${it} ABSOLUTE) qt5_make_output_file(${it} moc_ cpp outfile) @@ -300,54 +294,3 @@ function(QT5_ADD_RESOURCES outfiles ) endfunction() set(_Qt5_COMPONENT_PATH "${CMAKE_CURRENT_LIST_DIR}/..") - -if (NOT CMAKE_VERSION VERSION_LESS 2.8.9) - macro(qt5_use_modules _target _link_type) - if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.11) - if(CMAKE_WARN_DEPRECATED) - set(messageType WARNING) - endif() - if(CMAKE_ERROR_DEPRECATED) - set(messageType FATAL_ERROR) - endif() - if(messageType) - message(${messageType} "The qt5_use_modules macro is obsolete. Use target_link_libraries with IMPORTED targets instead.") - endif() - endif() - - if (NOT TARGET ${_target}) - message(FATAL_ERROR "The first argument to qt5_use_modules must be an existing target.") - endif() - if ("${_link_type}" STREQUAL "LINK_PUBLIC" OR "${_link_type}" STREQUAL "LINK_PRIVATE" ) - set(_qt5_modules ${ARGN}) - set(_qt5_link_type ${_link_type}) - else() - set(_qt5_modules ${_link_type} ${ARGN}) - endif() - - if ("${_qt5_modules}" STREQUAL "") - message(FATAL_ERROR "qt5_use_modules requires at least one Qt module to use.") - endif() - - foreach(_module ${_qt5_modules}) - if (NOT Qt5${_module}_FOUND) - find_package(Qt5${_module} PATHS "${_Qt5_COMPONENT_PATH}" NO_DEFAULT_PATH) - if (NOT Qt5${_module}_FOUND) - message(FATAL_ERROR "Can not use \"${_module}\" module which has not yet been found.") - endif() - endif() - target_link_libraries(${_target} ${_qt5_link_type} ${Qt5${_module}_LIBRARIES}) - set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${Qt5${_module}_INCLUDE_DIRS}) - set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS ${Qt5${_module}_COMPILE_DEFINITIONS}) - set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG) - set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG) - set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG) - if (Qt5_POSITION_INDEPENDENT_CODE - AND (CMAKE_VERSION VERSION_LESS 2.8.12 - AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU" - OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0))) - set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ${Qt5_POSITION_INDEPENDENT_CODE}) - endif() - endforeach() - endmacro() -endif() diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index 86ef1a2613..3469ebe5e6 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -87,6 +87,7 @@ #define QT_FEATURE_journald -1 #define QT_FEATURE_futimens -1 #define QT_FEATURE_futimes -1 +#define QT_FEATURE_itemmodel -1 #define QT_FEATURE_library -1 #ifdef __linux__ # define QT_FEATURE_linkat 1 diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 33b0b2eb66..3166fa1b83 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -676,8 +676,11 @@ QFile::rename(const QString &newName) return !error; } close(); + d->setError(QFile::RenameError, + tr("Cannot open destination file: %1").arg(out.errorString())); + } else { + d->setError(QFile::RenameError, errorString()); } - d->setError(QFile::RenameError, out.isOpen() ? errorString() : out.errorString()); } return false; } diff --git a/src/corelib/itemmodels/itemmodels.pri b/src/corelib/itemmodels/itemmodels.pri index 83ec4c5dbf..068a8c4b3a 100644 --- a/src/corelib/itemmodels/itemmodels.pri +++ b/src/corelib/itemmodels/itemmodels.pri @@ -1,20 +1,46 @@ # Qt itemmodels core module +!qtConfig(itemmodel): return() + HEADERS += \ itemmodels/qabstractitemmodel.h \ itemmodels/qabstractitemmodel_p.h \ - itemmodels/qabstractproxymodel.h \ - itemmodels/qabstractproxymodel_p.h \ itemmodels/qitemselectionmodel.h \ - itemmodels/qitemselectionmodel_p.h \ - itemmodels/qidentityproxymodel.h \ - itemmodels/qsortfilterproxymodel.h \ - itemmodels/qstringlistmodel.h + itemmodels/qitemselectionmodel_p.h SOURCES += \ itemmodels/qabstractitemmodel.cpp \ - itemmodels/qabstractproxymodel.cpp \ - itemmodels/qitemselectionmodel.cpp \ - itemmodels/qidentityproxymodel.cpp \ - itemmodels/qsortfilterproxymodel.cpp \ - itemmodels/qstringlistmodel.cpp + itemmodels/qitemselectionmodel.cpp + +qtConfig(proxymodel) { + HEADERS += \ + itemmodels/qabstractproxymodel.h \ + itemmodels/qabstractproxymodel_p.h + + SOURCES += \ + itemmodels/qabstractproxymodel.cpp + + qtConfig(identityproxymodel) { + HEADERS += \ + itemmodels/qidentityproxymodel.h + + SOURCES += \ + itemmodels/qidentityproxymodel.cpp + } + + qtConfig(sortfilterproxymodel) { + HEADERS += \ + itemmodels/qsortfilterproxymodel.h + + SOURCES += \ + itemmodels/qsortfilterproxymodel.cpp + } +} + +qtConfig(stringlistmodel) { + HEADERS += \ + itemmodels/qstringlistmodel.h + + SOURCES += \ + itemmodels/qstringlistmodel.cpp +} diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h index fca21b9bbc..21171124f9 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.h +++ b/src/corelib/itemmodels/qabstractitemmodel.h @@ -45,6 +45,8 @@ #include <QtCore/qhash.h> #include <QtCore/qvector.h> +QT_REQUIRE_CONFIG(itemmodel); + QT_BEGIN_NAMESPACE diff --git a/src/corelib/itemmodels/qabstractitemmodel_p.h b/src/corelib/itemmodels/qabstractitemmodel_p.h index 7086ae730a..12fd93d217 100644 --- a/src/corelib/itemmodels/qabstractitemmodel_p.h +++ b/src/corelib/itemmodels/qabstractitemmodel_p.h @@ -60,6 +60,8 @@ QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(itemmodel); + class QPersistentModelIndexData { public: diff --git a/src/corelib/itemmodels/qabstractproxymodel.cpp b/src/corelib/itemmodels/qabstractproxymodel.cpp index 39bfdd7782..b7c49a53e4 100644 --- a/src/corelib/itemmodels/qabstractproxymodel.cpp +++ b/src/corelib/itemmodels/qabstractproxymodel.cpp @@ -38,9 +38,6 @@ ****************************************************************************/ #include "qabstractproxymodel.h" - -#ifndef QT_NO_PROXYMODEL - #include "qitemselectionmodel.h" #include <private/qabstractproxymodel_p.h> #include <QtCore/QSize> @@ -471,5 +468,3 @@ Qt::DropActions QAbstractProxyModel::supportedDropActions() const QT_END_NAMESPACE #include "moc_qabstractproxymodel.cpp" - -#endif // QT_NO_PROXYMODEL diff --git a/src/corelib/itemmodels/qabstractproxymodel.h b/src/corelib/itemmodels/qabstractproxymodel.h index 6aa82b21ee..c4e5d67908 100644 --- a/src/corelib/itemmodels/qabstractproxymodel.h +++ b/src/corelib/itemmodels/qabstractproxymodel.h @@ -42,10 +42,9 @@ #include <QtCore/qabstractitemmodel.h> -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(proxymodel); -#ifndef QT_NO_PROXYMODEL +QT_BEGIN_NAMESPACE class QAbstractProxyModelPrivate; class QItemSelection; @@ -112,8 +111,6 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_sourceModelDestroyed()) }; -#endif // QT_NO_PROXYMODEL - QT_END_NAMESPACE #endif // QABSTRACTPROXYMODEL_H diff --git a/src/corelib/itemmodels/qabstractproxymodel_p.h b/src/corelib/itemmodels/qabstractproxymodel_p.h index 929bf1eb75..3a9f33baba 100644 --- a/src/corelib/itemmodels/qabstractproxymodel_p.h +++ b/src/corelib/itemmodels/qabstractproxymodel_p.h @@ -54,7 +54,7 @@ #include "private/qabstractitemmodel_p.h" -#ifndef QT_NO_PROXYMODEL +QT_REQUIRE_CONFIG(proxymodel); QT_BEGIN_NAMESPACE @@ -71,6 +71,4 @@ public: QT_END_NAMESPACE -#endif // QT_NO_PROXYMODEL - #endif // QABSTRACTPROXYMODEL_P_H diff --git a/src/corelib/itemmodels/qidentityproxymodel.cpp b/src/corelib/itemmodels/qidentityproxymodel.cpp index 7c306799d0..e984ec194e 100644 --- a/src/corelib/itemmodels/qidentityproxymodel.cpp +++ b/src/corelib/itemmodels/qidentityproxymodel.cpp @@ -38,9 +38,6 @@ ****************************************************************************/ #include "qidentityproxymodel.h" - -#ifndef QT_NO_IDENTITYPROXYMODEL - #include "qitemselectionmodel.h" #include <private/qabstractproxymodel_p.h> @@ -616,5 +613,3 @@ void QIdentityProxyModelPrivate::_q_sourceRowsRemoved(const QModelIndex &parent, QT_END_NAMESPACE #include "moc_qidentityproxymodel.cpp" - -#endif // QT_NO_IDENTITYPROXYMODEL diff --git a/src/corelib/itemmodels/qidentityproxymodel.h b/src/corelib/itemmodels/qidentityproxymodel.h index d2b1ed9498..3e6f5e4c48 100644 --- a/src/corelib/itemmodels/qidentityproxymodel.h +++ b/src/corelib/itemmodels/qidentityproxymodel.h @@ -43,7 +43,7 @@ #include <QtCore/qabstractproxymodel.h> -#ifndef QT_NO_IDENTITYPROXYMODEL +QT_REQUIRE_CONFIG(identityproxymodel); QT_BEGIN_NAMESPACE @@ -110,7 +110,5 @@ private: QT_END_NAMESPACE -#endif // QT_NO_IDENTITYPROXYMODEL - #endif // QIDENTITYPROXYMODEL_H diff --git a/src/corelib/itemmodels/qitemselectionmodel.h b/src/corelib/itemmodels/qitemselectionmodel.h index 091c5a21a5..63e5f0ca9c 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.h +++ b/src/corelib/itemmodels/qitemselectionmodel.h @@ -47,6 +47,8 @@ #include <QtCore/qlist.h> #include <QtCore/qabstractitemmodel.h> +QT_REQUIRE_CONFIG(itemmodel); + QT_BEGIN_NAMESPACE class Q_CORE_EXPORT QItemSelectionRange diff --git a/src/corelib/itemmodels/qitemselectionmodel_p.h b/src/corelib/itemmodels/qitemselectionmodel_p.h index dfc0387563..187d4a2c1d 100644 --- a/src/corelib/itemmodels/qitemselectionmodel_p.h +++ b/src/corelib/itemmodels/qitemselectionmodel_p.h @@ -53,6 +53,8 @@ #include "private/qobject_p.h" +QT_REQUIRE_CONFIG(itemmodel); + QT_BEGIN_NAMESPACE class QItemSelectionModelPrivate: public QObjectPrivate diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index c99a06fad8..0025c60c3b 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -38,9 +38,6 @@ ****************************************************************************/ #include "qsortfilterproxymodel.h" - -#ifndef QT_NO_SORTFILTERPROXYMODEL - #include "qitemselectionmodel.h" #include <qsize.h> #include <qdebug.h> @@ -2896,5 +2893,3 @@ QItemSelection QSortFilterProxyModel::mapSelectionFromSource(const QItemSelectio QT_END_NAMESPACE #include "moc_qsortfilterproxymodel.cpp" - -#endif // QT_NO_SORTFILTERPROXYMODEL diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.h b/src/corelib/itemmodels/qsortfilterproxymodel.h index 196dab2770..907ceb8e6d 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.h +++ b/src/corelib/itemmodels/qsortfilterproxymodel.h @@ -41,11 +41,10 @@ #define QSORTFILTERPROXYMODEL_H #include <QtCore/qabstractproxymodel.h> - -#ifndef QT_NO_SORTFILTERPROXYMODEL - #include <QtCore/qregexp.h> +QT_REQUIRE_CONFIG(sortfilterproxymodel); + QT_BEGIN_NAMESPACE @@ -198,6 +197,4 @@ private: QT_END_NAMESPACE -#endif // QT_NO_SORTFILTERPROXYMODEL - #endif // QSORTFILTERPROXYMODEL_H diff --git a/src/corelib/itemmodels/qstringlistmodel.cpp b/src/corelib/itemmodels/qstringlistmodel.cpp index bcfd88fb19..567e6fa35e 100644 --- a/src/corelib/itemmodels/qstringlistmodel.cpp +++ b/src/corelib/itemmodels/qstringlistmodel.cpp @@ -47,8 +47,6 @@ #include <algorithm> -#ifndef QT_NO_STRINGLISTMODEL - QT_BEGIN_NAMESPACE /*! @@ -329,5 +327,3 @@ Qt::DropActions QStringListModel::supportedDropActions() const QT_END_NAMESPACE #include "moc_qstringlistmodel.cpp" - -#endif // QT_NO_STRINGLISTMODEL diff --git a/src/corelib/itemmodels/qstringlistmodel.h b/src/corelib/itemmodels/qstringlistmodel.h index 38da1022ea..a40c13ae40 100644 --- a/src/corelib/itemmodels/qstringlistmodel.h +++ b/src/corelib/itemmodels/qstringlistmodel.h @@ -43,10 +43,9 @@ #include <QtCore/qabstractitemmodel.h> #include <QtCore/qstringlist.h> -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(stringlistmodel); -#ifndef QT_NO_STRINGLISTMODEL +QT_BEGIN_NAMESPACE class Q_CORE_EXPORT QStringListModel : public QAbstractListModel { @@ -78,8 +77,6 @@ private: QStringList lst; }; -#endif // QT_NO_STRINGLISTMODEL - QT_END_NAMESPACE #endif // QSTRINGLISTMODEL_H diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index ebe1813ec2..0e57cb8cba 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -61,7 +61,6 @@ # include "qbitarray.h" # include "qurl.h" # include "qvariant.h" -# include "qabstractitemmodel.h" # include "qjsonvalue.h" # include "qjsonobject.h" # include "qjsonarray.h" @@ -69,6 +68,10 @@ # include "qbytearraylist.h" #endif +#if QT_CONFIG(itemmodel) +# include "qabstractitemmodel.h" +#endif + #ifndef QT_NO_GEOM_VARIANT # include "qsize.h" # include "qpoint.h" @@ -1349,8 +1352,10 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data) case QMetaType::Void: case QMetaType::VoidStar: case QMetaType::QObjectStar: +#if QT_CONFIG(itemmodel) case QMetaType::QModelIndex: case QMetaType::QPersistentModelIndex: +#endif case QMetaType::QJsonValue: case QMetaType::QJsonObject: case QMetaType::QJsonArray: @@ -1573,8 +1578,10 @@ bool QMetaType::load(QDataStream &stream, int type, void *data) case QMetaType::Void: case QMetaType::VoidStar: case QMetaType::QObjectStar: +#if QT_CONFIG(itemmodel) case QMetaType::QModelIndex: case QMetaType::QPersistentModelIndex: +#endif case QMetaType::QJsonValue: case QMetaType::QJsonObject: case QMetaType::QJsonArray: diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 4674efe568..a0969ee908 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -89,6 +89,14 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId(); #define QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(F)\ F(VoidStar, 31, void*) \ +#if QT_CONFIG(itemmodel) +#define QT_FOR_EACH_STATIC_ITEMMODEL_CLASS(F)\ + F(QModelIndex, 42, QModelIndex) \ + F(QPersistentModelIndex, 50, QPersistentModelIndex) +#else +#define QT_FOR_EACH_STATIC_ITEMMODEL_CLASS(F) +#endif + #define QT_FOR_EACH_STATIC_CORE_CLASS(F)\ F(QChar, 7, QChar) \ F(QString, 10, QString) \ @@ -112,13 +120,12 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId(); F(QEasingCurve, 29, QEasingCurve) \ F(QUuid, 30, QUuid) \ F(QVariant, 41, QVariant) \ - F(QModelIndex, 42, QModelIndex) \ F(QRegularExpression, 44, QRegularExpression) \ F(QJsonValue, 45, QJsonValue) \ F(QJsonObject, 46, QJsonObject) \ F(QJsonArray, 47, QJsonArray) \ F(QJsonDocument, 48, QJsonDocument) \ - F(QPersistentModelIndex, 50, QPersistentModelIndex) \ + QT_FOR_EACH_STATIC_ITEMMODEL_CLASS(F) #define QT_FOR_EACH_STATIC_CORE_POINTER(F)\ F(QObjectStar, 39, QObject*) diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h index 0bf6bcb922..cef20a5d12 100644 --- a/src/corelib/kernel/qmetatype_p.h +++ b/src/corelib/kernel/qmetatype_p.h @@ -201,8 +201,6 @@ template<> struct TypeDefinition<QJsonArray> { static const bool IsAvailable = f template<> struct TypeDefinition<QJsonDocument> { static const bool IsAvailable = false; }; template<> struct TypeDefinition<QJsonObject> { static const bool IsAvailable = false; }; template<> struct TypeDefinition<QJsonValue> { static const bool IsAvailable = false; }; -template<> struct TypeDefinition<QModelIndex> { static const bool IsAvailable = false; }; -template<> struct TypeDefinition<QPersistentModelIndex> { static const bool IsAvailable = false; }; template<> struct TypeDefinition<QUrl> { static const bool IsAvailable = false; }; template<> struct TypeDefinition<QByteArrayList> { static const bool IsAvailable = false; }; #endif diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index c3c36e05d7..b3a86576af 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -56,8 +56,10 @@ #include "qurl.h" #include "qlocale.h" #include "quuid.h" -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(itemmodel) #include "qabstractitemmodel.h" +#endif +#ifndef QT_BOOTSTRAPPED #include "qjsonvalue.h" #include "qjsonobject.h" #include "qjsonarray.h" @@ -393,6 +395,8 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) return false; } break; +#endif // QT_BOOTSTRAPPED +#if QT_CONFIG(itemmodel) case QVariant::ModelIndex: switch (d->type) { case QVariant::PersistentModelIndex: @@ -411,7 +415,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) return false; } break; -#endif // QT_BOOTSTRAPPED +#endif // QT_CONFIG(itemmodel) case QVariant::String: { QString *str = static_cast<QString *>(result); switch (d->type) { @@ -1952,12 +1956,6 @@ QVariant::QVariant(const QRegularExpression &re) QVariant::QVariant(const QUuid &uuid) : d(Uuid) { v_construct<QUuid>(&d, uuid); } -QVariant::QVariant(const QModelIndex &modelIndex) - : d(ModelIndex) -{ v_construct<QModelIndex>(&d, modelIndex); } -QVariant::QVariant(const QPersistentModelIndex &modelIndex) - : d(PersistentModelIndex) -{ v_construct<QPersistentModelIndex>(&d, modelIndex); } QVariant::QVariant(const QJsonValue &jsonValue) : d(QMetaType::QJsonValue) { v_construct<QJsonValue>(&d, jsonValue); } @@ -1971,6 +1969,14 @@ QVariant::QVariant(const QJsonDocument &jsonDocument) : d(QMetaType::QJsonDocument) { v_construct<QJsonDocument>(&d, jsonDocument); } #endif // QT_BOOTSTRAPPED +#if QT_CONFIG(itemmodel) +QVariant::QVariant(const QModelIndex &modelIndex) + : d(ModelIndex) +{ v_construct<QModelIndex>(&d, modelIndex); } +QVariant::QVariant(const QPersistentModelIndex &modelIndex) + : d(PersistentModelIndex) +{ v_construct<QPersistentModelIndex>(&d, modelIndex); } +#endif /*! Returns the storage type of the value stored in the variant. @@ -2668,21 +2674,7 @@ QRegularExpression QVariant::toRegularExpression() const } #endif // QT_CONFIG(regularexpression) -#ifndef QT_BOOTSTRAPPED -/*! - \since 5.0 - - Returns the variant as a QUuid if the variant has type() - \l QMetaType::QUuid, \l QMetaType::QByteArray or \l QMetaType::QString; - otherwise returns a default-constructed QUuid. - - \sa canConvert(), convert() -*/ -QUuid QVariant::toUuid() const -{ - return qVariantToHelper<QUuid>(d, handlerManager); -} - +#if QT_CONFIG(itemmodel) /*! \since 5.0 @@ -2708,6 +2700,22 @@ QPersistentModelIndex QVariant::toPersistentModelIndex() const { return qVariantToHelper<QPersistentModelIndex>(d, handlerManager); } +#endif // QT_CONFIG(itemmodel) + +#ifndef QT_BOOTSTRAPPED +/*! + \since 5.0 + + Returns the variant as a QUuid if the variant has type() + \l QMetaType::QUuid, \l QMetaType::QByteArray or \l QMetaType::QString; + otherwise returns a default-constructed QUuid. + + \sa canConvert(), convert() +*/ +QUuid QVariant::toUuid() const +{ + return qVariantToHelper<QUuid>(d, handlerManager); +} /*! \since 5.0 @@ -3182,9 +3190,11 @@ bool QVariant::canConvert(int targetTypeId) const if (d.type == targetTypeId) return true; +#if QT_CONFIG(itemmodel) if ((targetTypeId == QMetaType::QModelIndex && d.type == QMetaType::QPersistentModelIndex) || (targetTypeId == QMetaType::QPersistentModelIndex && d.type == QMetaType::QModelIndex)) return true; +#endif if (targetTypeId == QMetaType::QVariantList && (d.type == QMetaType::QVariantList diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index b554ea4906..ff73c27b6e 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -165,8 +165,10 @@ class Q_CORE_EXPORT QVariant Hash = QMetaType::QVariantHash, EasingCurve = QMetaType::QEasingCurve, Uuid = QMetaType::QUuid, +#if QT_CONFIG(itemmodel) ModelIndex = QMetaType::QModelIndex, PersistentModelIndex = QMetaType::QPersistentModelIndex, +#endif LastCoreType = QMetaType::LastCoreType, Font = QMetaType::QFont, @@ -255,13 +257,15 @@ class Q_CORE_EXPORT QVariant QVariant(const QUrl &url); QVariant(const QEasingCurve &easing); QVariant(const QUuid &uuid); - QVariant(const QModelIndex &modelIndex); - QVariant(const QPersistentModelIndex &modelIndex); QVariant(const QJsonValue &jsonValue); QVariant(const QJsonObject &jsonObject); QVariant(const QJsonArray &jsonArray); QVariant(const QJsonDocument &jsonDocument); #endif // QT_BOOTSTRAPPED +#if QT_CONFIG(itemmodel) + QVariant(const QModelIndex &modelIndex); + QVariant(const QPersistentModelIndex &modelIndex); +#endif QVariant& operator=(const QVariant &other); #ifdef Q_COMPILER_RVALUE_REFS @@ -329,13 +333,15 @@ class Q_CORE_EXPORT QVariant QUrl toUrl() const; QEasingCurve toEasingCurve() const; QUuid toUuid() const; - QModelIndex toModelIndex() const; - QPersistentModelIndex toPersistentModelIndex() const; QJsonValue toJsonValue() const; QJsonObject toJsonObject() const; QJsonArray toJsonArray() const; QJsonDocument toJsonDocument() const; #endif // QT_BOOTSTRAPPED +#if QT_CONFIG(itemmodel) + QModelIndex toModelIndex() const; + QPersistentModelIndex toPersistentModelIndex() const; +#endif #ifndef QT_NO_DATASTREAM void load(QDataStream &ds); diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index 0b8fa4ca74..e66db58ed7 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -797,27 +797,60 @@ struct BezierEase : public QEasingCurveFunction return t3; } - qreal static inline findTForX(const SingleCubicBezier &singleCubicBezier, qreal x) - { - const qreal p0 = singleCubicBezier.p0x; - const qreal p1 = singleCubicBezier.p1x; - const qreal p2 = singleCubicBezier.p2x; - const qreal p3 = singleCubicBezier.p3x; - - const qreal factorT3 = p3 - p0 + 3 * p1 - 3 * p2; - const qreal factorT2 = 3 * p0 - 6 * p1 + 3 * p2; - const qreal factorT1 = -3 * p0 + 3 * p1; - const qreal factorT0 = p0 - x; - - const qreal a = factorT2 / factorT3; - const qreal b = factorT1 / factorT3; - const qreal c = factorT0 / factorT3; - - return singleRealSolutionForCubic(a, b, c); - - //one new iteration to increase numeric stability - //return newtonIteration(singleCubicBezier, t, x); - } + bool static inline almostZero(qreal value) + { + // 1e-3 might seem excessively fuzzy, but any smaller value will make the + // factors a, b, and c large enough to knock out the cubic solver. + return value > -1e-3 && value < 1e-3; + } + + qreal static inline findTForX(const SingleCubicBezier &singleCubicBezier, qreal x) + { + const qreal p0 = singleCubicBezier.p0x; + const qreal p1 = singleCubicBezier.p1x; + const qreal p2 = singleCubicBezier.p2x; + const qreal p3 = singleCubicBezier.p3x; + + const qreal factorT3 = p3 - p0 + 3 * p1 - 3 * p2; + const qreal factorT2 = 3 * p0 - 6 * p1 + 3 * p2; + const qreal factorT1 = -3 * p0 + 3 * p1; + const qreal factorT0 = p0 - x; + + // Cases for quadratic, linear and invalid equations + if (almostZero(factorT3)) { + if (almostZero(factorT2)) { + if (almostZero(factorT1)) + return 0.0; + + return -factorT0 / factorT1; + } + const qreal discriminant = factorT1 * factorT1 - 4.0 * factorT2 * factorT0; + if (discriminant < 0.0) + return 0.0; + + if (discriminant == 0.0) + return -factorT1 / (2.0 * factorT2); + + const qreal solution1 = (-factorT1 + std::sqrt(discriminant)) / (2.0 * factorT2); + if (solution1 >= 0.0 && solution1 <= 1.0) + return solution1; + + const qreal solution2 = (-factorT1 - std::sqrt(discriminant)) / (2.0 * factorT2); + if (solution2 >= 0.0 && solution2 <= 1.0) + return solution2; + + return 0.0; + } + + const qreal a = factorT2 / factorT3; + const qreal b = factorT1 / factorT3; + const qreal c = factorT0 / factorT3; + + return singleRealSolutionForCubic(a, b, c); + + //one new iteration to increase numeric stability + //return newtonIteration(singleCubicBezier, t, x); + } }; struct TCBEase : public BezierEase diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index bc22ea26f6..a6bd7847a5 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -176,11 +176,11 @@ public: inline QVarLengthArray<T, Prealloc> &operator<<(const T &t) { append(t); return *this; } inline QVarLengthArray<T, Prealloc> &operator<<(T &&t) - { append(t); return *this; } + { append(std::move(t)); return *this; } inline QVarLengthArray<T, Prealloc> &operator+=(const T &t) { append(t); return *this; } inline QVarLengthArray<T, Prealloc> &operator+=(T &&t) - { append(t); return *this; } + { append(std::move(t)); return *this; } void prepend(T &&t); void prepend(const T &t); diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index e4c7fd06d8..345ba4b097 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -284,9 +284,9 @@ public: inline QVector<T> &operator<<(const QVector<T> &l) { *this += l; return *this; } inline QVector<T> &operator+=(T &&t) - { append(t); return *this; } + { append(std::move(t)); return *this; } inline QVector<T> &operator<<(T &&t) - { append(t); return *this; } + { append(std::move(t)); return *this; } QList<T> toList() const; |