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
4#ifndef QQUICKSEARCHFIELD_P_H
5#define QQUICKSEARCHFIELD_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuickTemplates2/private/qquickcontrol_p.h>
19
20QT_BEGIN_NAMESPACE
21
22class QQuickSearchFieldPrivate;
23class QQuickTextField;
24class QQuickPopup;
25class QQmlInstanceModel;
26class QQuickIndicatorButton;
27class QQmlComponent;
28
29class Q_QUICKTEMPLATES2_EXPORT QQuickSearchField : public QQuickControl
30{
31 Q_OBJECT
32 Q_PROPERTY(QVariant suggestionModel READ suggestionModel WRITE setSuggestionModel
33 NOTIFY suggestionModelChanged FINAL)
34 Q_PROPERTY(QQmlInstanceModel *delegateModel READ delegateModel NOTIFY delegateModelChanged FINAL)
35 Q_PROPERTY(int suggestionCount READ suggestionCount NOTIFY suggestionCountChanged FINAL)
36 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged
37 FINAL)
38 Q_PROPERTY(int highlightedIndex READ highlightedIndex NOTIFY highlightedIndexChanged FINAL)
39 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL)
40 Q_PROPERTY(QString textRole READ textRole WRITE setTextRole NOTIFY textRoleChanged FINAL)
41 Q_PROPERTY(bool live READ isLive WRITE setLive NOTIFY liveChanged)
42 Q_PROPERTY(QQuickIndicatorButton *searchIndicator READ searchIndicator CONSTANT FINAL)
43 Q_PROPERTY(QQuickIndicatorButton *clearIndicator READ clearIndicator CONSTANT FINAL)
44 Q_PROPERTY(QQuickPopup *popup READ popup WRITE setPopup NOTIFY popupChanged FINAL)
45 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
46
47 QML_NAMED_ELEMENT(SearchField)
48 QML_ADDED_IN_VERSION(6, 10)
49
50public:
51 explicit QQuickSearchField(QQuickItem *parent = nullptr);
52 ~QQuickSearchField();
53
54 QVariant suggestionModel() const;
55 void setSuggestionModel(const QVariant &model);
56
57 QQmlInstanceModel *delegateModel() const;
58
59 int suggestionCount() const;
60
61 int currentIndex() const;
62 void setCurrentIndex(int index);
63
64 int highlightedIndex() const;
65
66 QString text() const;
67 void setText(const QString &text);
68
69 QString textRole() const;
70 void setTextRole(const QString &textRole);
71
72 bool isLive() const;
73 void setLive(const bool live);
74
75 QQuickIndicatorButton *searchIndicator() const;
76 QQuickIndicatorButton *clearIndicator() const;
77
78 QQuickPopup *popup() const;
79 void setPopup(QQuickPopup *popup);
80
81 QQmlComponent *delegate() const;
82 void setDelegate(QQmlComponent *delegate);
83
84Q_SIGNALS:
85 void activated(int index);
86 void highlighted(int index);
87 void accepted();
88 void searchTriggered();
89 void textEdited();
90 void suggestionModelChanged();
91 void delegateModelChanged();
92 void suggestionCountChanged();
93 void currentIndexChanged();
94 void highlightedIndexChanged();
95 void textChanged();
96 void textRoleChanged();
97 void liveChanged();
98 void popupChanged();
99 void delegateChanged();
100
101 void searchButtonPressed();
102 void clearButtonPressed();
103
104protected:
105 bool eventFilter(QObject *object, QEvent *event) override;
106 void focusInEvent(QFocusEvent *event) override;
107 void focusOutEvent(QFocusEvent *event) override;
108 void hoverEnterEvent(QHoverEvent *event) override;
109 void hoverMoveEvent(QHoverEvent *event) override;
110 void hoverLeaveEvent(QHoverEvent *event) override;
111 void keyPressEvent(QKeyEvent *event) override;
112 void classBegin() override;
113 void componentComplete() override;
114 void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
115 void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data) override;
116
117private:
118 Q_DISABLE_COPY(QQuickSearchField)
119 Q_DECLARE_PRIVATE(QQuickSearchField)
120};
121
122QT_END_NAMESPACE
123
124#endif // QQUICKSEARCHFIELD_P_H
125

source code of qtdeclarative/src/quicktemplates/qquicksearchfield_p.h