##// END OF EJS Templates
Title and name of QSeries replaced with name
Title and name of QSeries replaced with name

File last commit:

r722:3c81c15bc4ba
r731:90a16700f8b3
Show More
declarativelineseries.cpp
55 lines | 1.7 KiB | text/x-c | CppLexer
/ qmlplugin / declarativelineseries.cpp
Tero Ahola
Dynamic data for QML pie and line series
r215 #include "declarativelineseries.h"
#include "declarativechart.h"
#include "qchart.h"
Michal Klocek
Rename QLineChartSeries to QLineSeries
r349 #include "qlineseries.h"
Tero Ahola
Dynamic data for QML pie and line series
r215
QTCOMMERCIALCHART_BEGIN_NAMESPACE
DeclarativeLineSeries::DeclarativeLineSeries(QDeclarativeItem *parent) :
QDeclarativeItem(parent)
{
setFlag(QGraphicsItem::ItemHasNoContents, false);
connect(this, SIGNAL(parentChanged()),
this, SLOT(setParentForSeries()));
}
void DeclarativeLineSeries::setParentForSeries()
{
if (!m_series) {
DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(parent());
if (declarativeChart) {
QChart *chart = qobject_cast<QChart *>(declarativeChart->m_chart);
qDebug() << "creating line series for chart: " << chart;
Q_ASSERT(chart);
Michal Klocek
Rename QLineChartSeries to QLineSeries
r349 m_series = new QLineSeries();
Tero Ahola
Dynamic data for QML pie and line series
r215 Q_ASSERT(m_series);
for (int i(0); i < m_data.count(); i++) {
Tero Ahola
d
r722 DeclarativeXyPoint *element = m_data.at(i);
Tero Ahola
Dynamic data for QML pie and line series
r215 m_series->add(element->x(), element->y());
}
chart->addSeries(m_series);
}
}
}
Tero Ahola
d
r722 QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeLineSeries::data()
Tero Ahola
Dynamic data for QML pie and line series
r215 {
Tero Ahola
d
r722 return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeLineSeries::appendData);
Tero Ahola
Dynamic data for QML pie and line series
r215 }
Tero Ahola
d
r722 void DeclarativeLineSeries::appendData(QDeclarativeListProperty<DeclarativeXyPoint> *list,
DeclarativeXyPoint *element)
Tero Ahola
Dynamic data for QML pie and line series
r215 {
DeclarativeLineSeries *series = qobject_cast<DeclarativeLineSeries *>(list->object);
if (series) {
series->m_data.append(element);
if (series->m_series)
series->m_series->add(element->x(), element->y());
}
}
#include "moc_declarativelineseries.cpp"
QTCOMMERCIALCHART_END_NAMESPACE