mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-23 03:58:56 -04:00
Preparing RowNode for shared DownloadState
This is needed for preserving download state across filtering and similar operations that currently work by fully rebuilding the ContentManagerModel.
This commit is contained in:
parent
a13a1c0f6b
commit
ef2131d7f3
@ -107,7 +107,7 @@ void ContentManager::onCustomContextMenu(const QPoint &point)
|
||||
QAction menuCancelBook(gt("cancel-download"), this);
|
||||
QAction menuOpenFolder(gt("open-folder"), this);
|
||||
|
||||
if (DownloadState* download = bookNode->getDownloadState()) {
|
||||
if (const auto download = bookNode->getDownloadState()) {
|
||||
if (download->getDownloadInfo().paused) {
|
||||
contextMenu.addAction(&menuResumeBook);
|
||||
} else {
|
||||
|
@ -177,7 +177,7 @@ void ContentManagerDelegate::paint(QPainter *painter, const QStyleOptionViewItem
|
||||
}
|
||||
QStyleOptionViewItem eOpt = option;
|
||||
if (index.column() == 5) {
|
||||
if (DownloadState* downloadState = node->getDownloadState()) {
|
||||
if (const auto downloadState = node->getDownloadState()) {
|
||||
auto downloadInfo = downloadState->getDownloadInfo();
|
||||
showDownloadProgress(painter, r, downloadInfo);
|
||||
}
|
||||
@ -244,7 +244,7 @@ void ContentManagerDelegate::handleLastColumnClicked(const QModelIndex& index, Q
|
||||
int x = r.left();
|
||||
int w = r.width();
|
||||
|
||||
if (DownloadState* downloadState = node->getDownloadState()) {
|
||||
if (const auto downloadState = node->getDownloadState()) {
|
||||
if (downloadState->getDownloadInfo().paused) {
|
||||
if (clickX < (x + w/2)) {
|
||||
KiwixApp::instance()->getContentManager()->cancelBook(id, index);
|
||||
|
@ -142,7 +142,7 @@ bool RowNode::isChild(Node *candidate)
|
||||
return false;
|
||||
}
|
||||
|
||||
void RowNode::setDownloadState(DownloadState* ds)
|
||||
void RowNode::setDownloadState(std::shared_ptr<DownloadState> ds)
|
||||
{
|
||||
m_downloadState.reset(ds);
|
||||
m_downloadState = ds;
|
||||
}
|
||||
|
@ -50,15 +50,15 @@ public:
|
||||
bool isChild(Node* candidate);
|
||||
|
||||
|
||||
void setDownloadState(DownloadState* ds);
|
||||
DownloadState* getDownloadState() { return m_downloadState.get(); }
|
||||
void setDownloadState(std::shared_ptr<DownloadState> ds);
|
||||
std::shared_ptr<DownloadState> getDownloadState() { return m_downloadState; }
|
||||
|
||||
private:
|
||||
QList<QVariant> m_itemData;
|
||||
QList<std::shared_ptr<Node>> m_childItems;
|
||||
std::weak_ptr<RowNode> m_parentItem;
|
||||
QString m_bookId;
|
||||
std::unique_ptr<DownloadState> m_downloadState;
|
||||
std::shared_ptr<DownloadState> m_downloadState;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user