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_p_h 22 #define __ctkMenuComboBox_p_h 23 24 // Qt includes 25 #include <QComboBox> 26 #include <QPointer> 27 28 // CTK includes 29 #include "ctkMenuComboBox.h" 30 class ctkCompleter; 31 class QToolButton; 32 33 /// \ingroup Widgets 34 class ctkMenuComboBoxInternal: public QComboBox 35 { 36 Q_OBJECT 37 public: 38 /// Superclass typedef 39 typedef QComboBox Superclass; 40 41 ctkMenuComboBoxInternal(); 42 virtual ~ctkMenuComboBoxInternal(); 43 virtual void showPopup(); 44 45 virtual QSize minimumSizeHint()const; 46 Q_SIGNALS: 47 void popupShown(); 48 public: 49 QPointer<QMenu> Menu; 50 }; 51 52 // ------------------------------------------------------------------------- 53 /// \ingroup Widgets 54 class ctkMenuComboBoxPrivate: public QObject 55 { 56 Q_OBJECT 57 Q_DECLARE_PUBLIC(ctkMenuComboBox); 58 protected: 59 ctkMenuComboBox* const q_ptr; 60 public: 61 ctkMenuComboBoxPrivate(ctkMenuComboBox& object); 62 void init(); 63 QAction* actionByTitle(const QString& text, const QMenu* parentMenu); 64 void setCurrentText(const QString& newCurrentText); 65 QString currentText()const; 66 67 void setCurrentIcon(const QIcon& newCurrentIcon); 68 QIcon currentIcon()const; 69 70 void addAction(QAction* action); 71 void addMenuToCompleter(QMenu* menu); 72 void addActionToCompleter(QAction* action); 73 74 void removeActionToCompleter(QAction* action); 75 76 public Q_SLOTS: 77 void setComboBoxEditable(bool editable = true); 78 void onCompletion(const QString& text); 79 80 protected: 81 QIcon DefaultIcon; 82 QString DefaultText; 83 bool IsDefaultTextCurrent; 84 bool IsDefaultIconCurrent; 85 86 ctkMenuComboBox::EditableBehavior EditBehavior; 87 88 ctkMenuComboBoxInternal* MenuComboBox; 89 ctkCompleter* SearchCompleter; 90 QPointer<QMenu> Menu; 91 QToolButton* SearchButton; 92 }; 93 94 #endif 95 96