mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-24 04:32:15 -04:00
Extracted ContentManagerModel::updateDownload()
The diff is simpler if whitespace changes are ignored.
This commit is contained in:
parent
3e3cd676b5
commit
341c7ed8e3
@ -256,12 +256,20 @@ void ContentManagerModel::startDownload(QModelIndex index)
|
||||
node->setDownloadState(newDownload);
|
||||
QTimer *timer = newDownload->getDownloadUpdateTimer();
|
||||
connect(timer, &QTimer::timeout, this, [=]() {
|
||||
// We may not use node in this lambda since it may have been
|
||||
// invalidated by a call to ContentManagerModel::setBooksData().
|
||||
updateDownload(bookId);
|
||||
});
|
||||
}
|
||||
|
||||
const bool downloadStillValid = newDownload->update(bookId);
|
||||
void ContentManagerModel::updateDownload(QString bookId)
|
||||
{
|
||||
const auto download = m_downloads.value(bookId);
|
||||
|
||||
// newDownload->update() call above may result in
|
||||
if ( ! download )
|
||||
return;
|
||||
|
||||
const bool downloadStillValid = download->update(bookId);
|
||||
|
||||
// The download->update() call above may result in
|
||||
// ContentManagerModel::setBooksData() being called (through a chain
|
||||
// of signals), which in turn will rebuild bookIdToRowMap. Hence
|
||||
// bookIdToRowMap access must happen after it.
|
||||
@ -283,7 +291,6 @@ void ContentManagerModel::startDownload(QModelIndex index)
|
||||
const QModelIndex newIndex = this->index(row, 5, rootNodeIndex);
|
||||
emit dataChanged(newIndex, newIndex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void ContentManagerModel::pauseDownload(QModelIndex index)
|
||||
|
@ -53,6 +53,9 @@ protected: // functions
|
||||
bool canFetchMore(const QModelIndex &parent) const override;
|
||||
void fetchMore(const QModelIndex &parent) override;
|
||||
|
||||
private: // functions
|
||||
void updateDownload(QString bookId);
|
||||
|
||||
private: // data
|
||||
BookInfoList m_data;
|
||||
std::shared_ptr<RowNode> rootNode;
|
||||
|
Loading…
x
Reference in New Issue
Block a user