Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qquickpackage.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 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#include "qquickpackage_p.h"
5
6#include <private/qobject_p.h>
7#include <private/qqmlguard_p.h>
8
10
51{
52public:
54
55 struct DataGuard : public QQmlGuard<QObject>
56 {
59
60 private:
61 static void objectDestroyedImpl(QQmlGuardImpl *guard) {
62 auto This = static_cast<DataGuard *>(guard);
63 // we assume priv will always be destroyed after objectDestroyed calls
64 This->list->removeOne(*This);
65 }
66 };
67
70 QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
72 }
74 QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
75 list->clear();
76 }
78 QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
79 return list->at(index);
80 }
82 QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
83 return list->size();
84 }
86 QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
88 }
90 QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
92 }
93};
94
96
99{
100 attached.insert(parent, this);
101}
102
104{
106}
107
109{
110 return _name;
111}
112
114{
115 _name = n;
116}
117
120{
121}
122
124{
125 Q_D(QQuickPackage);
126 return QQmlListProperty<QObject>(this, &d->dataList,
133}
134
136{
137 Q_D(QQuickPackage);
138 for (int ii = 0; ii < d->dataList.size(); ++ii) {
139 QObject *obj = d->dataList.at(ii);
141 if (a && a->name() == name)
142 return true;
143 }
144 return false;
145}
146
148{
149 Q_D(QQuickPackage);
150 if (name.isEmpty() && !d->dataList.isEmpty())
151 return d->dataList.at(0);
152
153 for (int ii = 0; ii < d->dataList.size(); ++ii) {
154 QObject *obj = d->dataList.at(ii);
156 if (a && a->name() == name)
157 return obj;
158 }
159
160 if (name == QLatin1String("default") && !d->dataList.isEmpty())
161 return d->dataList.at(0);
162
163 return nullptr;
164}
165
167{
168 return new QQuickPackageAttached(o);
169}
170
171
172
174
175#include "moc_qquickpackage_p.cpp"
\inmodule QtCore
Definition qhash.h:818
bool remove(const Key &key)
Removes the item that has the key from the hash.
Definition qhash.h:956
T value(const Key &key) const noexcept
Definition qhash.h:1044
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition qhash.h:1283
Definition qlist.h:74
qsizetype size() const noexcept
Definition qlist.h:386
const_reference at(qsizetype i) const noexcept
Definition qlist.h:429
void replace(qsizetype i, parameter_type t)
Definition qlist.h:526
void removeLast() noexcept
Definition qlist.h:808
void append(parameter_type t)
Definition qlist.h:441
void clear()
Definition qlist.h:417
\inmodule QtCore
Definition qobject.h:90
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:311
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
Definition qqmllist.h:24
void setName(const QString &n)
static QHash< QObject *, QQuickPackageAttached * > attached
QQuickPackageAttached(QObject *parent)
\qmltype Package \instantiates QQuickPackage \inqmlmodule QtQml.Models
static void data_removeLast(QQmlListProperty< QObject > *prop)
QList< DataGuard > dataList
static QObject * data_at(QQmlListProperty< QObject > *prop, qsizetype index)
static void data_append(QQmlListProperty< QObject > *prop, QObject *o)
static qsizetype data_count(QQmlListProperty< QObject > *prop)
static void data_clear(QQmlListProperty< QObject > *prop)
static void data_replace(QQmlListProperty< QObject > *prop, qsizetype index, QObject *o)
QQuickPackage(QObject *parent=nullptr)
QObject * part(const QString &=QString())
QQmlListProperty< QObject > data
static QQuickPackageAttached * qmlAttachedProperties(QObject *)
bool hasPart(const QString &)
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
Combined button and popup list for selecting options.
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint index
[2]
GLuint name
GLfloat n
GLhandleARB obj
[2]
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
ptrdiff_t qsizetype
Definition qtypes.h:70
QList< int > list
[14]
QObject::connect nullptr
DataGuard(QObject *obj, QList< DataGuard > *l)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent