mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -04:00
parent
d2061a69a5
commit
078dd8ebe4
@ -62,6 +62,7 @@ ContentManager::ContentManager(Library* library, kiwix::Downloader* downloader,
|
||||
connect(&m_remoteLibraryManager, &OpdsRequestManager::requestReceived, this, &ContentManager::updateRemoteLibrary);
|
||||
connect(mp_view->getView(), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onCustomContextMenu(const QPoint &)));
|
||||
connect(this, &ContentManager::pendingRequest, mp_view, &ContentManagerView::showLoader);
|
||||
connect(treeView, &QTreeView::doubleClicked, this, &ContentManager::openBookWithIndex);
|
||||
}
|
||||
|
||||
QList<QMap<QString, QVariant>> ContentManager::getBooksList()
|
||||
@ -227,6 +228,21 @@ QMap<QString, QVariant> ContentManager::getBookInfos(QString id, const QStringLi
|
||||
}
|
||||
#undef ADD_V
|
||||
|
||||
void ContentManager::openBookWithIndex(const QModelIndex &index)
|
||||
{
|
||||
try {
|
||||
Node* bookNode = static_cast<Node*>(index.internalPointer());
|
||||
auto bookId = bookNode->getBookId();
|
||||
if (bookNode->isAdditonal())
|
||||
bookId = bookNode->parentItem()->getBookId();
|
||||
// check if the book is available in local library, will throw std::out_of_range if it isn't.
|
||||
KiwixApp::instance()->getLibrary()->getBookById(bookId);
|
||||
if (getBookInfos(bookId, {"downloadId"})["downloadId"] != "")
|
||||
return;
|
||||
openBook(bookId);
|
||||
} catch (std::out_of_range &e) {}
|
||||
}
|
||||
|
||||
void ContentManager::openBook(const QString &id)
|
||||
{
|
||||
QUrl url("zim://"+id+".zim/");
|
||||
|
@ -77,6 +77,7 @@ public slots:
|
||||
void resumeBook(const QString& id, QModelIndex index);
|
||||
void cancelBook(const QString& id, QModelIndex index);
|
||||
void onCustomContextMenu(const QPoint &point);
|
||||
void openBookWithIndex(const QModelIndex& index);
|
||||
};
|
||||
|
||||
#endif // CONTENTMANAGER_H
|
||||
|
@ -218,6 +218,11 @@ bool ContentManagerDelegate::editorEvent(QEvent *event, QAbstractItemModel *mode
|
||||
w = r.width();
|
||||
h = r.height();
|
||||
|
||||
if (e->button() == Qt::MiddleButton && index.column() != 5) {
|
||||
KiwixApp::instance()->getContentManager()->openBookWithIndex(index);
|
||||
return true;
|
||||
}
|
||||
|
||||
const auto lastColumnClicked = ((index.column() == 5) && (clickX > x && clickX < x + w)
|
||||
&& (clickY > y && clickY < y + h));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user