##// END OF EJS Templates
Some more qmake magic
Some more qmake magic

File last commit:

r1032:f1315a97f81e
r1046:7a7ac548bf6d
Show More
chartdataset.cpp
252 lines | 6.4 KiB | text/x-c | CppLexer
/ src / chartdataset.cpp
Michal Klocek
Updates chartdataset unit test
r771 /****************************************************************************
**
** Copyright (C) 2012 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 Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE$
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial 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$
**
****************************************************************************/
Michal Klocek
Refactors qchart , adds line animation...
r131 #include "chartdataset_p.h"
Michal Klocek
Changes QChartAxis -> QAxis
r1006 #include "qaxis.h"
#include "qaxis_p.h"
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 #include "qabstractseries_p.h"
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 #include "qbarseries.h"
#include "qstackedbarseries.h"
#include "qpercentbarseries.h"
Jani Honkonen
Moved pie stuff to own .pri file and rename stuff
r146 #include "qpieseries.h"
Michal Klocek
Refactors qchart , adds line animation...
r131
QTCOMMERCIALCHART_BEGIN_NAMESPACE
Michal Klocek
Refactors axis handling...
r223 ChartDataSet::ChartDataSet(QObject *parent):QObject(parent),
Michal Klocek
Changes QChartAxis -> QAxis
r1006 m_axisX(new QAxis(this)),
m_axisY(new QAxis(this)),
Marek Rosa
Spline working somewhat
r401 m_domainIndex(0),
m_axisXInitialized(false)
Michal Klocek
Refactors qchart , adds line animation...
r131 {
}
ChartDataSet::~ChartDataSet()
{
}
Michal Klocek
Changes QChartAxis -> QAxis
r1006 void ChartDataSet::addSeries(QAbstractSeries* series, QAxis *axisY)
Michal Klocek
Refactors qchart , adds line animation...
r131 {
Michal Klocek
Refactor domain model...
r439 if(axisY==0) axisY = m_axisY;
Michal Klocek
Refactored for MVP...
r139
Michal Klocek
Changes QChartAxis -> QAxis
r1006 QAxis* axis = m_seriesAxisMap.value(series);
Michal Klocek
Fix indexing issue of series
r910
if(axis) {
Michal Klocek
Refactor domain model...
r439 qWarning() << "Can not add series. Series already on the chart";
return;
}
Michal Klocek
Refactors axis handling...
r223
Michal Klocek
Krazy reported errors...
r974 series->setParent(this); // take ownership
axisY->setParent(this); // take ownership
Michal Klocek
Refactors axis handling...
r223
Michal Klocek
Refactor domain model...
r439 Domain* domain = m_axisDomainMap.value(axisY);
Michal Klocek
Fix indexing issue of series
r910
if(!domain) {
Michal Klocek
Adds owvership to domain
r787 domain = new Domain(axisY);
Michal Klocek
Adds pimpl for qchartaxis and qchartaxiscategories
r963 QObject::connect(axisY->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisYChanged(qreal,qreal,int,bool)));
QObject::connect(axisX()->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisXChanged(qreal,qreal,int,bool)));
QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),axisY->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int)));
QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),axisX()->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int)));
Michal Klocek
Bugfix missing min max intialization when axis added to domain
r442 //initialize
Michal Klocek
Refactor domain model...
r439 m_axisDomainMap.insert(axisY,domain);
emit axisAdded(axisY,domain);
Marek Rosa
Spline working somewhat
r401 }
Michal Klocek
Adds area chart...
r421
Michal Klocek
Fix indexing issue of series
r910 if(!m_axisXInitialized){
emit axisAdded(axisX(),domain);
m_axisXInitialized=true;
Michal Klocek
Refactor domain model...
r439 }
Michal Klocek
Adds area chart...
r421
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 series->d_ptr->scaleDomain(*domain);
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 if(series->type() == QAbstractSeries::SeriesTypeBar
|| series->type() == QAbstractSeries::SeriesTypeStackedBar
|| series->type() == QAbstractSeries::SeriesTypePercentBar) {
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 QBarSeries* barSeries = static_cast<QBarSeries*>(series);
setupCategories(barSeries);
}
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 if (series->type()== QAbstractSeries::SeriesTypePie && m_seriesAxisMap.count() == 0) {
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 axisX()->hide();
this->axisY()->hide();
}
Michal Klocek
Adds area chart...
r421
Michal Klocek
Fix indexing issue of series
r910 m_seriesAxisMap.insert(series,axisY);
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 QMapIterator<int, QAbstractSeries*> i(m_indexSeriesMap);
Michal Klocek
Fix indexing issue of series
r910
int key=0;
while (i.hasNext()) {
i.next();
if(i.key()!=key) {
break;
}
key++;
}
m_indexSeriesMap.insert(key,series);
emit seriesAdded(series,domain);
Michal Klocek
Refactored for MVP...
r139
Michal Klocek
Refactor domain model...
r439 }
Jani Honkonen
Pie chart refactoring
r142
Michal Klocek
Changes QChartAxis -> QAxis
r1006 QAxis* ChartDataSet::removeSeries(QAbstractSeries* series)
Michal Klocek
Refactor domain model...
r439 {
Michal Klocek
Changes QChartAxis -> QAxis
r1006 QAxis* axis = m_seriesAxisMap.value(series);
Michal Klocek
Fix indexing issue of series
r910
if(!axis){
qWarning()<<"Can not remove series. Series not found on the chart.";
Michal Klocek
Krazy reported errors...
r974 return 0;
Marek Rosa
Spline working somewhat
r401 }
Michal Klocek
Krazy reported errors...
r974
Michal Klocek
Fix indexing issue of series
r910 emit seriesRemoved(series);
Michal Klocek
Krazy reported errors...
r974
Michal Klocek
Fix indexing issue of series
r910 m_seriesAxisMap.remove(series);
int key = seriesIndex(series);
Q_ASSERT(key!=-1);
Michal Klocek
Refactored for MVP...
r139
Michal Klocek
Fix indexing issue of series
r910 m_indexSeriesMap.remove(key);
Michal Klocek
Krazy reported errors...
r974 series->setParent(0);
Michal Klocek
Refactored for MVP...
r139
Michal Klocek
Changes QChartAxis -> QAxis
r1006 QList<QAxis*> axes = m_seriesAxisMap.values();
Michal Klocek
Fix indexing issue of series
r910
int i = axes.indexOf(axis);
Michal Klocek
Refactors axis handling...
r223
Michal Klocek
Fix indexing issue of series
r910 if(i==-1){
Michal Klocek
Refactor domain model...
r439 Domain* domain = m_axisDomainMap.take(axis);
emit axisRemoved(axis);
Michal Klocek
Fix indexing issue of series
r910 if(axis!=axisY()){
Michal Klocek
Krazy reported errors...
r974 axis->setParent(0);
Michal Klocek
Fix ownership handling: if object has a parent do not delete it
r444 }
Michal Klocek
Refactor domain model...
r439 delete domain;
}
Michal Klocek
Refactors axis handling...
r223
Michal Klocek
Fix indexing issue of series
r910 if(m_seriesAxisMap.values().size()==0)
{
m_axisXInitialized=false;
Michal Klocek
Refactor domain model...
r439 emit axisRemoved(axisX());
Michal Klocek
Refactors axis handling...
r223 }
Michal Klocek
Krazy reported errors...
r974
return axis;
Michal Klocek
Refactored for MVP...
r139 }
Michal Klocek
Adds RemoveAllSeries method to API
r258 void ChartDataSet::removeAllSeries()
{
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 QList<QAbstractSeries*> series = m_seriesAxisMap.keys();
Michal Klocek
Changes QChartAxis -> QAxis
r1006 QList<QAxis*> axes;
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 foreach(QAbstractSeries *s , series) {
Michal Klocek
Changes QChartAxis -> QAxis
r1006 QAxis* axis = removeSeries(s);
Michal Klocek
Krazy reported errors...
r974 if(axis==axisY()) continue;
int i = axes.indexOf(axis);
if(i==-1){
axes<<axis;
}
Michal Klocek
Refactored for MVP...
r139 }
Michal Klocek
Fix indexing issue of series
r910 Q_ASSERT(m_seriesAxisMap.count()==0);
Q_ASSERT(m_axisDomainMap.count()==0);
Michal Klocek
Krazy reported errors...
r974 qDeleteAll(series);
qDeleteAll(axes);
Michal Klocek
Refactored for MVP...
r139 }
Michal Klocek
Adds back reimplemnted categories handling
r701 void ChartDataSet::setupCategories(QBarSeries* series)
{
Michal Klocek
Changes QChartAxisCategories -> QAxisCategories
r1032 QAxisCategories* categories = axisX()->categories();
Michal Klocek
Adds back reimplemnted categories handling
r701 categories->clear();
Michal Klocek
Adds BarCategories typedef
r703 categories->insert(series->categories());
Michal Klocek
Refactored for MVP...
r139 }
Michal Klocek
Refactor domain model...
r439 void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size)
Michal Klocek
Refactored for MVP...
r139 {
Michal Klocek
Changes QChartAxis -> QAxis
r1006 QMapIterator<QAxis*, Domain*> i(m_axisDomainMap);
Michal Klocek
Refactor domain model...
r439 while (i.hasNext()) {
i.next();
i.value()->zoomIn(rect,size);
Michal Klocek
Refactors axis handling...
r223 }
Michal Klocek
Refactor domain model...
r439 }
Michal Klocek
Refactors axis handling...
r223
Michal Klocek
Refactor domain model...
r439 void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size)
{
Michal Klocek
Changes QChartAxis -> QAxis
r1006 QMapIterator<QAxis*, Domain*> i(m_axisDomainMap);
Michal Klocek
Refactor domain model...
r439 while (i.hasNext()) {
i.next();
i.value()->zoomOut(rect,size);
}
Michal Klocek
Refactors axis handling...
r223 }
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 int ChartDataSet::seriesCount(QAbstractSeries::QSeriesType type)
Michal Klocek
Fix indexing issue of series
r910 {
int count=0;
Michal Klocek
Changes QChartAxis -> QAxis
r1006 QMapIterator<QAbstractSeries*, QAxis*> i(m_seriesAxisMap);
Michal Klocek
Fix indexing issue of series
r910 while (i.hasNext()) {
i.next();
if(i.key()->type()==type) count++;
}
return count;
}
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 int ChartDataSet::seriesIndex(QAbstractSeries *series)
Tero Ahola
Fixed bug with changing theme when several series exist
r538 {
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 QMapIterator<int, QAbstractSeries*> i(m_indexSeriesMap);
Michal Klocek
Fix indexing issue of series
r910 while (i.hasNext()) {
i.next();
if (i.value() == series)
return i.key();
Tero Ahola
Fixed bug with changing theme when several series exist
r538 }
Tero Ahola
Reserve ordering of chart series internally....
r825 return -1;
Tero Ahola
Fixed bug with changing theme when several series exist
r538 }
Michal Klocek
Changes QChartAxis -> QAxis
r1006 QAxis* ChartDataSet::axisY(QAbstractSeries *series) const
Michal Klocek
Refactors axis handling...
r223 {
Michal Klocek
Fix indexing issue of series
r910 if(series == 0) return m_axisY;
return m_seriesAxisMap.value(series);
Michal Klocek
Refactors axis handling...
r223 }
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 Domain* ChartDataSet::domain(QAbstractSeries *series) const
Michal Klocek
Refactors axis handling...
r223 {
Michal Klocek
Changes QChartAxis -> QAxis
r1006 QAxis* axis = m_seriesAxisMap.value(series);
Michal Klocek
Fix indexing issue of series
r910 if(axis){
Michal Klocek
Refactor domain model...
r439 return m_axisDomainMap.value(axis);
Michal Klocek
Fix indexing issue of series
r910 }else
return 0;
Michal Klocek
Refactors axis handling...
r223 }
Michal Klocek
Changes QChartAxis -> QAxis
r1006 Domain* ChartDataSet::domain(QAxis* axis) const
Michal Klocek
Refactors axis handling...
r223 {
Michal Klocek
Updates chartdataset unit test
r771 if(!axis || axis==axisX()) {
Michal Klocek
Fix ownership handling: if object has a parent do not delete it
r444 return m_axisDomainMap.value(axisY());
}
else {
return m_axisDomainMap.value(axis);
}
Michal Klocek
Refactors axis handling...
r223 }
Michal Klocek
Adds scroll support...
r531 void ChartDataSet::scrollDomain(int dx,int dy,const QSizeF& size)
{
Michal Klocek
Changes QChartAxis -> QAxis
r1006 QMapIterator<QAxis*, Domain*> i( m_axisDomainMap);
Michal Klocek
Adds scroll support...
r531 while (i.hasNext()) {
i.next();
i.value()->move(dx,dy,size);
}
}
Michal Klocek
Refactors qchart , adds line animation...
r131 #include "moc_chartdataset_p.cpp"
QTCOMMERCIALCHART_END_NAMESPACE