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