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
50 QML_NAMED_ELEMENT(SearchField)
51 QML_ADDED_IN_VERSION(6, 10)
52
53public:
54 explicit QQuickSearchField(QQuickItem *parent = nullptr);
55 ~QQuickSearchField();
56
57 QVariant suggestionModel() const;
58 void setSuggestionModel(const QVariant &model);
59
60 QQmlInstanceModel *delegateModel() const;
61
62 int suggestionCount() const;
63
64 int currentIndex() const;
65 void setCurrentIndex(int index);
66
67 int highlightedIndex() const;
68
69 QString text() const;
70 void setText(const QString &text);
71
72 QString textRole() const;
73 void setTextRole(const QString &textRole);
74
75 bool isLive() const;
76 void setLive(const bool live);
77
78 QQuickIndicatorButton *searchIndicator() const;
79 QQuickIndicatorButton *clearIndicator() const;
80
81 QQuickPopup *popup() const;
82 void setPopup(QQuickPopup *popup);
83
84 QQmlComponent *delegate() const;
85 void setDelegate(QQmlComponent *delegate);
86
87 QString placeholderText() const;
88 void setPlaceholderText(const QString &text);
90Q_SIGNALS:
91 void activated(int index);
92 void highlighted(int index);
93 void accepted();
94 void searchTriggered();
95 void textEdited();
96 void suggestionModelChanged();
97 void delegateModelChanged();
98 void suggestionCountChanged();
99 void currentIndexChanged();
100 void highlightedIndexChanged();
101 void textChanged();
102 void textRoleChanged();
103 void liveChanged();
104 void popupChanged();
105 void delegateChanged();
106 Q_REVISION(6, 12) void placeholderTextChanged();
108 void searchButtonPressed();
109 void clearButtonPressed();
110
111protected:
112 bool eventFilter(QObject *object, QEvent *event) override;
113 void focusInEvent(QFocusEvent *event) override;
114 void focusOutEvent(QFocusEvent *event) override;
115 void hoverEnterEvent(QHoverEvent *event) override;
116 void hoverMoveEvent(QHoverEvent *event) override;
117 void hoverLeaveEvent(QHoverEvent *event) override;
118 void keyPressEvent(QKeyEvent *event) override;
119 void classBegin() override;
120 void componentComplete() override;
121 void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
122 void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data) override;
123
124private:
125 Q_DISABLE_COPY(QQuickSearchField)
126 Q_DECLARE_PRIVATE(QQuickSearchField)
127};
128
129QT_END_NAMESPACE
130
131#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.