From 5f9be2bd06a3f0f8286325ad1eb323aa692126eb Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 14 May 2014 09:06:06 +0300 Subject: Multi-match behavior implementation for surface item model proxy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTRD-3074 Change-Id: I2dc67f0c524bce87498129bbc462bd8f014b8d2c Reviewed-by: Tomi Korpipää --- .../data/qitemmodelsurfacedataproxy.cpp | 62 +++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) (limited to 'src/datavisualization/data/qitemmodelsurfacedataproxy.cpp') 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: @@ -280,6 +282,36 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION * \sa zPosRole, zPosRolePattern */ +/*! + * \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. */ @@ -911,6 +943,31 @@ QString QItemModelSurfaceDataProxy::zPosRoleReplace() const return dptrc()->m_zPosRoleReplace; } +/*! + * \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 */ @@ -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 -- cgit v1.2.3