summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews/qtableview.cpp
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-09-09 16:28:27 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-09-12 05:42:53 +0200
commit3f8c4ae047428d21303cc5e12880838236138616 (patch)
tree44395d9678a117505eff06c6edb8684706c7e1d3 /src/widgets/itemviews/qtableview.cpp
parent605d2163f1dcd7e1ad701ade913cb476b91865b1 (diff)
QAbstractItemView: add virtual itemDelegateForIndex
and obsolete itemDelegate(index), which the new function replaces. This allows itemviews to override the item delegate per index. The existing APIs to set delegates for rows and columns doesn't work for tree views, or other views where the delegate should depend on the parent index as well. Adjust all itemview code that accessed the QAIVPrivate's relevant data structures directly to go through the virtual function. [ChangeLog][QtWidgets][QAbstractItemView] The itemDelegate(QModelIndex) member function has been made obsolete, and has been replaced by a new virtual itemDelegateForIndex(QModelIndex) member function that can be overridden to give subclasses control over which item delegate should be used for an index. Change-Id: Ib03529c38797386d3a1d4cf3c5646e911d95daf5 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Diffstat (limited to 'src/widgets/itemviews/qtableview.cpp')
-rw-r--r--src/widgets/itemviews/qtableview.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index cf927ef30d..f82473e60c 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -1050,7 +1050,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
q->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, q);
- q->itemDelegate(index)->paint(painter, opt, index);
+ q->itemDelegateForIndex(index)->paint(painter, opt, index);
}
/*!
@@ -1067,7 +1067,7 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
int max = editor->maximumSize().width();
hint = qBound(min, hint, max);
}
- hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
+ hint = qMax(hint, q->itemDelegateForIndex(index)->sizeHint(option, index).width());
return hint;
}
@@ -1089,7 +1089,7 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
if (wrapItemText) {// for wrapping boundaries
option.rect.setY(q->rowViewportPosition(index.row()));
int height = q->rowHeight(index.row());
- // if the option.height == 0 then q->itemDelegate(index)->sizeHint(option, index) will be wrong.
+ // if the option.height == 0 then q->itemDelegateForIndex(index)->sizeHint(option, index) will be wrong.
// The option.height == 0 is used to conclude that the text is not wrapped, and hence it will
// (exactly like widthHintForIndex) return a QSize with a long width (that we don't use) -
// and the height of the text if it was/is on one line.
@@ -1104,7 +1104,7 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
if (showGrid)
option.rect.setWidth(option.rect.width() - 1);
}
- hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).height());
+ hint = qMax(hint, q->itemDelegateForIndex(index)->sizeHint(option, index).height());
return hint;
}