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
wilder
Friedrich W. H. Kossebau 7 years ago
parent 1c74538a9f
commit c03781b0a6
  1. 6
      CMakeLists.txt
  2. 14
      src/CMakeLists.txt
  3. 2
      src/kdescendantsproxymodel.cpp
  4. 5
      src/kdescendantsproxymodel.h

@ -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)")

@ -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 "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF5}/KItemModels>")

@ -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
{

@ -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

Loading…
Cancel
Save