From 2d98b8f1921ca025db082b32fdfbd2f3c6e1d985 Mon Sep 17 00:00:00 2001 From: Ivan Sorokin Date: Sat, 25 Oct 2014 14:13:09 +0400 Subject: [PATCH] Call TorrentModelItem::state() directly in getTorrentStatusReport There is no point in wraping/unwraping QVariant. --- src/qtlibtorrent/torrentmodel.cpp | 2 +- src/qtlibtorrent/torrentmodel.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qtlibtorrent/torrentmodel.cpp b/src/qtlibtorrent/torrentmodel.cpp index d2bf7054f..09f063abd 100644 --- a/src/qtlibtorrent/torrentmodel.cpp +++ b/src/qtlibtorrent/torrentmodel.cpp @@ -504,7 +504,7 @@ TorrentStatusReport TorrentModel::getTorrentStatusReport() const QList::const_iterator it = m_torrents.constBegin(); QList::const_iterator itend = m_torrents.constEnd(); for ( ; it != itend; ++it) { - switch((*it)->data(TorrentModelItem::TR_STATUS).toInt()) { + switch((*it)->state()) { case TorrentModelItem::STATE_DOWNLOADING: ++report.nb_active; ++report.nb_downloading; diff --git a/src/qtlibtorrent/torrentmodel.h b/src/qtlibtorrent/torrentmodel.h index dc61c1cb7..e77bf4644 100644 --- a/src/qtlibtorrent/torrentmodel.h +++ b/src/qtlibtorrent/torrentmodel.h @@ -58,6 +58,7 @@ public: QVariant data(int column, int role = Qt::DisplayRole) const; bool setData(int column, const QVariant &value, int role = Qt::DisplayRole); inline QString hash() const { return m_hash; } + State state() const; signals: void labelChanged(QString previous, QString current); @@ -65,7 +66,6 @@ signals: private: static QIcon getIconByState(State state); static QColor getColorByState(State state); - State state() const; private: QTorrentHandle m_torrent;