Always use QStyledItemDelegate as base of delegate classes

PR #19340.
This commit is contained in:
Vladimir Golovnev 2023-07-21 08:37:11 +03:00 committed by GitHub
parent 0f862fcf9f
commit d554f4d44a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 39 deletions

View file

@ -1,5 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2023 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
*
* This program is free software; you can redistribute it and/or
@ -30,13 +31,12 @@
#include <QModelIndex>
#include <QPainter>
#include <QStyleOptionViewItem>
#include "base/utils/misc.h"
#include "base/utils/string.h"
#include "previewselectdialog.h"
PreviewListDelegate::PreviewListDelegate(QObject *parent)
: QItemDelegate(parent)
: QStyledItemDelegate(parent)
{
}
@ -44,15 +44,8 @@ void PreviewListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
{
painter->save();
QStyleOptionViewItem opt = QItemDelegate::setOptions(index, option);
drawBackground(painter, opt, index);
switch (index.column())
{
case PreviewSelectDialog::SIZE:
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong()));
break;
case PreviewSelectDialog::PROGRESS:
{
const qreal progress = (index.data().toReal() * 100);
@ -65,7 +58,7 @@ void PreviewListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
break;
default:
QItemDelegate::paint(painter, option, index);
QStyledItemDelegate::paint(painter, option, index);
break;
}