Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qqmllistmodelworkeragent.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
// Qt-Security score:significant
4
5
#
include
"qqmllistmodelworkeragent_p.h"
6
#
include
"qqmllistmodel_p_p.h"
7
#
include
<
private
/
qqmldata_p
.
h
>
8
#
include
<
private
/
qqmlengine_p
.
h
>
9
#
include
<
qqmlinfo
.
h
>
10
11
#
include
<
QtCore
/
qcoreevent
.
h
>
12
#
include
<
QtCore
/
qcoreapplication
.
h
>
13
#
include
<
QtCore
/
qdebug
.
h
>
14
15
16
QT_BEGIN_NAMESPACE
17
18
QQmlListModelWorkerAgent::Sync::~Sync()
19
{
20
}
21
22
QQmlListModelWorkerAgent
::QQmlListModelWorkerAgent(QQmlListModel *model)
23
: m_ref(1), m_orig(model), m_copy(
new
QQmlListModel(model,
this
))
24
{
25
}
26
27
QQmlListModelWorkerAgent
::~
QQmlListModelWorkerAgent
()
28
{
29
mutex.lock();
30
syncDone.wakeAll();
31
mutex.unlock();
32
}
33
34
QV4
::
ExecutionEngine
*
QQmlListModelWorkerAgent
::
engine
()
const
35
{
36
return
m_copy->m_engine;
37
}
38
39
void
QQmlListModelWorkerAgent
::
setEngine
(QV4::ExecutionEngine *eng)
40
{
41
if
(eng != m_copy->m_engine) {
42
m_copy->m_engine = eng;
43
emit engineChanged(eng);
44
}
45
}
46
47
void
QQmlListModelWorkerAgent
::
addref
()
48
{
49
m_ref.ref();
50
}
51
52
void
QQmlListModelWorkerAgent
::
release
()
53
{
54
bool
del = !m_ref.deref();
55
56
if
(del)
57
deleteLater();
58
}
59
60
void
QQmlListModelWorkerAgent
::
modelDestroyed
()
61
{
62
m_orig =
nullptr
;
63
}
64
65
int
QQmlListModelWorkerAgent
::
count
()
const
66
{
67
return
m_copy->count();
68
}
69
70
void
QQmlListModelWorkerAgent
::
clear
()
71
{
72
m_copy->clear();
73
}
74
75
void
QQmlListModelWorkerAgent
::
remove
(QQmlV4FunctionPtr args)
76
{
77
m_copy->remove(args);
78
}
79
80
void
QQmlListModelWorkerAgent
::
append
(QQmlV4FunctionPtr args)
81
{
82
m_copy->append(args);
83
}
84
85
void
QQmlListModelWorkerAgent
::
insert
(QQmlV4FunctionPtr args)
86
{
87
m_copy->insert(args);
88
}
89
90
QJSValue
QQmlListModelWorkerAgent
::get(
int
index)
const
91
{
92
return
m_copy->get(index);
93
}
94
95
void
QQmlListModelWorkerAgent
::set(
int
index,
const
QJSValue &value)
96
{
97
m_copy->set(index, value);
98
}
99
100
void
QQmlListModelWorkerAgent
::
setProperty
(
int
index,
const
QString& property,
const
QVariant& value)
101
{
102
m_copy->setProperty(index, property, value);
103
}
104
105
void
QQmlListModelWorkerAgent
::
move
(
int
from,
int
to,
int
count)
106
{
107
m_copy->move(from, to, count);
108
}
109
110
void
QQmlListModelWorkerAgent
::
sync
()
111
{
112
Sync *s =
new
Sync(m_copy);
113
114
mutex.lock();
115
QCoreApplication::postEvent(
this
, s);
116
syncDone.wait(&mutex);
117
mutex.unlock();
118
}
119
120
bool
QQmlListModelWorkerAgent
::
event
(QEvent *e)
121
{
122
if
(e->type() == QEvent::User) {
123
bool
cc =
false
;
124
QMutexLocker locker(&mutex);
125
if
(m_orig) {
126
Sync *s =
static_cast
<Sync *>(e);
127
128
cc = (m_orig->count() != s->list->count());
129
130
Q_ASSERT(m_orig->m_dynamicRoles == s->list->m_dynamicRoles);
131
if
(m_orig->m_dynamicRoles)
132
QQmlListModel::sync(s->list, m_orig);
133
else
134
ListModel
::
sync
(
s->list->m_listModel
,
m_orig->m_listModel
)
;
135
}
136
137
syncDone.wakeAll();
138
locker.unlock();
139
140
if
(cc)
141
emit m_orig->countChanged();
142
return
true
;
143
}
144
145
return
QObject::event(e);
146
}
147
148
QT_END_NAMESPACE
149
150
#
include
"moc_qqmllistmodelworkeragent_p.cpp"
ListModel
Definition
qqmllistmodel_p_p.h:330
ListModel::sync
static bool sync(ListModel *src, ListModel *target)
Definition
qqmllistmodel.cpp:339
QQmlListModelWorkerAgent
Definition
qqmllistmodelworkeragent_p.h:36
QQmlListModelWorkerAgent::modelDestroyed
void modelDestroyed()
Definition
qqmllistmodelworkeragent.cpp:60
QQmlListModelWorkerAgent::event
bool event(QEvent *) override
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition
qqmllistmodelworkeragent.cpp:120
QQmlListModelWorkerAgent::move
Q_INVOKABLE void move(int from, int to, int count)
Definition
qqmllistmodelworkeragent.cpp:105
QQmlListModelWorkerAgent::count
int count() const
Definition
qqmllistmodelworkeragent.cpp:65
QQmlListModelWorkerAgent::release
Q_INVOKABLE void release()
Definition
qqmllistmodelworkeragent.cpp:52
QQmlListModelWorkerAgent::remove
Q_INVOKABLE void remove(QQmlV4FunctionPtr args)
Definition
qqmllistmodelworkeragent.cpp:75
QQmlListModelWorkerAgent::insert
Q_INVOKABLE void insert(QQmlV4FunctionPtr args)
Definition
qqmllistmodelworkeragent.cpp:85
QQmlListModelWorkerAgent::setProperty
Q_INVOKABLE void setProperty(int index, const QString &property, const QVariant &value)
Definition
qqmllistmodelworkeragent.cpp:100
QQmlListModelWorkerAgent::sync
Q_INVOKABLE void sync()
Definition
qqmllistmodelworkeragent.cpp:110
QQmlListModelWorkerAgent::addref
Q_INVOKABLE void addref()
Definition
qqmllistmodelworkeragent.cpp:47
QQmlListModelWorkerAgent::append
Q_INVOKABLE void append(QQmlV4FunctionPtr args)
Definition
qqmllistmodelworkeragent.cpp:80
QQmlListModelWorkerAgent::clear
Q_INVOKABLE void clear()
Definition
qqmllistmodelworkeragent.cpp:70
QQmlListModelWorkerAgent::~QQmlListModelWorkerAgent
~QQmlListModelWorkerAgent()
Definition
qqmllistmodelworkeragent.cpp:27
QQmlListModelWorkerAgent::setEngine
void setEngine(QV4::ExecutionEngine *eng)
Definition
qqmllistmodelworkeragent.cpp:39
QQmlListModelWorkerAgent::engine
QV4::ExecutionEngine * engine() const
Definition
qqmllistmodelworkeragent.cpp:34
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtdeclarative
src
qmlmodels
qqmllistmodelworkeragent.cpp
Generated on
for Qt by
1.18.0