-
-
Notifications
You must be signed in to change notification settings - Fork 118
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
Implement Endless Zim Search Suggestions #1224
Conversation
Also there is the following bug:
As soon as you have typed the first three letters (bea) the text in the search box automatically changes to bea (Fulltext search). |
cc90069
to
1804f56
Compare
@veloman-yunkan The bug is caused by the absence of the commits that prevent suggestion completer flickering. I added those and the bug should be solved. |
02b297f
to
b4e5695
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can guess from the changed nature of most comments that we are now very close to merging this PR. The next iteration can be the final one.
aebe4db
to
4fa9ab4
Compare
4fa9ab4
to
b6a6c06
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still a couple of bugs (one old and one new) so let's brush up the PR a bit more.
b6a6c06
to
1bc6c82
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An issue was still left because of hasty conflict resolution. Since you have to fix it, please address a few other comments as well.
src/searchbar.cpp
Outdated
if (!m_aboutToScrollPastEnd) | ||
return false; | ||
|
||
if (auto e = dynamic_cast<QKeyEvent *>(event)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This time I checked the documentation of QObject::eventFilter()
as I was curious about the need for its first parameter). I saw in the example that a dynamic_cast
is not used because there is a cheaper way - QEvent::type()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work, as many key press events are not based on exactly keypress, such as QEvent::ShortcutOverride. This also explains some the same issue: https://forum.qt.io/topic/101176/casts-for-events
src/searchbar.cpp
Outdated
|
||
if (auto e = dynamic_cast<QKeyEvent *>(event)) | ||
{ | ||
if (e->key() == Qt::Key_PageDown && e->modifiers().testFlag(Qt::NoModifier)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I wonder if it's better to handle key down here too (instead of your previous fix for it). Won't it eliminate the need to undo the handling of wrapping from bottom to top? If yes then the final code will be simpler, and so let's do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it seems the scrolling event from Key_down either reaches the popup first or isn't blocked from reaching the popup. I simply removed onScrollPastEnd and put the scrolling only inside the onScroll !m_completer.popup()->currentIndex().isValid()
case.
src/searchbar.cpp
Outdated
void SearchBarLineEdit::fetchMoreSuggestions() | ||
{ | ||
fetchSuggestions(&SearchBarLineEdit::onAdditionalSuggestions); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This encapsulates a performance bug. fetchSuggestions()
creates a temporary SuggestionListWorker
which creates zim::SuggestionSearcher
that is discarded after a single use. In a more optimal implementation the zim::SuggestionSearcher
should be reused for loading additional suggestions (since those incremental calls to zim::SuggestionSearcher::getResults()
should be much cheaper compared to the first call). I am not implying that that optimization be implemented in this PR. I propose to do it myself after this PR is merged, but if you feel like becoming married to this suggestions feature and would like to take care of it to the end I will humbly stay away :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do this separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely. But please add a TODO comment in the body of SearchBarLineEdit::fetchMoreSuggestions()
in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't start working on this until the rest of your kiwix-desktop
PRs are merged.
1bc6c82
to
07aa791
Compare
Allow future customizing of suggestions.
More cohesive design to utilize new model's index data.
Data required can be retrieved from model.
Remove unecessary checks and prevent misuse if openCompletion.
Refactor to simplify book icon retrieval
Add offset and fetch size, prepare for endless.
Automatically determine start and allow custom callback. Prepare for endless
Trigger on scroll.
Down/Page_Down Key press correctly fetches.
Fetch offset and model removal requires this.
Before, view scroll to row based on prefix match
Focus event can happen more than once.
setCompleter call setCompletionPrefix on typing which flicker
f62d9ac
to
9982a22
Compare
This PR broke the handling of pressing ENTER in the search bar - it always opens the first suggestion (even if it doesn't fully match the text in the searchbar). |
@veloman-yunkan I believe its mainly from this #1224 (comment) where we discarded the checks for text comparison inside openCompletion. I will think of a way to avoid the duplication of text check in both openCompletion and getDefaultSuggestionIndex in #1189 |
I cannot agree. I don't see any flaw with the design of that approach. |
@veloman-yunkan getDefaultSuggestionIndex is only called during typing. openCompletion is also signaled normalled when user activate(click/enter) on a cell when not typing. openCompletion itself does not use getDefaultSuggestionIndex. |
@ShaopengLin Yes. But when an item from the list is activated |
The bug is that |
@veloman-yunkan Please open a dedicated issue, not very much cinfirtable with discussion on closed issues/PRa. |
Done (#1230) |
Fixes (part of) #413
Changes:
Known Issues to be fixed in #1189: The first suggestion is hidden by the header due to QCompleter's incorrect size management.