Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set items in the booktree to collapsed by default #37

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/bookview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/ebook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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(" "));
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/pagewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/pagewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class PageWidget : public QSplitter

virtual RET_SEARCH search(const Query&) = 0;

void collapseBookTree();

void zoomIn();
void zoomOut();
BookBrowser* bookBrowser()
Expand Down