QTableView::sizeHintForRow move word wrap into heightHintForIndex

In 03c761287f 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>
This commit is contained in:
Thorbjørn Martsum 2013-05-31 06:40:44 +02:00 committed by The Qt Project
parent f84dc0ff62
commit 9767824a7d
2 changed files with 8 additions and 15 deletions

View File

@ -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;
}

View File

@ -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;