1/****************************************************************************
2**
3** Copyright (C) 2017 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL3$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or later as published by the Free
28** Software Foundation and appearing in the file LICENSE.GPL included in
29** the packaging of this file. Please review the following information to
30** ensure the GNU General Public License version 2.0 requirements will be
31** met: http://www.gnu.org/licenses/gpl-2.0.html.
32**
33** $QT_END_LICENSE$
34**
35****************************************************************************/
36
37#ifndef QQUICKCOMBOBOX_P_H
38#define QQUICKCOMBOBOX_P_H
39
40//
41// W A R N I N G
42// -------------
43//
44// This file is not part of the Qt API. It exists purely as an
45// implementation detail. This header file may change from version to
46// version without notice, or even be removed.
47//
48// We mean it.
49//
50
51#include <QtCore/qloggingcategory.h>
52#include <QtQuickTemplates2/private/qquickcontrol_p.h>
53
54QT_BEGIN_NAMESPACE
55
56Q_DECLARE_LOGGING_CATEGORY(lcItemManagement)
57
58class QValidator;
59class QQuickPopup;
60class QQmlInstanceModel;
61class QQuickComboBoxPrivate;
62
63class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickComboBox : public QQuickControl
64{
65 Q_OBJECT
66 Q_PROPERTY(int count READ count NOTIFY countChanged FINAL)
67 Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged FINAL)
68 Q_PROPERTY(QQmlInstanceModel *delegateModel READ delegateModel NOTIFY delegateModelChanged FINAL)
69 Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL) // ### Qt 6: should not be writable
70 Q_PROPERTY(int highlightedIndex READ highlightedIndex NOTIFY highlightedIndexChanged FINAL)
71 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL)
72 Q_PROPERTY(QString currentText READ currentText NOTIFY currentTextChanged FINAL)
73 Q_PROPERTY(QString displayText READ displayText WRITE setDisplayText RESET resetDisplayText NOTIFY displayTextChanged FINAL)
74 Q_PROPERTY(QString textRole READ textRole WRITE setTextRole NOTIFY textRoleChanged FINAL)
75 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
76 Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL)
77 Q_PROPERTY(QQuickPopup *popup READ popup WRITE setPopup NOTIFY popupChanged FINAL)
78 // 2.1 (Qt 5.8)
79 Q_PROPERTY(bool flat READ isFlat WRITE setFlat NOTIFY flatChanged FINAL REVISION 1)
80 // 2.2 (Qt 5.9)
81 Q_PROPERTY(bool down READ isDown WRITE setDown RESET resetDown NOTIFY downChanged FINAL REVISION 2)
82 Q_PROPERTY(bool editable READ isEditable WRITE setEditable NOTIFY editableChanged FINAL REVISION 2)
83 Q_PROPERTY(QString editText READ editText WRITE setEditText RESET resetEditText NOTIFY editTextChanged FINAL REVISION 2)
84 Q_PROPERTY(QValidator *validator READ validator WRITE setValidator NOTIFY validatorChanged FINAL REVISION 2)
85 Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints NOTIFY inputMethodHintsChanged FINAL REVISION 2)
86 Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged FINAL REVISION 2)
87 Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged FINAL REVISION 2)
88 // 2.5 (Qt 5.12)
89 Q_PROPERTY(qreal implicitIndicatorWidth READ implicitIndicatorWidth NOTIFY implicitIndicatorWidthChanged FINAL REVISION 5)
90 Q_PROPERTY(qreal implicitIndicatorHeight READ implicitIndicatorHeight NOTIFY implicitIndicatorHeightChanged FINAL REVISION 5)
91 Q_CLASSINFO("DeferredPropertyNames", "background,contentItem,indicator,popup")
92 // 2.14 (Qt 5.14)
93 Q_PROPERTY(QVariant currentValue READ currentValue NOTIFY currentValueChanged FINAL REVISION 14)
94 Q_PROPERTY(QString valueRole READ valueRole WRITE setValueRole NOTIFY valueRoleChanged FINAL REVISION 14)
95 // 2.15 (Qt 5.15)
96 Q_PROPERTY(bool selectTextByMouse READ selectTextByMouse WRITE setSelectTextByMouse NOTIFY selectTextByMouseChanged FINAL REVISION 15)
97
98public:
99 explicit QQuickComboBox(QQuickItem *parent = nullptr);
100 ~QQuickComboBox();
101
102 int count() const;
103
104 QVariant model() const;
105 void setModel(const QVariant &model);
106 QQmlInstanceModel *delegateModel() const;
107
108 bool isPressed() const;
109 void setPressed(bool pressed);
110
111 int highlightedIndex() const;
112
113 int currentIndex() const;
114 void setCurrentIndex(int index);
115
116 QString currentText() const;
117
118 QString displayText() const;
119 void setDisplayText(const QString &text);
120 void resetDisplayText();
121
122 QString textRole() const;
123 void setTextRole(const QString &role);
124
125 QString valueRole() const;
126 void setValueRole(const QString &role);
127
128 QQmlComponent *delegate() const;
129 void setDelegate(QQmlComponent *delegate);
130
131 QQuickItem *indicator() const;
132 void setIndicator(QQuickItem *indicator);
133
134 QQuickPopup *popup() const;
135 void setPopup(QQuickPopup *popup);
136
137 Q_INVOKABLE QString textAt(int index) const;
138 Q_INVOKABLE int find(const QString &text, Qt::MatchFlags flags = Qt::MatchExactly) const;
139
140 // 2.1 (Qt 5.8)
141 bool isFlat() const;
142 void setFlat(bool flat);
143
144 // 2.2 (Qt 5.9)
145 bool isDown() const;
146 void setDown(bool down);
147 void resetDown();
148
149 bool isEditable() const;
150 void setEditable(bool editable);
151
152 QString editText() const;
153 void setEditText(const QString &text);
154 void resetEditText();
155
156 QValidator *validator() const;
157 void setValidator(QValidator *validator);
158
159 Qt::InputMethodHints inputMethodHints() const;
160 void setInputMethodHints(Qt::InputMethodHints hints);
161
162 bool isInputMethodComposing() const;
163 bool hasAcceptableInput() const;
164
165 // 2.5 (Qt 5.12)
166 qreal implicitIndicatorWidth() const;
167 qreal implicitIndicatorHeight() const;
168
169 // 2.14 (Qt 5.14)
170 QVariant currentValue() const;
171 Q_REVISION(14) Q_INVOKABLE QVariant valueAt(int index) const;
172 Q_REVISION(14) Q_INVOKABLE int indexOfValue(const QVariant &value) const;
173
174 // 2.15 (Qt 5.15)
175 bool selectTextByMouse() const;
176 void setSelectTextByMouse(bool canSelect);
177
178public Q_SLOTS:
179 void incrementCurrentIndex();
180 void decrementCurrentIndex();
181 Q_REVISION(2) void selectAll();
182
183Q_SIGNALS:
184 void activated(int index);
185 void highlighted(int index);
186 void countChanged();
187 void modelChanged();
188 void delegateModelChanged();
189 void pressedChanged();
190 void highlightedIndexChanged();
191 void currentIndexChanged();
192 void currentTextChanged();
193 void displayTextChanged();
194 void textRoleChanged();
195 void delegateChanged();
196 void indicatorChanged();
197 void popupChanged();
198 // 2.1 (Qt 5.8)
199 Q_REVISION(1) void flatChanged();
200 // 2.2 (Qt 5.9)
201 Q_REVISION(2) void accepted();
202 Q_REVISION(2) void downChanged();
203 Q_REVISION(2) void editableChanged();
204 Q_REVISION(2) void editTextChanged();
205 Q_REVISION(2) void validatorChanged();
206 Q_REVISION(2) void inputMethodHintsChanged();
207 Q_REVISION(2) void inputMethodComposingChanged();
208 Q_REVISION(2) void acceptableInputChanged();
209 // 2.5 (Qt 5.12)
210 Q_REVISION(5) void implicitIndicatorWidthChanged();
211 Q_REVISION(5) void implicitIndicatorHeightChanged();
212 // 2.14 (Qt 5.14)
213 Q_REVISION(14) void valueRoleChanged();
214 Q_REVISION(14) void currentValueChanged();
215 // 2.15 (Qt 5.15)
216 Q_REVISION(15) void selectTextByMouseChanged();
217
218protected:
219 bool eventFilter(QObject *object, QEvent *event) override;
220 void focusInEvent(QFocusEvent *event) override;
221 void focusOutEvent(QFocusEvent *event) override;
222#if QT_CONFIG(im)
223 void inputMethodEvent(QInputMethodEvent *event) override;
224#endif
225 void keyPressEvent(QKeyEvent *event) override;
226 void keyReleaseEvent(QKeyEvent *event) override;
227#if QT_CONFIG(wheelevent)
228 void wheelEvent(QWheelEvent *event) override;
229#endif
230 bool event(QEvent *e) override;
231
232 void componentComplete() override;
233 void itemChange(ItemChange change, const ItemChangeData &value) override;
234 void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
235 void localeChange(const QLocale &newLocale, const QLocale &oldLocale) override;
236
237 QFont defaultFont() const override;
238 QPalette defaultPalette() const override;
239
240#if QT_CONFIG(accessibility)
241 QAccessible::Role accessibleRole() const override;
242 void accessibilityActiveChanged(bool active) override;
243#endif
244
245private:
246 Q_DISABLE_COPY(QQuickComboBox)
247 Q_DECLARE_PRIVATE(QQuickComboBox)
248};
249
250QT_END_NAMESPACE
251
252QML_DECLARE_TYPE(QQuickComboBox)
253
254#endif // QQUICKCOMBOBOX_P_H
255

source code of qtquickcontrols2/src/quicktemplates2/qquickcombobox_p.h