From b64426248d2212eb59535b2ca383d30fdb5e1c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Sat, 3 Mar 2012 06:05:54 +0100 Subject: QHeaderView - renaming functions in Qt5 This patch renames the functions in Qt5 according to the notes. It also renames resizeMode to be consistent. The old functions are both marked with both QT_DEPRECATED and '### Qt 6 - remove' All usage of the function within the qtbase are also changed to use the new functions. Change-Id: I9e05fa41d232e9ca43b945fcc949987017f3aedd Reviewed-by: Stephen Kelly --- src/widgets/itemviews/qheaderview.cpp | 124 ++++++++++++++++++++++++---------- 1 file changed, 89 insertions(+), 35 deletions(-) (limited to 'src/widgets/itemviews/qheaderview.cpp') diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index eac543d37d..766d7ce6b6 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -120,9 +120,9 @@ QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionSpan &span) \section1 Moving Header Sections - A header can be fixed in place, or made movable with setMovable(). It can - be made clickable with setClickable(), and has resizing behavior in - accordance with setResizeMode(). + A header can be fixed in place, or made movable with setSectionsMovable(). It can + be made clickable with setSectionsClickable(), and has resizing behavior in + accordance with setResizeMode() and setSectionResizeMode() \note Double-clicking on a header to resize a section only applies for visible rows. @@ -185,7 +185,7 @@ QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionSpan &span) The following values are obsolete: \value Custom Use Fixed instead. - \sa setResizeMode() stretchLastSection minimumSectionSize + \sa setResizeMode() setSectionResizeMode() stretchLastSection minimumSectionSize */ /*! @@ -216,7 +216,7 @@ QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionSpan &span) This signal is emitted when a section is pressed. The section's logical index is specified by \a logicalIndex. - \sa setClickable() + \sa setSectionsClickable() */ /*! @@ -227,7 +227,7 @@ QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionSpan &span) Note that the sectionPressed signal will also be emitted. - \sa setClickable(), sectionPressed() + \sa setSectionsClickable(), sectionPressed() */ /*! @@ -238,7 +238,7 @@ QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionSpan &span) mouse button is pressed. The section's logical index is specified by \a logicalIndex. - \sa setClickable(), sectionPressed() + \sa setSectionsClickable(), sectionPressed() */ /*! @@ -247,7 +247,7 @@ QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionSpan &span) This signal is emitted when a section is double-clicked. The section's logical index is specified by \a logicalIndex. - \sa setClickable() + \sa setSectionsClickable() */ /*! @@ -266,7 +266,7 @@ QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionSpan &span) This signal is emitted when a section is double-clicked. The section's logical index is specified by \a logicalIndex. - \sa setClickable() + \sa setSectionsClickable() */ /*! @@ -1085,62 +1085,98 @@ int QHeaderView::logicalIndex(int visualIndex) const } /*! - If \a movable is true, the header may be moved by the user; otherwise it + If \a sectionsMovable is true, the header may be moved by the user; otherwise it is fixed in place. - \sa isMovable(), sectionMoved() + \sa sectionsMovable(), sectionMoved() */ -// ### Qt 5: change to setSectionsMovable() -void QHeaderView::setMovable(bool movable) +void QHeaderView::setSectionsMovable(bool movable) { Q_D(QHeaderView); d->movableSections = movable; } +// ### Qt 6 - remove this obsolete function +/*! + \obsolete + \fn void QHeaderView::setMovable(bool movable) + + Use setSectionsMovable instead. + + \sa setSectionsMovable() +*/ + /*! Returns true if the header can be moved by the user; otherwise returns false. - \sa setMovable() + \sa setSectionsMovable() */ -// ### Qt 5: change to sectionsMovable() -bool QHeaderView::isMovable() const +bool QHeaderView::sectionsMovable() const { Q_D(const QHeaderView); return d->movableSections; } +// ### Qt 6 - remove this obsolete function +/*! + \obsolete + \fn bool QHeaderView::isMovable(bool movable) + + Use sectionsMovable instead. + + \sa sectionsMovable() +*/ + /*! If \a clickable is true, the header will respond to single clicks. - \sa isClickable(), sectionClicked(), sectionPressed(), + \sa sectionsClickable(), sectionClicked(), sectionPressed(), setSortIndicatorShown() */ -// ### Qt 5: change to setSectionsClickable() -void QHeaderView::setClickable(bool clickable) +void QHeaderView::setSectionsClickable(bool clickable) { Q_D(QHeaderView); d->clickableSections = clickable; } +// ### Qt 6 - remove this obsolete function +/*! + \obsolete + \fn void QHeaderView::setClickable(bool clickable) + + Use setSectionsClickable instead. + + \sa setSectionsClickable() +*/ + /*! Returns true if the header is clickable; otherwise returns false. A clickable header could be set up to allow the user to change the representation of the data in the view related to the header. - \sa setClickable() + \sa setSectionsClickable() */ -// ### Qt 5: change to sectionsClickable() -bool QHeaderView::isClickable() const +bool QHeaderView::sectionsClickable() const { Q_D(const QHeaderView); 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); @@ -1172,8 +1208,6 @@ void QHeaderView::setResizeMode(ResizeMode mode) } /*! - \overload - Sets the constraints on how the section specified by \a logicalIndex in the header can be resized to those described by the given \a mode. The logical index should exist at the time this function is called. @@ -1185,8 +1219,7 @@ void QHeaderView::setResizeMode(ResizeMode mode) \sa setStretchLastSection() */ -// ### Qt 5: change to setSectionResizeMode() -void QHeaderView::setResizeMode(int logicalIndex, ResizeMode mode) +void QHeaderView::setSectionResizeMode(int logicalIndex, ResizeMode mode) { Q_D(QHeaderView); int visual = visualIndex(logicalIndex); @@ -1208,6 +1241,17 @@ void QHeaderView::setResizeMode(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() +*/ + /*! Returns the resize mode that applies to the section specified by the given \a logicalIndex. @@ -1215,7 +1259,7 @@ void QHeaderView::setResizeMode(int logicalIndex, ResizeMode mode) \sa setResizeMode() */ -QHeaderView::ResizeMode QHeaderView::resizeMode(int logicalIndex) const +QHeaderView::ResizeMode QHeaderView::sectionResizeMode(int logicalIndex) const { Q_D(const QHeaderView); int visual = visualIndex(logicalIndex); @@ -1224,6 +1268,16 @@ QHeaderView::ResizeMode QHeaderView::resizeMode(int logicalIndex) const return d->headerSectionResizeMode(visual); } +// ### Qt 6 - remove this obsolete function +/*! + \obsolete + \fn QHeaderView::ResizeMode QHeaderView::resizeMode(int logicalIndex) const + + Use sectionResizeMode instead. + + \sa sectionResizeMode() +*/ + /*! \since 4.1 @@ -1246,7 +1300,7 @@ int QHeaderView::stretchSectionCount() const By default, this property is false. - \sa setClickable() + \sa setSectionsClickable() */ void QHeaderView::setSortIndicatorShown(bool show) @@ -1299,8 +1353,8 @@ void QHeaderView::setSortIndicator(int logicalIndex, Qt::SortOrder order) } if (old != logicalIndex - && ((logicalIndex >= 0 && resizeMode(logicalIndex) == ResizeToContents) - || old >= d->sectionCount() || (old >= 0 && resizeMode(old) == ResizeToContents))) { + && ((logicalIndex >= 0 && sectionResizeMode(logicalIndex) == ResizeToContents) + || old >= d->sectionCount() || (old >= 0 && sectionResizeMode(old) == ResizeToContents))) { resizeSections(); d->viewport->update(); } else { @@ -2207,7 +2261,7 @@ void QHeaderView::mousePressEvent(QMouseEvent *e) updateSection(d->pressed); d->state = QHeaderViewPrivate::SelectSections; } - } else if (resizeMode(handle) == Interactive) { + } else if (sectionResizeMode(handle) == Interactive) { d->originalSize = sectionSize(handle); d->state = QHeaderViewPrivate::ResizeSection; d->section = handle; @@ -2289,7 +2343,7 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e) #ifndef QT_NO_CURSOR int handle = d->sectionHandleAt(pos); bool hasCursor = testAttribute(Qt::WA_SetCursor); - if (handle != -1 && (resizeMode(handle) == Interactive)) { + if (handle != -1 && (sectionResizeMode(handle) == Interactive)) { if (!hasCursor) setCursor(d->orientation == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor); } else if (hasCursor) { @@ -2360,7 +2414,7 @@ void QHeaderView::mouseDoubleClickEvent(QMouseEvent *e) Q_D(QHeaderView); int pos = d->orientation == Qt::Horizontal ? e->x() : e->y(); int handle = d->sectionHandleAt(pos); - if (handle > -1 && resizeMode(handle) == Interactive) { + if (handle > -1 && sectionResizeMode(handle) == Interactive) { emit sectionHandleDoubleClicked(handle); #ifndef QT_NO_CURSOR Qt::CursorShape splitCursor = (d->orientation == Qt::Horizontal) @@ -2368,7 +2422,7 @@ void QHeaderView::mouseDoubleClickEvent(QMouseEvent *e) if (cursor().shape() == splitCursor) { // signal handlers may have changed the section size handle = d->sectionHandleAt(pos); - if (!(handle > -1 && resizeMode(handle) == Interactive)) + if (!(handle > -1 && sectionResizeMode(handle) == Interactive)) setCursor(Qt::ArrowCursor); } #endif @@ -2673,7 +2727,7 @@ void QHeaderView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bot int first = orientation() == Qt::Horizontal ? topLeft.column() : topLeft.row(); int last = orientation() == Qt::Horizontal ? bottomRight.column() : bottomRight.row(); for (int i = first; i <= last && !resizeRequired; ++i) - resizeRequired = (resizeMode(i) == ResizeToContents); + resizeRequired = (sectionResizeMode(i) == ResizeToContents); if (resizeRequired) d->doDelayedResizeSections(); } -- cgit v1.2.3 From 39e0d35fe9acb2b2b539cc96170be2d227936b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Sun, 11 Mar 2012 10:52:25 +0100 Subject: QHeaderView - documentation update. Prefer hideSection over 0-resize. There is a different behavior on 0 sections and hidden sections e.g with scrollbars. Normally people want to use hideSection. Change-Id: Id99de30ea46906bb4ef7720ed12d4ac9615c9743 Reviewed-by: Stephen Kelly --- src/widgets/itemviews/qheaderview.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/widgets/itemviews/qheaderview.cpp') diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 766d7ce6b6..425eb4cd95 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -866,9 +866,11 @@ void QHeaderView::swapSections(int first, int second) \fn void QHeaderView::resizeSection(int logicalIndex, int size) Resizes the section specified by \a logicalIndex to \a size measured in - pixels. + pixels. The size parameter must be a value larger or equal to zero. A + size equal to zero is however not recommended. In that situation hideSection + should be used instead. - \sa sectionResized(), resizeMode(), sectionSize() + \sa sectionResized(), resizeMode(), sectionSize(), hideSection() */ void QHeaderView::resizeSection(int logical, int size) -- cgit v1.2.3