diff --git a/src/gui/properties/proplistdelegate.cpp b/src/gui/properties/proplistdelegate.cpp index 1445c0e13..38c10c6f1 100644 --- a/src/gui/properties/proplistdelegate.cpp +++ b/src/gui/properties/proplistdelegate.cpp @@ -28,14 +28,12 @@ * Contact : chris@qbittorrent.org */ -#include -#include -#include #include #include #include +#include #include -#include +#include #ifdef Q_OS_WIN #ifndef QBT_USES_QT5 @@ -51,6 +49,23 @@ #include "proplistdelegate.h" #include "torrentcontentmodelitem.h" +namespace { + + QPalette progressBarDisabledPalette() + { + auto getPalette = []() + { + QProgressBar bar; + bar.setEnabled(false); + QStyleOptionProgressBar opt; + opt.initFrom(&bar); + return opt.palette; + }; + static QPalette palette = getPalette(); + return palette; + } +} + PropListDelegate::PropListDelegate(PropertiesWidget *properties, QObject *parent) : QItemDelegate(parent) , m_properties(properties) @@ -85,8 +100,13 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti newopt.progress = (int)progress; newopt.maximum = 100; newopt.minimum = 0; - newopt.state |= QStyle::State_Enabled; newopt.textVisible = true; + if (index.sibling(index.row(), PRIORITY).data().toInt() == prio::IGNORED) { + newopt.state &= ~QStyle::State_Enabled; + newopt.palette = progressBarDisabledPalette(); + } + else + newopt.state |= QStyle::State_Enabled; #ifndef Q_OS_WIN QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter); #else diff --git a/src/gui/torrentcontentfiltermodel.h b/src/gui/torrentcontentfiltermodel.h index 0a924f9a4..cea551f00 100644 --- a/src/gui/torrentcontentfiltermodel.h +++ b/src/gui/torrentcontentfiltermodel.h @@ -33,7 +33,6 @@ #include #include "torrentcontentmodelitem.h" -#include "proplistdelegate.h" class TorrentContentModel; diff --git a/src/gui/torrentcontentmodel.cpp b/src/gui/torrentcontentmodel.cpp index 7324532de..830e32751 100644 --- a/src/gui/torrentcontentmodel.cpp +++ b/src/gui/torrentcontentmodel.cpp @@ -181,12 +181,14 @@ QVariant TorrentContentModel::data(const QModelIndex& index, int role) const return QVariant(); TorrentContentModelItem* item = static_cast(index.internalPointer()); + if ((index.column() == 0) && (role == Qt::DecorationRole)) { if (item->itemType() == TorrentContentModelItem::FolderType) return getDirectoryIcon(); else return getFileIcon(); } + if ((index.column() == 0) && (role == Qt::CheckStateRole)) { if (item->data(TorrentContentModelItem::COL_PRIO).toInt() == prio::IGNORED) return Qt::Unchecked; @@ -194,10 +196,11 @@ QVariant TorrentContentModel::data(const QModelIndex& index, int role) const return Qt::PartiallyChecked; return Qt::Checked; } - if (role != Qt::DisplayRole) - return QVariant(); - return item->data(index.column()); + if (role == Qt::DisplayRole) + return item->data(index.column()); + + return QVariant(); } Qt::ItemFlags TorrentContentModel::flags(const QModelIndex& index) const