From c03781b0a6b7ed5ee58fbc623280f00c5cbe7b05 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Sat, 12 Oct 2019 22:59:04 +0200 Subject: [PATCH] Use ECMGenerateExportHeader to manage deprecated API better Summary: Allows * projects linking to KItemModels to hide deprecated API up to a given version or silence deprecation warnings after a given version, using * -DKITEMMODELS_DISABLE_DEPRECATED_BEFORE_AND_AT * -DKITEMMODELS_NO_DEPRECATED * -DKITEMMODELS_DEPRECATED_WARNINGS_SINCE * -DKITEMMODELS_NO_DEPRECATED_WARNINGS or * -DKF_DISABLE_DEPRECATED_BEFORE_AND_AT * -DKF_NO_DEPRECATED * -DKF_DEPRECATED_WARNINGS_SINCE * -DKF_NO_DEPRECATED_WARNINGS * to build KItemModels optionally with deprecated API excluded from the build, using "EXCLUDE_DEPRECATED_BEFORE_AND_AT" cmake argument. Test Plan: Builds with EXCLUDE_DEPRECATED_BEFORE_AND_AT set to 0, 4.8.0, CURRENT. Reviewers: #frameworks, dfaure, mlaurent Reviewed By: mlaurent Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D24600 --- CMakeLists.txt | 6 +++--- src/CMakeLists.txt | 14 +++++++++++++- src/kdescendantsproxymodel.cpp | 2 ++ src/kdescendantsproxymodel.h | 5 ++++- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b269f8e..ee5e0ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,13 +19,13 @@ include(ECMQtDeclareLoggingCategory) set(REQUIRED_QT_VERSION 5.11.0) find_package(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE) - -include(GenerateExportHeader) - +include(ECMGenerateExportHeader) include(ECMSetupVersion) include(ECMGenerateHeaders) include(ECMAddQch) +set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].") + option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF) add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e7427be..14fe279 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,8 +15,20 @@ set(kitemmodels_SRCS ecm_qt_declare_logging_category(kitemmodels_SRCS HEADER kitemmodels_debug.h IDENTIFIER KITEMMODELS_LOG CATEGORY_NAME kf5.kitemmodels) add_library(KF5ItemModels ${kitemmodels_SRCS}) -generate_export_header(KF5ItemModels BASE_NAME KItemModels) add_library(KF5::ItemModels ALIAS KF5ItemModels) +ecm_generate_export_header(KF5ItemModels + BASE_NAME KItemModels + # GROUP_BASE_NAME KF <- enable once all of KF modules use ecm_generate_export_header + VERSION ${KF5_VERSION} + DEPRECATED_BASE_VERSION 0 + DEPRECATION_VERSIONS 4.8 + EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT} +) +# reminder trigger to apply KITEMMODELS_ENABLE_DEPRECATED_SINCE & friends to KConcatenateRowsProxyModel when the time is there +if (REQUIRED_QT_VERSION VERSION_GREATER 5.12.0) + message(WARNING "With Qt 5.13 as min dep, mark KConcatenateRowsProxyModel as deprecated to the compiler & remove this warning") +endif() + target_include_directories(KF5ItemModels INTERFACE "$") diff --git a/src/kdescendantsproxymodel.cpp b/src/kdescendantsproxymodel.cpp index 1422b88..7bb716f 100644 --- a/src/kdescendantsproxymodel.cpp +++ b/src/kdescendantsproxymodel.cpp @@ -208,10 +208,12 @@ KDescendantsProxyModel::~KDescendantsProxyModel() delete d_ptr; } +#if KITEMMODELS_BUILD_DEPRECATED_SINCE(4, 8) void KDescendantsProxyModel::setRootIndex(const QModelIndex &index) { Q_UNUSED(index) } +#endif QModelIndexList KDescendantsProxyModel::match(const QModelIndex &start, int role, const QVariant &value, int hits, Qt::MatchFlags flags) const { diff --git a/src/kdescendantsproxymodel.h b/src/kdescendantsproxymodel.h index e70cc41..b813471 100644 --- a/src/kdescendantsproxymodel.h +++ b/src/kdescendantsproxymodel.h @@ -104,12 +104,15 @@ public: */ void setSourceModel(QAbstractItemModel *model) override; +#if KITEMMODELS_ENABLE_DEPRECATED_SINCE(4, 8) /** - * @deprecated + * @deprecated Since 4.8 * * This method does nothing. */ + KITEMMODELS_DEPRECATED_VERSION(4, 8, "Method is a no-op.") void setRootIndex(const QModelIndex &index); +#endif /** * Set whether to show ancestor data in the model. If @p display is true, then