From 7e9dba4e5ea8d91c8268cc259be8a7c6e6584dd8 Mon Sep 17 00:00:00 2001 From: Johannes Schirm <9149359+jojosoft@users.noreply.github.com> Date: Sun, 13 Sep 2020 14:41:03 +0200 Subject: [PATCH 1/2] Set items in the booktree to collapsed by default Having all books collapsed by default makes it much easier to jump between them. I think this is a more frequently needed requirement than seeing all matches. --- src/bookview.cpp | 4 ++++ src/pagewidget.cpp | 10 ++++++++++ src/pagewidget.h | 2 ++ 3 files changed, 16 insertions(+) diff --git a/src/bookview.cpp b/src/bookview.cpp index b2f446b..fdacf39 100644 --- a/src/bookview.cpp +++ b/src/bookview.cpp @@ -129,6 +129,10 @@ RET_SEARCH BookView::newPage(QWidget *parent, const Query& query, bool newTab, RET_SEARCH retStatus = page->search(query); + // Collapse the book tree by default. + // This makes jumping between books easier. + page->collapseBookTree(); + QWidget *focus_page = 0; BookView *view = this; if (retStatus == NORMAL) { diff --git a/src/pagewidget.cpp b/src/pagewidget.cpp index 1bfe385..f356a30 100644 --- a/src/pagewidget.cpp +++ b/src/pagewidget.cpp @@ -39,6 +39,16 @@ PageWidget::PageWidget(QWidget *parent, const SearchMethod &method) SLOT(popupSlide(QPoint))); } +void PageWidget::collapseBookTree() +{ + try { + QTreeWidgetItem* root = bookTree->topLevelItem(0); + for (int i = 0; i < root->childCount(); i++) { + root->child(i)->setExpanded(false); + } + } catch (...) {}; +} + bool PageWidget::checkStop() { QEventLoop().processEvents(); diff --git a/src/pagewidget.h b/src/pagewidget.h index 453b372..b701413 100644 --- a/src/pagewidget.h +++ b/src/pagewidget.h @@ -16,6 +16,8 @@ class PageWidget : public QSplitter virtual RET_SEARCH search(const Query&) = 0; + void collapseBookTree(); + void zoomIn(); void zoomOut(); BookBrowser* bookBrowser() From e342d3a9a40e849fcf30a2b6bff9b6632f78eb17 Mon Sep 17 00:00:00 2001 From: Johannes Schirm <9149359+jojosoft@users.noreply.github.com> Date: Sun, 13 Sep 2020 15:21:13 +0200 Subject: [PATCH 2/2] Adjust string split flags from Qt:: to QString:: --- src/ebook.cpp | 2 +- src/mainwindow.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ebook.cpp b/src/ebook.cpp index 5470a13..685dca9 100644 --- a/src/ebook.cpp +++ b/src/ebook.cpp @@ -57,7 +57,7 @@ int EBook::searchQuery(int maxcnt, const QString& query, SearchType type) case SearchKeyWord: case SearchCrossWord: { - words = query.split(QRegExp("\\s+"), Qt::SkipEmptyParts); + words = query.split(QRegExp("\\s+"), QString::SkipEmptyParts); return hitMultiWord(maxcnt, words, type); } default: diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6e93c07..d9a3d46 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -651,7 +651,7 @@ void MainWindow::toggleBar() void MainWindow::changeOptSearchButtonText(const QString &str) { - QStringList list = str.split(QRegExp("\\W+"), Qt::SkipEmptyParts); + QStringList list = str.split(QRegExp("\\W+"), QString::SkipEmptyParts); if (list.count() > 0) { optSearchButton->setText(list[0]); @@ -884,7 +884,7 @@ void MainWindow::pasteMethod(const QString &str, const SearchMethod &m) if (m.direction == WholeRead || m.direction == MenuRead || m.direction == BookInfo ) { } else { - QStringList list = str.split(QRegExp("\\s+"), Qt::SkipEmptyParts); + QStringList list = str.split(QRegExp("\\s+"), QString::SkipEmptyParts); searchTextEdit->setText(list.join(" ")); } }