itom
Loading...
Searching...
No Matches
menuComboBox.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2020, Institut für Technische Optik (ITO),
5 Universität 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 für 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_H
32#define MENUCOMBOBOX_H
33
34// Qt includes
35#include <QMenu>
36#include <QMetaType>
37#include <QWidget>
38#include <qvariant.h>
39#include <qlist.h>
40class QComboBox;
41class QToolButton;
42
43// CTK includes
44#include "commonWidgets.h"
45class Completer;
47
60
64
65class ITOMWIDGETS_EXPORT MenuComboBox : public QWidget
66{
67 Q_OBJECT
68
72 Q_PROPERTY(QString defaultText READ defaultText WRITE setDefaultText)
76 Q_PROPERTY(QIcon defaultIcon READ defaultIcon WRITE setDefaultIcon)
82 Q_PROPERTY(EditableBehavior editBehavior READ editableBehavior WRITE setEditableBehavior)
85 Q_PROPERTY(bool searchIconVisible READ isSearchIconVisible WRITE setSearchIconVisible)
90 Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle)
91public:
92 enum EditableBehavior{
93 NotEditable = 0,
94 Editable,
95 EditableOnFocus,
96 EditableOnPopup
97 };
98
99 //Q_ENUM exposes a meta object to the enumeration types, such that the key names for the enumeration
100 //values are always accessible.
101 Q_ENUM(EditableBehavior)
102
103
104 typedef QWidget Superclass;
105
107 MenuComboBox(QWidget* parent = 0);
108 virtual ~MenuComboBox();
109
112 Q_INVOKABLE void setMenu(QMenu* menu);
113 Q_INVOKABLE QMenu* menu()const;
114
120 Q_INVOKABLE void setCompleterMenu(QMenu* menu);
121 Q_INVOKABLE QMenu* completerMenu()const;
122
123 void setDefaultText(const QString&);
124 QString defaultText()const;
125
126 void setDefaultIcon(const QIcon&);
127 QIcon defaultIcon()const;
128
129 void setEditableBehavior(EditableBehavior editBehavior);
130 EditableBehavior editableBehavior()const;
131
132 void setSearchIconVisible(bool state);
133 bool isSearchIconVisible() const;
134
135 Qt::ToolButtonStyle toolButtonStyle() const;
136
139 void setMinimumContentsLength(int characters);
140
142 QComboBox* menuComboBoxInternal() const;
143
145 QToolButton* toolButtonInternal() const;
146
148 Completer* searchCompleter() const;
149
150protected:
151 virtual bool eventFilter(QObject* target, QEvent* event);
152
153public Q_SLOTS:
154 void clearActiveAction();
155 void setToolButtonStyle(Qt::ToolButtonStyle style);
156
158 /* This slot has no further functionality and can be used
159 to test the proper marshalling between Python, C++ and Qt.
160 */
161 QVariantList __unittestVariantList(const QVariantList &list);
162
163 int __unittestInt(int value);
164 qint64 __unittestInt64(qint64 value);
165 quint64 __unittestUInt64(quint64 value);
166 float __unittestFloat(float value);
167 double __unittestDouble(double value);
168 short __unittestShort(short value);
169
170Q_SIGNALS:
171 void actionChanged(QAction* action);
172 void popupShown();
173
174protected Q_SLOTS:
178 void onActionSelected(QAction* action);
180 void onEditingFinished();
181
182protected:
183 QScopedPointer<MenuComboBoxPrivate> d_ptr;
184
185private:
186 Q_DECLARE_PRIVATE(MenuComboBox);
187 Q_DISABLE_COPY(MenuComboBox);
188};
189
190Q_DECLARE_METATYPE(MenuComboBox::EditableBehavior)
191
192#endif
Definition completer.h:64
Definition menuComboBox.h:66
QWidget Superclass
Superclass typedef.
Definition menuComboBox.h:104
Definition menuComboBox_p.h:65