Item views: Fix 5.11 API review findings

Rename getter QHeaderView::firstSectionMovable()
to QHeaderView::isFirstSectionMovable(), turn into a property
and fix \since.

Change-Id: Ica2ca43d22f3fd78ff63178ba75014807fc9b823
Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
Friedemann Kleint 2018-03-14 10:16:00 +01:00
parent c0272f98df
commit 39d2a11a86
3 changed files with 13 additions and 14 deletions

View File

@ -1175,9 +1175,10 @@ bool QHeaderView::sectionsMovable() const
*/ */
/*! /*!
\since 5.10 \property QHeaderView::firstSectionMovable
\brief Whether the first column can be moved by the user
If \a movable is true, the first column can be moved by the user. This property controls whether the first column can be moved by the user.
In a QTreeView, the first column holds the tree structure and is In a QTreeView, the first column holds the tree structure and is
therefore non-movable by default, even after setSectionsMovable(true). therefore non-movable by default, even after setSectionsMovable(true).
@ -1186,8 +1187,11 @@ bool QHeaderView::sectionsMovable() const
In such a scenario, it is recommended to call QTreeView::setRootIsDecorated(false) In such a scenario, it is recommended to call QTreeView::setRootIsDecorated(false)
as well. as well.
This method has no effect unless setSectionsMovable(true) is called as well. Setting it to true has no effect unless setSectionsMovable(true) is called
as well.
\sa setSectionsMovable() \sa setSectionsMovable()
\since 5.11
*/ */
void QHeaderView::setFirstSectionMovable(bool movable) void QHeaderView::setFirstSectionMovable(bool movable)
{ {
@ -1195,13 +1199,7 @@ void QHeaderView::setFirstSectionMovable(bool movable)
d->allowUserMoveOfSection0 = movable; d->allowUserMoveOfSection0 = movable;
} }
/*! bool QHeaderView::isFirstSectionMovable() const
\since 5.10
Returns \c true if the first column can be moved by the user,
when this header is used in a QTreeView.
*/
bool QHeaderView::firstSectionMovable() const
{ {
Q_D(const QHeaderView); Q_D(const QHeaderView);
return d->allowUserMoveOfSection0; return d->allowUserMoveOfSection0;

View File

@ -53,6 +53,7 @@ class QStyleOptionHeader;
class Q_WIDGETS_EXPORT QHeaderView : public QAbstractItemView class Q_WIDGETS_EXPORT QHeaderView : public QAbstractItemView
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool firstSectionMovable READ isFirstSectionMovable WRITE setFirstSectionMovable)
Q_PROPERTY(bool showSortIndicator READ isSortIndicatorShown WRITE setSortIndicatorShown) Q_PROPERTY(bool showSortIndicator READ isSortIndicatorShown WRITE setSortIndicatorShown)
Q_PROPERTY(bool highlightSections READ highlightSections WRITE setHighlightSections) Q_PROPERTY(bool highlightSections READ highlightSections WRITE setHighlightSections)
Q_PROPERTY(bool stretchLastSection READ stretchLastSection WRITE setStretchLastSection) Q_PROPERTY(bool stretchLastSection READ stretchLastSection WRITE setStretchLastSection)
@ -119,7 +120,7 @@ public:
inline QT_DEPRECATED bool isMovable() const { return sectionsMovable(); } inline QT_DEPRECATED bool isMovable() const { return sectionsMovable(); }
#endif #endif
void setFirstSectionMovable(bool movable); void setFirstSectionMovable(bool movable);
bool firstSectionMovable() const; bool isFirstSectionMovable() const;
void setSectionsClickable(bool clickable); void setSectionsClickable(bool clickable);
bool sectionsClickable() const; bool sectionsClickable() const;

View File

@ -544,11 +544,11 @@ void tst_QHeaderView::movable()
view->setSectionsMovable(true); view->setSectionsMovable(true);
QCOMPARE(view->sectionsMovable(), true); QCOMPARE(view->sectionsMovable(), true);
QCOMPARE(view->firstSectionMovable(), true); QCOMPARE(view->isFirstSectionMovable(), true);
view->setFirstSectionMovable(false); view->setFirstSectionMovable(false);
QCOMPARE(view->firstSectionMovable(), false); QCOMPARE(view->isFirstSectionMovable(), false);
view->setFirstSectionMovable(true); view->setFirstSectionMovable(true);
QCOMPARE(view->firstSectionMovable(), true); QCOMPARE(view->isFirstSectionMovable(), true);
} }
void tst_QHeaderView::clickable() void tst_QHeaderView::clickable()