From 4073d3a10e6ea8faf893b5c6faba98a06a5851cc Mon Sep 17 00:00:00 2001 From: Peng Wenhao Date: Wed, 26 Aug 2020 20:36:06 +0800 Subject: [PATCH] QColumnView: replace QItemDelegate with QStyledItemDelegate Resolve remaining Qt6 TODOs Change-Id: Ida72cbb58dafe4bde5da82996de7434c767bbe63 Reviewed-by: Volker Hilsheimer --- src/widgets/itemviews/qcolumnview.cpp | 8 +++----- src/widgets/itemviews/qcolumnview_p.h | 9 ++++----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp index 5ad7b5d78c..c09563c375 100644 --- a/src/widgets/itemviews/qcolumnview.cpp +++ b/src/widgets/itemviews/qcolumnview.cpp @@ -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()); diff --git a/src/widgets/itemviews/qcolumnview_p.h b/src/widgets/itemviews/qcolumnview_p.h index 4fa523fd67..25170251f5 100644 --- a/src/widgets/itemviews/qcolumnview_p.h +++ b/src/widgets/itemviews/qcolumnview_p.h @@ -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 #include -#include +#include #include #include #include @@ -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,