diff options
author | kh1 <karsten.heimrich@digia.com> | 2014-01-09 08:56:43 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-09 10:34:55 +0100 |
commit | 8895a66805e1a13bc909af30a545d78da65080d3 (patch) | |
tree | 41e6a7973e9130d7d7c62e88bf96867ec97fd2dc /src/assistant/help | |
parent | c1c77a9505d437c469662c3992cc336058f9c8fa (diff) | |
download | qttools-8895a66805e1a13bc909af30a545d78da65080d3.tar.gz |
Assistant: Introduce a 'compact' display for the simple search
Setting the mode disables the Previous and Next buttons for the simple
search history. This is meant to be used e.g. in Qt Creator where the
horizontal space in the side bar is precious.
Change-Id: If13ffbf2656c471ceb10c5bb15e39166fedbcb85
Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
Diffstat (limited to 'src/assistant/help')
-rw-r--r-- | src/assistant/help/qhelpsearchquerywidget.cpp | 38 | ||||
-rw-r--r-- | src/assistant/help/qhelpsearchquerywidget.h | 3 |
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(); |