Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquicksearchfield_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QQUICKSEARCHFIELD_P_H
6#define QQUICKSEARCHFIELD_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtQuickTemplates2/private/qquickcontrol_p.h>
20
21QT_BEGIN_NAMESPACE
22
23class QQuickSearchFieldPrivate;
24class QQuickTextField;
25class QQuickPopup;
26class QQmlInstanceModel;
27class QQuickIndicatorButton;
28class QQmlComponent;
29
30class Q_QUICKTEMPLATES2_EXPORT QQuickSearchField : public QQuickControl
31{
32 Q_OBJECT
33 Q_PROPERTY(QVariant suggestionModel READ suggestionModel WRITE setSuggestionModel
34 NOTIFY suggestionModelChanged FINAL)
35 Q_PROPERTY(QQmlInstanceModel *delegateModel READ delegateModel NOTIFY delegateModelChanged FINAL)
36 Q_PROPERTY(int suggestionCount READ suggestionCount NOTIFY suggestionCountChanged FINAL)
37 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged
38 FINAL)
39 Q_PROPERTY(int highlightedIndex READ highlightedIndex NOTIFY highlightedIndexChanged FINAL)
40 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL)
41 Q_PROPERTY(QString textRole READ textRole WRITE setTextRole NOTIFY textRoleChanged FINAL)
42 Q_PROPERTY(bool live READ isLive WRITE setLive NOTIFY liveChanged)
43 Q_PROPERTY(QQuickIndicatorButton *searchIndicator READ searchIndicator CONSTANT FINAL)
44 Q_PROPERTY(QQuickIndicatorButton *clearIndicator READ clearIndicator CONSTANT FINAL)
45 Q_PROPERTY(QQuickPopup *popup READ popup WRITE setPopup NOTIFY popupChanged FINAL)
46 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
47 Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText
48 NOTIFY placeholderTextChanged FINAL REVISION(6, 12))
49 Q_PROPERTY(bool selectTextByMouse READ selectTextByMouse WRITE setSelectTextByMouse
50 NOTIFY selectTextByMouseChanged FINAL REVISION(6, 12))
51 Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged FINAL REVISION(6, 12))
52 Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged FINAL REVISION(6, 12))
53 Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged FINAL REVISION(6, 12))
54 Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition
55 NOTIFY cursorPositionChanged FINAL REVISION(6, 12))
56
57 QML_NAMED_ELEMENT(SearchField)
58 QML_ADDED_IN_VERSION(6, 10)
59
60public:
61 explicit QQuickSearchField(QQuickItem *parent = nullptr);
62 ~QQuickSearchField();
63
64 QVariant suggestionModel() const;
65 void setSuggestionModel(const QVariant &model);
66
67 QQmlInstanceModel *delegateModel() const;
68
69 int suggestionCount() const;
70
71 int currentIndex() const;
72 void setCurrentIndex(int index);
73
74 int highlightedIndex() const;
75
76 QString text() const;
77 void setText(const QString &text);
78
79 QString textRole() const;
80 void setTextRole(const QString &textRole);
81
82 bool isLive() const;
83 void setLive(const bool live);
84
85 QQuickIndicatorButton *searchIndicator() const;
86 QQuickIndicatorButton *clearIndicator() const;
87
88 QQuickPopup *popup() const;
89 void setPopup(QQuickPopup *popup);
90
91 QQmlComponent *delegate() const;
92 void setDelegate(QQmlComponent *delegate);
93
94 QString placeholderText() const;
95 void setPlaceholderText(const QString &text);
96
97 bool selectTextByMouse() const;
98 void setSelectTextByMouse(const bool selectable);
99
100 QString selectedText() const;
101
102 int selectionStart() const;
103
104 int selectionEnd() const;
105
106 int cursorPosition() const;
107 void setCursorPosition(int position);
109public Q_SLOTS:
110 Q_REVISION(6, 12) void select(int start, int end);
111 Q_REVISION(6, 12) void selectWord();
112 Q_REVISION(6, 12) void selectAll();
113 Q_REVISION(6, 12) void deselect();
115Q_SIGNALS:
116 void activated(int index);
117 void highlighted(int index);
118 void accepted();
119 void searchTriggered();
120 void textEdited();
121 void suggestionModelChanged();
122 void delegateModelChanged();
123 void suggestionCountChanged();
124 void currentIndexChanged();
125 void highlightedIndexChanged();
126 void textChanged();
127 void textRoleChanged();
128 void liveChanged();
129 void popupChanged();
130 void delegateChanged();
131 Q_REVISION(6, 12) void placeholderTextChanged();
132 Q_REVISION(6, 12) void selectTextByMouseChanged();
133 Q_REVISION(6, 12) void selectedTextChanged();
134 Q_REVISION(6, 12) void selectionStartChanged();
135 Q_REVISION(6, 12) void selectionEndChanged();
136 Q_REVISION(6, 12) void cursorPositionChanged();
137
138 void searchButtonPressed();
139 void clearButtonPressed();
140
141protected:
142 bool eventFilter(QObject *object, QEvent *event) override;
143 void focusInEvent(QFocusEvent *event) override;
144 void focusOutEvent(QFocusEvent *event) override;
145 void hoverEnterEvent(QHoverEvent *event) override;
146 void hoverMoveEvent(QHoverEvent *event) override;
147 void hoverLeaveEvent(QHoverEvent *event) override;
148 void keyPressEvent(QKeyEvent *event) override;
149 void classBegin() override;
150 void componentComplete() override;
151 void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
152 void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data) override;
153
154private:
155 Q_DISABLE_COPY(QQuickSearchField)
156 Q_DECLARE_PRIVATE(QQuickSearchField)
157};
158
159QT_END_NAMESPACE
160
161#endif // QQUICKSEARCHFIELD_P_H
void createdItem(int index, QObject *object)
QQuickIndicatorButton * clearIndicator
bool handleRelease(const QPointF &point, ulong timestamp) override
void itemDestroyed(QQuickItem *item) override
bool isValidIndex(int index) const
static void hideOldPopup(QQuickPopup *popup)
QQuickDeferredPointer< QQuickPopup > popup
void itemImplicitWidthChanged(QQuickItem *item) override
void itemImplicitHeightChanged(QQuickItem *item) override
void setCurrentItemAtIndex(int index, Activation activate)
bool handlePress(const QPointF &point, ulong timestamp) override
void setHighlightedIndex(int index, Highlighting highlight)
QString textAt(int index) const
void executePopup(bool complete=false)
QQmlInstanceModel * delegateModel
QQuickIndicatorButton * searchIndicator
Combined button and popup list for selecting options.