##// END OF EJS Templates
Refactors Chart to ChartElement
Michal Klocek -
r1736:cb991e4e355f
parent child
Show More
@@ -356,7 +356,7 void QAreaSeriesPrivate::scaleDomain(Domain& domain)
356 356 domain.setRange(minX,maxX,minY,maxY);
357 357 }
358 358
359 Chart* QAreaSeriesPrivate::createGraphics(ChartPresenter* presenter)
359 ChartElement* QAreaSeriesPrivate::createGraphics(ChartPresenter* presenter)
360 360 {
361 361 Q_Q(QAreaSeries);
362 362
@@ -44,7 +44,7 public:
44 44 QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q);
45 45
46 46 void scaleDomain(Domain& domain);
47 Chart* createGraphics(ChartPresenter* presenter);
47 ChartElement* createGraphics(ChartPresenter* presenter);
48 48 QList<LegendMarker*> createLegendMarker(QLegend* legend);
49 49 void initializeAxis(QAbstractAxis* axis);
50 50 QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const;
@@ -28,7 +28,7
28 28
29 29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 30
31 ChartAxis::ChartAxis(QAbstractAxis *axis,ChartPresenter *presenter) : Chart(presenter),
31 ChartAxis::ChartAxis(QAbstractAxis *axis,ChartPresenter *presenter) : ChartElement(presenter),
32 32 m_chartAxis(axis),
33 33 m_labelsAngle(0),
34 34 m_grid(new QGraphicsItemGroup(presenter->rootItem())),
@@ -31,7 +31,7
31 31 #define CHARTAXIS_H
32 32
33 33 #include "qchartglobal.h"
34 #include "chart_p.h"
34 #include "chartelement_p.h"
35 35 #include "axisanimation_p.h"
36 36 #include <QGraphicsItem>
37 37 #include <QFont>
@@ -41,7 +41,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
41 41 class QAbstractAxis;
42 42 class ChartPresenter;
43 43
44 class ChartAxis : public Chart
44 class ChartAxis : public ChartElement
45 45 {
46 46 Q_OBJECT
47 47 public:
@@ -101,7 +101,7 void QHorizontalBarSeriesPrivate::scaleDomain(Domain& domain)
101 101 domain.setRange(minX,maxX,minY,maxY);
102 102 }
103 103
104 Chart* QHorizontalBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
104 ChartElement* QHorizontalBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
105 105 {
106 106 Q_Q(QHorizontalBarSeries);
107 107
@@ -39,7 +39,7 class QHorizontalBarSeriesPrivate: public QAbstractBarSeriesPrivate
39 39 {
40 40 public:
41 41 QHorizontalBarSeriesPrivate(QHorizontalBarSeries* q);
42 Chart* createGraphics(ChartPresenter* presenter);
42 ChartElement* createGraphics(ChartPresenter* presenter);
43 43 void scaleDomain(Domain& domain);
44 44 private:
45 45 Q_DECLARE_PUBLIC(QHorizontalBarSeries)
@@ -49,7 +49,7 void QHorizontalPercentBarSeriesPrivate::scaleDomain(Domain& domain)
49 49 domain.setRange(minX,maxX,minY,maxY);
50 50 }
51 51
52 Chart* QHorizontalPercentBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
52 ChartElement* QHorizontalPercentBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
53 53 {
54 54 Q_Q(QHorizontalPercentBarSeries);
55 55
@@ -39,7 +39,7 class QHorizontalPercentBarSeriesPrivate: public QAbstractBarSeriesPrivate
39 39 {
40 40 public:
41 41 QHorizontalPercentBarSeriesPrivate(QHorizontalPercentBarSeries* q);
42 Chart* createGraphics(ChartPresenter* presenter);
42 ChartElement* createGraphics(ChartPresenter* presenter);
43 43 void scaleDomain(Domain& domain);
44 44 private:
45 45 Q_DECLARE_PUBLIC(QHorizontalPercentBarSeries)
@@ -50,7 +50,7 void QHorizontalStackedBarSeriesPrivate::scaleDomain(Domain& domain)
50 50 domain.setRange(minX,maxX,minY,maxY);
51 51 }
52 52
53 Chart* QHorizontalStackedBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
53 ChartElement* QHorizontalStackedBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
54 54 {
55 55 Q_Q(QHorizontalStackedBarSeries);
56 56
@@ -39,7 +39,7 class QHorizontalStackedBarSeriesPrivate: public QAbstractBarSeriesPrivate
39 39 {
40 40 public:
41 41 QHorizontalStackedBarSeriesPrivate(QHorizontalStackedBarSeries* q);
42 Chart* createGraphics(ChartPresenter* presenter);
42 ChartElement* createGraphics(ChartPresenter* presenter);
43 43 void scaleDomain(Domain& domain);
44 44 private:
45 45 Q_DECLARE_PUBLIC(QHorizontalStackedBarSeries)
@@ -26,7 +26,6
26 26 #include "legendmarker_p.h"
27 27 #include "chartdataset_p.h"
28 28 #include "charttheme_p.h"
29 #include "chartanimator_p.h"
30 29 #include "qvaluesaxis.h"
31 30 #include "qbarcategoriesaxis.h"
32 31
@@ -569,7 +568,7 void QAbstractBarSeriesPrivate::scaleDomain(Domain& domain)
569 568 domain.setRange(minX,maxX,minY,maxY);
570 569 }
571 570
572 Chart* QAbstractBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
571 ChartElement* QAbstractBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
573 572 {
574 573 Q_UNUSED(presenter);
575 574 qWarning() << "QAbstractBarSeriesPrivate::createGraphics called";
@@ -54,7 +54,7 public:
54 54 void setLabelsVisible(bool visible);
55 55
56 56 void scaleDomain(Domain& domain);
57 Chart* createGraphics(ChartPresenter* presenter);
57 ChartElement* createGraphics(ChartPresenter* presenter);
58 58 QList<LegendMarker*> createLegendMarker(QLegend* legend);
59 59
60 60 void initializeAxis(QAbstractAxis* axis);
@@ -104,7 +104,7 void QBarSeriesPrivate::scaleDomain(Domain& domain)
104 104 }
105 105
106 106
107 Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
107 ChartElement* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
108 108 {
109 109 Q_Q(QBarSeries);
110 110
@@ -40,7 +40,7 class QBarSeriesPrivate: public QAbstractBarSeriesPrivate
40 40 {
41 41 public:
42 42 QBarSeriesPrivate(QBarSeries* q);
43 Chart* createGraphics(ChartPresenter* presenter);
43 ChartElement* createGraphics(ChartPresenter* presenter);
44 44 void scaleDomain(Domain& domain);
45 45 private:
46 46 Q_DECLARE_PUBLIC(QBarSeries)
@@ -103,7 +103,7 void QPercentBarSeriesPrivate::scaleDomain(Domain& domain)
103 103 }
104 104
105 105
106 Chart* QPercentBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
106 ChartElement* QPercentBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
107 107 {
108 108 Q_Q(QPercentBarSeries);
109 109
@@ -41,7 +41,7 class QPercentBarSeriesPrivate: public QAbstractBarSeriesPrivate
41 41 public:
42 42 QPercentBarSeriesPrivate(QPercentBarSeries* q);
43 43 void scaleDomain(Domain& domain);
44 Chart* createGraphics(ChartPresenter* presenter);
44 ChartElement* createGraphics(ChartPresenter* presenter);
45 45 private:
46 46 Q_DECLARE_PUBLIC(QPercentBarSeries)
47 47 };
@@ -104,7 +104,7 void QStackedBarSeriesPrivate::scaleDomain(Domain& domain)
104 104 }
105 105
106 106
107 Chart* QStackedBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
107 ChartElement* QStackedBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
108 108 {
109 109 Q_Q(QStackedBarSeries);
110 110
@@ -40,7 +40,7 class QStackedBarSeriesPrivate: public QAbstractBarSeriesPrivate
40 40 {
41 41 public:
42 42 QStackedBarSeriesPrivate(QStackedBarSeries* q);
43 Chart* createGraphics(ChartPresenter* presenter);
43 ChartElement* createGraphics(ChartPresenter* presenter);
44 44 void scaleDomain(Domain& domain);
45 45 private:
46 46 Q_DECLARE_PUBLIC(QStackedBarSeries)
@@ -18,45 +18,45
18 18 **
19 19 ****************************************************************************/
20 20
21 #include "chart_p.h"
21 #include "chartelement_p.h"
22 22 #include "chartpresenter_p.h"
23 23 #include "domain_p.h"
24 24
25 25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 26
27 Chart::Chart(ChartPresenter *presenter):QObject(presenter),
27 ChartElement::ChartElement(ChartPresenter *presenter):QObject(presenter),
28 28 m_presenter(presenter),
29 29 m_domain(0)
30 30 {
31 31 }
32 32
33 void Chart::setPresenter(ChartPresenter *presenter)
33 void ChartElement::setPresenter(ChartPresenter *presenter)
34 34 {
35 35 m_presenter=presenter;
36 36 }
37 37
38 ChartPresenter* Chart::presenter() const
38 ChartPresenter* ChartElement::presenter() const
39 39 {
40 40 return m_presenter;
41 41 }
42 42
43 void Chart::setDomain(Domain *domain)
43 void ChartElement::setDomain(Domain *domain)
44 44 {
45 45 m_domain=domain;
46 46 }
47 47
48 Domain* Chart::domain() const
48 Domain* ChartElement::domain() const
49 49 {
50 50 return m_domain;
51 51 }
52 52
53 void Chart::handleGeometryChanged(const QRectF& rect)
53 void ChartElement::handleGeometryChanged(const QRectF& rect)
54 54 {
55 55 Q_UNUSED(rect);
56 56 qWarning()<<"Slot not implemented";
57 57 }
58 58
59 void Chart::handleDomainChanged(qreal minX,qreal maxX,qreal minY,qreal maxY)
59 void ChartElement::handleDomainChanged(qreal minX,qreal maxX,qreal minY,qreal maxY)
60 60 {
61 61 Q_UNUSED(minX);
62 62 Q_UNUSED(maxX);
@@ -65,12 +65,12 void Chart::handleDomainChanged(qreal minX,qreal maxX,qreal minY,qreal maxY)
65 65 qWarning()<<"Slot not implemented";
66 66 }
67 67
68 void Chart::handleDomainUpdated()
68 void ChartElement::handleDomainUpdated()
69 69 {
70 70 qWarning()<<"Slot not implemented";
71 71 }
72 72
73 73
74 #include "moc_chart_p.cpp"
74 #include "moc_chartelement_p.cpp"
75 75
76 76 QTCOMMERCIALCHART_END_NAMESPACE
@@ -27,8 +27,8
27 27 //
28 28 // We mean it.
29 29
30 #ifndef CHART_H
31 #define CHART_H
30 #ifndef CHARTELEMENT_H
31 #define CHARTELEMENT_H
32 32
33 33 #include "qchartglobal.h"
34 34 #include <QObject>
@@ -41,11 +41,11 class ChartPresenter;
41 41 class ChartAnimation;
42 42 class Domain;
43 43
44 class Chart: public QObject
44 class ChartElement: public QObject
45 45 {
46 46 Q_OBJECT
47 47 public:
48 explicit Chart(ChartPresenter *presenter);
48 explicit ChartElement(ChartPresenter *presenter);
49 49
50 50 public Q_SLOTS:
51 51 virtual void handleGeometryChanged(const QRectF& rect);
@@ -30,17 +30,17
30 30 #ifndef CHARTITEM_H
31 31 #define CHARTITEM_H
32 32
33 #include "chart_p.h"
33 #include "chartelement_p.h"
34 34 #include "chartpresenter_p.h"
35 35 #include <QGraphicsItem>
36 36
37 37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38 38
39 class ChartItem : public QGraphicsItem, public Chart
39 class ChartItem : public QGraphicsItem, public ChartElement
40 40 {
41 41 enum ChartItemTypes{ AXIS_ITEM = UserType + 1, XYLINE_ITEM };
42 42 public:
43 ChartItem(ChartPresenter *presenter) : QGraphicsItem(presenter ? presenter->rootItem() : 0), Chart(presenter) {}
43 ChartItem(ChartPresenter *presenter) : QGraphicsItem(presenter ? presenter->rootItem() : 0), ChartElement(presenter) {}
44 44 };
45 45
46 46 QTCOMMERCIALCHART_END_NAMESPACE
@@ -104,7 +104,7 void ChartPresenter::handleAxisRemoved(QAbstractAxis* axis)
104 104
105 105 void ChartPresenter::handleSeriesAdded(QAbstractSeries* series,Domain* domain)
106 106 {
107 Chart *item = series->d_ptr->createGraphics(this);
107 ChartElement *item = series->d_ptr->createGraphics(this);
108 108 Q_ASSERT(item);
109 109 item->setDomain(domain);
110 110
@@ -119,7 +119,7 void ChartPresenter::handleSeriesAdded(QAbstractSeries* series,Domain* domain)
119 119
120 120 void ChartPresenter::handleSeriesRemoved(QAbstractSeries* series)
121 121 {
122 Chart* item = m_chartItems.take(series);
122 ChartElement* item = m_chartItems.take(series);
123 123 Q_ASSERT(item);
124 124 item->deleteLater();
125 125 }
@@ -214,7 +214,7 void ChartPresenter::resetAllElements()
214 214 handleAxisAdded(axis,domain);
215 215 }
216 216
217 QMapIterator<QAbstractSeries*, Chart*> j(m_chartItems);
217 QMapIterator<QAbstractSeries*, ChartElement*> j(m_chartItems);
218 218 while (j.hasNext()) {
219 219 j.next();
220 220 Domain* domain = j.value()->domain();
@@ -36,7 +36,7
36 36
37 37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38 38
39 class Chart;
39 class ChartElement;
40 40 class QAbstractSeries;
41 41 class ChartDataSet;
42 42 class Domain;
@@ -157,7 +157,7 private:
157 157 QChart* m_chart;
158 158 ChartDataSet* m_dataset;
159 159 ChartTheme *m_chartTheme;
160 QMap<QAbstractSeries*, Chart*> m_chartItems;
160 QMap<QAbstractSeries*, ChartElement*> m_chartItems;
161 161 QMap<QAbstractAxis*, ChartAxis*> m_axisItems;
162 162 QRectF m_rect;
163 163 QChart::AnimationOptions m_options;
@@ -116,7 +116,7 QLineSeriesPrivate::QLineSeriesPrivate(QLineSeries* q):QXYSeriesPrivate(q)
116 116
117 117 };
118 118
119 Chart* QLineSeriesPrivate::createGraphics(ChartPresenter* presenter)
119 ChartElement* QLineSeriesPrivate::createGraphics(ChartPresenter* presenter)
120 120 {
121 121 Q_Q(QLineSeries);
122 122 LineChartItem* line = new LineChartItem(q,presenter);
@@ -39,7 +39,7 class QLineSeriesPrivate: public QXYSeriesPrivate
39 39 {
40 40 public:
41 41 QLineSeriesPrivate(QLineSeries* q);
42 Chart* createGraphics(ChartPresenter* presenter);
42 ChartElement* createGraphics(ChartPresenter* presenter);
43 43
44 44 private:
45 45 Q_DECLARE_PUBLIC(QLineSeries);
@@ -818,7 +818,7 void QPieSeriesPrivate::scaleDomain(Domain& domain)
818 818 // does not apply to pie
819 819 }
820 820
821 Chart* QPieSeriesPrivate::createGraphics(ChartPresenter* presenter)
821 ChartElement* QPieSeriesPrivate::createGraphics(ChartPresenter* presenter)
822 822 {
823 823 Q_Q(QPieSeries);
824 824 PieChartItem* pie = new PieChartItem(q,presenter);
@@ -45,7 +45,7 public:
45 45 ~QPieSeriesPrivate();
46 46
47 47 void scaleDomain(Domain& domain);
48 Chart* createGraphics(ChartPresenter *presenter);
48 ChartElement* createGraphics(ChartPresenter *presenter);
49 49 QList<LegendMarker*> createLegendMarker(QLegend *legend);
50 50 void initializeAxis(QAbstractAxis* axis);
51 51 QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const;
@@ -36,7 +36,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
36 36
37 37 class Domain;
38 38 class ChartPresenter;
39 class Chart;
39 class ChartElement;
40 40 class LegendMarker;
41 41 class QLegend;
42 42 class ChartDataSet;
@@ -50,7 +50,7 public:
50 50 ~QAbstractSeriesPrivate();
51 51
52 52 virtual void scaleDomain(Domain& domain) = 0;
53 virtual Chart* createGraphics(ChartPresenter* presenter) = 0;
53 virtual ChartElement* createGraphics(ChartPresenter* presenter) = 0;
54 54 virtual QList<LegendMarker*> createLegendMarker(QLegend* legend) = 0;
55 55 virtual void initializeAxis(QAbstractAxis* axis) = 0;
56 56 virtual QAbstractAxis::AxisType defaultAxisType(Qt::Orientation) const = 0;
@@ -246,7 +246,7 QScatterSeriesPrivate::QScatterSeriesPrivate(QScatterSeries* q) :
246 246 {
247 247 }
248 248
249 Chart* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter)
249 ChartElement* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter)
250 250 {
251 251 Q_Q(QScatterSeries);
252 252 ScatterChartItem *scatter = new ScatterChartItem(q,presenter);
@@ -38,7 +38,7 class QScatterSeriesPrivate: public QXYSeriesPrivate
38 38 {
39 39 public:
40 40 QScatterSeriesPrivate(QScatterSeries* q);
41 Chart* createGraphics(ChartPresenter* presenter);
41 ChartElement* createGraphics(ChartPresenter* presenter);
42 42
43 43 private:
44 44 QScatterSeries::MarkerShape m_shape;
@@ -217,7 +217,7 void QSplineSeriesPrivate::updateControlPoints()
217 217 }
218 218 }
219 219
220 Chart* QSplineSeriesPrivate::createGraphics(ChartPresenter* presenter)
220 ChartElement* QSplineSeriesPrivate::createGraphics(ChartPresenter* presenter)
221 221 {
222 222 Q_Q(QSplineSeries);
223 223 SplineChartItem* spline = new SplineChartItem(q,presenter);
@@ -39,7 +39,7 class QSplineSeriesPrivate: public QLineSeriesPrivate
39 39 {
40 40 Q_OBJECT
41 41 public:
42 Chart* createGraphics(ChartPresenter* presenter);
42 ChartElement* createGraphics(ChartPresenter* presenter);
43 43 QSplineSeriesPrivate(QSplineSeries* q);
44 44
45 45 QPointF controlPoint(int index) const;
@@ -36,7 +36,7 SOURCES += \
36 36 $$PWD/qchartview.cpp \
37 37 $$PWD/qabstractseries.cpp \
38 38 $$PWD/chartbackground.cpp \
39 $$PWD/chart.cpp \
39 $$PWD/chartelement.cpp \
40 40 $$PWD/scroller.cpp \
41 41 $$PWD/chartlayout.cpp
42 42 PRIVATE_HEADERS += \
@@ -46,7 +46,7 PRIVATE_HEADERS += \
46 46 $$PWD/charttheme_p.h \
47 47 $$PWD/domain_p.h \
48 48 $$PWD/chartbackground_p.h \
49 $$PWD/chart_p.h \
49 $$PWD/chartelement_p.h \
50 50 $$PWD/chartconfig_p.h \
51 51 $$PWD/qchart_p.h \
52 52 $$PWD/qchartview_p.h \
@@ -32,7 +32,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32 32
33 33 //TODO: optimize : remove points which are not visible
34 34
35 XYChart::XYChart(QXYSeries *series, ChartPresenter *presenter):Chart(presenter),
35 XYChart::XYChart(QXYSeries *series, ChartPresenter *presenter):ChartElement(presenter),
36 36 m_minX(0),
37 37 m_maxX(0),
38 38 m_minY(0),
@@ -41,7 +41,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
41 41 class ChartPresenter;
42 42 class QXYSeries;
43 43
44 class XYChart : public Chart
44 class XYChart : public ChartElement
45 45 {
46 46 Q_OBJECT
47 47 public:
General Comments 0
You need to be logged in to leave comments. Login now