Browse Source

"Completed On" column is not updated until restart (closes #84)

adaptive-webui-19844
Christophe Dumez 12 years ago
parent
commit
d09a0f6167
  1. 19
      src/qtlibtorrent/torrentmodel.cpp
  2. 1
      src/qtlibtorrent/torrentmodel.h

19
src/qtlibtorrent/torrentmodel.cpp

@ -114,7 +114,7 @@ bool TorrentModelItem::setData(int column, const QVariant &value, int role)
{ {
qDebug() << Q_FUNC_INFO << column << value; qDebug() << Q_FUNC_INFO << column << value;
if (role != Qt::DisplayRole) return false; if (role != Qt::DisplayRole) return false;
// Label and Name columns can be edited // Label, seed date and Name columns can be edited
switch(column) { switch(column) {
case TR_NAME: case TR_NAME:
m_name = value.toString(); m_name = value.toString();
@ -130,6 +130,10 @@ bool TorrentModelItem::setData(int column, const QVariant &value, int role)
} }
return true; return true;
} }
case TR_SEED_DATE: {
m_seedTime = value.toDateTime();
return true;
}
default: default:
break; break;
} }
@ -219,7 +223,7 @@ void TorrentModel::populate() {
connect(QBtSession::instance(), SIGNAL(addedTorrent(QTorrentHandle)), SLOT(addTorrent(QTorrentHandle))); connect(QBtSession::instance(), SIGNAL(addedTorrent(QTorrentHandle)), SLOT(addTorrent(QTorrentHandle)));
connect(QBtSession::instance(), SIGNAL(torrentAboutToBeRemoved(QTorrentHandle)), SLOT(handleTorrentAboutToBeRemoved(QTorrentHandle))); connect(QBtSession::instance(), SIGNAL(torrentAboutToBeRemoved(QTorrentHandle)), SLOT(handleTorrentAboutToBeRemoved(QTorrentHandle)));
connect(QBtSession::instance(), SIGNAL(deletedTorrent(QString)), SLOT(removeTorrent(QString))); 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(metadataReceived(QTorrentHandle)), SLOT(handleTorrentUpdate(QTorrentHandle)));
connect(QBtSession::instance(), SIGNAL(resumedTorrent(QTorrentHandle)), SLOT(handleTorrentUpdate(QTorrentHandle))); connect(QBtSession::instance(), SIGNAL(resumedTorrent(QTorrentHandle)), SLOT(handleTorrentUpdate(QTorrentHandle)));
connect(QBtSession::instance(), SIGNAL(pausedTorrent(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) void TorrentModel::notifyTorrentChanged(int row)
{ {
emit dataChanged(index(row, 0), index(row, columnCount()-1)); emit dataChanged(index(row, 0), index(row, columnCount()-1));

1
src/qtlibtorrent/torrentmodel.h

@ -104,6 +104,7 @@ private slots:
void addTorrent(const QTorrentHandle& h); void addTorrent(const QTorrentHandle& h);
void removeTorrent(const QString &hash); void removeTorrent(const QString &hash);
void handleTorrentUpdate(const QTorrentHandle &h); void handleTorrentUpdate(const QTorrentHandle &h);
void handleFinishedTorrent(const QTorrentHandle& h);
void notifyTorrentChanged(int row); void notifyTorrentChanged(int row);
void forceModelRefresh(); void forceModelRefresh();
void handleTorrentLabelChange(QString previous, QString current); void handleTorrentLabelChange(QString previous, QString current);

Loading…
Cancel
Save