|
1 | NO CONTENT: modified file |
|
1 | NO CONTENT: modified file |
@@ -27,7 +27,8 | |||
|
27 | 27 | |
|
28 | 28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | 29 | |
|
30 |
ChartBarCategoryAxisX::ChartBarCategoryAxisX(QBarCategoryAxis *axis,ChartPresenter *presenter) |
|
|
30 | ChartBarCategoryAxisX::ChartBarCategoryAxisX(QBarCategoryAxis *axis, ChartPresenter *presenter) | |
|
31 | : HorizontalAxis(axis, presenter, true), | |
|
31 | 32 | m_categoriesAxis(axis) |
|
32 | 33 | { |
|
33 | 34 | |
@@ -51,14 +52,13 QVector<qreal> ChartBarCategoryAxisX::calculateLayout() const | |||
|
51 | 52 | const qreal delta = gridRect.width()/(count); |
|
52 | 53 | qreal offset =-min()-0.5; |
|
53 | 54 | |
|
54 |
if(delta<1) |
|
|
55 | if (delta < 1) | |
|
56 | return points; | |
|
55 | 57 | |
|
56 |
if(offset<0) |
|
|
58 | if (offset < 0) | |
|
57 | 59 | offset = int(offset * gridRect.width()/(max() - min()))%int(delta) + delta; |
|
58 |
|
|
|
59 | else { | |
|
60 | else | |
|
60 | 61 | offset = int(offset * gridRect.width()/(max() - min()))%int(delta); |
|
61 | } | |
|
62 | 62 | |
|
63 | 63 | for (int i = -1; i < count+1; ++i) { |
|
64 | 64 | qreal x = offset + i * delta + gridRect.left(); |
@@ -77,8 +77,7 QStringList ChartBarCategoryAxisX::createCategoryLabels(const QVector<qreal>& la | |||
|
77 | 77 | qreal x = qFloor((((layout[i] + layout[i+1])/2-gridRect.left())*d + min()+0.5)); |
|
78 | 78 | if ((x < m_categoriesAxis->categories().count()) && (x >= 0)) { |
|
79 | 79 | result << m_categoriesAxis->categories().at(x); |
|
80 | } | |
|
81 | else { | |
|
80 | } else { | |
|
82 | 81 | // No label for x coordinate |
|
83 | 82 | result << ""; |
|
84 | 83 | } |
@@ -91,17 +90,18 QStringList ChartBarCategoryAxisX::createCategoryLabels(const QVector<qreal>& la | |||
|
91 | 90 | void ChartBarCategoryAxisX::updateGeometry() |
|
92 | 91 | { |
|
93 | 92 | const QVector<qreal>& layout = ChartAxis::layout(); |
|
94 |
if(layout.isEmpty()) |
|
|
93 | if (layout.isEmpty()) | |
|
94 | return; | |
|
95 | 95 | setLabels(createCategoryLabels(layout)); |
|
96 | 96 | HorizontalAxis::updateGeometry(); |
|
97 | 97 | } |
|
98 | 98 | |
|
99 | 99 | void ChartBarCategoryAxisX::handleAxisUpdated() |
|
100 | 100 | { |
|
101 | if(m_categoriesAxis->categories()!=m_categories) | |
|
102 | { | |
|
101 | if (m_categoriesAxis->categories() != m_categories) { | |
|
103 | 102 | m_categories=m_categoriesAxis->categories(); |
|
104 |
if(ChartAxis::layout().count()==m_categoriesAxis->d_ptr->count()+2) |
|
|
103 | if (ChartAxis::layout().count() == m_categoriesAxis->d_ptr->count() + 2) | |
|
104 | updateGeometry(); | |
|
105 | 105 | } |
|
106 | 106 | ChartAxis::handleAxisUpdated(); |
|
107 | 107 | } |
@@ -127,8 +127,7 QSizeF ChartBarCategoryAxisX::sizeHint(Qt::SizeHint which, const QSizeF& constra | |||
|
127 | 127 |
|
|
128 | 128 |
|
|
129 | 129 | |
|
130 |
|
|
|
131 | { | |
|
130 | for (int i = 0; i < ticksList.size(); ++i) { | |
|
132 | 131 |
|
|
133 | 132 |
|
|
134 | 133 |
|
@@ -26,7 +26,8 | |||
|
26 | 26 | |
|
27 | 27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | 28 | |
|
29 |
ChartBarCategoryAxisY::ChartBarCategoryAxisY(QBarCategoryAxis *axis,ChartPresenter *presenter) |
|
|
29 | ChartBarCategoryAxisY::ChartBarCategoryAxisY(QBarCategoryAxis *axis, ChartPresenter *presenter) | |
|
30 | : VerticalAxis(axis, presenter, true), | |
|
30 | 31 | m_categoriesAxis(axis) |
|
31 | 32 | { |
|
32 | 33 | } |
@@ -49,14 +50,13 QVector<qreal> ChartBarCategoryAxisY::calculateLayout() const | |||
|
49 | 50 | const qreal delta = gridRect.height()/(count); |
|
50 | 51 | qreal offset = - min() - 0.5; |
|
51 | 52 | |
|
52 |
if(delta<1) |
|
|
53 | if (delta < 1) | |
|
54 | return points; | |
|
53 | 55 | |
|
54 |
if(offset<0) |
|
|
56 | if (offset < 0) | |
|
55 | 57 | offset = int(offset * gridRect.height()/(max() - min()))%int(delta) + delta; |
|
56 |
|
|
|
57 | else { | |
|
58 | else | |
|
58 | 59 | offset = int(offset * gridRect.height()/(max() - min()))%int(delta); |
|
59 | } | |
|
60 | 60 | |
|
61 | 61 | for (int i = -1; i < count +1; ++i) { |
|
62 | 62 | int y = gridRect.bottom() - i * delta - offset; |
@@ -74,8 +74,7 QStringList ChartBarCategoryAxisY::createCategoryLabels(const QVector<qreal>& la | |||
|
74 | 74 | qreal x = qFloor(((gridRect.height()- (layout[i+1] + layout[i])/2 + gridRect.top())*d + min()+0.5)); |
|
75 | 75 | if ((x < m_categoriesAxis->categories().count()) && (x >= 0)) { |
|
76 | 76 | result << m_categoriesAxis->categories().at(x); |
|
77 | } | |
|
78 | else { | |
|
77 | } else { | |
|
79 | 78 | // No label for x coordinate |
|
80 | 79 | result << ""; |
|
81 | 80 | } |
@@ -87,7 +86,8 QStringList ChartBarCategoryAxisY::createCategoryLabels(const QVector<qreal>& la | |||
|
87 | 86 | void ChartBarCategoryAxisY::updateGeometry() |
|
88 | 87 | { |
|
89 | 88 | const QVector<qreal>& layout = ChartAxis::layout(); |
|
90 |
if(layout.isEmpty()) |
|
|
89 | if (layout.isEmpty()) | |
|
90 | return; | |
|
91 | 91 | setLabels(createCategoryLabels(layout)); |
|
92 | 92 | VerticalAxis::updateGeometry(); |
|
93 | 93 | } |
@@ -95,13 +95,11 void ChartBarCategoryAxisY::updateGeometry() | |||
|
95 | 95 | void ChartBarCategoryAxisY::handleAxisUpdated() |
|
96 | 96 | { |
|
97 | 97 | |
|
98 | if(m_categoriesAxis->categories()!=m_categories) | |
|
99 | { | |
|
98 | if (m_categoriesAxis->categories() != m_categories) { | |
|
100 | 99 | m_categories=m_categoriesAxis->categories(); |
|
101 |
if(ChartAxis::layout().count()==m_categoriesAxis->d_ptr->count()+2) |
|
|
100 | if (ChartAxis::layout().count() == m_categoriesAxis->d_ptr->count() + 2) | |
|
102 | 101 | updateGeometry(); |
|
103 | 102 |
|
|
104 | } | |
|
105 | 103 | ChartAxis::handleAxisUpdated(); |
|
106 | 104 | } |
|
107 | 105 | |
@@ -126,8 +124,7 QSizeF ChartBarCategoryAxisY::sizeHint(Qt::SizeHint which, const QSizeF& constra | |||
|
126 | 124 |
|
|
127 | 125 |
|
|
128 | 126 | |
|
129 |
|
|
|
130 | { | |
|
127 | for (int i = 0; i < ticksList.size(); ++i) { | |
|
131 | 128 |
|
|
132 | 129 |
|
|
133 | 130 |
|
@@ -169,20 +169,19 void QBarCategoryAxis::append(const QStringList &categories) | |||
|
169 | 169 | |
|
170 | 170 | int count = d->m_categories.count(); |
|
171 | 171 | |
|
172 | foreach(QString category, categories) | |
|
173 | { | |
|
172 | foreach(QString category, categories) { | |
|
174 | 173 | if(!d->m_categories.contains(category) && !category.isNull()) { |
|
175 | 174 | d->m_categories.append(category); |
|
176 | 175 | } |
|
177 | 176 | } |
|
178 | 177 | |
|
179 |
if(d->m_categories.count() == count) |
|
|
178 | if (d->m_categories.count() == count) | |
|
179 | return; | |
|
180 | 180 | |
|
181 |
if (count == 0) |
|
|
181 | if (count == 0) | |
|
182 | 182 | setRange(d->m_categories.first(), d->m_categories.last()); |
|
183 |
|
|
|
183 | else | |
|
184 | 184 | setRange(d->m_minCategory, d->m_categories.last()); |
|
185 | } | |
|
186 | 185 | |
|
187 | 186 | emit categoriesChanged(); |
|
188 | 187 | } |
@@ -198,17 +197,16 void QBarCategoryAxis::append(const QString &category) | |||
|
198 | 197 | |
|
199 | 198 | int count = d->m_categories.count(); |
|
200 | 199 | |
|
201 |
if(!d->m_categories.contains(category) && !category.isNull()) |
|
|
200 | if (!d->m_categories.contains(category) && !category.isNull()) | |
|
202 | 201 | d->m_categories.append(category); |
|
203 | } | |
|
204 | 202 | |
|
205 |
if(d->m_categories.count() == count) |
|
|
203 | if (d->m_categories.count() == count) | |
|
204 | return; | |
|
206 | 205 | |
|
207 |
if (count == 0) |
|
|
206 | if (count == 0) | |
|
208 | 207 | setRange(d->m_categories.last(), d->m_categories.last()); |
|
209 |
|
|
|
208 | else | |
|
210 | 209 | setRange(d->m_minCategory, d->m_categories.last()); |
|
211 | } | |
|
212 | 210 | |
|
213 | 211 | emit categoriesChanged(); |
|
214 | 212 | } |
@@ -232,8 +230,9 void QBarCategoryAxis::remove(const QString &category) | |||
|
232 | 230 | d->updateCategoryDomain(); |
|
233 | 231 | d->emitUpdated(); |
|
234 | 232 | } |
|
235 | }else | |
|
233 | } else { | |
|
236 | 234 | setRange(QString::null, QString::null); |
|
235 | } | |
|
237 | 236 | emit categoriesChanged(); |
|
238 | 237 | } |
|
239 | 238 | } |
@@ -248,11 +247,11 void QBarCategoryAxis::insert(int index, const QString &category) | |||
|
248 | 247 | |
|
249 | 248 | int count = d->m_categories.count(); |
|
250 | 249 | |
|
251 |
if(!d->m_categories.contains(category) && !category.isNull()) |
|
|
250 | if (!d->m_categories.contains(category) && !category.isNull()) | |
|
252 | 251 | d->m_categories.insert(index, category); |
|
253 | } | |
|
254 | 252 | |
|
255 |
if(d->m_categories.count() == count) |
|
|
253 | if (d->m_categories.count() == count) | |
|
254 | return; | |
|
256 | 255 | |
|
257 | 256 | if (count == 0) { |
|
258 | 257 | setRange(d->m_categories.first(), d->m_categories.first()); |
@@ -404,9 +403,9 void QBarCategoryAxis::setRange(const QString &minCategory, const QString &maxCa | |||
|
404 | 403 | d->emitUpdated(); |
|
405 | 404 | } |
|
406 | 405 | |
|
407 |
if (d->m_categories.indexOf(maxCategory) < d->m_categories.indexOf(minCategory)) |
|
|
406 | if (d->m_categories.indexOf(maxCategory) < d->m_categories.indexOf(minCategory)) | |
|
408 | 407 | return; |
|
409 | } | |
|
408 | ||
|
410 | 409 | if (!minCategory.isEmpty() && d->m_minCategory != minCategory && d->m_categories.contains(minCategory)) { |
|
411 | 410 | d->m_minCategory = minCategory; |
|
412 | 411 | d->m_min = d->m_categories.indexOf(d->m_minCategory) - 0.5; |
@@ -28,7 +28,8 | |||
|
28 | 28 | |
|
29 | 29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | 30 | |
|
31 |
ChartCategoryAxisX::ChartCategoryAxisX(QCategoryAxis *axis,ChartPresenter *presenter) |
|
|
31 | ChartCategoryAxisX::ChartCategoryAxisX(QCategoryAxis *axis, ChartPresenter *presenter) | |
|
32 | : HorizontalAxis(axis, presenter, true), | |
|
32 | 33 | m_axis(axis) |
|
33 | 34 | { |
|
34 | 35 | } |
@@ -50,7 +51,7 QVector<qreal> ChartCategoryAxisX::calculateLayout() const | |||
|
50 | 51 | if (range > 0) { |
|
51 | 52 | points.resize(tickCount); |
|
52 | 53 | qreal scale = gridRect.width() / range; |
|
53 | for (int i = 0; i < tickCount; ++i) | |
|
54 | for (int i = 0; i < tickCount; ++i) { | |
|
54 | 55 | if (i < tickCount - 1) { |
|
55 | 56 | int x = (m_axis->startValue(m_axis->categoriesLabels().at(i)) - m_axis->min()) * scale + gridRect.left(); |
|
56 | 57 | points[i] = x; |
@@ -59,6 +60,7 QVector<qreal> ChartCategoryAxisX::calculateLayout() const | |||
|
59 | 60 | points[i] = x; |
|
60 | 61 | } |
|
61 | 62 | } |
|
63 | } | |
|
62 | 64 | |
|
63 | 65 | return points; |
|
64 | 66 | } |
@@ -96,8 +98,7 QSizeF ChartCategoryAxisX::sizeHint(Qt::SizeHint which, const QSizeF& constraint | |||
|
96 | 98 | break; |
|
97 | 99 |
|
|
98 | 100 | |
|
99 |
|
|
|
100 | { | |
|
101 | for (int i = 0; i < ticksList.size(); ++i) { | |
|
101 | 102 |
|
|
102 | 103 |
|
|
103 | 104 |
|
@@ -44,11 +44,14 public: | |||
|
44 | 44 | ~ChartCategoryAxisX(); |
|
45 | 45 | |
|
46 | 46 | QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const; |
|
47 | ||
|
47 | 48 | protected: |
|
48 | 49 | QVector<qreal> calculateLayout() const; |
|
49 | 50 | void updateGeometry(); |
|
50 | Q_SLOTS | |
|
51 | ||
|
52 | public Q_SLOTS: | |
|
51 | 53 | void handleAxisUpdated(); |
|
54 | ||
|
52 | 55 | private: |
|
53 | 56 | QCategoryAxis *m_axis; |
|
54 | 57 | }; |
@@ -28,7 +28,8 | |||
|
28 | 28 | |
|
29 | 29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | 30 | |
|
31 |
ChartCategoryAxisY::ChartCategoryAxisY(QCategoryAxis *axis,ChartPresenter *presenter) |
|
|
31 | ChartCategoryAxisY::ChartCategoryAxisY(QCategoryAxis *axis, ChartPresenter *presenter) | |
|
32 | : VerticalAxis(axis, presenter, true), | |
|
32 | 33 | m_axis(axis) |
|
33 | 34 | { |
|
34 | 35 | } |
@@ -50,7 +51,7 QVector<qreal> ChartCategoryAxisY::calculateLayout() const | |||
|
50 | 51 | if (range > 0) { |
|
51 | 52 | points.resize(tickCount); |
|
52 | 53 | qreal scale = gridRect.height() / range; |
|
53 | for (int i = 0; i < tickCount; ++i) | |
|
54 | for (int i = 0; i < tickCount; ++i) { | |
|
54 | 55 | if (i < tickCount - 1) { |
|
55 | 56 | int y = -(m_axis->startValue(m_axis->categoriesLabels().at(i)) - m_axis->min()) * scale + gridRect.bottom(); |
|
56 | 57 | points[i] = y; |
@@ -59,6 +60,7 QVector<qreal> ChartCategoryAxisY::calculateLayout() const | |||
|
59 | 60 | points[i] = y; |
|
60 | 61 | } |
|
61 | 62 | } |
|
63 | } | |
|
62 | 64 | |
|
63 | 65 | return points; |
|
64 | 66 | } |
@@ -96,8 +98,7 QSizeF ChartCategoryAxisY::sizeHint(Qt::SizeHint which, const QSizeF& constraint | |||
|
96 | 98 |
|
|
97 | 99 |
|
|
98 | 100 | |
|
99 |
|
|
|
100 | { | |
|
101 | for (int i = 0; i < ticksList.size(); ++i) { | |
|
101 | 102 |
|
|
102 | 103 |
|
|
103 | 104 |
|
@@ -44,11 +44,14 public: | |||
|
44 | 44 | ~ChartCategoryAxisY(); |
|
45 | 45 | |
|
46 | 46 | QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const; |
|
47 | ||
|
47 | 48 | protected: |
|
48 | 49 | QVector<qreal> calculateLayout() const; |
|
49 | 50 | void updateGeometry(); |
|
50 | Q_SLOTS | |
|
51 | ||
|
52 | public Q_SLOTS: | |
|
51 | 53 | void handleAxisUpdated(); |
|
54 | ||
|
52 | 55 | private: |
|
53 | 56 | QCategoryAxis *m_axis; |
|
54 | 57 | }; |
@@ -32,7 +32,8 | |||
|
32 | 32 | |
|
33 | 33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
34 | 34 | |
|
35 |
ChartAxis::ChartAxis(QAbstractAxis *axis,ChartPresenter *presenter, bool intervalAxis) |
|
|
35 | ChartAxis::ChartAxis(QAbstractAxis *axis, ChartPresenter *presenter, bool intervalAxis) | |
|
36 | : ChartElement(presenter), | |
|
36 | 37 | m_chartAxis(axis), |
|
37 | 38 | m_labelsAngle(0), |
|
38 | 39 | m_grid(new QGraphicsItemGroup(presenter->rootItem())), |
@@ -78,10 +79,12 void ChartAxis::createItems(int count) | |||
|
78 | 79 | { |
|
79 | 80 | if (m_arrow->children().size() == 0) |
|
80 | 81 | m_arrow->addToGroup(new AxisItem(this,presenter()->rootItem())); |
|
82 | ||
|
81 | 83 | if (m_intervalAxis && m_grid->children().size() == 0){ |
|
82 | 84 | for(int i = 0 ; i < 2 ;i ++) |
|
83 | 85 | m_grid->addToGroup(new QGraphicsLineItem(presenter()->rootItem())); |
|
84 | 86 | } |
|
87 | ||
|
85 | 88 | for (int i = 0; i < count; ++i) { |
|
86 | 89 | m_grid->addToGroup(new QGraphicsLineItem(presenter()->rootItem())); |
|
87 | 90 | m_labels->addToGroup(new QGraphicsSimpleTextItem(presenter()->rootItem())); |
@@ -99,7 +102,8 void ChartAxis::deleteItems(int count) | |||
|
99 | 102 | QList<QGraphicsItem *> axis = m_arrow->childItems(); |
|
100 | 103 | |
|
101 | 104 | for (int i = 0; i < count; ++i) { |
|
102 |
if (lines.size()%2 && lines.size() > 1) |
|
|
105 | if (lines.size() % 2 && lines.size() > 1) | |
|
106 | delete(shades.takeLast()); | |
|
103 | 107 | delete(lines.takeLast()); |
|
104 | 108 | delete(labels.takeLast()); |
|
105 | 109 | delete(axis.takeLast()); |
@@ -110,12 +114,10 void ChartAxis::updateLayout(QVector<qreal> &layout) | |||
|
110 | 114 | { |
|
111 | 115 | int diff = m_layoutVector.size() - layout.size(); |
|
112 | 116 | |
|
113 |
if (diff>0) |
|
|
117 | if (diff > 0) | |
|
114 | 118 | deleteItems(diff); |
|
115 | } | |
|
116 | else if (diff<0) { | |
|
119 | else if (diff < 0) | |
|
117 | 120 | createItems(-diff); |
|
118 | } | |
|
119 | 121 | |
|
120 | 122 | if(diff<0) handleAxisUpdated(); |
|
121 | 123 | |
@@ -143,8 +145,7 void ChartAxis::updateLayout(QVector<qreal> &layout) | |||
|
143 | 145 |
|
|
144 | 146 |
|
|
145 | 147 |
|
|
146 | } | |
|
147 | else { | |
|
148 | } else { | |
|
148 | 149 | setLayout(layout); |
|
149 | 150 | updateGeometry(); |
|
150 | 151 | } |
@@ -212,70 +213,61 void ChartAxis::setShadesVisibility(bool visible) | |||
|
212 | 213 | |
|
213 | 214 | void ChartAxis::setLabelsAngle(int angle) |
|
214 | 215 | { |
|
215 |
foreach(QGraphicsItem* |
|
|
216 | foreach (QGraphicsItem *item, m_labels->childItems()) | |
|
216 | 217 |
|
|
217 | } | |
|
218 | 218 | |
|
219 | 219 | m_labelsAngle=angle; |
|
220 | 220 | } |
|
221 | 221 | |
|
222 | 222 | void ChartAxis::setLabelsPen(const QPen &pen) |
|
223 | 223 | { |
|
224 |
foreach(QGraphicsItem* |
|
|
224 | foreach (QGraphicsItem *item , m_labels->childItems()) | |
|
225 | 225 | static_cast<QGraphicsSimpleTextItem*>(item)->setPen(pen); |
|
226 | 226 | } |
|
227 | } | |
|
228 | 227 | |
|
229 | 228 | void ChartAxis::setLabelsBrush(const QBrush &brush) |
|
230 | 229 | { |
|
231 |
foreach(QGraphicsItem* |
|
|
230 | foreach (QGraphicsItem *item , m_labels->childItems()) | |
|
232 | 231 | static_cast<QGraphicsSimpleTextItem*>(item)->setBrush(brush); |
|
233 | 232 | } |
|
234 | } | |
|
235 | 233 | |
|
236 | 234 | void ChartAxis::setLabelsFont(const QFont &font) |
|
237 | 235 | { |
|
238 |
foreach(QGraphicsItem* |
|
|
236 | foreach (QGraphicsItem *item , m_labels->childItems()) | |
|
239 | 237 | static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font); |
|
240 | } | |
|
238 | ||
|
241 | 239 | if(m_font!=font) { |
|
242 | 240 | m_font = font; |
|
243 |
foreach(QGraphicsItem* |
|
|
241 | foreach (QGraphicsItem *item , m_labels->childItems()) | |
|
244 | 242 | static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font); |
|
245 | } | |
|
246 | 243 | QGraphicsLayoutItem::updateGeometry(); |
|
247 | 244 | presenter()->layout()->invalidate(); |
|
248 | ||
|
249 | 245 | } |
|
250 | 246 | } |
|
251 | 247 | |
|
252 | 248 | void ChartAxis::setShadesBrush(const QBrush &brush) |
|
253 | 249 | { |
|
254 |
foreach(QGraphicsItem* |
|
|
250 | foreach (QGraphicsItem *item , m_shades->childItems()) | |
|
255 | 251 | static_cast<QGraphicsRectItem*>(item)->setBrush(brush); |
|
256 | 252 | } |
|
257 | } | |
|
258 | 253 | |
|
259 | 254 | void ChartAxis::setShadesPen(const QPen &pen) |
|
260 | 255 | { |
|
261 |
foreach(QGraphicsItem* |
|
|
256 | foreach (QGraphicsItem *item , m_shades->childItems()) | |
|
262 | 257 | static_cast<QGraphicsRectItem*>(item)->setPen(pen); |
|
263 | 258 | } |
|
264 | } | |
|
265 | 259 | |
|
266 | 260 | void ChartAxis::setArrowPen(const QPen &pen) |
|
267 | 261 | { |
|
268 |
foreach(QGraphicsItem* |
|
|
262 | foreach (QGraphicsItem *item , m_arrow->childItems()) | |
|
269 | 263 |
|
|
270 | 264 | } |
|
271 | } | |
|
272 | 265 | |
|
273 | 266 | void ChartAxis::setGridPen(const QPen &pen) |
|
274 | 267 | { |
|
275 |
foreach(QGraphicsItem* |
|
|
268 | foreach (QGraphicsItem *item , m_grid->childItems()) | |
|
276 | 269 | static_cast<QGraphicsLineItem*>(item)->setPen(pen); |
|
277 | 270 | } |
|
278 | } | |
|
279 | 271 | |
|
280 | 272 | void ChartAxis::setLabelPadding(int padding) |
|
281 | 273 | { |
@@ -296,15 +288,12 void ChartAxis::handleDomainUpdated() | |||
|
296 | 288 | if(m_chartAxis->orientation()==Qt::Horizontal) { |
|
297 | 289 | min = domain->minX(); |
|
298 | 290 | max = domain->maxX(); |
|
299 | } | |
|
300 | else if (m_chartAxis->orientation()==Qt::Vertical) | |
|
301 | { | |
|
291 | } else if (m_chartAxis->orientation() == Qt::Vertical) { | |
|
302 | 292 | min = domain->minY(); |
|
303 | 293 | max = domain->maxY(); |
|
304 | 294 | } |
|
305 | 295 | |
|
306 | if (!qFuzzyIsNull(m_min - min) || !qFuzzyIsNull(m_max - max)) | |
|
307 | { | |
|
296 | if (!qFuzzyIsNull(m_min - min) || !qFuzzyIsNull(m_max - max)) { | |
|
308 | 297 | m_min = min; |
|
309 | 298 | m_max = max; |
|
310 | 299 | |
@@ -329,8 +318,8 void ChartAxis::handleDomainUpdated() | |||
|
329 | 318 | |
|
330 | 319 | void ChartAxis::handleAxisUpdated() |
|
331 | 320 | { |
|
332 |
if(isEmpty()) |
|
|
333 | ||
|
321 | if (isEmpty()) | |
|
322 | return; | |
|
334 | 323 | |
|
335 | 324 | bool visible = m_chartAxis->isVisible(); |
|
336 | 325 | |
@@ -372,7 +361,8 void ChartAxis::setGeometry(const QRectF &axis, const QRectF &grid) | |||
|
372 | 361 |
|
|
373 | 362 |
|
|
374 | 363 | |
|
375 |
|
|
|
364 | if (isEmpty()) | |
|
365 | return; | |
|
376 | 366 | |
|
377 | 367 |
|
|
378 | 368 |
|
@@ -384,21 +374,19 void ChartAxis::setGeometry(const QRectF &axis, const QRectF &grid) | |||
|
384 | 374 |
|
|
385 | 375 | size = grid.height(); |
|
386 | 376 | |
|
387 |
|
|
|
388 | { | |
|
377 | if (fn.boundingRect(m_titleText).width() > size) { | |
|
389 | 378 |
|
|
390 | 379 |
|
|
391 | 380 | string.remove(string.length() - 4, 1); |
|
392 | 381 |
|
|
393 |
|
|
|
394 | else | |
|
382 | } else { | |
|
395 | 383 | m_title->setText(m_titleText); |
|
384 | } | |
|
396 | 385 | |
|
397 | 386 |
|
|
398 | 387 |
|
|
399 | 388 |
|
|
400 | } | |
|
401 | else if(orientation()==Qt::Vertical) { | |
|
389 | } else if (orientation() == Qt::Vertical) { | |
|
402 | 390 |
|
|
403 | 391 |
|
|
404 | 392 |
|
@@ -442,27 +430,22 QSizeF ChartAxis::sizeHint(Qt::SizeHint which, const QSizeF& constraint) const | |||
|
442 | 430 | QFontMetrics fn(m_title->font()); |
|
443 | 431 | QSizeF sh; |
|
444 | 432 | |
|
445 |
if(m_titleText.isNull()) |
|
|
433 | if (m_titleText.isNull()) | |
|
434 | return sh; | |
|
446 | 435 | |
|
447 | 436 | switch(which) { |
|
448 | 437 |
|
|
449 |
if(orientation()==Qt::Horizontal) |
|
|
438 | if (orientation() == Qt::Horizontal) | |
|
450 | 439 |
sh = QSizeF(fn.boundingRect |
|
451 | } | |
|
452 | else if(orientation()==Qt::Vertical) { | |
|
440 | else if (orientation() == Qt::Vertical) | |
|
453 | 441 |
sh = QSizeF(fn.height(),fn.boundingRect |
|
454 | } | |
|
455 | ||
|
456 | 442 | break; |
|
457 | 443 |
|
|
458 | 444 |
|
|
459 |
if(orientation()==Qt::Horizontal) |
|
|
445 | if (orientation() == Qt::Horizontal) | |
|
460 | 446 | sh = QSizeF(fn.boundingRect(m_chartAxis->title()).width(),fn.height()); |
|
461 | } | |
|
462 | else if(orientation()==Qt::Vertical) { | |
|
447 | else if (orientation() == Qt::Vertical) | |
|
463 | 448 | sh = QSizeF(fn.height(),fn.boundingRect(m_chartAxis->title()).width()); |
|
464 | } | |
|
465 | ||
|
466 | 449 | break; |
|
467 | 450 |
|
|
468 | 451 | break; |
@@ -490,8 +473,7 QStringList ChartAxis::createValueLabels(int ticks) const | |||
|
490 | 473 | qreal value = m_min + (i * (m_max - m_min)/ (ticks-1)); |
|
491 | 474 | labels << QString::number(value,'f',n); |
|
492 | 475 | } |
|
493 | } | |
|
494 | else { | |
|
476 | } else { | |
|
495 | 477 | QByteArray array = format.toAscii(); |
|
496 | 478 | for (int i=0; i< ticks; i++) { |
|
497 | 479 | qreal value = m_min + (i * (m_max - m_min)/ (ticks-1)); |
@@ -513,7 +495,6 QStringList ChartAxis::createDateTimeLabels(const QString& format,int ticks) con | |||
|
513 | 495 | qreal value = m_min + (i * (m_max - m_min)/ (ticks-1)); |
|
514 | 496 | labels << QDateTime::fromMSecsSinceEpoch(value).toString(format); |
|
515 | 497 | } |
|
516 | ||
|
517 | 498 | return labels; |
|
518 | 499 | } |
|
519 | 500 |
|
1 | NO CONTENT: modified file |
@@ -28,8 +28,10 | |||
|
28 | 28 | |
|
29 | 29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | 30 | |
|
31 |
ChartDateTimeAxisX::ChartDateTimeAxisX(QDateTimeAxis *axis,ChartPresenter *presenter) |
|
|
32 | m_tickCount(0),m_axis(axis) | |
|
31 | ChartDateTimeAxisX::ChartDateTimeAxisX(QDateTimeAxis *axis, ChartPresenter *presenter) | |
|
32 | : HorizontalAxis(axis, presenter), | |
|
33 | m_tickCount(0), | |
|
34 | m_axis(axis) | |
|
33 | 35 | { |
|
34 | 36 | } |
|
35 | 37 | |
@@ -55,7 +57,8 QVector<qreal> ChartDateTimeAxisX::calculateLayout() const | |||
|
55 | 57 | void ChartDateTimeAxisX::updateGeometry() |
|
56 | 58 | { |
|
57 | 59 | const QVector<qreal>& layout = ChartAxis::layout(); |
|
58 |
if(layout.isEmpty()) |
|
|
60 | if (layout.isEmpty()) | |
|
61 | return; | |
|
59 | 62 | setLabels(createDateTimeLabels(m_axis->format(),layout.size())); |
|
60 | 63 | HorizontalAxis::updateGeometry(); |
|
61 | 64 | } |
@@ -80,15 +83,14 QSizeF ChartDateTimeAxisX::sizeHint(Qt::SizeHint which, const QSizeF& constraint | |||
|
80 | 83 |
|
|
81 | 84 | |
|
82 | 85 |
|
|
83 |
|
|
|
86 | if (layout.isEmpty()) | |
|
87 | break; | |
|
84 | 88 |
|
|
85 | 89 | |
|
86 | ||
|
87 | 90 |
|
|
88 | 91 |
|
|
89 | 92 | |
|
90 |
|
|
|
91 | { | |
|
93 | for (int i = 0; i < ticksList.size(); ++i) { | |
|
92 | 94 |
|
|
93 | 95 |
|
|
94 | 96 |
|
@@ -28,8 +28,10 | |||
|
28 | 28 | |
|
29 | 29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | 30 | |
|
31 |
ChartDateTimeAxisY::ChartDateTimeAxisY(QDateTimeAxis *axis,ChartPresenter *presenter) |
|
|
32 | m_tickCount(0),m_axis(axis) | |
|
31 | ChartDateTimeAxisY::ChartDateTimeAxisY(QDateTimeAxis *axis, ChartPresenter *presenter) | |
|
32 | : VerticalAxis(axis, presenter), | |
|
33 | m_tickCount(0), | |
|
34 | m_axis(axis) | |
|
33 | 35 | { |
|
34 | 36 | } |
|
35 | 37 | |
@@ -56,7 +58,8 QVector<qreal> ChartDateTimeAxisY::calculateLayout() const | |||
|
56 | 58 | void ChartDateTimeAxisY::updateGeometry() |
|
57 | 59 | { |
|
58 | 60 | const QVector<qreal> &layout = ChartAxis::layout(); |
|
59 |
if(layout.isEmpty()) |
|
|
61 | if (layout.isEmpty()) | |
|
62 | return; | |
|
60 | 63 | setLabels(createDateTimeLabels(m_axis->format(),layout.size())); |
|
61 | 64 | VerticalAxis::updateGeometry(); |
|
62 | 65 | } |
@@ -84,12 +87,10 QSizeF ChartDateTimeAxisY::sizeHint(Qt::SizeHint which, const QSizeF& constraint | |||
|
84 | 87 |
|
|
85 | 88 |
|
|
86 | 89 | |
|
87 | ||
|
88 | 90 |
|
|
89 | 91 |
|
|
90 | 92 | |
|
91 |
|
|
|
92 | { | |
|
93 | for (int i = 0; i < ticksList.size(); ++i) { | |
|
93 | 94 |
|
|
94 | 95 |
|
|
95 | 96 |
|
@@ -25,7 +25,8 | |||
|
25 | 25 | |
|
26 | 26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | 27 | |
|
28 |
HorizontalAxis::HorizontalAxis(QAbstractAxis *axis, ChartPresenter *presenter,bool intervalAxis) |
|
|
28 | HorizontalAxis::HorizontalAxis(QAbstractAxis *axis, ChartPresenter *presenter, bool intervalAxis) | |
|
29 | : ChartAxis(axis, presenter, intervalAxis) | |
|
29 | 30 | { |
|
30 | 31 | } |
|
31 | 32 | |
@@ -37,7 +38,8 void HorizontalAxis::updateGeometry() | |||
|
37 | 38 | { |
|
38 | 39 | const QVector<qreal>& layout = ChartAxis::layout(); |
|
39 | 40 | |
|
40 |
if(layout.isEmpty()) |
|
|
41 | if (layout.isEmpty()) | |
|
42 | return; | |
|
41 | 43 | |
|
42 | 44 | QStringList ticksList = labels(); |
|
43 | 45 | |
@@ -98,8 +100,7 void HorizontalAxis::updateGeometry() | |||
|
98 | 100 | labelItem->setVisible(false); |
|
99 | 101 | gridItem->setVisible(false); |
|
100 | 102 | tickItem->setVisible(false); |
|
101 | } | |
|
102 | else { | |
|
103 | } else { | |
|
103 | 104 | labelItem->setVisible(true); |
|
104 | 105 | gridItem->setVisible(true); |
|
105 | 106 | tickItem->setVisible(true); |
|
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 | /*! |
@@ -705,8 +706,8 void QAbstractAxis::setAlignment(Qt::Alignment alignment) | |||
|
705 | 706 | |
|
706 | 707 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
707 | 708 | |
|
708 |
QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis* |
|
|
709 | q_ptr(q), | |
|
709 | QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis *q) | |
|
710 | : q_ptr(q), | |
|
710 | 711 | m_orientation(Qt::Orientation(0)), |
|
711 | 712 | m_alignment(0), |
|
712 | 713 | m_dataset(0), |
|
1 | NO CONTENT: modified file |
@@ -30,7 +30,8 | |||
|
30 | 30 | |
|
31 | 31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | 32 | |
|
33 |
ChartValueAxisX::ChartValueAxisX(QValueAxis *axis,ChartPresenter *presenter) |
|
|
33 | ChartValueAxisX::ChartValueAxisX(QValueAxis *axis, ChartPresenter *presenter) | |
|
34 | : HorizontalAxis(axis, presenter), | |
|
34 | 35 | m_tickCount(0),m_axis(axis) |
|
35 | 36 | { |
|
36 | 37 | } |
@@ -58,7 +59,8 QVector<qreal> ChartValueAxisX::calculateLayout() const | |||
|
58 | 59 | void ChartValueAxisX::updateGeometry() |
|
59 | 60 | { |
|
60 | 61 | const QVector<qreal>& layout = ChartAxis::layout(); |
|
61 |
if(layout.isEmpty()) |
|
|
62 | if (layout.isEmpty()) | |
|
63 | return; | |
|
62 | 64 | setLabels(createValueLabels(layout.size())); |
|
63 | 65 | HorizontalAxis::updateGeometry(); |
|
64 | 66 | } |
@@ -96,8 +98,7 QSizeF ChartValueAxisX::sizeHint(Qt::SizeHint which, const QSizeF& constraint) c | |||
|
96 | 98 | break; |
|
97 | 99 | } |
|
98 | 100 | case Qt::PreferredSize:{ |
|
99 | for (int i = 0; i < ticksList.size(); ++i) | |
|
100 | { | |
|
101 | for (int i = 0; i < ticksList.size(); ++i) { | |
|
101 | 102 | width+=fn.averageCharWidth()*ticksList.at(i).count(); |
|
102 | 103 | } |
|
103 | 104 | height=fn.height()+labelPadding(); |
@@ -29,8 +29,10 | |||
|
29 | 29 | |
|
30 | 30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | 31 | |
|
32 |
ChartValueAxisY::ChartValueAxisY(QValueAxis *axis,ChartPresenter *presenter) |
|
|
33 | m_tickCount(0),m_axis(axis) | |
|
32 | ChartValueAxisY::ChartValueAxisY(QValueAxis *axis, ChartPresenter *presenter) | |
|
33 | : VerticalAxis(axis, presenter), | |
|
34 | m_tickCount(0), | |
|
35 | m_axis(axis) | |
|
34 | 36 | { |
|
35 | 37 | } |
|
36 | 38 | |
@@ -59,7 +61,8 QVector<qreal> ChartValueAxisY::calculateLayout() const | |||
|
59 | 61 | void ChartValueAxisY::updateGeometry() |
|
60 | 62 | { |
|
61 | 63 | const QVector<qreal> &layout = ChartAxis::layout(); |
|
62 |
if(layout.isEmpty()) |
|
|
64 | if (layout.isEmpty()) | |
|
65 | return; | |
|
63 | 66 | setLabels(createValueLabels(layout.size())); |
|
64 | 67 | VerticalAxis::updateGeometry(); |
|
65 | 68 | } |
@@ -95,10 +98,8 QSizeF ChartValueAxisY::sizeHint(Qt::SizeHint which, const QSizeF& constraint) c | |||
|
95 | 98 | sh = QSizeF(width,height); |
|
96 | 99 | break; |
|
97 | 100 | } |
|
98 | case Qt::PreferredSize: | |
|
99 | { | |
|
100 | for (int i = 0; i < ticksList.size(); ++i) | |
|
101 | { | |
|
101 | case Qt::PreferredSize: { | |
|
102 | for (int i = 0; i < ticksList.size(); ++i) { | |
|
102 | 103 | width=qMax(qreal(fn.averageCharWidth()*ticksList.at(i).count())+labelPadding(),width); |
|
103 | 104 | height+=fn.height(); |
|
104 | 105 | } |
|
1 | NO CONTENT: modified file |
@@ -24,7 +24,8 | |||
|
24 | 24 | |
|
25 | 25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | 26 | |
|
27 |
VerticalAxis::VerticalAxis(QAbstractAxis *axis, ChartPresenter *presenter, bool intervalAxis) |
|
|
27 | VerticalAxis::VerticalAxis(QAbstractAxis *axis, ChartPresenter *presenter, bool intervalAxis) | |
|
28 | : ChartAxis(axis, presenter, intervalAxis) | |
|
28 | 29 | { |
|
29 | 30 | |
|
30 | 31 | } |
@@ -38,7 +39,8 void VerticalAxis::updateGeometry() | |||
|
38 | 39 | { |
|
39 | 40 | const QVector<qreal> &layout = ChartAxis::layout(); |
|
40 | 41 | |
|
41 |
if(layout.isEmpty()) |
|
|
42 | if (layout.isEmpty()) | |
|
43 | return; | |
|
42 | 44 | |
|
43 | 45 | QStringList labelList = labels(); |
|
44 | 46 | |
@@ -75,14 +77,12 void VerticalAxis::updateGeometry() | |||
|
75 | 77 | |
|
76 | 78 | //label text |
|
77 | 79 | QString text = labelList.at(i); |
|
78 |
if (fn.boundingRect(text).width() > axisRect.right() - axisRect.left() - labelPadding() |
|
|
79 | { | |
|
80 | if (fn.boundingRect(text).width() > axisRect.right() - axisRect.left() - labelPadding()) { | |
|
80 | 81 | QString label = text + "..."; |
|
81 | 82 | while (fn.boundingRect(label).width() > axisRect.right() - axisRect.left() - labelPadding() && label.length() > 3) |
|
82 | 83 | label.remove(label.length() - 4, 1); |
|
83 | 84 | labelItem->setText(label); |
|
84 | } | |
|
85 | else { | |
|
85 | } else { | |
|
86 | 86 | labelItem->setText(text); |
|
87 | 87 | } |
|
88 | 88 |
const QRectF& |
@@ -93,8 +93,7 void VerticalAxis::updateGeometry() | |||
|
93 | 93 | if (alignment()==Qt::AlignLeft) { |
|
94 | 94 |
labelItem->setPos( |
|
95 | 95 |
tickItem->setLine( |
|
96 | } | |
|
97 | else if(alignment()==Qt::AlignRight) { | |
|
96 | } else if (alignment() == Qt::AlignRight) { | |
|
98 | 97 |
labelItem->setPos( |
|
99 | 98 |
tickItem->setLine( |
|
100 | 99 | } |
@@ -110,8 +109,7 void VerticalAxis::updateGeometry() | |||
|
110 | 109 | labelItem->setVisible(false); |
|
111 | 110 | gridItem->setVisible(false); |
|
112 | 111 | tickItem->setVisible(false); |
|
113 | } | |
|
114 | else { | |
|
112 | } else { | |
|
115 | 113 | labelItem->setVisible(true); |
|
116 | 114 | gridItem->setVisible(true); |
|
117 | 115 | height=labelItem->pos().y(); |
|
1 | NO CONTENT: modified file |
@@ -31,8 +31,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
31 | 31 | |
|
32 | 32 | static const qreal golden_ratio = 0.25; |
|
33 | 33 | |
|
34 |
ChartLayout::ChartLayout(ChartPresenter* |
|
|
35 | m_presenter(presenter), | |
|
34 | ChartLayout::ChartLayout(ChartPresenter *presenter) | |
|
35 | : m_presenter(presenter), | |
|
36 | 36 | m_margins(20,20,20,20), |
|
37 | 37 | m_minChartRect(0,0,200,200) |
|
38 | 38 | { |
@@ -59,13 +59,11 void ChartLayout::setGeometry(const QRectF& rect) | |||
|
59 | 59 | |
|
60 | 60 | contentGeometry = calculateContentGeometry(contentGeometry); |
|
61 | 61 | |
|
62 |
if (title && title->isVisible()) |
|
|
62 | if (title && title->isVisible()) | |
|
63 | 63 | contentGeometry = calculateTitleGeometry(contentGeometry,title); |
|
64 | } | |
|
65 | 64 | |
|
66 |
if (legend->isAttachedToChart() && legend->isVisible()) |
|
|
65 | if (legend->isAttachedToChart() && legend->isVisible()) | |
|
67 | 66 | contentGeometry = calculateLegendGeometry(contentGeometry,legend); |
|
68 | } | |
|
69 | 67 | |
|
70 | 68 | contentGeometry = calculateAxisGeometry(contentGeometry,axes); |
|
71 | 69 | |
@@ -90,7 +88,8 QRectF ChartLayout::calculateBackgroundGeometry(const QRectF& geometry,ChartBack | |||
|
90 | 88 | qreal left, top, right, bottom; |
|
91 | 89 | getContentsMargins(&left, &top, &right, &bottom); |
|
92 | 90 | QRectF backgroundGeometry = geometry.adjusted(left,top,-right,-bottom); |
|
93 | if(background) background->setRect(backgroundGeometry); | |
|
91 | if (background) | |
|
92 | background->setRect(backgroundGeometry); | |
|
94 | 93 | return backgroundGeometry; |
|
95 | 94 | } |
|
96 | 95 | |
@@ -104,7 +103,6 QRectF ChartLayout::calculateBackgroundMinimum(const QRectF& minimum) const | |||
|
104 | 103 | |
|
105 | 104 |
QRectF ChartLayout::calculateAxisGeometry(const QRectF& |
|
106 | 105 | { |
|
107 | ||
|
108 | 106 | QSizeF left; |
|
109 | 107 | QSizeF right; |
|
110 | 108 | QSizeF bottom; |
@@ -116,7 +114,8 QRectF ChartLayout::calculateAxisGeometry(const QRectF& geometry, const QList<Ch | |||
|
116 | 114 | |
|
117 | 115 |
foreach(ChartAxis* |
|
118 | 116 | |
|
119 |
if(!axis->isVisible()) |
|
|
117 | if (!axis->isVisible()) | |
|
118 | continue; | |
|
120 | 119 | |
|
121 | 120 | QSizeF size = axis->effectiveSizeHint(Qt::MinimumSize); |
|
122 | 121 | |
@@ -141,7 +140,6 QRectF ChartLayout::calculateAxisGeometry(const QRectF& geometry, const QList<Ch | |||
|
141 | 140 | bottom.setHeight(bottom.height() + size.height()); |
|
142 | 141 | bottomCount++; |
|
143 | 142 | break; |
|
144 | ||
|
145 | 143 | } |
|
146 | 144 | } |
|
147 | 145 | |
@@ -161,7 +159,8 QRectF ChartLayout::calculateAxisGeometry(const QRectF& geometry, const QList<Ch | |||
|
161 | 159 | |
|
162 | 160 | foreach(ChartAxis* axis , axes) { |
|
163 | 161 | |
|
164 |
if(!axis->isVisible()) |
|
|
162 | if (!axis->isVisible()) | |
|
163 | continue; | |
|
165 | 164 | |
|
166 | 165 | QSizeF size = axis->effectiveSizeHint(Qt::MinimumSize); |
|
167 | 166 | |
@@ -203,7 +202,8 QRectF ChartLayout::calculateAxisMinimum(const QRectF& minimum, const QList<Char | |||
|
203 | 202 | |
|
204 | 203 | QSizeF size = axis->effectiveSizeHint(Qt::MinimumSize); |
|
205 | 204 | |
|
206 |
if(!axis->isVisible()) |
|
|
205 | if (!axis->isVisible()) | |
|
206 | continue; | |
|
207 | 207 | |
|
208 | 208 | switch(axis->alignment()) { |
|
209 | 209 |
|
@@ -272,12 +272,8 QRectF ChartLayout::calculateLegendGeometry(const QRectF& geometry,QLegend* lege | |||
|
272 | 272 |
QRectF ChartLayout::calculateChartsGeometry(const QRectF& |
|
273 | 273 | { |
|
274 | 274 | Q_ASSERT(geometry.isValid()); |
|
275 | ||
|
276 | 275 |
foreach(ChartElement* |
|
277 | { | |
|
278 | 276 | chart->handleGeometryChanged(geometry); |
|
279 | } | |
|
280 | ||
|
281 | 277 | return geometry; |
|
282 | 278 | } |
|
283 | 279 | |
@@ -315,7 +311,7 QSizeF ChartLayout::sizeHint ( Qt::SizeHint which, const QSizeF & constraint) co | |||
|
315 | 311 | minimumRect = calculateLegendMinimum(minimumRect,legend); |
|
316 | 312 | minimumRect = calculateAxisMinimum(minimumRect,axes); |
|
317 | 313 | return minimumRect.united(m_minChartRect).size().toSize(); |
|
318 |
} |
|
|
314 | } | |
|
319 | 315 |
|
|
320 | 316 | } |
|
321 | 317 |
|
1 | NO CONTENT: modified file |
@@ -35,7 +35,8 | |||
|
35 | 35 | |
|
36 | 36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | 37 | |
|
38 |
ChartPresenter::ChartPresenter(QChart* |
|
|
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), |
@@ -58,9 +59,8 void ChartPresenter::handleAxisAdded(QAbstractAxis* axis,Domain* domain) | |||
|
58 | 59 |
ChartAxis* |
|
59 | 60 | item->setDomain(domain); |
|
60 | 61 | |
|
61 |
if(m_options.testFlag(QChart::GridAxisAnimations)) |
|
|
62 | if (m_options.testFlag(QChart::GridAxisAnimations)) | |
|
62 | 63 | item->setAnimation(new AxisAnimation(item)); |
|
63 | } | |
|
64 | 64 | |
|
65 | 65 | QObject::connect(domain,SIGNAL(updated()),item,SLOT(handleDomainUpdated())); |
|
66 | 66 | QObject::connect(axis,SIGNAL(visibleChanged(bool)),this,SLOT(handleAxisVisibleChanged(bool))); |
@@ -149,19 +149,18 void ChartPresenter::handleAxisVisibleChanged(bool visible) | |||
|
149 | 149 | |
|
150 | 150 | while (i.hasNext()) { |
|
151 | 151 | i.next(); |
|
152 |
if(i.key()==axis) |
|
|
152 | if (i.key() == axis) | |
|
153 | 153 | continue; |
|
154 | } | |
|
155 | if(i.key()->orientation()==axis->orientation()) { | |
|
154 | if (i.key()->orientation() == axis->orientation()) | |
|
156 | 155 | i.key()->setVisible(false); |
|
157 | 156 | } |
|
158 | 157 |
|
|
159 | 158 | } |
|
160 | } | |
|
161 | 159 | |
|
162 | 160 | void ChartPresenter::setTheme(QChart::ChartTheme theme,bool force) |
|
163 | 161 | { |
|
164 |
if(m_chartTheme && m_chartTheme->id() == theme) |
|
|
162 | if (m_chartTheme && m_chartTheme->id() == theme) | |
|
163 | return; | |
|
165 | 164 | delete m_chartTheme; |
|
166 | 165 | m_chartTheme = ChartTheme::createTheme(theme); |
|
167 | 166 | m_chartTheme->setForced(force); |
@@ -288,16 +287,16 void ChartPresenter::createTitleItem() | |||
|
288 | 287 | void ChartPresenter::handleAnimationFinished() |
|
289 | 288 | { |
|
290 | 289 | m_animations.removeAll(qobject_cast<ChartAnimation*>(sender())); |
|
291 |
if(m_animations.empty()) |
|
|
290 | if (m_animations.empty()) | |
|
291 | emit animationsFinished(); | |
|
292 | 292 | } |
|
293 | 293 | |
|
294 | 294 |
void ChartPresenter::startAnimation(ChartAnimation* |
|
295 | 295 | { |
|
296 | 296 | if (animation->state() != QAbstractAnimation::Stopped) animation->stop(); |
|
297 | 297 | QObject::connect(animation, SIGNAL(finished()),this,SLOT(handleAnimationFinished()),Qt::UniqueConnection); |
|
298 |
if(!m_animations.isEmpty()) |
|
|
298 | if (!m_animations.isEmpty()) | |
|
299 | 299 | m_animations.append(animation); |
|
300 | } | |
|
301 | 300 | QTimer::singleShot(0, animation, SLOT(start())); |
|
302 | 301 | } |
|
303 | 302 | |
@@ -310,7 +309,8 void ChartPresenter::setBackgroundBrush(const QBrush& brush) | |||
|
310 | 309 | |
|
311 | 310 | QBrush ChartPresenter::backgroundBrush() const |
|
312 | 311 | { |
|
313 |
if (!m_background) |
|
|
312 | if (!m_background) | |
|
313 | return QBrush(); | |
|
314 | 314 | return m_background->brush(); |
|
315 | 315 | } |
|
316 | 316 | |
@@ -323,7 +323,8 void ChartPresenter::setBackgroundPen(const QPen& pen) | |||
|
323 | 323 | |
|
324 | 324 | QPen ChartPresenter::backgroundPen() const |
|
325 | 325 | { |
|
326 |
if (!m_background) |
|
|
326 | if (!m_background) | |
|
327 | return QPen(); | |
|
327 | 328 | return m_background->pen(); |
|
328 | 329 | } |
|
329 | 330 | |
@@ -336,7 +337,8 void ChartPresenter::setTitle(const QString& title) | |||
|
336 | 337 | |
|
337 | 338 | QString ChartPresenter::title() const |
|
338 | 339 | { |
|
339 |
if (!m_title) |
|
|
340 | if (!m_title) | |
|
341 | return QString(); | |
|
340 | 342 | return m_title->text(); |
|
341 | 343 | } |
|
342 | 344 | |
@@ -349,7 +351,8 void ChartPresenter::setTitleFont(const QFont& font) | |||
|
349 | 351 | |
|
350 | 352 | QFont ChartPresenter::titleFont() const |
|
351 | 353 | { |
|
352 |
if (!m_title) |
|
|
354 | if (!m_title) | |
|
355 | return QFont(); | |
|
353 | 356 | return m_title->font(); |
|
354 | 357 | } |
|
355 | 358 | |
@@ -362,7 +365,8 void ChartPresenter::setTitleBrush(const QBrush &brush) | |||
|
362 | 365 | |
|
363 | 366 | QBrush ChartPresenter::titleBrush() const |
|
364 | 367 | { |
|
365 |
if (!m_title) |
|
|
368 | if (!m_title) | |
|
369 | return QBrush(); | |
|
366 | 370 | return m_title->brush(); |
|
367 | 371 | } |
|
368 | 372 | |
@@ -375,7 +379,8 void ChartPresenter::setBackgroundVisible(bool visible) | |||
|
375 | 379 | |
|
376 | 380 | bool ChartPresenter::isBackgroundVisible() const |
|
377 | 381 | { |
|
378 |
if (!m_background) |
|
|
382 | if (!m_background) | |
|
383 | return false; | |
|
379 | 384 | return m_background->isVisible(); |
|
380 | 385 | } |
|
381 | 386 | |
@@ -387,7 +392,8 void ChartPresenter::setBackgroundDropShadowEnabled(bool enabled) | |||
|
387 | 392 | |
|
388 | 393 | bool ChartPresenter::isBackgroundDropShadowEnabled() const |
|
389 | 394 | { |
|
390 |
if (!m_background) |
|
|
395 | if (!m_background) | |
|
396 | return false; | |
|
391 | 397 | return m_background->isDropShadowEnabled(); |
|
392 | 398 | } |
|
393 | 399 |
|
1 | NO CONTENT: modified file |
|
1 | NO CONTENT: modified file |
|
1 | NO CONTENT: modified file |
|
1 | NO CONTENT: modified file |
@@ -26,8 +26,8 | |||
|
26 | 26 | |
|
27 | 27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | 28 | |
|
29 |
QPieModelMapper::QPieModelMapper(QObject *parent) |
|
|
30 | QObject(parent), | |
|
29 | QPieModelMapper::QPieModelMapper(QObject *parent) | |
|
30 | : QObject(parent), | |
|
31 | 31 | d_ptr(new QPieModelMapperPrivate(this)) |
|
32 | 32 | { |
|
33 | 33 | } |
|
1 | NO CONTENT: modified file |
@@ -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); |
@@ -265,7 +266,8 void QChart::zoomIn() | |||
|
265 | 266 | */ |
|
266 | 267 |
void QChart::zoomIn(const QRectF& |
|
267 | 268 | { |
|
268 |
if (!rect.isValid()) |
|
|
269 | if (!rect.isValid()) | |
|
270 | return; | |
|
269 | 271 | d_ptr->m_presenter->zoomIn(rect); |
|
270 | 272 | } |
|
271 | 273 | |
@@ -457,7 +459,8 QList<QAbstractSeries*> QChart::series() const | |||
|
457 | 459 | */ |
|
458 | 460 |
void QChart::setAxisX(QAbstractAxis* |
|
459 | 461 | { |
|
460 |
if(axis->alignment()==Qt::AlignLeft || axis->alignment()==Qt::AlignRight) |
|
|
462 | if (axis->alignment() == Qt::AlignLeft || axis->alignment() == Qt::AlignRight) | |
|
463 | return; | |
|
461 | 464 | d_ptr->m_dataset->setAxis(series,axis,Qt::Horizontal); |
|
462 | 465 | } |
|
463 | 466 | |
@@ -468,7 +471,8 void QChart::setAxisX(QAbstractAxis* axis , QAbstractSeries *series) | |||
|
468 | 471 | */ |
|
469 | 472 |
void QChart::setAxisY( |
|
470 | 473 | { |
|
471 |
if(axis->alignment()==Qt::AlignTop || axis->alignment()==Qt::AlignBottom) |
|
|
474 | if (axis->alignment() == Qt::AlignTop || axis->alignment() == Qt::AlignBottom) | |
|
475 | return; | |
|
472 | 476 | d_ptr->m_dataset->setAxis(series,axis,Qt::Vertical); |
|
473 | 477 | } |
|
474 | 478 |
|
1 | NO CONTENT: modified file |
@@ -29,8 +29,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
29 | 29 | /*! |
|
30 | 30 | Constructs a mapper object which is a child of \a parent. |
|
31 | 31 | */ |
|
32 |
QXYModelMapper::QXYModelMapper(QObject *parent) |
|
|
33 | QObject(parent), | |
|
32 | QXYModelMapper::QXYModelMapper(QObject *parent) | |
|
33 | : QObject(parent), | |
|
34 | 34 | d_ptr(new QXYModelMapperPrivate(this)) |
|
35 | 35 | { |
|
36 | 36 | } |
General Comments 0
You need to be logged in to leave comments.
Login now