From 6e8e9979d0786d7d730528c2888e0e1af4fb96ca Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 9 Feb 2018 15:22:03 +0100 Subject: Make sure we can build with -no-feature-itemmodel Various pieces of code have to be disabled in this case. Change-Id: I83b133f17e9f024016a79c9103293627185449d2 Reviewed-by: Oswald Buddenhagen --- src/corelib/global/qconfig-bootstrapped.h | 1 + src/corelib/itemmodels/itemmodels.pri | 48 +++++++++++++++----- src/corelib/itemmodels/qabstractitemmodel.h | 2 + src/corelib/itemmodels/qabstractitemmodel_p.h | 2 + src/corelib/itemmodels/qabstractproxymodel.cpp | 5 --- src/corelib/itemmodels/qabstractproxymodel.h | 7 +-- src/corelib/itemmodels/qabstractproxymodel_p.h | 4 +- src/corelib/itemmodels/qidentityproxymodel.cpp | 5 --- src/corelib/itemmodels/qidentityproxymodel.h | 4 +- src/corelib/itemmodels/qitemselectionmodel.h | 2 + src/corelib/itemmodels/qitemselectionmodel_p.h | 2 + src/corelib/itemmodels/qsortfilterproxymodel.cpp | 5 --- src/corelib/itemmodels/qsortfilterproxymodel.h | 7 +-- src/corelib/itemmodels/qstringlistmodel.cpp | 4 -- src/corelib/itemmodels/qstringlistmodel.h | 7 +-- src/corelib/kernel/qmetatype.cpp | 9 +++- src/corelib/kernel/qmetatype.h | 11 ++++- src/corelib/kernel/qmetatype_p.h | 2 - src/corelib/kernel/qvariant.cpp | 56 ++++++++++++++---------- src/corelib/kernel/qvariant.h | 14 ++++-- 20 files changed, 114 insertions(+), 83 deletions(-) (limited to 'src/corelib') 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/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 #include +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 #include @@ -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 -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 @@ -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 -#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 #include +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 220c6be79e..78093727b8 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 #include @@ -2883,5 +2880,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 - -#ifndef QT_NO_SORTFILTERPROXYMODEL - #include +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 -#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 #include -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 518381712a..fc40668c9a 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 { static const bool IsAvailable = f template<> struct TypeDefinition { static const bool IsAvailable = false; }; template<> struct TypeDefinition { static const bool IsAvailable = false; }; template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; template<> struct TypeDefinition { static const bool IsAvailable = false; }; template<> struct TypeDefinition { 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(result); switch (d->type) { @@ -1952,12 +1956,6 @@ QVariant::QVariant(const QRegularExpression &re) QVariant::QVariant(const QUuid &uuid) : d(Uuid) { v_construct(&d, uuid); } -QVariant::QVariant(const QModelIndex &modelIndex) - : d(ModelIndex) -{ v_construct(&d, modelIndex); } -QVariant::QVariant(const QPersistentModelIndex &modelIndex) - : d(PersistentModelIndex) -{ v_construct(&d, modelIndex); } QVariant::QVariant(const QJsonValue &jsonValue) : d(QMetaType::QJsonValue) { v_construct(&d, jsonValue); } @@ -1971,6 +1969,14 @@ QVariant::QVariant(const QJsonDocument &jsonDocument) : d(QMetaType::QJsonDocument) { v_construct(&d, jsonDocument); } #endif // QT_BOOTSTRAPPED +#if QT_CONFIG(itemmodel) +QVariant::QVariant(const QModelIndex &modelIndex) + : d(ModelIndex) +{ v_construct(&d, modelIndex); } +QVariant::QVariant(const QPersistentModelIndex &modelIndex) + : d(PersistentModelIndex) +{ v_construct(&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(d, handlerManager); -} - +#if QT_CONFIG(itemmodel) /*! \since 5.0 @@ -2708,6 +2700,22 @@ QPersistentModelIndex QVariant::toPersistentModelIndex() const { return qVariantToHelper(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(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 361768ef00..9a5fc63d03 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); -- cgit v1.2.3