mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-26 06:12:17 -04:00
Introduce Kiwix Search Header
This commit is contained in:
parent
951917f14d
commit
ff50e9d870
@ -171,5 +171,6 @@
|
||||
"save-page-as": "Save As...",
|
||||
"portable-disabled-tooltip": "Function disabled in portable mode",
|
||||
"scroll-next-tab": "Scroll to next tab",
|
||||
"scroll-previous-tab": "Scroll to previous tab"
|
||||
"scroll-previous-tab": "Scroll to previous tab",
|
||||
"kiwix-search": "Kiwix search"
|
||||
}
|
||||
|
@ -179,5 +179,6 @@
|
||||
"save-page-as": "Represents the action of saving the current tab content to a file chosen by the user.",
|
||||
"portable-disabled-tooltip": "Tooltip used to explain disabled components in the portable version.",
|
||||
"scroll-next-tab": "Represents the action of scrolling to the next tab of the current tab which toward the end of the tab bar.",
|
||||
"scroll-previous-tab": "Represents the action of scrolling to the previous tab of the current tab which toward the start of the tab bar."
|
||||
"scroll-previous-tab": "Represents the action of scrolling to the previous tab of the current tab which toward the start of the tab bar.",
|
||||
"kiwix-search": "Title text for a list of search results, which notes to the user those are from Kiwix's Search Engine"
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ void BookmarkButton::on_buttonClicked()
|
||||
|
||||
SearchBarLineEdit::SearchBarLineEdit(QWidget *parent) :
|
||||
QLineEdit(parent),
|
||||
m_suggestionView(new QTreeView),
|
||||
m_completer(&m_suggestionModel, this)
|
||||
{
|
||||
installEventFilter(this);
|
||||
@ -72,7 +73,13 @@ SearchBarLineEdit::SearchBarLineEdit(QWidget *parent) :
|
||||
m_completer.setMaxVisibleItems(SuggestionListWorker::getFetchSize() / 2);
|
||||
setCompleter(&m_completer);
|
||||
|
||||
m_completer.popup()->setStyleSheet(KiwixApp::instance()->parseStyleFromFile(":/css/popup.css"));
|
||||
/* QCompleter's uses default list views, which do not have headers. */
|
||||
m_completer.setPopup(m_suggestionView);
|
||||
|
||||
m_suggestionView->header()->setStretchLastSection(true);
|
||||
m_suggestionView->setRootIsDecorated(false);
|
||||
m_suggestionView->setStyleSheet(KiwixApp::instance()->parseStyleFromFile(":/css/popup.css"));
|
||||
|
||||
connect(m_completer.popup()->verticalScrollBar(), &QScrollBar::valueChanged,
|
||||
this, &SearchBarLineEdit::onScroll);
|
||||
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include <QToolBar>
|
||||
#include "suggestionlistmodel.h"
|
||||
|
||||
class QTreeView;
|
||||
|
||||
class BookmarkButton : public QToolButton {
|
||||
Q_OBJECT
|
||||
public:
|
||||
@ -42,6 +44,7 @@ protected:
|
||||
virtual void focusOutEvent(QFocusEvent *);
|
||||
private:
|
||||
SuggestionListModel m_suggestionModel;
|
||||
QTreeView *m_suggestionView;
|
||||
QCompleter m_completer;
|
||||
QString m_title;
|
||||
QString m_searchbarInput;
|
||||
|
@ -42,6 +42,21 @@ QVariant SuggestionListModel::data(const QModelIndex &index, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant SuggestionListModel::headerData(int section,
|
||||
Qt::Orientation orientation,
|
||||
int role) const
|
||||
{
|
||||
if (section != 0 || orientation != Qt::Orientation::Horizontal)
|
||||
return QVariant();
|
||||
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
return gt("kiwix-search");
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void SuggestionListModel::resetSuggestions()
|
||||
{
|
||||
beginResetModel();
|
||||
|
@ -22,6 +22,7 @@ public:
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
|
||||
void resetSuggestions();
|
||||
void append(const QList<SuggestionData>& suggestionList);
|
||||
|
Loading…
x
Reference in New Issue
Block a user