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