mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-29 11:48:05 -06:00
Make BitTorrent::TorrentState strongly-typed enum
This is needed to forward declare this type and pass it by value. Conversion from/to QVariant are hanled via Q_DECLARE_METATYPE, while TorrentState::toString() function was used in webui only and as such is moved there.
This commit is contained in:
@@ -58,7 +58,7 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
||||
bool isHideState = true;
|
||||
if (Preferences::instance()->getHideZeroComboValues() == 1) { // paused torrents only
|
||||
QModelIndex stateIndex = index.sibling(index.row(), TorrentModel::TR_STATUS);
|
||||
if (stateIndex.data().toInt() != BitTorrent::TorrentState::PausedDownloading)
|
||||
if (stateIndex.data().value<BitTorrent::TorrentState>() != BitTorrent::TorrentState::PausedDownloading)
|
||||
isHideState = false;
|
||||
}
|
||||
const bool hideValues = Preferences::instance()->getHideZeroValues() & isHideState;
|
||||
@@ -98,7 +98,7 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
||||
break;
|
||||
}
|
||||
case TorrentModel::TR_STATUS: {
|
||||
const int state = index.data().toInt();
|
||||
const auto state = index.data().value<BitTorrent::TorrentState>();
|
||||
QString display = getStatusString(state);
|
||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, display);
|
||||
break;
|
||||
@@ -223,7 +223,7 @@ QSize TransferListDelegate::sizeHint(const QStyleOptionViewItem & option, const
|
||||
return size;
|
||||
}
|
||||
|
||||
QString TransferListDelegate::getStatusString(const int state) const
|
||||
QString TransferListDelegate::getStatusString(const BitTorrent::TorrentState state) const
|
||||
{
|
||||
QString str;
|
||||
|
||||
|
||||
@@ -39,6 +39,10 @@ class QStyleOptionViewItem;
|
||||
class QModelIndex;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace BitTorrent
|
||||
{
|
||||
enum class TorrentState;
|
||||
}
|
||||
// Defines for download list list columns
|
||||
|
||||
class TransferListDelegate: public QItemDelegate
|
||||
@@ -52,7 +56,7 @@ public:
|
||||
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
||||
|
||||
private:
|
||||
QString getStatusString(const int state) const;
|
||||
QString getStatusString(const BitTorrent::TorrentState state) const;
|
||||
};
|
||||
|
||||
#endif // TRANSFERLISTDELEGATE_H
|
||||
|
||||
Reference in New Issue
Block a user