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#include <QtQuick/private/qquicktext_p.h>
21
22QT_BEGIN_NAMESPACE
23
24class QQuickSearchFieldPrivate;
25class QQuickTextField;
26class QQuickPopup;
27class QQmlInstanceModel;
28class QQuickIndicatorButton;
29class QQmlComponent;
30
31class Q_QUICKTEMPLATES2_EXPORT QQuickSearchField : public QQuickControl
32{
33 Q_OBJECT
34 Q_PROPERTY(QVariant suggestionModel READ suggestionModel WRITE setSuggestionModel
35 NOTIFY suggestionModelChanged FINAL)
36 Q_PROPERTY(QQmlInstanceModel *delegateModel READ delegateModel NOTIFY delegateModelChanged FINAL)
37 Q_PROPERTY(int suggestionCount READ suggestionCount NOTIFY suggestionCountChanged FINAL)
38 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged
39 FINAL)
40 Q_PROPERTY(int highlightedIndex READ highlightedIndex NOTIFY highlightedIndexChanged FINAL)
41 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL)
42 Q_PROPERTY(QString textRole READ textRole WRITE setTextRole NOTIFY textRoleChanged FINAL)
43 Q_PROPERTY(bool live READ isLive WRITE setLive NOTIFY liveChanged)
44 Q_PROPERTY(QQuickIndicatorButton *searchIndicator READ searchIndicator CONSTANT FINAL)
45 Q_PROPERTY(QQuickIndicatorButton *clearIndicator READ clearIndicator CONSTANT FINAL)
46 Q_PROPERTY(QQuickPopup *popup READ popup WRITE setPopup NOTIFY popupChanged FINAL)
47 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
48 Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText
49 NOTIFY placeholderTextChanged REVISION(6, 12))
50 Q_PROPERTY(bool selectTextByMouse READ selectTextByMouse WRITE setSelectTextByMouse
51 NOTIFY selectTextByMouseChanged REVISION(6, 12))
52 Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged REVISION(6, 12))
53 Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged REVISION(6, 12))
54 Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged REVISION(6, 12))
55 Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition
56 NOTIFY cursorPositionChanged REVISION(6, 12))
57 Q_PROPERTY(QQuickText::TextFormat textFormat READ textFormat WRITE setTextFormat
58 RESET resetTextFormat NOTIFY textFormatChanged REVISION(6, 13))
59
60 QML_NAMED_ELEMENT(SearchField)
61 QML_ADDED_IN_VERSION(6, 10)
62
63public:
64 explicit QQuickSearchField(QQuickItem *parent = nullptr);
65 ~QQuickSearchField();
66
67 QVariant suggestionModel() const;
68 void setSuggestionModel(const QVariant &model);
69
70 QQmlInstanceModel *delegateModel() const;
71
72 int suggestionCount() const;
73
74 int currentIndex() const;
75 void setCurrentIndex(int index);
76
77 int highlightedIndex() const;
78
79 QString text() const;
80 void setText(const QString &text);
81
82 QString textRole() const;
83 void setTextRole(const QString &textRole);
84
85 QQuickText::TextFormat textFormat() const;
86 void setTextFormat(QQuickText::TextFormat textFormat);
87 void resetTextFormat();
88
89 bool isLive() const;
90 void setLive(const bool live);
91
92 QQuickIndicatorButton *searchIndicator() const;
93 QQuickIndicatorButton *clearIndicator() const;
94
95 QQuickPopup *popup() const;
96 void setPopup(QQuickPopup *popup);
97
98 QQmlComponent *delegate() const;
99 void setDelegate(QQmlComponent *delegate);
100
101 QString placeholderText() const;
102 void setPlaceholderText(const QString &text);
103
104 bool selectTextByMouse() const;
105 void setSelectTextByMouse(const bool selectable);
106
107 QString selectedText() const;
108
109 int selectionStart() const;
110
111 int selectionEnd() const;
113 int cursorPosition() const;
114 void setCursorPosition(int position);
116public Q_SLOTS:
117 Q_REVISION(6, 12) void select(int start, int end);
118 Q_REVISION(6, 12) void selectWord();
119 Q_REVISION(6, 12) void selectAll();
120 Q_REVISION(6, 12) void deselect();
122Q_SIGNALS:
123 void activated(int index);
124 void highlighted(int index);
125 void accepted();
126 void searchTriggered();
127 void textEdited();
128 void suggestionModelChanged();
129 void delegateModelChanged();
130 void suggestionCountChanged();
131 void currentIndexChanged();
132 void highlightedIndexChanged();
133 void textChanged();
134 void textRoleChanged();
135 void liveChanged();
136 void popupChanged();
137 void delegateChanged();
138 Q_REVISION(6, 12) void placeholderTextChanged();
139 Q_REVISION(6, 12) void selectTextByMouseChanged();
140 Q_REVISION(6, 12) void selectedTextChanged();
141 Q_REVISION(6, 12) void selectionStartChanged();
142 Q_REVISION(6, 12) void selectionEndChanged();
143 Q_REVISION(6, 12) void cursorPositionChanged();
144 Q_REVISION(6, 13) void textFormatChanged();
145
146 void searchButtonPressed();
147 void clearButtonPressed();
148
149protected:
150 bool eventFilter(QObject *object, QEvent *event) override;
151 void focusInEvent(QFocusEvent *event) override;
152 void focusOutEvent(QFocusEvent *event) override;
153 void hoverEnterEvent(QHoverEvent *event) override;
154 void hoverMoveEvent(QHoverEvent *event) override;
155 void hoverLeaveEvent(QHoverEvent *event) override;
156 void keyPressEvent(QKeyEvent *event) override;
157 void classBegin() override;
158 void componentComplete() override;
159 void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
160 void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data) override;
161
162private:
163 Q_DISABLE_COPY(QQuickSearchField)
164 Q_DECLARE_PRIVATE(QQuickSearchField)
165};
166
167QT_END_NAMESPACE
168
169#endif // QQUICKSEARCHFIELD_P_H
void createdItem(int index, QObject *object)
QQuickIndicatorButton * clearIndicator
bool handleRelease(const QPointF &point, ulong timestamp) override
std::optional< QQuickText::TextFormat > textFormat
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.