From c544258484ff4fd5d2b88402fbaa5d154b89a3a2 Mon Sep 17 00:00:00 2001 From: Titta Heikkala Date: Tue, 1 Jul 2014 07:10:00 +0300 Subject: Qt Charts project file structure change Charts repository structure is changed to follow the structure of a Qt Add-On module. The task includes following changes: - All macros and definitions named 'commercial' have been renamed. - Compile errors related to QString and qSort usage have been fixed. - Old demos are moved under examples. The QML examples now support only Qt Quick 2.0, the support for Qt Quick 1 is removed. - The QML examples with multiple views are updated so that they are usable also with touch devices. - Unnecessary version checks are removed from examples. - The build stamp has been removed as it was only meant for Charts development purposes and it's no longer needed. Also development build related debug prints are removed as __DATE__ can't be used for all OS thus it doesn't make much sense. - Documentation structure has been updated based on the new module structure. The raw HTML files have been removed. Demos are combined to examples. - Unnecessary .qdocinc files are no longer needed. The content is moved to the corresponding .cpp files. - The Charts widget designer plugin is updated according to the module change. - The test cases updated according to the project structure change. Tests are added also for version 2.0. - cmake modules generation is not needed with Qt 5.4 and Qt Charts so it's disabled. - The new module name and version are updated to the plugin.qmltypes file. Task-number: QTRD-2844, QTRD-3217, QTRD-3218, QTRD-3277, QTRD-3228, QTRD-2526, QTRD-3233, QTRD-3222 Change-Id: Ib7fb26057cde710ffaf6bc780c8bf52a16f45160 Reviewed-by: Miikka Heikkinen --- src/xychart/qhxymodelmapper.cpp | 246 ------------ src/xychart/qhxymodelmapper.h | 70 ---- src/xychart/qvxymodelmapper.cpp | 246 ------------ src/xychart/qvxymodelmapper.h | 70 ---- src/xychart/qxymodelmapper.cpp | 533 -------------------------- src/xychart/qxymodelmapper.h | 69 ---- src/xychart/qxymodelmapper_p.h | 97 ----- src/xychart/qxyseries.cpp | 804 ---------------------------------------- src/xychart/qxyseries.h | 120 ------ src/xychart/qxyseries_p.h | 79 ---- src/xychart/xychart.cpp | 189 ---------- src/xychart/xychart.pri | 21 -- src/xychart/xychart_p.h | 92 ----- 13 files changed, 2636 deletions(-) delete mode 100644 src/xychart/qhxymodelmapper.cpp delete mode 100644 src/xychart/qhxymodelmapper.h delete mode 100644 src/xychart/qvxymodelmapper.cpp delete mode 100644 src/xychart/qvxymodelmapper.h delete mode 100644 src/xychart/qxymodelmapper.cpp delete mode 100644 src/xychart/qxymodelmapper.h delete mode 100644 src/xychart/qxymodelmapper_p.h delete mode 100644 src/xychart/qxyseries.cpp delete mode 100644 src/xychart/qxyseries.h delete mode 100644 src/xychart/qxyseries_p.h delete mode 100644 src/xychart/xychart.cpp delete mode 100644 src/xychart/xychart.pri delete mode 100644 src/xychart/xychart_p.h (limited to 'src/xychart') diff --git a/src/xychart/qhxymodelmapper.cpp b/src/xychart/qhxymodelmapper.cpp deleted file mode 100644 index fbb6192b..00000000 --- a/src/xychart/qhxymodelmapper.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 "qhxymodelmapper.h" - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -/*! - \class QHXYModelMapper - \inmodule Qt Charts - \mainclass - - Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series. - Horizontal model mapper is used to create a connection between QXYSeries and QAbstractItemModel derived model object. - It is possible to use both QAbstractItemModel and QXYSeries model API. QXYModelMapper makes sure that QXYSeries and the model are kept in sync. - Note: used model has to support adding/removing rows/columns and modifying the data of the cells. -*/ -#ifdef QDOC_QT5 -/*! - \qmltype HXYModelMapper - \instantiates QHXYModelMapper - \inqmlmodule QtCommercial.Chart - - \include doc/src/hxymodelmapper.qdocinc -*/ -#else -/*! - \qmlclass HXYModelMapper QHXYModelMapper - - \include ../doc/src/hxymodelmapper.qdocinc -*/ -#endif - -/*! - \property QHXYModelMapper::series - \brief Defines the QXYSeries 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 XYSeries HXYModelMapper::series - Defines the XYSeries 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 QHXYModelMapper::model - \brief Defines the model that is used by the mapper. -*/ -/*! - \qmlproperty SomeModel HXYModelMapper::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 QHXYModelMapper::xRow - \brief Defines which row of the model is kept in sync with the x values of the QXYSeries. - - Default value is: -1 (invalid mapping) -*/ -/*! - \qmlproperty int HXYModelMapper::xRow - Defines which row of the model is kept in sync with the x values of the series. Default value is -1 (invalid - mapping). -*/ - -/*! - \property QHXYModelMapper::yRow - \brief Defines which row of the model is kept in sync with the y values of the QXYSeries. - - Default value is: -1 (invalid mapping) -*/ -/*! - \qmlproperty int HXYModelMapper::yRow - Defines which row of the model is kept in sync with the y values of the series. Default value is -1 - (invalid mapping). -*/ - -/*! - \property QHXYModelMapper::firstColumn - \brief Defines which column of the model contains the data for the first point of the series. - - Minimal and default value is: 0 -*/ -/*! - \qmlproperty int HXYModelMapper::firstColumn - Defines which column of the model contains the data for the first point of the series. - The default value is 0. -*/ - -/*! - \property QHXYModelMapper::columnCount - \brief Defines the number of columns of the model that are mapped as the data for series. - - Minimal and default value is: -1 (count limited by the number of columns in the model) -*/ -/*! - \qmlproperty int HXYModelMapper::columnCount - Defines the number of columns of the model that are mapped as the data for series. The default value is - -1 (count limited by the number of columns in the model) -*/ - -/*! - \fn void QHXYModelMapper::seriesReplaced() - - Emitted when the series to which mapper is connected to has changed. -*/ - -/*! - \fn void QHXYModelMapper::modelReplaced() - - Emitted when the model to which mapper is connected to has changed. -*/ - -/*! - \fn void QHXYModelMapper::xRowChanged() - - Emitted when the xRow has changed. -*/ - -/*! - \fn void QHXYModelMapper::yRowChanged() - - Emitted when the yRow has changed. -*/ - -/*! - \fn void QHXYModelMapper::firstColumnChanged() - Emitted when the firstColumn has changed. -*/ - -/*! - \fn void QHXYModelMapper::columnCountChanged() - Emitted when the columnCount has changed. -*/ - -/*! - Constructs a mapper object which is a child of \a parent. -*/ -QHXYModelMapper::QHXYModelMapper(QObject *parent) : - QXYModelMapper(parent) -{ - QXYModelMapper::setOrientation(Qt::Horizontal); -} - -QAbstractItemModel *QHXYModelMapper::model() const -{ - return QXYModelMapper::model(); -} - -void QHXYModelMapper::setModel(QAbstractItemModel *model) -{ - if (model != QXYModelMapper::model()) { - QXYModelMapper::setModel(model); - emit modelReplaced(); - } -} - -QXYSeries *QHXYModelMapper::series() const -{ - return QXYModelMapper::series(); -} - -void QHXYModelMapper::setSeries(QXYSeries *series) -{ - if (series != QXYModelMapper::series()) { - QXYModelMapper::setSeries(series); - emit seriesReplaced(); - } -} - -int QHXYModelMapper::xRow() const -{ - return QXYModelMapper::xSection(); -} - -void QHXYModelMapper::setXRow(int xRow) -{ - if (xRow != xSection()) { - QXYModelMapper::setXSection(xRow); - emit xRowChanged(); - } -} - -int QHXYModelMapper::yRow() const -{ - return QXYModelMapper::ySection(); -} - -void QHXYModelMapper::setYRow(int yRow) -{ - if (yRow != ySection()) { - QXYModelMapper::setYSection(yRow); - emit yRowChanged(); - } -} - -int QHXYModelMapper::firstColumn() const -{ - return first(); -} - -void QHXYModelMapper::setFirstColumn(int firstColumn) -{ - if (firstColumn != first()) { - setFirst(firstColumn); - emit firstColumnChanged(); - } -} - -int QHXYModelMapper::columnCount() const -{ - return count(); -} - -void QHXYModelMapper::setColumnCount(int columnCount) -{ - if (columnCount != count()) { - setCount(columnCount); - emit columnCountChanged(); - } -} - -#include "moc_qhxymodelmapper.cpp" - -QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/xychart/qhxymodelmapper.h b/src/xychart/qhxymodelmapper.h deleted file mode 100644 index 1fb25e9d..00000000 --- a/src/xychart/qhxymodelmapper.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 QHXYMODELMAPPER_H -#define QHXYMODELMAPPER_H - -#include - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -class QTCOMMERCIALCHART_EXPORT QHXYModelMapper : public QXYModelMapper -{ - Q_OBJECT - Q_PROPERTY(QXYSeries *series READ series WRITE setSeries NOTIFY seriesReplaced) - Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced) - Q_PROPERTY(int xRow READ xRow WRITE setXRow NOTIFY xRowChanged) - Q_PROPERTY(int yRow READ yRow WRITE setYRow NOTIFY yRowChanged) - Q_PROPERTY(int firstColumn READ firstColumn WRITE setFirstColumn NOTIFY firstColumnChanged) - Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount NOTIFY columnCountChanged) - -public: - explicit QHXYModelMapper(QObject *parent = 0); - - QAbstractItemModel *model() const; - void setModel(QAbstractItemModel *model); - - QXYSeries *series() const; - void setSeries(QXYSeries *series); - - int xRow() const; - void setXRow(int xRow); - - int yRow() const; - void setYRow(int yRow); - - int firstColumn() const; - void setFirstColumn(int firstColumn); - - int columnCount() const; - void setColumnCount(int columnCount); - -Q_SIGNALS: - void seriesReplaced(); - void modelReplaced(); - void xRowChanged(); - void yRowChanged(); - void firstColumnChanged(); - void columnCountChanged(); -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif // QHXYMODELMAPPER_H diff --git a/src/xychart/qvxymodelmapper.cpp b/src/xychart/qvxymodelmapper.cpp deleted file mode 100644 index 6446c112..00000000 --- a/src/xychart/qvxymodelmapper.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 "qvxymodelmapper.h" - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -/*! - \class QVXYModelMapper - \inmodule Qt Charts - \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 QXYSeries and QAbstractItemModel derived model object. - It is possible to use both QAbstractItemModel and QXYSeries model API. QXYModelMapper makes sure that QXYSeries and the model are kept in sync. - Note: used model has to support adding/removing rows/columns and modifying the data of the cells. -*/ -#ifdef QDOC_QT5 -/*! - \qmltype VXYModelMapper - \instantiates QVXYModelMapper - \inqmlmodule QtCommercial.Chart - - \include doc/src/vxymodelmapper.qdocinc -*/ -#else -/*! - \qmlclass VXYModelMapper QVXYModelMapper - - \include ../doc/src/vxymodelmapper.qdocinc -*/ -#endif - -/*! - \property QVXYModelMapper::series - \brief Defines the QXYSeries 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 XYSeries VXYModelMapper::series - Defines the XYSeries 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 QVXYModelMapper::model - \brief Defines the model that is used by the mapper. -*/ -/*! - \qmlproperty SomeModel VXYModelMapper::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 QVXYModelMapper::xColumn - \brief Defines which column of the model is kept in sync with the x values of QXYSeries. - - Default value is: -1 (invalid mapping) -*/ -/*! - \qmlproperty int VXYModelMapper::xColumn - Defines which column of the model is kept in sync with the x values of the series. Default value is -1 (invalid - mapping). -*/ - -/*! - \property QVXYModelMapper::yColumn - \brief Defines which column of the model is kept in sync with the y values of QXYSeries. - - Default value is: -1 (invalid mapping) -*/ -/*! - \qmlproperty int VXYModelMapper::yColumn - Defines which column of the model is kept in sync with the y values of the series. Default value is -1 (invalid - mapping). -*/ - -/*! - \property QVXYModelMapper::firstRow - \brief Defines which row of the model contains the data for the first point of the series. - - Minimal and default value is: 0 -*/ -/*! - \qmlproperty int VXYModelMapper::firstRow - Defines which row of the model contains the data for the first point of the series. - The default value is 0. -*/ - -/*! - \property QVXYModelMapper::rowCount - \brief Defines the number of rows of the model that are mapped as the data for series. - - Minimal and default value is: -1 (count limited by the number of rows in the model) -*/ -/*! - \qmlproperty int VXYModelMapper::columnCount - Defines the number of rows of the model that are mapped as the data for series. The default value is - -1 (count limited by the number of rows in the model). -*/ - -/*! - \fn void QVXYModelMapper::seriesReplaced() - - Emitted when the series to which mapper is connected to has changed. -*/ - -/*! - \fn void QVXYModelMapper::modelReplaced() - - Emitted when the model to which mapper is connected to has changed. -*/ - -/*! - \fn void QVXYModelMapper::xColumnChanged() - - Emitted when the xColumn has changed. -*/ - -/*! - \fn void QVXYModelMapper::yColumnChanged() - - Emitted when the yColumn has changed. -*/ - -/*! - \fn void QVXYModelMapper::firstRowChanged() - Emitted when the firstRow has changed. -*/ - -/*! - \fn void QVXYModelMapper::rowCountChanged() - Emitted when the rowCount has changed. -*/ - -/*! - Constructs a mapper object which is a child of \a parent. -*/ -QVXYModelMapper::QVXYModelMapper(QObject *parent) : - QXYModelMapper(parent) -{ - QXYModelMapper::setOrientation(Qt::Vertical); -} - -QAbstractItemModel *QVXYModelMapper::model() const -{ - return QXYModelMapper::model(); -} - -void QVXYModelMapper::setModel(QAbstractItemModel *model) -{ - if (model != QXYModelMapper::model()) { - QXYModelMapper::setModel(model); - emit modelReplaced(); - } -} - -QXYSeries *QVXYModelMapper::series() const -{ - return QXYModelMapper::series(); -} - -void QVXYModelMapper::setSeries(QXYSeries *series) -{ - if (series != QXYModelMapper::series()) { - QXYModelMapper::setSeries(series); - emit seriesReplaced(); - } -} - -int QVXYModelMapper::xColumn() const -{ - return QXYModelMapper::xSection(); -} - -void QVXYModelMapper::setXColumn(int xColumn) -{ - if (xColumn != xSection()) { - QXYModelMapper::setXSection(xColumn); - emit xColumnChanged(); - } -} - -int QVXYModelMapper::yColumn() const -{ - return QXYModelMapper::ySection(); -} - -void QVXYModelMapper::setYColumn(int yColumn) -{ - if (yColumn != ySection()) { - QXYModelMapper::setYSection(yColumn); - emit yColumnChanged(); - } -} - -int QVXYModelMapper::firstRow() const -{ - return first(); -} - -void QVXYModelMapper::setFirstRow(int firstRow) -{ - if (firstRow != first()) { - setFirst(firstRow); - emit firstRowChanged(); - } -} - -int QVXYModelMapper::rowCount() const -{ - return count(); -} - -void QVXYModelMapper::setRowCount(int rowCount) -{ - if (rowCount != count()) { - setCount(rowCount); - emit rowCountChanged(); - } -} - -#include "moc_qvxymodelmapper.cpp" - -QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/xychart/qvxymodelmapper.h b/src/xychart/qvxymodelmapper.h deleted file mode 100644 index be6b3b8f..00000000 --- a/src/xychart/qvxymodelmapper.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 QVXYMODELMAPPER_H -#define QVXYMODELMAPPER_H - -#include - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -class QTCOMMERCIALCHART_EXPORT QVXYModelMapper : public QXYModelMapper -{ - Q_OBJECT - Q_PROPERTY(QXYSeries *series READ series WRITE setSeries NOTIFY seriesReplaced) - Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced) - Q_PROPERTY(int xColumn READ xColumn WRITE setXColumn NOTIFY xColumnChanged) - Q_PROPERTY(int yColumn READ yColumn WRITE setYColumn NOTIFY yColumnChanged) - Q_PROPERTY(int firstRow READ firstRow WRITE setFirstRow NOTIFY firstRowChanged) - Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged) - -public: - explicit QVXYModelMapper(QObject *parent = 0); - - QAbstractItemModel *model() const; - void setModel(QAbstractItemModel *model); - - QXYSeries *series() const; - void setSeries(QXYSeries *series); - - int xColumn() const; - void setXColumn(int xColumn); - - int yColumn() const; - void setYColumn(int yColumn); - - int firstRow() const; - void setFirstRow(int firstRow); - - int rowCount() const; - void setRowCount(int rowCount); - -Q_SIGNALS: - void seriesReplaced(); - void modelReplaced(); - void xColumnChanged(); - void yColumnChanged(); - void firstRowChanged(); - void rowCountChanged(); -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif // QVXYMODELMAPPER_H diff --git a/src/xychart/qxymodelmapper.cpp b/src/xychart/qxymodelmapper.cpp deleted file mode 100644 index 44cc2370..00000000 --- a/src/xychart/qxymodelmapper.cpp +++ /dev/null @@ -1,533 +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 "qxymodelmapper.h" -#include "qxymodelmapper_p.h" -#include "qxyseries.h" -#include -#include - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -/*! - Constructs a mapper object which is a child of \a parent. -*/ -QXYModelMapper::QXYModelMapper(QObject *parent) - : QObject(parent), - d_ptr(new QXYModelMapperPrivate(this)) -{ -} - -/*! - \internal -*/ -QAbstractItemModel *QXYModelMapper::model() const -{ - Q_D(const QXYModelMapper); - return d->m_model; -} - -/*! - \internal -*/ -void QXYModelMapper::setModel(QAbstractItemModel *model) -{ - if (model == 0) - return; - - Q_D(QXYModelMapper); - if (d->m_model) - disconnect(d->m_model, 0, d, 0); - - d->m_model = model; - d->initializeXYFromModel(); - // connect signals from the model - connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); - 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())); -} - -/*! - \internal -*/ -QXYSeries *QXYModelMapper::series() const -{ - Q_D(const QXYModelMapper); - return d->m_series; -} - -/*! - \internal -*/ -void QXYModelMapper::setSeries(QXYSeries *series) -{ - Q_D(QXYModelMapper); - if (d->m_series) - disconnect(d->m_series, 0, d, 0); - - if (series == 0) - return; - - d->m_series = series; - d->initializeXYFromModel(); - // connect the signals from the series - connect(d->m_series, SIGNAL(pointAdded(int)), d, SLOT(handlePointAdded(int))); - connect(d->m_series, SIGNAL(pointRemoved(int)), d, SLOT(handlePointRemoved(int))); - connect(d->m_series, SIGNAL(pointReplaced(int)), d, SLOT(handlePointReplaced(int))); - connect(d->m_series, SIGNAL(destroyed()), d, SLOT(handleSeriesDestroyed())); -} - -/*! - \internal -*/ -int QXYModelMapper::first() const -{ - Q_D(const QXYModelMapper); - return d->m_first; -} - -/*! - \internal -*/ -void QXYModelMapper::setFirst(int first) -{ - Q_D(QXYModelMapper); - d->m_first = qMax(first, 0); - d->initializeXYFromModel(); -} - -/*! - \internal -*/ -int QXYModelMapper::count() const -{ - Q_D(const QXYModelMapper); - return d->m_count; -} - -/*! - \internal -*/ -void QXYModelMapper::setCount(int count) -{ - Q_D(QXYModelMapper); - d->m_count = qMax(count, -1); - d->initializeXYFromModel(); -} - -/*! - Returns the orientation that is used when QXYModelMapper accesses the model. - This mean whether the consecutive x/y values of the QXYSeries are read from rows (Qt::Horizontal) - or from columns (Qt::Vertical) -*/ -Qt::Orientation QXYModelMapper::orientation() const -{ - Q_D(const QXYModelMapper); - return d->m_orientation; -} - -/*! - Returns the \a orientation that is used when QXYModelMapper accesses the model. - This mean whether the consecutive x/y values of the QXYSeries are read from rows (Qt::Horizontal) - or from columns (Qt::Vertical) -*/ -void QXYModelMapper::setOrientation(Qt::Orientation orientation) -{ - Q_D(QXYModelMapper); - d->m_orientation = orientation; - d->initializeXYFromModel(); -} - -/*! - Returns which section of the model is kept in sync with the x values of the QXYSeries -*/ -int QXYModelMapper::xSection() const -{ - Q_D(const QXYModelMapper); - return d->m_xSection; -} - -/*! - Sets the model section that is kept in sync with the x values of the QXYSeries. - Parameter \a xSection specifies the section of the model. -*/ -void QXYModelMapper::setXSection(int xSection) -{ - Q_D(QXYModelMapper); - d->m_xSection = qMax(-1, xSection); - d->initializeXYFromModel(); -} - -/*! - Returns which section of the model is kept in sync with the y values of the QXYSeries -*/ -int QXYModelMapper::ySection() const -{ - Q_D(const QXYModelMapper); - return d->m_ySection; -} - -/*! - Sets the model section that is kept in sync with the y values of the QXYSeries. - Parameter \a ySection specifies the section of the model. -*/ -void QXYModelMapper::setYSection(int ySection) -{ - Q_D(QXYModelMapper); - d->m_ySection = qMax(-1, ySection); - d->initializeXYFromModel(); -} - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -QXYModelMapperPrivate::QXYModelMapperPrivate(QXYModelMapper *q) : - QObject(q), - m_series(0), - m_model(0), - m_first(0), - m_count(-1), - m_orientation(Qt::Vertical), - m_xSection(-1), - m_ySection(-1), - m_seriesSignalsBlock(false), - m_modelSignalsBlock(false), - q_ptr(q) -{ -} - -void QXYModelMapperPrivate::blockModelSignals(bool block) -{ - m_modelSignalsBlock = block; -} - -void QXYModelMapperPrivate::blockSeriesSignals(bool block) -{ - m_seriesSignalsBlock = block; -} - -QModelIndex QXYModelMapperPrivate::xModelIndex(int xPos) -{ - if (m_count != -1 && xPos >= m_count) - return QModelIndex(); // invalid - - if (m_orientation == Qt::Vertical) - return m_model->index(xPos + m_first, m_xSection); - else - return m_model->index(m_xSection, xPos + m_first); -} - -QModelIndex QXYModelMapperPrivate::yModelIndex(int yPos) -{ - if (m_count != -1 && yPos >= m_count) - return QModelIndex(); // invalid - - if (m_orientation == Qt::Vertical) - return m_model->index(yPos + m_first, m_ySection); - else - return m_model->index(m_ySection, yPos + m_first); -} - -qreal QXYModelMapperPrivate::valueFromModel(QModelIndex index) -{ - QVariant value = m_model->data(index, Qt::DisplayRole); - switch (value.type()) { - case QVariant::DateTime: - return value.toDateTime().toMSecsSinceEpoch(); - case QVariant::Date: - return QDateTime(value.toDate()).toMSecsSinceEpoch(); - default: - return value.toReal(); - } -} - -void QXYModelMapperPrivate::setValueToModel(QModelIndex index, qreal value) -{ - QVariant oldValue = m_model->data(index, Qt::DisplayRole); - switch (oldValue.type()) { - case QVariant::DateTime: - m_model->setData(index, QDateTime::fromMSecsSinceEpoch(value)); - break; - case QVariant::Date: - m_model->setData(index, QDateTime::fromMSecsSinceEpoch(value).date()); - break; - default: - m_model->setData(index, value); - } -} - -void QXYModelMapperPrivate::handlePointAdded(int pointPos) -{ - if (m_seriesSignalsBlock) - return; - - if (m_count != -1) - m_count += 1; - - blockModelSignals(); - if (m_orientation == Qt::Vertical) - m_model->insertRows(pointPos + m_first, 1); - else - m_model->insertColumns(pointPos + m_first, 1); - - setValueToModel(xModelIndex(pointPos), m_series->points().at(pointPos).x()); - setValueToModel(yModelIndex(pointPos), m_series->points().at(pointPos).y()); - blockModelSignals(false); -} - -void QXYModelMapperPrivate::handlePointRemoved(int pointPos) -{ - if (m_seriesSignalsBlock) - return; - - if (m_count != -1) - m_count -= 1; - - blockModelSignals(); - if (m_orientation == Qt::Vertical) - m_model->removeRow(pointPos + m_first); - else - m_model->removeColumn(pointPos + m_first); - blockModelSignals(false); -} - -void QXYModelMapperPrivate::handlePointReplaced(int pointPos) -{ - if (m_seriesSignalsBlock) - return; - - blockModelSignals(); - setValueToModel(xModelIndex(pointPos), m_series->points().at(pointPos).x()); - setValueToModel(yModelIndex(pointPos), m_series->points().at(pointPos).y()); - blockModelSignals(false); -} - -void QXYModelMapperPrivate::handleSeriesDestroyed() -{ - m_series = 0; -} - -void QXYModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) -{ - if (m_model == 0 || m_series == 0) - return; - - if (m_modelSignalsBlock) - return; - - blockSeriesSignals(); - QModelIndex index; - QPointF oldPoint; - QPointF newPoint; - for (int row = topLeft.row(); row <= bottomRight.row(); row++) { - for (int column = topLeft.column(); column <= bottomRight.column(); column++) { - index = topLeft.sibling(row, column); - if (m_orientation == Qt::Vertical && (index.column() == m_xSection || index.column() == m_ySection)) { - if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) { - QModelIndex xIndex = xModelIndex(index.row() - m_first); - QModelIndex yIndex = yModelIndex(index.row() - m_first); - if (xIndex.isValid() && yIndex.isValid()) { - oldPoint = m_series->points().at(index.row() - m_first); - newPoint.setX(valueFromModel(xIndex)); - newPoint.setY(valueFromModel(yIndex)); - } - } - } else if (m_orientation == Qt::Horizontal && (index.row() == m_xSection || index.row() == m_ySection)) { - if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) { - QModelIndex xIndex = xModelIndex(index.column() - m_first); - QModelIndex yIndex = yModelIndex(index.column() - m_first); - if (xIndex.isValid() && yIndex.isValid()) { - oldPoint = m_series->points().at(index.column() - m_first); - newPoint.setX(valueFromModel(xIndex)); - newPoint.setY(valueFromModel(yIndex)); - } - } - } else { - continue; - } - m_series->replace(oldPoint, newPoint); - } - } - blockSeriesSignals(false); -} - -void QXYModelMapperPrivate::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_xSection || start <= m_ySection) // if the changes affect the map - reinitialize the xy - initializeXYFromModel(); - blockSeriesSignals(false); -} - -void QXYModelMapperPrivate::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_xSection || start <= m_ySection) // if the changes affect the map - reinitialize the xy - initializeXYFromModel(); - blockSeriesSignals(false); -} - -void QXYModelMapperPrivate::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_xSection || start <= m_ySection) // if the changes affect the map - reinitialize the xy - initializeXYFromModel(); - blockSeriesSignals(false); -} - -void QXYModelMapperPrivate::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_xSection || start <= m_ySection) // if the changes affect the map - reinitialize the xy - initializeXYFromModel(); - blockSeriesSignals(false); -} - -void QXYModelMapperPrivate::handleModelDestroyed() -{ - m_model = 0; -} - -void QXYModelMapperPrivate::insertData(int start, int end) -{ - if (m_model == 0 || m_series == 0) - return; - - if (m_count != -1 && start >= m_first + m_count) { - return; - } else { - int addedCount = end - start + 1; - if (m_count != -1 && addedCount > m_count) - addedCount = m_count; - int first = qMax(start, m_first); - int last = qMin(first + addedCount - 1, m_orientation == Qt::Vertical ? m_model->rowCount() - 1 : m_model->columnCount() - 1); - for (int i = first; i <= last; i++) { - QPointF point; - QModelIndex xIndex = xModelIndex(i - m_first); - QModelIndex yIndex = yModelIndex(i - m_first); - if (xIndex.isValid() && yIndex.isValid()) { - point.setX(valueFromModel(xIndex)); - point.setY(valueFromModel(yIndex)); - m_series->insert(i - m_first, point); - } - } - - // remove excess of points (above m_count) - if (m_count != -1 && m_series->points().size() > m_count) - for (int i = m_series->points().size() - 1; i >= m_count; i--) { - m_series->remove(m_series->points().at(i)); - } - } -} - -void QXYModelMapperPrivate::removeData(int start, int end) -{ - if (m_model == 0 || m_series == 0) - return; - - int removedCount = end - start + 1; - if (m_count != -1 && start >= m_first + m_count) { - return; - } else { - int toRemove = qMin(m_series->count(), removedCount); // first find how many items can actually be removed - int first = qMax(start, m_first); // get the index of the first item that will be removed. - int last = qMin(first + toRemove - 1, m_series->count() + m_first - 1); // get the index of the last item that will be removed. - for (int i = last; i >= first; i--) { - m_series->remove(m_series->points().at(i - m_first)); - } - - if (m_count != -1) { - int itemsAvailable; // check how many are available to be added - if (m_orientation == Qt::Vertical) - itemsAvailable = m_model->rowCount() - m_first - m_series->count(); - else - itemsAvailable = m_model->columnCount() - m_first - m_series->count(); - int toBeAdded = qMin(itemsAvailable, m_count - m_series->count()); // add not more items than there is space left to be filled. - int currentSize = m_series->count(); - if (toBeAdded > 0) - for (int i = m_series->count(); i < currentSize + toBeAdded; i++) { - QPointF point; - QModelIndex xIndex = xModelIndex(i); - QModelIndex yIndex = yModelIndex(i); - if (xIndex.isValid() && yIndex.isValid()) { - point.setX(valueFromModel(xIndex)); - point.setY(valueFromModel(yIndex)); - m_series->insert(i, point); - } - } - } - } -} - -void QXYModelMapperPrivate::initializeXYFromModel() -{ - if (m_model == 0 || m_series == 0) - return; - - blockSeriesSignals(); - // clear current content - m_series->clear(); - - // create the initial points set - int pointPos = 0; - QModelIndex xIndex = xModelIndex(pointPos); - QModelIndex yIndex = yModelIndex(pointPos); - while (xIndex.isValid() && yIndex.isValid()) { - QPointF point; - point.setX(valueFromModel(xIndex)); - point.setY(valueFromModel(yIndex)); - m_series->append(point); - pointPos++; - xIndex = xModelIndex(pointPos); - yIndex = yModelIndex(pointPos); - } - blockSeriesSignals(false); -} - -#include "moc_qxymodelmapper.cpp" -#include "moc_qxymodelmapper_p.cpp" - -QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/xychart/qxymodelmapper.h b/src/xychart/qxymodelmapper.h deleted file mode 100644 index 3c98aa0c..00000000 --- a/src/xychart/qxymodelmapper.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 QXYMODELMAPPER_H -#define QXYMODELMAPPER_H - -#include "qchartglobal.h" -#include - -class QAbstractItemModel; - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -class QXYModelMapperPrivate; -class QXYSeries; - -class QTCOMMERCIALCHART_EXPORT QXYModelMapper : public QObject -{ - Q_OBJECT - -protected: - explicit QXYModelMapper(QObject *parent = 0); - - QAbstractItemModel *model() const; - void setModel(QAbstractItemModel *model); - - QXYSeries *series() const; - void setSeries(QXYSeries *series); - - int first() const; - void setFirst(int first); - - int count() const; - void setCount(int count); - - Qt::Orientation orientation() const; - void setOrientation(Qt::Orientation orientation); - - int xSection() const; - void setXSection(int xSection); - - int ySection() const; - void setYSection(int ySection); - -protected: - QXYModelMapperPrivate *const d_ptr; - Q_DECLARE_PRIVATE(QXYModelMapper) -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif // QXYMODELMAPPER_H diff --git a/src/xychart/qxymodelmapper_p.h b/src/xychart/qxymodelmapper_p.h deleted file mode 100644 index 363d848f..00000000 --- a/src/xychart/qxymodelmapper_p.h +++ /dev/null @@ -1,97 +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 QXYMODELMAPPER_P_H -#define QXYMODELMAPPER_P_H - -#include "qxymodelmapper.h" -#include - -class QModelIndex; -class QAbstractItemModel; -class QPointF; - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -class QXYModelMapper; -class QXYSeries; - -class QXYModelMapperPrivate : public QObject -{ - Q_OBJECT - -public: - QXYModelMapperPrivate(QXYModelMapper *q); - -public Q_SLOTS: - // for the model - void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); - 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 handlePointAdded(int pointPos); - void handlePointRemoved(int pointPos); - void handlePointReplaced(int pointPos); - void handleSeriesDestroyed(); - - void initializeXYFromModel(); - -private: - QModelIndex xModelIndex(int xPos); - QModelIndex yModelIndex(int yPos); - void insertData(int start, int end); - void removeData(int start, int end); - void blockModelSignals(bool block = true); - void blockSeriesSignals(bool block = true); - qreal valueFromModel(QModelIndex index); - void setValueToModel(QModelIndex index, qreal value); - -private: - QXYSeries *m_series; - QAbstractItemModel *m_model; - int m_first; - int m_count; - Qt::Orientation m_orientation; - int m_xSection; - int m_ySection; - bool m_seriesSignalsBlock; - bool m_modelSignalsBlock; - -private: - QXYModelMapper *q_ptr; - Q_DECLARE_PUBLIC(QXYModelMapper) -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif // QXYMODELMAPPER_P_H diff --git a/src/xychart/qxyseries.cpp b/src/xychart/qxyseries.cpp deleted file mode 100644 index b573d7a0..00000000 --- a/src/xychart/qxyseries.cpp +++ /dev/null @@ -1,804 +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 "qxyseries.h" -#include "qxyseries_p.h" -#include "abstractdomain_p.h" -#include "qvalueaxis.h" -#include "xychart_p.h" -#include "qxylegendmarker.h" -#include "charthelpers_p.h" -#include "qchart_p.h" -#include - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -/*! - \class QXYSeries - \inmodule Qt Charts - \brief The QXYSeries class is a base class for line, spline and scatter series. -*/ -#ifdef QDOC_QT5 -/*! - \qmltype XYSeries - \instantiates QXYSeries - \inqmlmodule QtCommercial.Chart - - \include doc/src/xyseries.qdocinc -*/ -#else -/*! - \qmlclass XYSeries QXYSeries - - \include ../doc/src/xyseries.qdocinc -*/ -#endif - -/*! - \qmlproperty AbstractAxis XYSeries::axisX - The x axis used for the series. If you leave both axisX and axisXTop undefined, a ValueAxis is created for - the series. - \sa axisXTop -*/ - -/*! - \qmlproperty AbstractAxis XYSeries::axisY - The y axis used for the series. If you leave both axisY and axisYRight undefined, a ValueAxis is created for - the series. - \sa axisYRight -*/ - -/*! - \qmlproperty AbstractAxis XYSeries::axisXTop - The x axis used for the series, drawn on top of the chart view. Note that you can only provide either axisX or - axisXTop, but not both. - \sa axisX -*/ - -/*! - \qmlproperty AbstractAxis XYSeries::axisYRight - The y axis used for the series, drawn to the right on the chart view. Note that you can only provide either axisY - or axisYRight, but not both. - \sa axisY -*/ - -/*! - \qmlproperty AbstractAxis XYSeries::axisAngular - The angular axis used for the series, drawn around the polar chart view. - \sa axisX -*/ - -/*! - \qmlproperty AbstractAxis XYSeries::axisRadial - The radial axis used for the series, drawn inside the polar chart view. - \sa axisY -*/ - -/*! - \property QXYSeries::pointsVisible - Controls if the data points are visible and should be drawn. -*/ -/*! - \qmlproperty bool XYSeries::pointsVisible - Controls if the data points are visible and should be drawn. -*/ - -/*! - \fn QPen QXYSeries::pen() const - \brief Returns pen used to draw points for series. - \sa setPen() -*/ - -/*! - \fn QBrush QXYSeries::brush() const - \brief Returns brush used to draw points for series. - \sa setBrush() -*/ - -/*! - \property QXYSeries::color - The color of the series. This is line (pen) color in case of QLineSeries or QSplineSeries and - fill (brush) color in case of QScatterSeries or QAreaSeries. - \sa QXYSeries::pen(), QXYSeries::brush() -*/ -/*! - \qmlproperty color XYSeries::color - The color of the series. This is line (pen) color in case of LineSeries or SplineSeries and - fill (brush) color in case of ScatterSeries or AreaSeries. -*/ - -/*! - \property QXYSeries::pointLabelsFormat - The \a format used for showing labels with series points. - - QXYSeries supports the following format tags: - \table - \row - \li @xPoint \li The x value of the data point - \row - \li @yPoint \li The y value of the data point - \endtable - - For example, the following usage of the format tags would produce labels that have the data - point (x, y) shown inside brackets separated by a comma: - \code - series->setPointLabelsFormat("(@xPoint, @yPoint)"); - \endcode - - By default, the labels format is set to '@xPoint, @yPoint'. The labels are shown on the plot - area, labels on the edge of the plot area are cut. If the points are close to each other the - labels may overlap. - - \sa QXYSeries::pointLabelsVisible, QXYSeries::pointLabelsFont, QXYSeries::pointLabelsColor -*/ -/*! - \qmlproperty string XYSeries::pointLabelsFormat - The \a format used for showing labels with series points. - - \sa QXYSeries::pointLabelsFormat, pointLabelsVisible, pointLabelsFont, pointLabelsColor -*/ -/*! - \fn void QXYSeries::pointLabelsFormatChanged(const QString &format) - Signal is emitted when the \a format of data point labels is changed. -*/ -/*! - \qmlsignal XYSeries::onPointLabelsFormatChanged(string format) - Signal is emitted when the \a format of data point labels is changed. -*/ - -/*! - \property QXYSeries::pointLabelsVisible - Defines the visibility for data point labels. False by default. - - \sa QXYSeries::pointLabelsFormat -*/ -/*! - \qmlproperty bool XYSeries::pointLabelsVisible - Defines the visibility for data point labels. - - \sa pointLabelsFormat -*/ -/*! - \fn void QXYSeries::pointLabelsVisibilityChanged(bool visible) - The visibility of the data point labels is changed to \a visible. -*/ -/*! - \qmlsignal XYSeries::onPointLabelsVisibilityChanged(bool visible) - The visibility of the data point labels is changed to \a visible. -*/ - -/*! - \property QXYSeries::pointLabelsFont - Defines the font used for data point labels. - - \sa QXYSeries::pointLabelsFormat -*/ -/*! - \qmlproperty font XYSeries::pointLabelsFont - Defines the font used for data point labels. - - \sa pointLabelsFormat -*/ -/*! - \fn void QXYSeries::pointLabelsFontChanged(const QFont &font); - The font used for data point labels is changed to \a font. -*/ -/*! - \qmlsignal XYSeries::onPointLabelsFontChanged(Font font) - The font used for data point labels is changed to \a font. -*/ - -/*! - \property QXYSeries::pointLabelsColor - Defines the color used for data point labels. By default, the color is the color of the brush - defined in theme for labels. - - \sa QXYSeries::pointLabelsFormat -*/ -/*! - \qmlproperty font XYSeries::pointLabelsColor - Defines the color used for data point labels. By default, the color is the color of the brush - defined in theme for labels. - - \sa pointLabelsFormat -*/ -/*! - \fn void QXYSeries::pointLabelsColorChanged(const QColor &color); - The color used for data point labels is changed to \a color. -*/ -/*! - \qmlsignal XYSeries::onPointLabelsColorChanged(Color color) - The color used for data point labels is changed to \a color. -*/ - -/*! - \fn void QXYSeries::clicked(const QPointF& point) - \brief Signal is emitted when user clicks the \a point on chart. -*/ -/*! - \qmlsignal XYSeries::onClicked(QPointF point) - Signal is emitted when user clicks the \a point on chart. For example: - \code - LineSeries { - XYPoint { x: 0; y: 0 } - XYPoint { x: 1.1; y: 2.1 } - onClicked: console.log("onClicked: " + point.x + ", " + point.y); - } - \endcode -*/ - -/*! - \fn void QXYSeries::hovered(const QPointF &point, bool state) - This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate) - of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from - the series. -*/ -/*! - \qmlsignal XYSeries::onHovered(point point, bool state) - This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate) - of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from - the series. -*/ - -/*! - \fn void QXYSeries::pointReplaced(int index) - Signal is emitted when a point has been replaced at \a index. - \sa replace() -*/ -/*! - \qmlsignal XYSeries::onPointReplaced(int index) - Signal is emitted when a point has been replaced at \a index. -*/ - -/*! - \fn void QXYSeries::pointsReplaced() - Signal is emitted when all points have been replaced with other points. - \sa replace() -*/ -/*! - \qmlsignal XYSeries::onPointsReplaced() -*/ - -/*! - \fn void QXYSeries::pointAdded(int index) - Signal is emitted when a point has been added at \a index. - \sa append(), insert() -*/ -/*! - \qmlsignal XYSeries::onPointAdded(int index) - Signal is emitted when a point has been added at \a index. -*/ - -/*! - \fn void QXYSeries::pointRemoved(int index) - Signal is emitted when a point has been removed from \a index. - \sa remove() -*/ -/*! - \qmlsignal XYSeries::onPointRemoved(int index) - Signal is emitted when a point has been removed from \a index. -*/ - -/*! - \fn void QXYSeries::colorChanged(QColor color) - \brief Signal is emitted when the line (pen) color has changed to \a color. -*/ -/*! - \qmlsignal XYSeries::onColorChanged(color color) - Signal is emitted when the line (pen) color has changed to \a color. -*/ - -/*! - \fn void QXYSeriesPrivate::updated() - \brief \internal -*/ - -/*! - \qmlmethod XYSeries::append(real x, real y) - Append point (\a x, \a y) to the series -*/ - -/*! - \qmlmethod XYSeries::replace(real oldX, real oldY, real newX, real newY) - Replaces point (\a oldX, \a oldY) with point (\a newX, \a newY). Does nothing, if point (oldX, oldY) does not - exist. -*/ - -/*! - \qmlmethod XYSeries::remove(real x, real y) - Removes point (\a x, \a y) from the series. Does nothing, if point (x, y) does not exist. -*/ - -/*! - \qmlmethod XYSeries::insert(int index, real x, real y) - Inserts point (\a x, \a y) to the \a index. If index is 0 or smaller than 0 the point is prepended to the list of - points. If index is the same as or bigger than count, the point is appended to the list of points. -*/ - -/*! - \qmlmethod QPointF XYSeries::at(int index) - Returns point at \a index. Returns (0, 0) if the index is not valid. -*/ - -/*! - \internal - - Constructs empty series object which is a child of \a parent. - When series object is added to QChart instance ownerships is transferred. -*/ -QXYSeries::QXYSeries(QXYSeriesPrivate &d, QObject *parent) - : QAbstractSeries(d, parent) -{ -} - -/*! - Destroys the object. Series added to QChart instances are owned by those, - and are destroyed when QChart instances are destroyed. -*/ -QXYSeries::~QXYSeries() -{ -} - -/*! - Adds data point (\a x, \a y) to the series. - */ -void QXYSeries::append(qreal x, qreal y) -{ - append(QPointF(x, y)); -} - -/*! - This is an overloaded function. - Adds data \a point to the series. - */ -void QXYSeries::append(const QPointF &point) -{ - Q_D(QXYSeries); - - if (isValidValue(point)) { - d->m_points << point; - emit pointAdded(d->m_points.count() - 1); - } -} - -/*! - This is an overloaded function. - Adds list of data \a points to the series. - */ -void QXYSeries::append(const QList &points) -{ - foreach (const QPointF &point , points) - append(point); -} - -/*! - Replaces data point (\a oldX, \a oldY) with data point (\a newX, \a newY). - \sa QXYSeries::pointReplaced() -*/ -void QXYSeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY) -{ - replace(QPointF(oldX, oldY), QPointF(newX, newY)); -} - -/*! - Replaces \a oldPoint with \a newPoint. - \sa QXYSeries::pointReplaced() -*/ -void QXYSeries::replace(const QPointF &oldPoint, const QPointF &newPoint) -{ - Q_D(QXYSeries); - int index = d->m_points.indexOf(oldPoint); - if (index == -1) - return; - replace(index, newPoint); -} - -/*! - Replaces the point at \a index with data point (\a newX, \a newY). - \sa QXYSeries::pointReplaced() -*/ -void QXYSeries::replace(int index, qreal newX, qreal newY) -{ - replace(index, QPointF(newX, newY)); -} - -/*! - Replaces the point at \a index with \a newPoint. - \sa QXYSeries::pointReplaced() -*/ -void QXYSeries::replace(int index, const QPointF &newPoint) -{ - Q_D(QXYSeries); - if (isValidValue(newPoint)) { - d->m_points[index] = newPoint; - emit pointReplaced(index); - } -} - -/*! - Replaces the current points with \a points. - \note This is much faster than replacing data points one by one, - or first clearing all data, and then appending the new data. Emits QXYSeries::pointsReplaced() - when the points have been replaced. - \sa QXYSeries::pointsReplaced() -*/ -void QXYSeries::replace(QList points) -{ - Q_D(QXYSeries); - d->m_points = points.toVector(); - emit pointsReplaced(); -} - -/*! - Removes the point (\a x, \a y) from the series. -*/ -void QXYSeries::remove(qreal x, qreal y) -{ - remove(QPointF(x, y)); -} - -/*! - Removes the \a point from the series. -*/ -void QXYSeries::remove(const QPointF &point) -{ - Q_D(QXYSeries); - int index = d->m_points.indexOf(point); - if (index == -1) - return; - remove(index); -} - -/*! - Removes the point at \a index from the series. -*/ -void QXYSeries::remove(int index) -{ - Q_D(QXYSeries); - d->m_points.remove(index); - emit pointRemoved(index); -} - -/*! - Inserts a \a point in the series at \a index position. -*/ -void QXYSeries::insert(int index, const QPointF &point) -{ - Q_D(QXYSeries); - if (isValidValue(point)) { - d->m_points.insert(index, point); - emit pointAdded(index); - } -} - -/*! - Removes all points from the series. -*/ -void QXYSeries::clear() -{ - Q_D(QXYSeries); - for (int i = d->m_points.size() - 1; i >= 0; i--) - remove(d->m_points.at(i)); -} - -/*! - Returns list of points in the series. -*/ -QList QXYSeries::points() const -{ - Q_D(const QXYSeries); - return d->m_points.toList(); -} - -/*! - Returns point at \a index in internal points vector. -*/ -const QPointF &QXYSeries::at(int index) const -{ - Q_D(const QXYSeries); - return d->m_points.at(index); -} - -/*! - Returns number of data points within series. -*/ -int QXYSeries::count() const -{ - Q_D(const QXYSeries); - return d->m_points.count(); -} - - -/*! - Sets \a pen used for drawing points on the chart. If the pen is not defined, the - pen from chart theme is used. - \sa QChart::setTheme() -*/ -void QXYSeries::setPen(const QPen &pen) -{ - Q_D(QXYSeries); - if (d->m_pen != pen) { - bool emitColorChanged = d->m_pen.color() != pen.color(); - d->m_pen = pen; - emit d->updated(); - if (emitColorChanged) - emit colorChanged(pen.color()); - } -} - -QPen QXYSeries::pen() const -{ - Q_D(const QXYSeries); - if (d->m_pen == QChartPrivate::defaultPen()) - return QPen(); - else - return d->m_pen; -} - -/*! - Sets \a brush used for drawing points on the chart. If the brush is not defined, brush - from chart theme setting is used. - \sa QChart::setTheme() -*/ -void QXYSeries::setBrush(const QBrush &brush) -{ - Q_D(QXYSeries); - if (d->m_brush != brush) { - d->m_brush = brush; - emit d->updated(); - } -} - -QBrush QXYSeries::brush() const -{ - Q_D(const QXYSeries); - if (d->m_brush == QChartPrivate::defaultBrush()) - return QBrush(); - else - return d->m_brush; -} - -void QXYSeries::setColor(const QColor &color) -{ - QPen p = pen(); - if (p.color() != color) { - p.setColor(color); - setPen(p); - } -} - -QColor QXYSeries::color() const -{ - return pen().color(); -} - -void QXYSeries::setPointsVisible(bool visible) -{ - Q_D(QXYSeries); - if (d->m_pointsVisible != visible) { - d->m_pointsVisible = visible; - emit d->updated(); - } -} - -bool QXYSeries::pointsVisible() const -{ - Q_D(const QXYSeries); - return d->m_pointsVisible; -} - -void QXYSeries::setPointLabelsFormat(const QString &format) -{ - Q_D(QXYSeries); - if (d->m_pointLabelsFormat != format) { - d->m_pointLabelsFormat = format; - emit pointLabelsFormatChanged(format); - } -} - -QString QXYSeries::pointLabelsFormat() const -{ - Q_D(const QXYSeries); - return d->m_pointLabelsFormat; -} - -void QXYSeries::setPointLabelsVisible(bool visible) -{ - Q_D(QXYSeries); - if (d->m_pointLabelsVisible != visible) { - d->m_pointLabelsVisible = visible; - emit pointLabelsVisibilityChanged(visible); - } -} - -bool QXYSeries::pointLabelsVisible() const -{ - Q_D(const QXYSeries); - return d->m_pointLabelsVisible; -} - -void QXYSeries::setPointLabelsFont(const QFont &font) -{ - Q_D(QXYSeries); - if (d->m_pointLabelsFont != font) { - d->m_pointLabelsFont = font; - emit pointLabelsFontChanged(font); - } -} - -QFont QXYSeries::pointLabelsFont() const -{ - Q_D(const QXYSeries); - return d->m_pointLabelsFont; -} - -void QXYSeries::setPointLabelsColor(const QColor &color) -{ - Q_D(QXYSeries); - if (d->m_pointLabelsColor != color) { - d->m_pointLabelsColor = color; - emit pointLabelsColorChanged(color); - } -} - -QColor QXYSeries::pointLabelsColor() const -{ - Q_D(const QXYSeries); - if (d->m_pointLabelsColor == QChartPrivate::defaultPen().color()) - return QPen().color(); - else - return d->m_pointLabelsColor; -} - -/*! - Stream operator for adding a data \a point to the series. - \sa append() -*/ -QXYSeries &QXYSeries::operator<< (const QPointF &point) -{ - append(point); - return *this; -} - - -/*! - Stream operator for adding a list of \a points to the series. - \sa append() -*/ - -QXYSeries &QXYSeries::operator<< (const QList& points) -{ - append(points); - return *this; -} - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) - : QAbstractSeriesPrivate(q), - m_pen(QChartPrivate::defaultPen()), - m_brush(QChartPrivate::defaultBrush()), - m_pointsVisible(false), - m_pointLabelsFormat(QLatin1String("@xPoint, @yPoint")), - m_pointLabelsVisible(false), - m_pointLabelsFont(QChartPrivate::defaultFont()), - m_pointLabelsColor(QChartPrivate::defaultPen().color()) -{ -} - -void QXYSeriesPrivate::initializeDomain() -{ - qreal minX(0); - qreal minY(0); - qreal maxX(1); - qreal maxY(1); - - Q_Q(QXYSeries); - - const QList& points = q->points(); - - if (!points.isEmpty()) { - minX = points[0].x(); - minY = points[0].y(); - maxX = minX; - maxY = minY; - - for (int i = 0; i < points.count(); i++) { - qreal x = points[i].x(); - qreal y = points[i].y(); - minX = qMin(minX, x); - minY = qMin(minY, y); - maxX = qMax(maxX, x); - maxY = qMax(maxY, y); - } - } - - domain()->setRange(minX, maxX, minY, maxY); -} - -QList QXYSeriesPrivate::createLegendMarkers(QLegend* legend) -{ - Q_Q(QXYSeries); - QList list; - return list << new QXYLegendMarker(q,legend); -} - -void QXYSeriesPrivate::initializeAxes() -{ - -} - -QAbstractAxis::AxisType QXYSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const -{ - Q_UNUSED(orientation); - return QAbstractAxis::AxisTypeValue; -} - -QAbstractAxis* QXYSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const -{ - Q_UNUSED(orientation); - return new QValueAxis; -} - -void QXYSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options) -{ - XYChart *item = static_cast(m_item.data()); - Q_ASSERT(item); - if (item->animation()) - item->animation()->stopAndDestroyLater(); - - if (options.testFlag(QChart::SeriesAnimations)) - item->setAnimation(new XYAnimation(item)); - else - item->setAnimation(0); - QAbstractSeriesPrivate::initializeAnimations(options); -} - -void QXYSeriesPrivate::drawSeriesPointLabels(QPainter *painter, const QVector &points, - const int offset) -{ - static const QString xPointTag(QLatin1String("@xPoint")); - static const QString yPointTag(QLatin1String("@yPoint")); - const int labelOffset = offset + 2; - - painter->setFont(m_pointLabelsFont); - painter->setPen(QPen(m_pointLabelsColor)); - QFontMetrics fm(painter->font()); - - for (int i(0); i < m_points.size(); i++) { - QString pointLabel = m_pointLabelsFormat; - pointLabel.replace(xPointTag, presenter()->numberToString(m_points.at(i).x())); - pointLabel.replace(yPointTag, presenter()->numberToString(m_points.at(i).y())); - - // Position text in relation to the point - int pointLabelWidth = fm.width(pointLabel); - QPointF position(points.at(i)); - position.setX(position.x() - pointLabelWidth / 2); - position.setY(position.y() - labelOffset); - - painter->drawText(position, pointLabel); - } -} - -#include "moc_qxyseries.cpp" -#include "moc_qxyseries_p.cpp" - -QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/xychart/qxyseries.h b/src/xychart/qxyseries.h deleted file mode 100644 index 02c08eb0..00000000 --- a/src/xychart/qxyseries.h +++ /dev/null @@ -1,120 +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 QXYSERIES_H -#define QXYSERIES_H - -#include -#include -#include -#include - -class QModelIndex; - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -class QXYSeriesPrivate; -class QXYModelMapper; - -class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries -{ - Q_OBJECT - Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible) - Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) - Q_PROPERTY(QString pointLabelsFormat READ pointLabelsFormat WRITE setPointLabelsFormat NOTIFY pointLabelsFormatChanged) - Q_PROPERTY(bool pointLabelsVisible READ pointLabelsVisible WRITE setPointLabelsVisible NOTIFY pointLabelsVisibilityChanged) - Q_PROPERTY(QFont pointLabelsFont READ pointLabelsFont WRITE setPointLabelsFont NOTIFY pointLabelsFontChanged) - Q_PROPERTY(QColor pointLabelsColor READ pointLabelsColor WRITE setPointLabelsColor NOTIFY pointLabelsColorChanged) - -protected: - explicit QXYSeries(QXYSeriesPrivate &d, QObject *parent = 0); - -public: - ~QXYSeries(); - void append(qreal x, qreal y); - void append(const QPointF &point); - void append(const QList &points); - void replace(qreal oldX, qreal oldY, qreal newX, qreal newY); - void replace(const QPointF &oldPoint, const QPointF &newPoint); - void replace(int index, qreal newX, qreal newY); - void replace(int index, const QPointF &newPoint); - void remove(qreal x, qreal y); - void remove(const QPointF &point); - void remove(int index); - void insert(int index, const QPointF &point); - void clear(); - - int count() const; - QList points() const; - const QPointF &at(int index) const; - - QXYSeries &operator << (const QPointF &point); - QXYSeries &operator << (const QList &points); - - virtual void setPen(const QPen &pen); - QPen pen() const; - - virtual void setBrush(const QBrush &brush); - QBrush brush() const; - - virtual void setColor(const QColor &color); - virtual QColor color() const; - - void setPointsVisible(bool visible = true); - bool pointsVisible() const; - - void setPointLabelsFormat(const QString &format); - QString pointLabelsFormat() const; - - void setPointLabelsVisible(bool visible = true); - bool pointLabelsVisible() const; - - void setPointLabelsFont(const QFont &font); - QFont pointLabelsFont() const; - - void setPointLabelsColor(const QColor &color); - QColor pointLabelsColor() const; - - void replace(QList points); - -Q_SIGNALS: - void clicked(const QPointF &point); - void hovered(const QPointF &point, bool state); - void pointReplaced(int index); - void pointRemoved(int index); - void pointAdded(int index); - void colorChanged(QColor color); - void pointsReplaced(); - void pointLabelsFormatChanged(const QString &format); - void pointLabelsVisibilityChanged(bool visible); - void pointLabelsFontChanged(const QFont &font); - void pointLabelsColorChanged(const QColor &color); - -private: - Q_DECLARE_PRIVATE(QXYSeries) - Q_DISABLE_COPY(QXYSeries) - friend class QXYLegendMarkerPrivate; - friend class XYLegendMarker; - friend class XYChart; -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif // QXYSERIES_H diff --git a/src/xychart/qxyseries_p.h b/src/xychart/qxyseries_p.h deleted file mode 100644 index 996f0f0d..00000000 --- a/src/xychart/qxyseries_p.h +++ /dev/null @@ -1,79 +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 QXYSERIES_P_H -#define QXYSERIES_P_H - -#include "qabstractseries_p.h" - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -class QXYSeries; -class QAbstractAxis; - -class QXYSeriesPrivate: public QAbstractSeriesPrivate -{ - Q_OBJECT - -public: - QXYSeriesPrivate(QXYSeries *q); - - void initializeDomain(); - void initializeAxes(); - void initializeAnimations(QtCommercialChart::QChart::AnimationOptions options); - - QList createLegendMarkers(QLegend* legend); - - QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const; - QAbstractAxis* createDefaultAxis(Qt::Orientation orientation) const; - - void drawSeriesPointLabels(QPainter *painter, const QVector &points, - const int offset = 0); - -Q_SIGNALS: - void updated(); - -protected: - QVector m_points; - QPen m_pen; - QBrush m_brush; - bool m_pointsVisible; - QString m_pointLabelsFormat; - bool m_pointLabelsVisible; - QFont m_pointLabelsFont; - QColor m_pointLabelsColor; - -private: - Q_DECLARE_PUBLIC(QXYSeries) - friend class QScatterSeries; -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif diff --git a/src/xychart/xychart.cpp b/src/xychart/xychart.cpp deleted file mode 100644 index 85247ff9..00000000 --- a/src/xychart/xychart.cpp +++ /dev/null @@ -1,189 +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 "xychart_p.h" -#include "qxyseries.h" -#include "qxyseries_p.h" -#include "chartpresenter_p.h" -#include "abstractdomain_p.h" -#include "qxymodelmapper.h" -#include "qabstractaxis_p.h" -#include -#include - - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -XYChart::XYChart(QXYSeries *series, QGraphicsItem *item): - ChartItem(series->d_func(),item), - m_series(series), - m_animation(0), - m_dirty(true) -{ - QObject::connect(series, SIGNAL(pointReplaced(int)), this, SLOT(handlePointReplaced(int))); - QObject::connect(series, SIGNAL(pointsReplaced()), this, SLOT(handlePointsReplaced())); - QObject::connect(series, SIGNAL(pointAdded(int)), this, SLOT(handlePointAdded(int))); - QObject::connect(series, SIGNAL(pointRemoved(int)), this, SLOT(handlePointRemoved(int))); - QObject::connect(this, SIGNAL(clicked(QPointF)), series, SIGNAL(clicked(QPointF))); - QObject::connect(this, SIGNAL(hovered(QPointF,bool)), series, SIGNAL(hovered(QPointF,bool))); -} - -void XYChart::setGeometryPoints(const QVector &points) -{ - m_points = points; -} - -void XYChart::setAnimation(XYAnimation *animation) -{ - m_animation = animation; -} - -void XYChart::setDirty(bool dirty) -{ - m_dirty = dirty; -} - -// Returns a vector with same size as geometryPoints vector, indicating -// the off grid status of points. -QVector XYChart::offGridStatusVector() -{ - qreal minX = domain()->minX(); - qreal maxX = domain()->maxX(); - qreal minY = domain()->minY(); - qreal maxY = domain()->maxY(); - - QVector returnVector; - returnVector.resize(m_points.size()); - // During remove animation series may have different number of points, - // so ensure we don't go over the index. No need to check for zero points, this - // will not be called in such a situation. - const int seriesLastIndex = m_series->count() - 1; - - for (int i = 0; i < m_points.size(); i++) { - const QPointF &seriesPoint = m_series->at(qMin(seriesLastIndex, i)); - if (seriesPoint.x() < minX - || seriesPoint.x() > maxX - || seriesPoint.y() < minY - || seriesPoint.y() > maxY) { - returnVector[i] = true; - } else { - returnVector[i] = false; - } - } - return returnVector; -} - -void XYChart::updateChart(QVector &oldPoints, QVector &newPoints, int index) -{ - - if (m_animation) { - m_animation->setup(oldPoints, newPoints, index); - m_points = newPoints; - setDirty(false); - presenter()->startAnimation(m_animation); - } else { - m_points = newPoints; - updateGeometry(); - } -} - -//handlers - -void XYChart::handlePointAdded(int index) -{ - Q_ASSERT(index < m_series->count()); - Q_ASSERT(index >= 0); - - QVector points; - - if (m_dirty || m_points.isEmpty()) { - points = domain()->calculateGeometryPoints(m_series->points()); - } else { - points = m_points; - QPointF point = domain()->calculateGeometryPoint(m_series->points()[index], m_validData); - if (!m_validData) - m_points.clear(); - else - points.insert(index, point); - } - - updateChart(m_points, points, index); -} - -void XYChart::handlePointRemoved(int index) -{ - Q_ASSERT(index <= m_series->count()); - Q_ASSERT(index >= 0); - - QVector points; - - if (m_dirty || m_points.isEmpty()) { - points = domain()->calculateGeometryPoints(m_series->points()); - } else { - points = m_points; - points.remove(index); - } - - updateChart(m_points, points, index); -} - -void XYChart::handlePointReplaced(int index) -{ - Q_ASSERT(index < m_series->count()); - Q_ASSERT(index >= 0); - - QVector points; - - if (m_dirty || m_points.isEmpty()) { - points = domain()->calculateGeometryPoints(m_series->points()); - } else { - QPointF point = domain()->calculateGeometryPoint(m_series->points()[index], m_validData); - if (!m_validData) - m_points.clear(); - points = m_points; - if (m_validData) - points.replace(index, point); - } - - updateChart(m_points, points, index); -} - -void XYChart::handlePointsReplaced() -{ - // All the points were replaced -> recalculate - QVector points = domain()->calculateGeometryPoints(m_series->points()); - updateChart(m_points, points, -1); -} - -void XYChart::handleDomainUpdated() -{ - if (isEmpty()) return; - QVector points = domain()->calculateGeometryPoints(m_series->points()); - updateChart(m_points, points); -} - -bool XYChart::isEmpty() -{ - return domain()->isEmpty() || m_series->points().isEmpty(); -} - -#include "moc_xychart_p.cpp" - -QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/xychart/xychart.pri b/src/xychart/xychart.pri deleted file mode 100644 index d43fc8d0..00000000 --- a/src/xychart/xychart.pri +++ /dev/null @@ -1,21 +0,0 @@ -INCLUDEPATH += $$PWD -DEPENDPATH += $$PWD - -SOURCES += \ - $$PWD/xychart.cpp \ - $$PWD/qxyseries.cpp \ - $$PWD/qxymodelmapper.cpp \ - $$PWD/qvxymodelmapper.cpp \ - $$PWD/qhxymodelmapper.cpp - -PRIVATE_HEADERS += \ - $$PWD/xychart_p.h \ - $$PWD/qxyseries_p.h \ - $$PWD/qxymodelmapper_p.h - - -PUBLIC_HEADERS += \ - $$PWD/qxyseries.h \ - $$PWD/qxymodelmapper.h \ - $$PWD/qvxymodelmapper.h \ - $$PWD/qhxymodelmapper.h diff --git a/src/xychart/xychart_p.h b/src/xychart/xychart_p.h deleted file mode 100644 index d45e55fd..00000000 --- a/src/xychart/xychart_p.h +++ /dev/null @@ -1,92 +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 XYCHART_H -#define XYCHART_H - -#include "qchartglobal.h" -#include "chartitem_p.h" -#include "xyanimation_p.h" -#include "qvalueaxis.h" -#include - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -class ChartPresenter; -class QXYSeries; - -class XYChart : public ChartItem -{ - Q_OBJECT -public: - explicit XYChart(QXYSeries *series,QGraphicsItem *item = 0); - ~XYChart() {} - - void setGeometryPoints(const QVector &points); - QVector geometryPoints() const { return m_points; } - - void setAnimation(XYAnimation *animation); - ChartAnimation *animation() const { return m_animation; } - virtual void updateGeometry() = 0; - - bool isDirty() const { return m_dirty; } - void setDirty(bool dirty); - - void getSeriesRanges(qreal &minX, qreal &maxX, qreal &minY, qreal &maxY); - QVector offGridStatusVector(); - -public Q_SLOTS: - void handlePointAdded(int index); - void handlePointRemoved(int index); - void handlePointReplaced(int index); - void handlePointsReplaced(); - void handleDomainUpdated(); - -Q_SIGNALS: - void clicked(const QPointF &point); - void hovered(const QPointF &point, bool state); - -protected: - virtual void updateChart(QVector &oldPoints, QVector &newPoints, int index = -1); - -private: - inline bool isEmpty(); - -protected: - QXYSeries *m_series; - QVector m_points; - XYAnimation *m_animation; - bool m_dirty; - - friend class AreaChartItem; -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif -- cgit v1.2.3