itom 2.2.1
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2016, Institut fuer Technische Optik (ITO), 00005 Universitaet Stuttgart, Germany 00006 00007 This file is part of itom and its software development toolkit (SDK). 00008 00009 itom is free software; you can redistribute it and/or modify it 00010 under the terms of the GNU Library General Public Licence as published by 00011 the Free Software Foundation; either version 2 of the Licence, or (at 00012 your option) any later version. 00013 00014 In addition, as a special exception, the Institut fuer Technische 00015 Optik (ITO) gives you certain additional rights. 00016 These rights are described in the ITO LGPL Exception version 1.0, 00017 which can be found in the file LGPL_EXCEPTION.txt in this package. 00018 00019 itom is distributed in the hope that it will be useful, but 00020 WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library 00022 General Public Licence for more details. 00023 00024 You should have received a copy of the GNU Library General Public License 00025 along with itom. If not, see <http://www.gnu.org/licenses/>. 00026 00027 This file is a port and modified version of the 00028 Common framework (http://www.commontk.org) 00029 *********************************************************************** */ 00030 00031 #ifndef MENUCOMBOBOX_H 00032 #define MENUCOMBOBOX_H 00033 00034 // Qt includes 00035 #include <QMenu> 00036 #include <QMetaType> 00037 #include <QWidget> 00038 class QComboBox; 00039 class QToolButton; 00040 00041 // CTK includes 00042 #include "commonWidgets.h" 00043 class Completer; 00044 class MenuComboBoxPrivate; 00045 00058 00062 00063 class ITOMWIDGETS_EXPORT MenuComboBox : public QWidget 00064 { 00065 Q_OBJECT 00066 Q_ENUMS(EditableBehavior) 00070 Q_PROPERTY(QString defaultText READ defaultText WRITE setDefaultText) 00074 Q_PROPERTY(QIcon defaultIcon READ defaultIcon WRITE setDefaultIcon) 00080 Q_PROPERTY(EditableBehavior editBehavior READ editableBehavior WRITE setEditableBehavior) 00083 Q_PROPERTY(bool searchIconVisible READ isSearchIconVisible WRITE setSearchIconVisible) 00088 Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle) 00089 public: 00090 enum EditableBehavior{ 00091 NotEditable = 0, 00092 Editable, 00093 EditableOnFocus, 00094 EditableOnPopup 00095 }; 00096 00098 typedef QWidget Superclass; 00099 00101 MenuComboBox(QWidget* parent = 0); 00102 virtual ~MenuComboBox(); 00103 00105 void setMenu(QMenu* menu); 00106 QMenu* menu()const; 00107 00108 void setDefaultText(const QString&); 00109 QString defaultText()const; 00110 00111 void setDefaultIcon(const QIcon&); 00112 QIcon defaultIcon()const; 00113 00114 void setEditableBehavior(EditableBehavior editBehavior); 00115 EditableBehavior editableBehavior()const; 00116 00117 void setSearchIconVisible(bool state); 00118 bool isSearchIconVisible() const; 00119 00120 Qt::ToolButtonStyle toolButtonStyle() const; 00121 00124 void setMinimumContentsLength(int characters); 00125 00127 QComboBox* menuComboBoxInternal() const; 00128 00130 QToolButton* toolButtonInternal() const; 00131 00133 Completer* searchCompleter() const; 00134 00135 protected: 00136 virtual bool eventFilter(QObject* target, QEvent* event); 00137 00138 public Q_SLOTS: 00139 void clearActiveAction(); 00140 void setToolButtonStyle(Qt::ToolButtonStyle style); 00141 00142 Q_SIGNALS: 00143 void actionChanged(QAction* action); 00144 void popupShown(); 00145 00146 protected Q_SLOTS: 00150 void onActionSelected(QAction* action); 00152 void onEditingFinished(); 00153 00154 protected: 00155 QScopedPointer<MenuComboBoxPrivate> d_ptr; 00156 00157 private: 00158 Q_DECLARE_PRIVATE(MenuComboBox); 00159 Q_DISABLE_COPY(MenuComboBox); 00160 }; 00161 00162 Q_DECLARE_METATYPE(MenuComboBox::EditableBehavior) 00163 00164 #endif