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