mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-09 07:40:19 +08:00
"Completed On" column is not updated until restart (closes #84)
This commit is contained in:
parent
c79e801929
commit
d09a0f6167
@ -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));
|
||||||
|
@ -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…
Reference in New Issue
Block a user