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
qqmldelegatecomponent_p.h
Go to the documentation of this file.
1// Copyright (C) 2018 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
4
5#ifndef QQMLDELEGATECOMPONENT_P_H
6#define QQMLDELEGATECOMPONENT_P_H
7
8#include <private/qtqmlmodelsglobal_p.h>
9
10//
11// W A R N I N G
12// -------------
13//
14// This file is not part of the Qt API. It exists purely as an
15// implementation detail. This header file may change from version to
16// version without notice, or even be removed.
17//
18// We mean it.
19//
20
21#include <QtQmlModels/private/qtqmlmodelsglobal_p.h>
22#include <QtQmlModels/private/qqmlabstractdelegatecomponent_p.h>
23#include <QtQml/qqmlcomponent.h>
24
26
28
30{
31 Q_OBJECT
32 Q_PROPERTY(QVariant roleValue READ roleValue WRITE setRoleValue NOTIFY roleValueChanged FINAL)
33 Q_PROPERTY(int row READ row WRITE setRow NOTIFY rowChanged FINAL)
34 Q_PROPERTY(int index READ row WRITE setRow NOTIFY indexChanged FINAL)
35 Q_PROPERTY(int column READ column WRITE setColumn NOTIFY columnChanged FINAL)
36 Q_PROPERTY(QQmlComponent* delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
37 Q_CLASSINFO("DefaultProperty", "delegate")
38 QML_NAMED_ELEMENT(DelegateChoice)
39 QML_ADDED_IN_VERSION(6, 9)
40
41public:
42 QVariant roleValue() const;
43 void setRoleValue(const QVariant &roleValue);
44
45 int row() const;
46 void setRow(int r);
47
48 int column() const;
49 void setColumn(int c);
50
51 QQmlComponent *delegate() const;
52 void setDelegate(QQmlComponent *delegate);
53
54 virtual bool match(int row, int column, const QVariant &value) const;
55
56Q_SIGNALS:
57 void roleValueChanged();
58 void rowChanged();
59 void indexChanged();
60 void columnChanged();
61 void delegateChanged();
62 void changed();
63
64private:
65 QVariant m_value;
66 int m_row = -1;
67 int m_column = -1;
68 QQmlComponent *m_delegate = nullptr;
69};
70
71class Q_QMLMODELS_EXPORT QQmlDelegateChooser : public QQmlAbstractDelegateComponent
72{
73 Q_OBJECT
74 Q_PROPERTY(QString role READ role WRITE setRole NOTIFY roleChanged FINAL)
75 Q_PROPERTY(QQmlListProperty<QQmlDelegateChoice> choices READ choices CONSTANT FINAL)
76 Q_CLASSINFO("DefaultProperty", "choices")
77 QML_NAMED_ELEMENT(DelegateChooser)
78 QML_ADDED_IN_VERSION(6, 9)
79
80public:
81 QString role() const final { return m_role; }
82 void setRole(const QString &role);
83
84 virtual QQmlListProperty<QQmlDelegateChoice> choices();
85 static void choices_append(QQmlListProperty<QQmlDelegateChoice> *, QQmlDelegateChoice *);
86 static qsizetype choices_count(QQmlListProperty<QQmlDelegateChoice> *);
87 static QQmlDelegateChoice *choices_at(QQmlListProperty<QQmlDelegateChoice> *, qsizetype);
88 static void choices_clear(QQmlListProperty<QQmlDelegateChoice> *);
89 static void choices_replace(QQmlListProperty<QQmlDelegateChoice> *, qsizetype,
90 QQmlDelegateChoice *);
91 static void choices_removeLast(QQmlListProperty<QQmlDelegateChoice> *);
92
93 QQmlComponent *delegate(QQmlAdaptorModel *adaptorModel, int row, int column = -1) const override;
94
95Q_SIGNALS:
96 void roleChanged();
97
98private:
99 QString m_role;
100 QList<QQmlDelegateChoice *> m_choices;
101};
102
103QT_END_NAMESPACE
104
105#endif // QQMLDELEGATECOMPONENT_P_H
QT_REQUIRE_CONFIG(qml_delegate_model)