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// Qt-Security score:significant
4
5#ifndef QQMLMODELINDEXVALUETYPE_P_H
6#define QQMLMODELINDEXVALUETYPE_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 <QtCore/qabstractitemmodel.h>
20#include <QtCore/qitemselectionmodel.h>
21#include <QtQml/qqml.h>
22#include <QtCore/private/qglobal_p.h>
23
24QT_BEGIN_NAMESPACE
25
26struct QQmlModelIndexValueType
27{
28 QModelIndex v;
29
30 Q_PROPERTY(int row READ row CONSTANT FINAL)
31 Q_PROPERTY(int column READ column CONSTANT FINAL)
32 Q_PROPERTY(QModelIndex parent READ parent FINAL)
33 Q_PROPERTY(bool valid READ isValid CONSTANT FINAL)
34 Q_PROPERTY(QAbstractItemModel *model READ model CONSTANT FINAL)
35 Q_PROPERTY(quint64 internalId READ internalId CONSTANT FINAL)
36 Q_GADGET
37 QML_ANONYMOUS
38 QML_EXTENDED(QQmlModelIndexValueType)
39 QML_FOREIGN(QModelIndex)
40 QML_ADDED_IN_VERSION(2, 0)
41
42public:
43 Q_INVOKABLE QString toString() const
44 { return QLatin1String("QModelIndex") + propertiesString(v); }
45
46 Q_REVISION(6, 7) Q_INVOKABLE QVariant data(int role = Qt::DisplayRole) const
47 { return v.data(role); }
48
49 inline int row() const noexcept { return v.row(); }
50 inline int column() const noexcept { return v.column(); }
51 inline QModelIndex parent() const { return v.parent(); }
52 inline bool isValid() const noexcept { return v.isValid(); }
53 inline QAbstractItemModel *model() const noexcept
54 { return const_cast<QAbstractItemModel *>(v.model()); }
55 quint64 internalId() const { return v.internalId(); }
56
57 static QString propertiesString(const QModelIndex &idx);
58
59 static QPersistentModelIndex toPersistentModelIndex(const QModelIndex &index)
60 { return QPersistentModelIndex(index); }
61
62 operator QModelIndex() const { return v; }
63};
64
66{
68
69 Q_PROPERTY(int row READ row FINAL)
80
81public:
83 { return QLatin1String("QPersistentModelIndex") + QQmlModelIndexValueType::propertiesString(v); }
84
86 { return v.data(role); }
87
88 inline int row() const { return v.row(); }
89 inline int column() const { return v.column(); }
90 inline QModelIndex parent() const { return v.parent(); }
91 inline bool isValid() const { return v.isValid(); }
92 inline QAbstractItemModel *model() const { return const_cast<QAbstractItemModel *>(v.model()); }
93 inline quint64 internalId() const { return v.internalId(); }
94
95 operator QPersistentModelIndex() const { return v; }
96};
97
99{
101
102 Q_PROPERTY(int top READ top FINAL)
119
120public:
122 Q_INVOKABLE inline bool contains(const QModelIndex &index) const
123 { return v.contains(index); }
124 Q_INVOKABLE inline bool contains(int row, int column, const QModelIndex &parentIndex) const
125 { return v.contains(row, column, parentIndex); }
126 Q_INVOKABLE inline bool intersects(const QItemSelectionRange &other) const
127 { return v.intersects(other); }
128 Q_INVOKABLE QItemSelectionRange intersected(const QItemSelectionRange &other) const
129 { return v.intersected(other); }
130
131 inline int top() const { return v.top(); }
132 inline int left() const { return v.left(); }
133 inline int bottom() const { return v.bottom(); }
134 inline int right() const { return v.right(); }
135 inline int width() const { return v.width(); }
136 inline int height() const { return v.height(); }
137 inline QPersistentModelIndex &topLeft() const { return const_cast<QPersistentModelIndex &>(v.topLeft()); }
138 inline QPersistentModelIndex &bottomRight() const { return const_cast<QPersistentModelIndex &>(v.bottomRight()); }
139 inline QModelIndex parent() const { return v.parent(); }
140 inline QAbstractItemModel *model() const { return const_cast<QAbstractItemModel *>(v.model()); }
141 inline bool isValid() const { return v.isValid(); }
142 inline bool isEmpty() const { return v.isEmpty(); }
143
144 operator QItemSelectionRange() const { return v; }
145};
146
148{
149 Q_GADGET
150 QML_ANONYMOUS
154};
155
157{
158 Q_GADGET
159 QML_ANONYMOUS
163};
164
173
174#undef QLISTVALUETYPE_INVOKABLE_API
175
176QT_END_NAMESPACE
177
178#endif // QQMLMODELINDEXVALUETYPE_P_H
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