itom  4.1.0
menuComboBox_p.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet Stuttgart, Germany
6 
7  This file is part of itom and its software development toolkit (SDK).
8 
9  itom is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Library General Public Licence as published by
11  the Free Software Foundation; either version 2 of the Licence, or (at
12  your option) any later version.
13 
14  In addition, as a special exception, the Institut fuer Technische
15  Optik (ITO) gives you certain additional rights.
16  These rights are described in the ITO LGPL Exception version 1.0,
17  which can be found in the file LGPL_EXCEPTION.txt in this package.
18 
19  itom is distributed in the hope that it will be useful, but
20  WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
22  General Public Licence for more details.
23 
24  You should have received a copy of the GNU Library General Public License
25  along with itom. If not, see <http://www.gnu.org/licenses/>.
26 
27  This file is a port and modified version of the
28  Common framework (http://www.commontk.org)
29 *********************************************************************** */
30 
31 #ifndef MENUCOMBOBOX_P_H
32 #define MENUCOMBOBOX_P_H
33 
34 // Qt includes
35 #include <QComboBox>
36 #include <QPointer>
37 
38 // CTK includes
39 #include "menuComboBox.h"
40 class Completer;
41 class QToolButton;
42 
44 class MenuComboBoxInternal : public QComboBox
45 {
46  Q_OBJECT
47 public:
49  typedef QComboBox Superclass;
50 
52  virtual ~MenuComboBoxInternal();
53  virtual void showPopup();
54 
55  virtual QSize minimumSizeHint()const;
56 Q_SIGNALS:
57  void popupShown();
58 public:
59  QPointer<QMenu> Menu;
60 };
61 
62 // -------------------------------------------------------------------------
64 class MenuComboBoxPrivate : public QObject
65 {
66  Q_OBJECT
67  Q_DECLARE_PUBLIC(MenuComboBox);
68 
69 protected:
70  MenuComboBox* const q_ptr;
71 public:
73  void init();
74  QAction* actionByTitle(const QString& text, const QMenu* parentMenu);
75  void setCurrentText(const QString& newCurrentText);
76  QString currentText()const;
77 
78  void setCurrentIcon(const QIcon& newCurrentIcon);
79  QIcon currentIcon()const;
80 
81  void addAction(QAction* action);
82  void addMenuToCompleter(QMenu* menu);
83  void addActionToCompleter(QAction* action);
84 
85  void removeAction(QAction* action);
86  void removeMenuFromCompleter(QMenu* menu);
87  void removeActionFromCompleter(QAction* action);
88 
89 public Q_SLOTS:
90  void setComboBoxEditable(bool editable = true);
91  void onCompletion(const QString& text);
92 
93 protected:
94  QIcon DefaultIcon;
95  QString DefaultText;
96  bool IsDefaultTextCurrent;
97  bool IsDefaultIconCurrent;
98 
99  MenuComboBox::EditableBehavior EditBehavior;
100 
101  MenuComboBoxInternal* mMenuComboBox;
102  Completer* SearchCompleter;
103  QPointer<QMenu> CompleterMenu;
104  QToolButton* SearchButton;
105 };
106 
107 #endif
Definition: menuComboBox.h:63
Definition: menuComboBox_p.h:64
QComboBox Superclass
Superclass typedef.
Definition: menuComboBox_p.h:49
Definition: menuComboBox_p.h:44
Definition: completer.h:63