##// END OF EJS Templates
QML model mapper documentation for pie and xy
QML model mapper documentation for pie and xy

File last commit:

r1444:0ed586503264
r1516:267764825d23
Show More
chartpresenter.cpp
429 lines | 13.6 KiB | text/x-c | CppLexer
/ src / chartpresenter.cpp
Jani Honkonen
Add license headers
r794 /****************************************************************************
Michal Klocek
Fixes header guard style issues
r969 **
** 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$
**
****************************************************************************/
#include "chartpresenter_p.h"
Michal Klocek
Refactored for MVP...
r139 #include "qchart.h"
Michal Klocek
Refactor qledgend handling...
r855 #include "qchart_p.h"
Michal Klocek
Changes QChartAxis -> QAxis
r1006 #include "qaxis.h"
Michal Klocek
Refactors qchart , adds line animation...
r131 #include "chartdataset_p.h"
Michal Klocek
Refactor themes...
r143 #include "charttheme_p.h"
Michal Klocek
Animation refactor...
r530 #include "chartanimator_p.h"
Michal Klocek
Refactors axis animation, line animations
r1241 #include "chartanimation_p.h"
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 #include "qabstractseries_p.h"
Michal Klocek
Adds area chart...
r421 #include "qareaseries.h"
Michal Klocek
Changes QChartAxis -> QAxis
r1006 #include "chartaxis_p.h"
Michal Klocek
Refactors axis animation, line animations
r1241 #include "chartaxisx_p.h"
#include "chartaxisy_p.h"
Michal Klocek
Adds area chart...
r421 #include "areachartitem_p.h"
Michal Klocek
Changes QChartAxis -> QAxis
r1006 #include "chartbackground_p.h"
Michal Klocek
Refactors axis animation, line animations
r1241 #include <QTimer>
Michal Klocek
Refactors qchart , adds line animation...
r131
QTCOMMERCIALCHART_BEGIN_NAMESPACE
ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart),
Michal Klocek
Fixes header guard style issues
r969 m_chart(chart),
m_animator(0),
m_dataset(dataset),
m_chartTheme(0),
m_chartRect(QRectF(QPoint(0,0),m_chart->size())),
m_options(QChart::NoAnimation),
m_minLeftMargin(0),
m_minBottomMargin(0),
Michal Klocek
Refactors axis animation, line animations
r1241 m_state(ShowState),
Michal Klocek
Fixes header guard style issues
r969 m_backgroundItem(0),
m_titleItem(0),
m_marginBig(60),
m_marginSmall(20),
m_marginTiny(10),
m_chartMargins(QRect(m_marginBig,m_marginBig,0,0))
Michal Klocek
Refactors qchart , adds line animation...
r131 {
Michal Klocek
Refactors axis animation, line animations
r1241
Michal Klocek
Refactors qchart , adds line animation...
r131 }
ChartPresenter::~ChartPresenter()
{
Michal Klocek
Fixes header guard style issues
r969 delete m_chartTheme;
Michal Klocek
Refactors qchart , adds line animation...
r131 }
Michal Klocek
Refactor qledgend handling...
r855 void ChartPresenter::setGeometry(const QRectF& rect)
Michal Klocek
Refactors qchart , adds line animation...
r131 {
Michal Klocek
Refactor domain model...
r439 m_rect = rect;
Michal Klocek
Fix test application to have valid window size
r147 Q_ASSERT(m_rect.isValid());
Michal Klocek
Refactor qledgend handling...
r855 updateLayout();
}
Michal Klocek
Changes QChartAxis -> QAxis
r1006 void ChartPresenter::setMinimumMarginWidth(ChartAxis* axis, qreal width)
Michal Klocek
Refactor qledgend handling...
r855 {
switch(axis->axisType()){
Michal Klocek
Changes QChartAxis -> QAxis
r1006 case ChartAxis::X_AXIS:
Michal Klocek
Fixes header guard style issues
r969 {
if(width>m_chartRect.width()+ m_chartMargins.left()) {
m_minLeftMargin= width - m_chartRect.width();
updateLayout();
Michal Klocek
Refactor qledgend handling...
r855 }
Michal Klocek
Fixes header guard style issues
r969 break;
}
Michal Klocek
Changes QChartAxis -> QAxis
r1006 case ChartAxis::Y_AXIS:
Michal Klocek
Fixes header guard style issues
r969 {
Michal Klocek
Refactor qledgend handling...
r855
Michal Klocek
Fixes header guard style issues
r969 if(m_minLeftMargin!=width){
m_minLeftMargin= width;
updateLayout();
Michal Klocek
Refactor qledgend handling...
r855 }
Michal Klocek
Fixes header guard style issues
r969 break;
}
Michal Klocek
Refactor qledgend handling...
r855
}
}
Michal Klocek
Changes QChartAxis -> QAxis
r1006 void ChartPresenter::setMinimumMarginHeight(ChartAxis* axis, qreal height)
Michal Klocek
Refactor qledgend handling...
r855 {
switch(axis->axisType()){
Michal Klocek
Changes QChartAxis -> QAxis
r1006 case ChartAxis::X_AXIS:
Michal Klocek
Fixes header guard style issues
r969 {
if(m_minBottomMargin!=height) {
m_minBottomMargin= height;
updateLayout();
Michal Klocek
Refactor qledgend handling...
r855 }
Michal Klocek
Fixes header guard style issues
r969 break;
}
Michal Klocek
Changes QChartAxis -> QAxis
r1006 case ChartAxis::Y_AXIS:
Michal Klocek
Fixes header guard style issues
r969 {
Michal Klocek
Refactor qledgend handling...
r855
Michal Klocek
Fixes header guard style issues
r969 if(height>m_chartMargins.bottom()+m_chartRect.height()){
m_minBottomMargin= height - m_chartRect.height();
updateLayout();
Michal Klocek
Refactor qledgend handling...
r855 }
Michal Klocek
Fixes header guard style issues
r969 break;
}
Michal Klocek
Refactor qledgend handling...
r855
}
Michal Klocek
Refactored for MVP...
r139 }
Michal Klocek
Refactors qchart , adds line animation...
r131
Michal Klocek
Changes QChartAxis -> QAxis
r1006 void ChartPresenter::handleAxisAdded(QAxis* axis,Domain* domain)
Michal Klocek
Refactors axis handling...
r223 {
Michal Klocek
Refactors axis animation, line animations
r1241 ChartAxis* item;
if(axis == m_dataset->axisX()){
item = new ChartAxisX(axis,this);
}else{
item = new ChartAxisY(axis,this);
}
Michal Klocek
Adds animation settings handling
r298
Michal Klocek
Animation refactor...
r530 if(m_options.testFlag(QChart::GridAxisAnimations)){
Michal Klocek
Refactors axis animation, line animations
r1241 item->setAnimator(m_animator);
item->setAnimation(new AxisAnimation(item));
Michal Klocek
Refactor domain model...
r439 }
Michal Klocek
Animation refactor...
r530
Michal Klocek
Refactor domain model...
r439 if(axis==m_dataset->axisX()){
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 m_chartTheme->decorate(axis,true);
Michal Klocek
Adds scroll support...
r531 QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int)));
Michal Klocek
Refactor domain model...
r439 //initialize
Michal Klocek
Adds scroll support...
r531 item->handleRangeChanged(domain->minX(),domain->maxX(),domain->tickXCount());
Michal Klocek
Fix theme decoration calls on all xyseries
r562
Michal Klocek
Refactor domain model...
r439 }
else{
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 m_chartTheme->decorate(axis,false);
Michal Klocek
Adds scroll support...
r531 QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int)));
Michal Klocek
Refactor domain model...
r439 //initialize
Michal Klocek
Adds scroll support...
r531 item->handleRangeChanged(domain->minY(),domain->maxY(),domain->tickYCount());
Michal Klocek
Refactors axis handling...
r223 }
Michal Klocek
Adds animation settings handling
r298
Michal Klocek
Normalizes signal slots connections
r967 QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF)));
Michal Klocek
Refactor domain model...
r439 //initialize
Michal Klocek
Refactors animation handling for xyseries
r1217 if(m_chartRect.isValid()) item->handleGeometryChanged(m_chartRect);
Tero Ahola
Now using either vertical or horizontal grid shades
r561 m_axisItems.insert(axis, item);
Michal Klocek
Refactors axis handling...
r223 }
Michal Klocek
Changes QChartAxis -> QAxis
r1006 void ChartPresenter::handleAxisRemoved(QAxis* axis)
Michal Klocek
Refactors axis handling...
r223 {
Michal Klocek
Changes QChartAxis -> QAxis
r1006 ChartAxis* item = m_axisItems.take(axis);
Michal Klocek
Refactors axis handling...
r223 Q_ASSERT(item);
Michal Klocek
Animation refactor...
r530 if(m_animator) m_animator->removeAnimation(item);
Michal Klocek
Refactors axis handling...
r223 delete item;
}
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 void ChartPresenter::handleSeriesAdded(QAbstractSeries* series,Domain* domain)
Michal Klocek
Refactors qchart , adds line animation...
r131 {
Michal Klocek
Fixes header guard style issues
r969 Chart *item = series->d_ptr->createGraphics(this);
Q_ASSERT(item);
QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF)));
QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),item,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal)));
//initialize
item->handleDomainChanged(domain->minX(),domain->maxX(),domain->minY(),domain->maxY());
if(m_chartRect.isValid()) item->handleGeometryChanged(m_chartRect);
m_chartItems.insert(series,item);
Michal Klocek
Refactors qchart , adds line animation...
r131 }
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 void ChartPresenter::handleSeriesRemoved(QAbstractSeries* series)
Michal Klocek
Refactored for MVP...
r139 {
Michal Klocek
Refactors chartitem...
r677 Chart* item = m_chartItems.take(series);
Michal Klocek
Animation refactor...
r530 Q_ASSERT(item);
Michal Klocek
Adds area chart animations...
r560 if(m_animator) {
//small hack to handle area animations
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 if(series->type() == QAbstractSeries::SeriesTypeArea){
Michal Klocek
Fixes header guard style issues
r969 QAreaSeries* areaSeries = static_cast<QAreaSeries*>(series);
AreaChartItem* area = static_cast<AreaChartItem*>(item);
m_animator->removeAnimation(area->upperLineItem());
if(areaSeries->lowerSeries()) m_animator->removeAnimation(area->lowerLineItem());
Michal Klocek
Adds area chart animations...
r560 }else
Michal Klocek
Fixes header guard style issues
r969 m_animator->removeAnimation(item);
Michal Klocek
Adds area chart animations...
r560 }
Marek Rosa
Spline working somewhat
r401 delete item;
Michal Klocek
Refactored for MVP...
r139 }
Michal Klocek
Refactors qchart , adds line animation...
r131
Michal Klocek
Adds PIMPL to qchart
r740 void ChartPresenter::setTheme(QChart::ChartTheme theme,bool force)
Michal Klocek
Refactor themes...
r143 {
Michal Klocek
Fixes header guard style issues
r969 if(m_chartTheme && m_chartTheme->id() == theme) return;
Michal Klocek
Refactor themes...
r143 delete m_chartTheme;
m_chartTheme = ChartTheme::createTheme(theme);
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 m_chartTheme->setForced(force);
m_chartTheme->decorate(m_chart);
m_chartTheme->decorate(m_chart->legend());
Michal Klocek
Adds scroll support...
r531 resetAllElements();
Jani Honkonen
Bugfix: Adding/removing slices erased users colors....
r1093
// We do not want "force" to stay on.
// Bar/pie are calling decorate when adding/removing slices/bars which means
// that to preserve users colors "force" must not be on.
m_chartTheme->setForced(false);
Michal Klocek
Adds more axis handling...
r176 }
Michal Klocek
Adds PIMPL to qchart
r740 QChart::ChartTheme ChartPresenter::theme()
Michal Klocek
Refactor themes...
r143 {
Michal Klocek
Adds missing ids to theme classes
r153 return m_chartTheme->id();
}
Michal Klocek
Adds animation settings handling
r298 void ChartPresenter::setAnimationOptions(QChart::AnimationOptions options)
{
if(m_options!=options) {
m_options=options;
Michal Klocek
Animation refactor...
r530 if(m_options!=QChart::NoAnimation && !m_animator) {
m_animator= new ChartAnimator(this);
Michal Klocek
Adds animation settings handling
r298 }
Michal Klocek
Adds scroll support...
r531 resetAllElements();
Michal Klocek
Adds animation settings handling
r298 }
Michal Klocek
Animation refactor...
r530
Michal Klocek
Adds animation settings handling
r298 }
Michal Klocek
Adds scroll support...
r531 void ChartPresenter::resetAllElements()
{
Michal Klocek
Changes QChartAxis -> QAxis
r1006 QList<QAxis *> axisList = m_axisItems.uniqueKeys();
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 QList<QAbstractSeries *> seriesList = m_chartItems.uniqueKeys();
Michal Klocek
Fixes header guard style issues
r969
Michal Klocek
Changes QChartAxis -> QAxis
r1006 foreach(QAxis *axis, axisList) {
Michal Klocek
Fixes header guard style issues
r969 handleAxisRemoved(axis);
handleAxisAdded(axis,m_dataset->domain(axis));
}
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 foreach(QAbstractSeries *series, seriesList) {
Michal Klocek
Fixes header guard style issues
r969 handleSeriesRemoved(series);
handleSeriesAdded(series,m_dataset->domain(series));
Marek Rosa
Refactored model related methods in PieSeries
r1063 // m_dataset->removeSeries(series);
// m_dataset->addSeries(series);
Michal Klocek
Fixes header guard style issues
r969 }
Michal Klocek
Adds scroll support...
r531 }
Jani Honkonen
Add gestures support for zoomlinechart example...
r1187 void ChartPresenter::zoomIn(qreal factor)
Michal Klocek
Refactor domain model...
r439 {
Michal Klocek
Fixes header guard style issues
r969 QRectF rect = chartGeometry();
Jani Honkonen
Add gestures support for zoomlinechart example...
r1187 rect.setWidth(rect.width()/factor);
rect.setHeight(rect.height()/factor);
Michal Klocek
Fixes header guard style issues
r969 rect.moveCenter(chartGeometry().center());
zoomIn(rect);
Michal Klocek
Refactor domain model...
r439 }
void ChartPresenter::zoomIn(const QRectF& rect)
{
Michal Klocek
Fixes header guard style issues
r969 QRectF r = rect.normalized();
Michal Klocek
Refactor qledgend handling...
r855 r.translate(-m_chartMargins.topLeft());
Jani Honkonen
Add gestures support for zoomlinechart example...
r1187 if (!r.isValid())
return;
Michal Klocek
Fixes header guard style issues
r969
Michal Klocek
Refactors axis animation, line animations
r1241 m_state = ZoomInState;
m_statePoint = QPointF(r.center().x()/chartGeometry().width(),r.center().y()/chartGeometry().height());
Michal Klocek
Fixes header guard style issues
r969 m_dataset->zoomInDomain(r,chartGeometry().size());
Michal Klocek
Refactors axis animation, line animations
r1241 m_state = ShowState;
Michal Klocek
Refactor domain model...
r439 }
Jani Honkonen
Add gestures support for zoomlinechart example...
r1187 void ChartPresenter::zoomOut(qreal factor)
Michal Klocek
Refactor domain model...
r439 {
Michal Klocek
Refactors axis animation, line animations
r1241 m_state = ZoomOutState;
Michal Klocek
Adds loosenumber algorithm...
r678
Jani Honkonen
Add gestures support for zoomlinechart example...
r1187 QRectF chartRect;
chartRect.setSize(chartGeometry().size());
Michal Klocek
Adds loosenumber algorithm...
r678
Jani Honkonen
Add gestures support for zoomlinechart example...
r1187 QRectF rect;
rect.setSize(chartRect.size()/factor);
rect.moveCenter(chartRect.center());
if (!rect.isValid())
return;
Michal Klocek
Refactors axis animation, line animations
r1241 m_statePoint = QPointF(rect.center().x()/chartGeometry().width(),rect.center().y()/chartGeometry().height());
Jani Honkonen
Add gestures support for zoomlinechart example...
r1187 m_dataset->zoomOutDomain(rect, chartRect.size());
Michal Klocek
Refactors axis animation, line animations
r1241 m_state = ShowState;
Michal Klocek
Refactor domain model...
r439 }
Michal Klocek
Fix precision issue when scrolling domain
r1267 void ChartPresenter::scroll(qreal dx,qreal dy)
Michal Klocek
Adds scroll support...
r531 {
Michal Klocek
Refactors axis animation, line animations
r1241 if(dx<0) m_state=ScrollLeftState;
if(dx>0) m_state=ScrollRightState;
if(dy<0) m_state=ScrollUpState;
if(dy>0) m_state=ScrollDownState;
Michal Klocek
Adds scroll support...
r531
Michal Klocek
Refactors axis animation, line animations
r1241 m_dataset->scrollDomain(dx,dy,chartGeometry().size());
m_state = ShowState;
Michal Klocek
Adds scroll support...
r531 }
Michal Klocek
Adds animation settings handling
r298 QChart::AnimationOptions ChartPresenter::animationOptions() const
{
return m_options;
}
Michal Klocek
Refactor qledgend handling...
r855 void ChartPresenter::updateLayout()
{
if (!m_rect.isValid()) return;
// recalculate title size
QSize titleSize;
int titlePadding=0;
if (m_titleItem) {
titleSize= m_titleItem->boundingRect().size().toSize();
}
//defaults
m_chartMargins = QRect(QPoint(m_minLeftMargin>m_marginBig?m_minLeftMargin:m_marginBig,m_marginBig),QPoint(m_marginBig,m_minBottomMargin>m_marginBig?m_minBottomMargin:m_marginBig));
titlePadding = m_chartMargins.top()/2;
QLegend* legend = m_chart->d_ptr->m_legend;
// recalculate legend position
sauimone
legend example to documentation. minor legend fixes
r1300 if (legend != 0 && legend->isAttachedToChart() && legend->isEnabled()) {
Michal Klocek
Refactor qledgend handling...
r855
// Reserve some space for legend
switch (legend->alignment()) {
Tero Ahola
Qml ChartView properties; legend to use Qt alignments
r1357 case Qt::AlignTop: {
Michal Klocek
Fixes header guard style issues
r969 int ledgendSize = legend->minHeight();
int topPadding = 2*m_marginTiny + titleSize.height() + ledgendSize + m_marginTiny;
m_chartMargins = QRect(QPoint(m_chartMargins.left(),topPadding),QPoint(m_chartMargins.right(),m_chartMargins.bottom()));
m_legendMargins = QRect(QPoint(m_chartMargins.left(),topPadding - (ledgendSize + m_marginTiny)),QPoint(m_chartMargins.right(),m_rect.height()-topPadding + m_marginTiny));
titlePadding = m_marginTiny + m_marginTiny;
break;
}
Tero Ahola
Qml ChartView properties; legend to use Qt alignments
r1357 case Qt::AlignBottom: {
Michal Klocek
Fixes header guard style issues
r969 int ledgendSize = legend->minHeight();
int bottomPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny + m_minBottomMargin;
m_chartMargins = QRect(QPoint(m_chartMargins.left(),m_chartMargins.top()),QPoint(m_chartMargins.right(),bottomPadding));
m_legendMargins = QRect(QPoint(m_chartMargins.left(),m_rect.height()-bottomPadding + m_marginTiny + m_minBottomMargin),QPoint(m_chartMargins.right(),m_marginTiny + m_marginSmall));
titlePadding = m_chartMargins.top()/2;
break;
}
Tero Ahola
Qml ChartView properties; legend to use Qt alignments
r1357 case Qt::AlignLeft: {
Michal Klocek
Fixes header guard style issues
r969 int ledgendSize = legend->minWidth();
int leftPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny + m_minLeftMargin;
m_chartMargins = QRect(QPoint(leftPadding,m_chartMargins.top()),QPoint(m_chartMargins.right(),m_chartMargins.bottom()));
m_legendMargins = QRect(QPoint(m_marginTiny + m_marginSmall,m_chartMargins.top()),QPoint(m_rect.width()-leftPadding + m_marginTiny + m_minLeftMargin,m_chartMargins.bottom()));
titlePadding = m_chartMargins.top()/2;
break;
}
Tero Ahola
Qml ChartView properties; legend to use Qt alignments
r1357 case Qt::AlignRight: {
Michal Klocek
Fixes header guard style issues
r969 int ledgendSize = legend->minWidth();
int rightPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny;
m_chartMargins = QRect(QPoint(m_chartMargins.left(),m_chartMargins.top()),QPoint(rightPadding,m_chartMargins.bottom()));
m_legendMargins = QRect(QPoint(m_rect.width()- rightPadding+ m_marginTiny ,m_chartMargins.top()),QPoint(m_marginTiny + m_marginSmall,m_chartMargins.bottom()));
titlePadding = m_chartMargins.top()/2;
break;
}
default: {
break;
}
Michal Klocek
Refactor qledgend handling...
r855 }
}
Michal Klocek
Add minimum size back to chartview and qchart
r913 if(m_rect.width()<2*(m_chartMargins.top()+m_chartMargins.bottom()) || m_rect.height()< 2*(m_chartMargins.top() + m_chartMargins.bottom()))
{
m_chart->setMinimumSize(2*(m_chartMargins.top()+m_chartMargins.bottom()),2*(m_chartMargins.top() + m_chartMargins.bottom()));
return;
}
Michal Klocek
Refactor qledgend handling...
r855 // recalculate title position
if (m_titleItem) {
QPointF center = m_rect.center() -m_titleItem->boundingRect().center();
m_titleItem->setPos(center.x(),titlePadding);
}
//recalculate background gradient
if (m_backgroundItem) {
m_backgroundItem->setRect(m_rect.adjusted(m_marginTiny,m_marginTiny, -m_marginTiny, -m_marginTiny));
}
Michal Klocek
Add minimum size back to chartview and qchart
r913
Michal Klocek
Bugfixes for unnesery geometry changes
r869 QRectF chartRect = m_rect.adjusted(m_chartMargins.left(),m_chartMargins.top(),-m_chartMargins.right(),-m_chartMargins.bottom());
sauimone
better legend detach layout. updated legend example
r1444 if (legend != 0 && legend->isAttachedToChart() && legend->isEnabled()) {
legend->setGeometry(m_rect.adjusted(m_legendMargins.left(),m_legendMargins.top(),-m_legendMargins.right(),-m_legendMargins.bottom()));
}
Michal Klocek
Refactor , move dataset legend presentr connections to one place
r871
Michal Klocek
Refactors animation handling for xyseries
r1217 if(m_chartRect!=chartRect && chartRect.isValid()){
Michal Klocek
Fixes header guard style issues
r969 m_chartRect=chartRect;
emit geometryChanged(m_chartRect);
}
Michal Klocek
Refactor qledgend handling...
r855
}
void ChartPresenter::createChartBackgroundItem()
{
if (!m_backgroundItem) {
m_backgroundItem = new ChartBackground(rootItem());
m_backgroundItem->setPen(Qt::NoPen);
m_backgroundItem->setZValue(ChartPresenter::BackgroundZValue);
}
}
void ChartPresenter::createChartTitleItem()
{
if (!m_titleItem) {
m_titleItem = new QGraphicsSimpleTextItem(rootItem());
m_titleItem->setZValue(ChartPresenter::BackgroundZValue);
}
}
Michal Klocek
Refactor themes...
r143
Michal Klocek
Refactors axis animation, line animations
r1241 void ChartPresenter::handleAnimationFinished()
{
m_animations.removeAll(qobject_cast<ChartAnimation*>(sender()));
if(m_animations.empty()) emit animationsFinished();
}
void ChartPresenter::startAnimation(ChartAnimation* animation)
{
if (animation->state() != QAbstractAnimation::Stopped) animation->stop();
QObject::connect(animation, SIGNAL(finished()),this,SLOT(handleAnimationFinished()),Qt::UniqueConnection);
if(!m_animations.isEmpty()){
m_animations.append(animation);
}
QTimer::singleShot(0, animation, SLOT(start()));
}
Michal Klocek
Refactors qchart , adds line animation...
r131 #include "moc_chartpresenter_p.cpp"
QTCOMMERCIALCHART_END_NAMESPACE