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 
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 
124 
125 protected:
126  virtual bool eventFilter(QObject* target, QEvent* event);
127 
128 public Q_SLOTS:
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);
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
virtual ~ctkMenuComboBox()
bool isSearchIconVisible() const
EditableBehavior editableBehavior() const
QMenu * menu() const
void setMenu(QMenu *menu)
Add a menu to the QcomboBox and set a QCompleter.
void setToolButtonStyle(Qt::ToolButtonStyle style)
QWidget Superclass
Superclass typedef.
void setDefaultText(const QString &)
void setEditableBehavior(EditableBehavior editBehavior)
void clearActiveAction()
QToolButton * toolButtonInternal() const
Return the internal tool button.
ctkCompleter * searchCompleter() const
Return the internal completer.
Qt::ToolButtonStyle toolButtonStyle() const
void setSearchIconVisible(bool state)
void setDefaultIcon(const QIcon &)
void setMinimumContentsLength(int characters)
ctkMenuComboBox(QWidget *parent=0)
void onEditingFinished()
action selected from the line edit or the completer.
void actionChanged(QAction *action)
QIcon defaultIcon() const
void onActionSelected(QAction *action)
QString defaultText() const
virtual bool eventFilter(QObject *target, QEvent *event)
QComboBox * menuComboBoxInternal() const
Return the internal combo box.
QScopedPointer< ctkMenuComboBoxPrivate > d_ptr
Q_DECLARE_METATYPE(ctkDICOMPersonName)