1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -29,7 +29,8 Q_DECLARE_METATYPE(QVector<qreal>) | |||||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 |
|
31 | |||
32 |
AxisAnimation::AxisAnimation(ChartAxis *axis) |
|
32 | AxisAnimation::AxisAnimation(ChartAxis *axis) | |
|
33 | : ChartAnimation(axis), | |||
33 | m_axis(axis), |
|
34 | m_axis(axis), | |
34 | m_type(DefaultAnimation) |
|
35 | m_type(DefaultAnimation) | |
35 | { |
|
36 | { | |
@@ -43,19 +44,22 AxisAnimation::~AxisAnimation() | |||||
43 |
|
44 | |||
44 | void AxisAnimation::setAnimationType(Animation type) |
|
45 | void AxisAnimation::setAnimationType(Animation type) | |
45 | { |
|
46 | { | |
46 |
if (state() != QAbstractAnimation::Stopped) |
|
47 | if (state() != QAbstractAnimation::Stopped) | |
|
48 | stop(); | |||
47 | m_type=type; |
|
49 | m_type = type; | |
48 | } |
|
50 | } | |
49 |
|
51 | |||
50 | void AxisAnimation::setAnimationPoint(const QPointF& point) |
|
52 | void AxisAnimation::setAnimationPoint(const QPointF& point) | |
51 | { |
|
53 | { | |
52 |
if (state() != QAbstractAnimation::Stopped) |
|
54 | if (state() != QAbstractAnimation::Stopped) | |
|
55 | stop(); | |||
53 | m_point=point; |
|
56 | m_point = point; | |
54 | } |
|
57 | } | |
55 |
|
58 | |||
56 | void AxisAnimation::setValues(QVector<qreal> &oldLayout, QVector<qreal> &newLayout) |
|
59 | void AxisAnimation::setValues(QVector<qreal> &oldLayout, QVector<qreal> &newLayout) | |
57 | { |
|
60 | { | |
58 |
|
|
61 | if (state() != QAbstractAnimation::Stopped) | |
|
62 | stop(); | |||
59 |
|
63 | |||
60 |
|
|
64 | if (newLayout.count() == 0) | |
61 |
|
|
65 | return; | |
@@ -72,7 +76,8 void AxisAnimation::setValues(QVector<qreal> &oldLayout, QVector<qreal> &newLayo | |||||
72 | } |
|
76 | } | |
73 |
|
|
77 | break; | |
74 |
|
|
78 | case ZoomInAnimation: { | |
75 |
int index = qMin(oldLayout.count() * (m_axis->axisType() == ChartAxis::X_AXIS ? m_point.x() : (1 - m_point.y())), |
|
79 | int index = qMin(oldLayout.count() * (m_axis->axisType() == ChartAxis::X_AXIS ? m_point.x() : (1 - m_point.y())), | |
|
80 | newLayout.count() - (qreal)1.0); | |||
76 | oldLayout.resize(newLayout.count()); |
|
81 | oldLayout.resize(newLayout.count()); | |
77 |
|
82 | |||
78 | for(int i = 0; i < oldLayout.count(); i++) |
|
83 | for (int i = 0; i < oldLayout.count(); i++) | |
@@ -126,8 +131,7 QVariant AxisAnimation::interpolated(const QVariant &start, const QVariant &end, | |||||
126 |
|
131 | |||
127 |
void AxisAnimation::updateCurrentValue |
|
132 | void AxisAnimation::updateCurrentValue(const QVariant &value) | |
128 | { |
|
133 | { | |
129 | if (state() != QAbstractAnimation::Stopped)//workaround |
|
134 | if (state() != QAbstractAnimation::Stopped) { //workaround | |
130 | { |
|
|||
131 | QVector<qreal> vector = qVariantValue<QVector<qreal> >(value); |
|
135 | QVector<qreal> vector = qVariantValue<QVector<qreal> >(value); | |
132 | Q_ASSERT(vector.count() != 0); |
|
136 | Q_ASSERT(vector.count() != 0); | |
133 | m_axis->setLayout(vector); |
|
137 | m_axis->setLayout(vector); |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -26,8 +26,8 Q_DECLARE_METATYPE(QVector<QRectF>) | |||||
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 |
HorizontalBarAnimation::HorizontalBarAnimation(AbstractBarChartItem *item) |
|
29 | HorizontalBarAnimation::HorizontalBarAnimation(AbstractBarChartItem *item) | |
30 | AbstractBarAnimation(item) |
|
30 | : AbstractBarAnimation(item) | |
31 | { |
|
31 | { | |
32 | } |
|
32 | } | |
33 |
|
33 |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -102,12 +102,9 void SplineAnimation::setup(QVector<QPointF> &oldPoints, QVector<QPointF> &newPo | |||||
102 | x = m_oldSpline.first.count(); |
|
102 | x = m_oldSpline.first.count(); | |
103 | y = m_newSpline.first.count(); |
|
103 | y = m_newSpline.first.count(); | |
104 |
|
104 | |||
105 | if(x != y) |
|
105 | if (x != y) { | |
106 | { |
|
|||
107 | m_type = NewAnimation; |
|
106 | m_type = NewAnimation; | |
108 | } |
|
107 | } else if (m_type == NewAnimation) { | |
109 | else if(m_type == NewAnimation) |
|
|||
110 | { |
|
|||
111 | m_type = ReplacePointAnimation; |
|
108 | m_type = ReplacePointAnimation; | |
112 | } |
|
109 | } | |
113 |
|
110 | |||
@@ -127,11 +124,9 QVariant SplineAnimation::interpolated(const QVariant &start, const QVariant &en | |||||
127 | SplineVector result; |
|
124 | SplineVector result; | |
128 |
|
125 | |||
129 | switch (animationType()) { |
|
126 | switch (animationType()) { | |
130 |
|
||||
131 |
|
|
127 | case RemovePointAnimation: | |
132 |
|
|
128 | case AddPointAnimation: | |
133 |
|
|
129 | case ReplacePointAnimation: { | |
134 | { |
|
|||
135 | if (startPair.first.count() != endPair.first.count()) |
|
130 | if (startPair.first.count() != endPair.first.count()) | |
136 | break; |
|
131 | break; | |
137 | Q_ASSERT(startPair.first.count() * 2 - 2 == startPair.second.count()); |
|
132 | Q_ASSERT(startPair.first.count() * 2 - 2 == startPair.second.count()); | |
@@ -149,7 +144,6 QVariant SplineAnimation::interpolated(const QVariant &start, const QVariant &en | |||||
149 | y = startPair.second[i * 2 + 1].y() + ((endPair.second[i * 2 + 1].y() - startPair.second[i * 2 + 1].y()) * progress); |
|
144 | y = startPair.second[i * 2 + 1].y() + ((endPair.second[i * 2 + 1].y() - startPair.second[i * 2 + 1].y()) * progress); | |
150 | result.second << QPointF(x,y); |
|
145 | result.second << QPointF(x, y); | |
151 | } |
|
146 | } | |
152 |
|
||||
153 | } |
|
147 | } | |
154 | break; |
|
148 | break; | |
155 |
|
|
149 | case NewAnimation: { | |
@@ -188,8 +182,7 void SplineAnimation::updateState(QAbstractAnimation::State newState, QAbstractA | |||||
188 | { |
|
182 | { | |
189 | XYAnimation::updateState(newState, oldState); |
|
183 | XYAnimation::updateState(newState, oldState); | |
190 |
|
184 | |||
191 | if(oldState == QAbstractAnimation::Running && newState == QAbstractAnimation::Stopped) |
|
185 | if (oldState == QAbstractAnimation::Running && newState == QAbstractAnimation::Stopped) { | |
192 | { |
|
|||
193 | if(m_item->isDirty() && m_type==RemovePointAnimation) { |
|
186 | if (m_item->isDirty() && m_type == RemovePointAnimation) { | |
194 | if(!m_newSpline.first.isEmpty()) { |
|
187 | if (!m_newSpline.first.isEmpty()) { | |
195 | m_newSpline.first.remove(m_index); |
|
188 | m_newSpline.first.remove(m_index); | |
@@ -201,12 +194,10 void SplineAnimation::updateState(QAbstractAnimation::State newState, QAbstractA | |||||
201 | } |
|
194 | } | |
202 | } |
|
195 | } | |
203 |
|
196 | |||
204 | if(oldState == QAbstractAnimation::Stopped && newState == QAbstractAnimation::Running) |
|
197 | if (oldState == QAbstractAnimation::Stopped && newState == QAbstractAnimation::Running) { | |
205 | { |
|
198 | if (!m_valid) | |
206 | if(!m_valid) { |
|
|||
207 | stop(); |
|
199 | stop(); | |
208 |
|
|
200 | } | |
209 | } |
|
201 | } | |
210 | } |
|
|||
211 |
|
202 | |||
212 | QTCOMMERCIALCHART_END_NAMESPACE |
|
203 | QTCOMMERCIALCHART_END_NAMESPACE |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -26,7 +26,8 Q_DECLARE_METATYPE(QVector<QPointF>) | |||||
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 |
XYAnimation::XYAnimation(XYChart *item) |
|
29 | XYAnimation::XYAnimation(XYChart *item) | |
|
30 | : ChartAnimation(item), | |||
30 | m_type(NewAnimation), |
|
31 | m_type(NewAnimation), | |
31 | m_dirty(false), |
|
32 | m_dirty(false), | |
32 | m_index(-1), |
|
33 | m_index(-1), | |
@@ -77,13 +78,9 void XYAnimation::setup(const QVector<QPointF> &oldPoints, const QVector<QPointF | |||||
77 |
|
|
78 | y = m_newPoints.count(); | |
78 |
|
79 | |||
79 |
|
|
80 | if (x != y) | |
80 | { |
|
|||
81 |
|
|
81 | m_type = NewAnimation; | |
82 | } |
|
|||
83 |
|
|
82 | else if (m_type == NewAnimation) | |
84 | { |
|
|||
85 |
|
|
83 | m_type = ReplacePointAnimation; | |
86 | } |
|
|||
87 |
|
84 | |||
88 | setKeyValueAt(0.0, qVariantFromValue(m_oldPoints)); |
|
85 | setKeyValueAt(0.0, qVariantFromValue(m_oldPoints)); | |
89 | setKeyValueAt(1.0, qVariantFromValue(m_newPoints)); |
|
86 | setKeyValueAt(1.0, qVariantFromValue(m_newPoints)); | |
@@ -99,11 +96,9 QVariant XYAnimation::interpolated(const QVariant &start, const QVariant &end, q | |||||
99 |
|
96 | |||
100 | case ReplacePointAnimation: |
|
97 | case ReplacePointAnimation: | |
101 | case AddPointAnimation: |
|
98 | case AddPointAnimation: | |
102 | case RemovePointAnimation: |
|
99 | case RemovePointAnimation: { | |
103 | { |
|
100 | if (startVector.count() != endVector.count()) | |
104 | if (startVector.count() != endVector.count()){ |
|
|||
105 | break; |
|
101 | break; | |
106 | } |
|
|||
107 |
|
102 | |||
108 | for(int i = 0; i < startVector.count(); i++) { |
|
103 | for (int i = 0; i < startVector.count(); i++) { | |
109 | qreal x = startVector[i].x() + ((endVector[i].x() - startVector[i].x()) * progress); |
|
104 | qreal x = startVector[i].x() + ((endVector[i].x() - startVector[i].x()) * progress); | |
@@ -141,10 +136,10 void XYAnimation::updateCurrentValue (const QVariant &value) | |||||
141 |
|
136 | |||
142 |
void XYAnimation::updateState( |
|
137 | void XYAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) | |
143 | { |
|
138 | { | |
144 |
|
|
139 | if (oldState == QAbstractAnimation::Running && newState == QAbstractAnimation::Stopped) { | |
145 | { |
|
|||
146 |
|
|
140 | if (m_item->isDirty() && m_type == RemovePointAnimation) { | |
147 |
|
|
141 | if (!m_newPoints.isEmpty()) | |
|
142 | m_newPoints.remove(m_index); | |||
148 |
|
|
143 | m_item->setGeometryPoints(m_newPoints); | |
149 | } |
|
144 | } | |
150 | } |
|
145 | } |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -42,9 +42,8 AreaChartItem::AreaChartItem(QAreaSeries *areaSeries, ChartPresenter *presenter) | |||||
42 | { |
|
42 | { | |
43 | setZValue(ChartPresenter::LineChartZValue); |
|
43 | setZValue(ChartPresenter::LineChartZValue); | |
44 | m_upper = new AreaBoundItem(this,m_series->upperSeries(),presenter); |
|
44 | m_upper = new AreaBoundItem(this, m_series->upperSeries(), presenter); | |
45 |
if (m_series->lowerSeries()) |
|
45 | if (m_series->lowerSeries()) | |
46 | m_lower = new AreaBoundItem(this,m_series->lowerSeries(),presenter); |
|
46 | m_lower = new AreaBoundItem(this, m_series->lowerSeries(), presenter); | |
47 | } |
|
|||
48 |
|
47 | |||
49 | QObject::connect(m_series->d_func(),SIGNAL(updated()),this,SLOT(handleUpdated())); |
|
48 | QObject::connect(m_series->d_func(), SIGNAL(updated()), this, SLOT(handleUpdated())); | |
50 | QObject::connect(m_series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated())); |
|
49 | QObject::connect(m_series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated())); |
@@ -84,7 +84,9 private: | |||||
84 | class AreaBoundItem : public LineChartItem |
|
84 | class AreaBoundItem : public LineChartItem | |
85 | { |
|
85 | { | |
86 | public: |
|
86 | public: | |
87 |
AreaBoundItem(AreaChartItem *item,QLineSeries *lineSeries,ChartPresenter* presenter) |
|
87 | AreaBoundItem(AreaChartItem *item, QLineSeries *lineSeries, ChartPresenter* presenter) | |
|
88 | : LineChartItem(lineSeries, 0), m_item(item) | |||
|
89 | { | |||
88 | setPresenter(presenter); |
|
90 | setPresenter(presenter); | |
89 | } |
|
91 | } | |
90 | ~AreaBoundItem() {} |
|
92 | ~AreaBoundItem() {} |
@@ -180,10 +180,9 QAreaSeries::QAreaSeries(QObject *parent) | |||||
180 | QAreaSeries::~QAreaSeries() |
|
180 | QAreaSeries::~QAreaSeries() | |
181 | { |
|
181 | { | |
182 | Q_D(QAreaSeries); |
|
182 | Q_D(QAreaSeries); | |
183 |
if(d->m_dataset) |
|
183 | if (d->m_dataset) | |
184 |
|
|
184 | d->m_dataset->removeSeries(this); | |
185 | } |
|
185 | } | |
186 | } |
|
|||
187 |
|
186 | |||
188 | /*! |
|
187 | /*! | |
189 | Returns QChartSeries::SeriesTypeArea. |
|
188 | Returns QChartSeries::SeriesTypeArea. | |
@@ -315,8 +314,8 bool QAreaSeries::pointsVisible() const | |||||
315 |
|
314 | |||
316 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
315 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
317 |
|
316 | |||
318 |
QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q) |
|
317 | QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries, QAreaSeries* q) | |
319 | QAbstractSeriesPrivate(q), |
|
318 | : QAbstractSeriesPrivate(q), | |
320 | m_upperSeries(upperSeries), |
|
319 | m_upperSeries(upperSeries), | |
321 | m_lowerSeries(lowerSeries), |
|
320 | m_lowerSeries(lowerSeries), | |
322 | m_pointsVisible(false) |
|
321 | m_pointsVisible(false) | |
@@ -337,8 +336,7 void QAreaSeriesPrivate::scaleDomain(Domain& domain) | |||||
337 |
|
336 | |||
338 | const QList<QPointF>& points = upperSeries->points(); |
|
337 | const QList<QPointF>& points = upperSeries->points(); | |
339 |
|
338 | |||
340 | for (int i = 0; i < points.count(); i++) |
|
339 | for (int i = 0; i < points.count(); i++) { | |
341 | { |
|
|||
342 | qreal x = points[i].x(); |
|
340 | qreal x = points[i].x(); | |
343 | qreal y = points[i].y(); |
|
341 | qreal y = points[i].y(); | |
344 | minX = qMin(minX, x); |
|
342 | minX = qMin(minX, x); | |
@@ -350,15 +348,15 void QAreaSeriesPrivate::scaleDomain(Domain& domain) | |||||
350 |
|
348 | |||
351 | const QList<QPointF>& points = lowerSeries->points(); |
|
349 | const QList<QPointF>& points = lowerSeries->points(); | |
352 |
|
350 | |||
353 | for (int i = 0; i < points.count(); i++) |
|
351 | for (int i = 0; i < points.count(); i++) { | |
354 | { |
|
|||
355 | qreal x = points[i].x(); |
|
352 | qreal x = points[i].x(); | |
356 | qreal y = points[i].y(); |
|
353 | qreal y = points[i].y(); | |
357 | minX = qMin(minX, x); |
|
354 | minX = qMin(minX, x); | |
358 | minY = qMin(minY, y); |
|
355 | minY = qMin(minY, y); | |
359 | maxX = qMax(maxX, x); |
|
356 | maxX = qMax(maxX, x); | |
360 | maxY = qMax(maxY, y); |
|
357 | maxY = qMax(maxY, y); | |
361 |
} |
|
358 | } | |
|
359 | } | |||
362 |
|
360 | |||
363 | domain.setRange(minX,maxX,minY,maxY); |
|
361 | domain.setRange(minX, maxX, minY, maxY); | |
364 | } |
|
362 | } | |
@@ -370,10 +368,9 ChartElement* QAreaSeriesPrivate::createGraphics(ChartPresenter* presenter) | |||||
370 | AreaChartItem* area = new AreaChartItem(q,presenter); |
|
368 | AreaChartItem* area = new AreaChartItem(q, presenter); | |
371 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
369 | if (presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
372 | area->upperLineItem()->setAnimation(new XYAnimation(area->upperLineItem())); |
|
370 | area->upperLineItem()->setAnimation(new XYAnimation(area->upperLineItem())); | |
373 |
if(q->lowerSeries()) |
|
371 | if (q->lowerSeries()) | |
374 | area->lowerLineItem()->setAnimation(new XYAnimation(area->lowerLineItem())); |
|
372 | area->lowerLineItem()->setAnimation(new XYAnimation(area->lowerLineItem())); | |
375 |
|
|
373 | } | |
376 | } |
|
|||
377 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
374 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
378 | return area; |
|
375 | return area; | |
379 | } |
|
376 | } |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -29,7 +29,8 static int label_padding = 5; | |||||
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 |
ChartBarCategoryAxisX::ChartBarCategoryAxisX(QBarCategoryAxis *axis,ChartPresenter *presenter) |
|
32 | ChartBarCategoryAxisX::ChartBarCategoryAxisX(QBarCategoryAxis *axis, ChartPresenter *presenter) | |
|
33 | : ChartAxis(axis, presenter), | |||
33 | m_categoriesAxis(axis) |
|
34 | m_categoriesAxis(axis) | |
34 | { |
|
35 | { | |
35 |
|
36 | |||
@@ -55,12 +56,10 QVector<qreal> ChartBarCategoryAxisX::calculateLayout() const | |||||
55 |
|
56 | |||
56 | if(delta<1) return points; |
|
57 | if (delta < 1) return points; | |
57 |
|
58 | |||
58 |
if(offset<=0) |
|
59 | if (offset <= 0) | |
59 | offset = int(offset * rect.width()/(m_max - m_min))%int(delta) + delta; |
|
60 | offset = int(offset * rect.width() / (m_max - m_min)) % int(delta) + delta; | |
60 |
|
|
61 | else | |
61 | else { |
|
|||
62 | offset = int(offset * rect.width()/(m_max - m_min))%int(delta); |
|
62 | offset = int(offset * rect.width() / (m_max - m_min)) % int(delta); | |
63 | } |
|
|||
64 |
|
63 | |||
65 | points[0] = rect.left(); |
|
64 | points[0] = rect.left(); | |
66 | points[count+1] = rect.right(); |
|
65 | points[count + 1] = rect.right(); | |
@@ -79,13 +78,10 QStringList ChartBarCategoryAxisX::createCategoryLabels(const QVector<qreal>& la | |||||
79 | qreal d = (m_max - m_min)/rect.width(); |
|
78 | qreal d = (m_max - m_min) / rect.width(); | |
80 | for (int i = 0;i < layout.count()-1; ++i) { |
|
79 | for (int i = 0; i < layout.count() - 1; ++i) { | |
81 | qreal x = qFloor((((layout[i+1] + layout[i])/2-rect.left())*d + m_min+0.5)); |
|
80 | qreal x = qFloor((((layout[i + 1] + layout[i]) / 2 - rect.left()) * d + m_min + 0.5)); | |
82 |
if ((x < m_categoriesAxis->categories().count()) && (x >= 0)) |
|
81 | if ((x < m_categoriesAxis->categories().count()) && (x >= 0)) | |
83 | result << m_categoriesAxis->categories().at(x); |
|
82 | result << m_categoriesAxis->categories().at(x); | |
84 |
|
|
83 | else | |
85 | else { |
|
84 | result << ""; // No label for x coordinate | |
86 | // No label for x coordinate |
|
|||
87 | result << ""; |
|
|||
88 | } |
|
|||
89 | } |
|
85 | } | |
90 | result << ""; |
|
86 | result << ""; | |
91 | return result; |
|
87 | return result; | |
@@ -96,7 +92,8 void ChartBarCategoryAxisX::updateGeometry() | |||||
96 | { |
|
92 | { | |
97 | const QVector<qreal>& layout = ChartAxis::layout(); |
|
93 | const QVector<qreal>& layout = ChartAxis::layout(); | |
98 |
|
94 | |||
99 |
if(layout.isEmpty()) |
|
95 | if (layout.isEmpty()) | |
|
96 | return; | |||
100 |
|
97 | |||
101 | QStringList ticksList = createCategoryLabels(layout); |
|
98 | QStringList ticksList = createCategoryLabels(layout); | |
102 |
|
99 | |||
@@ -125,16 +122,14 void ChartBarCategoryAxisX::updateGeometry() | |||||
125 | QPointF center = rect.center(); |
|
122 | QPointF center = rect.center(); | |
126 | labelItem->setTransformOriginPoint(center.x(), center.y()); |
|
123 | labelItem->setTransformOriginPoint(center.x(), center.y()); | |
127 |
|
124 | |||
128 |
if(i==0) |
|
125 | if (i == 0) | |
129 | labelItem->setPos(layout[i+1] - (delta)/2 - center.x(), chartRect.bottom() + label_padding); |
|
126 | labelItem->setPos(layout[i + 1] - (delta) / 2 - center.x(), chartRect.bottom() + label_padding); | |
130 |
|
|
127 | else | |
131 | labelItem->setPos(layout[i] + (delta)/2 - center.x(), chartRect.bottom() + label_padding); |
|
128 | labelItem->setPos(layout[i] + (delta) / 2 - center.x(), chartRect.bottom() + label_padding); | |
132 | } |
|
|||
133 |
|
129 | |||
134 | if(labelItem->pos().x()<=width || labelItem->pos().x()+ rect.width()> chartRect.right()) { |
|
130 | if (labelItem->pos().x() <= width || labelItem->pos().x() + rect.width() > chartRect.right()) { | |
135 | labelItem->setVisible(false); |
|
131 | labelItem->setVisible(false); | |
136 | } |
|
132 | } else { | |
137 | else { |
|
|||
138 | labelItem->setVisible(true); |
|
133 | labelItem->setVisible(true); | |
139 | width=rect.width()+labelItem->pos().x(); |
|
134 | width = rect.width() + labelItem->pos().x(); | |
140 | } |
|
135 | } | |
@@ -150,8 +145,7 void ChartBarCategoryAxisX::updateGeometry() | |||||
150 |
|
145 | |||
151 | void ChartBarCategoryAxisX::handleAxisUpdated() |
|
146 | void ChartBarCategoryAxisX::handleAxisUpdated() | |
152 | { |
|
147 | { | |
153 | if(m_categoriesAxis->categories()!=m_categories) |
|
148 | if (m_categoriesAxis->categories() != m_categories) { | |
154 | { |
|
|||
155 | m_categories=m_categoriesAxis->categories(); |
|
149 | m_categories = m_categoriesAxis->categories(); | |
156 | if(ChartAxis::layout().count()==m_categoriesAxis->d_ptr->count()+2) updateGeometry(); |
|
150 | if (ChartAxis::layout().count() == m_categoriesAxis->d_ptr->count() + 2) updateGeometry(); | |
157 | } |
|
151 | } | |
@@ -177,10 +171,8 QSizeF ChartBarCategoryAxisX::sizeHint(Qt::SizeHint which, const QSizeF& constra | |||||
177 |
|
|
171 | height += base.height(); | |
178 |
|
|
172 | sh = QSizeF(width, height); | |
179 |
|
|
173 | break; | |
180 |
|
|
174 | case Qt::PreferredSize: | |
181 |
|
175 | for (int i = 0; i < ticksList.size(); ++i) { | ||
182 | for (int i = 0; i < ticksList.size(); ++i) |
|
|||
183 | { |
|
|||
184 |
|
|
176 | QRectF rect = fn.boundingRect(ticksList.at(i)); | |
185 |
|
|
177 | width += rect.width(); | |
186 |
|
|
178 | height = qMax(rect.height() + label_padding, height); | |
@@ -189,7 +181,6 QSizeF ChartBarCategoryAxisX::sizeHint(Qt::SizeHint which, const QSizeF& constra | |||||
189 |
|
|
181 | height += base.height(); | |
190 |
|
|
182 | sh = QSizeF(width, height); | |
191 |
|
|
183 | break; | |
192 | } |
|
|||
193 |
|
|
184 | default: | |
194 |
|
|
185 | break; | |
195 |
|
|
186 | } |
@@ -51,7 +51,7 protected: | |||||
51 | void updateGeometry(); |
|
51 | void updateGeometry(); | |
52 | private: |
|
52 | private: | |
53 | QStringList createCategoryLabels(const QVector<qreal>& layout) const; |
|
53 | QStringList createCategoryLabels(const QVector<qreal>& layout) const; | |
54 | Q_SLOTS |
|
54 | public Q_SLOTS: | |
55 | void handleAxisUpdated(); |
|
55 | void handleAxisUpdated(); | |
56 |
|
56 | |||
57 | private: |
|
57 | private: |
@@ -29,7 +29,8 static int label_padding = 5; | |||||
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 |
ChartBarCategoryAxisY::ChartBarCategoryAxisY(QBarCategoryAxis *axis,ChartPresenter *presenter) |
|
32 | ChartBarCategoryAxisY::ChartBarCategoryAxisY(QBarCategoryAxis *axis, ChartPresenter *presenter) | |
|
33 | : ChartAxis(axis, presenter), | |||
33 | m_categoriesAxis(axis) |
|
34 | m_categoriesAxis(axis) | |
34 | { |
|
35 | { | |
35 | } |
|
36 | } | |
@@ -54,12 +55,10 QVector<qreal> ChartBarCategoryAxisY::calculateLayout() const | |||||
54 |
|
55 | |||
55 | if(delta<1) return points; |
|
56 | if (delta < 1) return points; | |
56 |
|
57 | |||
57 |
if(offset<=0) |
|
58 | if (offset <= 0) | |
58 | offset = int(offset * rect.height()/(m_max - m_min))%int(delta) + delta; |
|
59 | offset = int(offset * rect.height() / (m_max - m_min)) % int(delta) + delta; | |
59 |
|
|
60 | else | |
60 | else { |
|
|||
61 | offset = int(offset * rect.height()/(m_max - m_min))%int(delta); |
|
61 | offset = int(offset * rect.height() / (m_max - m_min)) % int(delta); | |
62 | } |
|
|||
63 |
|
62 | |||
64 | points[0] = rect.bottom(); |
|
63 | points[0] = rect.bottom(); | |
65 | points[count+1] = rect.top(); |
|
64 | points[count + 1] = rect.top(); | |
@@ -78,13 +77,10 QStringList ChartBarCategoryAxisY::createCategoryLabels(const QVector<qreal>& la | |||||
78 | qreal d = (m_max - m_min)/rect.height(); |
|
77 | qreal d = (m_max - m_min) / rect.height(); | |
79 | for (int i = 0;i < layout.count()-1; ++i) { |
|
78 | for (int i = 0; i < layout.count() - 1; ++i) { | |
80 | qreal x = qFloor(((rect.height()- (layout[i+1] + layout[i])/2 + rect.top())*d + m_min+0.5)); |
|
79 | qreal x = qFloor(((rect.height() - (layout[i + 1] + layout[i]) / 2 + rect.top()) * d + m_min + 0.5)); | |
81 |
if ((x < m_categoriesAxis->categories().count()) && (x >= 0)) |
|
80 | if ((x < m_categoriesAxis->categories().count()) && (x >= 0)) | |
82 | result << m_categoriesAxis->categories().at(x); |
|
81 | result << m_categoriesAxis->categories().at(x); | |
83 |
|
|
82 | else | |
84 | else { |
|
83 | result << ""; // No label for x coordinate | |
85 | // No label for x coordinate |
|
|||
86 | result << ""; |
|
|||
87 | } |
|
|||
88 | } |
|
84 | } | |
89 | result << ""; |
|
85 | result << ""; | |
90 | return result; |
|
86 | return result; | |
@@ -94,7 +90,8 void ChartBarCategoryAxisY::updateGeometry() | |||||
94 | { |
|
90 | { | |
95 | const QVector<qreal>& layout = ChartAxis::layout(); |
|
91 | const QVector<qreal>& layout = ChartAxis::layout(); | |
96 |
|
92 | |||
97 |
if(layout.isEmpty()) |
|
93 | if (layout.isEmpty()) | |
|
94 | return; | |||
98 |
|
95 | |||
99 | QStringList ticksList = createCategoryLabels(layout); |
|
96 | QStringList ticksList = createCategoryLabels(layout); | |
100 |
|
97 | |||
@@ -123,17 +120,14 void ChartBarCategoryAxisY::updateGeometry() | |||||
123 | QPointF center = rect.center(); |
|
120 | QPointF center = rect.center(); | |
124 | labelItem->setTransformOriginPoint(center.x(), center.y()); |
|
121 | labelItem->setTransformOriginPoint(center.x(), center.y()); | |
125 |
|
122 | |||
126 |
if(i==0) |
|
123 | if (i == 0) | |
127 | labelItem->setPos(chartRect.left() - rect.width() - label_padding ,layout[i+1] + (delta)/2 - center.y()); |
|
124 | labelItem->setPos(chartRect.left() - rect.width() - label_padding , layout[i + 1] + (delta) / 2 - center.y()); | |
128 |
|
|
125 | else | |
129 | else { |
|
|||
130 | labelItem->setPos(chartRect.left() - rect.width() - label_padding ,layout[i] - (delta)/2 - center.y()); |
|
126 | labelItem->setPos(chartRect.left() - rect.width() - label_padding , layout[i] - (delta) / 2 - center.y()); | |
131 | } |
|
|||
132 |
|
127 | |||
133 | if(labelItem->pos().y()+rect.height()>= height || labelItem->pos().y() < chartRect.top()) { |
|
128 | if (labelItem->pos().y() + rect.height() >= height || labelItem->pos().y() < chartRect.top()) { | |
134 | labelItem->setVisible(false); |
|
129 | labelItem->setVisible(false); | |
135 | } |
|
130 | } else { | |
136 | else { |
|
|||
137 | labelItem->setVisible(true); |
|
131 | labelItem->setVisible(true); | |
138 | height=labelItem->pos().y(); |
|
132 | height = labelItem->pos().y(); | |
139 | } |
|
133 | } | |
@@ -150,13 +144,11 void ChartBarCategoryAxisY::updateGeometry() | |||||
150 | void ChartBarCategoryAxisY::handleAxisUpdated() |
|
144 | void ChartBarCategoryAxisY::handleAxisUpdated() | |
151 | { |
|
145 | { | |
152 |
|
146 | |||
153 | if(m_categoriesAxis->categories()!=m_categories) |
|
147 | if (m_categoriesAxis->categories() != m_categories) { | |
154 | { |
|
|||
155 | m_categories=m_categoriesAxis->categories(); |
|
148 | m_categories = m_categoriesAxis->categories(); | |
156 |
if(ChartAxis::layout().count()==m_categoriesAxis->d_ptr->count()+2) |
|
149 | if (ChartAxis::layout().count() == m_categoriesAxis->d_ptr->count() + 2) | |
157 | updateGeometry(); |
|
150 | updateGeometry(); | |
158 |
|
|
151 | } | |
159 | } |
|
|||
160 | ChartAxis::handleAxisUpdated(); |
|
152 | ChartAxis::handleAxisUpdated(); | |
161 | } |
|
153 | } | |
162 |
|
154 | |||
@@ -179,10 +171,8 QSizeF ChartBarCategoryAxisY::sizeHint(Qt::SizeHint which, const QSizeF& constra | |||||
179 |
|
|
171 | height = qMax(height, base.height()); | |
180 |
|
|
172 | sh = QSizeF(width, height); | |
181 |
|
|
173 | break; | |
182 |
|
|
174 | case Qt::PreferredSize: | |
183 |
|
175 | for (int i = 0; i < ticksList.size(); ++i) { | ||
184 | for (int i = 0; i < ticksList.size(); ++i) |
|
|||
185 | { |
|
|||
186 |
|
|
176 | QRectF rect = fn.boundingRect(ticksList.at(i)); | |
187 |
|
|
177 | height += rect.height(); | |
188 |
|
|
178 | width = qMax(rect.width() + label_padding, width); | |
@@ -191,7 +181,6 QSizeF ChartBarCategoryAxisY::sizeHint(Qt::SizeHint which, const QSizeF& constra | |||||
191 |
|
|
181 | width += base.width(); | |
192 |
|
|
182 | sh = QSizeF(width, height); | |
193 |
|
|
183 | break; | |
194 | } |
|
|||
195 |
|
|
184 | default: | |
196 |
|
|
185 | break; | |
197 |
|
|
186 | } |
@@ -51,7 +51,7 protected: | |||||
51 | void updateGeometry(); |
|
51 | void updateGeometry(); | |
52 | private: |
|
52 | private: | |
53 | QStringList createCategoryLabels(const QVector<qreal>& layout) const; |
|
53 | QStringList createCategoryLabels(const QVector<qreal>& layout) const; | |
54 | Q_SLOTS |
|
54 | public Q_SLOTS: | |
55 |
|
|
55 | void handleAxisUpdated(); | |
56 | private: |
|
56 | private: | |
57 | QStringList m_categories; |
|
57 | QStringList m_categories; |
@@ -141,15 +141,15 QBarCategoryAxis::QBarCategoryAxis(QObject *parent): | |||||
141 | QBarCategoryAxis::~QBarCategoryAxis() |
|
141 | QBarCategoryAxis::~QBarCategoryAxis() | |
142 | { |
|
142 | { | |
143 | Q_D(QBarCategoryAxis); |
|
143 | Q_D(QBarCategoryAxis); | |
144 |
if(d->m_dataset) |
|
144 | if (d->m_dataset) | |
145 |
|
|
145 | d->m_dataset->removeAxis(this); | |
146 | } |
|
146 | } | |
147 | } |
|
|||
148 |
|
147 | |||
149 | /*! |
|
148 | /*! | |
150 | \internal |
|
149 | \internal | |
151 | */ |
|
150 | */ | |
152 |
QBarCategoryAxis::QBarCategoryAxis(QBarCategoryAxisPrivate &d,QObject *parent) |
|
151 | QBarCategoryAxis::QBarCategoryAxis(QBarCategoryAxisPrivate &d, QObject *parent) | |
|
152 | : QAbstractAxis(d, parent) | |||
153 | { |
|
153 | { | |
154 |
|
154 | |||
155 | } |
|
155 | } | |
@@ -159,7 +159,8 QBarCategoryAxis::QBarCategoryAxis(QBarCategoryAxisPrivate &d,QObject *parent):Q | |||||
159 | */ |
|
159 | */ | |
160 | void QBarCategoryAxis::append(const QStringList &categories) |
|
160 | void QBarCategoryAxis::append(const QStringList &categories) | |
161 | { |
|
161 | { | |
162 |
if(categories.isEmpty()) |
|
162 | if (categories.isEmpty()) | |
|
163 | return; | |||
163 |
|
164 | |||
164 | Q_D(QBarCategoryAxis); |
|
165 | Q_D(QBarCategoryAxis); | |
165 | if (d->m_categories.isEmpty()) { |
|
166 | if (d->m_categories.isEmpty()) { | |
@@ -338,7 +339,8 void QBarCategoryAxis::setRange(const QString& minCategory, const QString& maxCa | |||||
338 | d->emitUpdated(); |
|
339 | d->emitUpdated(); | |
339 | } |
|
340 | } | |
340 |
|
341 | |||
341 |
if(d->m_categories.indexOf(d->m_maxCategory)<d->m_categories.indexOf(d->m_minCategory)) |
|
342 | if (d->m_categories.indexOf(d->m_maxCategory) < d->m_categories.indexOf(d->m_minCategory)) | |
|
343 | return; | |||
342 |
|
344 | |||
343 | if (!minCategory.isEmpty() && d->m_minCategory!=minCategory && d->m_categories.contains(minCategory)) { |
|
345 | if (!minCategory.isEmpty() && d->m_minCategory != minCategory && d->m_categories.contains(minCategory)) { | |
344 | d->m_minCategory = minCategory; |
|
346 | d->m_minCategory = minCategory; | |
@@ -411,8 +413,7 void QBarCategoryAxisPrivate::handleDomainUpdated() | |||||
411 | if(m_orientation==Qt::Horizontal) { |
|
413 | if (m_orientation == Qt::Horizontal) { | |
412 | m_min = domain->minX(); |
|
414 | m_min = domain->minX(); | |
413 | m_max = domain->maxX(); |
|
415 | m_max = domain->maxX(); | |
414 | } |
|
416 | } else if (m_orientation == Qt::Vertical) { | |
415 | else if(m_orientation==Qt::Vertical) { |
|
|||
416 | m_min = domain->minY(); |
|
417 | m_min = domain->minY(); | |
417 | m_max = domain->maxY(); |
|
418 | m_max = domain->maxY(); | |
418 | } |
|
419 | } | |
@@ -437,20 +438,17 void QBarCategoryAxisPrivate::handleDomainUpdated() | |||||
437 | } |
|
438 | } | |
438 | } |
|
439 | } | |
439 |
|
440 | |||
440 |
if (changed) |
|
441 | if (changed) | |
441 | emit q->rangeChanged(m_minCategory,m_maxCategory); |
|
442 | emit q->rangeChanged(m_minCategory, m_maxCategory); | |
442 | } |
|
443 | } | |
443 | } |
|
|||
444 |
|
444 | |||
445 | ChartAxis* QBarCategoryAxisPrivate::createGraphics(ChartPresenter* presenter) |
|
445 | ChartAxis* QBarCategoryAxisPrivate::createGraphics(ChartPresenter* presenter) | |
446 | { |
|
446 | { | |
447 | Q_Q(QBarCategoryAxis); |
|
447 | Q_Q(QBarCategoryAxis); | |
448 |
if(m_orientation == Qt::Vertical) |
|
448 | if (m_orientation == Qt::Vertical) | |
449 | return new ChartBarCategoryAxisY(q,presenter); |
|
449 | return new ChartBarCategoryAxisY(q, presenter); | |
450 | }else{ |
|
|||
451 |
|
|
450 | return new ChartBarCategoryAxisX(q, presenter); | |
452 | } |
|
451 | } | |
453 | } |
|
|||
454 |
|
452 | |||
455 | void QBarCategoryAxisPrivate::intializeDomain(Domain* domain) |
|
453 | void QBarCategoryAxisPrivate::intializeDomain(Domain* domain) | |
456 | { |
|
454 | { | |
@@ -462,24 +460,20 void QBarCategoryAxisPrivate::intializeDomain(Domain* domain) | |||||
462 | if(m_orientation==Qt::Vertical) { |
|
460 | if (m_orientation == Qt::Vertical) { | |
463 | min = domain->minY() + 0.5; |
|
461 | min = domain->minY() + 0.5; | |
464 | max = domain->maxY() - 0.5; |
|
462 | max = domain->maxY() - 0.5; | |
465 | } |
|
463 | } else { | |
466 | else { |
|
|||
467 | min = domain->minX() + 0.5; |
|
464 | min = domain->minX() + 0.5; | |
468 | max = domain->maxX() - 0.5; |
|
465 | max = domain->maxX() - 0.5; | |
469 | } |
|
466 | } | |
470 |
|
467 | |||
471 | if(min>0 && min<m_categories.count() && max>0 && max<m_categories.count()) |
|
468 | if (min > 0 && min < m_categories.count() && max > 0 && max < m_categories.count()) | |
472 | q->setRange(m_categories.at(min),m_categories.at(max)); |
|
469 | q->setRange(m_categories.at(min), m_categories.at(max)); | |
473 | } |
|
470 | } else { | |
474 | else { |
|
471 | if (m_orientation == Qt::Vertical) | |
475 | if(m_orientation==Qt::Vertical) { |
|
|||
476 | domain->setRangeY(m_min, m_max); |
|
472 | domain->setRangeY(m_min, m_max); | |
477 |
|
|
473 | else | |
478 | else { |
|
|||
479 | domain->setRangeX(m_min, m_max); |
|
474 | domain->setRangeX(m_min, m_max); | |
480 |
|
|
475 | } | |
481 | } |
|
476 | } | |
482 | } |
|
|||
483 |
|
477 | |||
484 | #include "moc_qbarcategoryaxis.cpp" |
|
478 | #include "moc_qbarcategoryaxis.cpp" | |
485 | #include "moc_qbarcategoryaxis_p.cpp" |
|
479 | #include "moc_qbarcategoryaxis_p.cpp" |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -30,7 +30,8 static int label_padding = 5; | |||||
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 |
ChartCategoryAxisX::ChartCategoryAxisX(QAbstractAxis *axis,ChartPresenter *presenter) |
|
33 | ChartCategoryAxisX::ChartCategoryAxisX(QAbstractAxis *axis, ChartPresenter *presenter) | |
|
34 | : ChartAxis(axis, presenter) | |||
34 | { |
|
35 | { | |
35 | } |
|
36 | } | |
36 |
|
37 | |||
@@ -69,7 +70,8 void ChartCategoryAxisX::updateGeometry() | |||||
69 | { |
|
70 | { | |
70 | const QVector<qreal>& layout = ChartAxis::layout(); |
|
71 | const QVector<qreal>& layout = ChartAxis::layout(); | |
71 |
|
72 | |||
72 |
if(layout.isEmpty()) |
|
73 | if (layout.isEmpty()) | |
|
74 | return; | |||
73 |
|
75 | |||
74 | QCategoryAxis *categoryAxis = qobject_cast<QCategoryAxis *>(m_chartAxis); |
|
76 | QCategoryAxis *categoryAxis = qobject_cast<QCategoryAxis *>(m_chartAxis); | |
75 | QStringList ticksList = categoryAxis->categoriesLabels(); |
|
77 | QStringList ticksList = categoryAxis->categoriesLabels(); | |
@@ -80,9 +82,8 void ChartCategoryAxisX::updateGeometry() | |||||
80 | QList<QGraphicsItem *> axis = m_arrow->childItems(); |
|
82 | QList<QGraphicsItem *> axis = m_arrow->childItems(); | |
81 |
|
83 | |||
82 |
|
84 | |||
83 |
for (int i = 0; i < labels.count(); i++) |
|
85 | for (int i = 0; i < labels.count(); i++) | |
84 | labels.at(i)->setVisible(false); |
|
86 | labels.at(i)->setVisible(false); | |
85 | } |
|
|||
86 |
|
87 | |||
87 | QRectF chartRect = presenter()->chartsGeometry(); |
|
88 | QRectF chartRect = presenter()->chartsGeometry(); | |
88 | // axis base line |
|
89 | // axis base line | |
@@ -93,18 +94,16 void ChartCategoryAxisX::updateGeometry() | |||||
93 | for (int i = 0; i < layout.size(); ++i) { |
|
94 | for (int i = 0; i < layout.size(); ++i) { | |
94 |
|
95 | |||
95 | QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i)); |
|
96 | QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i)); | |
96 |
if (i < ticksList.count()) |
|
97 | if (i < ticksList.count()) | |
97 | labelItem->setText(ticksList.at(i)); |
|
98 | labelItem->setText(ticksList.at(i)); | |
98 | } |
|
|||
99 | const QRectF& rect = labelItem->boundingRect(); |
|
99 | const QRectF& rect = labelItem->boundingRect(); | |
100 | QPointF center = rect.center(); |
|
100 | QPointF center = rect.center(); | |
101 | labelItem->setTransformOriginPoint(center.x(), center.y()); |
|
101 | labelItem->setTransformOriginPoint(center.x(), center.y()); | |
102 |
|
102 | |||
103 |
if (i < layout.size() - 1) |
|
103 | if (i < layout.size() - 1) | |
104 | labelItem->setPos(layout[i] + (layout[i + 1] - layout[i]) / 2 - center.x(), chartRect.bottom() + label_padding); |
|
104 | labelItem->setPos(layout[i] + (layout[i + 1] - layout[i]) / 2 - center.x(), chartRect.bottom() + label_padding); | |
105 |
|
|
105 | else | |
106 | labelItem->setPos(layout[i] - center.x(), chartRect.bottom() + label_padding); |
|
106 | labelItem->setPos(layout[i] - center.x(), chartRect.bottom() + label_padding); | |
107 | } |
|
|||
108 |
|
107 | |||
109 | // check if the label should be shown |
|
108 | // check if the label should be shown | |
110 | if (labelItem->pos().x() + center.x() < chartRect.left() || labelItem->pos().x() + center.x() > chartRect.right()) |
|
109 | if (labelItem->pos().x() + center.x() < chartRect.left() || labelItem->pos().x() + center.x() > chartRect.right()) | |
@@ -134,9 +133,7 void ChartCategoryAxisX::updateGeometry() | |||||
134 | lineItem->setVisible(true); |
|
133 | lineItem->setVisible(true); | |
135 | tickLineItem->setVisible(true); |
|
134 | tickLineItem->setVisible(true); | |
136 | } |
|
135 | } | |
137 |
|
||||
138 | } |
|
136 | } | |
139 |
|
||||
140 | } |
|
137 | } | |
141 |
|
138 | |||
142 | void ChartCategoryAxisX::handleAxisUpdated() |
|
139 | void ChartCategoryAxisX::handleAxisUpdated() | |
@@ -164,10 +161,8 QSizeF ChartCategoryAxisX::sizeHint(Qt::SizeHint which, const QSizeF& constraint | |||||
164 | height+=base.height(); |
|
161 | height += base.height(); | |
165 | sh = QSizeF(width,height); |
|
162 | sh = QSizeF(width, height); | |
166 | break; |
|
163 | break; | |
167 |
|
|
164 | case Qt::PreferredSize: | |
168 |
|
165 | for (int i = 0; i < ticksList.size(); ++i) { | ||
169 | for (int i = 0; i < ticksList.size(); ++i) |
|
|||
170 | { |
|
|||
171 |
|
|
166 | QRectF rect = fn.boundingRect(ticksList.at(i)); | |
172 |
|
|
167 | width += rect.width(); | |
173 |
|
|
168 | height = qMax(rect.height() + label_padding, height); | |
@@ -176,7 +171,6 QSizeF ChartCategoryAxisX::sizeHint(Qt::SizeHint which, const QSizeF& constraint | |||||
176 |
|
|
171 | height += base.height(); | |
177 |
|
|
172 | sh = QSizeF(width, height); | |
178 |
|
|
173 | break; | |
179 | } |
|
|||
180 |
|
|
174 | default: | |
181 | break; |
|
175 | break; | |
182 | } |
|
176 | } |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -30,7 +30,8 static int label_padding = 5; | |||||
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 |
ChartCategoryAxisY::ChartCategoryAxisY(QAbstractAxis *axis,ChartPresenter *presenter) |
|
33 | ChartCategoryAxisY::ChartCategoryAxisY(QAbstractAxis *axis, ChartPresenter *presenter) | |
|
34 | : ChartAxis(axis, presenter) | |||
34 | { |
|
35 | { | |
35 | } |
|
36 | } | |
36 |
|
37 | |||
@@ -53,7 +54,7 QVector<qreal> ChartCategoryAxisY::calculateLayout() const | |||||
53 | if (range > 0) { |
|
54 | if (range > 0) { | |
54 | points.resize(tickCount); |
|
55 | points.resize(tickCount); | |
55 | qreal scale = rect.height() / range; |
|
56 | qreal scale = rect.height() / range; | |
56 | for (int i = 0; i < tickCount; ++i) |
|
57 | for (int i = 0; i < tickCount; ++i) { | |
57 | if (i < tickCount - 1) { |
|
58 | if (i < tickCount - 1) { | |
58 | int y = -(axis->startValue(axis->categoriesLabels().at(i)) - axis->min()) * scale + rect.bottom(); |
|
59 | int y = -(axis->startValue(axis->categoriesLabels().at(i)) - axis->min()) * scale + rect.bottom(); | |
59 | points[i] = y; |
|
60 | points[i] = y; | |
@@ -62,6 +63,7 QVector<qreal> ChartCategoryAxisY::calculateLayout() const | |||||
62 | points[i] = y; |
|
63 | points[i] = y; | |
63 | } |
|
64 | } | |
64 | } |
|
65 | } | |
|
66 | } | |||
65 |
|
67 | |||
66 | return points; |
|
68 | return points; | |
67 | } |
|
69 | } | |
@@ -70,9 +72,8 void ChartCategoryAxisY::updateGeometry() | |||||
70 | { |
|
72 | { | |
71 | const QVector<qreal> &layout = ChartAxis::layout(); |
|
73 | const QVector<qreal> &layout = ChartAxis::layout(); | |
72 |
|
74 | |||
73 |
if(layout.isEmpty()) |
|
75 | if (layout.isEmpty()) | |
74 | return; |
|
76 | return; | |
75 | } |
|
|||
76 |
|
77 | |||
77 | QCategoryAxis *categoryAxis = qobject_cast<QCategoryAxis *>(m_chartAxis); |
|
78 | QCategoryAxis *categoryAxis = qobject_cast<QCategoryAxis *>(m_chartAxis); | |
78 | QStringList ticksList = categoryAxis->categoriesLabels(); |
|
79 | QStringList ticksList = categoryAxis->categoriesLabels(); | |
@@ -138,9 +139,7 void ChartCategoryAxisY::updateGeometry() | |||||
138 | lineItem->setVisible(true); |
|
139 | lineItem->setVisible(true); | |
139 | tickLineItem->setVisible(true); |
|
140 | tickLineItem->setVisible(true); | |
140 | } |
|
141 | } | |
141 |
|
||||
142 | } |
|
142 | } | |
143 |
|
||||
144 | } |
|
143 | } | |
145 |
|
144 | |||
146 | void ChartCategoryAxisY::handleAxisUpdated() |
|
145 | void ChartCategoryAxisY::handleAxisUpdated() | |
@@ -168,10 +167,8 QSizeF ChartCategoryAxisY::sizeHint(Qt::SizeHint which, const QSizeF& constraint | |||||
168 |
|
|
167 | height += base.height(); | |
169 |
|
|
168 | sh = QSizeF(width, height); | |
170 |
|
|
169 | break; | |
171 |
|
|
170 | case Qt::PreferredSize: | |
172 |
|
171 | for (int i = 0; i < ticksList.size(); ++i) { | ||
173 | for (int i = 0; i < ticksList.size(); ++i) |
|
|||
174 | { |
|
|||
175 |
|
|
172 | QRectF rect = fn.boundingRect(ticksList.at(i)); | |
176 |
|
|
173 | height += rect.height(); | |
177 |
|
|
174 | width = qMax(rect.width() + label_padding, width); | |
@@ -180,7 +177,6 QSizeF ChartCategoryAxisY::sizeHint(Qt::SizeHint which, const QSizeF& constraint | |||||
180 |
|
|
177 | width += base.width(); | |
181 |
|
|
178 | sh = QSizeF(width, height); | |
182 |
|
|
179 | break; | |
183 | } |
|
|||
184 |
|
|
180 | default: | |
185 |
|
|
181 | break; | |
186 |
|
|
182 | } |
@@ -49,7 +49,7 protected: | |||||
49 | QVector<qreal> calculateLayout() const; |
|
49 | QVector<qreal> calculateLayout() const; | |
50 | void updateGeometry(); |
|
50 | void updateGeometry(); | |
51 |
|
51 | |||
52 | Q_SLOTS |
|
52 | public Q_SLOTS: | |
53 | void handleAxisUpdated(); |
|
53 | void handleAxisUpdated(); | |
54 | }; |
|
54 | }; | |
55 |
|
55 |
@@ -115,8 +115,7 void QCategoryAxis::append(const QString& categoryLabel, qreal categoryEndValue) | |||||
115 | { |
|
115 | { | |
116 | Q_D(QCategoryAxis); |
|
116 | Q_D(QCategoryAxis); | |
117 |
|
117 | |||
118 | if (!d->m_categories.contains(categoryLabel)) |
|
118 | if (!d->m_categories.contains(categoryLabel)) { | |
119 | { |
|
|||
120 | if(d->m_categories.isEmpty()){ |
|
119 | if (d->m_categories.isEmpty()) { | |
121 | Range range(d->m_categoryMinimum, categoryEndValue); |
|
120 | Range range(d->m_categoryMinimum, categoryEndValue); | |
122 | d->m_categoriesMap.insert(categoryLabel, range); |
|
121 | d->m_categoriesMap.insert(categoryLabel, range); | |
@@ -154,7 +153,6 qreal QCategoryAxis::startValue(const QString& categoryLabel) const | |||||
154 | Q_D(const QCategoryAxis); |
|
153 | Q_D(const QCategoryAxis); | |
155 | if (categoryLabel.isEmpty()) |
|
154 | if (categoryLabel.isEmpty()) | |
156 | return d->m_categoryMinimum; |
|
155 | return d->m_categoryMinimum; | |
157 | else |
|
|||
158 |
|
|
156 | return d->m_categoriesMap.value(categoryLabel).first; | |
159 | } |
|
157 | } | |
160 |
|
158 | |||
@@ -224,7 +222,6 void QCategoryAxis::replaceLabel(const QString& oldLabel, const QString& newLabe | |||||
224 | d->m_categoriesMap.insert(newLabel, range); |
|
222 | d->m_categoriesMap.insert(newLabel, range); | |
225 | d->emitUpdated(); |
|
223 | d->emitUpdated(); | |
226 | } |
|
224 | } | |
227 |
|
||||
228 | } |
|
225 | } | |
229 |
|
226 | |||
230 | /*! |
|
227 | /*! | |
@@ -282,12 +279,10 void QCategoryAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count | |||||
282 | ChartAxis* QCategoryAxisPrivate::createGraphics(ChartPresenter* presenter) |
|
279 | ChartAxis* QCategoryAxisPrivate::createGraphics(ChartPresenter* presenter) | |
283 | { |
|
280 | { | |
284 | Q_Q(QCategoryAxis); |
|
281 | Q_Q(QCategoryAxis); | |
285 |
if(m_orientation == Qt::Vertical) |
|
282 | if (m_orientation == Qt::Vertical) | |
286 | return new ChartCategoryAxisY(q,presenter); |
|
283 | return new ChartCategoryAxisY(q, presenter); | |
287 | }else{ |
|
|||
288 |
|
|
284 | return new ChartCategoryAxisX(q, presenter); | |
289 | } |
|
285 | } | |
290 | } |
|
|||
291 |
|
286 | |||
292 | #include "moc_qcategoryaxis.cpp" |
|
287 | #include "moc_qcategoryaxis.cpp" | |
293 | #include "moc_qcategoryaxis_p.cpp" |
|
288 | #include "moc_qcategoryaxis_p.cpp" |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -31,7 +31,8 | |||||
31 |
|
31 | |||
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
33 |
|
33 | |||
34 |
ChartAxis::ChartAxis(QAbstractAxis *axis,ChartPresenter *presenter) |
|
34 | ChartAxis::ChartAxis(QAbstractAxis *axis, ChartPresenter *presenter) | |
|
35 | : ChartElement(presenter), | |||
35 | m_chartAxis(axis), |
|
36 | m_chartAxis(axis), | |
36 | m_labelsAngle(0), |
|
37 | m_labelsAngle(0), | |
37 | m_grid(new QGraphicsItemGroup(presenter->rootItem())), |
|
38 | m_grid(new QGraphicsItemGroup(presenter->rootItem())), | |
@@ -75,11 +76,13 void ChartAxis::createItems(int count) | |||||
75 | { |
|
76 | { | |
76 | if (m_arrow->children().size() == 0) |
|
77 | if (m_arrow->children().size() == 0) | |
77 | m_arrow->addToGroup(new AxisItem(this,presenter()->rootItem())); |
|
78 | m_arrow->addToGroup(new AxisItem(this, presenter()->rootItem())); | |
|
79 | ||||
78 | for (int i = 0; i < count; ++i) { |
|
80 | for (int i = 0; i < count; ++i) { | |
79 | m_grid->addToGroup(new QGraphicsLineItem(presenter()->rootItem())); |
|
81 | m_grid->addToGroup(new QGraphicsLineItem(presenter()->rootItem())); | |
80 | m_labels->addToGroup(new QGraphicsSimpleTextItem(presenter()->rootItem())); |
|
82 | m_labels->addToGroup(new QGraphicsSimpleTextItem(presenter()->rootItem())); | |
81 | m_arrow->addToGroup(new QGraphicsLineItem(presenter()->rootItem())); |
|
83 | m_arrow->addToGroup(new QGraphicsLineItem(presenter()->rootItem())); | |
82 |
if ((m_grid->childItems().size())%2 && m_grid->childItems().size()>2) |
|
84 | if ((m_grid->childItems().size()) % 2 && m_grid->childItems().size() > 2) | |
|
85 | m_shades->addToGroup(new QGraphicsRectItem(presenter()->rootItem())); | |||
83 | } |
|
86 | } | |
84 | } |
|
87 | } | |
85 |
|
88 | |||
@@ -91,7 +94,8 void ChartAxis::deleteItems(int count) | |||||
91 | QList<QGraphicsItem *> axis = m_arrow->childItems(); |
|
94 | QList<QGraphicsItem *> axis = m_arrow->childItems(); | |
92 |
|
95 | |||
93 | for (int i = 0; i < count; ++i) { |
|
96 | for (int i = 0; i < count; ++i) { | |
94 |
if (lines.size()%2 && lines.size() > 1) |
|
97 | if (lines.size() % 2 && lines.size() > 1) | |
|
98 | delete(shades.takeLast()); | |||
95 | delete(lines.takeLast()); |
|
99 | delete(lines.takeLast()); | |
96 | delete(labels.takeLast()); |
|
100 | delete(labels.takeLast()); | |
97 | delete(axis.takeLast()); |
|
101 | delete(axis.takeLast()); | |
@@ -102,14 +106,13 void ChartAxis::updateLayout(QVector<qreal> &layout) | |||||
102 | { |
|
106 | { | |
103 | int diff = m_layoutVector.size() - layout.size(); |
|
107 | int diff = m_layoutVector.size() - layout.size(); | |
104 |
|
108 | |||
105 |
if (diff>0) |
|
109 | if (diff > 0) | |
106 | deleteItems(diff); |
|
110 | deleteItems(diff); | |
107 | } |
|
111 | else if (diff < 0) | |
108 | else if (diff<0) { |
|
|||
109 | createItems(-diff); |
|
112 | createItems(-diff); | |
110 | } |
|
|||
111 |
|
113 | |||
112 | if(diff<0) handleAxisUpdated(); |
|
114 | if (diff < 0) | |
|
115 | handleAxisUpdated(); | |||
113 |
|
116 | |||
114 | if (m_animation) { |
|
117 | if (m_animation) { | |
115 |
|
|
118 | switch (presenter()->state()) { | |
@@ -135,8 +138,7 void ChartAxis::updateLayout(QVector<qreal> &layout) | |||||
135 |
|
|
138 | } | |
136 |
|
|
139 | m_animation->setValues(m_layoutVector, layout); | |
137 |
|
|
140 | presenter()->startAnimation(m_animation); | |
138 | } |
|
141 | } else { | |
139 | else { |
|
|||
140 | setLayout(layout); |
|
142 | setLayout(layout); | |
141 | updateGeometry(); |
|
143 | updateGeometry(); | |
142 | } |
|
144 | } | |
@@ -204,74 +206,67 void ChartAxis::setShadesVisibility(bool visible) | |||||
204 |
|
206 | |||
205 | void ChartAxis::setLabelsAngle(int angle) |
|
207 | void ChartAxis::setLabelsAngle(int angle) | |
206 | { |
|
208 | { | |
207 |
foreach(QGraphicsItem* |
|
209 | foreach (QGraphicsItem *item , m_labels->childItems()) | |
208 |
|
|
210 | item->setRotation(angle); | |
209 | } |
|
|||
210 |
|
211 | |||
211 | m_labelsAngle=angle; |
|
212 | m_labelsAngle = angle; | |
212 | } |
|
213 | } | |
213 |
|
214 | |||
214 | void ChartAxis::setLabelsPen(const QPen &pen) |
|
215 | void ChartAxis::setLabelsPen(const QPen &pen) | |
215 | { |
|
216 | { | |
216 |
foreach(QGraphicsItem* |
|
217 | foreach (QGraphicsItem *item , m_labels->childItems()) | |
217 | static_cast<QGraphicsSimpleTextItem*>(item)->setPen(pen); |
|
218 | static_cast<QGraphicsSimpleTextItem*>(item)->setPen(pen); | |
218 | } |
|
219 | } | |
219 | } |
|
|||
220 |
|
220 | |||
221 | void ChartAxis::setLabelsBrush(const QBrush &brush) |
|
221 | void ChartAxis::setLabelsBrush(const QBrush &brush) | |
222 | { |
|
222 | { | |
223 |
foreach(QGraphicsItem* |
|
223 | foreach (QGraphicsItem *item , m_labels->childItems()) | |
224 | static_cast<QGraphicsSimpleTextItem*>(item)->setBrush(brush); |
|
224 | static_cast<QGraphicsSimpleTextItem*>(item)->setBrush(brush); | |
225 | } |
|
225 | } | |
226 | } |
|
|||
227 |
|
226 | |||
228 | void ChartAxis::setLabelsFont(const QFont &font) |
|
227 | void ChartAxis::setLabelsFont(const QFont &font) | |
229 | { |
|
228 | { | |
230 |
foreach(QGraphicsItem* |
|
229 | foreach (QGraphicsItem *item , m_labels->childItems()) | |
231 | static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font); |
|
230 | static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font); | |
232 | } |
|
231 | ||
233 | if(m_font!=font) { |
|
232 | if (m_font != font) { | |
234 | m_font = font; |
|
233 | m_font = font; | |
235 |
foreach(QGraphicsItem* |
|
234 | foreach (QGraphicsItem *item , m_labels->childItems()) | |
236 | static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font); |
|
235 | static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font); | |
237 | } |
|
|||
238 | QGraphicsLayoutItem::updateGeometry(); |
|
236 | QGraphicsLayoutItem::updateGeometry(); | |
239 | presenter()->layout()->invalidate(); |
|
237 | presenter()->layout()->invalidate(); | |
240 |
|
||||
241 | } |
|
238 | } | |
242 | } |
|
239 | } | |
243 |
|
240 | |||
244 | void ChartAxis::setShadesBrush(const QBrush &brush) |
|
241 | void ChartAxis::setShadesBrush(const QBrush &brush) | |
245 | { |
|
242 | { | |
246 |
foreach(QGraphicsItem* |
|
243 | foreach (QGraphicsItem *item , m_shades->childItems()) | |
247 | static_cast<QGraphicsRectItem*>(item)->setBrush(brush); |
|
244 | static_cast<QGraphicsRectItem*>(item)->setBrush(brush); | |
248 | } |
|
245 | } | |
249 | } |
|
|||
250 |
|
246 | |||
251 | void ChartAxis::setShadesPen(const QPen &pen) |
|
247 | void ChartAxis::setShadesPen(const QPen &pen) | |
252 | { |
|
248 | { | |
253 |
foreach(QGraphicsItem* |
|
249 | foreach (QGraphicsItem *item , m_shades->childItems()) | |
254 | static_cast<QGraphicsRectItem*>(item)->setPen(pen); |
|
250 | static_cast<QGraphicsRectItem*>(item)->setPen(pen); | |
255 | } |
|
251 | } | |
256 | } |
|
|||
257 |
|
252 | |||
258 | void ChartAxis::setArrowPen(const QPen &pen) |
|
253 | void ChartAxis::setArrowPen(const QPen &pen) | |
259 | { |
|
254 | { | |
260 |
foreach(QGraphicsItem* |
|
255 | foreach (QGraphicsItem *item , m_arrow->childItems()) | |
261 |
|
|
256 | static_cast<QGraphicsLineItem*>(item)->setPen(pen); | |
262 | } |
|
257 | } | |
263 | } |
|
|||
264 |
|
258 | |||
265 | void ChartAxis::setGridPen(const QPen &pen) |
|
259 | void ChartAxis::setGridPen(const QPen &pen) | |
266 | { |
|
260 | { | |
267 |
foreach(QGraphicsItem* |
|
261 | foreach (QGraphicsItem *item , m_grid->childItems()) | |
268 | static_cast<QGraphicsLineItem*>(item)->setPen(pen); |
|
262 | static_cast<QGraphicsLineItem*>(item)->setPen(pen); | |
269 | } |
|
263 | } | |
270 | } |
|
|||
271 |
|
264 | |||
272 | bool ChartAxis::isEmpty() |
|
265 | bool ChartAxis::isEmpty() | |
273 | { |
|
266 | { | |
274 | return !m_rect.isValid() || presenter()->chartsGeometry().isEmpty() || qFuzzyIsNull(m_min - m_max); |
|
267 | return !m_rect.isValid() || | |
|
268 | presenter()->chartsGeometry().isEmpty() || | |||
|
269 | qFuzzyIsNull(m_min - m_max); | |||
275 | } |
|
270 | } | |
276 |
|
271 | |||
277 | void ChartAxis::handleDomainUpdated() |
|
272 | void ChartAxis::handleDomainUpdated() | |
@@ -283,15 +278,12 void ChartAxis::handleDomainUpdated() | |||||
283 | if(m_chartAxis->orientation()==Qt::Horizontal) { |
|
278 | if (m_chartAxis->orientation() == Qt::Horizontal) { | |
284 | min = domain->minX(); |
|
279 | min = domain->minX(); | |
285 | max = domain->maxX(); |
|
280 | max = domain->maxX(); | |
286 | } |
|
281 | } else if (m_chartAxis->orientation() == Qt::Vertical) { | |
287 | else if (m_chartAxis->orientation()==Qt::Vertical) |
|
|||
288 | { |
|
|||
289 | min = domain->minY(); |
|
282 | min = domain->minY(); | |
290 | max = domain->maxY(); |
|
283 | max = domain->maxY(); | |
291 | } |
|
284 | } | |
292 |
|
285 | |||
293 | if (!qFuzzyIsNull(m_min - min) || !qFuzzyIsNull(m_max - max)) |
|
286 | if (!qFuzzyIsNull(m_min - min) || !qFuzzyIsNull(m_max - max)) { | |
294 | { |
|
|||
295 | m_min = min; |
|
287 | m_min = min; | |
296 | m_max = max; |
|
288 | m_max = max; | |
297 |
|
289 | |||
@@ -316,8 +308,8 void ChartAxis::handleDomainUpdated() | |||||
316 |
|
308 | |||
317 | void ChartAxis::handleAxisUpdated() |
|
309 | void ChartAxis::handleAxisUpdated() | |
318 | { |
|
310 | { | |
319 |
if(isEmpty()) |
|
311 | if (isEmpty()) | |
320 |
|
312 | return; | ||
321 |
|
313 | |||
322 | bool visible = m_chartAxis->isVisible(); |
|
314 | bool visible = m_chartAxis->isVisible(); | |
323 |
|
315 | |||
@@ -356,10 +348,10 void ChartAxis::hide() | |||||
356 |
|
348 | |||
357 | void ChartAxis::setGeometry(const QRectF &rect) |
|
349 | void ChartAxis::setGeometry(const QRectF &rect) | |
358 | { |
|
350 | { | |
359 |
|
||||
360 |
|
|
351 | m_rect = rect; | |
361 |
|
352 | |||
362 |
|
|
353 | if (isEmpty()) | |
|
354 | return; | |||
363 |
|
355 | |||
364 |
|
|
356 | if (!m_titleText.isNull()) { | |
365 |
|
|
357 | QFontMetrics fn(m_title->font()); | |
@@ -373,21 +365,19 void ChartAxis::setGeometry(const QRectF &rect) | |||||
373 |
|
|
365 | else if (orientation() == Qt::Vertical) | |
374 | size = chartRect.height(); |
|
366 | size = chartRect.height(); | |
375 |
|
367 | |||
376 |
|
|
368 | if (fn.boundingRect(m_titleText).width() > size) { | |
377 | { |
|
|||
378 |
|
|
369 | QString string = m_titleText + "..."; | |
379 |
|
|
370 | while (fn.boundingRect(string).width() > size && string.length() > 3) | |
380 | string.remove(string.length() - 4, 1); |
|
371 | string.remove(string.length() - 4, 1); | |
381 |
|
|
372 | m_title->setText(string); | |
382 |
|
|
373 | } else { | |
383 | else |
|
|||
384 | m_title->setText(m_titleText); |
|
374 | m_title->setText(m_titleText); | |
|
375 | } | |||
385 |
|
376 | |||
386 |
|
|
377 | QPointF center = chartRect.center() - m_title->boundingRect().center(); | |
387 |
|
|
378 | if (orientation() == Qt::Horizontal) { | |
388 |
|
|
379 | m_title->setPos(center.x(), m_rect.bottom() - m_title->boundingRect().height()); | |
389 | } |
|
380 | } else if (orientation() == Qt::Vertical) { | |
390 | else if(orientation()==Qt::Vertical) { |
|
|||
391 |
|
|
381 | m_title->setTransformOriginPoint(m_title->boundingRect().center()); | |
392 |
|
|
382 | m_title->setRotation(270); | |
393 |
|
|
383 | m_title->setPos(m_rect.left() - m_title->boundingRect().width() / 2 + m_title->boundingRect().height() / 2, center.y()); | |
@@ -396,7 +386,6 void ChartAxis::setGeometry(const QRectF &rect) | |||||
396 |
|
386 | |||
397 |
|
|
387 | QVector<qreal> layout = calculateLayout(); | |
398 |
|
|
388 | updateLayout(layout); | |
399 |
|
||||
400 | } |
|
389 | } | |
401 |
|
390 | |||
402 | void ChartAxis::setInternalRect(const QRectF &size) |
|
391 | void ChartAxis::setInternalRect(const QRectF &size) | |
@@ -429,8 +418,7 QStringList ChartAxis::createNumberLabels(qreal min, qreal max, int ticks) const | |||||
429 | qreal value = min + (i * (max - min)/ (ticks-1)); |
|
418 | qreal value = min + (i * (max - min) / (ticks - 1)); | |
430 | labels << QString::number(value,'f',n); |
|
419 | labels << QString::number(value, 'f', n); | |
431 | } |
|
420 | } | |
432 | } |
|
421 | } else { | |
433 | else { |
|
|||
434 | QByteArray array = format.toAscii(); |
|
422 | QByteArray array = format.toAscii(); | |
435 | for (int i=0; i< ticks; i++) { |
|
423 | for (int i = 0; i < ticks; i++) { | |
436 | qreal value = min + (i * (max - min)/ (ticks-1)); |
|
424 | qreal value = min + (i * (max - min) / (ticks - 1)); | |
@@ -463,27 +451,22 QSizeF ChartAxis::sizeHint(Qt::SizeHint which, const QSizeF& constraint) const | |||||
463 | QFontMetrics fn(m_title->font()); |
|
451 | QFontMetrics fn(m_title->font()); | |
464 | QSizeF sh; |
|
452 | QSizeF sh; | |
465 |
|
453 | |||
466 |
if(m_titleText.isNull()) |
|
454 | if (m_titleText.isNull()) | |
|
455 | return sh; | |||
467 |
|
456 | |||
468 | switch(which) { |
|
457 | switch (which) { | |
469 |
|
|
458 | case Qt::MinimumSize: | |
470 |
if(orientation()==Qt::Horizontal) |
|
459 | if (orientation() == Qt::Horizontal) | |
471 |
sh = QSizeF(fn.boundingRect |
|
460 | sh = QSizeF(fn.boundingRect("...").width(), fn.height()); | |
472 | } |
|
461 | else if (orientation() == Qt::Vertical) | |
473 | else if(orientation()==Qt::Vertical) { |
|
|||
474 |
sh = QSizeF(fn.height(),fn.boundingRect |
|
462 | sh = QSizeF(fn.height(), fn.boundingRect("...").width()); | |
475 | } |
|
|||
476 |
|
||||
477 | break; |
|
463 | break; | |
478 |
|
|
464 | case Qt::MaximumSize: | |
479 |
|
|
465 | case Qt::PreferredSize: | |
480 |
if(orientation()==Qt::Horizontal) |
|
466 | if (orientation() == Qt::Horizontal) | |
481 | sh = QSizeF(fn.boundingRect(m_chartAxis->title()).width(),fn.height()); |
|
467 | sh = QSizeF(fn.boundingRect(m_chartAxis->title()).width(), fn.height()); | |
482 | } |
|
468 | else if (orientation() == Qt::Vertical) | |
483 | else if(orientation()==Qt::Vertical) { |
|
|||
484 | sh = QSizeF(fn.height(),fn.boundingRect(m_chartAxis->title()).width()); |
|
469 | sh = QSizeF(fn.height(), fn.boundingRect(m_chartAxis->title()).width()); | |
485 | } |
|
|||
486 |
|
||||
487 | break; |
|
470 | break; | |
488 |
|
|
471 | default: | |
489 | break; |
|
472 | break; |
@@ -156,19 +156,16 public: | |||||
156 | explicit AxisItem(ChartAxis *axis, QGraphicsItem *parent = 0) : QGraphicsLineItem(parent), m_axis(axis) {} |
|
156 | explicit AxisItem(ChartAxis *axis, QGraphicsItem *parent = 0) : QGraphicsLineItem(parent), m_axis(axis) {} | |
157 |
|
157 | |||
158 | protected: |
|
158 | protected: | |
159 | void mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
159 | void mousePressEvent(QGraphicsSceneMouseEvent *event) { | |
160 | { |
|
|||
161 | Q_UNUSED(event) |
|
160 | Q_UNUSED(event) | |
162 | m_axis->axisSelected(); |
|
161 | m_axis->axisSelected(); | |
163 | } |
|
162 | } | |
164 |
|
163 | |||
165 | QRectF boundingRect() const |
|
164 | QRectF boundingRect() const { | |
166 | { |
|
|||
167 | return shape().boundingRect(); |
|
165 | return shape().boundingRect(); | |
168 | } |
|
166 | } | |
169 |
|
167 | |||
170 | QPainterPath shape() const |
|
168 | QPainterPath shape() const { | |
171 | { |
|
|||
172 | QPainterPath path = QGraphicsLineItem::shape(); |
|
169 | QPainterPath path = QGraphicsLineItem::shape(); | |
173 | QRectF rect = path.boundingRect(); |
|
170 | QRectF rect = path.boundingRect(); | |
174 | path.addRect(rect.adjusted(0,0,m_axis->axisType()!=ChartAxis::X_AXIS?8:0,m_axis->axisType()!=ChartAxis::Y_AXIS?8:0)); |
|
171 | path.addRect(rect.adjusted(0, 0, m_axis->axisType() != ChartAxis::X_AXIS ? 8 : 0, m_axis->axisType() != ChartAxis::Y_AXIS ? 8 : 0)); | |
@@ -177,7 +174,6 protected: | |||||
177 |
|
174 | |||
178 | private: |
|
175 | private: | |
179 | ChartAxis* m_axis; |
|
176 | ChartAxis* m_axis; | |
180 |
|
||||
181 | }; |
|
177 | }; | |
182 |
|
178 | |||
183 | QTCOMMERCIALCHART_END_NAMESPACE |
|
179 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -31,7 +31,8 static int label_padding = 5; | |||||
31 |
|
31 | |||
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
33 |
|
33 | |||
34 |
ChartDateTimeAxisX::ChartDateTimeAxisX(QAbstractAxis *axis,ChartPresenter *presenter) |
|
34 | ChartDateTimeAxisX::ChartDateTimeAxisX(QAbstractAxis *axis, ChartPresenter *presenter) | |
|
35 | : ChartAxis(axis, presenter), | |||
35 | m_tickCount(0) |
|
36 | m_tickCount(0) | |
36 | { |
|
37 | { | |
37 | } |
|
38 | } | |
@@ -74,7 +75,8 void ChartDateTimeAxisX::updateGeometry() | |||||
74 | { |
|
75 | { | |
75 | const QVector<qreal>& layout = ChartAxis::layout(); |
|
76 | const QVector<qreal>& layout = ChartAxis::layout(); | |
76 |
|
77 | |||
77 |
if(layout.isEmpty()) |
|
78 | if (layout.isEmpty()) | |
|
79 | return; | |||
78 |
|
80 | |||
79 | QStringList ticksList; |
|
81 | QStringList ticksList; | |
80 |
|
82 | |||
@@ -142,17 +144,13 QSizeF ChartDateTimeAxisX::sizeHint(Qt::SizeHint which, const QSizeF& constraint | |||||
142 |
|
|
144 | sh = QSizeF(fn.boundingRect("...").width(), fn.height()); | |
143 |
|
|
145 | break; | |
144 |
|
|
146 | case Qt::PreferredSize: { | |
145 |
|
||||
146 |
|
|
147 | const QVector<qreal>& layout = ChartAxis::layout(); | |
147 |
|
|
148 | if (layout.isEmpty()) | |
|
149 | break; | |||
148 |
|
|
150 | QStringList ticksList; | |
149 |
|
||||
150 |
|
||||
151 |
|
|
151 | qreal width = 0; | |
152 |
|
|
152 | qreal height = 0; | |
153 |
|
153 | for (int i = 0; i < ticksList.size(); ++i) { | ||
154 | for (int i = 0; i < ticksList.size(); ++i) |
|
|||
155 | { |
|
|||
156 |
|
|
154 | QRectF rect = fn.boundingRect(ticksList.at(i)); | |
157 |
|
|
155 | width += rect.width(); | |
158 |
|
|
156 | height += qMax(rect.height() + label_padding, height); |
@@ -53,7 +53,6 protected: | |||||
53 |
|
53 | |||
54 | private: |
|
54 | private: | |
55 | int m_tickCount; |
|
55 | int m_tickCount; | |
56 |
|
||||
57 | }; |
|
56 | }; | |
58 |
|
57 | |||
59 | QTCOMMERCIALCHART_END_NAMESPACE |
|
58 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -31,7 +31,8 static int label_padding = 5; | |||||
31 |
|
31 | |||
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
33 |
|
33 | |||
34 |
ChartDateTimeAxisY::ChartDateTimeAxisY(QAbstractAxis *axis,ChartPresenter *presenter) |
|
34 | ChartDateTimeAxisY::ChartDateTimeAxisY(QAbstractAxis *axis, ChartPresenter *presenter) | |
|
35 | : ChartAxis(axis, presenter), | |||
35 | m_tickCount(0) |
|
36 | m_tickCount(0) | |
36 | { |
|
37 | { | |
37 | } |
|
38 | } | |
@@ -75,7 +76,8 void ChartDateTimeAxisY::updateGeometry() | |||||
75 | { |
|
76 | { | |
76 | const QVector<qreal> &layout = ChartAxis::layout(); |
|
77 | const QVector<qreal> &layout = ChartAxis::layout(); | |
77 |
|
78 | |||
78 |
if(layout.isEmpty()) |
|
79 | if (layout.isEmpty()) | |
|
80 | return; | |||
79 |
|
81 | |||
80 | QStringList ticksList; |
|
82 | QStringList ticksList; | |
81 |
|
83 | |||
@@ -111,8 +113,7 void ChartDateTimeAxisY::updateGeometry() | |||||
111 |
|
|
113 | if (labelItem->pos().y() + rect.height() > height) { | |
112 |
|
|
114 | labelItem->setVisible(false); | |
113 |
|
|
115 | lineItem->setVisible(false); | |
114 |
|
|
116 | } else { | |
115 | else { |
|
|||
116 |
|
|
117 | labelItem->setVisible(true); | |
117 |
|
|
118 | lineItem->setVisible(true); | |
118 |
|
|
119 | height = labelItem->pos().y(); | |
@@ -147,17 +148,13 QSizeF ChartDateTimeAxisY::sizeHint(Qt::SizeHint which, const QSizeF& constraint | |||||
147 |
|
|
148 | sh = QSizeF(fn.boundingRect("...").width(), fn.height()); | |
148 |
|
|
149 | break; | |
149 |
|
|
150 | case Qt::PreferredSize: { | |
150 |
|
||||
151 |
|
|
151 | const QVector<qreal>& layout = ChartAxis::layout(); | |
152 |
|
|
152 | if (layout.isEmpty()) | |
|
153 | break; | |||
153 |
|
|
154 | QStringList ticksList; | |
154 |
|
||||
155 |
|
||||
156 |
|
|
155 | qreal width = 0; | |
157 |
|
|
156 | qreal height = 0; | |
158 |
|
157 | for (int i = 0; i < ticksList.size(); ++i) { | ||
159 | for (int i = 0; i < ticksList.size(); ++i) |
|
|||
160 | { |
|
|||
161 |
|
|
158 | QRectF rect = fn.boundingRect(ticksList.at(i)); | |
162 |
|
|
159 | width += rect.width(); | |
163 |
|
|
160 | height += qMax(rect.height() + label_padding, height); |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -301,12 +301,11 void QDateTimeAxisPrivate::handleDomainUpdated() | |||||
301 | Domain* domain = qobject_cast<Domain*>(sender()); |
|
301 | Domain* domain = qobject_cast<Domain*>(sender()); | |
302 | Q_ASSERT(domain); |
|
302 | Q_ASSERT(domain); | |
303 |
|
303 | |||
304 |
if(orientation()==Qt::Horizontal) |
|
304 | if (orientation() == Qt::Horizontal) | |
305 | q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minX()), QDateTime::fromMSecsSinceEpoch(domain->maxX())); |
|
305 | q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minX()), QDateTime::fromMSecsSinceEpoch(domain->maxX())); | |
306 |
|
|
306 | else if (orientation() == Qt::Vertical) | |
307 | q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minY()), QDateTime::fromMSecsSinceEpoch(domain->maxY())); |
|
307 | q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minY()), QDateTime::fromMSecsSinceEpoch(domain->maxY())); | |
308 | } |
|
308 | } | |
309 | } |
|
|||
310 |
|
309 | |||
311 |
|
310 | |||
312 | void QDateTimeAxisPrivate::setMin(const QVariant &min) |
|
311 | void QDateTimeAxisPrivate::setMin(const QVariant &min) | |
@@ -334,31 +333,26 void QDateTimeAxisPrivate::setRange(const QVariant &min, const QVariant &max) | |||||
334 | ChartAxis* QDateTimeAxisPrivate::createGraphics(ChartPresenter* presenter) |
|
333 | ChartAxis* QDateTimeAxisPrivate::createGraphics(ChartPresenter* presenter) | |
335 | { |
|
334 | { | |
336 | Q_Q(QDateTimeAxis); |
|
335 | Q_Q(QDateTimeAxis); | |
337 |
if(m_orientation == Qt::Vertical) |
|
336 | if (m_orientation == Qt::Vertical) | |
338 | return new ChartDateTimeAxisY(q,presenter); |
|
337 | return new ChartDateTimeAxisY(q, presenter); | |
339 | }else{ |
|
|||
340 |
|
|
338 | return new ChartDateTimeAxisX(q, presenter); | |
341 | } |
|
339 | } | |
342 |
|
340 | |||
343 | } |
|
|||
344 |
|
||||
345 | void QDateTimeAxisPrivate::intializeDomain(Domain* domain) |
|
341 | void QDateTimeAxisPrivate::intializeDomain(Domain* domain) | |
346 | { |
|
342 | { | |
347 | Q_Q(QDateTimeAxis); |
|
343 | Q_Q(QDateTimeAxis); | |
348 | if(m_max == m_min) { |
|
344 | if (m_max == m_min) { | |
349 |
if(m_orientation==Qt::Vertical) |
|
345 | if (m_orientation == Qt::Vertical) | |
350 | q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minY()), QDateTime::fromMSecsSinceEpoch(domain->maxY())); |
|
346 | q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minY()), QDateTime::fromMSecsSinceEpoch(domain->maxY())); | |
351 |
|
|
347 | else | |
352 | q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minX()), QDateTime::fromMSecsSinceEpoch(domain->maxX())); |
|
348 | q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minX()), QDateTime::fromMSecsSinceEpoch(domain->maxX())); | |
353 | } |
|
|||
354 | } else { |
|
349 | } else { | |
355 |
if(m_orientation==Qt::Vertical) |
|
350 | if (m_orientation == Qt::Vertical) | |
356 | domain->setRangeY(m_min.toMSecsSinceEpoch(), m_max.toMSecsSinceEpoch()); |
|
351 | domain->setRangeY(m_min.toMSecsSinceEpoch(), m_max.toMSecsSinceEpoch()); | |
357 |
|
|
352 | else | |
358 | domain->setRangeX(m_min.toMSecsSinceEpoch(), m_max.toMSecsSinceEpoch()); |
|
353 | domain->setRangeX(m_min.toMSecsSinceEpoch(), m_max.toMSecsSinceEpoch()); | |
359 |
|
|
354 | } | |
360 | } |
|
355 | } | |
361 | } |
|
|||
362 |
|
356 | |||
363 | #include "moc_qdatetimeaxis.cpp" |
|
357 | #include "moc_qdatetimeaxis.cpp" | |
364 | #include "moc_qdatetimeaxis_p.cpp" |
|
358 | #include "moc_qdatetimeaxis_p.cpp" |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -260,8 +260,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
260 | QChart when axis added. |
|
260 | QChart when axis added. | |
261 | */ |
|
261 | */ | |
262 |
|
262 | |||
263 |
QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent) |
|
263 | QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent) | |
264 | QObject(parent), |
|
264 | : QObject(parent), | |
265 | d_ptr(&d) |
|
265 | d_ptr(&d) | |
266 | { |
|
266 | { | |
267 | } |
|
267 | } | |
@@ -272,7 +272,8 d_ptr(&d) | |||||
272 |
|
272 | |||
273 | QAbstractAxis::~QAbstractAxis() |
|
273 | QAbstractAxis::~QAbstractAxis() | |
274 | { |
|
274 | { | |
275 | if(d_ptr->m_dataset) qFatal("Still binded axis detected !"); |
|
275 | if (d_ptr->m_dataset) | |
|
276 | qFatal("Still binded axis detected !"); | |||
276 | } |
|
277 | } | |
277 |
|
278 | |||
278 | /*! |
|
279 | /*! |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -31,7 +31,8 static int label_padding = 5; | |||||
31 |
|
31 | |||
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
33 |
|
33 | |||
34 |
ChartValueAxisX::ChartValueAxisX(QAbstractAxis *axis,ChartPresenter *presenter) |
|
34 | ChartValueAxisX::ChartValueAxisX(QAbstractAxis *axis, ChartPresenter *presenter) | |
|
35 | : ChartAxis(axis, presenter), | |||
35 | m_tickCount(0) |
|
36 | m_tickCount(0) | |
36 | { |
|
37 | { | |
37 | } |
|
38 | } | |
@@ -61,7 +62,8 void ChartValueAxisX::updateGeometry() | |||||
61 | { |
|
62 | { | |
62 | const QVector<qreal>& layout = ChartAxis::layout(); |
|
63 | const QVector<qreal>& layout = ChartAxis::layout(); | |
63 |
|
64 | |||
64 |
if(layout.isEmpty()) |
|
65 | if (layout.isEmpty()) | |
|
66 | return; | |||
65 |
|
67 | |||
66 | QStringList ticksList = createNumberLabels(m_min,m_max,layout.size()); |
|
68 | QStringList ticksList = createNumberLabels(m_min, m_max, layout.size()); | |
67 |
|
69 | |||
@@ -150,18 +152,14 QSizeF ChartValueAxisX::sizeHint(Qt::SizeHint which, const QSizeF& constraint) c | |||||
150 | sh = QSizeF(width,height); |
|
152 | sh = QSizeF(width, height); | |
151 | break; |
|
153 | break; | |
152 | } |
|
154 | } | |
153 |
case Qt::PreferredSize: |
|
155 | case Qt::PreferredSize: | |
154 | for (int i = 0; i < ticksList.size(); ++i) |
|
156 | for (int i = 0; i < ticksList.size(); ++i) | |
155 | { |
|
|||
156 | width+=fn.averageCharWidth()*ticksList.at(i).count(); |
|
157 | width += fn.averageCharWidth() * ticksList.at(i).count(); | |
157 |
|
||||
158 | } |
|
|||
159 | height=fn.height()+label_padding; |
|
158 | height = fn.height() + label_padding; | |
160 | width=qMax(width,base.width()); |
|
159 | width = qMax(width, base.width()); | |
161 | height+=base.height(); |
|
160 | height += base.height(); | |
162 | sh = QSizeF(width,height); |
|
161 | sh = QSizeF(width, height); | |
163 | break; |
|
162 | break; | |
164 | } |
|
|||
165 | default: |
|
163 | default: | |
166 | break; |
|
164 | break; | |
167 | } |
|
165 | } |
@@ -31,7 +31,8 static int label_padding = 5; | |||||
31 |
|
31 | |||
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
33 |
|
33 | |||
34 |
ChartValueAxisY::ChartValueAxisY(QAbstractAxis *axis,ChartPresenter *presenter) |
|
34 | ChartValueAxisY::ChartValueAxisY(QAbstractAxis *axis, ChartPresenter *presenter) | |
|
35 | : ChartAxis(axis, presenter), | |||
35 | m_tickCount(0) |
|
36 | m_tickCount(0) | |
36 | { |
|
37 | { | |
37 | } |
|
38 | } | |
@@ -62,7 +63,8 void ChartValueAxisY::updateGeometry() | |||||
62 | { |
|
63 | { | |
63 | const QVector<qreal> &layout = ChartAxis::layout(); |
|
64 | const QVector<qreal> &layout = ChartAxis::layout(); | |
64 |
|
65 | |||
65 |
if(layout.isEmpty()) |
|
66 | if (layout.isEmpty()) | |
|
67 | return; | |||
66 |
|
68 | |||
67 | QStringList ticksList = createNumberLabels(m_min,m_max,layout.size()); |
|
69 | QStringList ticksList = createNumberLabels(m_min, m_max, layout.size()); | |
68 |
|
70 | |||
@@ -94,8 +96,7 void ChartValueAxisY::updateGeometry() | |||||
94 |
|
96 | |||
95 | QString text = ticksList.at(i); |
|
97 | QString text = ticksList.at(i); | |
96 |
|
98 | |||
97 |
if (fn.boundingRect(text).width() > chartRect.left() - m_rect.left() - label_padding |
|
99 | if (fn.boundingRect(text).width() > chartRect.left() - m_rect.left() - label_padding) { | |
98 | { |
|
|||
99 | QString label = text + "..."; |
|
100 | QString label = text + "..."; | |
100 | while (fn.boundingRect(label).width() > chartRect.left() - m_rect.left() - label_padding && label.length() > 3) |
|
101 | while (fn.boundingRect(label).width() > chartRect.left() - m_rect.left() - label_padding && label.length() > 3) | |
101 | label.remove(label.length() - 4, 1); |
|
102 | label.remove(label.length() - 4, 1); | |
@@ -167,9 +168,7 QSizeF ChartValueAxisY::sizeHint(Qt::SizeHint which, const QSizeF& constraint) c | |||||
167 | break; |
|
168 | break; | |
168 | } |
|
169 | } | |
169 | case Qt::PreferredSize: |
|
170 | case Qt::PreferredSize: | |
170 | { |
|
171 | for (int i = 0; i < ticksList.size(); ++i) { | |
171 | for (int i = 0; i < ticksList.size(); ++i) |
|
|||
172 | { |
|
|||
173 | width=qMax(qreal(fn.averageCharWidth()*ticksList.at(i).count())+label_padding,width); |
|
172 | width = qMax(qreal(fn.averageCharWidth() * ticksList.at(i).count()) + label_padding, width); | |
174 | height+=fn.height(); |
|
173 | height += fn.height(); | |
175 | } |
|
174 | } | |
@@ -177,7 +176,6 QSizeF ChartValueAxisY::sizeHint(Qt::SizeHint which, const QSizeF& constraint) c | |||||
177 | width+=base.width(); |
|
176 | width += base.width(); | |
178 | sh = QSizeF(width,height); |
|
177 | sh = QSizeF(width, height); | |
179 | break; |
|
178 | break; | |
180 | } |
|
|||
181 | default: |
|
179 | default: | |
182 | break; |
|
180 | break; | |
183 | } |
|
181 | } |
@@ -160,7 +160,8 QValueAxis::QValueAxis(QObject *parent) : | |||||
160 | /*! |
|
160 | /*! | |
161 | \internal |
|
161 | \internal | |
162 | */ |
|
162 | */ | |
163 |
QValueAxis::QValueAxis(QValueAxisPrivate &d,QObject *parent) |
|
163 | QValueAxis::QValueAxis(QValueAxisPrivate &d, QObject *parent) | |
|
164 | : QAbstractAxis(d, parent) | |||
164 | { |
|
165 | { | |
165 |
|
166 | |||
166 | } |
|
167 | } | |
@@ -171,10 +172,9 QValueAxis::QValueAxis(QValueAxisPrivate &d,QObject *parent) : QAbstractAxis(d,p | |||||
171 | QValueAxis::~QValueAxis() |
|
172 | QValueAxis::~QValueAxis() | |
172 | { |
|
173 | { | |
173 | Q_D(QValueAxis); |
|
174 | Q_D(QValueAxis); | |
174 |
if(d->m_dataset) |
|
175 | if (d->m_dataset) | |
175 | d->m_dataset->removeAxis(this); |
|
176 | d->m_dataset->removeAxis(this); | |
176 | } |
|
177 | } | |
177 | } |
|
|||
178 |
|
178 | |||
179 | void QValueAxis::setMin(qreal min) |
|
179 | void QValueAxis::setMin(qreal min) | |
180 | { |
|
180 | { | |
@@ -209,12 +209,14 void QValueAxis::setRange(qreal min, qreal max) | |||||
209 | Q_D(QValueAxis); |
|
209 | Q_D(QValueAxis); | |
210 | bool changed = false; |
|
210 | bool changed = false; | |
211 |
|
211 | |||
212 |
if (min > max) |
|
212 | if (min > max) | |
|
213 | return; | |||
213 |
|
214 | |||
214 | if(d->m_niceNumbers) { |
|
215 | if (d->m_niceNumbers) { | |
215 | int ticks = d->m_tickCount; |
|
216 | int ticks = d->m_tickCount; | |
216 | d->looseNiceNumbers(min, max, ticks); |
|
217 | d->looseNiceNumbers(min, max, ticks); | |
217 |
if(ticks!=d->m_tickCount) |
|
218 | if (ticks != d->m_tickCount) | |
|
219 | setTickCount(ticks); | |||
218 | } |
|
220 | } | |
219 |
|
221 | |||
220 | if (!qFuzzyIsNull(d->m_min - min)) { |
|
222 | if (!qFuzzyIsNull(d->m_min - min)) { | |
@@ -262,11 +264,10 void QValueAxis::setNiceNumbersEnabled(bool enable) | |||||
262 | Q_D(QValueAxis); |
|
264 | Q_D(QValueAxis); | |
263 | if (d->m_niceNumbers != enable){ |
|
265 | if (d->m_niceNumbers != enable) { | |
264 | d->m_niceNumbers = enable; |
|
266 | d->m_niceNumbers = enable; | |
265 |
if(enable && !qFuzzyIsNull(d->m_max - d->m_min)) |
|
267 | if (enable && !qFuzzyIsNull(d->m_max - d->m_min)) | |
266 | setRange(d->m_min,d->m_max); |
|
268 | setRange(d->m_min, d->m_max); | |
267 |
|
|
269 | } | |
268 | } |
|
270 | } | |
269 | } |
|
|||
270 |
|
271 | |||
271 | bool QValueAxis::niceNumbersEnabled() const |
|
272 | bool QValueAxis::niceNumbersEnabled() const | |
272 | { |
|
273 | { | |
@@ -318,12 +319,11 void QValueAxisPrivate::handleDomainUpdated() | |||||
318 | Domain* domain = qobject_cast<Domain*>(sender()); |
|
319 | Domain* domain = qobject_cast<Domain*>(sender()); | |
319 | Q_ASSERT(domain); |
|
320 | Q_ASSERT(domain); | |
320 |
|
321 | |||
321 |
if(orientation()==Qt::Horizontal) |
|
322 | if (orientation() == Qt::Horizontal) | |
322 | q->setRange(domain->minX(),domain->maxX()); |
|
323 | q->setRange(domain->minX(), domain->maxX()); | |
323 |
|
|
324 | else if (orientation() == Qt::Vertical) | |
324 | q->setRange(domain->minY(),domain->maxY()); |
|
325 | q->setRange(domain->minY(), domain->maxY()); | |
325 | } |
|
326 | } | |
326 | } |
|
|||
327 |
|
327 | |||
328 |
|
328 | |||
329 | void QValueAxisPrivate::setMin(const QVariant &min) |
|
329 | void QValueAxisPrivate::setMin(const QVariant &min) | |
@@ -331,7 +331,8 void QValueAxisPrivate::setMin(const QVariant &min) | |||||
331 | Q_Q(QValueAxis); |
|
331 | Q_Q(QValueAxis); | |
332 | bool ok; |
|
332 | bool ok; | |
333 | qreal value = min.toReal(&ok); |
|
333 | qreal value = min.toReal(&ok); | |
334 | if(ok) q->setMin(value); |
|
334 | if (ok) | |
|
335 | q->setMin(value); | |||
335 | } |
|
336 | } | |
336 |
|
337 | |||
337 | void QValueAxisPrivate::setMax(const QVariant &max) |
|
338 | void QValueAxisPrivate::setMax(const QVariant &max) | |
@@ -340,7 +341,8 void QValueAxisPrivate::setMax(const QVariant &max) | |||||
340 | Q_Q(QValueAxis); |
|
341 | Q_Q(QValueAxis); | |
341 | bool ok; |
|
342 | bool ok; | |
342 | qreal value = max.toReal(&ok); |
|
343 | qreal value = max.toReal(&ok); | |
343 | if(ok) q->setMax(value); |
|
344 | if (ok) | |
|
345 | q->setMax(value); | |||
344 | } |
|
346 | } | |
345 |
|
347 | |||
346 | void QValueAxisPrivate::setRange(const QVariant &min, const QVariant &max) |
|
348 | void QValueAxisPrivate::setRange(const QVariant &min, const QVariant &max) | |
@@ -350,37 +352,33 void QValueAxisPrivate::setRange(const QVariant &min, const QVariant &max) | |||||
350 | bool ok2; |
|
352 | bool ok2; | |
351 | qreal value1 = min.toReal(&ok1); |
|
353 | qreal value1 = min.toReal(&ok1); | |
352 | qreal value2 = max.toReal(&ok2); |
|
354 | qreal value2 = max.toReal(&ok2); | |
353 | if(ok1&&ok2) q->setRange(value1,value2); |
|
355 | if (ok1 && ok2) | |
|
356 | q->setRange(value1, value2); | |||
354 | } |
|
357 | } | |
355 |
|
358 | |||
356 | ChartAxis* QValueAxisPrivate::createGraphics(ChartPresenter* presenter) |
|
359 | ChartAxis* QValueAxisPrivate::createGraphics(ChartPresenter* presenter) | |
357 | { |
|
360 | { | |
358 | Q_Q(QValueAxis); |
|
361 | Q_Q(QValueAxis); | |
359 |
if(m_orientation == Qt::Vertical) |
|
362 | if (m_orientation == Qt::Vertical) | |
360 | return new ChartValueAxisY(q,presenter); |
|
363 | return new ChartValueAxisY(q, presenter); | |
361 | }else{ |
|
|||
362 |
|
|
364 | return new ChartValueAxisX(q, presenter); | |
363 | } |
|
365 | } | |
364 |
|
366 | |||
365 | } |
|
|||
366 |
|
||||
367 | void QValueAxisPrivate::intializeDomain(Domain* domain) |
|
367 | void QValueAxisPrivate::intializeDomain(Domain* domain) | |
368 | { |
|
368 | { | |
369 | Q_Q(QValueAxis); |
|
369 | Q_Q(QValueAxis); | |
370 | if(qFuzzyCompare(m_max,m_min)) { |
|
370 | if (qFuzzyCompare(m_max, m_min)) { | |
371 |
if(m_orientation==Qt::Vertical) |
|
371 | if (m_orientation == Qt::Vertical) | |
372 | q->setRange(domain->minY(),domain->maxY()); |
|
372 | q->setRange(domain->minY(), domain->maxY()); | |
373 |
|
|
373 | else | |
374 | q->setRange(domain->minX(), domain->maxX()); |
|
374 | q->setRange(domain->minX(), domain->maxX()); | |
375 | } |
|
|||
376 | } else { |
|
375 | } else { | |
377 |
if(m_orientation==Qt::Vertical) |
|
376 | if (m_orientation == Qt::Vertical) | |
378 | domain->setRangeY(m_min, m_max); |
|
377 | domain->setRangeY(m_min, m_max); | |
379 |
|
|
378 | else | |
380 | domain->setRangeX(m_min, m_max); |
|
379 | domain->setRangeX(m_min, m_max); | |
381 |
|
|
380 | } | |
382 | } |
|
381 | } | |
383 | } |
|
|||
384 |
|
382 | |||
385 | //algorithm defined by Paul S.Heckbert GraphicalGems I |
|
383 | //algorithm defined by Paul S.Heckbert GraphicalGems I | |
386 |
|
384 | |||
@@ -407,8 +405,7 qreal QValueAxisPrivate::niceNumber(qreal x,bool ceiling) const | |||||
407 | else if(q <= 2.0) q=2; |
|
405 | else if (q <= 2.0) q = 2; | |
408 | else if(q <= 5.0) q=5; |
|
406 | else if (q <= 5.0) q = 5; | |
409 | else q=10; |
|
407 | else q = 10; | |
410 | } |
|
408 | } else { | |
411 | else { |
|
|||
412 | if(q < 1.5) q=1; |
|
409 | if (q < 1.5) q = 1; | |
413 | else if(q < 3.0) q=2; |
|
410 | else if (q < 3.0) q = 2; | |
414 | else if(q < 7.0) q=5; |
|
411 | else if (q < 7.0) q = 5; |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -71,7 +71,6 void AbstractBarChartItem::applyLayout(const QVector<QRectF> &layout) | |||||
71 | if (m_animation) { |
|
71 | if (m_animation) { | |
72 | m_animation->setup(m_layout,layout); |
|
72 | m_animation->setup(m_layout, layout); | |
73 | presenter()->startAnimation(m_animation); |
|
73 | presenter()->startAnimation(m_animation); | |
74 |
|
||||
75 | } else { |
|
74 | } else { | |
76 | setLayout(layout); |
|
75 | setLayout(layout); | |
77 | update(); |
|
76 | update(); | |
@@ -90,10 +89,9 void AbstractBarChartItem::setLayout(const QVector<QRectF> &layout) | |||||
90 |
|
89 | |||
91 | m_layout = layout; |
|
90 | m_layout = layout; | |
92 |
|
91 | |||
93 |
for (int i=0; i < m_bars.count(); i++) |
|
92 | for (int i = 0; i < m_bars.count(); i++) | |
94 | m_bars.at(i)->setRect(layout.at(i)); |
|
93 | m_bars.at(i)->setRect(layout.at(i)); | |
95 | } |
|
94 | } | |
96 | } |
|
|||
97 | //handlers |
|
95 | //handlers | |
98 |
|
96 | |||
99 | void AbstractBarChartItem::handleDomainUpdated() |
|
97 | void AbstractBarChartItem::handleDomainUpdated() | |
@@ -114,27 +112,23 void AbstractBarChartItem::handleGeometryChanged(const QRectF &rect) | |||||
114 |
|
112 | |||
115 | void AbstractBarChartItem::handleLayoutChanged() |
|
113 | void AbstractBarChartItem::handleLayoutChanged() | |
116 | { |
|
114 | { | |
117 |
if ((m_rect.width() <= 0) || (m_rect.height() <= 0)) |
|
115 | if ((m_rect.width() <= 0) || (m_rect.height() <= 0)) | |
118 | // rect size zero. |
|
116 | return; // rect size zero. | |
119 | return; |
|
|||
120 | } |
|
|||
121 | QVector<QRectF> layout = calculateLayout(); |
|
117 | QVector<QRectF> layout = calculateLayout(); | |
122 | applyLayout(layout); |
|
118 | applyLayout(layout); | |
123 | } |
|
119 | } | |
124 |
|
120 | |||
125 | void AbstractBarChartItem::handleLabelsVisibleChanged(bool visible) |
|
121 | void AbstractBarChartItem::handleLabelsVisibleChanged(bool visible) | |
126 | { |
|
122 | { | |
127 |
foreach (QGraphicsSimpleTextItem* |
|
123 | foreach (QGraphicsSimpleTextItem *label, m_labels) | |
128 | label->setVisible(visible); |
|
124 | label->setVisible(visible); | |
129 | } |
|
|||
130 | update(); |
|
125 | update(); | |
131 | } |
|
126 | } | |
132 |
|
127 | |||
133 | void AbstractBarChartItem::handleDataStructureChanged() |
|
128 | void AbstractBarChartItem::handleDataStructureChanged() | |
134 | { |
|
129 | { | |
135 |
foreach(QGraphicsItem *item, childItems()) |
|
130 | foreach (QGraphicsItem *item, childItems()) | |
136 | delete item; |
|
131 | delete item; | |
137 | } |
|
|||
138 |
|
132 | |||
139 | m_bars.clear(); |
|
133 | m_bars.clear(); | |
140 | m_labels.clear(); |
|
134 | m_labels.clear(); |
@@ -25,8 +25,8 | |||||
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 |
HorizontalBarChartItem::HorizontalBarChartItem(QAbstractBarSeries *series, ChartPresenter *presenter) |
|
28 | HorizontalBarChartItem::HorizontalBarChartItem(QAbstractBarSeries *series, ChartPresenter *presenter) | |
29 | AbstractBarChartItem(series, presenter) |
|
29 | : AbstractBarChartItem(series, presenter) | |
30 | { |
|
30 | { | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
@@ -67,22 +67,20 QVector<QRectF> HorizontalBarChartItem::calculateLayout() | |||||
67 | layout.append(rect); |
|
67 | layout.append(rect); | |
68 | bar->setPen(barSet->m_pen); |
|
68 | bar->setPen(barSet->m_pen); | |
69 | bar->setBrush(barSet->m_brush); |
|
69 | bar->setBrush(barSet->m_brush); | |
70 |
if (qFuzzyIsNull(rectHeight)) |
|
70 | if (qFuzzyIsNull(rectHeight)) | |
71 | bar->setVisible(false); |
|
71 | bar->setVisible(false); | |
72 |
|
|
72 | else | |
73 | bar->setVisible(barsVisible); |
|
73 | bar->setVisible(barsVisible); | |
74 | } |
|
|||
75 |
|
74 | |||
76 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); |
|
75 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); | |
77 |
|
76 | |||
78 |
if (!qFuzzyIsNull(barSet->value(category))) |
|
77 | if (!qFuzzyIsNull(barSet->value(category))) | |
79 | label->setText(QString::number(barSet->value(category))); |
|
78 | label->setText(QString::number(barSet->value(category))); | |
80 |
|
|
79 | else | |
81 | label->setText(QString("")); |
|
80 | label->setText(QString("")); | |
82 | } |
|
|||
83 |
|
81 | |||
84 | label->setPos(xPos + (rect.width()/2 - label->boundingRect().width()/2) |
|
82 | label->setPos(xPos + (rect.width() / 2 - label->boundingRect().width() / 2), | |
85 |
|
|
83 | yPos - rectHeight / 2 - label->boundingRect().height() / 2); | |
86 | label->setFont(barSet->m_labelFont); |
|
84 | label->setFont(barSet->m_labelFont); | |
87 | label->setBrush(barSet->m_labelBrush); |
|
85 | label->setBrush(barSet->m_labelBrush); | |
88 |
|
86 |
@@ -72,10 +72,9 QHorizontalBarSeries::QHorizontalBarSeries(QObject *parent) : | |||||
72 | QHorizontalBarSeries::~QHorizontalBarSeries() |
|
72 | QHorizontalBarSeries::~QHorizontalBarSeries() | |
73 | { |
|
73 | { | |
74 | Q_D(QHorizontalBarSeries); |
|
74 | Q_D(QHorizontalBarSeries); | |
75 |
if(d->m_dataset) |
|
75 | if (d->m_dataset) | |
76 | d->m_dataset->removeSeries(this); |
|
76 | d->m_dataset->removeSeries(this); | |
77 | } |
|
77 | } | |
78 | } |
|
|||
79 |
|
78 | |||
80 | /*! |
|
79 | /*! | |
81 | Returns QChartSeries::SeriesTypeHorizontalBar. |
|
80 | Returns QChartSeries::SeriesTypeHorizontalBar. | |
@@ -113,9 +112,8 ChartElement* QHorizontalBarSeriesPrivate::createGraphics(ChartPresenter* presen | |||||
113 | Q_Q(QHorizontalBarSeries); |
|
112 | Q_Q(QHorizontalBarSeries); | |
114 |
|
113 | |||
115 | HorizontalBarChartItem* bar = new HorizontalBarChartItem(q,presenter); |
|
114 | HorizontalBarChartItem* bar = new HorizontalBarChartItem(q, presenter); | |
116 |
if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
115 | if (presenter->animationOptions().testFlag(QChart::SeriesAnimations)) | |
117 | bar->setAnimation(new HorizontalBarAnimation(bar)); |
|
116 | bar->setAnimation(new HorizontalBarAnimation(bar)); | |
118 | } |
|
|||
119 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
117 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
120 | return bar; |
|
118 | return bar; | |
121 | } |
|
119 | } |
@@ -65,11 +65,10 QVector<QRectF> HorizontalPercentBarChartItem::calculateLayout() | |||||
65 | layout.append(rect); |
|
65 | layout.append(rect); | |
66 | bar->setPen(barSet->m_pen); |
|
66 | bar->setPen(barSet->m_pen); | |
67 | bar->setBrush(barSet->m_brush); |
|
67 | bar->setBrush(barSet->m_brush); | |
68 |
if (qFuzzyIsNull(rectHeight)) |
|
68 | if (qFuzzyIsNull(rectHeight)) | |
69 | bar->setVisible(false); |
|
69 | bar->setVisible(false); | |
70 |
|
|
70 | else | |
71 | bar->setVisible(barsVisible); |
|
71 | bar->setVisible(barsVisible); | |
72 | } |
|
|||
73 |
|
72 | |||
74 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); |
|
73 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); | |
75 |
|
74 | |||
@@ -83,8 +82,8 QVector<QRectF> HorizontalPercentBarChartItem::calculateLayout() | |||||
83 | label->setText(QString("")); |
|
82 | label->setText(QString("")); | |
84 | } |
|
83 | } | |
85 |
|
84 | |||
86 | label->setPos(xPos + (rect.width()/2 - label->boundingRect().width()/2) |
|
85 | label->setPos(xPos + (rect.width() / 2 - label->boundingRect().width() / 2), | |
87 |
|
|
86 | yPos - rectHeight / 2 - label->boundingRect().height() / 2); | |
88 | label->setFont(barSet->m_labelFont); |
|
87 | label->setFont(barSet->m_labelFont); | |
89 | label->setBrush(barSet->m_labelBrush); |
|
88 | label->setBrush(barSet->m_labelBrush); | |
90 |
|
89 |
@@ -77,10 +77,9 QAbstractSeries::SeriesType QHorizontalPercentBarSeries::type() const | |||||
77 | QHorizontalPercentBarSeries::~QHorizontalPercentBarSeries() |
|
77 | QHorizontalPercentBarSeries::~QHorizontalPercentBarSeries() | |
78 | { |
|
78 | { | |
79 | Q_D(QHorizontalPercentBarSeries); |
|
79 | Q_D(QHorizontalPercentBarSeries); | |
80 |
if(d->m_dataset) |
|
80 | if (d->m_dataset) | |
81 | d->m_dataset->removeSeries(this); |
|
81 | d->m_dataset->removeSeries(this); | |
82 | } |
|
82 | } | |
83 | } |
|
|||
84 |
|
83 | |||
85 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
84 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
86 |
|
85 | |||
@@ -110,9 +109,8 ChartElement* QHorizontalPercentBarSeriesPrivate::createGraphics(ChartPresenter* | |||||
110 | Q_Q(QHorizontalPercentBarSeries); |
|
109 | Q_Q(QHorizontalPercentBarSeries); | |
111 |
|
110 | |||
112 | HorizontalPercentBarChartItem* bar = new HorizontalPercentBarChartItem(q,presenter); |
|
111 | HorizontalPercentBarChartItem* bar = new HorizontalPercentBarChartItem(q, presenter); | |
113 |
if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
112 | if (presenter->animationOptions().testFlag(QChart::SeriesAnimations)) | |
114 | bar->setAnimation(new HorizontalPercentBarAnimation(bar)); |
|
113 | bar->setAnimation(new HorizontalPercentBarAnimation(bar)); | |
115 | } |
|
|||
116 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
114 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
117 | return bar; |
|
115 | return bar; | |
118 | } |
|
116 | } |
@@ -62,33 +62,31 QVector<QRectF> HorizontalStackedBarChartItem::calculateLayout() | |||||
62 |
|
62 | |||
63 | bar->setPen(barSet->m_pen); |
|
63 | bar->setPen(barSet->m_pen); | |
64 | bar->setBrush(barSet->m_brush); |
|
64 | bar->setBrush(barSet->m_brush); | |
65 |
if (qFuzzyIsNull(rectHeight)) |
|
65 | if (qFuzzyIsNull(rectHeight)) | |
66 | bar->setVisible(false); |
|
66 | bar->setVisible(false); | |
67 |
|
|
67 | else | |
68 | bar->setVisible(barsVisible); |
|
68 | bar->setVisible(barsVisible); | |
69 | } |
|
|||
70 |
|
69 | |||
71 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); |
|
70 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); | |
72 |
|
71 | |||
73 |
if (!qFuzzyIsNull(barSet->value(category))) |
|
72 | if (!qFuzzyIsNull(barSet->value(category))) | |
74 | label->setText(QString::number(barSet->value(category))); |
|
73 | label->setText(QString::number(barSet->value(category))); | |
75 |
|
|
74 | else | |
76 | label->setText(QString("")); |
|
75 | label->setText(QString("")); | |
77 | } |
|
|||
78 | label->setFont(barSet->m_labelFont); |
|
76 | label->setFont(barSet->m_labelFont); | |
79 | label->setBrush(barSet->m_labelBrush); |
|
77 | label->setBrush(barSet->m_labelBrush); | |
80 |
|
78 | |||
81 | if (rectWidth > 0) { |
|
79 | if (rectWidth > 0) { | |
82 | QRectF rect(xMax, yPos - rectHeight, rectWidth, rectHeight); |
|
80 | QRectF rect(xMax, yPos - rectHeight, rectWidth, rectHeight); | |
83 | layout.append(rect); |
|
81 | layout.append(rect); | |
84 | label->setPos(xMax + (rect.width()/2 - label->boundingRect().width()/2) |
|
82 | label->setPos(xMax + (rect.width() / 2 - label->boundingRect().width() / 2), | |
85 |
|
|
83 | yPos - rectHeight / 2 - label->boundingRect().height() / 2); | |
86 | xMax += rectWidth; |
|
84 | xMax += rectWidth; | |
87 | } else { |
|
85 | } else { | |
88 | QRectF rect(xMin, yPos - rectHeight, rectWidth, rectHeight); |
|
86 | QRectF rect(xMin, yPos - rectHeight, rectWidth, rectHeight); | |
89 | layout.append(rect); |
|
87 | layout.append(rect); | |
90 | label->setPos(xMin + (rect.width()/2 - label->boundingRect().width()/2) |
|
88 | label->setPos(xMin + (rect.width() / 2 - label->boundingRect().width() / 2), | |
91 |
|
|
89 | yPos - rectHeight / 2 - label->boundingRect().height() / 2); | |
92 | xMin += rectWidth; |
|
90 | xMin += rectWidth; | |
93 | } |
|
91 | } | |
94 | itemIndex++; |
|
92 | itemIndex++; |
@@ -68,10 +68,9 QHorizontalStackedBarSeries::QHorizontalStackedBarSeries(QObject *parent) : | |||||
68 | QHorizontalStackedBarSeries::~QHorizontalStackedBarSeries() |
|
68 | QHorizontalStackedBarSeries::~QHorizontalStackedBarSeries() | |
69 | { |
|
69 | { | |
70 | Q_D(QHorizontalStackedBarSeries); |
|
70 | Q_D(QHorizontalStackedBarSeries); | |
71 |
if(d->m_dataset) |
|
71 | if (d->m_dataset) | |
72 | d->m_dataset->removeSeries(this); |
|
72 | d->m_dataset->removeSeries(this); | |
73 | } |
|
73 | } | |
74 | } |
|
|||
75 |
|
74 | |||
76 | /*! |
|
75 | /*! | |
77 | Returns QChartSeries::SeriesTypeHorizontalStackedBar. |
|
76 | Returns QChartSeries::SeriesTypeHorizontalStackedBar. | |
@@ -109,9 +108,8 ChartElement* QHorizontalStackedBarSeriesPrivate::createGraphics(ChartPresenter* | |||||
109 | Q_Q(QHorizontalStackedBarSeries); |
|
108 | Q_Q(QHorizontalStackedBarSeries); | |
110 |
|
109 | |||
111 | HorizontalStackedBarChartItem* bar = new HorizontalStackedBarChartItem(q,presenter); |
|
110 | HorizontalStackedBarChartItem* bar = new HorizontalStackedBarChartItem(q, presenter); | |
112 |
if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
111 | if (presenter->animationOptions().testFlag(QChart::SeriesAnimations)) | |
113 | bar->setAnimation(new HorizontalStackedBarAnimation(bar)); |
|
112 | bar->setAnimation(new HorizontalStackedBarAnimation(bar)); | |
114 | } |
|
|||
115 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
113 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
116 | return bar; |
|
114 | return bar; | |
117 | } |
|
115 | } |
@@ -198,8 +198,8 QAbstractBarSeries::~QAbstractBarSeries() | |||||
198 | /*! |
|
198 | /*! | |
199 | \internal |
|
199 | \internal | |
200 | */ |
|
200 | */ | |
201 |
QAbstractBarSeries::QAbstractBarSeries(QAbstractBarSeriesPrivate &o, QObject *parent) |
|
201 | QAbstractBarSeries::QAbstractBarSeries(QAbstractBarSeriesPrivate &o, QObject *parent) | |
202 | QAbstractSeries(o,parent) |
|
202 | : QAbstractSeries(o, parent) | |
203 | { |
|
203 | { | |
204 | Q_D(QAbstractSeries); |
|
204 | Q_D(QAbstractSeries); | |
205 | QObject::connect(this,SIGNAL(countChanged()),d,SIGNAL(countChanged())); |
|
205 | QObject::connect(this, SIGNAL(countChanged()), d, SIGNAL(countChanged())); | |
@@ -333,11 +333,10 void QAbstractBarSeries::clear() | |||||
333 | if (success) { |
|
333 | if (success) { | |
334 | emit barsetsRemoved(sets); |
|
334 | emit barsetsRemoved(sets); | |
335 | emit countChanged(); |
|
335 | emit countChanged(); | |
336 |
foreach (QBarSet* |
|
336 | foreach (QBarSet *set, sets) | |
337 | delete set; |
|
337 | delete set; | |
338 |
|
|
338 | } | |
339 | } |
|
339 | } | |
340 | } |
|
|||
341 |
|
340 | |||
342 | /*! |
|
341 | /*! | |
343 | Returns number of sets in series. |
|
342 | Returns number of sets in series. | |
@@ -393,19 +392,17 int QAbstractBarSeriesPrivate::categoryCount() const | |||||
393 | // No categories defined. return count of longest set. |
|
392 | // No categories defined. return count of longest set. | |
394 | int count = 0; |
|
393 | int count = 0; | |
395 | for (int i=0; i<m_barSets.count(); i++) { |
|
394 | for (int i = 0; i < m_barSets.count(); i++) { | |
396 |
if (m_barSets.at(i)->count() > count) |
|
395 | if (m_barSets.at(i)->count() > count) | |
397 | count = m_barSets.at(i)->count(); |
|
396 | count = m_barSets.at(i)->count(); | |
398 |
|
|
397 | } | |
399 | } |
|
|||
400 |
|
398 | |||
401 | return count; |
|
399 | return count; | |
402 | } |
|
400 | } | |
403 |
|
401 | |||
404 | void QAbstractBarSeriesPrivate::setBarWidth(qreal width) |
|
402 | void QAbstractBarSeriesPrivate::setBarWidth(qreal width) | |
405 | { |
|
403 | { | |
406 |
if (width < 0.0) |
|
404 | if (width < 0.0) | |
407 | width = 0.0; |
|
405 | width = 0.0; | |
408 | } |
|
|||
409 | m_barWidth = width; |
|
406 | m_barWidth = width; | |
410 | emit updatedLayout(); |
|
407 | emit updatedLayout(); | |
411 | } |
|
408 | } | |
@@ -434,9 +431,9 void QAbstractBarSeriesPrivate::setLabelsVisible(bool visible) | |||||
434 |
|
431 | |||
435 | qreal QAbstractBarSeriesPrivate::min() |
|
432 | qreal QAbstractBarSeriesPrivate::min() | |
436 | { |
|
433 | { | |
437 |
if (m_barSets.count() <= 0) |
|
434 | if (m_barSets.count() <= 0) | |
438 | return 0; |
|
435 | return 0; | |
439 | } |
|
436 | ||
440 | qreal min = INT_MAX; |
|
437 | qreal min = INT_MAX; | |
441 |
|
438 | |||
442 | for (int i = 0; i < m_barSets.count(); i++) { |
|
439 | for (int i = 0; i < m_barSets.count(); i++) { | |
@@ -452,9 +449,9 qreal QAbstractBarSeriesPrivate::min() | |||||
452 |
|
449 | |||
453 | qreal QAbstractBarSeriesPrivate::max() |
|
450 | qreal QAbstractBarSeriesPrivate::max() | |
454 | { |
|
451 | { | |
455 |
if (m_barSets.count() <= 0) |
|
452 | if (m_barSets.count() <= 0) | |
456 | return 0; |
|
453 | return 0; | |
457 | } |
|
454 | ||
458 | qreal max = INT_MIN; |
|
455 | qreal max = INT_MIN; | |
459 |
|
456 | |||
460 | for (int i = 0; i < m_barSets.count(); i++) { |
|
457 | for (int i = 0; i < m_barSets.count(); i++) { | |
@@ -471,32 +468,25 qreal QAbstractBarSeriesPrivate::max() | |||||
471 |
|
468 | |||
472 | qreal QAbstractBarSeriesPrivate::valueAt(int set, int category) |
|
469 | qreal QAbstractBarSeriesPrivate::valueAt(int set, int category) | |
473 | { |
|
470 | { | |
474 |
if ((set < 0) || (set >= m_barSets.count())) |
|
471 | if ((set < 0) || (set >= m_barSets.count())) | |
475 | // No set, no value. |
|
472 | return 0; // No set, no value. | |
476 | return 0; |
|
473 | else if ((category < 0) || (category >= m_barSets.at(set)->count())) | |
477 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { |
|
474 | return 0; // No category, no value. | |
478 | // No category, no value. |
|
|||
479 | return 0; |
|
|||
480 | } |
|
|||
481 |
|
475 | |||
482 | return m_barSets.at(set)->at(category); |
|
476 | return m_barSets.at(set)->at(category); | |
483 | } |
|
477 | } | |
484 |
|
478 | |||
485 | qreal QAbstractBarSeriesPrivate::percentageAt(int set, int category) |
|
479 | qreal QAbstractBarSeriesPrivate::percentageAt(int set, int category) | |
486 | { |
|
480 | { | |
487 |
if ((set < 0) || (set >= m_barSets.count())) |
|
481 | if ((set < 0) || (set >= m_barSets.count())) | |
488 | // No set, no value. |
|
482 | return 0; // No set, no value. | |
489 | return 0; |
|
483 | else if ((category < 0) || (category >= m_barSets.at(set)->count())) | |
490 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { |
|
484 | return 0; // No category, no value. | |
491 | // No category, no value. |
|
|||
492 | return 0; |
|
|||
493 | } |
|
|||
494 |
|
485 | |||
495 | qreal value = m_barSets.at(set)->at(category); |
|
486 | qreal value = m_barSets.at(set)->at(category); | |
496 | qreal sum = categorySum(category); |
|
487 | qreal sum = categorySum(category); | |
497 |
if ( |
|
488 | if (qFuzzyIsNull(sum)) | |
498 | return 0; |
|
489 | return 0; | |
499 | } |
|
|||
500 |
|
490 | |||
501 | return value / sum; |
|
491 | return value / sum; | |
502 | } |
|
492 | } | |
@@ -537,9 +527,9 qreal QAbstractBarSeriesPrivate::maxCategorySum() | |||||
537 |
|
527 | |||
538 | qreal QAbstractBarSeriesPrivate::minX() |
|
528 | qreal QAbstractBarSeriesPrivate::minX() | |
539 | { |
|
529 | { | |
540 |
if (m_barSets.count() <= 0) |
|
530 | if (m_barSets.count() <= 0) | |
541 | return 0; |
|
531 | return 0; | |
542 | } |
|
532 | ||
543 | qreal min = INT_MAX; |
|
533 | qreal min = INT_MAX; | |
544 |
|
534 | |||
545 | for (int i = 0; i < m_barSets.count(); i++) { |
|
535 | for (int i = 0; i < m_barSets.count(); i++) { | |
@@ -555,9 +545,9 qreal QAbstractBarSeriesPrivate::minX() | |||||
555 |
|
545 | |||
556 | qreal QAbstractBarSeriesPrivate::maxX() |
|
546 | qreal QAbstractBarSeriesPrivate::maxX() | |
557 | { |
|
547 | { | |
558 |
if (m_barSets.count() <= 0) |
|
548 | if (m_barSets.count() <= 0) | |
559 | return 0; |
|
549 | return 0; | |
560 | } |
|
550 | ||
561 | qreal max = INT_MIN; |
|
551 | qreal max = INT_MIN; | |
562 |
|
552 | |||
563 | for (int i = 0; i < m_barSets.count(); i++) { |
|
553 | for (int i = 0; i < m_barSets.count(); i++) { | |
@@ -613,10 +603,9 qreal QAbstractBarSeriesPrivate::top() | |||||
613 | int count = categoryCount(); |
|
603 | int count = categoryCount(); | |
614 | for (int i=0; i<count; i++) { |
|
604 | for (int i = 0; i < count; i++) { | |
615 | qreal temp = categoryTop(i); |
|
605 | qreal temp = categoryTop(i); | |
616 |
if (temp > top) |
|
606 | if (temp > top) | |
617 | top = temp; |
|
607 | top = temp; | |
618 |
|
|
608 | } | |
619 | } |
|
|||
620 | return top; |
|
609 | return top; | |
621 | } |
|
610 | } | |
622 |
|
611 | |||
@@ -627,10 +616,9 qreal QAbstractBarSeriesPrivate::bottom() | |||||
627 | int count = categoryCount(); |
|
616 | int count = categoryCount(); | |
628 | for (int i=0; i<count; i++) { |
|
617 | for (int i = 0; i < count; i++) { | |
629 | qreal temp = categoryBottom(i); |
|
618 | qreal temp = categoryBottom(i); | |
630 |
if (temp < bottom) |
|
619 | if (temp < bottom) | |
631 | bottom = temp; |
|
620 | bottom = temp; | |
632 |
|
|
621 | } | |
633 | } |
|
|||
634 | return bottom; |
|
622 | return bottom; | |
635 | } |
|
623 | } | |
636 |
|
624 | |||
@@ -674,10 +662,8 QList<LegendMarker*> QAbstractBarSeriesPrivate::createLegendMarker(QLegend* lege | |||||
674 |
|
662 | |||
675 | bool QAbstractBarSeriesPrivate::append(QBarSet *set) |
|
663 | bool QAbstractBarSeriesPrivate::append(QBarSet *set) | |
676 | { |
|
664 | { | |
677 |
if ((m_barSets.contains(set)) || (set == 0)) |
|
665 | if ((m_barSets.contains(set)) || (set == 0)) | |
678 | // Fail if set is already in list or set is null. |
|
666 | return false; // Fail if set is already in list or set is null. | |
679 | return false; |
|
|||
680 | } |
|
|||
681 |
|
667 | |||
682 | m_barSets.append(set); |
|
668 | m_barSets.append(set); | |
683 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout())); |
|
669 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout())); | |
@@ -690,10 +676,8 bool QAbstractBarSeriesPrivate::append(QBarSet *set) | |||||
690 |
|
676 | |||
691 | bool QAbstractBarSeriesPrivate::remove(QBarSet *set) |
|
677 | bool QAbstractBarSeriesPrivate::remove(QBarSet *set) | |
692 | { |
|
678 | { | |
693 |
if (!m_barSets.contains(set)) |
|
679 | if (!m_barSets.contains(set)) | |
694 | // Fail if set is not in list |
|
680 | return false; // Fail if set is not in list | |
695 | return false; |
|
|||
696 | } |
|
|||
697 |
|
681 | |||
698 | m_barSets.removeOne(set); |
|
682 | m_barSets.removeOne(set); | |
699 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout())); |
|
683 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout())); | |
@@ -707,14 +691,10 bool QAbstractBarSeriesPrivate::remove(QBarSet *set) | |||||
707 | bool QAbstractBarSeriesPrivate::append(QList<QBarSet* > sets) |
|
691 | bool QAbstractBarSeriesPrivate::append(QList<QBarSet* > sets) | |
708 | { |
|
692 | { | |
709 |
foreach (QBarSet* |
|
693 | foreach (QBarSet *set, sets) { | |
710 |
if ((set == 0) || (m_barSets.contains(set))) |
|
694 | if ((set == 0) || (m_barSets.contains(set))) | |
711 | // Fail if any of the sets is null or is already appended. |
|
695 | return false; // Fail if any of the sets is null or is already appended. | |
712 | return false; |
|
696 | if (sets.count(set) != 1) | |
713 | } |
|
697 | return false; // Also fail if same set is more than once in given list. | |
714 | if (sets.count(set) != 1) { |
|
|||
715 | // Also fail if same set is more than once in given list. |
|
|||
716 | return false; |
|
|||
717 | } |
|
|||
718 | } |
|
698 | } | |
719 |
|
699 | |||
720 |
foreach (QBarSet* |
|
700 | foreach (QBarSet *set, sets) { | |
@@ -730,18 +710,14 bool QAbstractBarSeriesPrivate::append(QList<QBarSet* > sets) | |||||
730 |
|
710 | |||
731 | bool QAbstractBarSeriesPrivate::remove(QList<QBarSet* > sets) |
|
711 | bool QAbstractBarSeriesPrivate::remove(QList<QBarSet* > sets) | |
732 | { |
|
712 | { | |
733 |
if (sets.count() == 0) |
|
713 | if (sets.count() == 0) | |
734 | return false; |
|
714 | return false; | |
735 | } |
|
715 | ||
736 |
foreach (QBarSet* |
|
716 | foreach (QBarSet *set, sets) { | |
737 |
if ((set == 0) || (!m_barSets.contains(set))) |
|
717 | if ((set == 0) || (!m_barSets.contains(set))) | |
738 | // Fail if any of the sets is null or is not in series |
|
718 | return false; // Fail if any of the sets is null or is not in series | |
739 | return false; |
|
719 | if (sets.count(set) != 1) | |
740 | } |
|
720 | return false; // Also fail if same set is more than once in given list. | |
741 | if (sets.count(set) != 1) { |
|
|||
742 | // Also fail if same set is more than once in given list. |
|
|||
743 | return false; |
|
|||
744 | } |
|
|||
745 | } |
|
721 | } | |
746 |
|
722 | |||
747 |
foreach (QBarSet* |
|
723 | foreach (QBarSet *set, sets) { | |
@@ -757,10 +733,8 bool QAbstractBarSeriesPrivate::remove(QList<QBarSet* > sets) | |||||
757 |
|
733 | |||
758 | bool QAbstractBarSeriesPrivate::insert(int index, QBarSet *set) |
|
734 | bool QAbstractBarSeriesPrivate::insert(int index, QBarSet *set) | |
759 | { |
|
735 | { | |
760 |
if ((m_barSets.contains(set)) || (set == 0)) |
|
736 | if ((m_barSets.contains(set)) || (set == 0)) | |
761 | // Fail if set is already in list or set is null. |
|
737 | return false; // Fail if set is already in list or set is null. | |
762 | return false; |
|
|||
763 | } |
|
|||
764 |
|
738 | |||
765 | m_barSets.insert(index, set); |
|
739 | m_barSets.insert(index, set); | |
766 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout())); |
|
740 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout())); | |
@@ -776,33 +750,22 void QAbstractBarSeriesPrivate::initializeAxis(QAbstractAxis* axis) | |||||
776 | Q_Q(QAbstractBarSeries); |
|
750 | Q_Q(QAbstractBarSeries); | |
777 |
|
751 | |||
778 | if(axis->type()==QAbstractAxis::AxisTypeBarCategory) { |
|
752 | if (axis->type() == QAbstractAxis::AxisTypeBarCategory) { | |
779 |
|
||||
780 | switch(q->type()) { |
|
753 | switch (q->type()) { | |
781 |
|
||||
782 |
|
|
754 | case QAbstractSeries::SeriesTypeHorizontalBar: | |
783 |
|
|
755 | case QAbstractSeries::SeriesTypeHorizontalPercentBar: | |
784 |
|
|
756 | case QAbstractSeries::SeriesTypeHorizontalStackedBar: | |
785 |
|
||||
786 |
|
|
757 | if (axis->orientation() == Qt::Vertical) | |
787 | { |
|
|||
788 |
|
|
758 | populateCategories(qobject_cast<QBarCategoryAxis*>(axis)); | |
789 | } |
|
|||
790 |
|
|
759 | break; | |
791 | } |
|
|||
792 |
|
|
760 | case QAbstractSeries::SeriesTypeBar: | |
793 |
|
|
761 | case QAbstractSeries::SeriesTypePercentBar: | |
794 |
|
|
762 | case QAbstractSeries::SeriesTypeStackedBar: | |
795 |
|
||||
796 |
|
|
763 | if (axis->orientation() == Qt::Horizontal) | |
797 | { |
|
|||
798 |
|
|
764 | populateCategories(qobject_cast<QBarCategoryAxis*>(axis)); | |
799 | } |
|
|||
800 |
|
|
765 | break; | |
801 | } |
|
|||
802 |
|
|
766 | default: | |
803 | qWarning()<<"Unexpected series type"; |
|
767 | qWarning() << "Unexpected series type"; | |
804 | break; |
|
768 | break; | |
805 |
|
||||
806 | } |
|
769 | } | |
807 | } |
|
770 | } | |
808 | } |
|
771 | } | |
@@ -812,31 +775,21 QAbstractAxis::AxisType QAbstractBarSeriesPrivate::defaultAxisType(Qt::Orientati | |||||
812 | Q_Q(const QAbstractBarSeries); |
|
775 | Q_Q(const QAbstractBarSeries); | |
813 |
|
776 | |||
814 | switch(q->type()) { |
|
777 | switch (q->type()) { | |
815 |
|
||||
816 |
|
|
778 | case QAbstractSeries::SeriesTypeHorizontalBar: | |
817 |
|
|
779 | case QAbstractSeries::SeriesTypeHorizontalPercentBar: | |
818 |
|
|
780 | case QAbstractSeries::SeriesTypeHorizontalStackedBar: | |
819 |
|
||||
820 |
|
|
781 | if (orientation == Qt::Vertical) | |
821 | { |
|
|||
822 |
|
|
782 | return QAbstractAxis::AxisTypeBarCategory; | |
823 | } |
|
|||
824 |
|
|
783 | break; | |
825 | } |
|
|||
826 |
|
|
784 | case QAbstractSeries::SeriesTypeBar: | |
827 |
|
|
785 | case QAbstractSeries::SeriesTypePercentBar: | |
828 |
|
|
786 | case QAbstractSeries::SeriesTypeStackedBar: | |
829 |
|
||||
830 |
|
|
787 | if (orientation == Qt::Horizontal) | |
831 | { |
|
|||
832 |
|
|
788 | return QAbstractAxis::AxisTypeBarCategory; | |
833 | } |
|
|||
834 |
|
|
789 | break; | |
835 | } |
|
|||
836 |
|
|
790 | default: | |
837 | qWarning()<<"Unexpected series type"; |
|
791 | qWarning() << "Unexpected series type"; | |
838 | break; |
|
792 | break; | |
839 |
|
||||
840 | } |
|
793 | } | |
841 | return QAbstractAxis::AxisTypeValue; |
|
794 | return QAbstractAxis::AxisTypeValue; | |
842 |
|
795 | |||
@@ -855,5 +808,4 void QAbstractBarSeriesPrivate::populateCategories(QBarCategoryAxis* axis) | |||||
855 | #include "moc_qabstractbarseries.cpp" |
|
808 | #include "moc_qabstractbarseries.cpp" | |
856 | #include "moc_qabstractbarseries_p.cpp" |
|
809 | #include "moc_qabstractbarseries_p.cpp" | |
857 |
|
810 | |||
858 |
|
||||
859 | QTCOMMERCIALCHART_END_NAMESPACE |
|
811 | QTCOMMERCIALCHART_END_NAMESPACE |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -45,9 +45,8 void QBarModelMapper::setModel(QAbstractItemModel *model) | |||||
45 | return; |
|
45 | return; | |
46 |
|
46 | |||
47 | Q_D(QBarModelMapper); |
|
47 | Q_D(QBarModelMapper); | |
48 |
if (d->m_model) |
|
48 | if (d->m_model) | |
49 | disconnect(d->m_model, 0, d, 0); |
|
49 | disconnect(d->m_model, 0, d, 0); | |
50 | } |
|
|||
51 |
|
50 | |||
52 | d->m_model = model; |
|
51 | d->m_model = model; | |
53 | d->initializeBarFromModel(); |
|
52 | d->initializeBarFromModel(); | |
@@ -70,9 +69,8 QAbstractBarSeries* QBarModelMapper::series() const | |||||
70 | void QBarModelMapper::setSeries(QAbstractBarSeries *series) |
|
69 | void QBarModelMapper::setSeries(QAbstractBarSeries *series) | |
71 | { |
|
70 | { | |
72 | Q_D(QBarModelMapper); |
|
71 | Q_D(QBarModelMapper); | |
73 |
if (d->m_series) |
|
72 | if (d->m_series) | |
74 | disconnect(d->m_series, 0, d, 0); |
|
73 | disconnect(d->m_series, 0, d, 0); | |
75 | } |
|
|||
76 |
|
74 | |||
77 | if (series == 0) |
|
75 | if (series == 0) | |
78 | return; |
|
76 | return; | |
@@ -402,9 +400,10 void QBarModelMapperPrivate::barSetsAdded(QList<QBarSet*> sets) | |||||
402 | return; |
|
400 | return; | |
403 |
|
401 | |||
404 | int maxCount = 0; |
|
402 | int maxCount = 0; | |
405 | for(int i = 0; i < sets.count(); i++) |
|
403 | for (int i = 0; i < sets.count(); i++) { | |
406 | if (sets.at(i)->count() > m_count) |
|
404 | if (sets.at(i)->count() > m_count) | |
407 | maxCount = sets.at(i)->count(); |
|
405 | maxCount = sets.at(i)->count(); | |
|
406 | } | |||
408 |
|
407 | |||
409 | if (m_count != -1 && m_count < maxCount) |
|
408 | if (m_count != -1 && m_count < maxCount) | |
410 | m_count = maxCount; |
|
409 | m_count = maxCount; |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -250,8 +250,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
250 | Constructs QBarSet with a label of \a label and with parent of \a parent |
|
250 | Constructs QBarSet with a label of \a label and with parent of \a parent | |
251 | */ |
|
251 | */ | |
252 | QBarSet::QBarSet(const QString label, QObject *parent) |
|
252 | QBarSet::QBarSet(const QString label, QObject *parent) | |
253 | : QObject(parent) |
|
253 | : QObject(parent), | |
254 |
|
|
254 | d_ptr(new QBarSetPrivate(label, this)) | |
255 | { |
|
255 | { | |
256 | } |
|
256 | } | |
257 |
|
257 | |||
@@ -331,9 +331,8 void QBarSet::insert(const int index, const qreal value) | |||||
331 | void QBarSet::remove(const int index, const int count) |
|
331 | void QBarSet::remove(const int index, const int count) | |
332 | { |
|
332 | { | |
333 | int removedCount = d_ptr->remove(index,count); |
|
333 | int removedCount = d_ptr->remove(index, count); | |
334 |
if (removedCount > 0) |
|
334 | if (removedCount > 0) | |
335 | emit valuesRemoved(index,removedCount); |
|
335 | emit valuesRemoved(index, removedCount); | |
336 | } |
|
|||
337 | return; |
|
336 | return; | |
338 | } |
|
337 | } | |
339 |
|
338 | |||
@@ -355,10 +354,8 void QBarSet::replace(const int index, const qreal value) | |||||
355 | */ |
|
354 | */ | |
356 | qreal QBarSet::at(const int index) const |
|
355 | qreal QBarSet::at(const int index) const | |
357 | { |
|
356 | { | |
358 |
if (index < 0 || index >= d_ptr->m_values.count()) |
|
357 | if (index < 0 || index >= d_ptr->m_values.count()) | |
359 | return 0; |
|
358 | return 0; | |
360 | } |
|
|||
361 |
|
||||
362 | return d_ptr->m_values.at(index).y(); |
|
359 | return d_ptr->m_values.at(index).y(); | |
363 | } |
|
360 | } | |
364 |
|
361 | |||
@@ -385,9 +382,8 int QBarSet::count() const | |||||
385 | qreal QBarSet::sum() const |
|
382 | qreal QBarSet::sum() const | |
386 | { |
|
383 | { | |
387 | qreal total(0); |
|
384 | qreal total(0); | |
388 |
for (int i=0; i < d_ptr->m_values.count(); i++) |
|
385 | for (int i = 0; i < d_ptr->m_values.count(); i++) | |
389 | total += d_ptr->m_values.at(i).y(); |
|
386 | total += d_ptr->m_values.at(i).y(); | |
390 | } |
|
|||
391 | return total; |
|
387 | return total; | |
392 | } |
|
388 | } | |
393 |
|
389 | |||
@@ -565,9 +561,8 void QBarSetPrivate::append(QPointF value) | |||||
565 |
|
561 | |||
566 | void QBarSetPrivate::append(QList<QPointF> values) |
|
562 | void QBarSetPrivate::append(QList<QPointF> values) | |
567 | { |
|
563 | { | |
568 |
for (int i=0; i<values.count(); i++) |
|
564 | for (int i = 0; i < values.count(); i++) | |
569 | m_values.append(values.at(i)); |
|
565 | m_values.append(values.at(i)); | |
570 | } |
|
|||
571 | emit restructuredBars(); |
|
566 | emit restructuredBars(); | |
572 | } |
|
567 | } | |
573 |
|
568 | |||
@@ -597,13 +592,10 int QBarSetPrivate::remove(const int index, const int count) | |||||
597 | { |
|
592 | { | |
598 | int removeCount = count; |
|
593 | int removeCount = count; | |
599 |
|
594 | |||
600 |
if ((index <0) || (m_values.count() == 0)) |
|
595 | if ((index < 0) || (m_values.count() == 0)) | |
601 | // Invalid index or not values in list, remove nothing. |
|
596 | return 0; // Invalid index or not values in list, remove nothing. | |
602 | return 0; |
|
597 | else if ((index + count) > m_values.count()) | |
603 | } else if ((index + count) > m_values.count()) { |
|
598 | removeCount = m_values.count() - index; // Trying to remove more items than list has. Limit amount to be removed. | |
604 | // Trying to remove more items than list has. Limit amount to be removed. |
|
|||
605 | removeCount = m_values.count() - index; |
|
|||
606 | } |
|
|||
607 |
|
599 | |||
608 | int c = 0; |
|
600 | int c = 0; | |
609 | while (c < removeCount) { |
|
601 | while (c < removeCount) { | |
@@ -628,19 +620,15 void QBarSetPrivate::replace(const int index, const QPointF value) | |||||
628 |
|
620 | |||
629 | qreal QBarSetPrivate::pos(const int index) |
|
621 | qreal QBarSetPrivate::pos(const int index) | |
630 | { |
|
622 | { | |
631 |
if (index < 0 || index >= m_values.count()) |
|
623 | if (index < 0 || index >= m_values.count()) | |
632 | return 0; |
|
624 | return 0; | |
633 | } |
|
|||
634 |
|
||||
635 | return m_values.at(index).x(); |
|
625 | return m_values.at(index).x(); | |
636 | } |
|
626 | } | |
637 |
|
627 | |||
638 | qreal QBarSetPrivate::value(const int index) |
|
628 | qreal QBarSetPrivate::value(const int index) | |
639 | { |
|
629 | { | |
640 |
if (index < 0 || index >= m_values.count()) |
|
630 | if (index < 0 || index >= m_values.count()) | |
641 | return 0; |
|
631 | return 0; | |
642 | } |
|
|||
643 |
|
||||
644 | return m_values.at(index).y(); |
|
632 | return m_values.at(index).y(); | |
645 | } |
|
633 | } | |
646 |
|
634 |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -66,22 +66,20 QVector<QRectF> BarChartItem::calculateLayout() | |||||
66 | layout.append(rect); |
|
66 | layout.append(rect); | |
67 | bar->setPen(barSet->m_pen); |
|
67 | bar->setPen(barSet->m_pen); | |
68 | bar->setBrush(barSet->m_brush); |
|
68 | bar->setBrush(barSet->m_brush); | |
69 |
if (qFuzzyIsNull(rectHeight)) |
|
69 | if (qFuzzyIsNull(rectHeight)) | |
70 | bar->setVisible(false); |
|
70 | bar->setVisible(false); | |
71 |
|
|
71 | else | |
72 | bar->setVisible(barsVisible); |
|
72 | bar->setVisible(barsVisible); | |
73 | } |
|
|||
74 |
|
73 | |||
75 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); |
|
74 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); | |
76 |
|
75 | |||
77 |
if (!qFuzzyIsNull(barSet->value(category))) |
|
76 | if (!qFuzzyIsNull(barSet->value(category))) | |
78 | label->setText(QString::number(barSet->value(category))); |
|
77 | label->setText(QString::number(barSet->value(category))); | |
79 |
|
|
78 | else | |
80 | label->setText(QString("")); |
|
79 | label->setText(QString("")); | |
81 | } |
|
|||
82 |
|
80 | |||
83 | label->setPos(xPos + (rect.width()/2 - label->boundingRect().width()/2) |
|
81 | label->setPos(xPos + (rect.width() / 2 - label->boundingRect().width() / 2), | |
84 |
|
|
82 | yPos - rectHeight / 2 - label->boundingRect().height() / 2); | |
85 | label->setFont(barSet->m_labelFont); |
|
83 | label->setFont(barSet->m_labelFont); | |
86 | label->setBrush(barSet->m_labelBrush); |
|
84 | label->setBrush(barSet->m_labelBrush); | |
87 |
|
85 |
@@ -79,10 +79,9 QAbstractSeries::SeriesType QBarSeries::type() const | |||||
79 | QBarSeries::~QBarSeries() |
|
79 | QBarSeries::~QBarSeries() | |
80 | { |
|
80 | { | |
81 | Q_D(QBarSeries); |
|
81 | Q_D(QBarSeries); | |
82 |
if(d->m_dataset) |
|
82 | if (d->m_dataset) | |
83 | d->m_dataset->removeSeries(this); |
|
83 | d->m_dataset->removeSeries(this); | |
84 | } |
|
84 | } | |
85 | } |
|
|||
86 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
85 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
87 |
|
86 | |||
88 | QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) : QAbstractBarSeriesPrivate(q) |
|
87 | QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) : QAbstractBarSeriesPrivate(q) | |
@@ -112,9 +111,8 ChartElement* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter) | |||||
112 | Q_Q(QBarSeries); |
|
111 | Q_Q(QBarSeries); | |
113 |
|
112 | |||
114 | BarChartItem* bar = new BarChartItem(q,presenter); |
|
113 | BarChartItem* bar = new BarChartItem(q, presenter); | |
115 |
if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
114 | if (presenter->animationOptions().testFlag(QChart::SeriesAnimations)) | |
116 | bar->setAnimation(new BarAnimation(bar)); |
|
115 | bar->setAnimation(new BarAnimation(bar)); | |
117 | } |
|
|||
118 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
116 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
119 | return bar; |
|
117 | return bar; | |
120 | } |
|
118 | } |
@@ -63,11 +63,10 QVector<QRectF> PercentBarChartItem::calculateLayout() | |||||
63 | Bar* bar = m_bars.at(itemIndex); |
|
63 | Bar* bar = m_bars.at(itemIndex); | |
64 | bar->setPen(barSet->m_pen); |
|
64 | bar->setPen(barSet->m_pen); | |
65 | bar->setBrush(barSet->m_brush); |
|
65 | bar->setBrush(barSet->m_brush); | |
66 |
if (qFuzzyIsNull(rectHeight)) |
|
66 | if (qFuzzyIsNull(rectHeight)) | |
67 | bar->setVisible(false); |
|
67 | bar->setVisible(false); | |
68 |
|
|
68 | else | |
69 | bar->setVisible(barsVisible); |
|
69 | bar->setVisible(barsVisible); | |
70 | } |
|
|||
71 |
|
70 | |||
72 | QRectF rect(xPos, yPos-rectHeight, rectWidth, rectHeight); |
|
71 | QRectF rect(xPos, yPos - rectHeight, rectWidth, rectHeight); | |
73 | layout.append(rect); |
|
72 | layout.append(rect); | |
@@ -84,8 +83,8 QVector<QRectF> PercentBarChartItem::calculateLayout() | |||||
84 | label->setText(QString("")); |
|
83 | label->setText(QString("")); | |
85 | } |
|
84 | } | |
86 |
|
85 | |||
87 | label->setPos(xPos + (rect.width()/2 - label->boundingRect().width()/2) |
|
86 | label->setPos(xPos + (rect.width() / 2 - label->boundingRect().width() / 2), | |
88 |
|
|
87 | yPos - rectHeight / 2 - label->boundingRect().height() / 2); | |
89 | label->setFont(barSet->m_labelFont); |
|
88 | label->setFont(barSet->m_labelFont); | |
90 | label->setBrush(barSet->m_labelBrush); |
|
89 | label->setBrush(barSet->m_labelBrush); | |
91 |
|
90 |
@@ -69,10 +69,9 QPercentBarSeries::QPercentBarSeries(QObject *parent) | |||||
69 | QPercentBarSeries::~QPercentBarSeries() |
|
69 | QPercentBarSeries::~QPercentBarSeries() | |
70 | { |
|
70 | { | |
71 | Q_D(QPercentBarSeries); |
|
71 | Q_D(QPercentBarSeries); | |
72 |
if(d->m_dataset) |
|
72 | if (d->m_dataset) | |
73 | d->m_dataset->removeSeries(this); |
|
73 | d->m_dataset->removeSeries(this); | |
74 | } |
|
74 | } | |
75 | } |
|
|||
76 |
|
75 | |||
77 | /*! |
|
76 | /*! | |
78 | Returns QChartSeries::SeriesTypePercentBar. |
|
77 | Returns QChartSeries::SeriesTypePercentBar. | |
@@ -111,9 +110,8 ChartElement* QPercentBarSeriesPrivate::createGraphics(ChartPresenter* presenter | |||||
111 | Q_Q(QPercentBarSeries); |
|
110 | Q_Q(QPercentBarSeries); | |
112 |
|
111 | |||
113 | PercentBarChartItem* bar = new PercentBarChartItem(q,presenter); |
|
112 | PercentBarChartItem* bar = new PercentBarChartItem(q, presenter); | |
114 |
if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
113 | if (presenter->animationOptions().testFlag(QChart::SeriesAnimations)) | |
115 | bar->setAnimation(new PercentBarAnimation(bar)); |
|
114 | bar->setAnimation(new PercentBarAnimation(bar)); | |
116 | } |
|
|||
117 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
115 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
118 | return bar; |
|
116 | return bar; | |
119 | } |
|
117 | } |
@@ -70,10 +70,9 QStackedBarSeries::QStackedBarSeries(QObject *parent) | |||||
70 | QStackedBarSeries::~QStackedBarSeries() |
|
70 | QStackedBarSeries::~QStackedBarSeries() | |
71 | { |
|
71 | { | |
72 | Q_D(QStackedBarSeries); |
|
72 | Q_D(QStackedBarSeries); | |
73 |
if(d->m_dataset) |
|
73 | if (d->m_dataset) | |
74 | d->m_dataset->removeSeries(this); |
|
74 | d->m_dataset->removeSeries(this); | |
75 | } |
|
75 | } | |
76 | } |
|
|||
77 | /*! |
|
76 | /*! | |
78 | Returns QChartSeries::SeriesTypeStackedBar. |
|
77 | Returns QChartSeries::SeriesTypeStackedBar. | |
79 | */ |
|
78 | */ | |
@@ -110,9 +109,8 ChartElement* QStackedBarSeriesPrivate::createGraphics(ChartPresenter* presenter | |||||
110 | Q_Q(QStackedBarSeries); |
|
109 | Q_Q(QStackedBarSeries); | |
111 |
|
110 | |||
112 | StackedBarChartItem* bar = new StackedBarChartItem(q,presenter); |
|
111 | StackedBarChartItem* bar = new StackedBarChartItem(q, presenter); | |
113 |
if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
112 | if (presenter->animationOptions().testFlag(QChart::SeriesAnimations)) | |
114 | bar->setAnimation(new StackedBarAnimation(bar)); |
|
113 | bar->setAnimation(new StackedBarAnimation(bar)); | |
115 | } |
|
|||
116 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
114 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
117 | return bar; |
|
115 | return bar; | |
118 | } |
|
116 | } |
@@ -61,33 +61,32 QVector<QRectF> StackedBarChartItem::calculateLayout() | |||||
61 | Bar* bar = m_bars.at(itemIndex); |
|
61 | Bar* bar = m_bars.at(itemIndex); | |
62 | bar->setPen(barSet->m_pen); |
|
62 | bar->setPen(barSet->m_pen); | |
63 | bar->setBrush(barSet->m_brush); |
|
63 | bar->setBrush(barSet->m_brush); | |
64 |
if (qFuzzyIsNull(rectHeight)) |
|
64 | if (qFuzzyIsNull(rectHeight)) | |
65 | bar->setVisible(false); |
|
65 | bar->setVisible(false); | |
66 |
|
|
66 | else | |
67 | bar->setVisible(barsVisible); |
|
67 | bar->setVisible(barsVisible); | |
68 | } |
|
|||
69 |
|
68 | |||
70 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); |
|
69 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); | |
71 |
|
70 | |||
72 |
if (!qFuzzyIsNull(barSet->value(category))) |
|
71 | if (!qFuzzyIsNull(barSet->value(category))) | |
73 | label->setText(QString::number(barSet->value(category))); |
|
72 | label->setText(QString::number(barSet->value(category))); | |
74 |
|
|
73 | else | |
75 | label->setText(QString("")); |
|
74 | label->setText(QString("")); | |
76 | } |
|
75 | ||
77 | label->setFont(barSet->m_labelFont); |
|
76 | label->setFont(barSet->m_labelFont); | |
78 | label->setBrush(barSet->m_labelBrush); |
|
77 | label->setBrush(barSet->m_labelBrush); | |
79 |
|
78 | |||
80 | if (rectHeight < 0) { |
|
79 | if (rectHeight < 0) { | |
81 | QRectF rect(xPos, yMax-rectHeight, rectWidth, rectHeight); |
|
80 | QRectF rect(xPos, yMax - rectHeight, rectWidth, rectHeight); | |
82 | layout.append(rect); |
|
81 | layout.append(rect); | |
83 | label->setPos(xPos + (rect.width()/2 - label->boundingRect().width()/2) |
|
82 | label->setPos(xPos + (rect.width() / 2 - label->boundingRect().width() / 2), | |
84 |
|
|
83 | yMax - rectHeight / 2 - label->boundingRect().height() / 2); | |
85 | yMax -= rectHeight; |
|
84 | yMax -= rectHeight; | |
86 | } else { |
|
85 | } else { | |
87 | QRectF rect(xPos, yMin-rectHeight, rectWidth, rectHeight); |
|
86 | QRectF rect(xPos, yMin - rectHeight, rectWidth, rectHeight); | |
88 | layout.append(rect); |
|
87 | layout.append(rect); | |
89 | label->setPos(xPos + (rect.width()/2 - label->boundingRect().width()/2) |
|
88 | label->setPos(xPos + (rect.width() / 2 - label->boundingRect().width() / 2), | |
90 |
|
|
89 | yMin - rectHeight / 2 - label->boundingRect().height() / 2); | |
91 | yMin -= rectHeight; |
|
90 | yMin -= rectHeight; | |
92 | } |
|
91 | } | |
93 |
|
92 |
@@ -83,7 +83,8 void ChartBackground::paint(QPainter *painter, const QStyleOptionGraphicsItem *o | |||||
83 |
|
83 | |||
84 | int ChartBackground::roundness(qreal size) const |
|
84 | int ChartBackground::roundness(qreal size) const | |
85 | { |
|
85 | { | |
86 |
if(qFuzzyIsNull(size)) |
|
86 | if (qFuzzyIsNull(size)) | |
|
87 | return 0; | |||
87 | return 100*m_diameter/int(size); |
|
88 | return 100 * m_diameter / int(size); | |
88 | } |
|
89 | } | |
89 |
|
90 | |||
@@ -92,9 +93,9 int ChartBackground::diameter() const | |||||
92 | return m_diameter; |
|
93 | return m_diameter; | |
93 | } |
|
94 | } | |
94 |
|
95 | |||
95 |
void ChartBackground::setDimeter(int di |
|
96 | void ChartBackground::setDiameter(int diameter) | |
96 | { |
|
97 | { | |
97 |
m_diameter=di |
|
98 | m_diameter = diameter; | |
98 | } |
|
99 | } | |
99 |
|
100 | |||
100 | QTCOMMERCIALCHART_END_NAMESPACE |
|
101 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -42,7 +42,7 public: | |||||
42 | ChartBackground(QGraphicsItem *parent =0); |
|
42 | ChartBackground(QGraphicsItem *parent = 0); | |
43 | ~ChartBackground(); |
|
43 | ~ChartBackground(); | |
44 |
|
44 | |||
45 |
void setDimeter(int di |
|
45 | void setDiameter(int diameter); | |
46 | int diameter() const; |
|
46 | int diameter() const; | |
47 | void setDropShadowEnabled(bool enabled); |
|
47 | void setDropShadowEnabled(bool enabled); | |
48 | bool isDropShadowEnabled() {return m_dropShadow != 0;} |
|
48 | bool isDropShadowEnabled() { return m_dropShadow != 0; } |
@@ -48,8 +48,8 const char *gitHead = "unknown"; | |||||
48 |
|
48 | |||
49 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
49 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
50 |
|
50 | |||
51 |
class ChartConfig |
|
51 | class ChartConfig | |
52 |
|
52 | { | ||
53 | private: |
|
53 | private: | |
54 | ChartConfig(){ |
|
54 | ChartConfig() { | |
55 |
|
|
55 | #if defined(DEVELOPMENT_BUILD) && !defined(QT_NO_DEBUG) |
@@ -101,9 +101,8 void ChartDataSet::createSeriesIndex(QAbstractSeries* series) | |||||
101 | int key=0; |
|
101 | int key = 0; | |
102 | while (i.hasNext()) { |
|
102 | while (i.hasNext()) { | |
103 | i.next(); |
|
103 | i.next(); | |
104 |
if(i.key()!=key) |
|
104 | if (i.key() != key) | |
105 | break; |
|
105 | break; | |
106 | } |
|
|||
107 | key++; |
|
106 | key++; | |
108 | } |
|
107 | } | |
109 |
|
108 | |||
@@ -137,13 +136,16 void ChartDataSet::createDefaultAxes() | |||||
137 | // Select the required axis x and axis y types based on the types of the current series |
|
136 | // Select the required axis x and axis y types based on the types of the current series | |
138 | while (i.hasNext()) { |
|
137 | while (i.hasNext()) { | |
139 | i.next(); |
|
138 | i.next(); | |
140 |
|
||||
141 | QAbstractAxis* axisX = m_seriesAxisXMap.value(i.key()); |
|
139 | QAbstractAxis* axisX = m_seriesAxisXMap.value(i.key()); | |
142 | QAbstractAxis* axisY = m_seriesAxisYMap.value(i.key()); |
|
140 | QAbstractAxis* axisY = m_seriesAxisYMap.value(i.key()); | |
143 | if(axisX) typeX&=axisX->type(); |
|
141 | if (axisX) | |
144 | else typeX|=i.key()->d_ptr->defaultAxisType(Qt::Horizontal); |
|
142 | typeX &= axisX->type(); | |
145 | if(axisY) typeY&=axisY->type(); |
|
143 | else | |
146 |
|
|
144 | typeX |= i.key()->d_ptr->defaultAxisType(Qt::Horizontal); | |
|
145 | if (axisY) | |||
|
146 | typeY &= axisY->type(); | |||
|
147 | else | |||
|
148 | typeY |= i.key()->d_ptr->defaultAxisType(Qt::Vertical); | |||
147 | } |
|
149 | } | |
148 |
|
150 | |||
149 | // Create the axes of the types selected |
|
151 | // Create the axes of the types selected | |
@@ -216,8 +218,7 void ChartDataSet::initializeAxis(QAbstractAxis* axis,QAbstractSeries* series) | |||||
216 | QObject::connect(axis->d_ptr.data(),SIGNAL(updated()),domain,SLOT(handleAxisUpdated())); |
|
218 | QObject::connect(axis->d_ptr.data(), SIGNAL(updated()), domain, SLOT(handleAxisUpdated())); | |
217 | QObject::connect(domain,SIGNAL(updated()),axis->d_ptr.data(),SLOT(handleDomainUpdated())); |
|
219 | QObject::connect(domain, SIGNAL(updated()), axis->d_ptr.data(), SLOT(handleDomainUpdated())); | |
218 | m_seriesAxisXMap.insert(series,axis); |
|
220 | m_seriesAxisXMap.insert(series, axis); | |
219 | } |
|
221 | } else { | |
220 | else { |
|
|||
221 | QObject::connect(axis->d_ptr.data(),SIGNAL(updated()),domain,SLOT(handleAxisUpdated())); |
|
222 | QObject::connect(axis->d_ptr.data(), SIGNAL(updated()), domain, SLOT(handleAxisUpdated())); | |
222 | QObject::connect(domain,SIGNAL(updated()),axis->d_ptr.data(),SLOT(handleDomainUpdated())); |
|
223 | QObject::connect(domain, SIGNAL(updated()), axis->d_ptr.data(), SLOT(handleDomainUpdated())); | |
223 | m_seriesAxisYMap.insert(series,axis); |
|
224 | m_seriesAxisYMap.insert(series, axis); | |
@@ -264,29 +265,25 void ChartDataSet::removeAxis(QAbstractAxis* axis) | |||||
264 |
|
265 | |||
265 | QMap<QAbstractSeries*, QAbstractAxis*> *seriesAxisMap; |
|
266 | QMap<QAbstractSeries*, QAbstractAxis*> *seriesAxisMap; | |
266 |
|
267 | |||
267 |
if(axis->orientation()==Qt::Vertical) |
|
268 | if (axis->orientation() == Qt::Vertical) | |
268 | seriesAxisMap= &m_seriesAxisYMap; |
|
269 | seriesAxisMap = &m_seriesAxisYMap; | |
269 |
|
|
270 | else | |
270 | else { |
|
|||
271 | seriesAxisMap= &m_seriesAxisXMap; |
|
271 | seriesAxisMap = &m_seriesAxisXMap; | |
272 | } |
|
|||
273 |
|
272 | |||
274 | QMapIterator<QAbstractSeries*, QAbstractAxis*> i(*seriesAxisMap); |
|
273 | QMapIterator<QAbstractSeries*, QAbstractAxis*> i(*seriesAxisMap); | |
275 |
|
274 | |||
276 | while (i.hasNext()) { |
|
275 | while (i.hasNext()) { | |
277 | i.next(); |
|
276 | i.next(); | |
278 |
if(i.value()==axis) |
|
277 | if (i.value() == axis) | |
279 | removeSeries(i.key()); |
|
278 | removeSeries(i.key()); | |
280 |
|
|
279 | } | |
281 | } |
|
280 | } | |
282 | } |
|
|||
283 |
|
281 | |||
284 | void ChartDataSet::removeAllSeries() |
|
282 | void ChartDataSet::removeAllSeries() | |
285 | { |
|
283 | { | |
286 | QList<QAbstractSeries*> series = m_seriesDomainMap.keys(); |
|
284 | QList<QAbstractSeries*> series = m_seriesDomainMap.keys(); | |
287 |
foreach(QAbstractSeries *s , series) |
|
285 | foreach (QAbstractSeries *s , series) | |
288 | removeSeries(s); |
|
286 | removeSeries(s); | |
289 | } |
|
|||
290 |
|
287 | |||
291 | Q_ASSERT(m_seriesAxisXMap.count()==0); |
|
288 | Q_ASSERT(m_seriesAxisXMap.count() == 0); | |
292 | Q_ASSERT(m_seriesAxisXMap.count()==0); |
|
289 | Q_ASSERT(m_seriesAxisXMap.count() == 0); | |
@@ -359,7 +356,8 int ChartDataSet::seriesCount(QAbstractSeries::SeriesType type) | |||||
359 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
356 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
360 | while (i.hasNext()) { |
|
357 | while (i.hasNext()) { | |
361 | i.next(); |
|
358 | i.next(); | |
362 |
if(i.key()->type()==type) |
|
359 | if (i.key()->type() == type) | |
|
360 | count++; | |||
363 | } |
|
361 | } | |
364 | return count; |
|
362 | return count; | |
365 | } |
|
363 | } | |
@@ -383,7 +381,8 QAbstractAxis* ChartDataSet::axisX(QAbstractSeries *series) const | |||||
383 |
|
381 | |||
384 | while (i.hasNext()) { |
|
382 | while (i.hasNext()) { | |
385 | i.next(); |
|
383 | i.next(); | |
386 |
if(i.value()->isVisible()) |
|
384 | if (i.value()->isVisible()) | |
|
385 | return i.value(); | |||
387 | } |
|
386 | } | |
388 | return 0; |
|
387 | return 0; | |
389 | } |
|
388 | } | |
@@ -434,11 +433,10 void ChartDataSet::setAxis(QAbstractSeries *series, QAbstractAxis *axis, Qt::Ori | |||||
434 |
|
433 | |||
435 | QMap<QAbstractSeries*, QAbstractAxis*> *seriesAxisMap; |
|
434 | QMap<QAbstractSeries*, QAbstractAxis*> *seriesAxisMap; | |
436 |
|
435 | |||
437 |
if(orientation==Qt::Vertical) |
|
436 | if (orientation == Qt::Vertical) | |
438 | seriesAxisMap= &m_seriesAxisYMap; |
|
437 | seriesAxisMap = &m_seriesAxisYMap; | |
439 |
|
|
438 | else | |
440 | seriesAxisMap= &m_seriesAxisXMap; |
|
439 | seriesAxisMap = &m_seriesAxisXMap; | |
441 | } |
|
|||
442 |
|
440 | |||
443 | if (seriesAxisMap->value(series) == axis) { |
|
441 | if (seriesAxisMap->value(series) == axis) { | |
444 | qWarning() << "The axis already set for the series"; |
|
442 | qWarning() << "The axis already set for the series"; |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -24,7 +24,8 | |||||
24 |
|
24 | |||
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
26 |
|
26 | |||
27 |
ChartElement::ChartElement(ChartPresenter *presenter) |
|
27 | ChartElement::ChartElement(ChartPresenter *presenter) | |
|
28 | : QObject(presenter), | |||
28 | m_presenter(presenter), |
|
29 | m_presenter(presenter), | |
29 | m_domain(0) |
|
30 | m_domain(0) | |
30 | { |
|
31 | { |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -30,8 +30,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
30 |
|
30 | |||
31 | static const qreal golden_ratio = 0.25; |
|
31 | static const qreal golden_ratio = 0.25; | |
32 |
|
32 | |||
33 |
ChartLayout::ChartLayout(ChartPresenter* presenter) |
|
33 | ChartLayout::ChartLayout(ChartPresenter* presenter) | |
34 | m_presenter(presenter), |
|
34 | : m_presenter(presenter), | |
35 | m_margins(20,20,20,20), |
|
35 | m_margins(20, 20, 20, 20), | |
36 | m_minChartRect(0,0,200,200) |
|
36 | m_minChartRect(0, 0, 200, 200) | |
37 | { |
|
37 | { | |
@@ -57,13 +57,11 void ChartLayout::setGeometry(const QRectF& rect) | |||||
57 |
|
57 | |||
58 | contentGeometry = calculateContentGeometry(contentGeometry); |
|
58 | contentGeometry = calculateContentGeometry(contentGeometry); | |
59 |
|
59 | |||
60 |
if (title && title->isVisible()) |
|
60 | if (title && title->isVisible()) | |
61 | contentGeometry = calculateTitleGeometry(contentGeometry,title); |
|
61 | contentGeometry = calculateTitleGeometry(contentGeometry, title); | |
62 | } |
|
|||
63 |
|
62 | |||
64 |
if (legend->isAttachedToChart() && legend->isVisible()) |
|
63 | if (legend->isAttachedToChart() && legend->isVisible()) | |
65 | contentGeometry = calculateLegendGeometry(contentGeometry,legend); |
|
64 | contentGeometry = calculateLegendGeometry(contentGeometry, legend); | |
66 | } |
|
|||
67 |
|
65 | |||
68 | calculateChartGeometry(contentGeometry,axes); |
|
66 | calculateChartGeometry(contentGeometry, axes); | |
69 |
|
67 | |||
@@ -77,9 +75,8 void ChartLayout::setGeometry(const QRectF& rect) | |||||
77 | debuger->add(legendGeometry ,m_presenter->rootItem()); |
|
75 | debuger->add(legendGeometry , m_presenter->rootItem()); | |
78 | debuger->add(axisGeometry ,m_presenter->rootItem()); |
|
76 | debuger->add(axisGeometry , m_presenter->rootItem()); | |
79 | debuger->add(geometry,m_presenter->rootItem()); |
|
77 | debuger->add(geometry, m_presenter->rootItem()); | |
80 |
foreach(LegendMarker* |
|
78 | foreach (LegendMarker *marker, legend->d_ptr->markers()) | |
81 | debuger->add(marker->mapRectToScene(marker->boundingRect()),m_presenter->rootItem()); |
|
79 | debuger->add(marker->mapRectToScene(marker->boundingRect()), m_presenter->rootItem()); | |
82 | } |
|
|||
83 | #endif |
|
80 | #endif | |
84 |
|
81 | |||
85 | QGraphicsLayout::setGeometry(rect); |
|
82 | QGraphicsLayout::setGeometry(rect); | |
@@ -101,7 +98,8 QRectF ChartLayout::calculateBackgroundGeometry(const QRectF& geometry,ChartBack | |||||
101 | qreal left, top, right, bottom; |
|
98 | qreal left, top, right, bottom; | |
102 | getContentsMargins(&left, &top, &right, &bottom); |
|
99 | getContentsMargins(&left, &top, &right, &bottom); | |
103 | QRectF backgroundGeometry = geometry.adjusted(left,top,-right,-bottom); |
|
100 | QRectF backgroundGeometry = geometry.adjusted(left, top, -right, -bottom); | |
104 | if(background) background->setRect(backgroundGeometry); |
|
101 | if (background) | |
|
102 | background->setRect(backgroundGeometry); | |||
105 | return backgroundGeometry; |
|
103 | return backgroundGeometry; | |
106 | } |
|
104 | } | |
107 |
|
105 | |||
@@ -131,15 +129,13 QRectF ChartLayout::calculateChartGeometry(const QRectF& geometry, const QList<C | |||||
131 | rightAxisCount++; |
|
129 | rightAxisCount++; | |
132 | else |
|
130 | else | |
133 | leftAxisCount++; |
|
131 | leftAxisCount++; | |
134 | } |
|
132 | } else if (axis->orientation() == Qt::Horizontal && axis->isVisible()) { | |
135 | else if(axis->orientation()==Qt::Horizontal && axis->isVisible()) { |
|
|||
136 | // horizontal = horizontal.expandedTo(axis->effectiveSizeHint(Qt::MinimumSize)); |
|
133 | // horizontal = horizontal.expandedTo(axis->effectiveSizeHint(Qt::MinimumSize)); | |
137 | if (axis->alternativePlacement()) |
|
134 | if (axis->alternativePlacement()) | |
138 | topAxisCount++; |
|
135 | topAxisCount++; | |
139 | else |
|
136 | else | |
140 | bottomAxisCount++; |
|
137 | bottomAxisCount++; | |
141 | } |
|
138 | } | |
142 |
|
||||
143 | } |
|
139 | } | |
144 |
|
140 | |||
145 | qreal width = qMin(vertical.width(),geometry.width() * golden_ratio); |
|
141 | qreal width = qMin(vertical.width(), geometry.width() * golden_ratio); | |
@@ -168,8 +164,7 QRectF ChartLayout::calculateChartGeometry(const QRectF& geometry, const QList<C | |||||
168 | rightAxisCount++; |
|
164 | rightAxisCount++; | |
169 | else |
|
165 | else | |
170 | leftAxisCount++; |
|
166 | leftAxisCount++; | |
171 | } |
|
167 | } else if (axis->orientation() == Qt::Horizontal) { | |
172 | else if(axis->orientation()==Qt::Horizontal) { |
|
|||
173 | axis->setInternalRect(rect.adjusted(0, -topAxisCount * axisWidth, 0, bottomAxisCount * axisWidth)); |
|
168 | axis->setInternalRect(rect.adjusted(0, -topAxisCount * axisWidth, 0, bottomAxisCount * axisWidth)); | |
174 | axis->setGeometry(rect.adjusted(0, -(topAxisCount + 1) * axisWidth, 0, (bottomAxisCount + 1) * axisWidth)); |
|
169 | axis->setGeometry(rect.adjusted(0, -(topAxisCount + 1) * axisWidth, 0, (bottomAxisCount + 1) * axisWidth)); | |
175 | if (axis->alternativePlacement()) |
|
170 | if (axis->alternativePlacement()) | |
@@ -189,12 +184,11 QRectF ChartLayout::calculateAxisMinimum(const QRectF& minimum, const QList<Char | |||||
189 |
|
184 | |||
190 | // check axis size |
|
185 | // check axis size | |
191 |
foreach(ChartAxis* |
|
186 | foreach (ChartAxis *axis , axes) { | |
192 |
if(axis->orientation()==Qt::Vertical && axis->isVisible()) |
|
187 | if (axis->orientation() == Qt::Vertical && axis->isVisible()) | |
193 | vertical = vertical.expandedTo(axis->effectiveSizeHint(Qt::MinimumSize)); |
|
188 | vertical = vertical.expandedTo(axis->effectiveSizeHint(Qt::MinimumSize)); | |
194 |
|
|
189 | else if (axis->orientation() == Qt::Horizontal && axis->isVisible()) | |
195 | horizontal = horizontal.expandedTo(axis->effectiveSizeHint(Qt::MinimumSize)); |
|
190 | horizontal = horizontal.expandedTo(axis->effectiveSizeHint(Qt::MinimumSize)); | |
196 |
|
|
191 | } | |
197 | } |
|
|||
198 |
return |
|
192 | return minimum.adjusted(0, 0, horizontal.width() + vertical.width(), horizontal.height() + vertical.height()); | |
199 | } |
|
193 | } | |
200 |
|
194 | |||
@@ -205,16 +199,14 QRectF ChartLayout::calculateLegendGeometry(const QRectF& geometry,QLegend* lege | |||||
205 | QRectF result; |
|
199 | QRectF result; | |
206 |
|
200 | |||
207 | switch (legend->alignment()) { |
|
201 | switch (legend->alignment()) { | |
208 |
case Qt::AlignTop: |
|
202 | case Qt::AlignTop: | |
209 | legendRect = QRectF(geometry.topLeft(),QSizeF(geometry.width(),size.height())); |
|
203 | legendRect = QRectF(geometry.topLeft(), QSizeF(geometry.width(), size.height())); | |
210 | result = geometry.adjusted(0,legendRect.height(),0,0); |
|
204 | result = geometry.adjusted(0, legendRect.height(), 0, 0); | |
211 | break; |
|
205 | break; | |
212 | } |
|
206 | case Qt::AlignBottom: | |
213 | case Qt::AlignBottom: { |
|
|||
214 | legendRect = QRectF(QPointF(geometry.left(),geometry.bottom()-size.height()),QSizeF(geometry.width(),size.height())); |
|
207 | legendRect = QRectF(QPointF(geometry.left(), geometry.bottom() - size.height()), QSizeF(geometry.width(), size.height())); | |
215 | result = geometry.adjusted(0,0,0,-legendRect.height()); |
|
208 | result = geometry.adjusted(0, 0, 0, -legendRect.height()); | |
216 | break; |
|
209 | break; | |
217 | } |
|
|||
218 | case Qt::AlignLeft: { |
|
210 | case Qt::AlignLeft: { | |
219 | qreal width = qMin(size.width(),geometry.width()*golden_ratio); |
|
211 | qreal width = qMin(size.width(), geometry.width() * golden_ratio); | |
220 | legendRect = QRectF(geometry.topLeft(),QSizeF(width,geometry.height())); |
|
212 | legendRect = QRectF(geometry.topLeft(), QSizeF(width, geometry.height())); | |
@@ -227,12 +219,11 QRectF ChartLayout::calculateLegendGeometry(const QRectF& geometry,QLegend* lege | |||||
227 | result = geometry.adjusted(0,0,-width,0); |
|
219 | result = geometry.adjusted(0, 0, -width, 0); | |
228 | break; |
|
220 | break; | |
229 | } |
|
221 | } | |
230 |
default: |
|
222 | default: | |
231 | legendRect = QRectF(0,0,0,0); |
|
223 | legendRect = QRectF(0, 0, 0, 0); | |
232 | result = geometry; |
|
224 | result = geometry; | |
233 | break; |
|
225 | break; | |
234 | } |
|
226 | } | |
235 | } |
|
|||
236 |
|
227 | |||
237 | legend->setGeometry(legendRect); |
|
228 | legend->setGeometry(legendRect); | |
238 |
|
229 | |||
@@ -273,13 +264,12 QSizeF ChartLayout::sizeHint ( Qt::SizeHint which, const QSizeF & constraint) co | |||||
273 | minimumRect = calculateLegendMinimum(minimumRect,legend); |
|
264 | minimumRect = calculateLegendMinimum(minimumRect, legend); | |
274 | minimumRect = calculateAxisMinimum(minimumRect,axes); |
|
265 | minimumRect = calculateAxisMinimum(minimumRect, axes); | |
275 |
return |
|
266 | return minimumRect.united(m_minChartRect).size().toSize(); | |
276 |
} |
|
267 | } | |
277 |
|
|
268 | return QSize(-1, -1); | |
278 | } |
|
269 | } | |
279 |
|
270 | |||
280 | void ChartLayout::setMargins(const QMargins& margins) |
|
271 | void ChartLayout::setMargins(const QMargins& margins) | |
281 | { |
|
272 | { | |
282 |
|
||||
283 | if(m_margins != margins){ |
|
273 | if (m_margins != margins) { | |
284 | m_margins = margins; |
|
274 | m_margins = margins; | |
285 | updateGeometry(); |
|
275 | updateGeometry(); |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -35,7 +35,8 | |||||
35 |
|
35 | |||
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
37 |
|
37 | |||
38 |
ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset) |
|
38 | ChartPresenter::ChartPresenter(QChart* chart, ChartDataSet* dataset) | |
|
39 | : QObject(chart), | |||
39 | m_chart(chart), |
|
40 | m_chart(chart), | |
40 | m_dataset(dataset), |
|
41 | m_dataset(dataset), | |
41 | m_chartTheme(0), |
|
42 | m_chartTheme(0), | |
@@ -60,11 +61,9 void ChartPresenter::setChartsGeometry(const QRectF& rect) | |||||
60 | if(m_chartsRect!=rect) { |
|
61 | if (m_chartsRect != rect) { | |
61 | m_chartsRect=rect; |
|
62 | m_chartsRect = rect; | |
62 |
foreach(ChartElement* |
|
63 | foreach (ChartElement *chart, m_chartItems) | |
63 | { |
|
|||
64 | chart->handleGeometryChanged(rect); |
|
64 | chart->handleGeometryChanged(rect); | |
65 |
|
|
65 | } | |
66 | } |
|
66 | } | |
67 | } |
|
|||
68 |
|
67 | |||
69 | QRectF ChartPresenter::chartsGeometry() const |
|
68 | QRectF ChartPresenter::chartsGeometry() const | |
70 | { |
|
69 | { | |
@@ -76,9 +75,8 void ChartPresenter::handleAxisAdded(QAbstractAxis* axis,Domain* domain) | |||||
76 | ChartAxis* item = axis->d_ptr->createGraphics(this); |
|
75 | ChartAxis* item = axis->d_ptr->createGraphics(this); | |
77 | item->setDomain(domain); |
|
76 | item->setDomain(domain); | |
78 |
|
77 | |||
79 |
if(m_options.testFlag(QChart::GridAxisAnimations)) |
|
78 | if (m_options.testFlag(QChart::GridAxisAnimations)) | |
80 | item->setAnimation(new AxisAnimation(item)); |
|
79 | item->setAnimation(new AxisAnimation(item)); | |
81 | } |
|
|||
82 |
|
80 | |||
83 | QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF))); |
|
81 | QObject::connect(this, SIGNAL(geometryChanged(QRectF)), item, SLOT(handleGeometryChanged(QRectF))); | |
84 | QObject::connect(domain,SIGNAL(updated()),item,SLOT(handleDomainUpdated())); |
|
82 | QObject::connect(domain, SIGNAL(updated()), item, SLOT(handleDomainUpdated())); | |
@@ -89,7 +87,8 void ChartPresenter::handleAxisAdded(QAbstractAxis* axis,Domain* domain) | |||||
89 | m_chartTheme->decorate(axis); |
|
87 | m_chartTheme->decorate(axis); | |
90 | axis->d_ptr->setDirty(false); |
|
88 | axis->d_ptr->setDirty(false); | |
91 | axis->d_ptr->emitUpdated(); |
|
89 | axis->d_ptr->emitUpdated(); | |
92 | if(m_chartsRect.isValid()) item->handleGeometryChanged(m_chartsRect); |
|
90 | if (m_chartsRect.isValid()) | |
|
91 | item->handleGeometryChanged(m_chartsRect); | |||
93 |
|
92 | |||
94 | m_axisItems.insert(axis, item); |
|
93 | m_axisItems.insert(axis, item); | |
95 | selectVisibleAxis(); |
|
94 | selectVisibleAxis(); | |
@@ -118,7 +117,8 void ChartPresenter::handleSeriesAdded(QAbstractSeries* series,Domain* domain) | |||||
118 | //initialize |
|
117 | //initialize | |
119 | item->handleDomainUpdated(); |
|
118 | item->handleDomainUpdated(); | |
120 |
|
119 | |||
121 | if(m_chartsRect.isValid()) item->handleGeometryChanged(m_chartsRect); |
|
120 | if (m_chartsRect.isValid()) | |
|
121 | item->handleGeometryChanged(m_chartsRect); | |||
122 | m_chartItems.insert(series,item); |
|
122 | m_chartItems.insert(series, item); | |
123 | } |
|
123 | } | |
124 |
|
124 | |||
@@ -169,19 +169,18 void ChartPresenter::handleAxisVisibleChanged(bool visible) | |||||
169 |
|
169 | |||
170 | while (i.hasNext()) { |
|
170 | while (i.hasNext()) { | |
171 | i.next(); |
|
171 | i.next(); | |
172 |
if(i.key()==axis) |
|
172 | if (i.key() == axis) | |
173 | continue; |
|
173 | continue; | |
174 | } |
|
174 | if (i.key()->orientation() == axis->orientation()) | |
175 | if(i.key()->orientation()==axis->orientation()) { |
|
|||
176 | i.key()->setVisible(false); |
|
175 | i.key()->setVisible(false); | |
177 | } |
|
176 | } | |
178 |
|
|
177 | } | |
179 | } |
|
178 | } | |
180 | } |
|
|||
181 |
|
179 | |||
182 | void ChartPresenter::setTheme(QChart::ChartTheme theme,bool force) |
|
180 | void ChartPresenter::setTheme(QChart::ChartTheme theme, bool force) | |
183 | { |
|
181 | { | |
184 |
if(m_chartTheme && m_chartTheme->id() == theme) |
|
182 | if (m_chartTheme && m_chartTheme->id() == theme) | |
|
183 | return; | |||
185 | delete m_chartTheme; |
|
184 | delete m_chartTheme; | |
186 | m_chartTheme = ChartTheme::createTheme(theme); |
|
185 | m_chartTheme = ChartTheme::createTheme(theme); | |
187 | m_chartTheme->setForced(force); |
|
186 | m_chartTheme->setForced(force); | |
@@ -308,16 +307,17 void ChartPresenter::createTitleItem() | |||||
308 | void ChartPresenter::handleAnimationFinished() |
|
307 | void ChartPresenter::handleAnimationFinished() | |
309 | { |
|
308 | { | |
310 | m_animations.removeAll(qobject_cast<ChartAnimation*>(sender())); |
|
309 | m_animations.removeAll(qobject_cast<ChartAnimation*>(sender())); | |
311 |
if(m_animations.empty()) |
|
310 | if (m_animations.empty()) | |
|
311 | emit animationsFinished(); | |||
312 | } |
|
312 | } | |
313 |
|
313 | |||
314 | void ChartPresenter::startAnimation(ChartAnimation* animation) |
|
314 | void ChartPresenter::startAnimation(ChartAnimation* animation) | |
315 | { |
|
315 | { | |
316 |
if (animation->state() != QAbstractAnimation::Stopped) |
|
316 | if (animation->state() != QAbstractAnimation::Stopped) | |
|
317 | animation->stop(); | |||
317 | QObject::connect(animation, SIGNAL(finished()),this,SLOT(handleAnimationFinished()),Qt::UniqueConnection); |
|
318 | QObject::connect(animation, SIGNAL(finished()), this, SLOT(handleAnimationFinished()), Qt::UniqueConnection); | |
318 |
if(!m_animations.isEmpty()) |
|
319 | if (!m_animations.isEmpty()) | |
319 | m_animations.append(animation); |
|
320 | m_animations.append(animation); | |
320 | } |
|
|||
321 | QTimer::singleShot(0, animation, SLOT(start())); |
|
321 | QTimer::singleShot(0, animation, SLOT(start())); | |
322 | } |
|
322 | } | |
323 |
|
323 | |||
@@ -330,7 +330,8 void ChartPresenter::setBackgroundBrush(const QBrush& brush) | |||||
330 |
|
330 | |||
331 | QBrush ChartPresenter::backgroundBrush() const |
|
331 | QBrush ChartPresenter::backgroundBrush() const | |
332 | { |
|
332 | { | |
333 |
if (!m_background) |
|
333 | if (!m_background) | |
|
334 | return QBrush(); | |||
334 | return m_background->brush(); |
|
335 | return m_background->brush(); | |
335 | } |
|
336 | } | |
336 |
|
337 | |||
@@ -343,7 +344,8 void ChartPresenter::setBackgroundPen(const QPen& pen) | |||||
343 |
|
344 | |||
344 | QPen ChartPresenter::backgroundPen() const |
|
345 | QPen ChartPresenter::backgroundPen() const | |
345 | { |
|
346 | { | |
346 |
if (!m_background) |
|
347 | if (!m_background) | |
|
348 | return QPen(); | |||
347 | return m_background->pen(); |
|
349 | return m_background->pen(); | |
348 | } |
|
350 | } | |
349 |
|
351 | |||
@@ -356,7 +358,8 void ChartPresenter::setTitle(const QString& title) | |||||
356 |
|
358 | |||
357 | QString ChartPresenter::title() const |
|
359 | QString ChartPresenter::title() const | |
358 | { |
|
360 | { | |
359 |
if (!m_title) |
|
361 | if (!m_title) | |
|
362 | return QString(); | |||
360 | return m_title->text(); |
|
363 | return m_title->text(); | |
361 | } |
|
364 | } | |
362 |
|
365 | |||
@@ -369,7 +372,8 void ChartPresenter::setTitleFont(const QFont& font) | |||||
369 |
|
372 | |||
370 | QFont ChartPresenter::titleFont() const |
|
373 | QFont ChartPresenter::titleFont() const | |
371 | { |
|
374 | { | |
372 |
if (!m_title) |
|
375 | if (!m_title) | |
|
376 | return QFont(); | |||
373 | return m_title->font(); |
|
377 | return m_title->font(); | |
374 | } |
|
378 | } | |
375 |
|
379 | |||
@@ -382,7 +386,8 void ChartPresenter::setTitleBrush(const QBrush &brush) | |||||
382 |
|
386 | |||
383 | QBrush ChartPresenter::titleBrush() const |
|
387 | QBrush ChartPresenter::titleBrush() const | |
384 | { |
|
388 | { | |
385 |
if (!m_title) |
|
389 | if (!m_title) | |
|
390 | return QBrush(); | |||
386 | return m_title->brush(); |
|
391 | return m_title->brush(); | |
387 | } |
|
392 | } | |
388 |
|
393 | |||
@@ -395,7 +400,8 void ChartPresenter::setBackgroundVisible(bool visible) | |||||
395 |
|
400 | |||
396 | bool ChartPresenter::isBackgroundVisible() const |
|
401 | bool ChartPresenter::isBackgroundVisible() const | |
397 | { |
|
402 | { | |
398 |
if (!m_background) |
|
403 | if (!m_background) | |
|
404 | return false; | |||
399 | return m_background->isVisible(); |
|
405 | return m_background->isVisible(); | |
400 | } |
|
406 | } | |
401 |
|
407 | |||
@@ -407,7 +413,8 void ChartPresenter::setBackgroundDropShadowEnabled(bool enabled) | |||||
407 |
|
413 | |||
408 | bool ChartPresenter::isBackgroundDropShadowEnabled() const |
|
414 | bool ChartPresenter::isBackgroundDropShadowEnabled() const | |
409 | { |
|
415 | { | |
410 |
if (!m_background) |
|
416 | if (!m_background) | |
|
417 | return false; | |||
411 | return m_background->isDropShadowEnabled(); |
|
418 | return m_background->isDropShadowEnabled(); | |
412 | } |
|
419 | } | |
413 |
|
420 |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -268,45 +268,37 void ChartTheme::decorate(QAbstractAxis *axis) | |||||
268 |
|
268 | |||
269 | if (axis->isLineVisible()) { |
|
269 | if (axis->isLineVisible()) { | |
270 |
|
270 | |||
271 |
if(m_force || brush == axis->labelsBrush()) |
|
271 | if (m_force || brush == axis->labelsBrush()) | |
272 | axis->setLabelsBrush(m_labelBrush); |
|
272 | axis->setLabelsBrush(m_labelBrush); | |
273 | } |
|
|||
274 | if(m_force || pen == axis->labelsPen()){ |
|
|||
275 | axis->setLabelsPen(Qt::NoPen); // NoPen for performance reasons |
|
|||
276 | } |
|
|||
277 |
|
273 | |||
|
274 | if (m_force || pen == axis->labelsPen()) | |||
|
275 | axis->setLabelsPen(Qt::NoPen); // NoPen for performance reasons | |||
278 |
|
276 | |||
279 | if (m_force || axis->shadesVisible()) { |
|
277 | if (m_force || axis->shadesVisible()) { | |
280 |
|
278 | |||
281 |
if(m_force || brush == axis->shadesBrush()) |
|
279 | if (m_force || brush == axis->shadesBrush()) | |
282 | axis->setShadesBrush(m_backgroundShadesBrush); |
|
280 | axis->setShadesBrush(m_backgroundShadesBrush); | |
283 | } |
|
|||
284 |
|
281 | |||
285 |
if(m_force || pen == axis->shadesPen()) |
|
282 | if (m_force || pen == axis->shadesPen()) | |
286 | axis->setShadesPen(m_backgroundShadesPen); |
|
283 | axis->setShadesPen(m_backgroundShadesPen); | |
287 | } |
|
|||
288 |
|
284 | |||
289 |
if( |
|
285 | if (m_force && (m_backgroundShades == BackgroundShadesBoth | |
290 | || (m_backgroundShades == BackgroundShadesVertical && axisX) |
|
286 | || (m_backgroundShades == BackgroundShadesVertical && axisX) | |
291 | || (m_backgroundShades == BackgroundShadesHorizontal && !axisX))){ |
|
287 | || (m_backgroundShades == BackgroundShadesHorizontal && !axisX))) { | |
292 | axis->setShadesVisible(true); |
|
288 | axis->setShadesVisible(true); | |
293 |
|
||||
294 | } |
|
289 | } | |
295 | } |
|
290 | } | |
296 |
|
291 | |||
297 |
if(m_force || pen == axis->linePen()) |
|
292 | if (m_force || pen == axis->linePen()) | |
298 | axis->setLinePen(m_axisLinePen); |
|
293 | axis->setLinePen(m_axisLinePen); | |
299 | } |
|
|||
300 |
|
294 | |||
301 |
if(m_force || pen == axis->gridLinePen()) |
|
295 | if (m_force || pen == axis->gridLinePen()) | |
302 | axis->setGridLinePen(m_gridLinePen); |
|
296 | axis->setGridLinePen(m_gridLinePen); | |
303 | } |
|
|||
304 |
|
297 | |||
305 |
if(m_force || font == axis->labelsFont()) |
|
298 | if (m_force || font == axis->labelsFont()) | |
306 | axis->setLabelsFont(m_labelFont); |
|
299 | axis->setLabelsFont(m_labelFont); | |
307 |
|
|
300 | } | |
308 | } |
|
301 | } | |
309 | } |
|
|||
310 |
|
302 | |||
311 | void ChartTheme::generateSeriesGradients() |
|
303 | void ChartTheme::generateSeriesGradients() | |
312 | { |
|
304 | { |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -25,7 +25,8 | |||||
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 |
ChartTitle::ChartTitle(QGraphicsItem* parent) |
|
28 | ChartTitle::ChartTitle(QGraphicsItem* parent) | |
|
29 | : QGraphicsSimpleTextItem(parent) | |||
29 | { |
|
30 | { | |
30 |
|
31 | |||
31 | } |
|
32 | } | |
@@ -51,15 +52,14 void ChartTitle::setGeometry(const QRectF &rect) | |||||
51 |
|
52 | |||
52 | int width = rect.width(); |
|
53 | int width = rect.width(); | |
53 |
|
54 | |||
54 | if (fn.boundingRect(m_text).width() > width) |
|
55 | if (fn.boundingRect(m_text).width() > width) { | |
55 | { |
|
|||
56 | QString string = m_text + "..."; |
|
56 | QString string = m_text + "..."; | |
57 | while (fn.boundingRect(string).width() > width && string.length() > 3) |
|
57 | while (fn.boundingRect(string).width() > width && string.length() > 3) | |
58 | string.remove(string.length() - 4, 1); |
|
58 | string.remove(string.length() - 4, 1); | |
59 | QGraphicsSimpleTextItem::setText(string); |
|
59 | QGraphicsSimpleTextItem::setText(string); | |
60 | } |
|
60 | } else { | |
61 | else |
|
|||
62 | QGraphicsSimpleTextItem::setText(m_text); |
|
61 | QGraphicsSimpleTextItem::setText(m_text); | |
|
62 | } | |||
63 |
|
63 | |||
64 | setPos(rect.topLeft()); |
|
64 | setPos(rect.topLeft()); | |
65 | } |
|
65 | } |
@@ -23,7 +23,8 | |||||
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 |
Domain::Domain(QObject* parent) |
|
26 | Domain::Domain(QObject* parent) | |
|
27 | : QObject(parent), | |||
27 | m_minX(0), |
|
28 | m_minX(0), | |
28 | m_maxX(0), |
|
29 | m_maxX(0), | |
29 | m_minY(0), |
|
30 | m_minY(0), | |
@@ -54,10 +55,9 void Domain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) | |||||
54 | emit rangeYChanged(m_minY,m_maxY); |
|
55 | emit rangeYChanged(m_minY, m_maxY); | |
55 | } |
|
56 | } | |
56 |
|
57 | |||
57 |
if(axisXChanged || axisYChanged) |
|
58 | if (axisXChanged || axisYChanged) | |
58 | emit updated(); |
|
59 | emit updated(); | |
59 | } |
|
60 | } | |
60 | } |
|
|||
61 |
|
61 | |||
62 | void Domain::setRangeX(qreal min, qreal max) |
|
62 | void Domain::setRangeX(qreal min, qreal max) | |
63 | { |
|
63 | { | |
@@ -173,12 +173,11 void Domain::handleAxisUpdated() | |||||
173 | QAbstractAxisPrivate* axis = qobject_cast<QAbstractAxisPrivate*>(sender()); |
|
173 | QAbstractAxisPrivate* axis = qobject_cast<QAbstractAxisPrivate*>(sender()); | |
174 | Q_ASSERT(axis); |
|
174 | Q_ASSERT(axis); | |
175 | axis->setDirty(false); |
|
175 | axis->setDirty(false); | |
176 |
if(axis->orientation()==Qt::Horizontal) |
|
176 | if (axis->orientation() == Qt::Horizontal) | |
177 | setRangeX(axis->min(),axis->max()); |
|
177 | setRangeX(axis->min(), axis->max()); | |
178 |
|
|
178 | else if (axis->orientation() == Qt::Vertical) | |
179 | setRangeY(axis->min(),axis->max()); |
|
179 | setRangeY(axis->min(), axis->max()); | |
180 | } |
|
180 | } | |
181 | } |
|
|||
182 |
|
181 | |||
183 | bool QTCOMMERCIALCHART_AUTOTEST_EXPORT operator== (const Domain &domain1, const Domain &domain2) |
|
182 | bool QTCOMMERCIALCHART_AUTOTEST_EXPORT operator== (const Domain &domain1, const Domain &domain2) | |
184 | { |
|
183 | { |
@@ -36,7 +36,8 | |||||
36 |
|
36 | |||
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 |
class QTCOMMERCIALCHART_AUTOTEST_EXPORT Domain: public QObject |
|
39 | class QTCOMMERCIALCHART_AUTOTEST_EXPORT Domain: public QObject | |
|
40 | { | |||
40 | Q_OBJECT |
|
41 | Q_OBJECT | |
41 | public: |
|
42 | public: | |
42 | explicit Domain(QObject* object=0); |
|
43 | explicit Domain(QObject* object = 0); |
@@ -26,8 +26,8 | |||||
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 |
LegendLayout::LegendLayout(QLegend* legend) |
|
29 | LegendLayout::LegendLayout(QLegend* legend) | |
30 | m_legend(legend) |
|
30 | : m_legend(legend) | |
31 | { |
|
31 | { | |
32 |
|
32 | |||
33 | } |
|
33 | } | |
@@ -42,21 +42,18 void LegendLayout::setOffset(qreal x, qreal y) | |||||
42 | bool scrollHorizontal = true; |
|
42 | bool scrollHorizontal = true; | |
43 | switch(m_legend->alignment()) { |
|
43 | switch (m_legend->alignment()) { | |
44 |
|
|
44 | case Qt::AlignTop: | |
45 |
|
|
45 | case Qt::AlignBottom: | |
46 |
|
|
46 | scrollHorizontal = true; | |
47 |
|
|
47 | break; | |
48 | } |
|
|||
49 |
|
|
48 | case Qt::AlignLeft: | |
50 |
|
|
49 | case Qt::AlignRight: | |
51 |
|
|
50 | scrollHorizontal = false; | |
52 |
|
|
51 | break; | |
53 |
|
|
52 | } | |
54 | } |
|
|||
55 |
|
53 | |||
56 | // If detached, the scrolling direction is vertical instead of horizontal and vice versa. |
|
54 | // If detached, the scrolling direction is vertical instead of horizontal and vice versa. | |
57 |
if (!m_legend->isAttachedToChart()) |
|
55 | if (!m_legend->isAttachedToChart()) | |
58 | scrollHorizontal = !scrollHorizontal; |
|
56 | scrollHorizontal = !scrollHorizontal; | |
59 | } |
|
|||
60 |
|
57 | |||
61 | QRectF boundingRect = geometry(); |
|
58 | QRectF boundingRect = geometry(); | |
62 | qreal left, top, right, bottom; |
|
59 | qreal left, top, right, bottom; | |
@@ -65,15 +62,16 void LegendLayout::setOffset(qreal x, qreal y) | |||||
65 |
|
62 | |||
66 | // Limit offset between m_minOffset and m_maxOffset |
|
63 | // Limit offset between m_minOffset and m_maxOffset | |
67 | if (scrollHorizontal) { |
|
64 | if (scrollHorizontal) { | |
68 |
if(m_width<=boundingRect.width()) |
|
65 | if (m_width <= boundingRect.width()) | |
|
66 | return; | |||
69 |
|
67 | |||
70 | if (x != m_offsetX) { |
|
68 | if (x != m_offsetX) { | |
71 | m_offsetX = qBound(m_minOffsetX, x, m_maxOffsetX); |
|
69 | m_offsetX = qBound(m_minOffsetX, x, m_maxOffsetX); | |
72 | m_legend->d_ptr->items()->setPos(-m_offsetX,boundingRect.top()); |
|
70 | m_legend->d_ptr->items()->setPos(-m_offsetX, boundingRect.top()); | |
73 | } |
|
71 | } | |
74 | } |
|
72 | } else { | |
75 | else { |
|
73 | if (m_height <= boundingRect.height()) | |
76 | if(m_height<=boundingRect.height()) return; |
|
74 | return; | |
77 |
|
75 | |||
78 | if (y != m_offsetY) { |
|
76 | if (y != m_offsetY) { | |
79 | m_offsetY = qBound(m_minOffsetY, y, m_maxOffsetY); |
|
77 | m_offsetY = qBound(m_minOffsetY, y, m_maxOffsetY); | |
@@ -90,10 +88,9 QPointF LegendLayout::offset() const | |||||
90 | void LegendLayout::invalidate() |
|
88 | void LegendLayout::invalidate() | |
91 | { |
|
89 | { | |
92 | QGraphicsLayout::invalidate(); |
|
90 | QGraphicsLayout::invalidate(); | |
93 |
if(m_legend->isAttachedToChart()) |
|
91 | if (m_legend->isAttachedToChart()) | |
94 | m_legend->d_ptr->m_presenter->layout()->invalidate(); |
|
92 | m_legend->d_ptr->m_presenter->layout()->invalidate(); | |
95 | } |
|
93 | } | |
96 | } |
|
|||
97 |
|
94 | |||
98 | void LegendLayout::setGeometry(const QRectF& rect) |
|
95 | void LegendLayout::setGeometry(const QRectF& rect) | |
99 | { |
|
96 | { | |
@@ -101,23 +98,24 void LegendLayout::setGeometry(const QRectF& rect) | |||||
101 |
|
98 | |||
102 | QGraphicsLayout::setGeometry(rect); |
|
99 | QGraphicsLayout::setGeometry(rect); | |
103 |
|
100 | |||
104 |
if(m_legend->isAttachedToChart()) |
|
101 | if (m_legend->isAttachedToChart()) | |
105 | setAttachedGeometry(rect); |
|
102 | setAttachedGeometry(rect); | |
106 |
|
|
103 | else | |
107 | setDettachedGeometry(rect); |
|
104 | setDettachedGeometry(rect); | |
108 | } |
|
105 | } | |
109 |
|
106 | |||
110 | } |
|
|||
111 |
|
||||
112 | void LegendLayout::setAttachedGeometry(const QRectF& rect) |
|
107 | void LegendLayout::setAttachedGeometry(const QRectF& rect) | |
113 | { |
|
108 | { | |
114 |
if (!rect.isValid()) |
|
109 | if (!rect.isValid()) | |
|
110 | return; | |||
|
111 | ||||
115 | m_offsetX=0; |
|
112 | m_offsetX = 0; | |
116 | m_offsetY=0; |
|
113 | m_offsetY = 0; | |
117 |
|
114 | |||
118 | QSizeF size(0,0); |
|
115 | QSizeF size(0, 0); | |
119 |
|
116 | |||
120 |
if( |
|
117 | if (m_legend->d_ptr->markers().isEmpty()) | |
|
118 | return; | |||
121 |
|
119 | |||
122 | m_width=0; |
|
120 | m_width = 0; | |
123 | m_height=0; |
|
121 | m_height = 0; | |
@@ -128,7 +126,6 void LegendLayout::setAttachedGeometry(const QRectF& rect) | |||||
128 | QRectF geometry = rect.adjusted(left,top,-right,-bottom); |
|
126 | QRectF geometry = rect.adjusted(left, top, -right, -bottom); | |
129 |
|
127 | |||
130 | switch(m_legend->alignment()) { |
|
128 | switch (m_legend->alignment()) { | |
131 |
|
||||
132 |
|
|
129 | case Qt::AlignTop: | |
133 |
|
|
130 | case Qt::AlignBottom: { | |
134 | QPointF point(0,0); |
|
131 | QPointF point(0, 0); | |
@@ -143,13 +140,10 void LegendLayout::setAttachedGeometry(const QRectF& rect) | |||||
143 | point.setX(point.x() + w); |
|
140 | point.setX(point.x() + w); | |
144 | } |
|
141 | } | |
145 | } |
|
142 | } | |
146 |
if(m_width<geometry.width()) |
|
143 | if (m_width < geometry.width()) | |
147 | m_legend->d_ptr->items()->setPos(geometry.width()/2-m_width/2,geometry.top()); |
|
144 | m_legend->d_ptr->items()->setPos(geometry.width() / 2 - m_width / 2, geometry.top()); | |
148 |
|
145 | else | ||
149 | } |
|
|||
150 | else { |
|
|||
151 | m_legend->d_ptr->items()->setPos(geometry.topLeft()); |
|
146 | m_legend->d_ptr->items()->setPos(geometry.topLeft()); | |
152 | } |
|
|||
153 | m_height=size.height(); |
|
147 | m_height = size.height(); | |
154 | } |
|
148 | } | |
155 | break; |
|
149 | break; | |
@@ -167,17 +161,15 void LegendLayout::setAttachedGeometry(const QRectF& rect) | |||||
167 |
|
|
161 | point.setY(point.y() + h); | |
168 |
|
|
162 | } | |
169 |
|
|
163 | } | |
170 | if(m_height<geometry.height()) { |
|
164 | ||
|
165 | if (m_height < geometry.height()) | |||
171 |
|
|
166 | m_legend->d_ptr->items()->setPos(geometry.left(), geometry.height() / 2 - m_height / 2); | |
172 |
|
|
167 | else | |
173 | else { |
|
|||
174 |
|
|
168 | m_legend->d_ptr->items()->setPos(geometry.topLeft()); | |
175 | } |
|
|||
176 |
|
|
169 | m_width = size.width(); | |
177 | } |
|
|||
178 | break; |
|
170 | break; | |
179 | } |
|
171 | } | |
180 |
|
172 | } | ||
181 |
|
173 | |||
182 | m_minOffsetX = -left; |
|
174 | m_minOffsetX = -left; | |
183 | m_minOffsetY = - top; |
|
175 | m_minOffsetY = - top; | |
@@ -187,7 +179,8 void LegendLayout::setAttachedGeometry(const QRectF& rect) | |||||
187 |
|
179 | |||
188 | void LegendLayout::setDettachedGeometry(const QRectF& rect) |
|
180 | void LegendLayout::setDettachedGeometry(const QRectF& rect) | |
189 | { |
|
181 | { | |
190 |
if (!rect.isValid()) |
|
182 | if (!rect.isValid()) | |
|
183 | return; | |||
191 |
|
184 | |||
192 | // Detached layout is different. |
|
185 | // Detached layout is different. | |
193 | // In detached mode legend may have multiple rows and columns, so layout calculations |
|
186 | // In detached mode legend may have multiple rows and columns, so layout calculations | |
@@ -205,7 +198,8 void LegendLayout::setDettachedGeometry(const QRectF& rect) | |||||
205 |
|
198 | |||
206 | QList<LegendMarker *> markers = m_legend->d_ptr->markers(); |
|
199 | QList<LegendMarker *> markers = m_legend->d_ptr->markers(); | |
207 |
|
200 | |||
208 |
if(markers.isEmpty()) |
|
201 | if (markers.isEmpty()) | |
|
202 | return; | |||
209 |
|
203 | |||
210 | switch (m_legend->alignment()) { |
|
204 | switch (m_legend->alignment()) { | |
211 |
|
|
205 | case Qt::AlignTop: { | |
@@ -359,12 +353,10 QSizeF LegendLayout::sizeHint ( Qt::SizeHint which, const QSizeF & constraint) c | |||||
359 | getContentsMargins(&left, &top, &right, &bottom); |
|
353 | getContentsMargins(&left, &top, &right, &bottom); | |
360 |
|
354 | |||
361 | if(constraint.isValid()) { |
|
355 | if (constraint.isValid()) { | |
362 |
foreach(LegendMarker* |
|
356 | foreach (LegendMarker *marker, m_legend->d_ptr->markers()) | |
363 | size = size.expandedTo(marker->effectiveSizeHint(which)); |
|
357 | size = size.expandedTo(marker->effectiveSizeHint(which)); | |
364 | } |
|
|||
365 | size = size.boundedTo(constraint); |
|
358 | size = size.boundedTo(constraint); | |
366 | } |
|
359 | } else if (constraint.width() >= 0) { | |
367 | else if (constraint.width() >= 0) { |
|
|||
368 | qreal width = 0; |
|
360 | qreal width = 0; | |
369 | qreal height = 0; |
|
361 | qreal height = 0; | |
370 |
foreach(LegendMarker* |
|
362 | foreach (LegendMarker *marker, m_legend->d_ptr->markers()) { | |
@@ -373,8 +365,7 QSizeF LegendLayout::sizeHint ( Qt::SizeHint which, const QSizeF & constraint) c | |||||
373 | } |
|
365 | } | |
374 |
|
366 | |||
375 | size = QSizeF(qMin(constraint.width(),width), height); |
|
367 | size = QSizeF(qMin(constraint.width(), width), height); | |
376 | } |
|
368 | } else if (constraint.height() >= 0) { | |
377 | else if (constraint.height() >= 0) { |
|
|||
378 | qreal width = 0; |
|
369 | qreal width = 0; | |
379 | qreal height = 0; |
|
370 | qreal height = 0; | |
380 |
foreach(LegendMarker* |
|
371 | foreach (LegendMarker *marker, m_legend->d_ptr->markers()) { | |
@@ -382,12 +373,10 QSizeF LegendLayout::sizeHint ( Qt::SizeHint which, const QSizeF & constraint) c | |||||
382 | height+=height,marker->effectiveSizeHint(which).height(); |
|
373 | height += height, marker->effectiveSizeHint(which).height(); | |
383 | } |
|
374 | } | |
384 | size = QSizeF(width,qMin(constraint.height(),height)); |
|
375 | size = QSizeF(width, qMin(constraint.height(), height)); | |
385 | } |
|
376 | } else { | |
386 | else { |
|
377 | foreach (LegendMarker *marker, m_legend->d_ptr->markers()) | |
387 | foreach(LegendMarker* marker, m_legend->d_ptr->markers()) { |
|
|||
388 | size = size.expandedTo(marker->effectiveSizeHint(which)); |
|
378 | size = size.expandedTo(marker->effectiveSizeHint(which)); | |
389 |
|
|
379 | } | |
390 | } |
|
|||
391 | size += QSize(left + right, top + bottom); |
|
380 | size += QSize(left + right, top + bottom); | |
392 | return size; |
|
381 | return size; | |
393 | } |
|
382 | } |
@@ -60,7 +60,6 private: | |||||
60 | qreal m_maxOffsetY; |
|
60 | qreal m_maxOffsetY; | |
61 | qreal m_width; |
|
61 | qreal m_width; | |
62 | qreal m_height; |
|
62 | qreal m_height; | |
63 |
|
||||
64 | }; |
|
63 | }; | |
65 |
|
64 | |||
66 | QTCOMMERCIALCHART_END_NAMESPACE |
|
65 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -121,19 +121,16 void LegendMarker::setGeometry(const QRectF& rect) | |||||
121 | qreal x = m_margin + m_markerRect.width() + m_space + m_margin; |
|
121 | qreal x = m_margin + m_markerRect.width() + m_space + m_margin; | |
122 | qreal y = qMax(m_markerRect.height()+2*m_margin,fn.height()+2*m_margin); |
|
122 | qreal y = qMax(m_markerRect.height() + 2 * m_margin, fn.height() + 2 * m_margin); | |
123 |
|
123 | |||
124 | if (fn.boundingRect(m_text).width() + x > width) |
|
124 | if (fn.boundingRect(m_text).width() + x > width) { | |
125 | { |
|
|||
126 | QString string = m_text + "..."; |
|
125 | QString string = m_text + "..."; | |
127 | while(fn.boundingRect(string).width() + x > width && string.length() > 3) |
|
126 | while (fn.boundingRect(string).width() + x > width && string.length() > 3) | |
128 | string.remove(string.length() - 4, 1); |
|
127 | string.remove(string.length() - 4, 1); | |
129 | m_textItem->setText(string); |
|
128 | m_textItem->setText(string); | |
130 | } |
|
129 | } else { | |
131 | else |
|
|||
132 | m_textItem->setText(m_text); |
|
130 | m_textItem->setText(m_text); | |
|
131 | } | |||
133 |
|
132 | |||
134 | const QRectF& textRect = m_textItem->boundingRect(); |
|
133 | const QRectF& textRect = m_textItem->boundingRect(); | |
135 |
|
||||
136 |
|
||||
137 | m_textItem->setPos(x-m_margin,y/2 - textRect.height()/2); |
|
134 | m_textItem->setPos(x - m_margin, y / 2 - textRect.height() / 2); | |
138 | m_rectItem->setRect(m_markerRect); |
|
135 | m_rectItem->setRect(m_markerRect); | |
139 | m_rectItem->setPos(m_margin,y/2 - m_markerRect.height()/2); |
|
136 | m_rectItem->setPos(m_margin, y / 2 - m_markerRect.height() / 2); | |
@@ -177,7 +174,8 void LegendMarker::mousePressEvent(QGraphicsSceneMouseEvent *event) | |||||
177 |
|
174 | |||
178 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
175 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
179 |
|
176 | |||
180 |
AreaLegendMarker::AreaLegendMarker(QAreaSeries *series,QLegend *legend) |
|
177 | AreaLegendMarker::AreaLegendMarker(QAreaSeries *series, QLegend *legend) | |
|
178 | : LegendMarker(series, legend), | |||
181 | m_series(series) |
|
179 | m_series(series) | |
182 | { |
|
180 | { | |
183 | //QObject::connect(this, SIGNAL(selected()), series, SIGNAL(selected())); |
|
181 | //QObject::connect(this, SIGNAL(selected()), series, SIGNAL(selected())); | |
@@ -194,7 +192,8 void AreaLegendMarker::updated() | |||||
194 |
|
192 | |||
195 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
193 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
196 |
|
194 | |||
197 |
BarLegendMarker::BarLegendMarker(QAbstractBarSeries *barseries,QBarSet *barset, QLegend *legend) |
|
195 | BarLegendMarker::BarLegendMarker(QAbstractBarSeries *barseries, QBarSet *barset, QLegend *legend) | |
|
196 | : LegendMarker(barseries, legend), | |||
198 | m_barset(barset) |
|
197 | m_barset(barset) | |
199 | { |
|
198 | { | |
200 | //QObject::connect(this, SIGNAL(selected()),barset->d_ptr.data(), SIGNAL(selected())); |
|
199 | //QObject::connect(this, SIGNAL(selected()),barset->d_ptr.data(), SIGNAL(selected())); | |
@@ -211,7 +210,8 void BarLegendMarker::updated() | |||||
211 |
|
210 | |||
212 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
211 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
213 |
|
212 | |||
214 |
PieLegendMarker::PieLegendMarker(QPieSeries* series,QPieSlice *pieslice, QLegend *legend) |
|
213 | PieLegendMarker::PieLegendMarker(QPieSeries* series, QPieSlice *pieslice, QLegend *legend) | |
|
214 | : LegendMarker(series, legend), | |||
215 | m_pieslice(pieslice) |
|
215 | m_pieslice(pieslice) | |
216 | { |
|
216 | { | |
217 | QObject::connect(pieslice, SIGNAL(labelChanged()), this, SLOT(updated())); |
|
217 | QObject::connect(pieslice, SIGNAL(labelChanged()), this, SLOT(updated())); | |
@@ -227,7 +227,8 void PieLegendMarker::updated() | |||||
227 |
|
227 | |||
228 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
228 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
229 |
|
229 | |||
230 |
XYLegendMarker::XYLegendMarker(QXYSeries *series, QLegend *legend) |
|
230 | XYLegendMarker::XYLegendMarker(QXYSeries *series, QLegend *legend) | |
|
231 | : LegendMarker(series, legend), | |||
231 | m_series(series) |
|
232 | m_series(series) | |
232 | { |
|
233 | { | |
233 | //QObject::connect(this, SIGNAL(selected()), series, SIGNAL(selected())); |
|
234 | //QObject::connect(this, SIGNAL(selected()), series, SIGNAL(selected())); | |
@@ -241,14 +242,10 void XYLegendMarker::updated() | |||||
241 | setLabel(m_series->name()); |
|
242 | setLabel(m_series->name()); | |
242 |
|
243 | |||
243 | if(m_series->type()== QAbstractSeries::SeriesTypeScatter) |
|
244 | if (m_series->type() == QAbstractSeries::SeriesTypeScatter) | |
244 | { |
|
|||
245 | setBrush(m_series->brush()); |
|
245 | setBrush(m_series->brush()); | |
246 |
|
246 | else | ||
247 | } |
|
|||
248 | else { |
|
|||
249 | setBrush(QBrush(m_series->pen().color())); |
|
247 | setBrush(QBrush(m_series->pen().color())); | |
250 | } |
|
248 | } | |
251 | } |
|
|||
252 |
|
249 | |||
253 | #include "moc_legendmarker_p.cpp" |
|
250 | #include "moc_legendmarker_p.cpp" | |
254 |
|
251 |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -41,28 +41,17 class LegendScroller: public QLegend, public Scroller | |||||
41 | { |
|
41 | { | |
42 |
|
42 | |||
43 | public: |
|
43 | public: | |
44 | LegendScroller(QChart *chart):QLegend(chart) |
|
44 | LegendScroller(QChart *chart): QLegend(chart) { } | |
45 | { |
|
|||
46 | } |
|
|||
47 |
|
45 | |||
48 | void setOffset(const QPointF& point) |
|
46 | void setOffset(const QPointF& point) { d_ptr->setOffset(point.x(), point.y()); } | |
49 | { |
|
47 | ||
50 | d_ptr->setOffset(point.x(), point.y()); |
|
48 | QPointF offset() const { return d_ptr->offset(); } | |
51 | } |
|
49 | ||
52 | QPointF offset() const |
|
50 | void mousePressEvent(QGraphicsSceneMouseEvent* event) { Scroller::mousePressEvent(event); } | |
53 | { |
|
51 | ||
54 | return d_ptr->offset(); |
|
52 | void mouseMoveEvent(QGraphicsSceneMouseEvent* event) { Scroller::mouseMoveEvent(event); } | |
55 | } |
|
|||
56 |
|
53 | |||
57 |
void mouse |
|
54 | void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) { Scroller::mouseReleaseEvent(event); } | |
58 | Scroller::mousePressEvent(event); |
|
|||
59 | } |
|
|||
60 | void mouseMoveEvent(QGraphicsSceneMouseEvent* event){ |
|
|||
61 | Scroller::mouseMoveEvent(event); |
|
|||
62 | } |
|
|||
63 | void mouseReleaseEvent(QGraphicsSceneMouseEvent* event){ |
|
|||
64 | Scroller::mouseReleaseEvent(event); |
|
|||
65 | } |
|
|||
66 | }; |
|
55 | }; | |
67 |
|
56 | |||
68 | QTCOMMERCIALCHART_END_NAMESPACE |
|
57 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -193,13 +193,13 void QLegend::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q | |||||
193 | Q_UNUSED(option) |
|
193 | Q_UNUSED(option) | |
194 | Q_UNUSED(widget) |
|
194 | Q_UNUSED(widget) | |
195 |
|
195 | |||
196 |
if(!d_ptr->m_backgroundVisible) |
|
196 | if (!d_ptr->m_backgroundVisible) | |
|
197 | return; | |||
197 |
|
198 | |||
198 | painter->setOpacity(opacity()); |
|
199 | painter->setOpacity(opacity()); | |
199 | painter->setPen(d_ptr->m_pen); |
|
200 | painter->setPen(d_ptr->m_pen); | |
200 | painter->setBrush(d_ptr->m_brush); |
|
201 | painter->setBrush(d_ptr->m_brush); | |
201 | painter->drawRoundRect(rect(),d_ptr->roundness(rect().width()),d_ptr->roundness(rect().height())); |
|
202 | painter->drawRoundRect(rect(), d_ptr->roundness(rect().width()), d_ptr->roundness(rect().height())); | |
202 |
|
||||
203 | } |
|
203 | } | |
204 |
|
204 | |||
205 |
|
205 | |||
@@ -263,10 +263,8 void QLegend::setFont(const QFont &font) | |||||
263 | { |
|
263 | { | |
264 | if (d_ptr->m_font != font) { |
|
264 | if (d_ptr->m_font != font) { | |
265 | d_ptr->m_font = font; |
|
265 | d_ptr->m_font = font; | |
266 |
|
266 | foreach (LegendMarker *marker, d_ptr->markers()) | ||
267 | foreach (LegendMarker *marker, d_ptr->markers()) { |
|
|||
268 |
|
|
267 | marker->setFont(d_ptr->m_font); | |
269 | } |
|
|||
270 | layout()->invalidate(); |
|
268 | layout()->invalidate(); | |
271 | emit fontChanged(font); |
|
269 | emit fontChanged(font); | |
272 | } |
|
270 | } | |
@@ -399,7 +397,8 bool QLegend::isBackgroundVisible() const | |||||
399 | */ |
|
397 | */ | |
400 | void QLegend::hideEvent(QHideEvent *event) |
|
398 | void QLegend::hideEvent(QHideEvent *event) | |
401 | { |
|
399 | { | |
402 | if(isAttachedToChart()) d_ptr->m_presenter->layout()->invalidate(); |
|
400 | if (isAttachedToChart()) | |
|
401 | d_ptr->m_presenter->layout()->invalidate(); | |||
403 | QGraphicsWidget::hideEvent(event); |
|
402 | QGraphicsWidget::hideEvent(event); | |
404 | } |
|
403 | } | |
405 | /*! |
|
404 | /*! | |
@@ -417,8 +416,8 void QLegend::showEvent(QShowEvent *event) | |||||
417 |
|
416 | |||
418 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
417 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
419 |
|
418 | |||
420 |
QLegendPrivate::QLegendPrivate(ChartPresenter* presenter, QChart *chart, QLegend *q) |
|
419 | QLegendPrivate::QLegendPrivate(ChartPresenter* presenter, QChart *chart, QLegend *q) | |
421 | q_ptr(q), |
|
420 | : q_ptr(q), | |
422 | m_presenter(presenter), |
|
421 | m_presenter(presenter), | |
423 | m_layout(new LegendLayout(q)), |
|
422 | m_layout(new LegendLayout(q)), | |
424 | m_chart(chart), |
|
423 | m_chart(chart), | |
@@ -495,10 +494,9 void QLegendPrivate::handleSeriesVisibleChanged() | |||||
495 | Q_ASSERT(series); |
|
494 | Q_ASSERT(series); | |
496 |
|
495 | |||
497 |
foreach (LegendMarker* |
|
496 | foreach (LegendMarker *marker, m_markers) { | |
498 |
if (marker->series() == series) |
|
497 | if (marker->series() == series) | |
499 | marker->setVisible(series->isVisible()); |
|
498 | marker->setVisible(series->isVisible()); | |
500 |
|
|
499 | } | |
501 | } |
|
|||
502 | m_layout->invalidate(); |
|
500 | m_layout->invalidate(); | |
503 | } |
|
501 | } | |
504 |
|
502 |
@@ -80,7 +80,6 private: | |||||
80 |
|
80 | |||
81 | friend class QLegend; |
|
81 | friend class QLegend; | |
82 | friend class LegendLayout; |
|
82 | friend class LegendLayout; | |
83 |
|
||||
84 | }; |
|
83 | }; | |
85 |
|
84 | |||
86 | QTCOMMERCIALCHART_END_NAMESPACE |
|
85 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -29,8 +29,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
29 |
|
29 | |||
30 | const qreal mouseEventMinWidth(12); |
|
30 | const qreal mouseEventMinWidth(12); | |
31 |
|
31 | |||
32 |
LineChartItem::LineChartItem(QLineSeries* series,ChartPresenter *presenter) |
|
32 | LineChartItem::LineChartItem(QLineSeries* series, ChartPresenter *presenter) | |
33 | XYChart(series, presenter), |
|
33 | : XYChart(series, presenter), | |
34 | QGraphicsItem(presenter ? presenter->rootItem() : 0), |
|
34 | QGraphicsItem(presenter ? presenter->rootItem() : 0), | |
35 | m_series(series), |
|
35 | m_series(series), | |
36 | m_pointsVisible(false) |
|
36 | m_pointsVisible(false) | |
@@ -56,8 +56,7 void LineChartItem::updateGeometry() | |||||
56 | { |
|
56 | { | |
57 | m_points = geometryPoints(); |
|
57 | m_points = geometryPoints(); | |
58 |
|
58 | |||
59 | if(m_points.size()==0) |
|
59 | if (m_points.size() == 0) { | |
60 | { |
|
|||
61 | prepareGeometryChange(); |
|
60 | prepareGeometryChange(); | |
62 | m_path = QPainterPath(); |
|
61 | m_path = QPainterPath(); | |
63 | m_rect = QRect(); |
|
62 | m_rect = QRect(); | |
@@ -76,11 +75,9 void LineChartItem::updateGeometry() | |||||
76 | } |
|
75 | } | |
77 |
|
76 | |||
78 | } else { |
|
77 | } else { | |
79 |
|
78 | for (int i = 1; i < m_points.size(); i++) | ||
80 | for(int i=1; i< m_points.size();i++) { |
|
|||
81 | linePath.lineTo(m_points.at(i)); |
|
79 | linePath.lineTo(m_points.at(i)); | |
82 |
|
|
80 | } | |
83 | } |
|
|||
84 |
|
81 | |||
85 | m_linePath = linePath; |
|
82 | m_linePath = linePath; | |
86 |
|
83 | |||
@@ -122,8 +119,7 void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt | |||||
122 |
|
119 | |||
123 | if (m_pointsVisible) { |
|
120 | if (m_pointsVisible) { | |
124 | painter->drawPath(m_linePath); |
|
121 | painter->drawPath(m_linePath); | |
125 | } |
|
122 | } else { | |
126 | else { |
|
|||
127 | for (int i(1); i < m_points.size();i++) |
|
123 | for (int i(1); i < m_points.size(); i++) | |
128 | painter->drawLine(m_points.at(i-1), m_points.at(i)); |
|
124 | painter->drawLine(m_points.at(i - 1), m_points.at(i)); | |
129 | } |
|
125 | } |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -98,7 +98,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
98 | Constructs empty series object which is a child of \a parent. |
|
98 | Constructs empty series object which is a child of \a parent. | |
99 | When series object is added to QChartView or QChart instance ownerships is transferred. |
|
99 | When series object is added to QChartView or QChart instance ownerships is transferred. | |
100 | */ |
|
100 | */ | |
101 |
QLineSeries::QLineSeries(QObject *parent) |
|
101 | QLineSeries::QLineSeries(QObject *parent) | |
|
102 | : QXYSeries(*new QLineSeriesPrivate(this), parent) | |||
102 | { |
|
103 | { | |
103 |
|
104 | |||
104 | } |
|
105 | } | |
@@ -106,7 +107,8 QLineSeries::QLineSeries(QObject *parent) : QXYSeries(*new QLineSeriesPrivate(th | |||||
106 | /*! |
|
107 | /*! | |
107 | \internal |
|
108 | \internal | |
108 | */ |
|
109 | */ | |
109 |
QLineSeries::QLineSeries(QLineSeriesPrivate &d,QObject *parent) |
|
110 | QLineSeries::QLineSeries(QLineSeriesPrivate &d, QObject *parent) | |
|
111 | : QXYSeries(d, parent) | |||
110 | { |
|
112 | { | |
111 |
|
113 | |||
112 | } |
|
114 | } | |
@@ -117,10 +119,9 QLineSeries::QLineSeries(QLineSeriesPrivate &d,QObject *parent) : QXYSeries (d,p | |||||
117 | QLineSeries::~QLineSeries() |
|
119 | QLineSeries::~QLineSeries() | |
118 | { |
|
120 | { | |
119 | Q_D(QLineSeries); |
|
121 | Q_D(QLineSeries); | |
120 |
if(d->m_dataset) |
|
122 | if (d->m_dataset) | |
121 |
|
|
123 | d->m_dataset->removeSeries(this); | |
122 | } |
|
124 | } | |
123 | } |
|
|||
124 |
|
125 | |||
125 | QAbstractSeries::SeriesType QLineSeries::type() const |
|
126 | QAbstractSeries::SeriesType QLineSeries::type() const | |
126 | { |
|
127 | { | |
@@ -150,9 +151,8 ChartElement* QLineSeriesPrivate::createGraphics(ChartPresenter* presenter) | |||||
150 | { |
|
151 | { | |
151 | Q_Q(QLineSeries); |
|
152 | Q_Q(QLineSeries); | |
152 | LineChartItem* line = new LineChartItem(q,presenter); |
|
153 | LineChartItem* line = new LineChartItem(q, presenter); | |
153 |
if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
154 | if (presenter->animationOptions().testFlag(QChart::SeriesAnimations)) | |
154 | line->setAnimation(new XYAnimation(line)); |
|
155 | line->setAnimation(new XYAnimation(line)); | |
155 | } |
|
|||
156 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
156 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
157 | return line; |
|
157 | return line; | |
158 | } |
|
158 | } |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -133,9 +133,8 void PieChartItem::updateLayout() | |||||
133 | PieSliceItem *sliceItem = m_sliceItems.value(slice); |
|
133 | PieSliceItem *sliceItem = m_sliceItems.value(slice); | |
134 | if (sliceItem) { |
|
134 | if (sliceItem) { | |
135 | PieSliceData sliceData = updateSliceGeometry(slice); |
|
135 | PieSliceData sliceData = updateSliceGeometry(slice); | |
136 |
if (m_animation) |
|
136 | if (m_animation) | |
137 | presenter()->startAnimation(m_animation->updateValue(sliceItem, sliceData)); |
|
137 | presenter()->startAnimation(m_animation->updateValue(sliceItem, sliceData)); | |
138 | } |
|
|||
139 | else |
|
138 | else | |
140 | sliceItem->setLayout(sliceData); |
|
139 | sliceItem->setLayout(sliceData); | |
141 | } |
|
140 | } |
@@ -85,8 +85,7 void PieSliceItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*op | |||||
85 | painter->setBrush(m_data.m_labelBrush); |
|
85 | painter->setBrush(m_data.m_labelBrush); | |
86 | painter->setFont(m_data.m_labelFont); |
|
86 | painter->setFont(m_data.m_labelFont); | |
87 |
|
87 | |||
88 | switch (m_data.m_labelPosition) |
|
88 | switch (m_data.m_labelPosition) { | |
89 | { |
|
|||
90 | case QPieSlice::LabelOutside: |
|
89 | case QPieSlice::LabelOutside: | |
91 | painter->setClipRect(parentItem()->boundingRect()); |
|
90 | painter->setClipRect(parentItem()->boundingRect()); | |
92 | painter->strokePath(m_labelArmPath, m_data.m_labelBrush.color()); |
|
91 | painter->strokePath(m_labelArmPath, m_data.m_labelBrush.color()); | |
@@ -163,8 +162,7 void PieSliceItem::updateGeometry() | |||||
163 | m_labelArmPath = labelArmPath(armStart, centerAngle, m_data.m_radius * m_data.m_labelArmLengthFactor, m_labelTextRect.width(), &labelTextStart); |
|
162 | m_labelArmPath = labelArmPath(armStart, centerAngle, m_data.m_radius * m_data.m_labelArmLengthFactor, m_labelTextRect.width(), &labelTextStart); | |
164 |
|
163 | |||
165 | // text position |
|
164 | // text position | |
166 | switch (m_data.m_labelPosition) |
|
165 | switch (m_data.m_labelPosition) { | |
167 | { |
|
|||
168 | case QPieSlice::LabelOutside: |
|
166 | case QPieSlice::LabelOutside: | |
169 | m_labelTextRect.moveBottomLeft(labelTextStart); |
|
167 | m_labelTextRect.moveBottomLeft(labelTextStart); | |
170 | break; |
|
168 | break; | |
@@ -263,8 +261,7 QPainterPath PieSliceItem::labelArmPath(QPointF start, qreal angle, qreal length | |||||
263 | if (angle < 180) { // arm swings the other way on the left side |
|
261 | if (angle < 180) { // arm swings the other way on the left side | |
264 | parm2 += QPointF(textWidth, 0); |
|
262 | parm2 += QPointF(textWidth, 0); | |
265 | *textStart = parm1; |
|
263 | *textStart = parm1; | |
266 | } |
|
264 | } else { | |
267 | else { |
|
|||
268 | parm2 += QPointF(-textWidth,0); |
|
265 | parm2 += QPointF(-textWidth, 0); | |
269 | *textStart = parm2; |
|
266 | *textStart = parm2; | |
270 | } |
|
267 | } |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -347,8 +347,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
347 | /*! |
|
347 | /*! | |
348 | Constructs a series object which is a child of \a parent. |
|
348 | Constructs a series object which is a child of \a parent. | |
349 | */ |
|
349 | */ | |
350 |
QPieSeries::QPieSeries(QObject *parent) |
|
350 | QPieSeries::QPieSeries(QObject *parent) | |
351 | QAbstractSeries(*new QPieSeriesPrivate(this),parent) |
|
351 | : QAbstractSeries(*new QPieSeriesPrivate(this), parent) | |
352 | { |
|
352 | { | |
353 | Q_D(QPieSeries); |
|
353 | Q_D(QPieSeries); | |
354 | QObject::connect(this,SIGNAL(countChanged()),d,SIGNAL(countChanged())); |
|
354 | QObject::connect(this, SIGNAL(countChanged()), d, SIGNAL(countChanged())); | |
@@ -844,9 +844,8 ChartElement* QPieSeriesPrivate::createGraphics(ChartPresenter* presenter) | |||||
844 | { |
|
844 | { | |
845 | Q_Q(QPieSeries); |
|
845 | Q_Q(QPieSeries); | |
846 | PieChartItem* pie = new PieChartItem(q,presenter); |
|
846 | PieChartItem* pie = new PieChartItem(q, presenter); | |
847 |
if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
847 | if (presenter->animationOptions().testFlag(QChart::SeriesAnimations)) | |
848 | pie->setAnimation(new PieAnimation(pie)); |
|
848 | pie->setAnimation(new PieAnimation(pie)); | |
849 | } |
|
|||
850 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
849 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
851 | return pie; |
|
850 | return pie; | |
852 | } |
|
851 | } |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -137,7 +137,8 QAbstractSeries::QAbstractSeries(QAbstractSeriesPrivate &d, QObject *parent) : | |||||
137 | */ |
|
137 | */ | |
138 | QAbstractSeries::~QAbstractSeries() |
|
138 | QAbstractSeries::~QAbstractSeries() | |
139 | { |
|
139 | { | |
140 | if(d_ptr->m_dataset) qFatal("Still binded series detected !"); |
|
140 | if (d_ptr->m_dataset) | |
|
141 | qFatal("Still binded series detected !"); | |||
141 | } |
|
142 | } | |
142 |
|
143 | |||
143 | void QAbstractSeries::setName(const QString& name) |
|
144 | void QAbstractSeries::setName(const QString& name) | |
@@ -223,8 +224,8 void QAbstractSeries::hide() | |||||
223 |
|
224 | |||
224 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
|
225 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
225 |
|
226 | |||
226 |
QAbstractSeriesPrivate::QAbstractSeriesPrivate(QAbstractSeries* q) |
|
227 | QAbstractSeriesPrivate::QAbstractSeriesPrivate(QAbstractSeries* q) | |
227 | q_ptr(q), |
|
228 | : q_ptr(q), | |
228 | m_chart(0), |
|
229 | m_chart(0), | |
229 | m_dataset(0), |
|
230 | m_dataset(0), | |
230 | m_visible(true), |
|
231 | m_visible(true), |
@@ -104,7 +104,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
104 | /*! |
|
104 | /*! | |
105 | Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor. |
|
105 | Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor. | |
106 | */ |
|
106 | */ | |
107 |
QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) |
|
107 | QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) | |
|
108 | : QGraphicsWidget(parent, wFlags), | |||
108 | d_ptr(new QChartPrivate()) |
|
109 | d_ptr(new QChartPrivate()) | |
109 | { |
|
110 | { | |
110 | d_ptr->m_dataset = new ChartDataSet(this); |
|
111 | d_ptr->m_dataset = new ChartDataSet(this); |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -47,7 +47,6 struct QChartPrivate | |||||
47 | ChartPresenter *m_presenter; |
|
47 | ChartPresenter *m_presenter; | |
48 |
|
48 | |||
49 | void createConnections(); |
|
49 | void createConnections(); | |
50 |
|
||||
51 | }; |
|
50 | }; | |
52 |
|
51 | |||
53 | QTCOMMERCIALCHART_END_NAMESPACE |
|
52 | QTCOMMERCIALCHART_END_NAMESPACE |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -53,8 +53,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
53 | Constructs a chartView object with parent \a parent. |
|
53 | Constructs a chartView object with parent \a parent. | |
54 | */ |
|
54 | */ | |
55 |
|
55 | |||
56 |
QChartView::QChartView(QWidget *parent) |
|
56 | QChartView::QChartView(QWidget *parent) | |
57 | QGraphicsView(parent), |
|
57 | : QGraphicsView(parent), | |
58 | d_ptr(new QChartViewPrivate(this)) |
|
58 | d_ptr(new QChartViewPrivate(this)) | |
59 | { |
|
59 | { | |
60 |
|
60 | |||
@@ -64,8 +64,8 QChartView::QChartView(QWidget *parent) : | |||||
64 | Constructs a chartView object with parent \a parent to display a \a chart. |
|
64 | Constructs a chartView object with parent \a parent to display a \a chart. | |
65 | */ |
|
65 | */ | |
66 |
|
66 | |||
67 |
QChartView::QChartView(QChart *chart,QWidget *parent) |
|
67 | QChartView::QChartView(QChart *chart, QWidget *parent) | |
68 | QGraphicsView(parent), |
|
68 | : QGraphicsView(parent), | |
69 | d_ptr(new QChartViewPrivate(this,chart)) |
|
69 | d_ptr(new QChartViewPrivate(this, chart)) | |
70 | { |
|
70 | { | |
71 |
|
71 | |||
@@ -142,8 +142,7 void QChartView::mousePressEvent(QMouseEvent *event) | |||||
142 | d_ptr->m_rubberBand->show(); |
|
142 | d_ptr->m_rubberBand->show(); | |
143 | event->accept(); |
|
143 | event->accept(); | |
144 | } |
|
144 | } | |
145 | } |
|
145 | } else { | |
146 | else { |
|
|||
147 | QGraphicsView::mousePressEvent(event); |
|
146 | QGraphicsView::mousePressEvent(event); | |
148 | } |
|
147 | } | |
149 | } |
|
148 | } | |
@@ -167,8 +166,7 void QChartView::mouseMoveEvent(QMouseEvent *event) | |||||
167 | width= rect.width(); |
|
166 | width = rect.width(); | |
168 | } |
|
167 | } | |
169 | d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin.x(),d_ptr->m_rubberBandOrigin.y(), width,height).normalized()); |
|
168 | d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin.x(), d_ptr->m_rubberBandOrigin.y(), width, height).normalized()); | |
170 | } |
|
169 | } else { | |
171 | else { |
|
|||
172 | QGraphicsView::mouseMoveEvent(event); |
|
170 | QGraphicsView::mouseMoveEvent(event); | |
173 | } |
|
171 | } | |
174 | } |
|
172 | } | |
@@ -191,8 +189,7 void QChartView::mouseReleaseEvent(QMouseEvent *event) | |||||
191 | d_ptr->m_chart->zoomOut(); |
|
189 | d_ptr->m_chart->zoomOut(); | |
192 | event->accept(); |
|
190 | event->accept(); | |
193 | } |
|
191 | } | |
194 | } |
|
192 | } else { | |
195 | else { |
|
|||
196 | QGraphicsView::mouseReleaseEvent(event); |
|
193 | QGraphicsView::mouseReleaseEvent(event); | |
197 | } |
|
194 | } | |
198 | } |
|
195 | } | |
@@ -208,8 +205,8 void QChartView::resizeEvent(QResizeEvent *event) | |||||
208 |
|
205 | |||
209 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
206 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
210 |
|
207 | |||
211 |
QChartViewPrivate::QChartViewPrivate(QChartView *q,QChart* chart) |
|
208 | QChartViewPrivate::QChartViewPrivate(QChartView *q, QChart* chart) | |
212 | q_ptr(q), |
|
209 | : q_ptr(q), | |
213 | m_scene(new QGraphicsScene(q)), |
|
210 | m_scene(new QGraphicsScene(q)), | |
214 | m_chart(chart), |
|
211 | m_chart(chart), | |
215 | m_rubberBand(0), |
|
212 | m_rubberBand(0), | |
@@ -221,7 +218,8 m_rubberBandFlags(QChartView::NoRubberBand) | |||||
221 | q_ptr->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
|
218 | q_ptr->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
222 | q_ptr->setScene(m_scene); |
|
219 | q_ptr->setScene(m_scene); | |
223 | q_ptr->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
220 | q_ptr->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
224 | if(!m_chart) m_chart = new QChart(); |
|
221 | if (!m_chart) | |
|
222 | m_chart = new QChart(); | |||
225 | m_scene->addItem(m_chart); |
|
223 | m_scene->addItem(m_chart); | |
226 | } |
|
224 | } | |
227 |
|
225 |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -40,8 +40,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
40 | class QChart; |
|
40 | class QChart; | |
41 | class QChartView; |
|
41 | class QChartView; | |
42 |
|
42 | |||
43 |
class QChartViewPrivate |
|
43 | class QChartViewPrivate | |
44 |
|
44 | { | ||
45 | public: |
|
45 | public: | |
46 | explicit QChartViewPrivate(QChartView *q, QChart *chart = 0); |
|
46 | explicit QChartViewPrivate(QChartView *q, QChart *chart = 0); | |
47 | ~QChartViewPrivate(); |
|
47 | ~QChartViewPrivate(); |
@@ -128,7 +128,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
128 | /*! |
|
128 | /*! | |
129 | Constructs a series object which is a child of \a parent. |
|
129 | Constructs a series object which is a child of \a parent. | |
130 | */ |
|
130 | */ | |
131 |
QScatterSeries::QScatterSeries(QObject *parent) |
|
131 | QScatterSeries::QScatterSeries(QObject *parent) | |
|
132 | : QXYSeries(*new QScatterSeriesPrivate(this), parent) | |||
132 | { |
|
133 | { | |
133 | } |
|
134 | } | |
134 |
|
135 | |||
@@ -138,10 +139,9 QScatterSeries::QScatterSeries(QObject *parent) : QXYSeries(*new QScatterSeriesP | |||||
138 | QScatterSeries::~QScatterSeries() |
|
139 | QScatterSeries::~QScatterSeries() | |
139 | { |
|
140 | { | |
140 | Q_D(QScatterSeries); |
|
141 | Q_D(QScatterSeries); | |
141 |
if(d->m_dataset) |
|
142 | if (d->m_dataset) | |
142 | d->m_dataset->removeSeries(this); |
|
143 | d->m_dataset->removeSeries(this); | |
143 | } |
|
144 | } | |
144 | } |
|
|||
145 |
|
145 | |||
146 | QAbstractSeries::SeriesType QScatterSeries::type() const |
|
146 | QAbstractSeries::SeriesType QScatterSeries::type() const | |
147 | { |
|
147 | { | |
@@ -254,9 +254,8 ChartElement* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter) | |||||
254 | { |
|
254 | { | |
255 | Q_Q(QScatterSeries); |
|
255 | Q_Q(QScatterSeries); | |
256 | ScatterChartItem *scatter = new ScatterChartItem(q,presenter); |
|
256 | ScatterChartItem *scatter = new ScatterChartItem(q, presenter); | |
257 |
if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
257 | if (presenter->animationOptions().testFlag(QChart::SeriesAnimations)) | |
258 | scatter->setAnimation(new XYAnimation(scatter)); |
|
258 | scatter->setAnimation(new XYAnimation(scatter)); | |
259 | } |
|
|||
260 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
259 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
261 | return scatter; |
|
260 | return scatter; | |
262 | } |
|
261 | } |
@@ -29,8 +29,8 | |||||
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 |
ScatterChartItem::ScatterChartItem(QScatterSeries *series, ChartPresenter *presenter) |
|
32 | ScatterChartItem::ScatterChartItem(QScatterSeries *series, ChartPresenter *presenter) | |
33 | XYChart(series,presenter), |
|
33 | : XYChart(series, presenter), | |
34 | QGraphicsItem(presenter ? presenter->rootItem() : 0), |
|
34 | QGraphicsItem(presenter ? presenter->rootItem() : 0), | |
35 | m_series(series), |
|
35 | m_series(series), | |
36 | m_items(this), |
|
36 | m_items(this), | |
@@ -76,7 +76,6 void ScatterChartItem::createPoints(int count) | |||||
76 |
|
|
76 | default: | |
77 | qWarning()<<"Unsupported marker type"; |
|
77 | qWarning() << "Unsupported marker type"; | |
78 | break; |
|
78 | break; | |
79 |
|
||||
80 | } |
|
79 | } | |
81 | m_items.addToGroup(item); |
|
80 | m_items.addToGroup(item); | |
82 | } |
|
81 | } | |
@@ -103,22 +102,20 void ScatterChartItem::updateGeometry() | |||||
103 |
|
102 | |||
104 | const QVector<QPointF>& points = geometryPoints(); |
|
103 | const QVector<QPointF>& points = geometryPoints(); | |
105 |
|
104 | |||
106 | if(points.size()==0) |
|
105 | if (points.size() == 0) { | |
107 | { |
|
|||
108 | deletePoints(m_items.childItems().count()); |
|
106 | deletePoints(m_items.childItems().count()); | |
109 | return; |
|
107 | return; | |
110 | } |
|
108 | } | |
111 |
|
109 | |||
112 | int diff = m_items.childItems().size() - points.size(); |
|
110 | int diff = m_items.childItems().size() - points.size(); | |
113 |
|
111 | |||
114 |
if(diff>0) |
|
112 | if (diff > 0) | |
115 | deletePoints(diff); |
|
113 | deletePoints(diff); | |
116 | } |
|
114 | else if (diff < 0) | |
117 | else if(diff<0) { |
|
|||
118 | createPoints(-diff); |
|
115 | createPoints(-diff); | |
119 | } |
|
|||
120 |
|
116 | |||
121 |
if(diff!=0) |
|
117 | if (diff != 0) | |
|
118 | handleUpdated(); | |||
122 |
|
119 | |||
123 | QList<QGraphicsItem*> items = m_items.childItems(); |
|
120 | QList<QGraphicsItem*> items = m_items.childItems(); | |
124 |
|
121 | |||
@@ -128,13 +125,11 void ScatterChartItem::updateGeometry() | |||||
128 | const QRectF& rect = item->boundingRect(); |
|
125 | const QRectF& rect = item->boundingRect(); | |
129 | m_markerMap[item]=point; |
|
126 | m_markerMap[item] = point; | |
130 | item->setPos(point.x()-rect.width()/2,point.y()-rect.height()/2); |
|
127 | item->setPos(point.x() - rect.width() / 2, point.y() - rect.height() / 2); | |
131 |
if(!m_visible || !clipRect().contains(point)) |
|
128 | if (!m_visible || !clipRect().contains(point)) | |
132 | item->setVisible(false); |
|
129 | item->setVisible(false); | |
133 |
|
|
130 | else | |
134 | else { |
|
|||
135 | item->setVisible(true); |
|
131 | item->setVisible(true); | |
136 |
|
|
132 | } | |
137 | } |
|
|||
138 |
|
133 | |||
139 | prepareGeometryChange(); |
|
134 | prepareGeometryChange(); | |
140 | m_rect = clipRect(); |
|
135 | m_rect = clipRect(); | |
@@ -150,23 +145,22 void ScatterChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem * | |||||
150 |
|
145 | |||
151 | void ScatterChartItem::setPen(const QPen& pen) |
|
146 | void ScatterChartItem::setPen(const QPen& pen) | |
152 | { |
|
147 | { | |
153 |
foreach(QGraphicsItem* |
|
148 | foreach (QGraphicsItem *item , m_items.childItems()) | |
154 | static_cast<QAbstractGraphicsShapeItem*>(item)->setPen(pen); |
|
149 | static_cast<QAbstractGraphicsShapeItem*>(item)->setPen(pen); | |
155 | } |
|
150 | } | |
156 | } |
|
|||
157 |
|
151 | |||
158 | void ScatterChartItem::setBrush(const QBrush& brush) |
|
152 | void ScatterChartItem::setBrush(const QBrush& brush) | |
159 | { |
|
153 | { | |
160 |
foreach(QGraphicsItem* |
|
154 | foreach (QGraphicsItem *item , m_items.childItems()) | |
161 | static_cast<QAbstractGraphicsShapeItem*>(item)->setBrush(brush); |
|
155 | static_cast<QAbstractGraphicsShapeItem*>(item)->setBrush(brush); | |
162 | } |
|
156 | } | |
163 | } |
|
|||
164 |
|
157 | |||
165 | void ScatterChartItem::handleUpdated() |
|
158 | void ScatterChartItem::handleUpdated() | |
166 | { |
|
159 | { | |
167 | int count = m_items.childItems().count(); |
|
160 | int count = m_items.childItems().count(); | |
168 |
|
161 | |||
169 |
if(count==0) |
|
162 | if (count == 0) | |
|
163 | return; | |||
170 |
|
164 | |||
171 | bool recreate = m_visible != m_series->isVisible() |
|
165 | bool recreate = m_visible != m_series->isVisible() | |
172 | || m_size != m_series->markerSize() |
|
166 | || m_size != m_series->markerSize() |
@@ -80,7 +80,8 class CircleMarker: public QGraphicsEllipseItem | |||||
80 | { |
|
80 | { | |
81 |
|
81 | |||
82 | public: |
|
82 | public: | |
83 |
CircleMarker(qreal x, qreal y, qreal w, qreal h, ScatterChartItem *parent) |
|
83 | CircleMarker(qreal x, qreal y, qreal w, qreal h, ScatterChartItem *parent) | |
|
84 | : QGraphicsEllipseItem(x, y, w, h, parent), | |||
84 |
|
|
85 | m_parent(parent) | |
85 | { |
|
86 | { | |
86 | } |
|
87 | } | |
@@ -100,7 +101,8 class RectangleMarker: public QGraphicsRectItem | |||||
100 | { |
|
101 | { | |
101 |
|
102 | |||
102 | public: |
|
103 | public: | |
103 |
RectangleMarker(qreal x, qreal y, qreal w, qreal h, ScatterChartItem *parent) |
|
104 | RectangleMarker(qreal x, qreal y, qreal w, qreal h, ScatterChartItem *parent) | |
|
105 | : QGraphicsRectItem(x, y, w, h, parent), | |||
104 | m_parent(parent) |
|
106 | m_parent(parent) | |
105 | { |
|
107 | { | |
106 | } |
|
108 | } |
@@ -25,8 +25,8 | |||||
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 |
Scroller::Scroller() |
|
28 | Scroller::Scroller() | |
29 | m_ticker(this), |
|
29 | : m_ticker(this), | |
30 | m_state(Idle), |
|
30 | m_state(Idle), | |
31 | m_moveThreshold(10), |
|
31 | m_moveThreshold(10), | |
32 | m_timeTreshold(50) |
|
32 | m_timeTreshold(50) | |
@@ -41,26 +41,21 Scroller::~Scroller() | |||||
41 | void Scroller::mousePressEvent(QGraphicsSceneMouseEvent* event) |
|
41 | void Scroller::mousePressEvent(QGraphicsSceneMouseEvent* event) | |
42 | { |
|
42 | { | |
43 | if (event->button() == Qt::LeftButton) { |
|
43 | if (event->button() == Qt::LeftButton) { | |
44 |
|
||||
45 | switch (m_state) { |
|
44 | switch (m_state) { | |
46 | case Idle: |
|
45 | case Idle: | |
47 | { |
|
|||
48 | m_state = Pressed; |
|
46 | m_state = Pressed; | |
49 | m_offset = offset(); |
|
47 | m_offset = offset(); | |
50 | m_press = event->pos(); |
|
48 | m_press = event->pos(); | |
51 | m_timeStamp = QTime::currentTime(); |
|
49 | m_timeStamp = QTime::currentTime(); | |
52 | event->accept(); |
|
50 | event->accept(); | |
53 | break; |
|
51 | break; | |
54 | } |
|
|||
55 | case Scroll: |
|
52 | case Scroll: | |
56 | { |
|
|||
57 | m_state = Stop; |
|
53 | m_state = Stop; | |
58 | m_speed = QPointF(0, 0); |
|
54 | m_speed = QPointF(0, 0); | |
59 | m_offset = offset(); |
|
55 | m_offset = offset(); | |
60 | m_press = event->pos(); |
|
56 | m_press = event->pos(); | |
61 | event->accept(); |
|
57 | event->accept(); | |
62 | break; |
|
58 | break; | |
63 | } |
|
|||
64 | case Pressed: |
|
59 | case Pressed: | |
65 | case Move: |
|
60 | case Move: | |
66 | case Stop: |
|
61 | case Stop: | |
@@ -78,34 +73,27 void Scroller::mouseMoveEvent(QGraphicsSceneMouseEvent* event) | |||||
78 | switch (m_state) { |
|
73 | switch (m_state) { | |
79 | case Pressed: |
|
74 | case Pressed: | |
80 | case Stop: |
|
75 | case Stop: | |
81 | { |
|
|||
82 | if (qAbs(delta.x()) > m_moveThreshold || qAbs(delta.y()) > m_moveThreshold) { |
|
76 | if (qAbs(delta.x()) > m_moveThreshold || qAbs(delta.y()) > m_moveThreshold) { | |
83 | m_state = Move; |
|
77 | m_state = Move; | |
84 | m_timeStamp = QTime::currentTime(); |
|
78 | m_timeStamp = QTime::currentTime(); | |
85 | m_distance = QPointF(0, 0); |
|
79 | m_distance = QPointF(0, 0); | |
86 | m_press = event->pos(); |
|
80 | m_press = event->pos(); | |
87 | event->accept(); |
|
81 | event->accept(); | |
88 | break; |
|
82 | } else { | |
89 | } |
|
|||
90 | else { |
|
|||
91 | event->ignore(); |
|
83 | event->ignore(); | |
92 | break; |
|
|||
93 | } |
|
|||
94 | } |
|
84 | } | |
|
85 | break; | |||
95 | case Move: |
|
86 | case Move: | |
96 | { |
|
|||
97 | setOffset(m_offset - delta); |
|
87 | setOffset(m_offset - delta); | |
98 | calculateSpeed(event->pos()); |
|
88 | calculateSpeed(event->pos()); | |
99 | event->accept(); |
|
89 | event->accept(); | |
100 | break; |
|
90 | break; | |
101 | } |
|
|||
102 | case Idle: |
|
91 | case Idle: | |
103 | case Scroll: |
|
92 | case Scroll: | |
104 | qWarning() << __FUNCTION__<<"Scroller unexpected state" << m_state; |
|
93 | qWarning() << __FUNCTION__ << "Scroller unexpected state" << m_state; | |
105 | event->ignore(); |
|
94 | event->ignore(); | |
106 | break; |
|
95 | break; | |
107 | } |
|
96 | } | |
108 |
|
||||
109 | } |
|
97 | } | |
110 |
|
98 | |||
111 | void Scroller::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) |
|
99 | void Scroller::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) | |
@@ -121,7 +109,6 void Scroller::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) | |||||
121 | event->accept(); |
|
109 | event->accept(); | |
122 | break; |
|
110 | break; | |
123 | case Pressed: |
|
111 | case Pressed: | |
124 | { |
|
|||
125 | m_state = Idle; |
|
112 | m_state = Idle; | |
126 | //if (m_timeStamp.elapsed() < m_clickedPressDelay) { |
|
113 | //if (m_timeStamp.elapsed() < m_clickedPressDelay) { | |
127 |
|
114 | |||
@@ -129,30 +116,24 void Scroller::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) | |||||
129 | //} |
|
116 | //} | |
130 | event->accept(); |
|
117 | event->accept(); | |
131 | break; |
|
118 | break; | |
132 | } |
|
|||
133 | case Move: |
|
119 | case Move: | |
134 | { |
|
|||
135 | calculateSpeed(event->pos()); |
|
120 | calculateSpeed(event->pos()); | |
136 | m_offset = offset(); |
|
121 | m_offset = offset(); | |
137 | m_press = event->pos(); |
|
122 | m_press = event->pos(); | |
138 | if (m_speed == QPointF(0, 0)) { |
|
123 | if (m_speed == QPointF(0, 0)) { | |
139 | m_state = Idle; |
|
124 | m_state = Idle; | |
140 | } |
|
125 | } else { | |
141 | else { |
|
|||
142 | m_speed /= 3.75; |
|
126 | m_speed /= 3.75; | |
143 | m_state = Scroll; |
|
127 | m_state = Scroll; | |
144 | m_ticker.start(25); |
|
128 | m_ticker.start(25); | |
145 | } |
|
129 | } | |
146 | event->accept(); |
|
130 | event->accept(); | |
147 | break; |
|
131 | break; | |
148 | } |
|
|||
149 |
|
||||
150 | case Stop: |
|
132 | case Stop: | |
151 | case Idle: |
|
133 | case Idle: | |
152 | qWarning() << __FUNCTION__<<"Scroller unexpected state" << m_state; |
|
134 | qWarning() << __FUNCTION__ << "Scroller unexpected state" << m_state; | |
153 | event->ignore(); |
|
135 | event->ignore(); | |
154 | break; |
|
136 | break; | |
155 |
|
||||
156 | } |
|
137 | } | |
157 | } |
|
138 | } | |
158 | } |
|
139 | } | |
@@ -161,7 +142,6 void Scroller::scrollTick() | |||||
161 | { |
|
142 | { | |
162 | switch (m_state) { |
|
143 | switch (m_state) { | |
163 |
|
|
144 | case Scroll: | |
164 | { |
|
|||
165 |
|
|
145 | lowerSpeed(m_speed); | |
166 |
|
|
146 | setOffset(m_offset - m_speed); | |
167 |
|
|
147 | m_offset = offset(); | |
@@ -170,7 +150,6 void Scroller::scrollTick() | |||||
170 |
|
|
150 | m_ticker.stop(); | |
171 |
|
|
151 | } | |
172 |
|
|
152 | break; | |
173 | } |
|
|||
174 |
|
|
153 | case Stop: | |
175 |
|
|
154 | m_ticker.stop(); | |
176 |
|
|
155 | break; | |
@@ -212,8 +191,7 void Scroller::calculateSpeed(const QPointF& position) | |||||
212 | if (fraction != 0) { |
|
191 | if (fraction != 0) { | |
213 | m_fraction.setX(qAbs(m_speed.x() / fraction)); |
|
192 | m_fraction.setX(qAbs(m_speed.x() / fraction)); | |
214 | m_fraction.setY(qAbs(m_speed.y() / fraction)); |
|
193 | m_fraction.setY(qAbs(m_speed.y() / fraction)); | |
215 | } |
|
194 | } else { | |
216 | else { |
|
|||
217 | m_fraction.setX(1); |
|
195 | m_fraction.setX(1); | |
218 | m_fraction.setY(1); |
|
196 | m_fraction.setY(1); | |
219 | } |
|
197 | } | |
@@ -222,7 +200,8 void Scroller::calculateSpeed(const QPointF& position) | |||||
222 |
|
200 | |||
223 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
201 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
224 |
|
202 | |||
225 |
ScrollTicker::ScrollTicker(Scroller *scroller,QObject* parent) |
|
203 | ScrollTicker::ScrollTicker(Scroller *scroller, QObject* parent) | |
|
204 | : QObject(parent), | |||
226 | m_scroller(scroller) |
|
205 | m_scroller(scroller) | |
227 | { |
|
206 | { | |
228 |
|
207 | |||
@@ -230,10 +209,9 ScrollTicker::ScrollTicker(Scroller *scroller,QObject* parent):QObject(parent), | |||||
230 |
|
209 | |||
231 | void ScrollTicker::start(int interval) |
|
210 | void ScrollTicker::start(int interval) | |
232 | { |
|
211 | { | |
233 |
if (!m_timer.isActive()) |
|
212 | if (!m_timer.isActive()) | |
234 | m_timer.start(interval, this); |
|
213 | m_timer.start(interval, this); | |
235 | } |
|
214 | } | |
236 | } |
|
|||
237 |
|
215 | |||
238 | void ScrollTicker::stop() |
|
216 | void ScrollTicker::stop() | |
239 | { |
|
217 | { |
@@ -77,7 +77,6 public: | |||||
77 | public: |
|
77 | public: | |
78 | void scrollTick(); |
|
78 | void scrollTick(); | |
79 |
|
79 | |||
80 |
|
||||
81 | public: |
|
80 | public: | |
82 | void mousePressEvent(QGraphicsSceneMouseEvent* event); |
|
81 | void mousePressEvent(QGraphicsSceneMouseEvent* event); | |
83 | void mouseMoveEvent(QGraphicsSceneMouseEvent* event); |
|
82 | void mouseMoveEvent(QGraphicsSceneMouseEvent* event); | |
@@ -98,8 +97,6 private: | |||||
98 | QPointF m_fraction; |
|
97 | QPointF m_fraction; | |
99 | int m_moveThreshold; |
|
98 | int m_moveThreshold; | |
100 | int m_timeTreshold; |
|
99 | int m_timeTreshold; | |
101 |
|
||||
102 |
|
||||
103 | }; |
|
100 | }; | |
104 |
|
101 | |||
105 | QTCOMMERCIALCHART_END_NAMESPACE |
|
102 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -98,8 +98,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
98 | When series object is added to QChartView or QChart instance then the ownerships is transferred. |
|
98 | When series object is added to QChartView or QChart instance then the ownerships is transferred. | |
99 | */ |
|
99 | */ | |
100 |
|
100 | |||
101 |
QSplineSeries::QSplineSeries(QObject *parent) |
|
101 | QSplineSeries::QSplineSeries(QObject *parent) | |
102 | QLineSeries(*new QSplineSeriesPrivate(this),parent) |
|
102 | : QLineSeries(*new QSplineSeriesPrivate(this), parent) | |
103 | { |
|
103 | { | |
104 | Q_D(QSplineSeries); |
|
104 | Q_D(QSplineSeries); | |
105 | QObject::connect(this,SIGNAL(pointAdded(int)), d, SLOT(updateControlPoints())); |
|
105 | QObject::connect(this, SIGNAL(pointAdded(int)), d, SLOT(updateControlPoints())); | |
@@ -114,10 +114,9 QSplineSeries::QSplineSeries(QObject *parent) : | |||||
114 | QSplineSeries::~QSplineSeries() |
|
114 | QSplineSeries::~QSplineSeries() | |
115 | { |
|
115 | { | |
116 | Q_D(QSplineSeries); |
|
116 | Q_D(QSplineSeries); | |
117 |
if(d->m_dataset) |
|
117 | if (d->m_dataset) | |
118 | d->m_dataset->removeSeries(this); |
|
118 | d->m_dataset->removeSeries(this); | |
119 | } |
|
119 | } | |
120 | } |
|
|||
121 |
|
120 | |||
122 | QAbstractSeries::SeriesType QSplineSeries::type() const |
|
121 | QAbstractSeries::SeriesType QSplineSeries::type() const | |
123 | { |
|
122 | { | |
@@ -126,7 +125,8 QAbstractSeries::SeriesType QSplineSeries::type() const | |||||
126 |
|
125 | |||
127 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
126 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
128 |
|
127 | |||
129 |
QSplineSeriesPrivate::QSplineSeriesPrivate(QSplineSeries* q) |
|
128 | QSplineSeriesPrivate::QSplineSeriesPrivate(QSplineSeries* q) | |
|
129 | : QLineSeriesPrivate(q) | |||
130 | { |
|
130 | { | |
131 | } |
|
131 | } | |
132 |
|
132 | |||
@@ -141,8 +141,7 void QSplineSeriesPrivate::calculateControlPoints() | |||||
141 |
|
141 | |||
142 | int n = points.count() - 1; |
|
142 | int n = points.count() - 1; | |
143 |
|
143 | |||
144 | if (n == 1) |
|
144 | if (n == 1) { | |
145 | { |
|
|||
146 | //for n==1 |
|
145 | //for n==1 | |
147 | m_controlPoints[0].setX((2 * points[0].x() + points[1].x()) / 3); |
|
146 | m_controlPoints[0].setX((2 * points[0].x() + points[1].x()) / 3); | |
148 | m_controlPoints[0].setY((2 * points[0].y() + points[1].y()) / 3); |
|
147 | m_controlPoints[0].setY((2 * points[0].y() + points[1].y()) / 3); | |
@@ -169,9 +168,8 void QSplineSeriesPrivate::calculateControlPoints() | |||||
169 | vector[0] = points[0].x() + 2 * points[1].x(); |
|
168 | vector[0] = points[0].x() + 2 * points[1].x(); | |
170 |
|
169 | |||
171 |
|
170 | |||
172 |
for (int i = 1; i < n - 1; ++i) |
|
171 | for (int i = 1; i < n - 1; ++i) | |
173 | vector[i] = 4 * points[i].x() + 2 * points[i + 1].x(); |
|
172 | vector[i] = 4 * points[i].x() + 2 * points[i + 1].x(); | |
174 | } |
|
|||
175 |
|
173 | |||
176 | vector[n - 1] = (8 * points[n-1].x() + points[n].x()) / 2.0; |
|
174 | vector[n - 1] = (8 * points[n - 1].x() + points[n].x()) / 2.0; | |
177 |
|
175 | |||
@@ -179,9 +177,8 void QSplineSeriesPrivate::calculateControlPoints() | |||||
179 |
|
177 | |||
180 | vector[0] = points[0].y() + 2 * points[1].y(); |
|
178 | vector[0] = points[0].y() + 2 * points[1].y(); | |
181 |
|
179 | |||
182 |
for (int i = 1; i < n - 1; ++i) |
|
180 | for (int i = 1; i < n - 1; ++i) | |
183 | vector[i] = 4 * points[i].y() + 2 * points[i + 1].y(); |
|
181 | vector[i] = 4 * points[i].y() + 2 * points[i + 1].y(); | |
184 | } |
|
|||
185 |
|
182 | |||
186 | vector[n - 1] = (8 * points[n-1].y() + points[n].y()) / 2.0; |
|
183 | vector[n - 1] = (8 * points[n - 1].y() + points[n].y()) / 2.0; | |
187 |
|
184 | |||
@@ -223,6 +220,7 QVector<qreal> QSplineSeriesPrivate::firstControlPoints(const QVector<qreal>& ve | |||||
223 | b = (i < count - 1 ? 4.0 : 3.5) - temp[i]; |
|
220 | b = (i < count - 1 ? 4.0 : 3.5) - temp[i]; | |
224 | result[i]=(vector[i] - result[i - 1]) / b; |
|
221 | result[i] = (vector[i] - result[i - 1]) / b; | |
225 | } |
|
222 | } | |
|
223 | ||||
226 | for (int i = 1; i < count; i++) |
|
224 | for (int i = 1; i < count; i++) | |
227 | result[count - i - 1] -= temp[count - i] * result[count - i]; |
|
225 | result[count - i - 1] -= temp[count - i] * result[count - i]; | |
228 |
|
226 | |||
@@ -250,10 +248,8 ChartElement* QSplineSeriesPrivate::createGraphics(ChartPresenter* presenter) | |||||
250 | { |
|
248 | { | |
251 | Q_Q(QSplineSeries); |
|
249 | Q_Q(QSplineSeries); | |
252 |
SplineChartItem* |
|
250 | SplineChartItem *spline = new SplineChartItem(q, presenter); | |
253 |
if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
251 | if (presenter->animationOptions().testFlag(QChart::SeriesAnimations)) | |
254 | spline->setAnimation(new SplineAnimation(spline)); |
|
252 | spline->setAnimation(new SplineAnimation(spline)); | |
255 | } |
|
|||
256 |
|
||||
257 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
253 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
258 | return spline; |
|
254 | return spline; | |
259 | } |
|
255 | } |
@@ -27,8 +27,8 | |||||
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 |
SplineChartItem::SplineChartItem(QSplineSeries *series, ChartPresenter *presenter) |
|
30 | SplineChartItem::SplineChartItem(QSplineSeries *series, ChartPresenter *presenter) | |
31 | XYChart(series, presenter), |
|
31 | : XYChart(series, presenter), | |
32 | QGraphicsItem(presenter ? presenter->rootItem() : 0), |
|
32 | QGraphicsItem(presenter ? presenter->rootItem() : 0), | |
33 | m_series(series), |
|
33 | m_series(series), | |
34 | m_pointsVisible(false), |
|
34 | m_pointsVisible(false), | |
@@ -76,9 +76,8 void SplineChartItem::updateChart(QVector<QPointF> &oldPoints, QVector<QPointF> | |||||
76 | { |
|
76 | { | |
77 | QVector<QPointF> controlPoints; |
|
77 | QVector<QPointF> controlPoints; | |
78 |
|
78 | |||
79 |
if(newPoints.count()>=2) |
|
79 | if (newPoints.count() >= 2) | |
80 | controlPoints.resize(newPoints.count()*2-2); |
|
80 | controlPoints.resize(newPoints.count() * 2 - 2); | |
81 | } |
|
|||
82 |
|
81 | |||
83 | for (int i = 0; i < newPoints.size() - 1; i++) { |
|
82 | for (int i = 0; i < newPoints.size() - 1; i++) { | |
84 | controlPoints[2*i] = calculateGeometryControlPoint(2 * i); |
|
83 | controlPoints[2 * i] = calculateGeometryControlPoint(2 * i); | |
@@ -92,12 +91,11 void SplineChartItem::updateChart(QVector<QPointF> &oldPoints, QVector<QPointF> | |||||
92 | m_controlPoints = controlPoints; |
|
91 | m_controlPoints = controlPoints; | |
93 | setDirty(false); |
|
92 | setDirty(false); | |
94 |
|
93 | |||
95 |
if (m_animation) |
|
94 | if (m_animation) | |
96 | presenter()->startAnimation(m_animation); |
|
95 | presenter()->startAnimation(m_animation); | |
97 |
|
|
96 | else | |
98 | updateGeometry(); |
|
97 | updateGeometry(); | |
99 | } |
|
98 | } | |
100 | } |
|
|||
101 |
|
99 | |||
102 | QPointF SplineChartItem::calculateGeometryControlPoint(int index) const |
|
100 | QPointF SplineChartItem::calculateGeometryControlPoint(int index) const | |
103 | { |
|
101 | { |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -37,8 +37,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
37 | class ChartThemeBlueCerulean: public ChartTheme |
|
37 | class ChartThemeBlueCerulean: public ChartTheme | |
38 | { |
|
38 | { | |
39 | public: |
|
39 | public: | |
40 | ChartThemeBlueCerulean() : ChartTheme(QChart::ChartThemeBlueCerulean) |
|
40 | ChartThemeBlueCerulean() : ChartTheme(QChart::ChartThemeBlueCerulean) { | |
41 | { |
|
|||
42 | // Series colors |
|
41 | // Series colors | |
43 | m_seriesColors << QRgb(0xc7e85b); |
|
42 | m_seriesColors << QRgb(0xc7e85b); | |
44 | m_seriesColors << QRgb(0x1cb54f); |
|
43 | m_seriesColors << QRgb(0x1cb54f); |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -52,9 +52,8 void QXYModelMapper::setModel(QAbstractItemModel *model) | |||||
52 | return; |
|
52 | return; | |
53 |
|
53 | |||
54 | Q_D(QXYModelMapper); |
|
54 | Q_D(QXYModelMapper); | |
55 |
if (d->m_model) |
|
55 | if (d->m_model) | |
56 | disconnect(d->m_model, 0, d, 0); |
|
56 | disconnect(d->m_model, 0, d, 0); | |
57 | } |
|
|||
58 |
|
57 | |||
59 | d->m_model = model; |
|
58 | d->m_model = model; | |
60 | d->initializeXYFromModel(); |
|
59 | d->initializeXYFromModel(); | |
@@ -82,9 +81,8 QXYSeries* QXYModelMapper::series() const | |||||
82 | void QXYModelMapper::setSeries(QXYSeries *series) |
|
81 | void QXYModelMapper::setSeries(QXYSeries *series) | |
83 | { |
|
82 | { | |
84 | Q_D(QXYModelMapper); |
|
83 | Q_D(QXYModelMapper); | |
85 |
if (d->m_series) |
|
84 | if (d->m_series) | |
86 | disconnect(d->m_series, 0, d, 0); |
|
85 | disconnect(d->m_series, 0, d, 0); | |
87 | } |
|
|||
88 |
|
86 | |||
89 | if (series == 0) |
|
87 | if (series == 0) | |
90 | return; |
|
88 | return; |
@@ -173,7 +173,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
173 | Constructs empty series object which is a child of \a parent. |
|
173 | Constructs empty series object which is a child of \a parent. | |
174 | When series object is added to QChartView or QChart instance ownerships is transferred. |
|
174 | When series object is added to QChartView or QChart instance ownerships is transferred. | |
175 | */ |
|
175 | */ | |
176 |
QXYSeries::QXYSeries(QXYSeriesPrivate &d,QObject *parent) |
|
176 | QXYSeries::QXYSeries(QXYSeriesPrivate &d, QObject *parent) | |
|
177 | : QAbstractSeries(d, parent) | |||
177 | { |
|
178 | { | |
178 | } |
|
179 | } | |
179 |
|
180 | |||
@@ -210,10 +211,9 void QXYSeries::append(const QPointF &point) | |||||
210 | */ |
|
211 | */ | |
211 | void QXYSeries::append(const QList<QPointF> &points) |
|
212 | void QXYSeries::append(const QList<QPointF> &points) | |
212 | { |
|
213 | { | |
213 |
foreach(const QPointF& |
|
214 | foreach (const QPointF &point , points) | |
214 | append(point); |
|
215 | append(point); | |
215 | } |
|
216 | } | |
216 | } |
|
|||
217 |
|
217 | |||
218 | /*! |
|
218 | /*! | |
219 | Replaces data point \a oldX \a oldY with data point \a newX \a newY. |
|
219 | Replaces data point \a oldX \a oldY with data point \a newX \a newY. | |
@@ -232,7 +232,8 void QXYSeries::replace(const QPointF &oldPoint,const QPointF &newPoint) | |||||
232 | { |
|
232 | { | |
233 | Q_D(QXYSeries); |
|
233 | Q_D(QXYSeries); | |
234 | int index = d->m_points.indexOf(oldPoint); |
|
234 | int index = d->m_points.indexOf(oldPoint); | |
235 |
if(index==-1) |
|
235 | if (index == -1) | |
|
236 | return; | |||
236 | d->m_points[index] = newPoint; |
|
237 | d->m_points[index] = newPoint; | |
237 | emit pointReplaced(index); |
|
238 | emit pointReplaced(index); | |
238 | } |
|
239 | } | |
@@ -267,7 +268,8 void QXYSeries::remove(const QPointF &point) | |||||
267 | { |
|
268 | { | |
268 | Q_D(QXYSeries); |
|
269 | Q_D(QXYSeries); | |
269 | int index = d->m_points.indexOf(point); |
|
270 | int index = d->m_points.indexOf(point); | |
270 |
if(index==-1) |
|
271 | if (index == -1) | |
|
272 | return; | |||
271 | d->m_points.remove(index); |
|
273 | d->m_points.remove(index); | |
272 | emit pointRemoved(index); |
|
274 | emit pointRemoved(index); | |
273 | } |
|
275 | } |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -32,7 +32,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
32 |
|
32 | |||
33 | //TODO: optimize : remove points which are not visible |
|
33 | //TODO: optimize : remove points which are not visible | |
34 |
|
34 | |||
35 |
XYChart::XYChart(QXYSeries *series, ChartPresenter *presenter) |
|
35 | XYChart::XYChart(QXYSeries *series, ChartPresenter *presenter) | |
|
36 | : ChartElement(presenter), | |||
36 | m_minX(0), |
|
37 | m_minX(0), | |
37 | m_maxX(0), |
|
38 | m_maxX(0), | |
38 | m_minY(0), |
|
39 | m_minY(0), | |
@@ -121,8 +122,7 void XYChart::updateChart(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoin | |||||
121 | m_points = newPoints; |
|
122 | m_points = newPoints; | |
122 | setDirty(false); |
|
123 | setDirty(false); | |
123 | presenter()->startAnimation(m_animation); |
|
124 | presenter()->startAnimation(m_animation); | |
124 | } |
|
125 | } else { | |
125 | else { |
|
|||
126 | m_points = newPoints; |
|
126 | m_points = newPoints; | |
127 | updateGeometry(); |
|
127 | updateGeometry(); | |
128 | } |
|
128 | } |
General Comments 0
You need to be logged in to leave comments.
Login now