diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-08-16 13:55:11 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-08-26 18:02:58 +0200 |
commit | c501e09efacb8a60deb41f85f3402f6f4c041d95 (patch) | |
tree | ba3696c02eeff30279383dd618c7e39638445e37 /src/widgets/itemviews/qtableview.cpp | |
parent | 70f7c484c39dd5581160a8c3fa475ee108c4920d (diff) |
Replace QAbstractItemView::viewOptions with initViewItemOption
viewOptions returned a QStyleOptionViewItem object. Such a method
can never support newer versions of the option structure.
Most styleable QWidget classes provide a virtual method
initStyleOption that initializes the option object passed in as a
pointer, e.g QFrame, QAbstractSpinBox, or QComboBox.
Follow that API convention, but name it initViewItemOption, as the
QStyleOptionViewItem struct contains information about the item as
well as the widget itelf.
This is a source incompatible change that will go unnoticed unless
existing subclasses mark their overrides as 'override', or call
the removed QAbstractItemView::viewOption virtual function.
[ChangeLog][QtWidgets][QAbstractItemView] The virtual viewOptions
method that previously returned a QStyleOptionViewItem object has
been renamed to initViewItemOption, and initializes a
QStyleOptionViewItem object that's passed in through a pointer.
Change-Id: Ie058702aed42d77274fa3c4abb43ba302e57e348
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/itemviews/qtableview.cpp')
-rw-r--r-- | src/widgets/itemviews/qtableview.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index 115413cfaf..30f2eba912 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -1459,11 +1459,10 @@ void QTableView::scrollContentsBy(int dx, int dy) /*! \reimp */ -QStyleOptionViewItem QTableView::viewOptions() const +void QTableView::initViewItemOption(QStyleOptionViewItem *option) const { - QStyleOptionViewItem option = QAbstractItemView::viewOptions(); - option.showDecorationSelected = true; - return option; + QAbstractItemView::initViewItemOption(option); + option->showDecorationSelected = true; } /*! @@ -1473,7 +1472,8 @@ void QTableView::paintEvent(QPaintEvent *event) { Q_D(QTableView); // setup temp variables for the painting - QStyleOptionViewItem option = viewOptions(); + QStyleOptionViewItem option; + initViewItemOption(&option); const QPoint offset = d->scrollDelayOffset; const bool showGrid = d->showGrid; const int gridSize = showGrid ? 1 : 0; @@ -2352,7 +2352,8 @@ int QTableView::sizeHintForRow(int row) const if (right == -1) // the table don't have enough columns to fill the viewport right = d->model->columnCount(d->root) - 1; - QStyleOptionViewItem option = viewOptions(); + QStyleOptionViewItem option; + initViewItemOption(&option); int hint = 0; QModelIndex index; @@ -2440,7 +2441,8 @@ int QTableView::sizeHintForColumn(int column) const if (!isVisible() || bottom == -1) // the table don't have enough rows to fill the viewport bottom = d->model->rowCount(d->root) - 1; - QStyleOptionViewItem option = viewOptions(); + QStyleOptionViewItem option; + initViewItemOption(&option); int hint = 0; int rowsProcessed = 0; |