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

Implement Fine-Tuned Zim Search #1189

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7b7c949
Introduce suggestiolistmodel.{h, cpp}
ShaopengLin Aug 19, 2024
1f1743b
Move SearchBarLineEdit urlList to SuggestionListModel
ShaopengLin Sep 1, 2024
8611a1c
Enter Library::getZimIcon()
ShaopengLin Sep 1, 2024
6cbc9e8
Add Suggestion Icon Decoration Role
ShaopengLin Sep 1, 2024
c029da2
Refactor SuggestionListWorker
ShaopengLin Sep 1, 2024
d5de7c6
Introduce SuggestionListModel::lastIndex
ShaopengLin Sep 17, 2024
0aac03f
Introduce Endless Suggestions
ShaopengLin Sep 17, 2024
84e29ec
Endless Suggestion Key press compatible
ShaopengLin Sep 17, 2024
2aca115
Endless Suggestion Page_Down Compatible
ShaopengLin Sep 17, 2024
1894d41
Correctly handle Endless w/Fulltext
ShaopengLin Sep 17, 2024
d0a1680
Fetch Only When More Suggesion Exist
ShaopengLin Sep 18, 2024
76bae0d
Make First Row Visible on Suggestion Popup
ShaopengLin Sep 17, 2024
a7d7304
Introduce Kiwix Search Header
ShaopengLin Sep 17, 2024
d713173
Replace m_completer.popup() with m_suggestionView
ShaopengLin Sep 17, 2024
b3d9424
Enter KiwixApp::getSearchBar()
ShaopengLin Sep 17, 2024
ff7117b
BugFix openCompletion Connected Multiple Times
ShaopengLin Sep 28, 2024
ce36366
Make SearchBar Margin Consistent
ShaopengLin Sep 28, 2024
b9f4f94
Align Search Suggestion with Line Edit
ShaopengLin Sep 28, 2024
02e042a
Fix Suggestion Flickering when Typing
ShaopengLin Sep 28, 2024
dac8d04
Proper Size for Suggestion View
ShaopengLin Sep 28, 2024
fcebdd0
Proper Suggestion Icon&Text Spacing
ShaopengLin Sep 28, 2024
64b30c3
Proper Hover Style to Suggestion Items
ShaopengLin Sep 28, 2024
b19ea81
Proper Elide for Suggestion List Text
ShaopengLin Sep 28, 2024
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
6 changes: 6 additions & 0 deletions src/searchbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@ void SearchBarLineEdit::fetchMoreSuggestion()

void SearchBarLineEdit::onScrollToEnd(int value)
{
if (m_suggestionModel.noMoreSuggestion())
{
m_scrolledEndBefore = false;
return;
}

if (!m_completer.popup()->currentIndex().isValid())
{
m_scrolledEndBefore = false;
Expand Down
9 changes: 9 additions & 0 deletions src/suggestionlistmodel.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "suggestionlistmodel.h"
#include "kiwixapp.h"
#include "suggestionlistworker.h"

#include <QIcon>

Expand Down Expand Up @@ -62,6 +63,7 @@ void SuggestionListModel::resetUrlList(const QVector<QUrl> &urlList)
{
beginResetModel();
m_urlList = urlList;
setNoMoreSuggestion(urlList.size());
endResetModel();
}

Expand All @@ -80,6 +82,7 @@ void SuggestionListModel::append(const QStringList &suggestions,
m_urlList.append(urlList[i]);
m_suggestions.append(suggestions[i]);
}
setNoMoreSuggestion(urlList.size());
endResetModel();
}

Expand All @@ -93,3 +96,9 @@ QModelIndex SuggestionListModel::fetchEndIndex() const
int trueFetchSize = m_urlList.size() - (m_hasFullText ? 1 : 0);
return index(trueFetchSize - 1);
}

void SuggestionListModel::setNoMoreSuggestion(int fetchedSize)
{
int trueFetchSize = fetchedSize - (m_hasFullText ? 1 : 0);
m_noMoreSuggestion = trueFetchSize < SuggestionListWorker::getFetchSize();
ShaopengLin marked this conversation as resolved.
Show resolved Hide resolved
}
4 changes: 4 additions & 0 deletions src/suggestionlistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ class SuggestionListModel : public QAbstractListModel
QModelIndex fetchEndIndex() const;
void setHasFullText(bool hasFullText) { m_hasFullText = hasFullText; }
bool hasFullText() const { return m_hasFullText; }
bool noMoreSuggestion() const { return m_noMoreSuggestion; }

private:
QStringList m_suggestions;
QVector<QUrl> m_urlList;
bool m_hasFullText = true;
bool m_noMoreSuggestion = true;

void setNoMoreSuggestion(int fetchedSize);
};

#endif // SUGGESTIONLISTMODEL_H