diff options
author | Thorbjørn Martsum <tmartsum@gmail.com> | 2013-04-16 09:07:44 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-05-13 16:32:50 +0200 |
commit | adaa50e37da1fddada874a289792a1bd95c5aebc (patch) | |
tree | 24b50587636ef9db139676b2579cca125f2e4be5 /src/widgets/itemviews/qtreeview.cpp | |
parent | 70410467f0f99ce6d16fe0ac2b2a93a0c053fa05 (diff) |
QHeaderView - add parameter to control sizeHint precision
Currently Qt looks at 1000 rows when scaling a column.
That can be slow in some situations and too inaccurate in others.
With this patch we leave it up to the user to decide how precise
e.g resizeToContents should be.
Change-Id: I6ef60f9a3bb40fc331ce1a1544fdc77488d20ca3
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src/widgets/itemviews/qtreeview.cpp')
-rw-r--r-- | src/widgets/itemviews/qtreeview.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 21a408d6f1..38f0aa6a9e 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -2565,7 +2565,7 @@ void QTreeView::columnCountChanged(int oldCount, int newCount) /*! Resizes the \a column given to the size of its contents. - \sa columnWidth(), setColumnWidth() + \sa columnWidth(), setColumnWidth(), sizeHintForColumn(), QHeaderView::resizeContentsPrecision() */ void QTreeView::resizeColumnToContents(int column) { @@ -2801,7 +2801,7 @@ void QTreeView::updateGeometries() if a larger column width is required by either the view's header or the item delegate, that width will be used instead. - \sa QWidget::sizeHint, header() + \sa QWidget::sizeHint, header(), QHeaderView::resizeContentsPrecision() */ int QTreeView::sizeHintForColumn(int column) const { @@ -2814,7 +2814,7 @@ int QTreeView::sizeHintForColumn(int column) const QStyleOptionViewItem option = d->viewOptions(); const QVector<QTreeViewItem> viewItems = d->viewItems; - const int maximumProcessRows = 1000; // To avoid this to take forever. + const int maximumProcessRows = d->header->resizeContentsPrecision(); // To avoid this to take forever. int offset = 0; int start = d->firstVisibleItem(&offset); @@ -2835,6 +2835,10 @@ int QTreeView::sizeHintForColumn(int column) const --end; int actualBottom = viewItems.size() - 1; + + if (maximumProcessRows == 0) + rowsProcessed = 0; // skip the while loop + while (rowsProcessed != maximumProcessRows && (start > 0 || end < actualBottom)) { int idx = -1; |