diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index 86ac3fdaa..8572c65b6 100755 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -821,8 +821,6 @@ void QBtSession::deleteTorrent(const QString &hash, bool delete_local_files) { else addConsoleMessage(tr("'%1' was removed from transfer list.", "'xxx.avi' was removed...").arg(fileName)); qDebug("Torrent deleted."); - emit deletedTorrent(hash); - qDebug("Deleted signal emitted."); } void QBtSession::pauseAllTorrents() { diff --git a/src/qtlibtorrent/qbtsession.h b/src/qtlibtorrent/qbtsession.h index f6a80535f..c1eec4cc3 100755 --- a/src/qtlibtorrent/qbtsession.h +++ b/src/qtlibtorrent/qbtsession.h @@ -272,7 +272,6 @@ private slots: signals: void addedTorrent(const QTorrentHandle& h); - void deletedTorrent(const QString &hash); void torrentAboutToBeRemoved(const QTorrentHandle &h); void pausedTorrent(const QTorrentHandle& h); void resumedTorrent(const QTorrentHandle& h); diff --git a/src/qtlibtorrent/torrentmodel.cpp b/src/qtlibtorrent/torrentmodel.cpp index 9234a1138..774240600 100644 --- a/src/qtlibtorrent/torrentmodel.cpp +++ b/src/qtlibtorrent/torrentmodel.cpp @@ -331,7 +331,6 @@ void TorrentModel::populate() { // Listen for torrent changes connect(QBtSession::instance(), SIGNAL(addedTorrent(QTorrentHandle)), SLOT(addTorrent(QTorrentHandle))); connect(QBtSession::instance(), SIGNAL(torrentAboutToBeRemoved(QTorrentHandle)), SLOT(handleTorrentAboutToBeRemoved(QTorrentHandle))); - connect(QBtSession::instance(), SIGNAL(deletedTorrent(QString)), SLOT(removeTorrent(QString))); connect(QBtSession::instance(), SIGNAL(finishedTorrent(QTorrentHandle)), SLOT(handleFinishedTorrent(QTorrentHandle))); connect(QBtSession::instance(), SIGNAL(metadataReceived(QTorrentHandle)), SLOT(handleTorrentUpdate(QTorrentHandle))); connect(QBtSession::instance(), SIGNAL(resumedTorrent(QTorrentHandle)), SLOT(handleTorrentUpdate(QTorrentHandle))); @@ -440,18 +439,6 @@ void TorrentModel::addTorrent(const QTorrentHandle &h) } } -void TorrentModel::removeTorrent(const QString &hash) -{ - const int row = torrentRow(hash); - qDebug() << Q_FUNC_INFO << hash << row; - if (row >= 0) { - beginRemoveTorrent(row); - delete m_torrents[row]; - m_torrents.removeAt(row); - endRemoveTorrent(); - } -} - void TorrentModel::beginInsertTorrent(int row) { beginInsertRows(QModelIndex(), row, row); @@ -578,8 +565,14 @@ QString TorrentModel::torrentHash(int row) const void TorrentModel::handleTorrentAboutToBeRemoved(const QTorrentHandle &h) { const int row = torrentRow(h.hash()); + qDebug() << Q_FUNC_INFO << row; if (row >= 0) { emit torrentAboutToBeRemoved(m_torrents.at(row)); + + beginRemoveTorrent(row); + delete m_torrents[row]; + m_torrents.removeAt(row); + endRemoveTorrent(); } } diff --git a/src/qtlibtorrent/torrentmodel.h b/src/qtlibtorrent/torrentmodel.h index 8bebce656..5153b4853 100644 --- a/src/qtlibtorrent/torrentmodel.h +++ b/src/qtlibtorrent/torrentmodel.h @@ -105,7 +105,6 @@ signals: private slots: void addTorrent(const QTorrentHandle& h); - void removeTorrent(const QString &hash); void handleTorrentUpdate(const QTorrentHandle &h); void handleFinishedTorrent(const QTorrentHandle& h); void notifyTorrentChanged(int row); diff --git a/src/qtlibtorrent/torrentspeedmonitor.cpp b/src/qtlibtorrent/torrentspeedmonitor.cpp index 5cdb62d30..9b593ac8b 100644 --- a/src/qtlibtorrent/torrentspeedmonitor.cpp +++ b/src/qtlibtorrent/torrentspeedmonitor.cpp @@ -117,7 +117,7 @@ private: TorrentSpeedMonitor::TorrentSpeedMonitor(QBtSession* session) : m_session(session) { - connect(m_session, SIGNAL(deletedTorrent(QString)), SLOT(removeSamples(QString))); + connect(m_session, SIGNAL(torrentAboutToBeRemoved(QTorrentHandle)), SLOT(removeSamples(QTorrentHandle))); connect(m_session, SIGNAL(pausedTorrent(QTorrentHandle)), SLOT(removeSamples(QTorrentHandle))); connect(m_session, SIGNAL(statsReceived(libtorrent::stats_alert)), SLOT(statsReceived(libtorrent::stats_alert))); } @@ -143,11 +143,6 @@ Sample SpeedSample::average() const return Sample(m_sum) * (1. / m_speedSamples.size()); } -void TorrentSpeedMonitor::removeSamples(const QString &hash) -{ - m_samples.remove(hash); -} - void TorrentSpeedMonitor::removeSamples(const QTorrentHandle& h) { try { m_samples.remove(h.hash()); diff --git a/src/qtlibtorrent/torrentspeedmonitor.h b/src/qtlibtorrent/torrentspeedmonitor.h index 5e0ea1c6a..473a4bdd5 100644 --- a/src/qtlibtorrent/torrentspeedmonitor.h +++ b/src/qtlibtorrent/torrentspeedmonitor.h @@ -52,7 +52,6 @@ public: private slots: void statsReceived(const libtorrent::stats_alert& stats); - void removeSamples(const QString& hash); void removeSamples(const QTorrentHandle& h); private: