mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-24 04:32:15 -04:00
Rewrote handling of last column clicks using book states
This commit is contained in:
parent
b6fbfb6104
commit
0ecb142ca6
@ -257,21 +257,23 @@ void ContentManagerDelegate::handleLastColumnClicked(const QModelIndex& index, Q
|
||||
int w = r.width();
|
||||
|
||||
ContentManager& contentMgr = *KiwixApp::instance()->getContentManager();
|
||||
if (const auto downloadState = node->getDownloadState()) {
|
||||
if ( !downloadState->paused ) {
|
||||
contentMgr.pauseBook(id, index);
|
||||
} else if (clickX < (x + w/2)) {
|
||||
contentMgr.cancelBook(id);
|
||||
} else {
|
||||
contentMgr.resumeBook(id, index);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
const auto book = KiwixApp::instance()->getLibrary()->getBookById(id);
|
||||
contentMgr.openBook(id);
|
||||
} catch (std::out_of_range& e) {
|
||||
contentMgr.downloadBook(id, index);
|
||||
}
|
||||
switch ( contentMgr.getBookState(id) ) {
|
||||
case ContentManager::BookState::AVAILABLE_LOCALLY_AND_HEALTHY:
|
||||
return contentMgr.openBook(id);
|
||||
|
||||
case ContentManager::BookState::AVAILABLE_ONLINE:
|
||||
return contentMgr.downloadBook(id, index);
|
||||
|
||||
case ContentManager::BookState::DOWNLOADING:
|
||||
return contentMgr.pauseBook(id, index);
|
||||
|
||||
case ContentManager::BookState::DOWNLOAD_PAUSED:
|
||||
return clickX < (x + w/2)
|
||||
? contentMgr.cancelBook(id)
|
||||
: contentMgr.resumeBook(id, index);
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user