##// END OF EJS Templates
QIntervalsAxis renamed to QCategoryAxis
Marek Rosa -
r1816:57c485eadcaf
parent child
Show More
@@ -22,7 +22,7
22 22 #include <QMainWindow>
23 23 #include <QChartView>
24 24 #include <QLineSeries>
25 #include <QIntervalsAxis>
25 #include <QCategoryAxis>
26 26
27 27 QTCOMMERCIALCHART_USE_NAMESPACE
28 28
@@ -62,8 +62,8 int main(int argc, char *argv[])
62 62 //![2]
63 63
64 64 //![3]
65 QIntervalsAxis* axisX = new QIntervalsAxis();
66 QIntervalsAxis* axisY = new QIntervalsAxis();
65 QCategoryAxis* axisX = new QCategoryAxis();
66 QCategoryAxis* axisY = new QCategoryAxis();
67 67
68 68 // Customize axis label font
69 69 QFont labelsFont;
@@ -40,7 +40,7 ChartIntervalAxisX::~ChartIntervalAxisX()
40 40
41 41 QVector<qreal> ChartIntervalAxisX::calculateLayout() const
42 42 {
43 QIntervalsAxis *axis = qobject_cast<QIntervalsAxis *>(m_chartAxis);
43 QCategoryAxis *axis = qobject_cast<QCategoryAxis *>(m_chartAxis);
44 44 int tickCount = axis->intervalsLabels().count() + 1;
45 45 QVector<qreal> points;
46 46
@@ -71,7 +71,7 void ChartIntervalAxisX::updateGeometry()
71 71
72 72 if(layout.isEmpty()) return;
73 73
74 QIntervalsAxis *intervalAxis = qobject_cast<QIntervalsAxis *>(m_chartAxis);
74 QCategoryAxis *intervalAxis = qobject_cast<QCategoryAxis *>(m_chartAxis);
75 75
76 76 QStringList ticksList = intervalAxis->intervalsLabels();
77 77
@@ -41,7 +41,7 ChartIntervalAxisY::~ChartIntervalAxisY()
41 41
42 42 QVector<qreal> ChartIntervalAxisY::calculateLayout() const
43 43 {
44 QIntervalsAxis *axis = qobject_cast<QIntervalsAxis *>(m_chartAxis);
44 QCategoryAxis *axis = qobject_cast<QCategoryAxis *>(m_chartAxis);
45 45 int tickCount = axis->intervalsLabels().count() + 1;
46 46 QVector<qreal> points;
47 47
@@ -71,7 +71,7 void ChartIntervalAxisY::updateGeometry()
71 71
72 72 if(layout.isEmpty()) return;
73 73
74 QIntervalsAxis *intervalAxis = qobject_cast<QIntervalsAxis *>(m_chartAxis);
74 QCategoryAxis *intervalAxis = qobject_cast<QCategoryAxis *>(m_chartAxis);
75 75
76 76 QStringList ticksList = intervalAxis->intervalsLabels();
77 77
@@ -27,13 +27,13
27 27
28 28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 29 /*!
30 \class QIntervalsAxis
31 \brief The QIntervalsAxis class is used for manipulating chart's axis.
30 \class QCategoryAxis
31 \brief The QCategoryAxis class is used for manipulating chart's axis.
32 32 \mainclass
33 33 */
34 34
35 35 /*!
36 \qmlclass Axis QIntervalsAxis
36 \qmlclass Axis QCategoryAxis
37 37 \brief The Axis element is used for manipulating chart's axes.
38 38
39 39 Axis can be setup to show axis line with tick marks, grid lines and shades.
@@ -47,15 +47,15 QTCOMMERCIALCHART_BEGIN_NAMESPACE
47 47 /*!
48 48 Constructs an axis object which is a child of \a parent.
49 49 */
50 QIntervalsAxis::QIntervalsAxis(QObject *parent):
51 QValueAxis(*new QIntervalsAxisPrivate(this),parent)
50 QCategoryAxis::QCategoryAxis(QObject *parent):
51 QValueAxis(*new QCategoryAxisPrivate(this),parent)
52 52 {
53 53 }
54 54
55 55 /*!
56 56 Destroys the object
57 57 */
58 QIntervalsAxis::~QIntervalsAxis()
58 QCategoryAxis::~QCategoryAxis()
59 59 {
60 60 // Q_D(QValueAxis);
61 61 // if(d->m_dataset) {
@@ -66,7 +66,7 QIntervalsAxis::~QIntervalsAxis()
66 66 /*!
67 67 \internal
68 68 */
69 QIntervalsAxis::QIntervalsAxis(QIntervalsAxisPrivate &d,QObject *parent):QValueAxis(d,parent)
69 QCategoryAxis::QCategoryAxis(QCategoryAxisPrivate &d,QObject *parent):QValueAxis(d,parent)
70 70 {
71 71
72 72 }
@@ -78,9 +78,9 QIntervalsAxis::QIntervalsAxis(QIntervalsAxisPrivate &d,QObject *parent):QValueA
78 78 It has to be greater than the high end limit of the previous interval.
79 79 Otherwise the method returns without adding a new interval.
80 80 */
81 void QIntervalsAxis::append(const QString& intervalLabel, qreal intervalEnd)
81 void QCategoryAxis::append(const QString& intervalLabel, qreal intervalEnd)
82 82 {
83 Q_D(QIntervalsAxis);
83 Q_D(QCategoryAxis);
84 84
85 85 if (!d->m_intervals.contains(intervalLabel))
86 86 {
@@ -99,9 +99,9 void QIntervalsAxis::append(const QString& intervalLabel, qreal intervalEnd)
99 99 /*!
100 100 Sets to \a min the low end limit of the first interval on the axis.
101 101 */
102 void QIntervalsAxis::setFisrtIntervalMinimum(qreal min)
102 void QCategoryAxis::setFisrtIntervalMinimum(qreal min)
103 103 {
104 Q_D(QIntervalsAxis);
104 Q_D(QCategoryAxis);
105 105 if(d->m_intervals.isEmpty()){
106 106 d->m_categoryMinimum = min;
107 107 }else{
@@ -113,27 +113,27 void QIntervalsAxis::setFisrtIntervalMinimum(qreal min)
113 113 /*!
114 114 Returns the low end limit of the interval specified by an \a intervalLabel
115 115 */
116 qreal QIntervalsAxis::intervalMin(const QString& intervalLabel) const
116 qreal QCategoryAxis::intervalMin(const QString& intervalLabel) const
117 117 {
118 Q_D(const QIntervalsAxis);
118 Q_D(const QCategoryAxis);
119 119 return d->m_intervalsMap.value(intervalLabel).first;
120 120 }
121 121
122 122 /*!
123 123 Returns the high end limit of the interval specified by an \a intervalLabel
124 124 */
125 qreal QIntervalsAxis::intervalMax(const QString& intervalLabel) const
125 qreal QCategoryAxis::intervalMax(const QString& intervalLabel) const
126 126 {
127 Q_D(const QIntervalsAxis);
127 Q_D(const QCategoryAxis);
128 128 return d->m_intervalsMap.value(intervalLabel).second;
129 129 }
130 130
131 131 /*!
132 132 Removes an interval specified by the \a intervalLabel from the axis
133 133 */
134 void QIntervalsAxis::remove(const QString &intervalLabel)
134 void QCategoryAxis::remove(const QString &intervalLabel)
135 135 {
136 Q_D(QIntervalsAxis);
136 Q_D(QCategoryAxis);
137 137 int labelIndex = d->m_intervals.indexOf(intervalLabel);
138 138
139 139 // check if such label exists
@@ -163,9 +163,9 void QIntervalsAxis::remove(const QString &intervalLabel)
163 163 Replaces \a oldLabel of an existing interval with a \a newLabel
164 164 If the old label does not exist the method returns without making any changes.
165 165 */
166 void QIntervalsAxis::replaceLabel(const QString& oldLabel, const QString& newLabel)
166 void QCategoryAxis::replaceLabel(const QString& oldLabel, const QString& newLabel)
167 167 {
168 Q_D(QIntervalsAxis);
168 Q_D(QCategoryAxis);
169 169 int labelIndex = d->m_intervals.indexOf(oldLabel);
170 170
171 171 // check if such label exists
@@ -182,49 +182,49 void QIntervalsAxis::replaceLabel(const QString& oldLabel, const QString& newLab
182 182 /*!
183 183 Returns the list of the intervals labels
184 184 */
185 QStringList QIntervalsAxis::intervalsLabels()
185 QStringList QCategoryAxis::intervalsLabels()
186 186 {
187 Q_D(QIntervalsAxis);
187 Q_D(QCategoryAxis);
188 188 return d->m_intervals;
189 189 }
190 190
191 191 /*!
192 192 Returns number of intervals.
193 193 */
194 int QIntervalsAxis::count() const
194 int QCategoryAxis::count() const
195 195 {
196 Q_D(const QIntervalsAxis);
196 Q_D(const QCategoryAxis);
197 197 return d->m_intervals.count();
198 198 }
199 199
200 200 /*!
201 201 Returns the type of the axis
202 202 */
203 QAbstractAxis::AxisType QIntervalsAxis::type() const
203 QAbstractAxis::AxisType QCategoryAxis::type() const
204 204 {
205 205 return QAbstractAxis::AxisTypeIntervals;
206 206 }
207 207
208 208 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
209 209
210 QIntervalsAxisPrivate::QIntervalsAxisPrivate(QIntervalsAxis* q):
210 QCategoryAxisPrivate::QCategoryAxisPrivate(QCategoryAxis* q):
211 211 QValueAxisPrivate(q),
212 212 m_categoryMinimum(0)
213 213 {
214 214
215 215 }
216 216
217 QIntervalsAxisPrivate::~QIntervalsAxisPrivate()
217 QCategoryAxisPrivate::~QCategoryAxisPrivate()
218 218 {
219 219
220 220 }
221 221
222 int QIntervalsAxisPrivate::ticksCount() const
222 int QCategoryAxisPrivate::ticksCount() const
223 223 {
224 224 return m_intervals.count() + 1;
225 225 }
226 226
227 void QIntervalsAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count)
227 void QCategoryAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count)
228 228 {
229 229 Q_UNUSED(count);
230 230 Q_UNUSED(min);
@@ -233,9 +233,9 void QIntervalsAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int coun
233 233 //m_max = max;
234 234 }
235 235
236 ChartAxis* QIntervalsAxisPrivate::createGraphics(ChartPresenter* presenter)
236 ChartAxis* QCategoryAxisPrivate::createGraphics(ChartPresenter* presenter)
237 237 {
238 Q_Q(QIntervalsAxis);
238 Q_Q(QCategoryAxis);
239 239 if(m_orientation == Qt::Vertical){
240 240 return new ChartIntervalAxisY(q,presenter);
241 241 }else{
@@ -26,18 +26,18
26 26
27 27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 28
29 class QIntervalsAxisPrivate;
29 class QCategoryAxisPrivate;
30 30
31 class QTCOMMERCIALCHART_EXPORT QIntervalsAxis : public QValueAxis
31 class QTCOMMERCIALCHART_EXPORT QCategoryAxis : public QValueAxis
32 32 {
33 33 Q_OBJECT
34 34
35 35 public:
36 explicit QIntervalsAxis(QObject *parent = 0);
37 ~QIntervalsAxis();
36 explicit QCategoryAxis(QObject *parent = 0);
37 ~QCategoryAxis();
38 38
39 39 protected:
40 QIntervalsAxis(QIntervalsAxisPrivate &d,QObject *parent = 0);
40 QCategoryAxis(QCategoryAxisPrivate &d,QObject *parent = 0);
41 41
42 42 public:
43 43 AxisType type() const;
@@ -56,8 +56,8 public:
56 56
57 57
58 58 private:
59 Q_DECLARE_PRIVATE(QIntervalsAxis)
60 Q_DISABLE_COPY(QIntervalsAxis)
59 Q_DECLARE_PRIVATE(QCategoryAxis)
60 Q_DISABLE_COPY(QCategoryAxis)
61 61 };
62 62
63 63 QTCOMMERCIALCHART_END_NAMESPACE
@@ -27,8 +27,8
27 27 //
28 28 // We mean it.
29 29
30 #ifndef QIntervalsAxis_P_H
31 #define QIntervalsAxis_P_H
30 #ifndef QCATEGORYAXIS_P_H
31 #define QCATEGORYAXIS_P_H
32 32
33 33 #include "qintervalsaxis.h"
34 34 #include "qvalueaxis_p.h"
@@ -37,13 +37,13 QTCOMMERCIALCHART_BEGIN_NAMESPACE
37 37
38 38 typedef QPair<qreal, qreal> Range;
39 39
40 class QIntervalsAxisPrivate : public QValueAxisPrivate
40 class QCategoryAxisPrivate : public QValueAxisPrivate
41 41 {
42 42 Q_OBJECT
43 43
44 44 public:
45 QIntervalsAxisPrivate(QIntervalsAxis *q);
46 ~QIntervalsAxisPrivate();
45 QCategoryAxisPrivate(QCategoryAxis *q);
46 ~QCategoryAxisPrivate();
47 47
48 48
49 49 public:
@@ -62,9 +62,9 private:
62 62 qreal m_categoryMinimum;
63 63
64 64 private:
65 Q_DECLARE_PUBLIC(QIntervalsAxis)
65 Q_DECLARE_PUBLIC(QCategoryAxis)
66 66 };
67 67
68 68 QTCOMMERCIALCHART_END_NAMESPACE
69 69
70 #endif // QCATEGORIESAXIS_P_H
70 #endif // QCATEGORYAXIS_P_H
@@ -185,7 +185,7 QAbstractAxis* ChartDataSet::createAxis(QAbstractAxis::AxisType type, Qt::Orient
185 185 axis = new QBarCategoryAxis(this);
186 186 break;
187 187 case QAbstractAxis::AxisTypeIntervals:
188 axis = new QIntervalsAxis(this);
188 axis = new QCategoryAxis(this);
189 189 break;
190 190 case QAbstractAxis::AxisTypeDateTime:
191 191 axis = new QDateTimeAxis(this);
@@ -22,7 +22,7
22 22 #include "qintervalsaxis.h"
23 23 #include <qlineseries.h>
24 24
25 class tst_QIntervalsAxis: public tst_QAbstractAxis
25 class tst_QCategoryAxis: public tst_QAbstractAxis
26 26 {
27 27 Q_OBJECT
28 28
@@ -59,21 +59,21 private slots:
59 59 void interval();
60 60
61 61 private:
62 QIntervalsAxis* m_intervalsaxis;
62 QCategoryAxis* m_intervalsaxis;
63 63 QLineSeries* m_series;
64 64 };
65 65
66 void tst_QIntervalsAxis::initTestCase()
66 void tst_QCategoryAxis::initTestCase()
67 67 {
68 68 }
69 69
70 void tst_QIntervalsAxis::cleanupTestCase()
70 void tst_QCategoryAxis::cleanupTestCase()
71 71 {
72 72 }
73 73
74 void tst_QIntervalsAxis::init()
74 void tst_QCategoryAxis::init()
75 75 {
76 m_intervalsaxis = new QIntervalsAxis();
76 m_intervalsaxis = new QCategoryAxis();
77 77 m_series = new QLineSeries();
78 78 *m_series << QPointF(-100, -100) << QPointF(0, 0) << QPointF(100, 100);
79 79 tst_QAbstractAxis::init(m_intervalsaxis, m_series);
@@ -81,7 +81,7 void tst_QIntervalsAxis::init()
81 81 m_chart->createDefaultAxes();
82 82 }
83 83
84 void tst_QIntervalsAxis::cleanup()
84 void tst_QCategoryAxis::cleanup()
85 85 {
86 86 delete m_series;
87 87 delete m_intervalsaxis;
@@ -90,11 +90,11 void tst_QIntervalsAxis::cleanup()
90 90 tst_QAbstractAxis::cleanup();
91 91 }
92 92
93 void tst_QIntervalsAxis::qintervalsaxis_data()
93 void tst_QCategoryAxis::qintervalsaxis_data()
94 94 {
95 95 }
96 96
97 void tst_QIntervalsAxis::qintervalsaxis()
97 void tst_QCategoryAxis::qintervalsaxis()
98 98 {
99 99 qabstractaxis();
100 100
@@ -110,7 +110,7 void tst_QIntervalsAxis::qintervalsaxis()
110 110 QVERIFY(!qFuzzyIsNull(m_intervalsaxis->min()));
111 111 }
112 112
113 void tst_QIntervalsAxis::max_raw_data()
113 void tst_QCategoryAxis::max_raw_data()
114 114 {
115 115 QTest::addColumn<qreal>("max");
116 116 QTest::newRow("1.0") << 1.0;
@@ -118,7 +118,7 void tst_QIntervalsAxis::max_raw_data()
118 118 QTest::newRow("101.0") << 101.0;
119 119 }
120 120
121 void tst_QIntervalsAxis::max_raw()
121 void tst_QCategoryAxis::max_raw()
122 122 {
123 123 QFETCH(qreal, max);
124 124
@@ -134,12 +134,12 void tst_QIntervalsAxis::max_raw()
134 134 QCOMPARE(spy2.count(), 1);
135 135 }
136 136
137 void tst_QIntervalsAxis::max_data()
137 void tst_QCategoryAxis::max_data()
138 138 {
139 139 max_raw_data();
140 140 }
141 141
142 void tst_QIntervalsAxis::max()
142 void tst_QCategoryAxis::max()
143 143 {
144 144 m_chart->setAxisX(m_intervalsaxis, m_series);
145 145 m_view->show();
@@ -147,18 +147,18 void tst_QIntervalsAxis::max()
147 147 max_raw();
148 148 }
149 149
150 void tst_QIntervalsAxis::max_animation_data()
150 void tst_QCategoryAxis::max_animation_data()
151 151 {
152 152 max_data();
153 153 }
154 154
155 void tst_QIntervalsAxis::max_animation()
155 void tst_QCategoryAxis::max_animation()
156 156 {
157 157 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
158 158 max();
159 159 }
160 160
161 void tst_QIntervalsAxis::min_raw_data()
161 void tst_QCategoryAxis::min_raw_data()
162 162 {
163 163 QTest::addColumn<qreal>("min");
164 164 QTest::newRow("-1.0") << -1.0;
@@ -166,7 +166,7 void tst_QIntervalsAxis::min_raw_data()
166 166 QTest::newRow("-101.0") << -101.0;
167 167 }
168 168
169 void tst_QIntervalsAxis::min_raw()
169 void tst_QCategoryAxis::min_raw()
170 170 {
171 171 QFETCH(qreal, min);
172 172
@@ -182,12 +182,12 void tst_QIntervalsAxis::min_raw()
182 182 QCOMPARE(spy2.count(), 1);
183 183 }
184 184
185 void tst_QIntervalsAxis::min_data()
185 void tst_QCategoryAxis::min_data()
186 186 {
187 187 min_raw_data();
188 188 }
189 189
190 void tst_QIntervalsAxis::min()
190 void tst_QCategoryAxis::min()
191 191 {
192 192 m_chart->setAxisX(m_intervalsaxis, m_series);
193 193 m_view->show();
@@ -195,18 +195,18 void tst_QIntervalsAxis::min()
195 195 min_raw();
196 196 }
197 197
198 void tst_QIntervalsAxis::min_animation_data()
198 void tst_QCategoryAxis::min_animation_data()
199 199 {
200 200 min_data();
201 201 }
202 202
203 void tst_QIntervalsAxis::min_animation()
203 void tst_QCategoryAxis::min_animation()
204 204 {
205 205 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
206 206 min();
207 207 }
208 208
209 void tst_QIntervalsAxis::range_raw_data()
209 void tst_QCategoryAxis::range_raw_data()
210 210 {
211 211 QTest::addColumn<qreal>("min");
212 212 QTest::addColumn<qreal>("max");
@@ -215,7 +215,7 void tst_QIntervalsAxis::range_raw_data()
215 215 QTest::newRow("101.0") << 40.0 << 60.0;
216 216 }
217 217
218 void tst_QIntervalsAxis::range_raw()
218 void tst_QCategoryAxis::range_raw()
219 219 {
220 220 QFETCH(qreal, min);
221 221 QFETCH(qreal, max);
@@ -233,12 +233,12 void tst_QIntervalsAxis::range_raw()
233 233 QCOMPARE(spy2.count(), 1);
234 234 }
235 235
236 void tst_QIntervalsAxis::range_data()
236 void tst_QCategoryAxis::range_data()
237 237 {
238 238 range_raw_data();
239 239 }
240 240
241 void tst_QIntervalsAxis::range()
241 void tst_QCategoryAxis::range()
242 242 {
243 243 m_chart->setAxisX(m_intervalsaxis, m_series);
244 244 m_view->show();
@@ -246,23 +246,23 void tst_QIntervalsAxis::range()
246 246 range_raw();
247 247 }
248 248
249 void tst_QIntervalsAxis::range_animation_data()
249 void tst_QCategoryAxis::range_animation_data()
250 250 {
251 251 range_data();
252 252 }
253 253
254 void tst_QIntervalsAxis::range_animation()
254 void tst_QCategoryAxis::range_animation()
255 255 {
256 256 m_chart->setAnimationOptions(QChart::GridAxisAnimations);
257 257 range();
258 258 }
259 259
260 void tst_QIntervalsAxis::interval_data()
260 void tst_QCategoryAxis::interval_data()
261 261 {
262 262 //
263 263 }
264 264
265 void tst_QIntervalsAxis::interval()
265 void tst_QCategoryAxis::interval()
266 266 {
267 267 // append one correct interval
268 268 m_intervalsaxis->append("first", (qreal)45);
@@ -299,6 +299,6 void tst_QIntervalsAxis::interval()
299 299 QCOMPARE(m_intervalsaxis->intervalMax("replaced"), (qreal)75);
300 300 }
301 301
302 QTEST_MAIN(tst_QIntervalsAxis)
302 QTEST_MAIN(tst_QCategoryAxis)
303 303 #include "tst_qintervalsaxis.moc"
304 304
General Comments 0
You need to be logged in to leave comments. Login now