mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-19 06:57:24 -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user