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
qqmlmodelindexvaluetype_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 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 QQMLMODELINDEXVALUETYPE_P_H
5#define QQMLMODELINDEXVALUETYPE_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 <QtCore/qabstractitemmodel.h>
19#include <QtCore/qitemselectionmodel.h>
20#include <QtQml/qqml.h>
21#include <QtCore/private/qglobal_p.h>
22
23QT_BEGIN_NAMESPACE
24
25struct QQmlModelIndexValueType
26{
27 QModelIndex v;
28
29 Q_PROPERTY(int row READ row CONSTANT FINAL)
30 Q_PROPERTY(int column READ column CONSTANT FINAL)
31 Q_PROPERTY(QModelIndex parent READ parent FINAL)
32 Q_PROPERTY(bool valid READ isValid CONSTANT FINAL)
33 Q_PROPERTY(QAbstractItemModel *model READ model CONSTANT FINAL)
34 Q_PROPERTY(quint64 internalId READ internalId CONSTANT FINAL)
35 Q_GADGET
36 QML_ANONYMOUS
37 QML_EXTENDED(QQmlModelIndexValueType)
38 QML_FOREIGN(QModelIndex)
39 QML_ADDED_IN_VERSION(2, 0)
40
41public:
42 Q_INVOKABLE QString toString() const
43 { return QLatin1String("QModelIndex") + propertiesString(v); }
44
45 Q_REVISION(6, 7) Q_INVOKABLE QVariant data(int role = Qt::DisplayRole) const
46 { return v.data(role); }
47
48 inline int row() const noexcept { return v.row(); }
49 inline int column() const noexcept { return v.column(); }
50 inline QModelIndex parent() const { return v.parent(); }
51 inline bool isValid() const noexcept { return v.isValid(); }
52 inline QAbstractItemModel *model() const noexcept
53 { return const_cast<QAbstractItemModel *>(v.model()); }
54 quint64 internalId() const { return v.internalId(); }
55
56 static QString propertiesString(const QModelIndex &idx);
57
58 static QPersistentModelIndex toPersistentModelIndex(const QModelIndex &index)
59 { return QPersistentModelIndex(index); }
60
61 operator QModelIndex() const { return v; }
62};
63
65{
67
68 Q_PROPERTY(int row READ row FINAL)
79
80public:
82 { return QLatin1String("QPersistentModelIndex") + QQmlModelIndexValueType::propertiesString(v); }
83
85 { return v.data(role); }
86
87 inline int row() const { return v.row(); }
88 inline int column() const { return v.column(); }
89 inline QModelIndex parent() const { return v.parent(); }
90 inline bool isValid() const { return v.isValid(); }
91 inline QAbstractItemModel *model() const { return const_cast<QAbstractItemModel *>(v.model()); }
92 inline quint64 internalId() const { return v.internalId(); }
93
94 operator QPersistentModelIndex() const { return v; }
95};
96
98{
100
101 Q_PROPERTY(int top READ top FINAL)
118
119public:
121 Q_INVOKABLE inline bool contains(const QModelIndex &index) const
122 { return v.contains(index); }
123 Q_INVOKABLE inline bool contains(int row, int column, const QModelIndex &parentIndex) const
124 { return v.contains(row, column, parentIndex); }
125 Q_INVOKABLE inline bool intersects(const QItemSelectionRange &other) const
126 { return v.intersects(other); }
127 Q_INVOKABLE QItemSelectionRange intersected(const QItemSelectionRange &other) const
128 { return v.intersected(other); }
129
130 inline int top() const { return v.top(); }
131 inline int left() const { return v.left(); }
132 inline int bottom() const { return v.bottom(); }
133 inline int right() const { return v.right(); }
134 inline int width() const { return v.width(); }
135 inline int height() const { return v.height(); }
136 inline QPersistentModelIndex &topLeft() const { return const_cast<QPersistentModelIndex &>(v.topLeft()); }
137 inline QPersistentModelIndex &bottomRight() const { return const_cast<QPersistentModelIndex &>(v.bottomRight()); }
138 inline QModelIndex parent() const { return v.parent(); }
139 inline QAbstractItemModel *model() const { return const_cast<QAbstractItemModel *>(v.model()); }
140 inline bool isValid() const { return v.isValid(); }
141 inline bool isEmpty() const { return v.isEmpty(); }
142
143 operator QItemSelectionRange() const { return v; }
144};
145
147{
148 Q_GADGET
149 QML_ANONYMOUS
153};
154
156{
157 Q_GADGET
158 QML_ANONYMOUS
162};
163
172
173#undef QLISTVALUETYPE_INVOKABLE_API
174
175QT_END_NAMESPACE
176
177#endif // QQMLMODELINDEXVALUETYPE_P_H
Combined button and popup list for selecting options.
Q_INVOKABLE bool contains(int row, int column, const QModelIndex &parentIndex) const
Q_INVOKABLE bool contains(const QModelIndex &index) const
Q_INVOKABLE bool intersects(const QItemSelectionRange &other) const