gepetto-viewer 6.0.0
An user-friendly Graphical Interface
Loading...
Searching...
No Matches
action-search-bar.hh
Go to the documentation of this file.
1// Copyright (c) 2015-2018, LAAS-CNRS
2// Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3//
4// This file is part of gepetto-viewer.
5// gepetto-viewer is free software: you can redistribute it
6// and/or modify it under the terms of the GNU Lesser General Public
7// License as published by the Free Software Foundation, either version
8// 3 of the License, or (at your option) any later version.
9//
10// gepetto-viewer is distributed in the hope that it will be
11// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13// General Lesser Public License for more details. You should have
14// received a copy of the GNU Lesser General Public License along with
15// gepetto-viewer. If not, see <http://www.gnu.org/licenses/>.
16
17#ifndef GEPETTO_GUI_ACTION_SEARCH_BAR_HH
18#define GEPETTO_GUI_ACTION_SEARCH_BAR_HH
19
20#include <gepetto/gui/fwd.hh>
21// This include must be include before any other Qt include for GLDEBUGPROC
22#include <QLineEdit>
23#include <QMap>
24#include <QString>
25#include <QStringListModel>
26
27namespace gepetto {
28namespace gui {
29class ActionSearchBar : public QLineEdit {
30 Q_OBJECT
31
32 public:
33 ActionSearchBar(QWidget* parent);
34
35 void addAction(QAction* action);
36
37 QAction* showAction() const { return showAction_; }
38
39 protected:
40 virtual void keyPressEvent(QKeyEvent* event);
41 virtual void showEvent(QShowEvent* event);
42
43 private slots:
44 bool trigger(const QString& s);
45 void handleReturnPressed();
46
47 private:
48 QStringListModel* model_;
49 QCompleter* completer_;
50 QMap<QString, QAction*> actions_;
51 QAction* showAction_;
52};
53} // namespace gui
54} // namespace gepetto
55
56#endif // GEPETTO_GUI_ACTION_SEARCH_BAR_HH
Definition action-search-bar.hh:29
virtual void keyPressEvent(QKeyEvent *event)
QAction * showAction() const
Definition action-search-bar.hh:37
ActionSearchBar(QWidget *parent)
virtual void showEvent(QShowEvent *event)
void addAction(QAction *action)
Definition action-search-bar.hh:27