Debian Codegraph @

src/Gui/CommandCompleter.h

raw
1 /****************************************************************************
2 * Copyright (c) 2022 Zheng Lei (realthunder) <[email protected]> *
3 * *
4 * This file is part of the FreeCAD CAx development system. *
5 * *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Library General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2 of the License, or (at your option) any later version. *
10 * *
11 * This library is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU Library General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Library General Public *
17 * License along with this library; see the file COPYING.LIB. If not, *
18 * write to the Free Software Foundation, Inc., 59 Temple Place, *
19 * Suite 330, Boston, MA 02111-1307, USA *
20 * *
21 ****************************************************************************/
22
23 #ifndef GUI_COMMAND_COMPLETER_H
24 #define GUI_COMMAND_COMPLETER_H
25
26 #include <FCGlobal.h>
27 #include <QCompleter>
28
29 class QLineEdit;
30
31 namespace Gui
32 {
33
34 /**
35 * Command name auto completer.
36 *
37 * This class provides an auto completer for a QLineEdit widget. The auto
38 * completer supports keyword search in command title, internal name, and
39 * shortcut.
40 */
41 class GuiExport CommandCompleter: public QCompleter
42 {
43 Q_OBJECT
44 public:
45 explicit CommandCompleter(QLineEdit* edit, QObject* parent = nullptr);
46
47 Q_SIGNALS:
48 /// Triggered when a command is selected in the completer
49 void commandActivated(const QByteArray& name);
50
51 protected Q_SLOTS:
52 void onTextChanged(const QString&);
53 void onCommandActivated(const QModelIndex&);
54
55 protected:
56 bool eventFilter(QObject*, QEvent* ev) override;
57 };
58
59 } // namespace Gui
60
61 #endif