From 461b2e61910e6737f99dd58ea074dfee4e85dd9e 2012-02-21 13:55:52 From: Michal Klocek Date: 2012-02-21 13:55:52 Subject: [PATCH] Adds ZOrder enum to presenter --- diff --git a/src/axisitem.cpp b/src/axisitem.cpp index 540cea9..ceaa778 100644 --- a/src/axisitem.cpp +++ b/src/axisitem.cpp @@ -1,5 +1,6 @@ #include "axisitem_p.h" #include "qchartaxis.h" +#include "chartpresenter_p.h" #include #include @@ -14,11 +15,12 @@ m_labelsAngle(0), m_shadesEnabled(true), m_grid(parent), m_shades(parent), -m_labels(parent) +m_labels(parent), +m_origin(0,0) { //initial initialization - m_shades.setZValue(0); - m_grid.setZValue(2); + m_shades.setZValue(ChartPresenter::ShadesZValue); + m_grid.setZValue(ChartPresenter::GridZValue); } AxisItem::~AxisItem() @@ -209,7 +211,6 @@ void AxisItem::setGridOpacity(qreal opacity) m_grid.setOpacity(opacity); } - qreal AxisItem::gridOpacity() const { return m_grid.opacity(); diff --git a/src/axisitem_p.h b/src/axisitem_p.h index 3c4bba1..cd28482 100644 --- a/src/axisitem_p.h +++ b/src/axisitem_p.h @@ -50,9 +50,9 @@ public: void setLabelsFont(const QFont& font); public slots: - void handleAxisUpdate(QChartAxis* axis); - void handleLabelsChanged(QChartAxis* axis,const QStringList& labels); - void handleGeometryChanged(const QRectF& size); + void handleAxisUpdate(QChartAxis* axis); //look and feel + void handleLabelsChanged(QChartAxis* axis,const QStringList& labels); //labels from dataset + void handleGeometryChanged(const QRectF& size); // geometry from presenter protected: void updateItem(int count); private: @@ -68,6 +68,7 @@ private: QGraphicsItemGroup m_labels; QGraphicsLineItem m_axis; QStringList m_thicksList; + QPointF m_origin; }; diff --git a/src/chartpresenter_p.h b/src/chartpresenter_p.h index 8088d6e..6ec594a 100644 --- a/src/chartpresenter_p.h +++ b/src/chartpresenter_p.h @@ -20,6 +20,8 @@ class ChartPresenter: public QObject { Q_OBJECT public: + enum ZValues { BackgroundZValue = -1 , ShadesZValue, GridZValue, AxisZValue , LineChartZValue }; + ChartPresenter(QChart* chart,ChartDataSet *dataset); virtual ~ChartPresenter(); diff --git a/src/linechart/linechartitem.cpp b/src/linechart/linechartitem.cpp index 804dc5a..25d9e2c 100644 --- a/src/linechart/linechartitem.cpp +++ b/src/linechart/linechartitem.cpp @@ -15,7 +15,7 @@ m_dirtyData(false), m_dirtyGeometry(false), m_dirtyDomain(false) { - + setZValue(ChartPresenter::LineChartZValue); } QRectF LineChartItem::boundingRect() const diff --git a/src/qchart.cpp b/src/qchart.cpp index 26d13e5..fb1c41b 100644 --- a/src/qchart.cpp +++ b/src/qchart.cpp @@ -63,13 +63,16 @@ void QChart::createChartBackgroundItem() { if(!m_backgroundItem) { m_backgroundItem = new QGraphicsRectItem(this); - m_backgroundItem->setZValue(-1); + m_backgroundItem->setZValue(ChartPresenter::BackgroundZValue); } } void QChart::createChartTitleItem() { - if(!m_titleItem) m_titleItem = new QGraphicsTextItem(this); + if(!m_titleItem) { + m_titleItem = new QGraphicsTextItem(this); + m_titleItem->setZValue(ChartPresenter::BackgroundZValue); + } } int QChart::margin() const