1 | // Copyright (C) 2023 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #include "qitemmodelscatterdataproxy_p.h" |
5 | #include "scatteritemmodelhandler_p.h" |
6 | |
7 | QT_BEGIN_NAMESPACE |
8 | |
9 | /*! |
10 | * \class QItemModelScatterDataProxy |
11 | * \inmodule QtGraphs |
12 | * \brief Proxy class for presenting data in item models with Q3DScatter. |
13 | * |
14 | * QItemModelScatterDataProxy allows you to use QAbstractItemModel derived models as a data source |
15 | * for Q3DScatter. It maps roles of QAbstractItemModel to the XYZ-values of Q3DScatter points. |
16 | * |
17 | * The data is resolved asynchronously whenever the mapping or the model changes. |
18 | * QScatterDataProxy::arrayReset() is emitted when the data has been resolved. However, inserts, |
19 | * removes, and single data item changes after the model initialization are resolved synchronously, |
20 | * unless the same frame also contains a change that causes the whole model to be resolved. |
21 | * |
22 | * Mapping ignores rows and columns of the QAbstractItemModel and treats |
23 | * all items equally. It requires the model to provide roles for the data items |
24 | * that can be mapped to X, Y, and Z-values for the scatter points. |
25 | * |
26 | * For example, assume that you have a custom QAbstractItemModel for storing various measurements |
27 | * done on material samples, providing data for roles such as "density", "hardness", and |
28 | * "conductivity". You could visualize these properties on a scatter graph using this proxy: |
29 | * |
30 | * \snippet doc_src_qtgraphs.cpp 4 |
31 | * |
32 | * If the fields of the model do not contain the data in the exact format you need, you can specify |
33 | * a search pattern regular expression and a replace rule for each role to get the value in a |
34 | * format you need. For more information how the replace using regular expressions works, see |
35 | * QString::replace(const QRegularExpression &rx, const QString &after) function documentation. Note that |
36 | * using regular expressions has an impact on the performance, so it's more efficient to utilize |
37 | * item models where doing search and replace is not necessary to get the desired values. |
38 | * |
39 | * For example about using the search patterns in conjunction with the roles, see |
40 | * ItemModelBarDataProxy usage in \l{Simple Bar Graph}. |
41 | * |
42 | * \sa {Qt Graphs Data Handling} |
43 | */ |
44 | |
45 | /*! |
46 | * \qmltype ItemModelScatterDataProxy |
47 | * \inqmlmodule QtGraphs |
48 | * \ingroup graphs_qml |
49 | * \instantiates QItemModelScatterDataProxy |
50 | * \inherits ScatterDataProxy |
51 | * \brief Proxy class for presenting data in item models with Scatter3D. |
52 | * |
53 | * This type allows you to use AbstractItemModel derived models as a data source for Scatter3D. |
54 | * |
55 | * The data is resolved asynchronously whenever the mapping or the model changes. |
56 | * QScatterDataProxy::arrayReset() is emitted when the data has been resolved. |
57 | * |
58 | * For more details, see QItemModelScatterDataProxy documentation. |
59 | * |
60 | * Usage example: |
61 | * |
62 | * \snippet doc_src_qmlgraphs.cpp 8 |
63 | * |
64 | * \sa ScatterDataProxy, {Qt Graphs Data Handling} |
65 | */ |
66 | |
67 | /*! |
68 | * \qmlproperty model ItemModelScatterDataProxy::itemModel |
69 | * The item model to use as a data source for Scatter3D. |
70 | */ |
71 | |
72 | /*! |
73 | * \qmlproperty string ItemModelScatterDataProxy::xPosRole |
74 | * The item model role to map into the X position. |
75 | */ |
76 | |
77 | /*! |
78 | * \qmlproperty string ItemModelScatterDataProxy::yPosRole |
79 | * The item model role to map into the Y position. |
80 | */ |
81 | |
82 | /*! |
83 | * \qmlproperty string ItemModelScatterDataProxy::zPosRole |
84 | * The item model role to map into the Z position. |
85 | */ |
86 | |
87 | /*! |
88 | * \qmlproperty string ItemModelScatterDataProxy::rotationRole |
89 | * |
90 | * The item model role to map into item rotation. |
91 | * The model may supply the value for rotation as either variant that is directly convertible |
92 | * to \l [QtQuick] quaternion, or as one of the string representations: \c{"scalar,x,y,z"} or |
93 | * \c{"@angle,x,y,z"}. The first format will construct the \l [QtQuick] quaternion directly with |
94 | * given values, and the second one will construct the \l [QtQuick] quaternion using |
95 | * QQuaternion::fromAxisAndAngle() method. |
96 | */ |
97 | |
98 | /*! |
99 | * \qmlproperty regExp ItemModelScatterDataProxy::xPosRolePattern |
100 | * |
101 | * When set, a search and replace is done on the value mapped by the x position |
102 | * role before it is used as |
103 | * an item position value. This property specifies the regular expression to find the portion of the |
104 | * mapped value to replace and xPosRoleReplace property contains the replacement string. |
105 | * |
106 | * \sa xPosRole, xPosRoleReplace |
107 | */ |
108 | |
109 | /*! |
110 | * \qmlproperty regExp ItemModelScatterDataProxy::yPosRolePattern |
111 | * |
112 | * When set, a search and replace is done on the value mapped by the y position |
113 | * role before it is used as |
114 | * an item position value. This property specifies the regular expression to find the portion of the |
115 | * mapped value to replace and yPosRoleReplace property contains the replacement string. |
116 | * |
117 | * \sa yPosRole, yPosRoleReplace |
118 | */ |
119 | |
120 | /*! |
121 | * \qmlproperty regExp ItemModelScatterDataProxy::zPosRolePattern |
122 | * |
123 | * When set, a search and replace is done on the value mapped by the z position |
124 | * role before it is used as |
125 | * an item position value. This property specifies the regular expression to find the portion of the |
126 | * mapped value to replace and zPosRoleReplace property contains the replacement string. |
127 | * |
128 | * \sa zPosRole, zPosRoleReplace |
129 | */ |
130 | |
131 | /*! |
132 | * \qmlproperty regExp ItemModelScatterDataProxy::rotationRolePattern |
133 | * When set, a search and replace is done on the value mapped by the rotation |
134 | * role before it is used |
135 | * as item rotation. This property specifies the regular expression to find the portion |
136 | * of the mapped value to replace and rotationRoleReplace property contains the replacement string. |
137 | * |
138 | * \sa rotationRole, rotationRoleReplace |
139 | */ |
140 | |
141 | /*! |
142 | * \qmlproperty string ItemModelScatterDataProxy::xPosRoleReplace |
143 | * |
144 | * This property defines the replace content to be used in conjunction with xPosRolePattern. |
145 | * Defaults to an empty string. For more information on how the search and replace using regular |
146 | * expressions works, see QString::replace(const QRegularExpression &rx, const QString &after) |
147 | * function documentation. |
148 | * |
149 | * \sa xPosRole, xPosRolePattern |
150 | */ |
151 | |
152 | /*! |
153 | * \qmlproperty string ItemModelScatterDataProxy::yPosRoleReplace |
154 | * |
155 | * This property defines the replace content to be used in conjunction with yPosRolePattern. |
156 | * Defaults to an empty string. For more information on how the search and replace using regular |
157 | * expressions works, see QString::replace(const QRegularExpression &rx, const QString &after) |
158 | * function documentation. |
159 | * |
160 | * \sa yPosRole, yPosRolePattern |
161 | */ |
162 | |
163 | /*! |
164 | * \qmlproperty string ItemModelScatterDataProxy::zPosRoleReplace |
165 | * |
166 | * This property defines the replace content to be used in conjunction with zPosRolePattern. |
167 | * Defaults to an empty string. For more information on how the search and replace using regular |
168 | * expressions works, see QString::replace(const QRegularExpression &rx, const QString &after) |
169 | * function documentation. |
170 | * |
171 | * \sa zPosRole, zPosRolePattern |
172 | */ |
173 | |
174 | /*! |
175 | * \qmlproperty string ItemModelScatterDataProxy::rotationRoleReplace |
176 | * This property defines the replace content to be used in conjunction with rotationRolePattern. |
177 | * Defaults to an empty string. For more information on how the search and replace using regular |
178 | * expressions works, see QString::replace(const QRegularExpression &rx, const QString &after) |
179 | * function documentation. |
180 | * |
181 | * \sa rotationRole, rotationRolePattern |
182 | */ |
183 | |
184 | /*! |
185 | * Constructs QItemModelScatterDataProxy with optional \a parent. |
186 | */ |
187 | QItemModelScatterDataProxy::QItemModelScatterDataProxy(QObject *parent) |
188 | : QScatterDataProxy(new QItemModelScatterDataProxyPrivate(this), parent) |
189 | { |
190 | Q_D(QItemModelScatterDataProxy); |
191 | d->connectItemModelHandler(); |
192 | } |
193 | |
194 | /*! |
195 | * Constructs QItemModelScatterDataProxy with \a itemModel and optional \a parent. Proxy doesn't take |
196 | * ownership of the \a itemModel, as typically item models are owned by other controls. |
197 | */ |
198 | QItemModelScatterDataProxy::QItemModelScatterDataProxy(QAbstractItemModel *itemModel, |
199 | QObject *parent) |
200 | : QScatterDataProxy(new QItemModelScatterDataProxyPrivate(this), parent) |
201 | { |
202 | Q_D(QItemModelScatterDataProxy); |
203 | d->m_itemModelHandler->setItemModel(itemModel); |
204 | d->connectItemModelHandler(); |
205 | } |
206 | |
207 | /*! |
208 | * Constructs QItemModelScatterDataProxy with \a itemModel and optional \a parent. Proxy doesn't take |
209 | * ownership of the \a itemModel, as typically item models are owned by other controls. |
210 | * The xPosRole property is set to \a xPosRole, yPosRole property to \a yPosRole, and zPosRole property |
211 | * to \a zPosRole. |
212 | */ |
213 | QItemModelScatterDataProxy::QItemModelScatterDataProxy(QAbstractItemModel *itemModel, |
214 | const QString &xPosRole, |
215 | const QString &yPosRole, |
216 | const QString &zPosRole, |
217 | QObject *parent) |
218 | : QScatterDataProxy(new QItemModelScatterDataProxyPrivate(this), parent) |
219 | { |
220 | Q_D(QItemModelScatterDataProxy); |
221 | d->m_itemModelHandler->setItemModel(itemModel); |
222 | d->m_xPosRole = xPosRole; |
223 | d->m_yPosRole = yPosRole; |
224 | d->m_zPosRole = zPosRole; |
225 | d->connectItemModelHandler(); |
226 | } |
227 | |
228 | /*! |
229 | * Constructs QItemModelScatterDataProxy with \a itemModel and optional \a parent. Proxy doesn't take |
230 | * ownership of the \a itemModel, as typically item models are owned by other controls. |
231 | * The xPosRole property is set to \a xPosRole, yPosRole property to \a yPosRole, zPosRole property |
232 | * to \a zPosRole, and rotationRole property to \a rotationRole. |
233 | */ |
234 | QItemModelScatterDataProxy::QItemModelScatterDataProxy(QAbstractItemModel *itemModel, |
235 | const QString &xPosRole, |
236 | const QString &yPosRole, |
237 | const QString &zPosRole, |
238 | const QString &rotationRole, |
239 | QObject *parent) |
240 | : QScatterDataProxy(new QItemModelScatterDataProxyPrivate(this), parent) |
241 | { |
242 | Q_D(QItemModelScatterDataProxy); |
243 | d->m_itemModelHandler->setItemModel(itemModel); |
244 | d->m_xPosRole = xPosRole; |
245 | d->m_yPosRole = yPosRole; |
246 | d->m_zPosRole = zPosRole; |
247 | d->m_rotationRole = rotationRole; |
248 | d->connectItemModelHandler(); |
249 | } |
250 | |
251 | /*! |
252 | * Destroys QItemModelScatterDataProxy. |
253 | */ |
254 | QItemModelScatterDataProxy::~QItemModelScatterDataProxy() |
255 | { |
256 | } |
257 | |
258 | /*! |
259 | * \property QItemModelScatterDataProxy::itemModel |
260 | * |
261 | * \brief The item model to use as a data source for a 3D scatter series. |
262 | */ |
263 | |
264 | /*! |
265 | * Sets \a itemModel as the item model for Q3DScatter. Does not take |
266 | * ownership of the model, but does connect to it to listen for changes. |
267 | */ |
268 | void QItemModelScatterDataProxy::setItemModel(QAbstractItemModel *itemModel) |
269 | { |
270 | Q_D(QItemModelScatterDataProxy); |
271 | d->m_itemModelHandler->setItemModel(itemModel); |
272 | } |
273 | |
274 | QAbstractItemModel *QItemModelScatterDataProxy::itemModel() const |
275 | { |
276 | const Q_D(QItemModelScatterDataProxy); |
277 | return d->m_itemModelHandler->itemModel(); |
278 | } |
279 | |
280 | /*! |
281 | * \property QItemModelScatterDataProxy::xPosRole |
282 | * |
283 | * \brief The item model role to map into the X position. |
284 | */ |
285 | void QItemModelScatterDataProxy::setXPosRole(const QString &role) |
286 | { |
287 | Q_D(QItemModelScatterDataProxy); |
288 | if (d->m_xPosRole != role) { |
289 | d->m_xPosRole = role; |
290 | emit xPosRoleChanged(role); |
291 | } |
292 | } |
293 | |
294 | QString QItemModelScatterDataProxy::xPosRole() const |
295 | { |
296 | const Q_D(QItemModelScatterDataProxy); |
297 | return d->m_xPosRole; |
298 | } |
299 | |
300 | /*! |
301 | * \property QItemModelScatterDataProxy::yPosRole |
302 | * |
303 | * \brief The item model role to map into the Y position. |
304 | */ |
305 | void QItemModelScatterDataProxy::setYPosRole(const QString &role) |
306 | { |
307 | Q_D(QItemModelScatterDataProxy); |
308 | if (d->m_yPosRole != role) { |
309 | d->m_yPosRole = role; |
310 | emit yPosRoleChanged(role); |
311 | } |
312 | } |
313 | |
314 | QString QItemModelScatterDataProxy::yPosRole() const |
315 | { |
316 | const Q_D(QItemModelScatterDataProxy); |
317 | return d->m_yPosRole; |
318 | } |
319 | |
320 | /*! |
321 | * \property QItemModelScatterDataProxy::zPosRole |
322 | * |
323 | * \brief The item model role to map into the Z position. |
324 | */ |
325 | void QItemModelScatterDataProxy::setZPosRole(const QString &role) |
326 | { |
327 | Q_D(QItemModelScatterDataProxy); |
328 | if (d->m_zPosRole != role) { |
329 | d->m_zPosRole = role; |
330 | emit zPosRoleChanged(role); |
331 | } |
332 | } |
333 | |
334 | QString QItemModelScatterDataProxy::zPosRole() const |
335 | { |
336 | const Q_D(QItemModelScatterDataProxy); |
337 | return d->m_zPosRole; |
338 | } |
339 | |
340 | /*! |
341 | * \property QItemModelScatterDataProxy::rotationRole |
342 | * |
343 | * \brief The item model role to map into item rotation. |
344 | * |
345 | * The model may supply the value for rotation as either variant that is directly convertible |
346 | * to QQuaternion, or as one of the string representations: \c{"scalar,x,y,z"} or \c{"@angle,x,y,z"}. |
347 | * The first will construct the quaternion directly with given values, and the second one will |
348 | * construct the quaternion using QQuaternion::fromAxisAndAngle() method. |
349 | */ |
350 | void QItemModelScatterDataProxy::setRotationRole(const QString &role) |
351 | { |
352 | Q_D(QItemModelScatterDataProxy); |
353 | if (d->m_rotationRole != role) { |
354 | d->m_rotationRole = role; |
355 | emit rotationRoleChanged(role); |
356 | } |
357 | } |
358 | |
359 | QString QItemModelScatterDataProxy::rotationRole() const |
360 | { |
361 | const Q_D(QItemModelScatterDataProxy); |
362 | return d->m_rotationRole; |
363 | } |
364 | |
365 | /*! |
366 | * \property QItemModelScatterDataProxy::xPosRolePattern |
367 | * |
368 | * \brief Whether search and replace is done on the value mapped by the x |
369 | * position role before it is used as an item position value. |
370 | * |
371 | * This property specifies the regular expression to find the portion of the |
372 | * mapped value to replace and xPosRoleReplace property contains the replacement string. |
373 | * |
374 | * \sa xPosRole, xPosRoleReplace |
375 | */ |
376 | void QItemModelScatterDataProxy::setXPosRolePattern(const QRegularExpression &pattern) |
377 | { |
378 | Q_D(QItemModelScatterDataProxy); |
379 | if (d->m_xPosRolePattern != pattern) { |
380 | d->m_xPosRolePattern = pattern; |
381 | emit xPosRolePatternChanged(pattern); |
382 | } |
383 | } |
384 | |
385 | QRegularExpression QItemModelScatterDataProxy::xPosRolePattern() const |
386 | { |
387 | const Q_D(QItemModelScatterDataProxy); |
388 | return d->m_xPosRolePattern; |
389 | } |
390 | |
391 | /*! |
392 | * \property QItemModelScatterDataProxy::yPosRolePattern |
393 | * |
394 | * \brief Whether a search and replace is done on the value mapped by the |
395 | * y position role before it is used as an item position value. |
396 | * |
397 | * This property specifies the regular expression to find the portion of the |
398 | * mapped value to replace and yPosRoleReplace property contains the replacement string. |
399 | * |
400 | * \sa yPosRole, yPosRoleReplace |
401 | */ |
402 | void QItemModelScatterDataProxy::setYPosRolePattern(const QRegularExpression &pattern) |
403 | { |
404 | Q_D(QItemModelScatterDataProxy); |
405 | if (d->m_yPosRolePattern != pattern) { |
406 | d->m_yPosRolePattern = pattern; |
407 | emit yPosRolePatternChanged(pattern); |
408 | } |
409 | } |
410 | |
411 | QRegularExpression QItemModelScatterDataProxy::yPosRolePattern() const |
412 | { |
413 | const Q_D(QItemModelScatterDataProxy); |
414 | return d->m_yPosRolePattern; |
415 | } |
416 | |
417 | /*! |
418 | * \property QItemModelScatterDataProxy::zPosRolePattern |
419 | * |
420 | * \brief Whether a search and replace is done on the value mapped by the z |
421 | * position role before it is used as an item position value. |
422 | * |
423 | * This property specifies the regular expression to find the portion of the |
424 | * mapped value to replace and zPosRoleReplace property contains the replacement string. |
425 | * |
426 | * \sa zPosRole, zPosRoleReplace |
427 | */ |
428 | void QItemModelScatterDataProxy::setZPosRolePattern(const QRegularExpression &pattern) |
429 | { |
430 | Q_D(QItemModelScatterDataProxy); |
431 | if (d->m_zPosRolePattern != pattern) { |
432 | d->m_zPosRolePattern = pattern; |
433 | emit zPosRolePatternChanged(pattern); |
434 | } |
435 | } |
436 | |
437 | QRegularExpression QItemModelScatterDataProxy::zPosRolePattern() const |
438 | { |
439 | const Q_D(QItemModelScatterDataProxy); |
440 | return d->m_zPosRolePattern; |
441 | } |
442 | |
443 | /*! |
444 | * \property QItemModelScatterDataProxy::rotationRolePattern |
445 | * |
446 | * \brief Whether a search and replace is done on the value mapped by the |
447 | * rotation role before it is used as item rotation. |
448 | * |
449 | * This property specifies the regular expression to find the portion |
450 | * of the mapped value to replace and rotationRoleReplace property contains the replacement string. |
451 | * |
452 | * \sa rotationRole, rotationRoleReplace |
453 | */ |
454 | void QItemModelScatterDataProxy::setRotationRolePattern(const QRegularExpression &pattern) |
455 | { |
456 | Q_D(QItemModelScatterDataProxy); |
457 | if (d->m_rotationRolePattern != pattern) { |
458 | d->m_rotationRolePattern = pattern; |
459 | emit rotationRolePatternChanged(pattern); |
460 | } |
461 | } |
462 | |
463 | QRegularExpression QItemModelScatterDataProxy::rotationRolePattern() const |
464 | { |
465 | const Q_D(QItemModelScatterDataProxy); |
466 | return d->m_rotationRolePattern; |
467 | } |
468 | |
469 | /*! |
470 | * \property QItemModelScatterDataProxy::xPosRoleReplace |
471 | * |
472 | * \brief The replace content to be used in conjunction with the x position role |
473 | * pattern. |
474 | * |
475 | * Defaults to an empty string. For more information on how the search and replace using regular |
476 | * expressions works, see QString::replace(const QRegularExpression &rx, const QString &after) |
477 | * function documentation. |
478 | * |
479 | * \sa xPosRole, xPosRolePattern |
480 | */ |
481 | void QItemModelScatterDataProxy::setXPosRoleReplace(const QString &replace) |
482 | { |
483 | Q_D(QItemModelScatterDataProxy); |
484 | if (d->m_xPosRoleReplace != replace) { |
485 | d->m_xPosRoleReplace = replace; |
486 | emit xPosRoleReplaceChanged(replace); |
487 | } |
488 | } |
489 | |
490 | QString QItemModelScatterDataProxy::xPosRoleReplace() const |
491 | { |
492 | const Q_D(QItemModelScatterDataProxy); |
493 | return d->m_xPosRoleReplace; |
494 | } |
495 | |
496 | /*! |
497 | * \property QItemModelScatterDataProxy::yPosRoleReplace |
498 | * |
499 | * \brief The replace content to be used in conjunction with the y position role |
500 | * pattern. |
501 | * |
502 | * Defaults to an empty string. For more information on how the search and replace using regular |
503 | * expressions works, see QString::replace(const QRegularExpression &rx, const QString &after) |
504 | * function documentation. |
505 | * |
506 | * \sa yPosRole, yPosRolePattern |
507 | */ |
508 | void QItemModelScatterDataProxy::setYPosRoleReplace(const QString &replace) |
509 | { |
510 | Q_D(QItemModelScatterDataProxy); |
511 | if (d->m_yPosRoleReplace != replace) { |
512 | d->m_yPosRoleReplace = replace; |
513 | emit yPosRoleReplaceChanged(replace); |
514 | } |
515 | } |
516 | |
517 | QString QItemModelScatterDataProxy::yPosRoleReplace() const |
518 | { |
519 | const Q_D(QItemModelScatterDataProxy); |
520 | return d->m_yPosRoleReplace; |
521 | } |
522 | |
523 | /*! |
524 | * \property QItemModelScatterDataProxy::zPosRoleReplace |
525 | * |
526 | * \brief The replace content to be used in conjunction with the z position role |
527 | * pattern. |
528 | * |
529 | * Defaults to an empty string. For more information on how the search and replace using regular |
530 | * expressions works, see QString::replace(const QRegularExpression &rx, const QString &after) |
531 | * function documentation. |
532 | * |
533 | * \sa zPosRole, zPosRolePattern |
534 | */ |
535 | void QItemModelScatterDataProxy::setZPosRoleReplace(const QString &replace) |
536 | { |
537 | Q_D(QItemModelScatterDataProxy); |
538 | if (d->m_zPosRoleReplace != replace) { |
539 | d->m_zPosRoleReplace = replace; |
540 | emit zPosRoleReplaceChanged(replace); |
541 | } |
542 | } |
543 | |
544 | QString QItemModelScatterDataProxy::zPosRoleReplace() const |
545 | { |
546 | const Q_D(QItemModelScatterDataProxy); |
547 | return d->m_zPosRoleReplace; |
548 | } |
549 | |
550 | /*! |
551 | * \property QItemModelScatterDataProxy::rotationRoleReplace |
552 | * |
553 | * \brief The replace content to be used in conjunction with the rotation role |
554 | * pattern. |
555 | * |
556 | * Defaults to an empty string. For more information on how the search and replace using regular |
557 | * expressions works, see QString::replace(const QRegularExpression &rx, const QString &after) |
558 | * function documentation. |
559 | * |
560 | * \sa rotationRole, rotationRolePattern |
561 | */ |
562 | void QItemModelScatterDataProxy::setRotationRoleReplace(const QString &replace) |
563 | { |
564 | Q_D(QItemModelScatterDataProxy); |
565 | if (d->m_rotationRoleReplace != replace) { |
566 | d->m_rotationRoleReplace = replace; |
567 | emit rotationRoleReplaceChanged(replace); |
568 | } |
569 | } |
570 | |
571 | QString QItemModelScatterDataProxy::rotationRoleReplace() const |
572 | { |
573 | const Q_D(QItemModelScatterDataProxy); |
574 | return d->m_rotationRoleReplace; |
575 | } |
576 | |
577 | /*! |
578 | * Changes \a xPosRole, \a yPosRole, \a zPosRole, and \a rotationRole mapping. |
579 | */ |
580 | void QItemModelScatterDataProxy::remap(const QString &xPosRole, const QString &yPosRole, |
581 | const QString &zPosRole, const QString &rotationRole) |
582 | { |
583 | setXPosRole(xPosRole); |
584 | setYPosRole(yPosRole); |
585 | setZPosRole(zPosRole); |
586 | setRotationRole(rotationRole); |
587 | } |
588 | |
589 | // QItemModelScatterDataProxyPrivate |
590 | |
591 | QItemModelScatterDataProxyPrivate::QItemModelScatterDataProxyPrivate(QItemModelScatterDataProxy *q) |
592 | : QScatterDataProxyPrivate(q), |
593 | m_itemModelHandler(new ScatterItemModelHandler(q)) |
594 | { |
595 | } |
596 | |
597 | QItemModelScatterDataProxyPrivate::~QItemModelScatterDataProxyPrivate() |
598 | { |
599 | delete m_itemModelHandler; |
600 | } |
601 | |
602 | void QItemModelScatterDataProxyPrivate::connectItemModelHandler() |
603 | { |
604 | Q_Q(QItemModelScatterDataProxy); |
605 | QObject::connect(sender: m_itemModelHandler, signal: &ScatterItemModelHandler::itemModelChanged, |
606 | context: q, slot: &QItemModelScatterDataProxy::itemModelChanged); |
607 | QObject::connect(sender: q, signal: &QItemModelScatterDataProxy::xPosRoleChanged, |
608 | context: m_itemModelHandler, slot: &AbstractItemModelHandler::handleMappingChanged); |
609 | QObject::connect(sender: q, signal: &QItemModelScatterDataProxy::yPosRoleChanged, |
610 | context: m_itemModelHandler, slot: &AbstractItemModelHandler::handleMappingChanged); |
611 | QObject::connect(sender: q, signal: &QItemModelScatterDataProxy::zPosRoleChanged, |
612 | context: m_itemModelHandler, slot: &AbstractItemModelHandler::handleMappingChanged); |
613 | QObject::connect(sender: q, signal: &QItemModelScatterDataProxy::rotationRoleChanged, |
614 | context: m_itemModelHandler, slot: &AbstractItemModelHandler::handleMappingChanged); |
615 | QObject::connect(sender: q, signal: &QItemModelScatterDataProxy::xPosRolePatternChanged, |
616 | context: m_itemModelHandler, slot: &AbstractItemModelHandler::handleMappingChanged); |
617 | QObject::connect(sender: q, signal: &QItemModelScatterDataProxy::yPosRolePatternChanged, |
618 | context: m_itemModelHandler, slot: &AbstractItemModelHandler::handleMappingChanged); |
619 | QObject::connect(sender: q, signal: &QItemModelScatterDataProxy::zPosRolePatternChanged, |
620 | context: m_itemModelHandler, slot: &AbstractItemModelHandler::handleMappingChanged); |
621 | QObject::connect(sender: q, signal: &QItemModelScatterDataProxy::rotationRolePatternChanged, |
622 | context: m_itemModelHandler, slot: &AbstractItemModelHandler::handleMappingChanged); |
623 | QObject::connect(sender: q, signal: &QItemModelScatterDataProxy::xPosRoleReplaceChanged, |
624 | context: m_itemModelHandler, slot: &AbstractItemModelHandler::handleMappingChanged); |
625 | QObject::connect(sender: q, signal: &QItemModelScatterDataProxy::yPosRoleReplaceChanged, |
626 | context: m_itemModelHandler, slot: &AbstractItemModelHandler::handleMappingChanged); |
627 | QObject::connect(sender: q, signal: &QItemModelScatterDataProxy::zPosRoleReplaceChanged, |
628 | context: m_itemModelHandler, slot: &AbstractItemModelHandler::handleMappingChanged); |
629 | QObject::connect(sender: q, signal: &QItemModelScatterDataProxy::rotationRoleReplaceChanged, |
630 | context: m_itemModelHandler, slot: &AbstractItemModelHandler::handleMappingChanged); |
631 | } |
632 | |
633 | QT_END_NAMESPACE |
634 | |