diff options
Diffstat (limited to 'src/boxplotchart')
-rw-r--r-- | src/boxplotchart/boxplotchart.pri | 25 | ||||
-rw-r--r-- | src/boxplotchart/boxplotchartitem.cpp | 215 | ||||
-rw-r--r-- | src/boxplotchart/boxplotchartitem_p.h | 84 | ||||
-rw-r--r-- | src/boxplotchart/boxwhiskers.cpp | 194 | ||||
-rw-r--r-- | src/boxplotchart/boxwhiskers_p.h | 102 | ||||
-rw-r--r-- | src/boxplotchart/boxwhiskersdata_p.h | 80 | ||||
-rw-r--r-- | src/boxplotchart/qboxplotmodelmapper.cpp | 489 | ||||
-rw-r--r-- | src/boxplotchart/qboxplotmodelmapper.h | 69 | ||||
-rw-r--r-- | src/boxplotchart/qboxplotmodelmapper_p.h | 93 | ||||
-rw-r--r-- | src/boxplotchart/qboxplotseries.cpp | 690 | ||||
-rw-r--r-- | src/boxplotchart/qboxplotseries.h | 85 | ||||
-rw-r--r-- | src/boxplotchart/qboxplotseries_p.h | 100 | ||||
-rw-r--r-- | src/boxplotchart/qboxset.cpp | 336 | ||||
-rw-r--r-- | src/boxplotchart/qboxset.h | 94 | ||||
-rw-r--r-- | src/boxplotchart/qboxset_p.h | 84 | ||||
-rw-r--r-- | src/boxplotchart/qvboxplotmodelmapper.cpp | 246 | ||||
-rw-r--r-- | src/boxplotchart/qvboxplotmodelmapper.h | 70 |
17 files changed, 0 insertions, 3056 deletions
diff --git a/src/boxplotchart/boxplotchart.pri b/src/boxplotchart/boxplotchart.pri deleted file mode 100644 index db6e034b..00000000 --- a/src/boxplotchart/boxplotchart.pri +++ /dev/null @@ -1,25 +0,0 @@ -INCLUDEPATH += $$PWD -DEPENDPATH += $$PWD - -SOURCES += \ - $$PWD/boxplotchartitem.cpp \ - $$PWD/qboxplotseries.cpp \ - $$PWD/boxwhiskers.cpp \ - $$PWD/qboxset.cpp \ - $$PWD/qboxplotmodelmapper.cpp \ - $$PWD/qvboxplotmodelmapper.cpp - -PRIVATE_HEADERS += \ - $$PWD/boxplotchartitem_p.h \ - $$PWD/qboxplotseries_p.h \ - $$PWD/boxwhiskers_p.h \ - $$PWD/boxwhiskersdata_p.h \ - $$PWD/qboxset_p.h \ - $$PWD/qboxplotmodelmapper_p.h - -PUBLIC_HEADERS += \ - $$PWD/qboxplotseries.h \ - $$PWD/qboxset.h \ - $$PWD/qboxplotmodelmapper.h \ - $$PWD/qvboxplotmodelmapper.h - diff --git a/src/boxplotchart/boxplotchartitem.cpp b/src/boxplotchart/boxplotchartitem.cpp deleted file mode 100644 index 430e903b..00000000 --- a/src/boxplotchart/boxplotchartitem.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "boxplotchartitem_p.h" -#include "qboxplotseries_p.h" -#include "bar_p.h" -#include "qboxset_p.h" -#include "qabstractbarseries_p.h" -#include "qboxset.h" -#include "boxwhiskers_p.h" -#include <QPainter> - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -BoxPlotChartItem::BoxPlotChartItem(QBoxPlotSeries *series, QGraphicsItem *item) : - ChartItem(series->d_func(), item), - m_series(series), - m_animation(0) -{ - connect(series, SIGNAL(boxsetsRemoved(QList<QBoxSet *>)), this, SLOT(handleBoxsetRemove(QList<QBoxSet *>))); - connect(series->d_func(), SIGNAL(restructuredBoxes()), this, SLOT(handleDataStructureChanged())); - connect(series->d_func(), SIGNAL(updatedLayout()), this, SLOT(handleLayoutChanged())); - connect(series->d_func(), SIGNAL(updatedBoxes()), this, SLOT(handleUpdatedBars())); - connect(series->d_func(), SIGNAL(updated()), this, SLOT(handleUpdatedBars())); - // QBoxPlotSeriesPrivate calls handleDataStructureChanged(), don't do it here - setZValue(ChartPresenter::BoxPlotSeriesZValue); -} - -BoxPlotChartItem::~BoxPlotChartItem() -{ -} - -void BoxPlotChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(painter); - Q_UNUSED(option); - Q_UNUSED(widget); -} - -void BoxPlotChartItem::setAnimation(BoxPlotAnimation *animation) -{ - m_animation = animation; - if (m_animation) { - foreach (BoxWhiskers *item, m_boxTable.values()) - m_animation->addBox(item); - handleDomainUpdated(); - } -} - -void BoxPlotChartItem::handleDataStructureChanged() -{ - int setCount = m_series->count(); - - for (int s = 0; s < setCount; s++) { - QBoxSet *set = m_series->d_func()->boxSetAt(s); - - BoxWhiskers *box = m_boxTable.value(set); - if (!box) { - // Item is not yet created, make a box and add it to hash table - box = new BoxWhiskers(set, domain(), this); - m_boxTable.insert(set, box); - connect(box, SIGNAL(clicked(QBoxSet *)), m_series, SIGNAL(clicked(QBoxSet *))); - connect(box, SIGNAL(hovered(bool, QBoxSet *)), m_series, SIGNAL(hovered(bool, QBoxSet *))); - connect(box, SIGNAL(clicked(QBoxSet *)), set, SIGNAL(clicked())); - connect(box, SIGNAL(hovered(bool, QBoxSet *)), set, SIGNAL(hovered(bool))); - - // Set the decorative issues for the newly created box - // so that the brush and pen already defined for the set are kept. - if (set->brush() == Qt::NoBrush) - box->setBrush(m_series->brush()); - else - box->setBrush(set->brush()); - if (set->pen() == Qt::NoPen) - box->setPen(m_series->pen()); - else - box->setPen(set->pen()); - box->setBoxOutlined(m_series->boxOutlineVisible()); - box->setBoxWidth(m_series->boxWidth()); - } - updateBoxGeometry(box, s); - - box->updateGeometry(domain()); - - if (m_animation) - m_animation->addBox(box); - } - - handleDomainUpdated(); -} - -void BoxPlotChartItem::handleUpdatedBars() -{ - foreach (BoxWhiskers *item, m_boxTable.values()) { - item->setBrush(m_series->brush()); - item->setPen(m_series->pen()); - item->setBoxOutlined(m_series->boxOutlineVisible()); - item->setBoxWidth(m_series->boxWidth()); - } - // Override with QBoxSet specific settings - foreach (QBoxSet *set, m_boxTable.keys()) { - if (set->brush().style() != Qt::NoBrush) - m_boxTable.value(set)->setBrush(set->brush()); - if (set->pen().style() != Qt::NoPen) - m_boxTable.value(set)->setPen(set->pen()); - } -} - -void BoxPlotChartItem::handleBoxsetRemove(QList<QBoxSet*> barSets) -{ - foreach (QBoxSet *set, barSets) { - BoxWhiskers *boxItem = m_boxTable.value(set); - m_boxTable.remove(set); - delete boxItem; - } -} - -void BoxPlotChartItem::handleDomainUpdated() -{ - if ((domain()->size().width() <= 0) || (domain()->size().height() <= 0)) - return; - - // Set my bounding rect to same as domain size. Add one pixel at the top (-1.0) and the bottom as 0.0 would - // snip a bit off from the whisker at the grid line - m_boundingRect.setRect(0.0, -1.0, domain()->size().width(), domain()->size().height() + 1.0); - - foreach (BoxWhiskers *item, m_boxTable.values()) { - item->updateGeometry(domain()); - - // If the animation is set, start the animation for each BoxWhisker item - if (m_animation) - presenter()->startAnimation(m_animation->boxAnimation(item)); - } -} - -void BoxPlotChartItem::handleLayoutChanged() -{ - foreach (BoxWhiskers *item, m_boxTable.values()) { - if (m_animation) - m_animation->setAnimationStart(item); - - item->setBoxWidth(m_series->boxWidth()); - - bool dirty = updateBoxGeometry(item, item->m_data.m_index); - if (dirty && m_animation) - presenter()->startAnimation(m_animation->boxChangeAnimation(item)); - else - item->updateGeometry(domain()); - } -} - -QRectF BoxPlotChartItem::boundingRect() const -{ - return m_boundingRect; -} - -void BoxPlotChartItem::initializeLayout() -{ -} - -QVector<QRectF> BoxPlotChartItem::calculateLayout() -{ - return QVector<QRectF>(); -} - -bool BoxPlotChartItem::updateBoxGeometry(BoxWhiskers *box, int index) -{ - bool changed = false; - - QBoxSet *set = m_series->d_func()->boxSetAt(index); - BoxWhiskersData &data = box->m_data; - - if ((data.m_lowerExtreme != set->at(0)) || (data.m_lowerQuartile != set->at(1)) || - (data.m_median != set->at(2)) || (data.m_upperQuartile != set->at(3)) || (data.m_upperExtreme != set->at(4))) { - changed = true; - } - - data.m_lowerExtreme = set->at(0); - data.m_lowerQuartile = set->at(1); - data.m_median = set->at(2); - data.m_upperQuartile = set->at(3); - data.m_upperExtreme = set->at(4); - data.m_index = index; - data.m_boxItems = m_series->count(); - - data.m_maxX = domain()->maxX(); - data.m_minX = domain()->minX(); - data.m_maxY = domain()->maxY(); - data.m_minY = domain()->minY(); - - data.m_seriesIndex = m_seriesIndex; - data.m_seriesCount = m_seriesCount; - - return changed; -} - -#include "moc_boxplotchartitem_p.cpp" - -QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/boxplotchart/boxplotchartitem_p.h b/src/boxplotchart/boxplotchartitem_p.h deleted file mode 100644 index e6a06a9c..00000000 --- a/src/boxplotchart/boxplotchartitem_p.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// W A R N I N G -// ------------- -// -// This file is not part of the Qt Enterprise Chart API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. - - -#ifndef BOXPLOTCHARTITEM_H -#define BOXPLOTCHARTITEM_H - -#include "boxwhiskers_p.h" -#include "qboxplotseries.h" -#include "chartitem_p.h" -#include "boxplotanimation_p.h" -#include "qboxset.h" -#include <QGraphicsItem> - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -class BoxPlotSeriesPrivate; - -class BoxPlotChartItem : public ChartItem -{ - Q_OBJECT -public: - BoxPlotChartItem(QBoxPlotSeries *series, QGraphicsItem *item = 0); - ~BoxPlotChartItem(); - - void setAnimation(BoxPlotAnimation *animation); - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - QRectF boundingRect() const; - -public Q_SLOTS: - void handleDataStructureChanged(); - void handleDomainUpdated(); - void handleLayoutChanged(); - void handleUpdatedBars(); - void handleBoxsetRemove(QList<QBoxSet *> barSets); - -private: - virtual QVector<QRectF> calculateLayout(); - void initializeLayout(); - bool updateBoxGeometry(BoxWhiskers *box, int index); - -protected: - friend class QBoxPlotSeriesPrivate; - QBoxPlotSeries *m_series; // Not owned. - QList<BoxWhiskers *> m_boxes; - QHash<QBoxSet *, BoxWhiskers *> m_boxTable; - int m_seriesIndex; - int m_seriesCount; - - BoxPlotAnimation *m_animation; - - QRectF m_boundingRect; -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif // BOXPLOTCHARTITEM_H diff --git a/src/boxplotchart/boxwhiskers.cpp b/src/boxplotchart/boxwhiskers.cpp deleted file mode 100644 index 151c8668..00000000 --- a/src/boxplotchart/boxwhiskers.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/**************************************************************************** - ** - ** Copyright (C) 2014 Digia Plc - ** All rights reserved. - ** For any questions to Digia, please use contact form at http://qt.digia.com - ** - ** This file is part of the Qt Enterprise Charts Add-on. - ** - ** $QT_BEGIN_LICENSE$ - ** Licensees holding valid Qt Enterprise licenses may use this file in - ** accordance with the Qt Enterprise License Agreement provided with the - ** Software or, alternatively, in accordance with the terms contained in - ** a written agreement between you and Digia. - ** - ** If you have questions regarding the use of this file, please use - ** contact form at http://qt.digia.com - ** $QT_END_LICENSE$ - ** - ****************************************************************************/ - -#include "boxwhiskers_p.h" -#include <QPainter> -#include <QWidget> - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -BoxWhiskers::BoxWhiskers(QBoxSet *set, AbstractDomain *domain, QGraphicsObject *parent) : - QGraphicsObject(parent), - m_boxSet(set), - m_domain(domain) -{ - setAcceptHoverEvents(true); - setAcceptedMouseButtons(Qt::MouseButtonMask); -} - -BoxWhiskers::~BoxWhiskers() -{ -} - -void BoxWhiskers::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - Q_UNUSED(event) - emit clicked(m_boxSet); -} - -void BoxWhiskers::hoverEnterEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event) - emit hovered(true, m_boxSet); -} - -void BoxWhiskers::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event) - emit hovered(false, m_boxSet); -} - -void BoxWhiskers::setBrush(const QBrush &brush) -{ - m_brush = brush; - m_outlinePen.setColor(m_brush.color()); - update(); -} - -void BoxWhiskers::setPen(const QPen &pen) -{ - qreal widthDiff = pen.widthF() - m_pen.widthF(); - m_boundingRect.adjust(-widthDiff, -widthDiff, widthDiff, widthDiff); - - m_pen = pen; - m_medianPen = pen; - m_medianPen.setCapStyle(Qt::FlatCap); - m_outlinePen = pen; - m_outlinePen.setStyle(Qt::SolidLine); - m_outlinePen.setColor(m_brush.color()); - - update(); -} - -void BoxWhiskers::setBoxWidth(const qreal width) -{ - m_boxWidth = width; -} - -void BoxWhiskers::setLayout(const BoxWhiskersData &data) -{ - m_data = data; - - updateGeometry(m_domain); - update(); -} - -QSizeF BoxWhiskers::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const -{ - Q_UNUSED(which) - Q_UNUSED(constraint) - - return QSizeF(); -} - -void BoxWhiskers::setGeometry(const QRectF &rect) -{ - Q_UNUSED(rect) -} - -QRectF BoxWhiskers::boundingRect() const -{ - return m_boundingRect; -} - -void BoxWhiskers::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(option) - Q_UNUSED(widget) - - painter->save(); - painter->setBrush(m_brush); - painter->setClipRect(parentItem()->boundingRect()); - painter->setPen(m_pen); - painter->drawPath(m_boxPath); - if (!m_boxOutlined) - painter->setPen(m_outlinePen); - painter->drawRect(m_middleBox); - painter->setPen(m_medianPen); - qreal halfLine = m_pen.widthF() / 2.0; - painter->drawLine(QLineF(m_geometryLeft - halfLine, m_geometryMedian, - m_geometryRight + halfLine, m_geometryMedian)); - painter->restore(); -} - -void BoxWhiskers::updateGeometry(AbstractDomain *domain) -{ - m_domain = domain; - - prepareGeometryChange(); - - QPainterPath path; - m_boxPath = path; - m_boundingRect = m_boxPath.boundingRect(); - - qreal columnWidth = 1.0 / m_data.m_seriesCount; - qreal left = ((1.0 - m_boxWidth) / 2.0) * columnWidth + columnWidth * m_data.m_seriesIndex + m_data.m_index - 0.5; - qreal barWidth = m_boxWidth * columnWidth; - - QPointF geometryPoint = m_domain->calculateGeometryPoint(QPointF(left, m_data.m_upperExtreme), m_validData); - if (!m_validData) - return; - m_geometryLeft = geometryPoint.x(); - qreal geometryUpperExtreme = geometryPoint.y(); - geometryPoint = m_domain->calculateGeometryPoint(QPointF(left + barWidth, m_data.m_upperQuartile), m_validData); - if (!m_validData) - return; - m_geometryRight = geometryPoint.x(); - qreal geometryUpperQuartile = geometryPoint.y(); - geometryPoint = m_domain->calculateGeometryPoint(QPointF(left, m_data.m_lowerQuartile), m_validData); - if (!m_validData) - return; - qreal geometryLowerQuartile = geometryPoint.y(); - geometryPoint = m_domain->calculateGeometryPoint(QPointF(left, m_data.m_lowerExtreme), m_validData); - if (!m_validData) - return; - qreal geometryLowerExtreme = geometryPoint.y(); - geometryPoint = m_domain->calculateGeometryPoint(QPointF(left, m_data.m_median), m_validData); - if (!m_validData) - return; - m_geometryMedian = geometryPoint.y(); - - // Upper whisker - path.moveTo(m_geometryLeft, geometryUpperExtreme); - path.lineTo(m_geometryRight, geometryUpperExtreme); - path.moveTo((m_geometryLeft + m_geometryRight) / 2.0, geometryUpperExtreme); - path.lineTo((m_geometryLeft + m_geometryRight) / 2.0, geometryUpperQuartile); - - // Middle Box - m_middleBox.setCoords(m_geometryLeft, geometryUpperQuartile, m_geometryRight, geometryLowerQuartile); - - // Lower whisker - path.moveTo(m_geometryLeft, geometryLowerExtreme); - path.lineTo(m_geometryRight, geometryLowerExtreme); - path.moveTo((m_geometryLeft + m_geometryRight) / 2.0, geometryLowerQuartile); - path.lineTo((m_geometryLeft + m_geometryRight) / 2.0, geometryLowerExtreme); - - path.closeSubpath(); - - m_boxPath = path; - m_boundingRect = m_boxPath.boundingRect(); - - qreal extra = m_pen.widthF(); - m_boundingRect.adjust(-extra, -extra, extra, extra); -} - -#include "moc_boxwhiskers_p.cpp" - -QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/boxplotchart/boxwhiskers_p.h b/src/boxplotchart/boxwhiskers_p.h deleted file mode 100644 index f6d1837a..00000000 --- a/src/boxplotchart/boxwhiskers_p.h +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// W A R N I N G -// ------------- -// -// This file is not part of the Qt Enterprise Chart API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. - -#ifndef BOXWHISKERS_H -#define BOXWHISKERS_H - -#include "boxwhiskersdata_p.h" -#include "qchartglobal.h" -#include "abstractdomain_p.h" -#include <QBoxSet> -#include <QGraphicsRectItem> -#include <QGraphicsLineItem> -#include <QGraphicsLayoutItem> -#include <QPainterPath> - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -class QBarSet; - -class BoxWhiskers : public QGraphicsObject -{ - Q_OBJECT - -public: - BoxWhiskers(QBoxSet *set, AbstractDomain *domain, QGraphicsObject *parent); - ~BoxWhiskers(); - - void setBrush(const QBrush &brush); - void setPen(const QPen &pen); - void setLayout(const BoxWhiskersData &data); - void setBoxOutlined(const bool outlined) { m_boxOutlined = outlined; } - void setBoxWidth(const qreal width); - - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void hoverEnterEvent(QGraphicsSceneHoverEvent *event); - void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); - - QRectF boundingRect() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - - void updateGeometry(AbstractDomain *domain); -protected: - QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const; - void setGeometry(const QRectF &rect); - -Q_SIGNALS: - void clicked(QBoxSet *boxset); - void hovered(bool status, QBoxSet *boxset); - -private: - friend class BoxPlotChartItem; - friend class BoxPlotAnimation; - - QBoxSet *m_boxSet; - AbstractDomain *m_domain; - QPainterPath m_boxPath; - QRectF m_boundingRect; - bool m_hovering; - bool m_validData; - QBrush m_brush; - QPen m_pen; - QPen m_medianPen; - QPen m_outlinePen; - bool m_boxOutlined; - qreal m_boxWidth; - BoxWhiskersData m_data; - QSizeF m_domainSize; - QRectF m_middleBox; - qreal m_geometryMedian; - qreal m_geometryLeft; - qreal m_geometryRight; -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif // BOXWHISKERS_H diff --git a/src/boxplotchart/boxwhiskersdata_p.h b/src/boxplotchart/boxwhiskersdata_p.h deleted file mode 100644 index 653f51c3..00000000 --- a/src/boxplotchart/boxwhiskersdata_p.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// W A R N I N G -// ------------- -// -// This file is not part of the Qt Enterprise Chart API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. - -#ifndef BOXWHISKERSDATA_P_H -#define BOXWHISKERSDATA_P_H - -#include "qchartglobal.h" -#include <QSizeF> - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -class BoxWhiskersData -{ -public: - BoxWhiskersData() : - m_lowerExtreme(0.0), - m_lowerQuartile(0.0), - m_median(0.0), - m_upperQuartile(0.0), - m_upperExtreme(0.0), - m_index(0), - m_boxItems(0), - m_maxX(0.0), - m_minX(0.0), - m_maxY(0.0), - m_minY(0.0), - m_seriesIndex(0), - m_seriesCount(0) - { - } - - // Box related statistics - qreal m_lowerExtreme; - qreal m_lowerQuartile; - qreal m_median; - qreal m_upperQuartile; - qreal m_upperExtreme; - int m_index; - int m_boxItems; - - // Domain boundaries, axis - qreal m_maxX; - qreal m_minX; - qreal m_maxY; - qreal m_minY; - - // Serieses related data - int m_seriesIndex; - int m_seriesCount; -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif // BOXWHISKERSDATA_P_H diff --git a/src/boxplotchart/qboxplotmodelmapper.cpp b/src/boxplotchart/qboxplotmodelmapper.cpp deleted file mode 100644 index cf84e479..00000000 --- a/src/boxplotchart/qboxplotmodelmapper.cpp +++ /dev/null @@ -1,489 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qboxplotmodelmapper.h" -#include "qboxplotmodelmapper_p.h" -#include "qboxplotseries.h" -#include "qboxset.h" -#include "qchart.h" -#include <QAbstractItemModel> - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -QBoxPlotModelMapper::QBoxPlotModelMapper(QObject *parent) : - QObject(parent), - d_ptr(new QBoxPlotModelMapperPrivate(this)) -{ -} - -QAbstractItemModel *QBoxPlotModelMapper::model() const -{ - Q_D(const QBoxPlotModelMapper); - return d->m_model; -} - -void QBoxPlotModelMapper::setModel(QAbstractItemModel *model) -{ - if (model == 0) - return; - - Q_D(QBoxPlotModelMapper); - if (d->m_model) - disconnect(d->m_model, 0, d, 0); - - d->m_model = model; - d->initializeBoxFromModel(); - // connect signals from the model - connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); - connect(d->m_model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), d, SLOT(modelHeaderDataUpdated(Qt::Orientation,int,int))); - connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); - connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); - connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); - connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); - connect(d->m_model, SIGNAL(destroyed()), d, SLOT(handleModelDestroyed())); -} - -QBoxPlotSeries *QBoxPlotModelMapper::series() const -{ - Q_D(const QBoxPlotModelMapper); - return d->m_series; -} - -void QBoxPlotModelMapper::setSeries(QBoxPlotSeries *series) -{ - Q_D(QBoxPlotModelMapper); - if (d->m_series) - disconnect(d->m_series, 0, d, 0); - - if (series == 0) - return; - - d->m_series = series; - d->initializeBoxFromModel(); - // connect the signals from the series - connect(d->m_series, SIGNAL(boxsetsAdded(QList<QBoxSet *>)), d, SLOT(boxSetsAdded(QList<QBoxSet *>))); - connect(d->m_series, SIGNAL(boxsetsRemoved(QList<QBoxSet *>)), d, SLOT(boxSetsRemoved(QList<QBoxSet *>))); - connect(d->m_series, SIGNAL(destroyed()), d, SLOT(handleSeriesDestroyed())); -} - -/*! - Returns which row/column of the model contains the first values of the QBoxSets in the series. - The default value is 0. -*/ -int QBoxPlotModelMapper::first() const -{ - Q_D(const QBoxPlotModelMapper); - return d->m_first; -} - -/*! - Sets which row/column of the model contains the \a first values of the QBoxSets in the series. - The default value is 0. -*/ -void QBoxPlotModelMapper::setFirst(int first) -{ - Q_D(QBoxPlotModelMapper); - d->m_first = qMax(first, 0); - d->initializeBoxFromModel(); -} - -/*! - Returns the number of rows/columns of the model that are mapped as the data for QBoxPlotSeries - Minimal and default value is: -1 (count limited by the number of rows/columns in the model) -*/ -int QBoxPlotModelMapper::count() const -{ - Q_D(const QBoxPlotModelMapper); - return d->m_count; -} - -/*! - Sets the \a count of rows/columns of the model that are mapped as the data for QBoxPlotSeries - Minimal and default value is: -1 (count limited by the number of rows/columns in the model) -*/ -void QBoxPlotModelMapper::setCount(int count) -{ - Q_D(QBoxPlotModelMapper); - d->m_count = qMax(count, -1); - d->initializeBoxFromModel(); -} - -/*! - Returns the orientation that is used when QBoxPlotModelMapper accesses the model. - This means whether the consecutive values of the box-and-whiskers set are read from row (Qt::Horizontal) - or from columns (Qt::Vertical) -*/ -Qt::Orientation QBoxPlotModelMapper::orientation() const -{ - Q_D(const QBoxPlotModelMapper); - return d->m_orientation; -} - -/*! - Returns the \a orientation that is used when QBoxPlotModelMapper accesses the model. - This mean whether the consecutive values of the box-and-whiskers set are read from row (Qt::Horizontal) - or from columns (Qt::Vertical) -*/ -void QBoxPlotModelMapper::setOrientation(Qt::Orientation orientation) -{ - Q_D(QBoxPlotModelMapper); - d->m_orientation = orientation; - d->initializeBoxFromModel(); -} - -/*! - Returns which section of the model is used as the data source for the first box set -*/ -int QBoxPlotModelMapper::firstBoxSetSection() const -{ - Q_D(const QBoxPlotModelMapper); - return d->m_firstBoxSetSection; -} - -/*! - Sets the model section that is used as the data source for the first box set - Parameter \a firstBoxSetSection specifies the section of the model. -*/ -void QBoxPlotModelMapper::setFirstBoxSetSection(int firstBoxSetSection) -{ - Q_D(QBoxPlotModelMapper); - d->m_firstBoxSetSection = qMax(-1, firstBoxSetSection); - d->initializeBoxFromModel(); -} - -/*! - Returns which section of the model is used as the data source for the last box set -*/ -int QBoxPlotModelMapper::lastBoxSetSection() const -{ - Q_D(const QBoxPlotModelMapper); - return d->m_lastBoxSetSection; -} - -/*! - Sets the model section that is used as the data source for the last box set - Parameter \a lastBoxSetSection specifies the section of the model. -*/ -void QBoxPlotModelMapper::setLastBoxSetSection(int lastBoxSetSection) -{ - Q_D(QBoxPlotModelMapper); - d->m_lastBoxSetSection = qMax(-1, lastBoxSetSection); - d->initializeBoxFromModel(); -} - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -QBoxPlotModelMapperPrivate::QBoxPlotModelMapperPrivate(QBoxPlotModelMapper *q) : - QObject(q), - m_series(0), - m_model(0), - m_first(0), - m_count(-1), - m_orientation(Qt::Vertical), - m_firstBoxSetSection(-1), - m_lastBoxSetSection(-1), - m_seriesSignalsBlock(false), - m_modelSignalsBlock(false), - q_ptr(q) -{ -} - -void QBoxPlotModelMapperPrivate::blockModelSignals(bool block) -{ - m_modelSignalsBlock = block; -} - -void QBoxPlotModelMapperPrivate::blockSeriesSignals(bool block) -{ - m_seriesSignalsBlock = block; -} - -QBoxSet *QBoxPlotModelMapperPrivate::boxSet(QModelIndex index) -{ - if (!index.isValid()) - return 0; - - if (m_orientation == Qt::Vertical && index.column() >= m_firstBoxSetSection && index.column() <= m_lastBoxSetSection) { - if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) - return m_series->boxSets().at(index.column() - m_firstBoxSetSection); - } else if (m_orientation == Qt::Horizontal && index.row() >= m_firstBoxSetSection && index.row() <= m_lastBoxSetSection) { - if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) - return m_series->boxSets().at(index.row() - m_firstBoxSetSection); - } - return 0; // This part of model has not been mapped to any boxset -} - -QModelIndex QBoxPlotModelMapperPrivate::boxModelIndex(int boxSection, int posInBar) -{ - if (m_count != -1 && posInBar >= m_count) - return QModelIndex(); // invalid - - if (boxSection < m_firstBoxSetSection || boxSection > m_lastBoxSetSection) - return QModelIndex(); // invalid - - if (m_orientation == Qt::Vertical) - return m_model->index(posInBar + m_first, boxSection); - else - return m_model->index(boxSection, posInBar + m_first); -} - -void QBoxPlotModelMapperPrivate::handleSeriesDestroyed() -{ - m_series = 0; -} - -void QBoxPlotModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) -{ - Q_UNUSED(topLeft) - Q_UNUSED(bottomRight) - - if (m_model == 0 || m_series == 0) - return; - - if (m_modelSignalsBlock) - return; - - blockSeriesSignals(); - QModelIndex index; - for (int row = topLeft.row(); row <= bottomRight.row(); row++) { - for (int column = topLeft.column(); column <= bottomRight.column(); column++) { - index = topLeft.sibling(row, column); - QBoxSet *box = boxSet(index); - if (box) { - if (m_orientation == Qt::Vertical) - box->setValue(row - m_first, m_model->data(index).toReal()); - else - box->setValue(column - m_first, m_model->data(index).toReal()); - } - } - } - blockSeriesSignals(false); -} - -void QBoxPlotModelMapperPrivate::modelHeaderDataUpdated(Qt::Orientation orientation, int first, int last) -{ - Q_UNUSED(orientation); - Q_UNUSED(first); - Q_UNUSED(last); -} - -void QBoxPlotModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end) -{ - Q_UNUSED(parent) - if (m_modelSignalsBlock) - return; - - blockSeriesSignals(); - if (m_orientation == Qt::Vertical) - insertData(start, end); - else if (start <= m_firstBoxSetSection || start <= m_lastBoxSetSection) // if the changes affect the map - reinitialize - initializeBoxFromModel(); - blockSeriesSignals(false); -} - -void QBoxPlotModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end) -{ - Q_UNUSED(parent) - if (m_modelSignalsBlock) - return; - - blockSeriesSignals(); - if (m_orientation == Qt::Vertical) - removeData(start, end); - else if (start <= m_firstBoxSetSection || start <= m_lastBoxSetSection) // if the changes affect the map - reinitialize - initializeBoxFromModel(); - blockSeriesSignals(false); -} - -void QBoxPlotModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end) -{ - Q_UNUSED(parent) - if (m_modelSignalsBlock) - return; - - blockSeriesSignals(); - if (m_orientation == Qt::Horizontal) - insertData(start, end); - else if (start <= m_firstBoxSetSection || start <= m_lastBoxSetSection) // if the changes affect the map - reinitialize - initializeBoxFromModel(); - blockSeriesSignals(false); -} - -void QBoxPlotModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end) -{ - Q_UNUSED(parent) - if (m_modelSignalsBlock) - return; - - blockSeriesSignals(); - if (m_orientation == Qt::Horizontal) - removeData(start, end); - else if (start <= m_firstBoxSetSection || start <= m_lastBoxSetSection) // if the changes affect the map - reinitialize - initializeBoxFromModel(); - blockSeriesSignals(false); -} - -void QBoxPlotModelMapperPrivate::handleModelDestroyed() -{ - m_model = 0; -} - -void QBoxPlotModelMapperPrivate::insertData(int start, int end) -{ - Q_UNUSED(end) - Q_UNUSED(start) - Q_UNUSED(end) - // Currently boxplotchart needs to be fully recalculated when change is made. - // Re-initialize - initializeBoxFromModel(); -} - -void QBoxPlotModelMapperPrivate::removeData(int start, int end) -{ - Q_UNUSED(end) - Q_UNUSED(start) - Q_UNUSED(end) - // Currently boxplotchart needs to be fully recalculated when change is made. - // Re-initialize - initializeBoxFromModel(); -} - -void QBoxPlotModelMapperPrivate::boxSetsAdded(QList<QBoxSet *> sets) -{ - if (m_seriesSignalsBlock) - return; - - if (sets.count() == 0) - return; - - int firstIndex = m_series->boxSets().indexOf(sets.at(0)); - if (firstIndex == -1) - return; - - int maxCount = 0; - for (int i = 0; i < sets.count(); i++) { - if (sets.at(i)->count() > m_count) - maxCount = sets.at(i)->count(); - } - - if (m_count != -1 && m_count < maxCount) - m_count = maxCount; - - m_lastBoxSetSection += sets.count(); - - blockModelSignals(); - int modelCapacity = m_orientation == Qt::Vertical ? m_model->rowCount() - m_first : m_model->columnCount() - m_first; - if (maxCount > modelCapacity) { - if (m_orientation == Qt::Vertical) - m_model->insertRows(m_model->rowCount(), maxCount - modelCapacity); - else - m_model->insertColumns(m_model->columnCount(), maxCount - modelCapacity); - } - - if (m_orientation == Qt::Vertical) - m_model->insertColumns(firstIndex + m_firstBoxSetSection, sets.count()); - else - m_model->insertRows(firstIndex + m_firstBoxSetSection, sets.count()); - - - for (int i = firstIndex + m_firstBoxSetSection; i < firstIndex + m_firstBoxSetSection + sets.count(); i++) { - for (int j = 0; j < sets.at(i - firstIndex - m_firstBoxSetSection)->count(); j++) - m_model->setData(boxModelIndex(i, j), sets.at(i - firstIndex - m_firstBoxSetSection)->at(j)); - } - blockModelSignals(false); - initializeBoxFromModel(); -} - -void QBoxPlotModelMapperPrivate::boxSetsRemoved(QList<QBoxSet *> sets) -{ - if (m_seriesSignalsBlock) - return; - - if (sets.count() == 0) - return; - - int firstIndex = m_boxSets.indexOf(sets.at(0)); - if (firstIndex == -1) - return; - - m_lastBoxSetSection -= sets.count(); - - for (int i = firstIndex + sets.count() - 1; i >= firstIndex; i--) - m_boxSets.removeAt(i); - - blockModelSignals(); - if (m_orientation == Qt::Vertical) - m_model->removeColumns(firstIndex + m_firstBoxSetSection, sets.count()); - else - m_model->removeRows(firstIndex + m_firstBoxSetSection, sets.count()); - blockModelSignals(false); - initializeBoxFromModel(); -} - -void QBoxPlotModelMapperPrivate::boxValueChanged(int index) -{ - if (m_seriesSignalsBlock) - return; - - int boxSetIndex = m_boxSets.indexOf(qobject_cast<QBoxSet *>(QObject::sender())); - - blockModelSignals(); - m_model->setData(boxModelIndex(boxSetIndex + m_firstBoxSetSection, index), m_boxSets.at(boxSetIndex)->at(index)); - blockModelSignals(false); - initializeBoxFromModel(); -} - -void QBoxPlotModelMapperPrivate::initializeBoxFromModel() -{ - if (m_model == 0 || m_series == 0) - return; - - blockSeriesSignals(); - // clear current content - m_series->clear(); - m_boxSets.clear(); - - // create the initial box-and-whiskers sets - for (int i = m_firstBoxSetSection; i <= m_lastBoxSetSection; i++) { - int posInBar = 0; - QModelIndex boxIndex = boxModelIndex(i, posInBar); - // check if there is such model index - if (boxIndex.isValid()) { - QBoxSet *boxSet = new QBoxSet(); - while (boxIndex.isValid()) { - boxSet->append(m_model->data(boxIndex, Qt::DisplayRole).toDouble()); - posInBar++; - boxIndex = boxModelIndex(i, posInBar); - } - connect(boxSet, SIGNAL(valueChanged(int)), this, SLOT(boxValueChanged(int))); - m_series->append(boxSet); - m_boxSets.append(boxSet); - } else { - break; - } - } - blockSeriesSignals(false); -} - -#include "moc_qboxplotmodelmapper.cpp" -#include "moc_qboxplotmodelmapper_p.cpp" - -QTCOMMERCIALCHART_END_NAMESPACE - diff --git a/src/boxplotchart/qboxplotmodelmapper.h b/src/boxplotchart/qboxplotmodelmapper.h deleted file mode 100644 index 6e2a8c9c..00000000 --- a/src/boxplotchart/qboxplotmodelmapper.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QBOXPLOTMODELMAPPER_H -#define QBOXPLOTMODELMAPPER_H - -#include "qchartglobal.h" -#include <QObject> - -class QAbstractItemModel; - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -class QBoxPlotModelMapperPrivate; -class QBoxPlotSeries; - -class QTCOMMERCIALCHART_EXPORT QBoxPlotModelMapper : public QObject -{ - Q_OBJECT - -protected: - explicit QBoxPlotModelMapper(QObject *parent = 0); - - QAbstractItemModel *model() const; - void setModel(QAbstractItemModel *model); - - QBoxPlotSeries *series() const; - void setSeries(QBoxPlotSeries *series); - - int first() const; - void setFirst(int first); - - int count() const; - void setCount(int count); - - int firstBoxSetSection() const; - void setFirstBoxSetSection(int firstBoxSetSection); - - int lastBoxSetSection() const; - void setLastBoxSetSection(int lastBoxSetSection); - - Qt::Orientation orientation() const; - void setOrientation(Qt::Orientation orientation); - -protected: - QBoxPlotModelMapperPrivate * const d_ptr; - Q_DECLARE_PRIVATE(QBoxPlotModelMapper) -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif // QBOXPLOTMODELMAPPER_H diff --git a/src/boxplotchart/qboxplotmodelmapper_p.h b/src/boxplotchart/qboxplotmodelmapper_p.h deleted file mode 100644 index cbaef258..00000000 --- a/src/boxplotchart/qboxplotmodelmapper_p.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// W A R N I N G -// ------------- -// -// This file is not part of the Qt Enterprise Chart API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. - -#ifndef QBOXPLOTMODELMAPPER_P_H -#define QBOXPLOTMODELMAPPER_P_H - -#include <QObject> -#include "qboxplotmodelmapper.h" - -class QModelIndex; - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -class QBoxSet; - -class QBoxPlotModelMapperPrivate : public QObject -{ - Q_OBJECT -public: - explicit QBoxPlotModelMapperPrivate(QBoxPlotModelMapper *q); - -public Q_SLOTS: - // for the model - void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); - void modelHeaderDataUpdated(Qt::Orientation orientation, int first, int last); - void modelRowsAdded(QModelIndex parent, int start, int end); - void modelRowsRemoved(QModelIndex parent, int start, int end); - void modelColumnsAdded(QModelIndex parent, int start, int end); - void modelColumnsRemoved(QModelIndex parent, int start, int end); - void handleModelDestroyed(); - - // for the series - void boxSetsAdded(QList<QBoxSet *> sets); - void boxSetsRemoved(QList<QBoxSet *> sets); - void boxValueChanged(int index); - void handleSeriesDestroyed(); - - void initializeBoxFromModel(); - -private: - QBoxSet *boxSet(QModelIndex index); - QModelIndex boxModelIndex(int boxSection, int posInBox); - void insertData(int start, int end); - void removeData(int start, int end); - void blockModelSignals(bool block = true); - void blockSeriesSignals(bool block = true); - -private: - QBoxPlotSeries *m_series; - QList<QBoxSet *> m_boxSets; - QAbstractItemModel *m_model; - int m_first; - int m_count; - Qt::Orientation m_orientation; - int m_firstBoxSetSection; - int m_lastBoxSetSection; - bool m_seriesSignalsBlock; - bool m_modelSignalsBlock; - -private: - QBoxPlotModelMapper *q_ptr; - Q_DECLARE_PUBLIC(QBoxPlotModelMapper) -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif // QBOXPLOTMODELMAPPER_P_H diff --git a/src/boxplotchart/qboxplotseries.cpp b/src/boxplotchart/qboxplotseries.cpp deleted file mode 100644 index 4f562d79..00000000 --- a/src/boxplotchart/qboxplotseries.cpp +++ /dev/null @@ -1,690 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qboxplotseries.h" -#include "qboxplotseries_p.h" -#include "qboxplotlegendmarker.h" -#include "qbarcategoryaxis.h" -#include "boxplotchartitem_p.h" -#include "chartdataset_p.h" -#include "charttheme_p.h" -#include "qvalueaxis.h" -#include "charttheme_p.h" -#include "boxplotanimation_p.h" -#include "qchart_p.h" -#include "qboxset.h" -#include "qboxset_p.h" - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -/*! - \class QBoxPlotSeries - \inmodule Qt Charts - \brief Series for creating box-and-whiskers chart - \mainclass - - QBoxPlotSeries represents a series of data shown as box-and-whisker bars. The purpose of this class is to act as - a container for single box-and-whisker items. Each item is drawn to own slot. If chart includes multiple instances of - QBoxPlotSeries then box-and-whiskers items with the same index are drawn to same slot. - - See the \l {Box and Whiskers Example} {box-and-whiskers chart example} to learn how to create a box-and-whiskers chart. - \image examples_boxplotchart.png - - \sa QBoxSet -*/ -/*! - \fn QBoxPlotSeries::boxsetsAdded(QList<QBoxSet *> sets) - \brief Signal is emitted when a new \a sets of box-and-whiskers data is added to the series. -*/ -/*! - \fn QBoxPlotSeries::boxsetsRemoved(QList<QBoxSet *> sets) - \brief Signal is emitted when \a sets of box-and-whiskers data is removed from the series. -*/ -/*! - \fn QBoxPlotSeries::clicked(QBoxSet *boxset) - \brief Signal is emitted when the user clicks the \a boxset on the chart. -*/ -/*! - \fn QBoxPlotSeries::hovered(bool status, QBoxSet *boxset) - \brief Signal is emitted when there is change in hover \a status over \a boxset. -*/ -/*! - \fn QBoxPlotSeries::countChanged() - \brief Signal is emitted when there is change in count of box-and-whiskers items in the series. -*/ -/*! - \property QBoxPlotSeries::boxOutlineVisible - \brief This property configures the visibility of the middle box outline. -*/ -/*! - \property QBoxPlotSeries::boxWidth - \brief This property configures the width of the box-and-whiskers item. The value signifies the relative - width of the box-and-whiskers item inside its own slot. The value can between 0.0 and 1.0. Negative values - are clamped to 0.0 and values over 1.0 are clamped to 1.0. -*/ -/*! - \property QBoxPlotSeries::pen - \brief This property configures the pen of the box-and-whiskers items. -*/ -/*! - \property QBoxPlotSeries::brush - \brief This property configures the brush of the box-and-whiskers items. -*/ -/*! - \property QBoxPlotSeries::count - \brief The count of sets in series. -*/ - -/*! - \qmlproperty QString BoxPlotSeries::brushFilename - The name of the file used as a brush for the series. -*/ - -/*! - \fn void QBoxPlotSeries::boxOutlineVisibilityChanged() - Signal is emitted when the middle box outline visibility is changed. -*/ -/*! - \fn void QBoxPlotSeries::boxWidthChanged() - Signal is emitted when the width of the box-and-whiskers item is changed. -*/ -/*! - \fn void QBoxPlotSeries::penChanged() - This signal is emitted when the pen of the box-and-whiskers has changed. - \sa brush -*/ -/*! - \fn void QBoxPlotSeries::brushChanged() - This signal is emitted when the brush of the box-and-whiskers has changed. - \sa brush -*/ -/*! - \fn virtual SeriesType QBoxPlotSeries::type() const - \brief Returns type of series. - \sa QAbstractSeries, SeriesType -*/ - -/*! - Constructs empty QBoxPlotSeries. - QBoxPlotSeries is QObject which is a child of a \a parent. -*/ -QBoxPlotSeries::QBoxPlotSeries(QObject *parent) - : QAbstractSeries(*new QBoxPlotSeriesPrivate(this), parent) -{ -} - -/*! - Destructor. Removes series from chart. -*/ -QBoxPlotSeries::~QBoxPlotSeries() -{ - Q_D(QBoxPlotSeries); - if (d->m_chart) - d->m_chart->removeSeries(this); -} - -/*! - Adds a single box and whiskers set to series. Takes ownership of the \a set. If the set is null or is already in series, it won't be appended. - Returns true, if appending succeeded. -*/ -bool QBoxPlotSeries::append(QBoxSet *set) -{ - Q_D(QBoxPlotSeries); - - bool success = d->append(set); - if (success) { - QList<QBoxSet *> sets; - sets.append(set); - set->setParent(this); - emit boxsetsAdded(sets); - emit countChanged(); - } - return success; -} - -/*! - Removes boxset from the series. Deletes the \a set and returns true if successful. -*/ -bool QBoxPlotSeries::remove(QBoxSet *set) -{ - Q_D(QBoxPlotSeries); - bool success = d->remove(set); - if (success) { - QList<QBoxSet *> sets; - sets.append(set); - set->setParent(0); - emit boxsetsRemoved(sets); - emit countChanged(); - delete set; - set = 0; - } - return success; -} - -/*! - Takes a single \a set from the series. Does not delete the boxset object. - - NOTE: The series remains as the boxset's parent object. You must set the - parent object to take full ownership. - - Returns true if take was successful. -*/ -bool QBoxPlotSeries::take(QBoxSet *set) -{ - Q_D(QBoxPlotSeries); - - bool success = d->remove(set); - if (success) { - QList<QBoxSet *> sets; - sets.append(set); - emit boxsetsRemoved(sets); - emit countChanged(); - } - return success; -} - -/*! - Adds a list of boxsets to series. Takes ownership of the \a sets. - Returns true, if all sets were appended successfully. If any of the sets is null or is already appended to series, - nothing is appended and function returns false. If any of the sets is in list more than once, nothing is appended - and function returns false. -*/ -bool QBoxPlotSeries::append(QList<QBoxSet *> sets) -{ - Q_D(QBoxPlotSeries); - bool success = d->append(sets); - if (success) { - emit boxsetsAdded(sets); - emit countChanged(); - } - return success; -} - -/*! - Insert a box-and-whiskers set to the series at \a index postion. Takes ownership of the \a set. If the set is null or - is already in series, it won't be appended. Returns true, if inserting succeeded. - -*/ -bool QBoxPlotSeries::insert(int index, QBoxSet *set) -{ - Q_D(QBoxPlotSeries); - bool success = d->insert(index, set); - if (success) { - QList<QBoxSet *> sets; - sets.append(set); - emit boxsetsAdded(sets); - emit countChanged(); - } - return success; -} - -/*! - Removes all boxsets from the series. Deletes removed sets. -*/ -void QBoxPlotSeries::clear() -{ - Q_D(QBoxPlotSeries); - QList<QBoxSet *> sets = boxSets(); - bool success = d->remove(sets); - if (success) { - emit boxsetsRemoved(sets); - emit countChanged(); - foreach (QBoxSet *set, sets) - delete set; - } -} - -/*! - Returns number of sets in series. -*/ -int QBoxPlotSeries::count() const -{ - Q_D(const QBoxPlotSeries); - return d->m_boxSets.count(); -} - -/*! - Returns a list of sets in series. Keeps ownership of sets. - */ -QList<QBoxSet *> QBoxPlotSeries::boxSets() const -{ - Q_D(const QBoxPlotSeries); - return d->m_boxSets; -} - -/* - Returns QAbstractSeries::SeriesTypeBoxPlot. -*/ -QAbstractSeries::SeriesType QBoxPlotSeries::type() const -{ - return QAbstractSeries::SeriesTypeBoxPlot; -} - -void QBoxPlotSeries::setBoxOutlineVisible(bool visible) -{ - Q_D(QBoxPlotSeries); - - if (d->m_boxOutlineVisible != visible) { - d->m_boxOutlineVisible = visible; - emit d->updated(); - emit boxOutlineVisibilityChanged(); - } -} - -bool QBoxPlotSeries::boxOutlineVisible() -{ - Q_D(QBoxPlotSeries); - - return d->m_boxOutlineVisible; -} - -void QBoxPlotSeries::setBoxWidth(qreal width) -{ - Q_D(QBoxPlotSeries); - - if (width != d->m_boxWidth) { - if (width < 0.0) - width = 0.0; - if (width > 1.0) - width = 1.0; - d->m_boxWidth = width; - emit d->updatedLayout(); - emit boxWidthChanged(); - } -} - -qreal QBoxPlotSeries::boxWidth() -{ - Q_D(QBoxPlotSeries); - - return d->m_boxWidth; -} - -void QBoxPlotSeries::setBrush(const QBrush &brush) -{ - Q_D(QBoxPlotSeries); - - if (d->m_brush != brush) { - d->m_brush = brush; - emit d->updated(); - emit brushChanged(); - } -} - -QBrush QBoxPlotSeries::brush() const -{ - Q_D(const QBoxPlotSeries); - - return d->m_brush; -} - -void QBoxPlotSeries::setPen(const QPen &pen) -{ - Q_D(QBoxPlotSeries); - - if (d->m_pen != pen) { - d->m_pen = pen; - emit d->updated(); - emit penChanged(); - } -} - -QPen QBoxPlotSeries::pen() const -{ - Q_D(const QBoxPlotSeries); - - return d->m_pen; -} - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -QBoxPlotSeriesPrivate::QBoxPlotSeriesPrivate(QBoxPlotSeries *q) - : QAbstractSeriesPrivate(q), - m_pen(QChartPrivate::defaultPen()), - m_brush(QChartPrivate::defaultBrush()), - m_boxOutlineVisible(true), - m_boxWidth(0.5) -{ -} - -QBoxPlotSeriesPrivate::~QBoxPlotSeriesPrivate() -{ - disconnect(this, 0, 0, 0); -} - -void QBoxPlotSeriesPrivate::initializeDomain() -{ - qreal minX(domain()->minX()); - qreal minY(domain()->minY()); - qreal maxX(domain()->maxX()); - qreal maxY(domain()->maxY()); - - qreal x = m_boxSets.count(); - minX = qMin(minX, qreal(-0.5)); - minY = qMin(minY, min()); - maxX = qMax(maxX, x - qreal(0.5)); - maxY = qMax(maxY, max()); - - domain()->setRange(minX, maxX, minY, maxY); -} - -void QBoxPlotSeriesPrivate::initializeAxes() -{ - foreach (QAbstractAxis* axis, m_axes) { - if (axis->type() == QAbstractAxis::AxisTypeBarCategory) { - if (axis->orientation() == Qt::Horizontal) - populateCategories(qobject_cast<QBarCategoryAxis *>(axis)); - } - } -} - -QAbstractAxis::AxisType QBoxPlotSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const -{ - if (orientation == Qt::Horizontal) - return QAbstractAxis::AxisTypeBarCategory; - - return QAbstractAxis::AxisTypeValue; -} - -QAbstractAxis* QBoxPlotSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const -{ - if (defaultAxisType(orientation) == QAbstractAxis::AxisTypeBarCategory) - return new QBarCategoryAxis; - else - return new QValueAxis; -} - -void QBoxPlotSeriesPrivate::populateCategories(QBarCategoryAxis *axis) -{ - QStringList categories; - if (axis->categories().isEmpty()) { - for (int i(1); i < m_boxSets.count() + 1; i++) { - QBoxSet *set = m_boxSets.at(i - 1); - if (set->label().isEmpty()) - categories << presenter()->numberToString(i); - else - categories << set->label(); - } - axis->append(categories); - } -} - -void QBoxPlotSeriesPrivate::initializeGraphics(QGraphicsItem *parent) -{ - Q_Q(QBoxPlotSeries); - - BoxPlotChartItem *boxPlot = new BoxPlotChartItem(q, parent); - m_item.reset(boxPlot); - QAbstractSeriesPrivate::initializeGraphics(parent); - - if (m_chart) { - connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), this, SLOT(handleSeriesChange(QAbstractSeries*)) ); - connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), this, SLOT(handleSeriesRemove(QAbstractSeries*)) ); - - QList<QAbstractSeries *> serieses = m_chart->series(); - - // Tries to find this series from the Chart's list of series and deduce the index - int index = 0; - foreach (QAbstractSeries *s, serieses) { - if (s->type() == QAbstractSeries::SeriesTypeBoxPlot) { - if (q == static_cast<QBoxPlotSeries *>(s)) { - boxPlot->m_seriesIndex = index; - m_index = index; - } - index++; - } - } - boxPlot->m_seriesCount = index; - } - - // Make BoxPlotChartItem to instantiate box & whisker items - boxPlot->handleDataStructureChanged(); -} - -void QBoxPlotSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forced) -{ - Q_Q(QBoxPlotSeries); - - const QList<QGradient> gradients = theme->seriesGradients(); - - if (forced || QChartPrivate::defaultBrush() == m_brush) { - QColor brushColor = ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0.5); - q->setBrush(brushColor); - } - - if (forced || QChartPrivate::defaultPen() == m_pen) { - QPen pen = theme->outlinePen(); - pen.setCosmetic(true); - q->setPen(pen); - } -} - -void QBoxPlotSeriesPrivate::initializeAnimations(QChart::AnimationOptions options) -{ - BoxPlotChartItem *item = static_cast<BoxPlotChartItem *>(m_item.data()); - Q_ASSERT(item); - if (item->animation()) - item->animation()->stopAndDestroyLater(); - - if (options.testFlag(QChart::SeriesAnimations)) - m_animation = new BoxPlotAnimation(item); - else - m_animation = 0; - item->setAnimation(m_animation); - - QAbstractSeriesPrivate::initializeAnimations(options); -} - -QList<QLegendMarker*> QBoxPlotSeriesPrivate::createLegendMarkers(QLegend *legend) -{ - Q_Q(QBoxPlotSeries); - QList<QLegendMarker *> list; - return list << new QBoxPlotLegendMarker(q, legend); -} - -void QBoxPlotSeriesPrivate::handleSeriesRemove(QAbstractSeries *series) -{ - Q_Q(QBoxPlotSeries); - - QBoxPlotSeries *removedSeries = static_cast<QBoxPlotSeries *>(series); - - if (q == removedSeries && m_animation) { - m_animation->stopAll(); - QObject::disconnect(m_chart->d_ptr->m_dataset, 0, removedSeries->d_func(), 0); - } - - // Test if series removed is me, then don't do anything - if (q != removedSeries) { - BoxPlotChartItem *item = static_cast<BoxPlotChartItem *>(m_item.data()); - if (item) { - item->m_seriesCount = item->m_seriesCount - 1; - if (removedSeries->d_func()->m_index < m_index) { - m_index--; - item->m_seriesIndex = m_index; - } - - item->handleDataStructureChanged(); - } - } -} - -void QBoxPlotSeriesPrivate::handleSeriesChange(QAbstractSeries *series) -{ - Q_UNUSED(series); - - Q_Q(QBoxPlotSeries); - - BoxPlotChartItem *boxPlot = static_cast<BoxPlotChartItem *>(m_item.data()); - - if (m_chart) { - QList<QAbstractSeries *> serieses = m_chart->series(); - - // Tries to find this series from the Chart's list of series and deduce the index - int index = 0; - foreach (QAbstractSeries *s, serieses) { - if (s->type() == QAbstractSeries::SeriesTypeBoxPlot) { - if (q == static_cast<QBoxPlotSeries *>(s)) { - boxPlot->m_seriesIndex = index; - m_index = index; - } - index++; - } - } - boxPlot->m_seriesCount = index; - } - - boxPlot->handleDataStructureChanged(); -} - -bool QBoxPlotSeriesPrivate::append(QBoxSet *set) -{ - if (m_boxSets.contains(set) || (set == 0) || set->d_ptr->m_series) - return false; // Fail if set is already in list or set is null. - - m_boxSets.append(set); - QObject::connect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout())); - QObject::connect(set->d_ptr.data(), SIGNAL(updatedBox()), this, SIGNAL(updatedBoxes())); - QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBox()), this, SIGNAL(restructuredBoxes())); - set->d_ptr->m_series = this; - - emit restructuredBoxes(); // this notifies boxplotchartitem - return true; -} - -bool QBoxPlotSeriesPrivate::remove(QBoxSet *set) -{ - if (!m_boxSets.contains(set)) - return false; // Fail if set is not in list - - set->d_ptr->m_series = 0; - m_boxSets.removeOne(set); - QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout())); - QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBox()), this, SIGNAL(updatedBoxes())); - QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBox()), this, SIGNAL(restructuredBoxes())); - - emit restructuredBoxes(); // this notifies boxplotchartitem - return true; -} - -bool QBoxPlotSeriesPrivate::append(QList<QBoxSet *> sets) -{ - foreach (QBoxSet *set, sets) { - if ((set == 0) || m_boxSets.contains(set) || set->d_ptr->m_series) - return false; // Fail if any of the sets is null or is already appended. - if (sets.count(set) != 1) - return false; // Also fail if same set is more than once in given list. - } - - foreach (QBoxSet *set, sets) { - m_boxSets.append(set); - QObject::connect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout())); - QObject::connect(set->d_ptr.data(), SIGNAL(updatedBox()), this, SIGNAL(updatedBoxes())); - QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBox()), this, SIGNAL(restructuredBoxes())); - set->d_ptr->m_series = this; - } - - emit restructuredBoxes(); // this notifies boxplotchartitem - return true; -} - -bool QBoxPlotSeriesPrivate::remove(QList<QBoxSet *> sets) -{ - if (sets.count() == 0) - return false; - - foreach (QBoxSet *set, sets) { - if ((set == 0) || (!m_boxSets.contains(set))) - return false; // Fail if any of the sets is null or is not in series - if (sets.count(set) != 1) - return false; // Also fail if same set is more than once in given list. - } - - foreach (QBoxSet *set, sets) { - set->d_ptr->m_series = 0; - m_boxSets.removeOne(set); - QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout())); - QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBox()), this, SIGNAL(updatedBoxes())); - QObject::disconnect(set->d_ptr.data(), SIGNAL(restructuredBox()), this, SIGNAL(restructuredBoxes())); - } - - emit restructuredBoxes(); // this notifies boxplotchartitem - - return true; -} - -bool QBoxPlotSeriesPrivate::insert(int index, QBoxSet *set) -{ - if ((m_boxSets.contains(set)) || (set == 0) || set->d_ptr->m_series) - return false; // Fail if set is already in list or set is null. - - m_boxSets.insert(index, set); - set->d_ptr->m_series = this; - QObject::connect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout())); - QObject::connect(set->d_ptr.data(), SIGNAL(updatedBox()), this, SIGNAL(updatedBoxes())); - QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBox()), this, SIGNAL(restructuredBoxes())); - - emit restructuredBoxes(); // this notifies boxplotchartitem - return true; -} - -QBoxSet *QBoxPlotSeriesPrivate::boxSetAt(int index) -{ - return m_boxSets.at(index); -} - -qreal QBoxPlotSeriesPrivate::min() -{ - if (m_boxSets.count() <= 0) - return 0; - - qreal min = m_boxSets.at(0)->at(0); - - foreach (QBoxSet *set, m_boxSets) { - for (int i = 0; i < 5; i++) { - if (set->at(i) < min) - min = set->at(i); - } - } - - return min; -} - -qreal QBoxPlotSeriesPrivate::max() -{ - if (m_boxSets.count() <= 0) - return 0; - - qreal max = m_boxSets.at(0)->at(0); - - foreach (QBoxSet *set, m_boxSets) { - for (int i = 0; i < 5; i++) { - if (set->at(i) > max) - max = set->at(i); - } - } - - return max; -} - -#include "moc_qboxplotseries.cpp" -#include "moc_qboxplotseries_p.cpp" - -QTCOMMERCIALCHART_END_NAMESPACE - diff --git a/src/boxplotchart/qboxplotseries.h b/src/boxplotchart/qboxplotseries.h deleted file mode 100644 index f1b819a3..00000000 --- a/src/boxplotchart/qboxplotseries.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QBOXPLOTSERIES_H -#define QBOXPLOTSERIES_H - -#include <qchartglobal.h> -#include <qboxset.h> -#include <qabstractseries.h> - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -class QBoxPlotSeriesPrivate; - -class QTCOMMERCIALCHART_EXPORT QBoxPlotSeries : public QAbstractSeries -{ - Q_OBJECT - Q_PROPERTY(bool boxOutlineVisible READ boxOutlineVisible WRITE setBoxOutlineVisible NOTIFY boxOutlineVisibilityChanged) - Q_PROPERTY(qreal boxWidth READ boxWidth WRITE setBoxWidth NOTIFY boxWidthChanged) - Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) - Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) - Q_PROPERTY(int count READ count NOTIFY countChanged REVISION 1) -public: - explicit QBoxPlotSeries(QObject *parent = 0); - ~QBoxPlotSeries(); - - bool append(QBoxSet *box); - bool remove(QBoxSet *box); - bool take(QBoxSet *box); - bool append(QList<QBoxSet *> boxes); - bool insert(int index, QBoxSet *box); - int count() const; - QList<QBoxSet *> boxSets() const; - void clear(); - - QAbstractSeries::SeriesType type() const; - - void setBoxOutlineVisible(bool visible); - bool boxOutlineVisible(); - void setBoxWidth(qreal width); - qreal boxWidth(); - void setBrush(const QBrush &brush); - QBrush brush() const; - void setPen(const QPen &pen); - QPen pen() const; - -Q_SIGNALS: - void clicked(QBoxSet *boxset); - void hovered(bool status, QBoxSet *boxset); - void countChanged(); - void penChanged(); - void brushChanged(); - void boxOutlineVisibilityChanged(); - void boxWidthChanged(); - - void boxsetsAdded(QList<QBoxSet *> sets); - void boxsetsRemoved(QList<QBoxSet *> sets); - -private: - Q_DECLARE_PRIVATE(QBoxPlotSeries) - Q_DISABLE_COPY(QBoxPlotSeries) - friend class BoxPlotChartItem; - friend class QBoxPlotLegendMarkerPrivate; -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif // QBOXPLOTSERIES_H diff --git a/src/boxplotchart/qboxplotseries_p.h b/src/boxplotchart/qboxplotseries_p.h deleted file mode 100644 index 4c87b0d8..00000000 --- a/src/boxplotchart/qboxplotseries_p.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// W A R N I N G -// ------------- -// -// This file is not part of the Qt Enterprise Chart API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. - -#ifndef QBOXPLOTSERIES_P_H -#define QBOXPLOTSERIES_P_H - -#include "qboxplotseries.h" -#include "qabstractbarseries_p.h" -#include "abstractdomain_p.h" -#include "qbarset.h" - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -class BoxPlotAnimation; - -class QBoxPlotSeriesPrivate : public QAbstractSeriesPrivate -{ - Q_OBJECT - -public: - QBoxPlotSeriesPrivate(QBoxPlotSeries *q); - ~QBoxPlotSeriesPrivate(); - - void initializeGraphics(QGraphicsItem *parent); - void initializeDomain(); - void initializeAxes(); - void initializeAnimations(QChart::AnimationOptions options); - void initializeTheme(int index, ChartTheme *theme, bool forced = false); - - QList<QLegendMarker*> createLegendMarkers(QLegend *legend); - - virtual QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const; - QAbstractAxis *createDefaultAxis(Qt::Orientation orientation) const; - - bool append(QBoxSet *set); - bool remove(QBoxSet *set); - bool append(QList<QBoxSet *> sets); - bool remove(QList<QBoxSet *> sets); - bool insert(int index, QBoxSet *set); - QBoxSet *boxSetAt(int index); - - qreal max(); - qreal min(); - -private: - void populateCategories(QBarCategoryAxis *axis); - -Q_SIGNALS: - void updated(); - void clicked(int index, QBoxSet *barset); - void updatedBoxes(); - void updatedLayout(); - void restructuredBoxes(); - -private slots: - void handleSeriesChange(QAbstractSeries *series); - void handleSeriesRemove(QAbstractSeries *series); - -protected: - QList<QBoxSet *> m_boxSets; - QPen m_pen; - QBrush m_brush; - bool m_boxOutlineVisible; - int m_index; - BoxPlotAnimation *m_animation; - qreal m_boxWidth; - -private: - Q_DECLARE_PUBLIC(QBoxPlotSeries) -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif diff --git a/src/boxplotchart/qboxset.cpp b/src/boxplotchart/qboxset.cpp deleted file mode 100644 index 5ccf0a44..00000000 --- a/src/boxplotchart/qboxset.cpp +++ /dev/null @@ -1,336 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qboxset.h" -#include "qboxset_p.h" -#include "charthelpers_p.h" - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -/*! - \class QBoxSet - \inmodule Qt Charts - \brief Building block for box-and-whiskers chart - - QBoxSet represents one box-and-whiskers item. It takes five values to create a graphical representation - of range and three medians. There are two ways to give the values. The first one is with constructor - or stream operator (<<). The values have to be given in the following order: lower extreme, - lower quartile, median, upper quartile and upper extreme. The Second method is to create an empty QBoxSet instance and - give the values using setValue method. - - \mainclass - - \sa QBoxPlotSeries -*/ -/*! - \enum QBoxSet::ValuePositions - - \value LowerExtreme - \value LowerQuartile - \value Median - \value UpperQuartile - \value UpperExtreme -*/ -/*! - \property QBoxSet::pen - \brief Defines the pen used by the box-and-whiskers set. -*/ -/*! - \property QBoxSet::brush - \brief Defines the brush used by the box-and-whiskers set. -*/ - -/*! - \qmlproperty QString BoxSet::brushFilename - The name of the file used as a brush for the box-and-whiskers set. -*/ - -/*! - \fn void QBoxSet::clicked() - The signal is emitted if the user clicks with a mouse on top of box-and-whisker item. -*/ -/*! - \fn void QBoxSet::hovered(bool status) - - The signal is emitted if mouse is hovered on top of box-and-whisker item. - Parameter \a status is true, if mouse entered on top of item, false if mouse left from top of item. -*/ -/*! - \fn void QBoxSet::penChanged() - This signal is emitted when the pen of the box-and-whisker item has changed. - \sa pen -*/ -/*! - \fn void QBoxSet::brushChanged() - This signal is emitted when the brush of the box-and-whisker item has changed. - \sa brush -*/ -/*! - \fn void QBoxSet::valuesChanged() - This signal is emitted when multiple values have been changed on the box-and-whisker item. - \sa append() -*/ -/*! - \fn void QBoxSet::valueChanged(int index) - This signal is emitted values the value in the box-and-whisker item has been modified. - Parameter \a index indicates the position of the modified value. - \sa at() -*/ -/*! - \fn void QBoxSet::cleared() - This signal is emitted when all the values on the set are cleared to 0. -*/ - -/*! - Constructs QBoxSet with optional \a label and parent of \a parent -*/ -QBoxSet::QBoxSet(const QString label, QObject *parent) - : QObject(parent), - d_ptr(new QBoxSetPrivate(label, this)) -{ -} - -/*! - Constructs QBoxSet with given ordered values. \a le for lower extreme, \a lq for lower quartile, \a m for median, - \a uq for upper quartile and \a ue for upper quartile. \a label and \a parent are optional. - */ -QBoxSet::QBoxSet(const qreal le, const qreal lq, const qreal m, const qreal uq, const qreal ue, const QString label, QObject *parent) - : QObject(parent), - d_ptr(new QBoxSetPrivate(label, this)) -{ - d_ptr->append(le); - d_ptr->append(lq); - d_ptr->append(m); - d_ptr->append(uq); - d_ptr->append(ue); -} - -/*! - Destroys the boxset -*/ -QBoxSet::~QBoxSet() -{ -} - -/*! - Appends new value \a value to the end of set. -*/ -void QBoxSet::append(const qreal value) -{ - if (d_ptr->append(value)) - emit valueChanged(d_ptr->m_appendCount - 1); -} - -/*! - Appends a list of reals to set. Works like append with single real value. The \a values in list - are appended to end of boxset. - \sa append() -*/ -void QBoxSet::append(const QList<qreal> &values) -{ - if (d_ptr->append(values)) - emit valuesChanged(); -} - -/*! - Sets new \a label for set. -*/ -void QBoxSet::setLabel(const QString label) -{ - d_ptr->m_label = label; -} - -/*! - Returns label of the set. -*/ -QString QBoxSet::label() const -{ - return d_ptr->m_label; -} - -/*! - Convenience operator. Same as append, with real \a value. - \sa append() -*/ -QBoxSet &QBoxSet::operator << (const qreal &value) -{ - append(value); - return *this; -} - -/*! - Sets a new \a value on the \a index position. For \a index ValuePositions can be used. -*/ -void QBoxSet::setValue(const int index, const qreal value) -{ - d_ptr->setValue(index, value); - emit valueChanged(index); -} - -/*! - Sets all values on the set to 0. - */ -void QBoxSet::clear() -{ - d_ptr->clear(); - emit cleared(); -} - -/*! - Returns value of set indexed by \a index. For \a index ValuePositions can be used. - If the index is out of bounds 0.0 is returned. -*/ -qreal QBoxSet::at(const int index) const -{ - if (index < 0 || index >= 5) - return 0; - return d_ptr->m_values[index]; -} - -/*! - Returns value of set indexed by \a index. For \a index ValuePositions can be used. - If the index is out of bounds 0.0 is returned. -*/ -qreal QBoxSet::operator [](const int index) const -{ - return at(index); -} - -/*! - Returns count of values appended to the set. -*/ -int QBoxSet::count() const -{ - return d_ptr->m_appendCount; -} - -/*! - Sets pen for set. Boxes of this set are drawn using \a pen -*/ -void QBoxSet::setPen(const QPen &pen) -{ - if (d_ptr->m_pen != pen) { - d_ptr->m_pen = pen; - emit d_ptr->updatedBox(); - emit penChanged(); - } -} - -/*! - Returns pen of the set. -*/ -QPen QBoxSet::pen() const -{ - return d_ptr->m_pen; -} - -/*! - Sets brush for the set. Boxes of this set are drawn using \a brush -*/ -void QBoxSet::setBrush(const QBrush &brush) -{ - if (d_ptr->m_brush != brush) { - d_ptr->m_brush = brush; - emit d_ptr->updatedBox(); - emit brushChanged(); - } -} - -/*! - Returns brush of the set. -*/ -QBrush QBoxSet::brush() const -{ - return d_ptr->m_brush; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -QBoxSetPrivate::QBoxSetPrivate(const QString label, QBoxSet *parent) : QObject(parent), - q_ptr(parent), - m_label(label), - m_valuesCount(5), - m_appendCount(0), - m_pen(QPen(Qt::NoPen)), - m_brush(QBrush(Qt::NoBrush)), - m_series(0) -{ - m_values = new qreal[m_valuesCount]; -} - -QBoxSetPrivate::~QBoxSetPrivate() -{ -} - -bool QBoxSetPrivate::append(qreal value) -{ - if (isValidValue(value) && m_appendCount < m_valuesCount) { - m_values[m_appendCount++] = value; - emit restructuredBox(); - - return true; - } - return false; -} - -bool QBoxSetPrivate::append(QList<qreal> values) -{ - bool success = false; - - for (int i = 0; i < values.count(); i++) { - if (isValidValue(values.at(i)) && m_appendCount < m_valuesCount) { - success = true; - m_values[m_appendCount++] = values.at(i); - } - } - - if (success) - emit restructuredBox(); - - return success; -} - -void QBoxSetPrivate::clear() -{ - m_appendCount = 0; - for (int i = 0; i < m_valuesCount; i++) - m_values[i] = 0.0; - emit restructuredBox(); -} - -void QBoxSetPrivate::setValue(const int index, const qreal value) -{ - if (index < m_valuesCount) { - m_values[index] = value; - emit updatedLayout(); - } -} - -qreal QBoxSetPrivate::value(const int index) -{ - if (index < 0 || index >= m_valuesCount) - return 0; - return m_values[index]; -} - -#include "moc_qboxset.cpp" -#include "moc_qboxset_p.cpp" - -QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/boxplotchart/qboxset.h b/src/boxplotchart/qboxset.h deleted file mode 100644 index f54cbe61..00000000 --- a/src/boxplotchart/qboxset.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QBOXSET_H -#define QBOXSET_H - -#include <qchartglobal.h> -#include <QPen> -#include <QBrush> -#include <QFont> - -QTCOMMERCIALCHART_BEGIN_NAMESPACE -class QBoxSetPrivate; - -class QTCOMMERCIALCHART_EXPORT QBoxSet : public QObject -{ - Q_OBJECT - Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) - Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) - -public: - enum ValuePositions { - LowerExtreme, - LowerQuartile, - Median, - UpperQuartile, - UpperExtreme - }; - -public: - explicit QBoxSet(const QString label = QString(), QObject *parent = 0); - explicit QBoxSet(const qreal le, const qreal lq, const qreal m, const qreal uq, const qreal ue, const QString label = QString(), QObject *parent = 0); - virtual ~QBoxSet(); - - void append(const qreal value); - void append(const QList<qreal> &values); - - void clear(); - - void setLabel(const QString label); - QString label() const; - - QBoxSet &operator << (const qreal &value); - - void setValue(const int index, const qreal value); - qreal at(const int index) const; - qreal operator [](const int index) const; - int count() const; - - void setPen(const QPen &pen); - QPen pen() const; - - void setBrush(const QBrush &brush); - QBrush brush() const; - -Q_SIGNALS: - void clicked(); - void hovered(bool status); - void penChanged(); - void brushChanged(); - - void valuesChanged(); - void valueChanged(int index); - void cleared(); - -private: - QScopedPointer<QBoxSetPrivate> d_ptr; - Q_DISABLE_COPY(QBoxSet) - friend class BarLegendMarker; - friend class BarChartItem; - friend class BoxPlotChartItem; - friend class QBoxPlotSeriesPrivate; -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif // QBOXSET_H diff --git a/src/boxplotchart/qboxset_p.h b/src/boxplotchart/qboxset_p.h deleted file mode 100644 index e34d8e18..00000000 --- a/src/boxplotchart/qboxset_p.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// W A R N I N G -// ------------- -// -// This file is not part of the Qt Enterprise Chart API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. - -#ifndef QBOXSET_P_H -#define QBOXSET_P_H - -#include "qboxset.h" -#include <QMap> -#include <QPen> -#include <QBrush> -#include <QFont> - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -class QBoxPlotSeriesPrivate; - -class QBoxSetPrivate : public QObject -{ - Q_OBJECT - -public: - QBoxSetPrivate(const QString label, QBoxSet *parent); - ~QBoxSetPrivate(); - - bool append(qreal value); - bool append(QList<qreal> values); - - int remove(const int index, const int count); - void clear(); - - void setValue(const int index, const qreal value); - - qreal value(const int index); - -Q_SIGNALS: - void restructuredBox(); - void updatedBox(); - void updatedLayout(); - -private: - const QBoxSet *q_ptr; - QString m_label; - const int m_valuesCount; - qreal *m_values; - int m_appendCount; - QPen m_pen; - QBrush m_brush; - QBrush m_labelBrush; - QFont m_labelFont; - QBoxPlotSeriesPrivate *m_series; - - friend class QBoxSet; - friend class QBoxPlotSeriesPrivate; -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif // QBOXSET_P_H diff --git a/src/boxplotchart/qvboxplotmodelmapper.cpp b/src/boxplotchart/qvboxplotmodelmapper.cpp deleted file mode 100644 index fa870905..00000000 --- a/src/boxplotchart/qvboxplotmodelmapper.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qvboxplotmodelmapper.h" - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -/*! - \class QVBoxPlotModelMapper - \inmodule Qt Charts - \brief Vertical model mapper for bar series - \mainclass - - Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series. - Vertical model mapper is used to create a connection between QBoxPlotSeries and QAbstractItemModel derived model object. - Model mapper maintains equal size of all the QBoxSets. - \note used model has to support adding/removing rows/columns and modifying the data of the cells. -*/ -#ifdef QDOC_QT5 -/*! - \qmltype VBoxPlotModelMapper - \instantiates QVBoxPlotModelMapper - \inqmlmodule QtCommercial.Chart - - \include doc/src/vboxplotmodelmapper.qdocinc -*/ -#else -/*! - \qmlclass VBoxPlotModelMapper QVBoxPlotModelMapper - - \include ../doc/src/vboxplotmodelmapper.qdocinc -*/ -#endif - -/*! - \property QVBoxPlotModelMapper::series - \brief Defines the QBoxPlotSeries object that is used by the mapper. - - All the data in the series is discarded when it is set to the mapper. - When new series is specified the old series is disconnected (it preserves its data) -*/ -/*! - \qmlproperty AbstractBarSeries VBoxPlotModelMapper::series - Defines the AbstractBarSeries based object that is used by the mapper. All the data in the series is discarded when it is - set to the mapper. When new series is specified the old series is disconnected (it preserves its data). -*/ - -/*! - \property QVBoxPlotModelMapper::model - \brief Defines the model that is used by the mapper. -*/ -/*! - \qmlproperty SomeModel VBoxPlotModelMapper::model - The QAbstractItemModel based model that is used by the mapper. You need to implement the model - and expose it to QML. \note the model has to support adding/removing rows/columns and modifying - the data of the cells. -*/ - -/*! - \property QVBoxPlotModelMapper::firstBoxSetColumn - \brief Defines which column of the model is used as the data source for the first box-and-whiskers set. - - Default value is: -1 (invalid mapping) -*/ -/*! - \qmlproperty int VBarModelMapper::firstBoxSetColumn - Defines which column of the model is used as the data source for the first box-and-whiskers set. Default value - is: -1 (invalid mapping). -*/ - -/*! - \property QVBoxPlotModelMapper::lastBoxSetColumn - \brief Defines which column of the model is used as the data source for the last box-and-whiskers set. - - Default value is: -1 (invalid mapping) -*/ -/*! - \qmlproperty int VBarModelMapper::lastBoxSetColumn - Defines which column of the model is used as the data source for the last box-and-whiskers set. Default - value is: -1 (invalid mapping). -*/ - -/*! - \property QVBoxPlotModelMapper::firstRow - \brief Defines which row of the model contains the first values of the QBoxSets in the series. - - Minimal and default value is: 0 -*/ -/*! - \qmlproperty int VBoxPlotModelMapper::firstRow - Defines which row of the model contains the first values of the QBoxSets in the series. - The default value is 0. -*/ - -/*! - \property QVBoxPlotModelMapper::rowCount - \brief Defines the number of rows of the model that are mapped as the data for QBoxPlotSeries - - Minimal and default value is: -1 (count limited by the number of rows in the model) -*/ -/*! - \qmlproperty int VBoxModelMapper::rowCount - Defines the number of rows of the model that are mapped as the data for QBoxPlotSeries. The default value is - -1 (count limited by the number of rows in the model) -*/ - -/*! - \fn void QVBoxPlotModelMapper::seriesReplaced() - - Emitted when the series to which mapper is connected to has changed. -*/ - -/*! - \fn void QVBoxPlotModelMapper::modelReplaced() - - Emitted when the model to which mapper is connected to has changed. -*/ - -/*! - \fn void QVBoxPlotModelMapper::firstBoxSetColumnChanged() - Emitted when the firstBoxSetColumn has changed. -*/ - -/*! - \fn void QVBoxPlotModelMapper::lastBoxSetColumnChanged() - Emitted when the lastBoxSetColumn has changed. -*/ - -/*! - \fn void QVBoxPlotModelMapper::firstRowChanged() - Emitted when the firstRow has changed. -*/ - -/*! - \fn void QVBoxPlotModelMapper::rowCountChanged() - Emitted when the rowCount has changed. -*/ - -/*! - Constructs a mapper object which is a child of \a parent. -*/ -QVBoxPlotModelMapper::QVBoxPlotModelMapper(QObject *parent) : - QBoxPlotModelMapper(parent) -{ - QBoxPlotModelMapper::setOrientation(Qt::Vertical); -} - -QAbstractItemModel *QVBoxPlotModelMapper::model() const -{ - return QBoxPlotModelMapper::model(); -} - -void QVBoxPlotModelMapper::setModel(QAbstractItemModel *model) -{ - if (model != QBoxPlotModelMapper::model()) { - QBoxPlotModelMapper::setModel(model); - emit modelReplaced(); - } -} - -QBoxPlotSeries *QVBoxPlotModelMapper::series() const -{ - return QBoxPlotModelMapper::series(); -} - -void QVBoxPlotModelMapper::setSeries(QBoxPlotSeries *series) -{ - if (series != QBoxPlotModelMapper::series()) { - QBoxPlotModelMapper::setSeries(series); - emit seriesReplaced(); - } -} - -int QVBoxPlotModelMapper::firstBoxSetColumn() const -{ - return QBoxPlotModelMapper::firstBoxSetSection(); -} - -void QVBoxPlotModelMapper::setFirstBoxSetColumn(int firstBoxSetColumn) -{ - if (firstBoxSetColumn != firstBoxSetSection()) { - QBoxPlotModelMapper::setFirstBoxSetSection(firstBoxSetColumn); - emit firstBoxSetColumnChanged(); - } -} - -int QVBoxPlotModelMapper::lastBoxSetColumn() const -{ - return QBoxPlotModelMapper::lastBoxSetSection(); -} - -void QVBoxPlotModelMapper::setLastBoxSetColumn(int lastBoxSetColumn) -{ - if (lastBoxSetColumn != lastBoxSetSection()) { - QBoxPlotModelMapper::setLastBoxSetSection(lastBoxSetColumn); - emit lastBoxSetColumnChanged(); - } -} - -int QVBoxPlotModelMapper::firstRow() const -{ - return QBoxPlotModelMapper::first(); -} - -void QVBoxPlotModelMapper::setFirstRow(int firstRow) -{ - if (firstRow != first()) { - QBoxPlotModelMapper::setFirst(firstRow); - emit firstRowChanged(); - } -} - -int QVBoxPlotModelMapper::rowCount() const -{ - return QBoxPlotModelMapper::count(); -} - -void QVBoxPlotModelMapper::setRowCount(int rowCount) -{ - if (rowCount != count()) { - QBoxPlotModelMapper::setCount(rowCount); - emit rowCountChanged(); - } -} - -#include "moc_qvboxplotmodelmapper.cpp" - -QTCOMMERCIALCHART_END_NAMESPACE - diff --git a/src/boxplotchart/qvboxplotmodelmapper.h b/src/boxplotchart/qvboxplotmodelmapper.h deleted file mode 100644 index 2bcb7f64..00000000 --- a/src/boxplotchart/qvboxplotmodelmapper.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QVBOXPLOTMODELMAPPER_H -#define QVBOXPLOTMODELMAPPER_H - -#include <QBoxPlotModelMapper> - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -class QTCOMMERCIALCHART_EXPORT QVBoxPlotModelMapper : public QBoxPlotModelMapper -{ - Q_OBJECT - Q_PROPERTY(QBoxPlotSeries *series READ series WRITE setSeries NOTIFY seriesReplaced) - Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced) - Q_PROPERTY(int firstBoxSetColumn READ firstBoxSetColumn WRITE setFirstBoxSetColumn NOTIFY firstBoxSetColumnChanged) - Q_PROPERTY(int lastBoxSetColumn READ lastBoxSetColumn WRITE setLastBoxSetColumn NOTIFY lastBoxSetColumnChanged) - Q_PROPERTY(int firstRow READ firstRow WRITE setFirstRow NOTIFY firstRowChanged) - Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged) - -public: - explicit QVBoxPlotModelMapper(QObject *parent = 0); - - QAbstractItemModel *model() const; - void setModel(QAbstractItemModel *model); - - QBoxPlotSeries *series() const; - void setSeries(QBoxPlotSeries *series); - - int firstBoxSetColumn() const; - void setFirstBoxSetColumn(int firstBoxSetColumn); - - int lastBoxSetColumn() const; - void setLastBoxSetColumn(int lastBoxSetColumn); - - int firstRow() const; - void setFirstRow(int firstRow); - - int rowCount() const; - void setRowCount(int rowCount); - -Q_SIGNALS: - void seriesReplaced(); - void modelReplaced(); - void firstBoxSetColumnChanged(); - void lastBoxSetColumnChanged(); - void firstRowChanged(); - void rowCountChanged(); -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif // QVBOXPLOTMODELMAPPER_H |