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 <QMap>
21 #include <QString>
22 #include <QLineEdit>
23 #include <QStringListModel>
24 
25 #include <gepetto/gui/fwd.hh>
26 
27 namespace gepetto {
28  namespace gui {
29  class ActionSearchBar : public QLineEdit
30  {
31  Q_OBJECT
32 
33  public:
34  ActionSearchBar (QWidget* parent);
35 
36  void addAction (QAction* action);
37 
38  QAction* showAction() const { return showAction_; }
39 
40  protected:
41  virtual void keyPressEvent ( QKeyEvent* event );
42  virtual void showEvent ( QShowEvent* event );
43 
44  private slots:
45  bool trigger(const QString& s);
46  void handleReturnPressed();
47 
48  private:
49  QStringListModel* model_;
50  QCompleter* completer_;
51  QMap<QString, QAction*> actions_;
52  QAction* showAction_;
53  };
54  }
55 }
56 
57 #endif // GEPETTO_GUI_ACTION_SEARCH_BAR_HH
virtual void showEvent(QShowEvent *event)
Definition: action-search-bar.hh:29
Definition: action-search-bar.hh:27
ActionSearchBar(QWidget *parent)
QAction * showAction() const
Definition: action-search-bar.hh:38
virtual void keyPressEvent(QKeyEvent *event)
void addAction(QAction *action)