mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -04:00
Download id is accessed directly via kiwix::Book
... whereupon `ContentManager::getBookInfos()` no longer needs to support the `downloadId` key.
This commit is contained in:
parent
073dd06937
commit
f70d0b3ccd
@ -385,7 +385,6 @@ QVariant getBookAttribute(const kiwix::Book& b, const QString& a)
|
|||||||
if ( a == "date" ) return QString::fromStdString(b.getDate());
|
if ( a == "date" ) return QString::fromStdString(b.getDate());
|
||||||
if ( a == "url" ) return QString::fromStdString(b.getUrl());
|
if ( a == "url" ) return QString::fromStdString(b.getUrl());
|
||||||
if ( a == "name" ) return QString::fromStdString(b.getName());
|
if ( a == "name" ) return QString::fromStdString(b.getName());
|
||||||
if ( a == "downloadId" ) return QString::fromStdString(b.getDownloadId());
|
|
||||||
if ( a == "favicon") return getFaviconDataOrUrl(b);
|
if ( a == "favicon") return getFaviconDataOrUrl(b);
|
||||||
if ( a == "size" ) return QString::number(b.getSize());
|
if ( a == "size" ) return QString::number(b.getSize());
|
||||||
if ( a == "tags" ) return getBookTags(b);
|
if ( a == "tags" ) return getBookTags(b);
|
||||||
@ -422,9 +421,9 @@ void ContentManager::openBookWithIndex(const QModelIndex &index)
|
|||||||
QString bookId;
|
QString bookId;
|
||||||
auto bookNode = static_cast<Node*>(index.internalPointer());
|
auto bookNode = static_cast<Node*>(index.internalPointer());
|
||||||
bookId = bookNode->getBookId();
|
bookId = bookNode->getBookId();
|
||||||
// check if the book is available in local library, will throw std::out_of_range if it isn't.
|
// throws std::out_of_range if the book isn't available in local library
|
||||||
mp_library->getBookById(bookId);
|
const kiwix::Book& book = mp_library->getBookById(bookId);
|
||||||
if (getBookInfos(bookId, {"downloadId"})["downloadId"] != "")
|
if ( !book.getDownloadId().empty() )
|
||||||
return;
|
return;
|
||||||
openBook(bookId);
|
openBook(bookId);
|
||||||
} catch (std::out_of_range &e) {}
|
} catch (std::out_of_range &e) {}
|
||||||
|
@ -169,8 +169,7 @@ void ContentManagerDelegate::paint(QPainter *painter, const QStyleOptionViewItem
|
|||||||
try {
|
try {
|
||||||
const auto id = node->getBookId();
|
const auto id = node->getBookId();
|
||||||
const auto book = KiwixApp::instance()->getLibrary()->getBookById(id);
|
const auto book = KiwixApp::instance()->getLibrary()->getBookById(id);
|
||||||
if(KiwixApp::instance()->getContentManager()->getBookInfos(id, {"downloadId"})["downloadId"] != "") {
|
if ( book.getDownloadId().empty() ) {
|
||||||
} else {
|
|
||||||
button.text = gt("open");
|
button.text = gt("open");
|
||||||
}
|
}
|
||||||
} catch (std::out_of_range& e) {
|
} catch (std::out_of_range& e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user