CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkMenuComboBox.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Library: CTK
4 
5  Copyright (c) Kitware Inc.
6 
7  Licensed under the Apache License, Version 2.0 (the "License");
8  you may not use this file except in compliance with the License.
9  You may obtain a copy of the License at
10 
11  http://www.apache.org/licenses/LICENSE-2.0.txt
12 
13  Unless required by applicable law or agreed to in writing, software
14  distributed under the License is distributed on an "AS IS" BASIS,
15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  See the License for the specific language governing permissions and
17  limitations under the License.
18 
19 =========================================================================*/
20 
21 #ifndef __ctkMenuComboBox_h
22 #define __ctkMenuComboBox_h
23 
24 // Qt includes
25 #include <QMenu>
26 #include <QMetaType>
27 #include <QWidget>
28 class QComboBox;
29 class QToolButton;
30 
31 // CTK includes
32 #include "ctkWidgetsExport.h"
33 class ctkCompleter;
34 class ctkMenuComboBoxPrivate;
35 
48 
52 
53 class CTK_WIDGETS_EXPORT ctkMenuComboBox : public QWidget
54 {
55  Q_OBJECT
56  Q_ENUMS(EditableBehavior)
60  Q_PROPERTY(QString defaultText READ defaultText WRITE setDefaultText)
64  Q_PROPERTY(QIcon defaultIcon READ defaultIcon WRITE setDefaultIcon)
70  Q_PROPERTY(EditableBehavior editBehavior READ editableBehavior WRITE setEditableBehavior)
73  Q_PROPERTY(bool searchIconVisible READ isSearchIconVisible WRITE setSearchIconVisible)
78  Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle)
79 public:
81  NotEditable = 0,
84  EditableOnPopup
85  };
86 
88  typedef QWidget Superclass;
89 
91  ctkMenuComboBox(QWidget* parent = 0);
92  virtual ~ctkMenuComboBox();
93 
95  void setMenu(QMenu* menu);
96  QMenu* menu()const;
97 
98  void setDefaultText(const QString&);
99  QString defaultText()const;
100 
101  void setDefaultIcon(const QIcon&);
102  QIcon defaultIcon()const;
103 
104  void setEditableBehavior(EditableBehavior editBehavior);
105  EditableBehavior editableBehavior()const;
106 
107  void setSearchIconVisible(bool state);
108  bool isSearchIconVisible() const;
109 
110  Qt::ToolButtonStyle toolButtonStyle() const;
111 
114  void setMinimumContentsLength(int characters);
115 
117  QComboBox* menuComboBoxInternal() const;
118 
120  QToolButton* toolButtonInternal() const;
121 
123  ctkCompleter* searchCompleter() const;
124 
125 protected:
126  virtual bool eventFilter(QObject* target, QEvent* event);
127 
128 public Q_SLOTS:
129  void clearActiveAction();
130  void setToolButtonStyle(Qt::ToolButtonStyle style);
131 
132 Q_SIGNALS:
133  void actionChanged(QAction* action);
134  void popupShown();
135 
136 protected Q_SLOTS:
140  void onActionSelected(QAction* action);
142  void onEditingFinished();
143 
144 protected:
145  QScopedPointer<ctkMenuComboBoxPrivate> d_ptr;
146 
147 private:
148  Q_DECLARE_PRIVATE(ctkMenuComboBox);
149  Q_DISABLE_COPY(ctkMenuComboBox);
150 };
151 
153 
154 #endif
ctkMenuComboBox
Definition: ctkMenuComboBox.h:53
ctkMenuComboBox::EditableOnFocus
@ EditableOnFocus
Definition: ctkMenuComboBox.h:83
ctkCompleter
Definition: ctkCompleter.h:52
ctkWrapPythonQt.action
action
Definition: ctkWrapPythonQt.py:214
ctkMenuComboBox::Superclass
QWidget Superclass
Superclass typedef.
Definition: ctkMenuComboBox.h:88
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(ctkDICOMPersonName)
ctkMenuComboBox::EditableBehavior
EditableBehavior
Definition: ctkMenuComboBox.h:80
ctkMenuComboBox::d_ptr
QScopedPointer< ctkMenuComboBoxPrivate > d_ptr
Definition: ctkMenuComboBox.h:145
ctkMenuComboBox::Editable
@ Editable
Definition: ctkMenuComboBox.h:82