##// END OF EJS Templates
Fix memory leak in presenter example
Fix memory leak in presenter example

File last commit:

r227:c1a8606b64b8
r257:0ac69f2530b6
Show More
qchart.cpp
153 lines | 3.2 KiB | text/x-c | CppLexer
Michal Klocek
adds missing files form previous commit
r12 #include "qchart.h"
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 #include "qchartaxis.h"
Michal Klocek
Refactors qchart , adds line animation...
r131 #include "chartpresenter_p.h"
#include "chartdataset_p.h"
Tero Ahola
Integrated scatter type series...
r42 #include <QGraphicsScene>
Michal Klocek
Adds layout support for charts....
r115 #include <QGraphicsSceneResizeEvent>
Michal Klocek
Refactor current draft to fit int current design specs...
r21 #include <QDebug>
Michal Klocek
adds missing files form previous commit
r12
Tero Ahola
Renamed to QtCommercialChart
r30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
Michal Klocek
adds missing files form previous commit
r12
Michal Klocek
Adds layout support for charts....
r115 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
Michal Klocek
Refactor themes...
r143 m_backgroundItem(0),
m_titleItem(0),
m_dataset(new ChartDataSet(this)),
m_presenter(new ChartPresenter(this,m_dataset))
Michal Klocek
adds missing files form previous commit
r12 {
}
Michal Klocek
Refactor themes...
r143 QChart::~QChart() {}
Michal Klocek
adds missing files form previous commit
r12
Michal Klocek
Refactors axis handling...
r223 void QChart::addSeries(QChartSeries* series,QChartAxis* axisY)
{
m_dataset->addSeries(series,axisY);
}
Tero Ahola
Integrated scatter type series...
r42
Michal Klocek
Refactors axis handling...
r223 void QChart::removeSeries(QChartSeries* series)
{
m_dataset->removeSeries(series);
Tero Ahola
Integrated scatter type series...
r42 }
Tero Ahola
Resizing of QGraphicItems now possible by resize signal from QChart
r48
Michal Klocek
Change background gradient to use ObjectBoundingMode...
r122 void QChart::setChartBackgroundBrush(const QBrush& brush)
{
Michal Klocek
Refactors axis handling...
r223 createChartBackgroundItem();
Michal Klocek
Change background gradient to use ObjectBoundingMode...
r122 m_backgroundItem->setBrush(brush);
m_backgroundItem->update();
}
void QChart::setChartBackgroundPen(const QPen& pen)
{
Michal Klocek
Refactors axis handling...
r223 createChartBackgroundItem();
Michal Klocek
Change background gradient to use ObjectBoundingMode...
r122 m_backgroundItem->setPen(pen);
m_backgroundItem->update();
}
Michal Klocek
Adds font handling for chart's titile...
r192 void QChart::setChartTitle(const QString& title)
Michal Klocek
Add background to chart...
r69 {
Michal Klocek
Refactors axis handling...
r223 createChartTitleItem();
Michal Klocek
Adds title support
r87 m_titleItem->setPlainText(title);
Michal Klocek
Adds font handling for chart's titile...
r192 }
void QChart::setChartTitleFont(const QFont& font)
{
Michal Klocek
Refactors axis handling...
r223 createChartTitleItem();
Michal Klocek
Adds title support
r87 m_titleItem->setFont(font);
Michal Klocek
Add background to chart...
r69 }
Michal Klocek
Refactors axis handling...
r223 void QChart::createChartBackgroundItem()
{
if(!m_backgroundItem) {
m_backgroundItem = new QGraphicsRectItem(this);
m_backgroundItem->setZValue(-1);
}
}
void QChart::createChartTitleItem()
{
if(!m_titleItem) m_titleItem = new QGraphicsTextItem(this);
}
Michal Klocek
Adds pimpl to qchart class
r28 int QChart::margin() const
{
Jani Honkonen
Pie chart refactoring
r142 return m_presenter->margin();
Michal Klocek
Adds pimpl to qchart class
r28 }
Michal Klocek
adds missing files form previous commit
r12 void QChart::setMargin(int margin)
{
Michal Klocek
Refactor themes...
r143 m_presenter->setMargin(margin);
Michal Klocek
adds missing files form previous commit
r12 }
Michal Klocek
Adds missing ids to theme classes
r153 void QChart::setChartTheme(QChart::ChartTheme theme)
Tero Ahola
Draft implementation for setting color themes for a chart
r64 {
Michal Klocek
Adds missing ids to theme classes
r153 m_presenter->setChartTheme(theme);
Tero Ahola
Draft implementation for setting color themes for a chart
r64 }
Michal Klocek
Adds missing ids to theme classes
r153 QChart::ChartTheme QChart::chartTheme() const
Tero Ahola
Proof-of-concept for QML api...
r120 {
Michal Klocek
Adds missing ids to theme classes
r153 return m_presenter->chartTheme();
Tero Ahola
Proof-of-concept for QML api...
r120 }
Michal Klocek
Refactors axis handling...
r223 void QChart::zoomIn()
Michal Klocek
Add zoom support...
r67 {
Michal Klocek
Refactors axis handling...
r223 if (!m_dataset->nextDomain()) {
QRectF rect = m_presenter->geometry();
rect.setWidth(rect.width()/2);
rect.setHeight(rect.height()/2);
rect.moveCenter(m_presenter->geometry().center());
zoomIn(rect);
}
Michal Klocek
Add zoom support...
r67 }
Michal Klocek
Refactors axis handling...
r223 void QChart::zoomIn(const QRectF& rect)
Michal Klocek
Add zoom support...
r67 {
Michal Klocek
Refactors axis handling...
r223 if(!rect.isValid()) return;
QRectF r = rect.normalized();
int margin = m_presenter->margin();
r.translate(-margin, -margin);
m_dataset->addDomain(r,m_presenter->geometry());
Michal Klocek
Add zoom support...
r67 }
void QChart::zoomOut()
{
Michal Klocek
Refactors axis handling...
r223 m_dataset->previousDomain();
Michal Klocek
Add zoom support...
r67 }
Tero Ahola
QChartWidget now zooms only x axis and zoom is reset with right click
r93 void QChart::zoomReset()
{
Michal Klocek
Refactors axis handling...
r223 m_dataset->clearDomains();
Michal Klocek
Adds more axis handling...
r176 }
Michal Klocek
Refactors axis handling...
r223 QChartAxis* QChart::axisX() const
Michal Klocek
Adds more axis handling...
r176 {
Michal Klocek
Refactors axis handling...
r223 return m_dataset->axisX();
Michal Klocek
Adds more axis handling...
r176 }
Michal Klocek
Refactors axis handling...
r223 QChartAxis* QChart::axisY() const
Michal Klocek
Adds more axis handling...
r176 {
Michal Klocek
Refactors axis handling...
r223 return m_dataset->axisY();
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 }
Michal Klocek
Adds layout support for charts....
r115 void QChart::resizeEvent(QGraphicsSceneResizeEvent *event)
{
m_rect = QRectF(QPoint(0,0),event->newSize());
QRectF rect = m_rect.adjusted(margin(),margin(), -margin(), -margin());
// recalculate title position
if (m_titleItem) {
QPointF center = m_rect.center() -m_titleItem->boundingRect().center();
m_titleItem->setPos(center.x(),m_rect.top()/2 + margin()/2);
}
//recalculate background gradient
if (m_backgroundItem) {
m_backgroundItem->setRect(rect);
}
Michal Klocek
Removes obsolate methods from qchart
r117 QGraphicsWidget::resizeEvent(event);
Michal Klocek
Adds layout support for charts....
r115 update();
}
Tero Ahola
Draft implementation for setting color themes for a chart
r64 #include "moc_qchart.cpp"
Tero Ahola
Resizing of QGraphicItems now possible by resize signal from QChart
r48
Tero Ahola
Renamed to QtCommercialChart
r30 QTCOMMERCIALCHART_END_NAMESPACE