itom  3.0.0
comboBox.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2016, Institut fuer Technische Optik (ITO),
5  Universitaet 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 fuer 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 COMBOBOX_H
32 #define COMBOBOX_H
33 
34 // Qt includes
35 #include <QComboBox>
36 
37 // CTK includes
38 //#include "ctkPimpl.h"
39 #include "commonWidgets.h"
40 class ComboBoxPrivate;
41 
54 class ITOMWIDGETS_EXPORT ComboBox : public QComboBox
55 {
56  Q_OBJECT
57  Q_PROPERTY(QString defaultText READ defaultText WRITE setDefaultText)
58  Q_PROPERTY(QIcon defaultIcon READ defaultIcon WRITE setDefaultIcon)
59  Q_PROPERTY(bool forceDefault READ isDefaultForced WRITE forceDefault)
60  Q_PROPERTY(Qt::TextElideMode elideMode READ elideMode WRITE setElideMode)
64  Q_PROPERTY(ScrollEffect scrollWheelEffect READ scrollWheelEffect WRITE setScrollWheelEffect)
65 
66 #if QT_VERSION < 0x050500
67  //for >= Qt 5.5.0 see Q_ENUM definition below
68  Q_ENUMS(ScrollEffect);
69 #endif
70 
71 public:
73  explicit ComboBox(QWidget* parent = 0);
74  virtual ~ComboBox();
75 
77  void setDefaultText(const QString&);
78  QString defaultText()const;
79 
81  void setDefaultIcon(const QIcon&);
82  QIcon defaultIcon()const;
83 
86  void forceDefault(bool forceDefault);
87  bool isDefaultForced()const;
88 
91  void setElideMode(const Qt::TextElideMode& newMode);
92  Qt::TextElideMode elideMode()const;
93 
96  {
106  ScrollWithNoVScrollBar
107  };
108 
109 #if QT_VERSION >= 0x050500
110  //Q_ENUM exposes a meta object to the enumeration types, such that the key names for the enumeration
111  //values are always accessible.
112  Q_ENUM(ScrollEffect);
113 #endif
114 
117  ScrollEffect scrollWheelEffect()const;
120  void setScrollWheelEffect(ScrollEffect scroll);
121 
123  virtual QSize minimumSizeHint()const;
125  virtual QSize sizeHint()const;
126 
127 protected:
129  virtual void paintEvent(QPaintEvent* event);
130  virtual void changeEvent(QEvent* event);
131  virtual void wheelEvent(QWheelEvent* event);
132 
133 protected:
134  QScopedPointer<ComboBoxPrivate> d_ptr;
135 
136 private:
137  Q_DECLARE_PRIVATE(ComboBox);
138  Q_DISABLE_COPY(ComboBox);
139 };
140 
141 #endif
Definition: comboBox.h:103
ComboBox is an advanced QComboBox. It adds multiple features:
Definition: comboBox.h:54
Scrolling is always possible with the mouse wheel.
Definition: comboBox.h:100
Scrolling is not possible with the mouse wheel.
Definition: comboBox.h:98
ScrollEffect
turn into flags ?
Definition: comboBox.h:95
Definition: comboBox.cpp:43