diff options
author | Christoph Schleifenbaum <christoph@kdab.com> | 2011-12-22 19:33:28 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-22 17:56:55 +0200 |
commit | ae0fd6884d30ae2ce084e239468696aaec7f5795 (patch) | |
tree | 7342d45c8b2c9cbf309d2347812c4d83f1701ac3 /src/widgets/itemviews/qabstractitemview.cpp | |
parent | 7df16fb4ccbe0476bc34274a77e98eec4e8d2d93 (diff) |
QAbstractScrollArea - add SizeAdjustPolicy and viewportSizeHint
This patch adds SizeAdjustPolicy to QAbstractScrollArea.
If it is set to AdjustToContents it will make use of the new
protected viewportSizeHint() (BC since it was reserved in Qt5).
This function returns a suggested size based on contents.
Change-Id: I5d8aa517e88b8b21c5712e62b4d574c3aad99d3b
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src/widgets/itemviews/qabstractitemview.cpp')
-rw-r--r-- | src/widgets/itemviews/qabstractitemview.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 70c8f44a73..b79525b9df 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -1108,6 +1108,7 @@ void QAbstractItemView::reset() QAccessible::updateAccessibility(&accessibleEvent); } #endif + d->updateGeometry(); } /*! @@ -1124,6 +1125,7 @@ void QAbstractItemView::setRootIndex(const QModelIndex &index) } d->root = index; d->doDelayedItemsLayout(); + d->updateGeometry(); } /*! @@ -2668,8 +2670,10 @@ void QAbstractItemView::updateEditorGeometries() */ void QAbstractItemView::updateGeometries() { + Q_D(QAbstractItemView); updateEditorGeometries(); - d_func()->fetchMoreTimer.start(0, this); //fetch more later + d->fetchMoreTimer.start(0, this); //fetch more later + d->updateGeometry(); } /*! @@ -3231,6 +3235,7 @@ void QAbstractItemView::dataChanged(const QModelIndex &topLeft, const QModelInde QAccessible::updateAccessibility(&accessibleEvent); } #endif + d->updateGeometry(); } /*! @@ -3332,6 +3337,7 @@ void QAbstractItemViewPrivate::_q_rowsRemoved(const QModelIndex &index, int star QAccessible::updateAccessibility(&accessibleEvent); } #endif + updateGeometry(); } /*! @@ -3412,6 +3418,7 @@ void QAbstractItemViewPrivate::_q_columnsRemoved(const QModelIndex &index, int s QAccessible::updateAccessibility(&accessibleEvent); } #endif + updateGeometry(); } @@ -3435,6 +3442,7 @@ void QAbstractItemViewPrivate::_q_rowsInserted(const QModelIndex &index, int sta QAccessible::updateAccessibility(&accessibleEvent); } #endif + updateGeometry(); } /*! @@ -3459,6 +3467,7 @@ void QAbstractItemViewPrivate::_q_columnsInserted(const QModelIndex &index, int QAccessible::updateAccessibility(&accessibleEvent); } #endif + updateGeometry(); } /*! @@ -4084,7 +4093,14 @@ void QAbstractItemViewPrivate::interruptDelayedItemsLayout() const delayedPendingLayout = false; } - +void QAbstractItemViewPrivate::updateGeometry() +{ + Q_Q(QAbstractItemView); + if (sizeAdjustPolicy == QAbstractScrollArea::AdjustIgnored) + return; + if (sizeAdjustPolicy == QAbstractScrollArea::AdjustToContents || !shownOnce) + q->updateGeometry(); +} QWidget *QAbstractItemViewPrivate::editor(const QModelIndex &index, const QStyleOptionViewItem &options) |