diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-05-14 09:06:06 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-05-14 09:26:37 +0300 |
commit | 5f9be2bd06a3f0f8286325ad1eb323aa692126eb (patch) | |
tree | db6240e2768d000f43df0a80023e80077e889baa /src/datavisualization/data/qitemmodelsurfacedataproxy.cpp | |
parent | c5e993ad507cc0d56d0e2a62076584d020086ad7 (diff) |
Multi-match behavior implementation for surface item model proxy
Task-number: QTRD-3074
Change-Id: I2dc67f0c524bce87498129bbc462bd8f014b8d2c
Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src/datavisualization/data/qitemmodelsurfacedataproxy.cpp')
-rw-r--r-- | src/datavisualization/data/qitemmodelsurfacedataproxy.cpp | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/src/datavisualization/data/qitemmodelsurfacedataproxy.cpp b/src/datavisualization/data/qitemmodelsurfacedataproxy.cpp index 94f36ec7..6ed1ec07 100644 --- a/src/datavisualization/data/qitemmodelsurfacedataproxy.cpp +++ b/src/datavisualization/data/qitemmodelsurfacedataproxy.cpp @@ -93,6 +93,8 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION * Data is resolved asynchronously whenever the mapping or the model changes. * QSurfaceDataProxy::arrayReset() is emitted when the data has been resolved. * + * For ItemModelSurfaceDataProxy enums, see \l{QItemModelSurfaceDataProxy::MultiMatchBehavior}. + * * For more details, see QItemModelSurfaceDataProxy documentation. * * Usage example: @@ -281,6 +283,36 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION */ /*! + * \qmlproperty ItemModelSurfaceDataProxy.MultiMatchBehavior ItemModelSurfaceDataProxy::multiMatchBehavior + * This property defines how multiple matches for each row/column combination are handled. + * Defaults to ItemModelSurfaceDataProxy.MMBLast. + * + * For example, you might have an item model with timestamped data taken at irregular intervals + * and you want to visualize an average position of data items on each hour with a surface graph. + * This can be done by specifying row and column categories so that each surface point represents + * an hour, and setting multiMatchBehavior to ItemModelSurfaceDataProxy.MMBAverage. + */ + +/*! + * \enum QItemModelSurfaceDataProxy::MultiMatchBehavior + * + * Behavior types for QItemModelSurfaceDataProxy::multiMatchBehavior property. + * + * \value MMBFirst + * The position values are taken from the first item in the item model that matches + * each row/column combination. + * \value MMBLast + * The position values are taken from the last item in the item model that matches + * each row/column combination. + * \value MMBAverage + * The position values from all items matching each row/column combination are + * averaged together and the averages are used as the surface point position. + * \value MMBCumulativeY + * For X and Z values this acts just like \c{MMBAverage}, but Y values are added together + * instead of averaged and the total is used as the surface point Y position. + */ + +/*! * Constructs QItemModelSurfaceDataProxy with optional \a parent. */ QItemModelSurfaceDataProxy::QItemModelSurfaceDataProxy(QObject *parent) @@ -912,6 +944,31 @@ QString QItemModelSurfaceDataProxy::zPosRoleReplace() const } /*! + * \property QItemModelSurfaceDataProxy::multiMatchBehavior + * + * This property defines how multiple matches for each row/column combination are handled. + * Defaults to QItemModelSurfaceDataProxy::MMBLast. + * + * For example, you might have an item model with timestamped data taken at irregular intervals + * and you want to visualize an average position of data items on each hour with a surface graph. + * This can be done by specifying row and column categories so that each surface point represents + * an hour, and setting multiMatchBehavior to QItemModelSurfaceDataProxy::MMBAverage. + */ + +void QItemModelSurfaceDataProxy::setMultiMatchBehavior(QItemModelSurfaceDataProxy::MultiMatchBehavior behavior) +{ + if (dptr()->m_multiMatchBehavior != behavior) { + dptr()->m_multiMatchBehavior = behavior; + emit multiMatchBehaviorChanged(behavior); + } +} + +QItemModelSurfaceDataProxy::MultiMatchBehavior QItemModelSurfaceDataProxy::multiMatchBehavior() const +{ + return dptrc()->m_multiMatchBehavior; +} + +/*! * \internal */ QItemModelSurfaceDataProxyPrivate *QItemModelSurfaceDataProxy::dptr() @@ -934,7 +991,8 @@ QItemModelSurfaceDataProxyPrivate::QItemModelSurfaceDataProxyPrivate(QItemModelS m_itemModelHandler(new SurfaceItemModelHandler(q)), m_useModelCategories(false), m_autoRowCategories(true), - m_autoColumnCategories(true) + m_autoColumnCategories(true), + m_multiMatchBehavior(QItemModelSurfaceDataProxy::MMBLast) { } @@ -992,6 +1050,8 @@ void QItemModelSurfaceDataProxyPrivate::connectItemModelHandler() m_itemModelHandler, &AbstractItemModelHandler::handleMappingChanged); QObject::connect(qptr(), &QItemModelSurfaceDataProxy::zPosRoleReplaceChanged, m_itemModelHandler, &AbstractItemModelHandler::handleMappingChanged); + QObject::connect(qptr(), &QItemModelSurfaceDataProxy::multiMatchBehaviorChanged, + m_itemModelHandler, &AbstractItemModelHandler::handleMappingChanged); } QT_END_NAMESPACE_DATAVISUALIZATION |