QColumnView: replace QItemDelegate with QStyledItemDelegate

Resolve remaining Qt6 TODOs

Change-Id: Ida72cbb58dafe4bde5da82996de7434c767bbe63
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Peng Wenhao 2020-08-26 20:36:06 +08:00 committed by Volker Hilsheimer
parent 02d4495115
commit 4073d3a10e
2 changed files with 7 additions and 10 deletions

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
@ -1126,14 +1126,12 @@ void QColumnViewPrivate::doLayout()
Draws a delegate with a > if an object has children.
\sa {Model/View Programming}, QItemDelegate
\sa {Model/View Programming}, QStyledItemDelegate
*/
void QColumnViewDelegate::paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
drawBackground(painter, option, index );
bool reverse = (option.direction == Qt::RightToLeft);
int width = ((option.rect.height() * 2) / 3);
// Modify the options to give us room to add an arrow
@ -1148,7 +1146,7 @@ void QColumnViewDelegate::paint(QPainter *painter,
opt.state |= QStyle::State_Selected;
}
QItemDelegate::paint(painter, opt, index);
QStyledItemDelegate::paint(painter, opt, index);
if (reverse)
opt.rect = QRect(option.rect.x(), option.rect.y(), width, option.rect.height());

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
@ -62,7 +62,7 @@
#endif
#include <QtWidgets/qabstractitemdelegate.h>
#include <QtWidgets/qabstractitemview.h>
#include <QtWidgets/qitemdelegate.h>
#include <QtWidgets/qstyleditemdelegate.h>
#include <qlistview.h>
#include <qevent.h>
#include <qscrollbar.h>
@ -181,12 +181,11 @@ public:
/*!
* This is a delegate that will paint the triangle
*/
// ### Qt6: QStyledItemDelegate
class QColumnViewDelegate : public QItemDelegate
class QColumnViewDelegate : public QStyledItemDelegate
{
public:
explicit QColumnViewDelegate(QObject *parent = nullptr) : QItemDelegate(parent) {}
explicit QColumnViewDelegate(QObject *parent = nullptr) : QStyledItemDelegate(parent) {}
~QColumnViewDelegate() {}
void paint(QPainter *painter,