diff --git a/src/qtlibtorrent/torrentmodel.cpp b/src/qtlibtorrent/torrentmodel.cpp index 5e3891c6e..b91e52450 100644 --- a/src/qtlibtorrent/torrentmodel.cpp +++ b/src/qtlibtorrent/torrentmodel.cpp @@ -114,7 +114,7 @@ bool TorrentModelItem::setData(int column, const QVariant &value, int role) { qDebug() << Q_FUNC_INFO << column << value; if (role != Qt::DisplayRole) return false; - // Label and Name columns can be edited + // Label, seed date and Name columns can be edited switch(column) { case TR_NAME: m_name = value.toString(); @@ -130,6 +130,10 @@ bool TorrentModelItem::setData(int column, const QVariant &value, int role) } return true; } + case TR_SEED_DATE: { + m_seedTime = value.toDateTime(); + return true; + } default: break; } @@ -219,7 +223,7 @@ void TorrentModel::populate() { 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(handleTorrentUpdate(QTorrentHandle))); + 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))); connect(QBtSession::instance(), SIGNAL(pausedTorrent(QTorrentHandle)), SLOT(handleTorrentUpdate(QTorrentHandle))); @@ -378,6 +382,17 @@ void TorrentModel::handleTorrentUpdate(const QTorrentHandle &h) } } +void TorrentModel::handleFinishedTorrent(const QTorrentHandle& h) +{ + const int row = torrentRow(h.hash()); + if (row < 0) + return; + + // Update completion date + m_torrents[row]->setData(TorrentModelItem::TR_SEED_DATE, QDateTime::currentDateTime(), Qt::DisplayRole); + notifyTorrentChanged(row); +} + void TorrentModel::notifyTorrentChanged(int row) { emit dataChanged(index(row, 0), index(row, columnCount()-1)); diff --git a/src/qtlibtorrent/torrentmodel.h b/src/qtlibtorrent/torrentmodel.h index 5cd341c1f..33057b28e 100644 --- a/src/qtlibtorrent/torrentmodel.h +++ b/src/qtlibtorrent/torrentmodel.h @@ -104,6 +104,7 @@ 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); void forceModelRefresh(); void handleTorrentLabelChange(QString previous, QString current);