From 376715f1a57209cbb19502954a37939e2d6d88c6 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Tue, 23 Jul 2019 15:26:19 +0200 Subject: Remove usages of deprecated APIs of qtbase/widgets - Replace the usages of deprecated APIs by corresponding alternatives in the library code and documentation. - Build docs for deprecated APIs conditionally, based on deprecation version. Remove the docs of methods deprecated since 5.0.0, these methods are not compiled anymore. - Modify the tests to make them build when deprecated APIs disabled: * Make the the parts of the tests testing the deprecated APIs to be compiled conditionally, only when the corresponding methods are enabled. * If the test-case tests only the deprecated API, but not the corresponding replacement, add tests for the replacement Task-number: QTBUG-76491 Task-number: QTBUG-76540 Task-number: QTBUG-76541 Change-Id: I6aaf0a1369c479fb880369a38f2b8e1e86b46934 Reviewed-by: Volker Hilsheimer --- src/widgets/itemviews/qheaderview.cpp | 80 +++------------------------------- src/widgets/itemviews/qlistwidget.cpp | 6 +++ src/widgets/itemviews/qtablewidget.cpp | 4 ++ src/widgets/itemviews/qtreewidget.cpp | 4 ++ 4 files changed, 19 insertions(+), 75 deletions(-) (limited to 'src/widgets/itemviews') diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index be80843b07..c4766a74bd 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -189,7 +189,7 @@ static const int maxSizeSection = 1048575; // since section size is in a bitfiel The following values are obsolete: \value Custom Use Fixed instead. - \sa setResizeMode(), setSectionResizeMode(), stretchLastSection, minimumSectionSize + \sa setSectionResizeMode(), stretchLastSection, minimumSectionSize */ /*! @@ -880,7 +880,7 @@ void QHeaderView::swapSections(int first, int second) size equal to zero is however not recommended. In that situation hideSection should be used instead. - \sa sectionResized(), resizeMode(), sectionSize(), hideSection() + \sa sectionResized(), sectionSize(), hideSection() */ void QHeaderView::resizeSection(int logical, int size) @@ -960,7 +960,7 @@ void QHeaderView::resizeSection(int logical, int size) Resizes the sections according to the given \a mode, ignoring the current resize mode. - \sa resizeMode(), sectionResized() + \sa sectionResized() */ void QHeaderView::resizeSections(QHeaderView::ResizeMode mode) @@ -1139,16 +1139,6 @@ void QHeaderView::setSectionsMovable(bool movable) d->movableSections = movable; } -// ### Qt 6 - remove this obsolete function -/*! - \obsolete - \fn void QHeaderView::setMovable(bool movable) - - Use setSectionsMovable instead. - - \sa setSectionsMovable() -*/ - /*! \since 5.0 @@ -1167,16 +1157,6 @@ bool QHeaderView::sectionsMovable() const return d->movableSections; } -// ### Qt 6 - remove this obsolete function -/*! - \obsolete - \fn bool QHeaderView::isMovable() const - - Use sectionsMovable instead. - - \sa sectionsMovable() -*/ - /*! \property QHeaderView::firstSectionMovable \brief Whether the first column can be moved by the user @@ -1223,16 +1203,6 @@ void QHeaderView::setSectionsClickable(bool clickable) d->clickableSections = clickable; } -// ### Qt 6 - remove this obsolete function -/*! - \obsolete - \fn void QHeaderView::setClickable(bool clickable) - - Use setSectionsClickable instead. - - \sa setSectionsClickable() -*/ - /*! \since 5.0 @@ -1249,16 +1219,6 @@ bool QHeaderView::sectionsClickable() const return d->clickableSections; } -// ### Qt 6 - remove this obsolete function -/*! - \obsolete - \fn bool QHeaderView::isClickable() const - - Use sectionsClickable instead. - - \sa sectionsClickable() -*/ - void QHeaderView::setHighlightSections(bool highlight) { Q_D(QHeaderView); @@ -1277,7 +1237,7 @@ bool QHeaderView::highlightSections() const Sets the constraints on how the header can be resized to those described by the given \a mode. - \sa resizeMode(), length(), sectionResized() + \sa length(), sectionResized() */ void QHeaderView::setSectionResizeMode(ResizeMode mode) @@ -1327,26 +1287,6 @@ void QHeaderView::setSectionResizeMode(int logicalIndex, ResizeMode mode) d->doDelayedResizeSections(); // section sizes may change as a result of the new mode } -// ### Qt 6 - remove this obsolete function -/*! - \overload - \obsolete - \fn void QHeaderView::setResizeMode(int logicalIndex, ResizeMode mode) - - Use setSectionResizeMode instead. - - \sa setSectionResizeMode() -*/ - -/*! - \obsolete - \fn void QHeaderView::setResizeMode(ResizeMode mode) - - Use setSectionResizeMode instead. - - \sa setSectionResizeMode() -*/ - /*! \since 5.0 @@ -1407,16 +1347,6 @@ int QHeaderView::resizeContentsPrecision() const return d->resizeContentsPrecision; } -// ### Qt 6 - remove this obsolete function -/*! - \obsolete - \fn QHeaderView::ResizeMode QHeaderView::resizeMode(int logicalIndex) const - - Use sectionResizeMode instead. - - \sa sectionResizeMode() -*/ - /*! \since 4.1 @@ -1424,7 +1354,7 @@ int QHeaderView::resizeContentsPrecision() const views, this can be used to see if the headerview needs to resize the sections when the view's geometry changes. - \sa stretchLastSection, resizeMode() + \sa stretchLastSection */ int QHeaderView::stretchSectionCount() const diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp index 37bb370e73..e7dcfac403 100644 --- a/src/widgets/itemviews/qlistwidget.cpp +++ b/src/widgets/itemviews/qlistwidget.cpp @@ -930,12 +930,14 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item) \sa Qt::AlignmentFlag */ +#if QT_DEPRECATED_SINCE(5, 13) /*! \fn QColor QListWidgetItem::backgroundColor() const \obsolete This function is deprecated. Use background() instead. */ +#endif /*! \fn QBrush QListWidgetItem::background() const @@ -946,6 +948,7 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item) \sa setBackground(), foreground() */ +#if QT_DEPRECATED_SINCE(5, 13) /*! \fn QColor QListWidgetItem::textColor() const \obsolete @@ -954,6 +957,7 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item) This function is deprecated. Use foreground() instead. */ +#endif /*! \fn QBrush QListWidgetItem::foreground() const @@ -1119,12 +1123,14 @@ void QListWidgetItem::setFlags(Qt::ItemFlags aflags) \sa background(), setForeground() */ +#if QT_DEPRECATED_SINCE(5, 13) /*! \fn void QListWidgetItem::setTextColor(const QColor &color) \obsolete This function is deprecated. Use setForeground() instead. */ +#endif /*! \fn void QListWidgetItem::setForeground(const QBrush &brush) diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp index 0fb9e28385..a25a582881 100644 --- a/src/widgets/itemviews/qtablewidget.cpp +++ b/src/widgets/itemviews/qtablewidget.cpp @@ -1251,6 +1251,7 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags) \sa font(), setText(), setForeground() */ +#if QT_DEPRECATED_SINCE(5, 13) /*! \fn QColor QTableWidgetItem::backgroundColor() const \obsolete @@ -1264,6 +1265,7 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags) This function is deprecated. Use setBackground() instead. */ +#endif /*! \fn QBrush QTableWidgetItem::background() const @@ -1283,6 +1285,7 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags) \sa setForeground() */ +#if QT_DEPRECATED_SINCE(5, 13) /*! \fn QColor QTableWidgetItem::textColor() const \obsolete @@ -1296,6 +1299,7 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags) This function is deprecated. Use setForeground() instead. */ +#endif /*! \fn QBrush QTableWidgetItem::foreground() const diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index d2dc91b18c..d285ad6d28 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -1251,6 +1251,7 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const \sa font(), setText(), setForeground() */ +#if QT_DEPRECATED_SINCE(5, 13) /*! \fn QColor QTreeWidgetItem::backgroundColor(int column) const \obsolete @@ -1264,6 +1265,7 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const This function is deprecated. Use setBackground() instead. */ +#endif /*! \fn QBrush QTreeWidgetItem::background(int column) const @@ -1284,6 +1286,7 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const \sa setForeground() */ +#if QT_DEPRECATED_SINCE(5, 13) /*! \fn QColor QTreeWidgetItem::textColor(int column) const \obsolete @@ -1297,6 +1300,7 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const This function is deprecated. Use setForeground() instead. */ +#endif /*! \fn QBrush QTreeWidgetItem::foreground(int column) const -- cgit v1.2.3