summaryrefslogtreecommitdiff
path: root/src/assistant/help
diff options
context:
space:
mode:
Diffstat (limited to 'src/assistant/help')
-rw-r--r--src/assistant/help/qhelpsearchquerywidget.cpp38
-rw-r--r--src/assistant/help/qhelpsearchquerywidget.h3
2 files changed, 41 insertions, 0 deletions
diff --git a/src/assistant/help/qhelpsearchquerywidget.cpp b/src/assistant/help/qhelpsearchquerywidget.cpp
index d2e5da082..d07161363 100644
--- a/src/assistant/help/qhelpsearchquerywidget.cpp
+++ b/src/assistant/help/qhelpsearchquerywidget.cpp
@@ -101,6 +101,7 @@ private:
QHelpSearchQueryWidgetPrivate()
: QObject()
+ , compactMode(false)
, simpleSearch(true)
, searchCompleter(new CompleterModel(this), this)
{
@@ -287,6 +288,25 @@ private:
}
private slots:
+ bool eventFilter(QObject *ob, QEvent *event)
+ {
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent *const keyEvent = static_cast<QKeyEvent *>(event);
+ if (keyEvent->key() == Qt::Key_Down) {
+ if (simpleQueries.curQuery + 1 < simpleQueries.queries.size())
+ nextQuery();
+ return true;
+ }
+ if (keyEvent->key() == Qt::Key_Up) {
+ if (simpleQueries.curQuery > 0)
+ prevQuery();
+ return true;
+ }
+
+ }
+ return QObject::eventFilter(ob, event);
+ }
+
void showHideAdvancedSearch()
{
if (simpleSearch) {
@@ -381,6 +401,7 @@ private slots:
private:
friend class QHelpSearchQueryWidget;
+ bool compactMode;
bool simpleSearch;
QLabel *simpleSearchLabel;
QLabel *advancedSearchLabel;
@@ -441,6 +462,7 @@ QHelpSearchQueryWidget::QHelpSearchQueryWidget(QWidget *parent)
d->simpleSearchLabel = new QLabel(this);
d->defaultQuery = new QLineEdit(this);
d->defaultQuery->setCompleter(&d->searchCompleter);
+ d->defaultQuery->installEventFilter(d);
d->prevQueryButton = new QToolButton(this);
d->prevQueryButton->setArrowType(Qt::LeftArrow);
d->prevQueryButton->setEnabled(false);
@@ -529,6 +551,7 @@ QHelpSearchQueryWidget::QHelpSearchQueryWidget(QWidget *parent)
d, SLOT(showHideAdvancedSearch()));
#endif
connect(this, SIGNAL(search()), d, SLOT(searchRequested()));
+ setCompactMode(true);
}
/*!
@@ -593,6 +616,21 @@ void QHelpSearchQueryWidget::setQuery(const QList<QHelpSearchQuery> &queryList)
d->searchRequested();
}
+bool QHelpSearchQueryWidget::isCompactMode() const
+{
+ return d->compactMode;
+}
+
+void QHelpSearchQueryWidget::setCompactMode(bool on)
+{
+ if (d->compactMode != on) {
+ d->compactMode = on;
+ d->prevQueryButton->setVisible(!on);
+ d->nextQueryButton->setVisible(!on);
+ d->simpleSearchLabel->setVisible(!on);
+ }
+}
+
/*!
\reimp
*/
diff --git a/src/assistant/help/qhelpsearchquerywidget.h b/src/assistant/help/qhelpsearchquerywidget.h
index f72e2ae39..ed0e209c2 100644
--- a/src/assistant/help/qhelpsearchquerywidget.h
+++ b/src/assistant/help/qhelpsearchquerywidget.h
@@ -71,6 +71,9 @@ public:
QList<QHelpSearchQuery> query() const;
void setQuery(const QList<QHelpSearchQuery> &queryList);
+ bool isCompactMode() const;
+ Q_SLOT void setCompactMode(bool on);
+
Q_SIGNALS:
void search();