##// END OF EJS Templates
Fixes header guard style issues
Michal Klocek -
r969:db6eae90aaea
parent child
Show More
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef AXISANIMATIONITEM_H_
21 #ifndef AXISANIMATION_H
22 #define AXISANIMATIONITEM_H_
22 #define AXISANIMATION_H
23
23
24 #include "axis_p.h"
24 #include "axis_p.h"
25 #include "chartanimation_p.h"
25 #include "chartanimation_p.h"
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef BARANIMATION_P_H_
21 #ifndef BARANIMATION_P_H
22 #define BARANIMATION_P_H_
22 #define BARANIMATION_P_H
23
23
24 #include "chartanimation_p.h"
24 #include "chartanimation_p.h"
25 #include "barchartitem_p.h"
25 #include "barchartitem_p.h"
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef CHARTANIMATION_H_
21 #ifndef CHARTANIMATION_H
22 #define CHARTANIMATION_H_
22 #define CHARTANIMATION_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include <QVariantAnimation>
25 #include <QVariantAnimation>
@@ -18,8 +18,9
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef CHARTANIMATOR_P_H_
21 #ifndef CHARTANIMATOR_P_H
22 #define CHARTANIMATOR_P_H_
22 #define CHARTANIMATOR_P_H
23
23 #include "qchartglobal.h"
24 #include "qchartglobal.h"
24 #include "chartanimation_p.h"
25 #include "chartanimation_p.h"
25 #include "piechartitem_p.h"
26 #include "piechartitem_p.h"
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef PIEANIMATION_P_H_
21 #ifndef PIEANIMATION_P_H
22 #define PIEANIMATION_P_H_
22 #define PIEANIMATION_P_H
23
23
24 #include "chartanimation_p.h"
24 #include "chartanimation_p.h"
25 #include "piechartitem_p.h"
25 #include "piechartitem_p.h"
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef PIESLICEANIMATION_P_H_
21 #ifndef PIESLICEANIMATION_P_H
22 #define PIESLICEANIMATION_P_H_
22 #define PIESLICEANIMATION_P_H
23
23
24 #include "piechartitem_p.h"
24 #include "piechartitem_p.h"
25 #include <QVariantAnimation>
25 #include <QVariantAnimation>
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef SPLINEANIMATION_P_H_
21 #ifndef SPLINEANIMATION_P_H
22 #define SPLINEANIMATION_P_H_
22 #define SPLINEANIMATION_P_H
23 #include "chartanimation_p.h"
23 #include "chartanimation_p.h"
24 #include <QPointF>
24 #include <QPointF>
25
25
@@ -18,8 +18,9
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef XYCHARTANIMATION_P_H_
21 #ifndef XYANIMATION_P_H
22 #define XYCHARTANIMATION_P_H_
22 #define XYANIMATION_P_H
23
23 #include "chartanimation_p.h"
24 #include "chartanimation_p.h"
24 #include <QPointF>
25 #include <QPointF>
25
26
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef QAREASERIES_H_
21 #ifndef QAREASERIES_H
22 #define QAREASERIES_H_
22 #define QAREASERIES_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <qseries.h>
25 #include <qseries.h>
@@ -27,8 +27,8
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QAREASERIES_P_H_
30 #ifndef QAREASERIES_P_H
31 #define QAREASERIES_P_H_
31 #define QAREASERIES_P_H
32
32
33 #include "qseries_p.h"
33 #include "qseries_p.h"
34
34
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef AXISITEM_H_
21 #ifndef AXIS_H
22 #define AXISITEM_H_
22 #define AXIS_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include "chart_p.h"
25 #include "chart_p.h"
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef QCHARTAXIS_H_
21 #ifndef QCHARTAXIS_H
22 #define QCHARTAXIS_H_
22 #define QCHARTAXIS_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <qchartaxiscategories.h>
25 #include <qchartaxiscategories.h>
@@ -27,8 +27,8
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QCHARTAXIS_P_H_
30 #ifndef QCHARTAXIS_P_H
31 #define QCHARTAXIS_P_H_
31 #define QCHARTAXIS_P_H
32
32
33 #include "qchartaxis.h"
33 #include "qchartaxis.h"
34
34
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef QCHARTAXISCATEGORIES_H_
21 #ifndef QCHARTAXISCATEGORIES_H
22 #define QCHARTAXISCATEGORIES_H_
22 #define QCHARTAXISCATEGORIES_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <qbarseries.h>
25 #include <qbarseries.h>
@@ -27,8 +27,8
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QCHARTAXISCATEGORIES_P_H_
30 #ifndef QCHARTAXISCATEGORIES_P_H
31 #define QCHARTAXISCATEGORIES_P_H_
31 #define QCHARTAXISCATEGORIES_P_H
32
32
33 #include "qchartaxiscategories.h"
33 #include "qchartaxiscategories.h"
34
34
@@ -18,11 +18,11
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "barchartmodel_p.h"
22 #include "qbarset.h"
21 #include <limits.h>
23 #include <limits.h>
22 #include <QVector>
24 #include <QVector>
23 #include <QDebug>
25 #include <QDebug>
24 #include "barchartmodel_p.h"
25 #include "qbarset.h"
26
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
28
@@ -195,4 +195,4 QString BarChartModel::categoryName(int category)
195
195
196 #include "moc_barchartmodel_p.cpp"
196 #include "moc_barchartmodel_p.cpp"
197
197
198 QTCOMMERCIALCHART_END_NAMESPACE
198 QTCOMMERCIALCHART_END_NAMESPACE No newline at end of file
@@ -27,8 +27,8
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QPERCENTBARSERIES_P_H_
30 #ifndef QPERCENTBARSERIES_P_H
31 #define QPERCENTBARSERIES_P_H_
31 #define QPERCENTBARSERIES_P_H
32
32
33 #include "qbarseries_p.h"
33 #include "qbarseries_p.h"
34 #include "domain_p.h"
34 #include "domain_p.h"
@@ -27,8 +27,8
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QSTACKEDBARSERIES_P_H_
30 #ifndef QSTACKEDBARSERIES_P_H
31 #define QSTACKEDBARSERIES_P_H_
31 #define QSTACKEDBARSERIES_P_H
32
32
33 #include "qbarseries_p.h"
33 #include "qbarseries_p.h"
34 #include "domain_p.h"
34 #include "domain_p.h"
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef CHART_H_
21 #ifndef CHART_H
22 #define CHART_H_
22 #define CHART_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include <QRect>
25 #include <QRect>
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef CHARTBACKGROUND_H_
21 #ifndef CHARTBACKGROUND_H
22 #define CHARTBACKGROUND_H_
22 #define CHARTBACKGROUND_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include <QGraphicsRectItem>
25 #include <QGraphicsRectItem>
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef CHARTCONFIG_H_
21 #ifndef CHARTCONFIG_H
22 #define CHARTCONFIG_H_
22 #define CHARTCONFIG_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #ifdef Q_CC_MSVC
25 #ifdef Q_CC_MSVC
@@ -27,8 +27,8
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef CHARTDATASET_P_H_
30 #ifndef CHARTDATASET_P_H
31 #define CHARTDATASET_P_H_
31 #define CHARTDATASET_P_H
32
32
33 #include "qseries.h"
33 #include "qseries.h"
34 #include "domain_p.h"
34 #include "domain_p.h"
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef CHARTITEM_H_
21 #ifndef CHARTITEM_H
22 #define CHARTITEM_H_
22 #define CHARTITEM_H
23
23
24 #include "chart_p.h"
24 #include "chart_p.h"
25 #include "chartpresenter_p.h"
25 #include "chartpresenter_p.h"
@@ -1,27 +1,26
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20 #include "chartpresenter_p.h"
21 #include "qchart.h"
21 #include "qchart.h"
22 #include "qchart_p.h"
22 #include "qchart_p.h"
23 #include "qchartaxis.h"
23 #include "qchartaxis.h"
24 #include "chartpresenter_p.h"
25 #include "chartdataset_p.h"
24 #include "chartdataset_p.h"
26 #include "charttheme_p.h"
25 #include "charttheme_p.h"
27 #include "chartanimator_p.h"
26 #include "chartanimator_p.h"
@@ -33,26 +32,26
33 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32 QTCOMMERCIALCHART_BEGIN_NAMESPACE
34
33
35 ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart),
34 ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart),
36 m_chart(chart),
35 m_chart(chart),
37 m_animator(0),
36 m_animator(0),
38 m_dataset(dataset),
37 m_dataset(dataset),
39 m_chartTheme(0),
38 m_chartTheme(0),
40 m_chartRect(QRectF(QPoint(0,0),m_chart->size())),
39 m_chartRect(QRectF(QPoint(0,0),m_chart->size())),
41 m_options(QChart::NoAnimation),
40 m_options(QChart::NoAnimation),
42 m_minLeftMargin(0),
41 m_minLeftMargin(0),
43 m_minBottomMargin(0),
42 m_minBottomMargin(0),
44 m_backgroundItem(0),
43 m_backgroundItem(0),
45 m_titleItem(0),
44 m_titleItem(0),
46 m_marginBig(60),
45 m_marginBig(60),
47 m_marginSmall(20),
46 m_marginSmall(20),
48 m_marginTiny(10),
47 m_marginTiny(10),
49 m_chartMargins(QRect(m_marginBig,m_marginBig,0,0))
48 m_chartMargins(QRect(m_marginBig,m_marginBig,0,0))
50 {
49 {
51 }
50 }
52
51
53 ChartPresenter::~ChartPresenter()
52 ChartPresenter::~ChartPresenter()
54 {
53 {
55 delete m_chartTheme;
54 delete m_chartTheme;
56 }
55 }
57
56
58 void ChartPresenter::setGeometry(const QRectF& rect)
57 void ChartPresenter::setGeometry(const QRectF& rect)
@@ -65,23 +64,23 void ChartPresenter::setGeometry(const QRectF& rect)
65 void ChartPresenter::setMinimumMarginWidth(Axis* axis, qreal width)
64 void ChartPresenter::setMinimumMarginWidth(Axis* axis, qreal width)
66 {
65 {
67 switch(axis->axisType()){
66 switch(axis->axisType()){
68 case Axis::X_AXIS:
67 case Axis::X_AXIS:
69 {
68 {
70 if(width>m_chartRect.width()+ m_chartMargins.left()) {
69 if(width>m_chartRect.width()+ m_chartMargins.left()) {
71 m_minLeftMargin= width - m_chartRect.width();
70 m_minLeftMargin= width - m_chartRect.width();
72 updateLayout();
71 updateLayout();
73 }
74 break;
75 }
72 }
76 case Axis::Y_AXIS:
73 break;
77 {
74 }
75 case Axis::Y_AXIS:
76 {
78
77
79 if(m_minLeftMargin!=width){
78 if(m_minLeftMargin!=width){
80 m_minLeftMargin= width;
79 m_minLeftMargin= width;
81 updateLayout();
80 updateLayout();
82 }
83 break;
84 }
81 }
82 break;
83 }
85
84
86 }
85 }
87 }
86 }
@@ -89,23 +88,23 void ChartPresenter::setMinimumMarginWidth(Axis* axis, qreal width)
89 void ChartPresenter::setMinimumMarginHeight(Axis* axis, qreal height)
88 void ChartPresenter::setMinimumMarginHeight(Axis* axis, qreal height)
90 {
89 {
91 switch(axis->axisType()){
90 switch(axis->axisType()){
92 case Axis::X_AXIS:
91 case Axis::X_AXIS:
93 {
92 {
94 if(m_minBottomMargin!=height) {
93 if(m_minBottomMargin!=height) {
95 m_minBottomMargin= height;
94 m_minBottomMargin= height;
96 updateLayout();
95 updateLayout();
97 }
98 break;
99 }
96 }
100 case Axis::Y_AXIS:
97 break;
101 {
98 }
99 case Axis::Y_AXIS:
100 {
102
101
103 if(height>m_chartMargins.bottom()+m_chartRect.height()){
102 if(height>m_chartMargins.bottom()+m_chartRect.height()){
104 m_minBottomMargin= height - m_chartRect.height();
103 m_minBottomMargin= height - m_chartRect.height();
105 updateLayout();
104 updateLayout();
106 }
107 break;
108 }
105 }
106 break;
107 }
109
108
110 }
109 }
111 }
110 }
@@ -149,14 +148,14 void ChartPresenter::handleAxisRemoved(QChartAxis* axis)
149
148
150 void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain)
149 void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain)
151 {
150 {
152 Chart *item = series->d_ptr->createGraphics(this);
151 Chart *item = series->d_ptr->createGraphics(this);
153 Q_ASSERT(item);
152 Q_ASSERT(item);
154 QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF)));
153 QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF)));
155 QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),item,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal)));
154 QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),item,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal)));
156 //initialize
155 //initialize
157 item->handleDomainChanged(domain->minX(),domain->maxX(),domain->minY(),domain->maxY());
156 item->handleDomainChanged(domain->minX(),domain->maxX(),domain->minY(),domain->maxY());
158 if(m_chartRect.isValid()) item->handleGeometryChanged(m_chartRect);
157 if(m_chartRect.isValid()) item->handleGeometryChanged(m_chartRect);
159 m_chartItems.insert(series,item);
158 m_chartItems.insert(series,item);
160 }
159 }
161
160
162 void ChartPresenter::handleSeriesRemoved(QSeries* series)
161 void ChartPresenter::handleSeriesRemoved(QSeries* series)
@@ -166,19 +165,19 void ChartPresenter::handleSeriesRemoved(QSeries* series)
166 if(m_animator) {
165 if(m_animator) {
167 //small hack to handle area animations
166 //small hack to handle area animations
168 if(series->type()==QSeries::SeriesTypeArea){
167 if(series->type()==QSeries::SeriesTypeArea){
169 QAreaSeries* areaSeries = static_cast<QAreaSeries*>(series);
168 QAreaSeries* areaSeries = static_cast<QAreaSeries*>(series);
170 AreaChartItem* area = static_cast<AreaChartItem*>(item);
169 AreaChartItem* area = static_cast<AreaChartItem*>(item);
171 m_animator->removeAnimation(area->upperLineItem());
170 m_animator->removeAnimation(area->upperLineItem());
172 if(areaSeries->lowerSeries()) m_animator->removeAnimation(area->lowerLineItem());
171 if(areaSeries->lowerSeries()) m_animator->removeAnimation(area->lowerLineItem());
173 }else
172 }else
174 m_animator->removeAnimation(item);
173 m_animator->removeAnimation(item);
175 }
174 }
176 delete item;
175 delete item;
177 }
176 }
178
177
179 void ChartPresenter::setTheme(QChart::ChartTheme theme,bool force)
178 void ChartPresenter::setTheme(QChart::ChartTheme theme,bool force)
180 {
179 {
181 if(m_chartTheme && m_chartTheme->id() == theme) return;
180 if(m_chartTheme && m_chartTheme->id() == theme) return;
182 delete m_chartTheme;
181 delete m_chartTheme;
183 m_chartTheme = ChartTheme::createTheme(theme);
182 m_chartTheme = ChartTheme::createTheme(theme);
184 m_chartTheme->setForced(force);
183 m_chartTheme->setForced(force);
@@ -208,75 +207,75 void ChartPresenter::setAnimationOptions(QChart::AnimationOptions options)
208
207
209 void ChartPresenter::resetAllElements()
208 void ChartPresenter::resetAllElements()
210 {
209 {
211 QList<QChartAxis*> axisList = m_axisItems.uniqueKeys();
210 QList<QChartAxis*> axisList = m_axisItems.uniqueKeys();
212 QList<QSeries*> seriesList = m_chartItems.uniqueKeys();
211 QList<QSeries*> seriesList = m_chartItems.uniqueKeys();
213
212
214 foreach(QChartAxis* axis, axisList) {
213 foreach(QChartAxis* axis, axisList) {
215 handleAxisRemoved(axis);
214 handleAxisRemoved(axis);
216 handleAxisAdded(axis,m_dataset->domain(axis));
215 handleAxisAdded(axis,m_dataset->domain(axis));
217 }
216 }
218 foreach(QSeries* series, seriesList) {
217 foreach(QSeries* series, seriesList) {
219 handleSeriesRemoved(series);
218 handleSeriesRemoved(series);
220 handleSeriesAdded(series,m_dataset->domain(series));
219 handleSeriesAdded(series,m_dataset->domain(series));
221 }
220 }
222 }
221 }
223
222
224 void ChartPresenter::zoomIn()
223 void ChartPresenter::zoomIn()
225 {
224 {
226 QRectF rect = chartGeometry();
225 QRectF rect = chartGeometry();
227 rect.setWidth(rect.width()/2);
226 rect.setWidth(rect.width()/2);
228 rect.setHeight(rect.height()/2);
227 rect.setHeight(rect.height()/2);
229 rect.moveCenter(chartGeometry().center());
228 rect.moveCenter(chartGeometry().center());
230 zoomIn(rect);
229 zoomIn(rect);
231 }
230 }
232
231
233 void ChartPresenter::zoomIn(const QRectF& rect)
232 void ChartPresenter::zoomIn(const QRectF& rect)
234 {
233 {
235 QRectF r = rect.normalized();
234 QRectF r = rect.normalized();
236 r.translate(-m_chartMargins.topLeft());
235 r.translate(-m_chartMargins.topLeft());
237 if(m_animator) {
236 if(m_animator) {
238
237
239 QPointF point(r.center().x()/chartGeometry().width(),r.center().y()/chartGeometry().height());
238 QPointF point(r.center().x()/chartGeometry().width(),r.center().y()/chartGeometry().height());
240 m_animator->setState(ChartAnimator::ZoomInState,point);
239 m_animator->setState(ChartAnimator::ZoomInState,point);
241 }
240 }
242 m_dataset->zoomInDomain(r,chartGeometry().size());
241 m_dataset->zoomInDomain(r,chartGeometry().size());
243 if(m_animator) {
242 if(m_animator) {
244 m_animator->setState(ChartAnimator::ShowState);
243 m_animator->setState(ChartAnimator::ShowState);
245 }
244 }
246 }
245 }
247
246
248 void ChartPresenter::zoomOut()
247 void ChartPresenter::zoomOut()
249 {
248 {
250 if(m_animator)
249 if(m_animator)
251 {
250 {
252 m_animator->setState(ChartAnimator::ZoomOutState);
251 m_animator->setState(ChartAnimator::ZoomOutState);
253 }
252 }
254
253
255 QSizeF size = chartGeometry().size();
254 QSizeF size = chartGeometry().size();
256 QRectF rect = chartGeometry();
255 QRectF rect = chartGeometry();
257 rect.translate(-m_chartMargins.topLeft());
256 rect.translate(-m_chartMargins.topLeft());
258 m_dataset->zoomOutDomain(rect.adjusted(size.width()/4,size.height()/4,-size.width()/4,-size.height()/4),size);
257 m_dataset->zoomOutDomain(rect.adjusted(size.width()/4,size.height()/4,-size.width()/4,-size.height()/4),size);
259 //m_dataset->zoomOutDomain(m_zoomStack[m_zoomIndex-1],geometry().size());
258 //m_dataset->zoomOutDomain(m_zoomStack[m_zoomIndex-1],geometry().size());
260
259
261 if(m_animator){
260 if(m_animator){
262 m_animator->setState(ChartAnimator::ShowState);
261 m_animator->setState(ChartAnimator::ShowState);
263 }
262 }
264 }
263 }
265
264
266 void ChartPresenter::scroll(int dx,int dy)
265 void ChartPresenter::scroll(int dx,int dy)
267 {
266 {
268 if(m_animator){
267 if(m_animator){
269 if(dx<0) m_animator->setState(ChartAnimator::ScrollLeftState,QPointF());
268 if(dx<0) m_animator->setState(ChartAnimator::ScrollLeftState,QPointF());
270 if(dx>0) m_animator->setState(ChartAnimator::ScrollRightState,QPointF());
269 if(dx>0) m_animator->setState(ChartAnimator::ScrollRightState,QPointF());
271 if(dy<0) m_animator->setState(ChartAnimator::ScrollUpState,QPointF());
270 if(dy<0) m_animator->setState(ChartAnimator::ScrollUpState,QPointF());
272 if(dy>0) m_animator->setState(ChartAnimator::ScrollDownState,QPointF());
271 if(dy>0) m_animator->setState(ChartAnimator::ScrollDownState,QPointF());
273 }
272 }
274
273
275 m_dataset->scrollDomain(dx,dy,chartGeometry().size());
274 m_dataset->scrollDomain(dx,dy,chartGeometry().size());
276
275
277 if(m_animator){
276 if(m_animator){
278 m_animator->setState(ChartAnimator::ShowState);
277 m_animator->setState(ChartAnimator::ShowState);
279 }
278 }
280 }
279 }
281
280
282 QChart::AnimationOptions ChartPresenter::animationOptions() const
281 QChart::AnimationOptions ChartPresenter::animationOptions() const
@@ -311,41 +310,41 void ChartPresenter::updateLayout()
311 // Reserve some space for legend
310 // Reserve some space for legend
312 switch (legend->alignment()) {
311 switch (legend->alignment()) {
313
312
314 case QLegend::AlignmentTop: {
313 case QLegend::AlignmentTop: {
315 int ledgendSize = legend->minHeight();
314 int ledgendSize = legend->minHeight();
316 int topPadding = 2*m_marginTiny + titleSize.height() + ledgendSize + m_marginTiny;
315 int topPadding = 2*m_marginTiny + titleSize.height() + ledgendSize + m_marginTiny;
317 m_chartMargins = QRect(QPoint(m_chartMargins.left(),topPadding),QPoint(m_chartMargins.right(),m_chartMargins.bottom()));
316 m_chartMargins = QRect(QPoint(m_chartMargins.left(),topPadding),QPoint(m_chartMargins.right(),m_chartMargins.bottom()));
318 m_legendMargins = QRect(QPoint(m_chartMargins.left(),topPadding - (ledgendSize + m_marginTiny)),QPoint(m_chartMargins.right(),m_rect.height()-topPadding + m_marginTiny));
317 m_legendMargins = QRect(QPoint(m_chartMargins.left(),topPadding - (ledgendSize + m_marginTiny)),QPoint(m_chartMargins.right(),m_rect.height()-topPadding + m_marginTiny));
319 titlePadding = m_marginTiny + m_marginTiny;
318 titlePadding = m_marginTiny + m_marginTiny;
320 break;
319 break;
321 }
320 }
322 case QLegend::AlignmentBottom: {
321 case QLegend::AlignmentBottom: {
323 int ledgendSize = legend->minHeight();
322 int ledgendSize = legend->minHeight();
324 int bottomPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny + m_minBottomMargin;
323 int bottomPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny + m_minBottomMargin;
325 m_chartMargins = QRect(QPoint(m_chartMargins.left(),m_chartMargins.top()),QPoint(m_chartMargins.right(),bottomPadding));
324 m_chartMargins = QRect(QPoint(m_chartMargins.left(),m_chartMargins.top()),QPoint(m_chartMargins.right(),bottomPadding));
326 m_legendMargins = QRect(QPoint(m_chartMargins.left(),m_rect.height()-bottomPadding + m_marginTiny + m_minBottomMargin),QPoint(m_chartMargins.right(),m_marginTiny + m_marginSmall));
325 m_legendMargins = QRect(QPoint(m_chartMargins.left(),m_rect.height()-bottomPadding + m_marginTiny + m_minBottomMargin),QPoint(m_chartMargins.right(),m_marginTiny + m_marginSmall));
327 titlePadding = m_chartMargins.top()/2;
326 titlePadding = m_chartMargins.top()/2;
328 break;
327 break;
329 }
328 }
330 case QLegend::AlignmentLeft: {
329 case QLegend::AlignmentLeft: {
331 int ledgendSize = legend->minWidth();
330 int ledgendSize = legend->minWidth();
332 int leftPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny + m_minLeftMargin;
331 int leftPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny + m_minLeftMargin;
333 m_chartMargins = QRect(QPoint(leftPadding,m_chartMargins.top()),QPoint(m_chartMargins.right(),m_chartMargins.bottom()));
332 m_chartMargins = QRect(QPoint(leftPadding,m_chartMargins.top()),QPoint(m_chartMargins.right(),m_chartMargins.bottom()));
334 m_legendMargins = QRect(QPoint(m_marginTiny + m_marginSmall,m_chartMargins.top()),QPoint(m_rect.width()-leftPadding + m_marginTiny + m_minLeftMargin,m_chartMargins.bottom()));
333 m_legendMargins = QRect(QPoint(m_marginTiny + m_marginSmall,m_chartMargins.top()),QPoint(m_rect.width()-leftPadding + m_marginTiny + m_minLeftMargin,m_chartMargins.bottom()));
335 titlePadding = m_chartMargins.top()/2;
334 titlePadding = m_chartMargins.top()/2;
336 break;
335 break;
337 }
336 }
338 case QLegend::AlignmentRight: {
337 case QLegend::AlignmentRight: {
339 int ledgendSize = legend->minWidth();
338 int ledgendSize = legend->minWidth();
340 int rightPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny;
339 int rightPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny;
341 m_chartMargins = QRect(QPoint(m_chartMargins.left(),m_chartMargins.top()),QPoint(rightPadding,m_chartMargins.bottom()));
340 m_chartMargins = QRect(QPoint(m_chartMargins.left(),m_chartMargins.top()),QPoint(rightPadding,m_chartMargins.bottom()));
342 m_legendMargins = QRect(QPoint(m_rect.width()- rightPadding+ m_marginTiny ,m_chartMargins.top()),QPoint(m_marginTiny + m_marginSmall,m_chartMargins.bottom()));
341 m_legendMargins = QRect(QPoint(m_rect.width()- rightPadding+ m_marginTiny ,m_chartMargins.top()),QPoint(m_marginTiny + m_marginSmall,m_chartMargins.bottom()));
343 titlePadding = m_chartMargins.top()/2;
342 titlePadding = m_chartMargins.top()/2;
344 break;
343 break;
345 }
344 }
346 default: {
345 default: {
347 break;
346 break;
348 }
347 }
349 }
348 }
350 }
349 }
351
350
@@ -372,10 +371,10 void ChartPresenter::updateLayout()
372
371
373 legend->setGeometry(m_rect.adjusted(m_legendMargins.left(),m_legendMargins.top(),-m_legendMargins.right(),-m_legendMargins.bottom()));
372 legend->setGeometry(m_rect.adjusted(m_legendMargins.left(),m_legendMargins.top(),-m_legendMargins.right(),-m_legendMargins.bottom()));
374
373
375 if(m_chartRect!=chartRect){
374 if(m_chartRect!=chartRect){
376 m_chartRect=chartRect;
375 m_chartRect=chartRect;
377 emit geometryChanged(m_chartRect);
376 emit geometryChanged(m_chartRect);
378 }
377 }
379
378
380
379
381 }
380 }
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef CHARTPRESENTER_H_
21 #ifndef CHARTPRESENTER_H
22 #define CHARTPRESENTER_H_
22 #define CHARTPRESENTER_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include "chartbackground_p.h" //TODO fix me
25 #include "chartbackground_p.h" //TODO fix me
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef DOMAIN_H_
21 #ifndef DOMAIN_H
22 #define DOMAIN_H_
22 #define DOMAIN_H
23 #include "qchartglobal.h"
23 #include "qchartglobal.h"
24 #include <QRectF>
24 #include <QRectF>
25 #include <QSizeF>
25 #include <QSizeF>
@@ -28,8 +28,8
28 // We mean it.
28 // We mean it.
29
29
30
30
31 #ifndef LEGENDSCROLLER_P_H_
31 #ifndef LEGENDSCROLLER_P_H
32 #define LEGENDSCROLLER_P_H_
32 #define LEGENDSCROLLER_P_H
33
33
34 #include "qlegend.h"
34 #include "qlegend.h"
35 #include "scroller_p.h"
35 #include "scroller_p.h"
@@ -27,8 +27,8
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QLEGEND_P_H_
30 #ifndef QLEGEND_P_H
31 #define QLEGEND_P_H_
31 #define QLEGEND_P_H
32
32
33 #include "qlegend.h"
33 #include "qlegend.h"
34
34
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef QLINESERIES_H_
21 #ifndef QLINESERIES_H
22 #define QLINESERIES_H_
22 #define QLINESERIES_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <qxyseries.h>
25 #include <qxyseries.h>
@@ -33,12 +33,12 class QTCOMMERCIALCHART_EXPORT QLineSeries : public QXYSeries
33 {
33 {
34 public:
34 public:
35 explicit QLineSeries(QObject *parent=0);
35 explicit QLineSeries(QObject *parent=0);
36 ~QLineSeries();
36 ~QLineSeries();
37
37
38 QSeries::QSeriesType type() const;
38 QSeries::QSeriesType type() const;
39
39
40 protected:
40 protected:
41 QLineSeries(QLineSeriesPrivate &d,QObject *parent = 0);
41 QLineSeries(QLineSeriesPrivate &d,QObject *parent = 0);
42
42
43 private:
43 private:
44 Q_DECLARE_PRIVATE(QLineSeries);
44 Q_DECLARE_PRIVATE(QLineSeries);
@@ -27,8 +27,8
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QLINESERIES_P_H_
30 #ifndef QLINESERIES_P_H
31 #define QLINESERIES_P_H_
31 #define QLINESERIES_P_H
32
32
33 #include "qxyseries_p.h"
33 #include "qxyseries_p.h"
34
34
@@ -1,219 +1,218
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qchartview.h"
21 #include "qchartview.h"
22 #include "qchart_p.h"
22 #include "qchartview_p.h"
23 #include "qchartview_p.h"
23 #include "qchart_p.h"
24 #include <QGraphicsScene>
24 #include <QGraphicsScene>
25 #include <QRubberBand>
25 #include <QRubberBand>
26
26
27
27 /*!
28 /*!
28 \enum QChartView::RubberBand
29 \enum QChartView::RubberBand
29
30
30 This enum describes the different types of rubber bands that can be used for zoom rect selection
31 This enum describes the different types of rubber bands that can be used for zoom rect selection
31
32
32 \value NoRubberBand
33 \value NoRubberBand
33 \value VerticalRubberBand
34 \value VerticalRubberBand
34 \value HorizonalRubberBand
35 \value HorizonalRubberBand
35 \value RectangleRubberBand
36 \value RectangleRubberBand
36 */
37 */
37
38
38 /*!
39 /*!
39 \class QChartView
40 \class QChartView
40 \brief Standalone charting widget.
41 \brief Standalone charting widget.
41
42
42 QChartView is a standalone widget that can display charts. It does not require separate
43 QChartView is a standalone widget that can display charts. It does not require separate
43 QGraphicsScene to work. It manages the graphical representation of different types of
44 QGraphicsScene to work. It manages the graphical representation of different types of
44 QChartSeries and other chart related objects like QChartAxis and QChartLegend. If you want to
45 QChartSeries and other chart related objects like QChartAxis and QChartLegend. If you want to
45 display a chart in your existing QGraphicsScene, you can use the QChart class instead.
46 display a chart in your existing QGraphicsScene, you can use the QChart class instead.
46
47
47 \sa QChart
48 \sa QChart
48 */
49 */
49
50
50 QTCOMMERCIALCHART_BEGIN_NAMESPACE
51 QTCOMMERCIALCHART_BEGIN_NAMESPACE
51
52
52 /*!
53 /*!
53 Constructs a chartView object which is a child of a\a parent.
54 Constructs a chartView object which is a child of a\a parent.
54 */
55 */
55 QChartView::QChartView(QChart *chart,QWidget *parent) :
56 QChartView::QChartView(QChart *chart,QWidget *parent) :
56 QGraphicsView(parent),
57 QGraphicsView(parent),
57 d_ptr(new QChartViewPrivate())
58 d_ptr(new QChartViewPrivate())
58 {
59 {
59 Q_ASSERT(chart);
60 Q_ASSERT(chart);
60 d_ptr->m_scene = new QGraphicsScene(this);
61 d_ptr->m_scene = new QGraphicsScene(this);
61 d_ptr->m_chart = chart;
62 d_ptr->m_chart = chart;
62 setFrameShape(QFrame::NoFrame);
63 setFrameShape(QFrame::NoFrame);
63 setBackgroundRole(QPalette::Window);
64 setBackgroundRole(QPalette::Window);
64 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
65 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
65 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
66 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
66 setScene(d_ptr->m_scene);
67 setScene(d_ptr->m_scene);
67 d_ptr->m_scene->addItem(chart);
68 d_ptr->m_scene->addItem(chart);
68 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
69 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
69 }
70 }
70
71
71
72
72 /*!
73 /*!
73 Destroys the object and it's children, like QChartSeries and QChartAxis object added to it.
74 Destroys the object and it's children, like QChartSeries and QChartAxis object added to it.
74 */
75 */
75 QChartView::~QChartView()
76 QChartView::~QChartView()
76 {
77 {
77 }
78 }
78
79
79 /*!
80 /*!
80 Returns the pointer to the associated chart
81 Returns the pointer to the associated chart
81 */
82 */
82 QChart* QChartView::chart() const
83 QChart* QChartView::chart() const
83 {
84 {
84 return d_ptr->m_chart;
85 return d_ptr->m_chart;
85 }
86 }
86
87
87 /*!
88 /*!
88 Sets the RubberBandPlicy to \a rubberBand. Selected policy determines the way zooming is performed.
89 Sets the RubberBandPlicy to \a rubberBand. Selected policy determines the way zooming is performed.
89 */
90 */
90 void QChartView::setRubberBand(const RubberBands& rubberBand)
91 void QChartView::setRubberBand(const RubberBands& rubberBand)
91 {
92 {
92 d_ptr->m_rubberBandFlags=rubberBand;
93 d_ptr->m_rubberBandFlags=rubberBand;
93
94
94 if (!d_ptr->m_rubberBandFlags) {
95 if (!d_ptr->m_rubberBandFlags) {
95 delete d_ptr->m_rubberBand;
96 delete d_ptr->m_rubberBand;
96 d_ptr->m_rubberBand=0;
97 d_ptr->m_rubberBand=0;
97 return;
98 return;
98 }
99 }
99
100
100 if (!d_ptr->m_rubberBand) {
101 if (!d_ptr->m_rubberBand) {
101 d_ptr->m_rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
102 d_ptr->m_rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
102 d_ptr->m_rubberBand->setEnabled(true);
103 d_ptr->m_rubberBand->setEnabled(true);
103 }
104 }
104 }
105 }
105
106
106 /*!
107 /*!
107 Returns the RubberBandPolicy that is currently being used by the widget.
108 Returns the RubberBandPolicy that is currently being used by the widget.
108 */
109 */
109 QChartView::RubberBands QChartView::rubberBand() const
110 QChartView::RubberBands QChartView::rubberBand() const
110 {
111 {
111 return d_ptr->m_rubberBandFlags;
112 return d_ptr->m_rubberBandFlags;
112 }
113 }
113
114
114 /*!
115 /*!
115 If Left mouse button is pressed and the RubberBandPolicy is enabled the \a event is accepted and the rubber band is displayed on the screen allowing the user to select the zoom area.
116 If Left mouse button is pressed and the RubberBandPolicy is enabled the \a event is accepted and the rubber band is displayed on the screen allowing the user to select the zoom area.
116 If different mouse button is pressed and/or the RubberBandPolicy is disabled then the \a event is passed to QGraphicsView::mousePressEvent() implementation.
117 If different mouse button is pressed and/or the RubberBandPolicy is disabled then the \a event is passed to QGraphicsView::mousePressEvent() implementation.
117 */
118 */
118 void QChartView::mousePressEvent(QMouseEvent *event)
119 void QChartView::mousePressEvent(QMouseEvent *event)
119 {
120 {
120 if(d_ptr->m_rubberBand && d_ptr->m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) {
121 if(d_ptr->m_rubberBand && d_ptr->m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) {
121
122
122 int padding = d_ptr->m_chart->margins().top();
123 int padding = d_ptr->m_chart->margins().top();
123 QRect rect(padding, padding, width() - 2 * padding, height() - 2 * padding);
124 QRect rect(padding, padding, width() - 2 * padding, height() - 2 * padding);
124
125
125 if (rect.contains(event->pos())) {
126 if (rect.contains(event->pos())) {
126 d_ptr->m_rubberBandOrigin = event->pos();
127 d_ptr->m_rubberBandOrigin = event->pos();
127 d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin, QSize()));
128 d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin, QSize()));
128 d_ptr->m_rubberBand->show();
129 d_ptr->m_rubberBand->show();
129 event->accept();
130 event->accept();
130 }
131 }
131 }
132 }
132 else {
133 else {
133 QGraphicsView::mousePressEvent(event);
134 QGraphicsView::mousePressEvent(event);
134 }
135 }
135 }
136 }
136
137
137 /*!
138 /*!
138 If RubberBand rectange specification has been initiated in pressEvent then \a event data is used to update RubberBand geometry.
139 If RubberBand rectange specification has been initiated in pressEvent then \a event data is used to update RubberBand geometry.
139 In other case the defualt QGraphicsView::mouseMoveEvent implementation is called.
140 In other case the defualt QGraphicsView::mouseMoveEvent implementation is called.
140 */
141 */
141 void QChartView::mouseMoveEvent(QMouseEvent *event)
142 void QChartView::mouseMoveEvent(QMouseEvent *event)
142 {
143 {
143 if(d_ptr->m_rubberBand && d_ptr->m_rubberBand->isVisible()) {
144 if(d_ptr->m_rubberBand && d_ptr->m_rubberBand->isVisible()) {
144 QRectF margins = d_ptr->m_chart->margins();
145 QRectF margins = d_ptr->m_chart->margins();
145 QRectF geometry = d_ptr->m_chart->geometry();
146 QRectF geometry = d_ptr->m_chart->geometry();
146 QRectF rect =geometry.adjusted(margins.left(),margins.top(),-margins.right(),-margins.bottom());
147 QRectF rect =geometry.adjusted(margins.left(),margins.top(),-margins.right(),-margins.bottom());
147 int width = event->pos().x() - d_ptr->m_rubberBandOrigin.x();
148 int width = event->pos().x() - d_ptr->m_rubberBandOrigin.x();
148 int height = event->pos().y() - d_ptr->m_rubberBandOrigin.y();
149 int height = event->pos().y() - d_ptr->m_rubberBandOrigin.y();
149 if (!d_ptr->m_rubberBandFlags.testFlag(VerticalRubberBand)) {
150 if (!d_ptr->m_rubberBandFlags.testFlag(VerticalRubberBand)) {
150 d_ptr->m_rubberBandOrigin.setY(rect.top());
151 d_ptr->m_rubberBandOrigin.setY(rect.top());
151 height = rect.height();
152 height = rect.height();
152 }
153 }
153 if (!d_ptr->m_rubberBandFlags.testFlag(HorizonalRubberBand)) {
154 if (!d_ptr->m_rubberBandFlags.testFlag(HorizonalRubberBand)) {
154 d_ptr->m_rubberBandOrigin.setX(rect.left());
155 d_ptr->m_rubberBandOrigin.setX(rect.left());
155 width= rect.width();
156 width= rect.width();
156 }
157 }
157 d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin.x(),d_ptr->m_rubberBandOrigin.y(), width,height).normalized());
158 d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin.x(),d_ptr->m_rubberBandOrigin.y(), width,height).normalized());
158 }
159 }
159 else {
160 else {
160 QGraphicsView::mouseMoveEvent(event);
161 QGraphicsView::mouseMoveEvent(event);
161 }
162 }
162 }
163 }
163
164
164 /*!
165 /*!
165 If left mouse button is release and RubberBand is enabled then \a event is accepted and the view is zoomed in to rect specified by RubberBand
166 If left mouse button is release and RubberBand is enabled then \a event is accepted and the view is zoomed in to rect specified by RubberBand
166 If it is the right mouse button \a event then RubberBand is dissmissed and zoom is canceled.
167 If it is the right mouse button \a event then RubberBand is dissmissed and zoom is canceled.
167 */
168 */
168 void QChartView::mouseReleaseEvent(QMouseEvent *event)
169 void QChartView::mouseReleaseEvent(QMouseEvent *event)
169 {
170 {
170 if(d_ptr->m_rubberBand) {
171 if(d_ptr->m_rubberBand) {
171 if (event->button() == Qt::LeftButton && d_ptr->m_rubberBand->isVisible()) {
172 if (event->button() == Qt::LeftButton && d_ptr->m_rubberBand->isVisible()) {
172 d_ptr->m_rubberBand->hide();
173 d_ptr->m_rubberBand->hide();
173 QRect rect = d_ptr->m_rubberBand->geometry();
174 QRect rect = d_ptr->m_rubberBand->geometry();
174 d_ptr->m_chart->zoomIn(rect);
175 d_ptr->m_chart->zoomIn(rect);
175 event->accept();
176 event->accept();
176 }
177 }
177
178
178 if(event->button()==Qt::RightButton){
179 if(event->button()==Qt::RightButton){
179 d_ptr->m_chart->zoomOut();
180 d_ptr->m_chart->zoomOut();
180 event->accept();
181 event->accept();
181 }
182 }
182 }
183 }
183 else {
184 else {
184 QGraphicsView::mouseReleaseEvent(event);
185 QGraphicsView::mouseReleaseEvent(event);
185 }
186 }
186 }
187 }
187
188
188 /*!
189 /*!
189 Resizes and updates the chart area using the \a event data
190 Resizes and updates the chart area using the \a event data
190 */
191 */
191 void QChartView::resizeEvent(QResizeEvent *event)
192 void QChartView::resizeEvent(QResizeEvent *event)
192 {
193 {
193 QGraphicsView::resizeEvent(event);
194 QGraphicsView::resizeEvent(event);
194 d_ptr->m_chart->resize(size());
195 d_ptr->m_chart->resize(size());
195 setMinimumSize(d_ptr->m_chart->minimumSize().toSize());
196 setMinimumSize(d_ptr->m_chart->minimumSize().toSize());
196 setSceneRect(d_ptr->m_chart->geometry());
197 setSceneRect(d_ptr->m_chart->geometry());
197 }
198 }
198
199
199 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
200 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
200
201
201 QChartViewPrivate::QChartViewPrivate():
202 QChartViewPrivate::QChartViewPrivate():
202 m_scene(0),
203 m_scene(0),
203 m_chart(0),
204 m_chart(0),
204 m_presenter(0),
205 m_presenter(0),
205 m_rubberBand(0),
206 m_rubberBand(0),
206 m_rubberBandFlags(QChartView::NoRubberBand)
207 m_rubberBandFlags(QChartView::NoRubberBand)
207 {
208 {
208
209
209 }
210 }
210
211
211 QChartViewPrivate::~QChartViewPrivate()
212 QChartViewPrivate::~QChartViewPrivate()
212 {
213 {
213
214
214 }
215 }
215
216
216 #include "moc_qchartview.cpp"
217 #include "moc_qchartview.cpp"
217
218
218 QTCOMMERCIALCHART_END_NAMESPACE
219 QTCOMMERCIALCHART_END_NAMESPACE
@@ -33,6 +33,7
33 #include "qchartview.h"
33 #include "qchartview.h"
34
34
35 class QGraphicsScene;
35 class QGraphicsScene;
36 class ChartPresenter;
36
37
37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38
39
@@ -27,8 +27,8
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QSERIES_P_H_
30 #ifndef QSERIES_P_H
31 #define QSERIES_P_H_
31 #define QSERIES_P_H
32
32
33 #include "qseries.h"
33 #include "qseries.h"
34
34
@@ -27,8 +27,8
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QSCATTERSERIES_P_H_
30 #ifndef QSCATTERSERIES_P_H
31 #define QSCATTERSERIES_P_H_
31 #define QSCATTERSERIES_P_H
32
32
33 #include "qxyseries_p.h"
33 #include "qxyseries_p.h"
34
34
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef SCATTERPRESENTER_H
21 #ifndef SCATTERCHARTITEM_H
22 #define SCATTERPRESENTER_H
22 #define SCATTERCHARTITEM_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include "xychartitem_p.h"
25 #include "xychartitem_p.h"
@@ -27,8 +27,8
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef SCROLLER_P_H_
30 #ifndef SCROLLER_P_H
31 #define SCROLLER_P_H_
31 #define SCROLLER_P_H
32
32
33 #include "qchartglobal.h"
33 #include "qchartglobal.h"
34 #include <QBasicTimer>
34 #include <QBasicTimer>
@@ -27,8 +27,8
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QSPLINESERIES_P_H_
30 #ifndef QSPLINESERIES_P_H
31 #define QSPLINESERIES_P_H_
31 #define QSPLINESERIES_P_H
32
32
33 #include "qlineseries_p.h"
33 #include "qlineseries_p.h"
34
34
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef CHARTTHEMEBLUECEICY_P_H
21 #ifndef CHARTTHEMEBLUEICY_P_H
22 #define CHARTTHEMEBLUECEICY_P_H
22 #define CHARTTHEMEBLUEICY_P_H
23
23
24 #include "charttheme_p.h"
24 #include "charttheme_p.h"
25
25
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef CHARTTHEMEHIGHLIGHT_P_H
21 #ifndef CHARTTHEMELIGHT_P_H
22 #define CHARTTHEMEHIGHLIGHT_P_H
22 #define CHARTTHEMELIGHT_P_H
23
23
24 #include "charttheme_p.h"
24 #include "charttheme_p.h"
25
25
@@ -18,8 +18,8
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef QXYSERIES_H_
21 #ifndef QXYSERIES_H
22 #define QXYSERIES_H_
22 #define QXYSERIES_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <qseries.h>
25 #include <qseries.h>
@@ -27,8 +27,8
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QXYSERIES_P_H_
30 #ifndef QXYSERIES_P_H
31 #define QXYSERIES_P_H_
31 #define QXYSERIES_P_H
32
32
33 #include "qseries_p.h"
33 #include "qseries_p.h"
34
34
General Comments 0
You need to be logged in to leave comments. Login now