diff options
author | Thorbjørn Martsum <tmartsum@gmail.com> | 2013-05-31 06:40:44 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-07-04 18:55:03 +0200 |
commit | 9767824a7dc9379a0959968b2ae9b047fce14856 (patch) | |
tree | 1ca2c6e0aa194cd853538049032fec5c7cf98a95 /src/widgets | |
parent | f84dc0ff62234c871f30c1b51121ba2beb65e968 (diff) | |
download | qtbase-9767824a7dc9379a0959968b2ae9b047fce14856.tar.gz |
QTableView::sizeHintForRow move word wrap into heightHintForIndex
In 03c761287f1a007c7177d90ed81341d0147eae05 it was overlooked
that word wrap handling (with advantage) could be moved into the
function, too.
This patch makes the code more readable, but does not change
anything.
Change-Id: Ifed349398b862650da383e4e6fd337a166dc680e
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/itemviews/qtableview.cpp | 21 | ||||
-rw-r--r-- | src/widgets/itemviews/qtableview_p.h | 2 |
2 files changed, 8 insertions, 15 deletions
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index 41ecd3b48f..990e07bfcb 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -952,7 +952,7 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con \internal Get sizeHint height for single Index (providing existing hint and style option) */ -int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const +int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QStyleOptionViewItem &option) const { Q_Q(const QTableView); QWidget *editor = editorForIndex(index).widget.data(); @@ -963,6 +963,12 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, co hint = qBound(min, hint, max); } + if (wrapItemText) {// for wrapping boundaries + option.rect.setY(q->rowViewportPosition(index.row())); + option.rect.setHeight(q->rowHeight(index.row())); + option.rect.setX(q->columnViewportPosition(index.column())); + option.rect.setWidth(q->columnWidth(index.column())); + } hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).height()); return hint; } @@ -2237,12 +2243,6 @@ int QTableView::sizeHintForRow(int row) const if (d->horizontalHeader->isSectionHidden(logicalColumn)) continue; index = d->model->index(row, logicalColumn, d->root); - if (d->wrapItemText) {// for wrapping boundaries - option.rect.setY(rowViewportPosition(index.row())); - option.rect.setHeight(rowHeight(index.row())); - option.rect.setX(columnViewportPosition(index.column())); - option.rect.setWidth(columnWidth(index.column())); - } hint = d->heightHintForIndex(index, hint, option); ++columnsProcessed; @@ -2283,13 +2283,6 @@ int QTableView::sizeHintForRow(int row) const continue; index = d->model->index(row, logicalIdx, d->root); - - if (d->wrapItemText) {// for wrapping boundaries - option.rect.setY(rowViewportPosition(index.row())); - option.rect.setHeight(rowHeight(index.row())); - option.rect.setX(columnViewportPosition(index.column())); - option.rect.setWidth(columnWidth(index.column())); - } hint = d->heightHintForIndex(index, hint, option); ++columnsProcessed; } diff --git a/src/widgets/itemviews/qtableview_p.h b/src/widgets/itemviews/qtableview_p.h index 3850cba9d3..d36dcd2c3a 100644 --- a/src/widgets/itemviews/qtableview_p.h +++ b/src/widgets/itemviews/qtableview_p.h @@ -182,7 +182,7 @@ public: int firstVisualRow, int lastVisualRow, int firstVisualColumn, int lastVisualColumn); void drawCell(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index); int widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const; - int heightHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const; + int heightHintForIndex(const QModelIndex &index, int hint, QStyleOptionViewItem &option) const; bool showGrid; Qt::PenStyle gridStyle; |