##// END OF EJS Templates
Fix theme decoration calls on all xyseries
Michal Klocek -
r562:f23c0d74d416
parent child
Show More
@@ -105,11 +105,14 void ChartPresenter::handleAxisAdded(QChartAxis* axis,Domain* domain)
105 }
105 }
106
106
107 if(axis==m_dataset->axisX()){
107 if(axis==m_dataset->axisX()){
108 m_chartTheme->decorate(axis,true);
108 QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int)));
109 QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int)));
109 //initialize
110 //initialize
110 item->handleRangeChanged(domain->minX(),domain->maxX(),domain->tickXCount());
111 item->handleRangeChanged(domain->minX(),domain->maxX(),domain->tickXCount());
112
111 }
113 }
112 else{
114 else{
115 m_chartTheme->decorate(axis,false);
113 QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int)));
116 QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int)));
114 //initialize
117 //initialize
115 item->handleRangeChanged(domain->minY(),domain->maxY(),domain->tickYCount());
118 item->handleRangeChanged(domain->minY(),domain->maxY(),domain->tickYCount());
@@ -118,7 +121,6 void ChartPresenter::handleAxisAdded(QChartAxis* axis,Domain* domain)
118 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
121 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
119 //initialize
122 //initialize
120 item->handleGeometryChanged(m_rect);
123 item->handleGeometryChanged(m_rect);
121 m_chartTheme->decorate(axis, m_chart);
122 m_axisItems.insert(axis, item);
124 m_axisItems.insert(axis, item);
123 }
125 }
124
126
@@ -144,7 +146,7 void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain)
144 if(m_options.testFlag(QChart::SeriesAnimations)) {
146 if(m_options.testFlag(QChart::SeriesAnimations)) {
145 m_animator->addAnimation(line);
147 m_animator->addAnimation(line);
146 }
148 }
147 m_chartTheme->decorate(line, lineSeries, m_dataset->seriesIndex(series));
149 m_chartTheme->decorate(lineSeries, m_dataset->seriesIndex(series));
148 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),line,SLOT(handleGeometryChanged(const QRectF&)));
150 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),line,SLOT(handleGeometryChanged(const QRectF&)));
149 QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),line,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal)));
151 QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),line,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal)));
150 item = line;
152 item = line;
@@ -159,7 +161,7 void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain)
159 m_animator->addAnimation(area->upperLineItem());
161 m_animator->addAnimation(area->upperLineItem());
160 if(areaSeries->lowerSeries()) m_animator->addAnimation(area->lowerLineItem());
162 if(areaSeries->lowerSeries()) m_animator->addAnimation(area->lowerLineItem());
161 }
163 }
162 m_chartTheme->decorate(area, areaSeries, m_dataset->seriesIndex(series));
164 m_chartTheme->decorate(areaSeries, m_dataset->seriesIndex(series));
163 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),area,SLOT(handleGeometryChanged(const QRectF&)));
165 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),area,SLOT(handleGeometryChanged(const QRectF&)));
164 QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),area,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal)));
166 QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),area,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal)));
165 item=area;
167 item=area;
@@ -211,7 +213,7 void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain)
211 if(m_options.testFlag(QChart::SeriesAnimations)) {
213 if(m_options.testFlag(QChart::SeriesAnimations)) {
212 m_animator->addAnimation(scatter);
214 m_animator->addAnimation(scatter);
213 }
215 }
214 m_chartTheme->decorate(scatter, scatterSeries, m_dataset->seriesIndex(series));
216 m_chartTheme->decorate(scatterSeries, m_dataset->seriesIndex(series));
215 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),scatter,SLOT(handleGeometryChanged(const QRectF&)));
217 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),scatter,SLOT(handleGeometryChanged(const QRectF&)));
216 QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),scatter,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal)));
218 QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),scatter,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal)));
217 item = scatter;
219 item = scatter;
@@ -244,7 +246,7 void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain)
244 if(m_options.testFlag(QChart::SeriesAnimations)) {
246 if(m_options.testFlag(QChart::SeriesAnimations)) {
245 m_animator->addAnimation(spline);
247 m_animator->addAnimation(spline);
246 }
248 }
247 m_chartTheme->decorate(spline, splineSeries, m_dataset->seriesIndex(series));
249 m_chartTheme->decorate(splineSeries, m_dataset->seriesIndex(series));
248 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),spline,SLOT(handleGeometryChanged(const QRectF&)));
250 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),spline,SLOT(handleGeometryChanged(const QRectF&)));
249 QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),spline,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal)));
251 QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),spline,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal)));
250 item=spline;
252 item=spline;
@@ -71,7 +71,7 void ChartTheme::decorate(QLegend* legend)
71 legend->setBackgroundBrush(m_backgroundGradient);
71 legend->setBackgroundBrush(m_backgroundGradient);
72 }
72 }
73
73
74 void ChartTheme::decorate(AreaChartItem* item, QAreaSeries* series, int index)
74 void ChartTheme::decorate(QAreaSeries* series, int index)
75 {
75 {
76 QPen pen;
76 QPen pen;
77 QBrush brush;
77 QBrush brush;
@@ -89,7 +89,7 void ChartTheme::decorate(AreaChartItem* item, QAreaSeries* series, int index)
89 }
89 }
90
90
91
91
92 void ChartTheme::decorate(LineChartItem* item, QLineSeries* series,int index)
92 void ChartTheme::decorate(QLineSeries* series,int index)
93 {
93 {
94 QPen pen;
94 QPen pen;
95 if(pen == series->pen()){
95 if(pen == series->pen()){
@@ -159,10 +159,8 void ChartTheme::decorate(PercentBarPresenter* item, QPercentBarSeries* series,i
159 }
159 }
160 }
160 }
161
161
162 void ChartTheme::decorate(ScatterChartItem* item, QScatterSeries* series, int index)
162 void ChartTheme::decorate(QScatterSeries* series, int index)
163 {
163 {
164 Q_ASSERT(item);
165 Q_ASSERT(series);
166
164
167 QPen pen;
165 QPen pen;
168 QBrush brush;
166 QBrush brush;
@@ -191,45 +189,26 void ChartTheme::decorate(PiePresenter* item, QPieSeries* series, int index)
191 }
189 }
192 }
190 }
193
191
194 void ChartTheme::decorate(SplineChartItem* item, QSplineSeries* series, int index)
192 void ChartTheme::decorate(QSplineSeries* series, int index)
195 {
193 {
196 Q_ASSERT(item);
197 Q_ASSERT(series);
198
199 QPen pen;
194 QPen pen;
200
195
201 if(pen != series->pen()){
196 if(pen == series->pen()){
202 item->setLinePen(series->pen());
203 }else{
204 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
197 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
205 pen.setWidthF(series->pen().widthF());
198 pen.setWidthF(2);
206 item->setLinePen(series->pen());
199 series->setPen(pen);
207 }
200 }
208
209 // QColor color = m_seriesColors.at(index % m_seriesColors.size());
210 // TODO: define alpha in the theme? or in the series?
211 //color.setAlpha(120);
212
213 // QBrush brush(color, Qt::SolidPattern);
214 // presenter->m_markerBrush = brush;
215
216 // QPen pen(brush, 3);
217 // pen.setColor(color);
218 // presenter->m_markerPen = pen;
219 }
201 }
220
202
221 void ChartTheme::decorate(QChartAxis* axis, QChart* parent)
203 void ChartTheme::decorate(QChartAxis* axis,bool axisX)
222 {
204 {
223 Q_ASSERT(axis);
224 Q_ASSERT(parent);
225
226 if (axis->isAxisVisible()) {
205 if (axis->isAxisVisible()) {
227 axis->setLabelsBrush(m_axisLabelBrush);
206 axis->setLabelsBrush(m_axisLabelBrush);
228 axis->setLabelsPen(m_axisLabelPen);
207 axis->setLabelsPen(m_axisLabelPen);
229 // TODO: check the axis type (x or y) should define whether to show the shades or not
208 // TODO: check the axis type (x or y) should define whether to show the shades or not
230 if (m_backgroundShades == BackgroundShadesBoth
209 if (m_backgroundShades == BackgroundShadesBoth
231 || (m_backgroundShades == BackgroundShadesVertical && parent->axisX() == axis)
210 || (m_backgroundShades == BackgroundShadesVertical && axisX)
232 || (m_backgroundShades == BackgroundShadesHorizontal && parent->axisY() == axis)) {
211 || (m_backgroundShades == BackgroundShadesHorizontal && !axisX)) {
233 axis->setShadesPen(m_backgroundShadesPen);
212 axis->setShadesPen(m_backgroundShadesPen);
234 axis->setShadesBrush(m_backgroundShadesBrush);
213 axis->setShadesBrush(m_backgroundShadesBrush);
235 } else {
214 } else {
@@ -48,12 +48,12 public:
48 void decorate(BarPresenter* item, QBarSeries* series, int index);
48 void decorate(BarPresenter* item, QBarSeries* series, int index);
49 void decorate(StackedBarPresenter* item, QStackedBarSeries* series, int index);
49 void decorate(StackedBarPresenter* item, QStackedBarSeries* series, int index);
50 void decorate(PercentBarPresenter* item, QPercentBarSeries* series, int index);
50 void decorate(PercentBarPresenter* item, QPercentBarSeries* series, int index);
51 void decorate(LineChartItem* item, QLineSeries* series, int index);
51 void decorate(QLineSeries* series, int index);
52 void decorate(AreaChartItem* item, QAreaSeries* series, int index);
52 void decorate(QAreaSeries* series, int index);
53 void decorate(ScatterChartItem* presenter, QScatterSeries* series, int index);
53 void decorate(QScatterSeries* series, int index);
54 void decorate(PiePresenter* item, QPieSeries* series, int index);
54 void decorate(PiePresenter* item, QPieSeries* series, int index);
55 void decorate(SplineChartItem* presenter, QSplineSeries* series, int index);
55 void decorate(QSplineSeries* series, int index);
56 void decorate(QChartAxis* axis, QChart* parent);
56 void decorate(QChartAxis* axis, bool axisX);
57
57
58 public: // utils
58 public: // utils
59 void generateSeriesGradients();
59 void generateSeriesGradients();
@@ -53,17 +53,12 void SplineChartItem::setLayout(QVector<QPointF>& points)
53 XYChartItem::setLayout(points);
53 XYChartItem::setLayout(points);
54 }
54 }
55
55
56 void SplineChartItem::setLinePen(const QPen& pen)
57 {
58 m_pen = pen;
59 }
60
61 //handlers
56 //handlers
62
57
63 void SplineChartItem::handleUpdated()
58 void SplineChartItem::handleUpdated()
64 {
59 {
65 //m_items.setVisible(m_series->pointsVisible());
60 //m_items.setVisible(m_series->pointsVisible());
66 setLinePen(m_series->pen());
61 m_pen = m_series->pen();
67 update();
62 update();
68 }
63 }
69
64
@@ -18,7 +18,6 public:
18 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
18 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
19 QPainterPath shape() const;
19 QPainterPath shape() const;
20
20
21 void setLinePen(const QPen& pen);
22 void setPointsVisible(bool visible);
21 void setPointsVisible(bool visible);
23
22
24 public slots:
23 public slots:
General Comments 0
You need to be logged in to leave comments. Login now