qhxymodelmapper.cpp
241 lines
| 6.5 KiB
| text/x-c
|
CppLexer
|
r1355 | /**************************************************************************** | ||
** | ||||
|
r2776 | ** Copyright (C) 2015 The Qt Company Ltd | ||
|
r1355 | ** All rights reserved. | ||
|
r2776 | ** For any questions to The Qt Company, please use contact form at http://qt.io | ||
|
r1355 | ** | ||
|
r2740 | ** This file is part of the Qt Charts module. | ||
|
r1355 | ** | ||
|
r2740 | ** Licensees holding valid commercial license for Qt may use this file in | ||
** accordance with the Qt License Agreement provided with the Software | ||||
** or, alternatively, in accordance with the terms contained in a written | ||||
|
r2776 | ** agreement between you and The Qt Company. | ||
|
r1355 | ** | ||
** If you have questions regarding the use of this file, please use | ||||
|
r2740 | ** contact form at http://qt.io | ||
|
r1355 | ** | ||
****************************************************************************/ | ||||
|
r2714 | #include <QtCharts/QHXYModelMapper> | ||
|
r1252 | |||
|
r2712 | QT_CHARTS_BEGIN_NAMESPACE | ||
|
r1252 | |||
|
r1331 | /*! | ||
\class QHXYModelMapper | ||||
|
r2639 | \inmodule Qt Charts | ||
|
r2712 | \brief Horizontal model mapper for QXYSeries. | ||
|
r1331 | \mainclass | ||
|
r1397 | Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series. | ||
|
r1378 | 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. | ||||
|
r2396 | Note: used model has to support adding/removing rows/columns and modifying the data of the cells. | ||
|
r1331 | */ | ||
|
r2639 | /*! | ||
\qmltype HXYModelMapper | ||||
\instantiates QHXYModelMapper | ||||
|
r2712 | \inqmlmodule QtCharts | ||
|
r2639 | |||
|
r2712 | \brief Horizontal model mapper for QXYSeries | ||
|
r1516 | |||
|
r2712 | HXYModelMapper allows you to use your own QAbstractItemModel derived model with data in rows as | ||
a data source for XYSeries based series. It is possible to use both QAbstractItemModel and | ||||
XYSeries data API to manipulate data. HXYModelMapper keeps the series and the model in sync. | ||||
|
r1516 | */ | ||
|
r1331 | |||
|
r1507 | /*! | ||
\property QHXYModelMapper::series | ||||
\brief Defines the QXYSeries object that is used by the mapper. | ||||
|
r2520 | |||
|
r1507 | 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) | ||||
*/ | ||||
|
r1516 | /*! | ||
\qmlproperty XYSeries HXYModelMapper::series | ||||
|
r1519 | Defines the XYSeries object that is used by the mapper. All the data in the series is discarded when it is set to | ||
|
r1516 | the mapper. When new series is specified the old series is disconnected (it preserves its data). | ||
*/ | ||||
|
r1507 | |||
/*! | ||||
\property QHXYModelMapper::model | ||||
\brief Defines the model that is used by the mapper. | ||||
*/ | ||||
|
r1516 | /*! | ||
\qmlproperty SomeModel HXYModelMapper::model | ||||
|
r2618 | 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. | ||||
|
r1516 | */ | ||
|
r1507 | |||
|
r1344 | /*! | ||
\property QHXYModelMapper::xRow | ||||
|
r2520 | \brief Defines which row of the model is kept in sync with the x values of the QXYSeries. | ||
|
r1344 | Default value is: -1 (invalid mapping) | ||
*/ | ||||
|
r1516 | /*! | ||
\qmlproperty int HXYModelMapper::xRow | ||||
|
r1519 | Defines which row of the model is kept in sync with the x values of the series. Default value is -1 (invalid | ||
|
r1516 | mapping). | ||
*/ | ||||
|
r1344 | |||
/*! | ||||
\property QHXYModelMapper::yRow | ||||
|
r2520 | \brief Defines which row of the model is kept in sync with the y values of the QXYSeries. | ||
|
r1344 | Default value is: -1 (invalid mapping) | ||
*/ | ||||
|
r1516 | /*! | ||
\qmlproperty int HXYModelMapper::yRow | ||||
|
r1519 | Defines which row of the model is kept in sync with the y values of the series. Default value is -1 | ||
|
r1516 | (invalid mapping). | ||
*/ | ||||
|
r1344 | |||
|
r1507 | /*! | ||
\property QHXYModelMapper::firstColumn | ||||
\brief Defines which column of the model contains the data for the first point of the series. | ||||
|
r2520 | |||
|
r1507 | Minimal and default value is: 0 | ||
*/ | ||||
/*! | ||||
|
r1516 | \qmlproperty int HXYModelMapper::firstColumn | ||
|
r1507 | Defines which column of the model contains the data for the first point of the series. | ||
The default value is 0. | ||||
*/ | ||||
/*! | ||||
\property QHXYModelMapper::columnCount | ||||
|
r2520 | \brief Defines the number of columns of the model that are mapped as the data for series. | ||
|
r1507 | Minimal and default value is: -1 (count limited by the number of columns in the model) | ||
*/ | ||||
/*! | ||||
|
r1516 | \qmlproperty int HXYModelMapper::columnCount | ||
|
r1507 | 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. | ||||
*/ | ||||
|
r1477 | /*! | ||
\fn void QHXYModelMapper::xRowChanged() | ||||
Emitted when the xRow has changed. | ||||
*/ | ||||
/*! | ||||
\fn void QHXYModelMapper::yRowChanged() | ||||
Emitted when the yRow has changed. | ||||
*/ | ||||
|
r1507 | /*! | ||
\fn void QHXYModelMapper::firstColumnChanged() | ||||
Emitted when the firstColumn has changed. | ||||
*/ | ||||
/*! | ||||
\fn void QHXYModelMapper::columnCountChanged() | ||||
Emitted when the columnCount has changed. | ||||
*/ | ||||
|
r1347 | /*! | ||
Constructs a mapper object which is a child of \a parent. | ||||
*/ | ||||
|
r1252 | QHXYModelMapper::QHXYModelMapper(QObject *parent) : | ||
QXYModelMapper(parent) | ||||
{ | ||||
|
r1310 | QXYModelMapper::setOrientation(Qt::Horizontal); | ||
|
r1252 | } | ||
|
r2104 | QAbstractItemModel *QHXYModelMapper::model() const | ||
|
r1507 | { | ||
return QXYModelMapper::model(); | ||||
} | ||||
void QHXYModelMapper::setModel(QAbstractItemModel *model) | ||||
{ | ||||
if (model != QXYModelMapper::model()) { | ||||
QXYModelMapper::setModel(model); | ||||
emit modelReplaced(); | ||||
} | ||||
} | ||||
|
r2104 | QXYSeries *QHXYModelMapper::series() const | ||
|
r1507 | { | ||
return QXYModelMapper::series(); | ||||
} | ||||
void QHXYModelMapper::setSeries(QXYSeries *series) | ||||
{ | ||||
if (series != QXYModelMapper::series()) { | ||||
QXYModelMapper::setSeries(series); | ||||
emit seriesReplaced(); | ||||
} | ||||
} | ||||
|
r1252 | int QHXYModelMapper::xRow() const | ||
{ | ||||
return QXYModelMapper::xSection(); | ||||
} | ||||
void QHXYModelMapper::setXRow(int xRow) | ||||
{ | ||||
|
r1477 | if (xRow != xSection()) { | ||
|
r1920 | QXYModelMapper::setXSection(xRow); | ||
|
r1477 | emit xRowChanged(); | ||
} | ||||
|
r1252 | } | ||
int QHXYModelMapper::yRow() const | ||||
{ | ||||
return QXYModelMapper::ySection(); | ||||
} | ||||
void QHXYModelMapper::setYRow(int yRow) | ||||
{ | ||||
|
r1477 | if (yRow != ySection()) { | ||
|
r1920 | QXYModelMapper::setYSection(yRow); | ||
|
r1477 | emit yRowChanged(); | ||
} | ||||
|
r1252 | } | ||
|
r1507 | 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); | ||||
|
r1922 | emit columnCountChanged(); | ||
|
r1507 | } | ||
} | ||||
|
r1252 | #include "moc_qhxymodelmapper.cpp" | ||
|
r2712 | QT_CHARTS_END_NAMESPACE | ||