|
@@
-1,334
+1,334
|
|
1
|
/****************************************************************************
|
|
1
|
/****************************************************************************
|
|
2
|
**
|
|
2
|
**
|
|
3
|
** Copyright (C) 2012 Digia Plc
|
|
3
|
** Copyright (C) 2012 Digia Plc
|
|
4
|
** All rights reserved.
|
|
4
|
** All rights reserved.
|
|
5
|
** For any questions to Digia, please use contact form at http://qt.digia.com
|
|
5
|
** For any questions to Digia, please use contact form at http://qt.digia.com
|
|
6
|
**
|
|
6
|
**
|
|
7
|
** This file is part of the Qt Commercial Charts Add-on.
|
|
7
|
** This file is part of the Qt Commercial Charts Add-on.
|
|
8
|
**
|
|
8
|
**
|
|
9
|
** $QT_BEGIN_LICENSE$
|
|
9
|
** $QT_BEGIN_LICENSE$
|
|
10
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
10
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
11
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
11
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
12
|
** Software or, alternatively, in accordance with the terms contained in
|
|
12
|
** Software or, alternatively, in accordance with the terms contained in
|
|
13
|
** a written agreement between you and Digia.
|
|
13
|
** a written agreement between you and Digia.
|
|
14
|
**
|
|
14
|
**
|
|
15
|
** If you have questions regarding the use of this file, please use
|
|
15
|
** If you have questions regarding the use of this file, please use
|
|
16
|
** contact form at http://qt.digia.com
|
|
16
|
** contact form at http://qt.digia.com
|
|
17
|
** $QT_END_LICENSE$
|
|
17
|
** $QT_END_LICENSE$
|
|
18
|
**
|
|
18
|
**
|
|
19
|
****************************************************************************/
|
|
19
|
****************************************************************************/
|
|
20
|
|
|
20
|
|
|
21
|
#include "qdatetimeaxis.h"
|
|
21
|
#include "qdatetimeaxis.h"
|
|
22
|
#include "qdatetimeaxis_p.h"
|
|
22
|
#include "qdatetimeaxis_p.h"
|
|
23
|
#include "chartdatetimeaxisx_p.h"
|
|
23
|
#include "chartdatetimeaxisx_p.h"
|
|
24
|
#include "chartdatetimeaxisy_p.h"
|
|
24
|
#include "chartdatetimeaxisy_p.h"
|
|
25
|
#include "domain_p.h"
|
|
25
|
#include "domain_p.h"
|
|
26
|
#include <cmath>
|
|
26
|
#include <cmath>
|
|
27
|
#include <QDebug>
|
|
27
|
#include <QDebug>
|
|
28
|
|
|
28
|
|
|
29
|
QTCOMMERCIALCHART_BEGIN_NAMESPACE
|
|
29
|
QTCOMMERCIALCHART_BEGIN_NAMESPACE
|
|
30
|
/*!
|
|
30
|
/*!
|
|
31
|
\class QDateTimeAxis
|
|
31
|
\class QDateTimeAxis
|
|
32
|
\brief The QDateTimeAxis class is used for manipulating chart's axis.
|
|
32
|
\brief The QDateTimeAxis class is used for manipulating chart's axis.
|
|
33
|
\mainclass
|
|
33
|
\mainclass
|
|
34
|
|
|
34
|
|
|
35
|
Note that any date before 4800 BCE or after about 1.4 million CE may not be accurately stored.
|
|
35
|
Note that any date before 4800 BCE or after about 1.4 million CE may not be accurately stored.
|
|
36
|
|
|
36
|
|
|
37
|
ValuesAxis can be setup to show axis line with tick marks, grid lines and shades.
|
|
37
|
ValuesAxis can be setup to show axis line with tick marks, grid lines and shades.
|
|
38
|
Values of axis are drawn to position of ticks
|
|
38
|
Values of axis are drawn to position of ticks
|
|
39
|
*/
|
|
39
|
*/
|
|
40
|
|
|
40
|
|
|
41
|
/*!
|
|
41
|
/*!
|
|
42
|
\qmlclass ValuesAxis QDateTimeAxis
|
|
42
|
\qmlclass ValuesAxis QDateTimeAxis
|
|
43
|
\brief The ValuesAxis element is used for manipulating chart's axes
|
|
43
|
\brief The ValuesAxis element is used for manipulating chart's axes
|
|
44
|
|
|
44
|
|
|
45
|
ValueAxis can be setup to show axis line with tick marks, grid lines and shades.
|
|
45
|
ValueAxis can be setup to show axis line with tick marks, grid lines and shades.
|
|
46
|
Values of axis are drawn to position of ticks
|
|
46
|
Values of axis are drawn to position of ticks
|
|
47
|
|
|
47
|
|
|
48
|
To access Axes you can use ChartView API. For example:
|
|
48
|
To access Axes you can use ChartView API. For example:
|
|
49
|
\code
|
|
49
|
\code
|
|
50
|
ChartView {
|
|
50
|
ChartView {
|
|
51
|
ValuesAxis {
|
|
51
|
ValuesAxis {
|
|
52
|
id: xAxis
|
|
52
|
id: xAxis
|
|
53
|
min: 0
|
|
53
|
min: 0
|
|
54
|
max: 10
|
|
54
|
max: 10
|
|
55
|
}
|
|
55
|
}
|
|
56
|
// Add a few series...
|
|
56
|
// Add a few series...
|
|
57
|
}
|
|
57
|
}
|
|
58
|
\endcode
|
|
58
|
\endcode
|
|
59
|
*/
|
|
59
|
*/
|
|
60
|
|
|
60
|
|
|
61
|
/*!
|
|
61
|
/*!
|
|
62
|
\property QDateTimeAxis::min
|
|
62
|
\property QDateTimeAxis::min
|
|
63
|
Defines the minimum value on the axis.
|
|
63
|
Defines the minimum value on the axis.
|
|
64
|
When setting this property the max is adjusted if necessary, to ensure that the range remains valid.
|
|
64
|
When setting this property the max is adjusted if necessary, to ensure that the range remains valid.
|
|
65
|
*/
|
|
65
|
*/
|
|
66
|
/*!
|
|
66
|
/*!
|
|
67
|
\qmlproperty real ValuesAxis::min
|
|
67
|
\qmlproperty real ValuesAxis::min
|
|
68
|
Defines the minimum value on the axis.
|
|
68
|
Defines the minimum value on the axis.
|
|
69
|
When setting this property the max is adjusted if necessary, to ensure that the range remains valid.
|
|
69
|
When setting this property the max is adjusted if necessary, to ensure that the range remains valid.
|
|
70
|
*/
|
|
70
|
*/
|
|
71
|
|
|
71
|
|
|
72
|
/*!
|
|
72
|
/*!
|
|
73
|
\property QDateTimeAxis::max
|
|
73
|
\property QDateTimeAxis::max
|
|
74
|
Defines the maximum value on the axis.
|
|
74
|
Defines the maximum value on the axis.
|
|
75
|
When setting this property the min is adjusted if necessary, to ensure that the range remains valid.
|
|
75
|
When setting this property the min is adjusted if necessary, to ensure that the range remains valid.
|
|
76
|
*/
|
|
76
|
*/
|
|
77
|
/*!
|
|
77
|
/*!
|
|
78
|
\qmlproperty real ValuesAxis::max
|
|
78
|
\qmlproperty real ValuesAxis::max
|
|
79
|
Defines the maximum value on the axis.
|
|
79
|
Defines the maximum value on the axis.
|
|
80
|
When setting this property the min is adjusted if necessary, to ensure that the range remains valid.
|
|
80
|
When setting this property the min is adjusted if necessary, to ensure that the range remains valid.
|
|
81
|
*/
|
|
81
|
*/
|
|
82
|
|
|
82
|
|
|
83
|
/*!
|
|
83
|
/*!
|
|
84
|
\fn void QDateTimeAxis::minChanged(QDateTime min)
|
|
84
|
\fn void QDateTimeAxis::minChanged(QDateTime min)
|
|
85
|
Axis emits signal when \a min of axis has changed.
|
|
85
|
Axis emits signal when \a min of axis has changed.
|
|
86
|
*/
|
|
86
|
*/
|
|
87
|
/*!
|
|
87
|
/*!
|
|
88
|
\qmlsignal ValuesAxis::onMinChanged(QDateTime min)
|
|
88
|
\qmlsignal ValuesAxis::onMinChanged(QDateTime min)
|
|
89
|
Axis emits signal when \a min of axis has changed.
|
|
89
|
Axis emits signal when \a min of axis has changed.
|
|
90
|
*/
|
|
90
|
*/
|
|
91
|
|
|
91
|
|
|
92
|
/*!
|
|
92
|
/*!
|
|
93
|
\fn void QDateTimeAxis::maxChanged(QDateTime max)
|
|
93
|
\fn void QDateTimeAxis::maxChanged(QDateTime max)
|
|
94
|
Axis emits signal when \a max of axis has changed.
|
|
94
|
Axis emits signal when \a max of axis has changed.
|
|
95
|
*/
|
|
95
|
*/
|
|
96
|
/*!
|
|
96
|
/*!
|
|
97
|
\qmlsignal ValuesAxis::onMaxChanged(QDateTime max)
|
|
97
|
\qmlsignal ValuesAxis::onMaxChanged(QDateTime max)
|
|
98
|
Axis emits signal when \a max of axis has changed.
|
|
98
|
Axis emits signal when \a max of axis has changed.
|
|
99
|
*/
|
|
99
|
*/
|
|
100
|
|
|
100
|
|
|
101
|
/*!
|
|
101
|
/*!
|
|
102
|
\fn void QDateTimeAxis::rangeChanged(QDateTime min, QDateTime max)
|
|
102
|
\fn void QDateTimeAxis::rangeChanged(QDateTime min, QDateTime max)
|
|
103
|
Axis emits signal when \a min or \a max of axis has changed.
|
|
103
|
Axis emits signal when \a min or \a max of axis has changed.
|
|
104
|
*/
|
|
104
|
*/
|
|
105
|
|
|
105
|
|
|
106
|
/*!
|
|
106
|
/*!
|
|
107
|
\property QDateTimeAxis::ticksCount
|
|
107
|
\property QDateTimeAxis::ticksCount
|
|
108
|
The number of tick marks for the axis.
|
|
108
|
The number of tick marks for the axis.
|
|
109
|
*/
|
|
109
|
*/
|
|
110
|
|
|
110
|
|
|
111
|
/*!
|
|
111
|
/*!
|
|
112
|
\qmlproperty int ValuesAxis::ticksCount
|
|
112
|
\qmlproperty int ValuesAxis::ticksCount
|
|
113
|
The number of tick marks for the axis.
|
|
113
|
The number of tick marks for the axis.
|
|
114
|
*/
|
|
114
|
*/
|
|
115
|
|
|
115
|
|
|
116
|
/*!
|
|
116
|
/*!
|
|
117
|
Constructs an axis object which is a child of \a parent.
|
|
117
|
Constructs an axis object which is a child of \a parent.
|
|
118
|
*/
|
|
118
|
*/
|
|
119
|
QDateTimeAxis::QDateTimeAxis(QObject *parent) :
|
|
119
|
QDateTimeAxis::QDateTimeAxis(QObject *parent) :
|
|
120
|
QAbstractAxis(*new QDateTimeAxisPrivate(this),parent)
|
|
120
|
QAbstractAxis(*new QDateTimeAxisPrivate(this),parent)
|
|
121
|
{
|
|
121
|
{
|
|
122
|
|
|
122
|
|
|
123
|
}
|
|
123
|
}
|
|
124
|
|
|
124
|
|
|
125
|
/*!
|
|
125
|
/*!
|
|
126
|
\internal
|
|
126
|
\internal
|
|
127
|
*/
|
|
127
|
*/
|
|
128
|
QDateTimeAxis::QDateTimeAxis(QDateTimeAxisPrivate &d,QObject *parent) : QAbstractAxis(d,parent)
|
|
128
|
QDateTimeAxis::QDateTimeAxis(QDateTimeAxisPrivate &d,QObject *parent) : QAbstractAxis(d,parent)
|
|
129
|
{
|
|
129
|
{
|
|
130
|
|
|
130
|
|
|
131
|
}
|
|
131
|
}
|
|
132
|
|
|
132
|
|
|
133
|
/*!
|
|
133
|
/*!
|
|
134
|
Destroys the object
|
|
134
|
Destroys the object
|
|
135
|
*/
|
|
135
|
*/
|
|
136
|
QDateTimeAxis::~QDateTimeAxis()
|
|
136
|
QDateTimeAxis::~QDateTimeAxis()
|
|
137
|
{
|
|
137
|
{
|
|
138
|
|
|
138
|
|
|
139
|
}
|
|
139
|
}
|
|
140
|
|
|
140
|
|
|
141
|
void QDateTimeAxis::setMin(QDateTime min)
|
|
141
|
void QDateTimeAxis::setMin(QDateTime min)
|
|
142
|
{
|
|
142
|
{
|
|
143
|
Q_D(QDateTimeAxis);
|
|
143
|
Q_D(QDateTimeAxis);
|
|
144
|
if (min.isValid())
|
|
144
|
if (min.isValid())
|
|
145
|
setRange(min, qMax(d->m_max, min));
|
|
145
|
setRange(min, qMax(d->m_max, min));
|
|
146
|
}
|
|
146
|
}
|
|
147
|
|
|
147
|
|
|
148
|
QDateTime QDateTimeAxis::min() const
|
|
148
|
QDateTime QDateTimeAxis::min() const
|
|
149
|
{
|
|
149
|
{
|
|
150
|
Q_D(const QDateTimeAxis);
|
|
150
|
Q_D(const QDateTimeAxis);
|
|
151
|
return d->m_min;
|
|
151
|
return d->m_min;
|
|
152
|
}
|
|
152
|
}
|
|
153
|
|
|
153
|
|
|
154
|
void QDateTimeAxis::setMax(QDateTime max)
|
|
154
|
void QDateTimeAxis::setMax(QDateTime max)
|
|
155
|
{
|
|
155
|
{
|
|
156
|
Q_D(QDateTimeAxis);
|
|
156
|
Q_D(QDateTimeAxis);
|
|
157
|
if (max.isValid())
|
|
157
|
if (max.isValid())
|
|
158
|
setRange(qMin(d->m_min, max), max);
|
|
158
|
setRange(qMin(d->m_min, max), max);
|
|
159
|
}
|
|
159
|
}
|
|
160
|
|
|
160
|
|
|
161
|
QDateTime QDateTimeAxis::max() const
|
|
161
|
QDateTime QDateTimeAxis::max() const
|
|
162
|
{
|
|
162
|
{
|
|
163
|
Q_D(const QDateTimeAxis);
|
|
163
|
Q_D(const QDateTimeAxis);
|
|
164
|
return d->m_max;
|
|
164
|
return d->m_max;
|
|
165
|
}
|
|
165
|
}
|
|
166
|
|
|
166
|
|
|
167
|
/*!
|
|
167
|
/*!
|
|
168
|
Sets range from \a min to \a max on the axis.
|
|
168
|
Sets range from \a min to \a max on the axis.
|
|
169
|
If min is greater than max then this function returns without making any changes.
|
|
169
|
If min is greater than max then this function returns without making any changes.
|
|
170
|
*/
|
|
170
|
*/
|
|
171
|
void QDateTimeAxis::setRange(QDateTime min, QDateTime max)
|
|
171
|
void QDateTimeAxis::setRange(QDateTime min, QDateTime max)
|
|
172
|
{
|
|
172
|
{
|
|
173
|
Q_D(QDateTimeAxis);
|
|
173
|
Q_D(QDateTimeAxis);
|
|
174
|
if (!min.isValid() || !max.isValid() || min > max)
|
|
174
|
if (!min.isValid() || !max.isValid() || min > max)
|
|
175
|
return;
|
|
175
|
return;
|
|
176
|
|
|
176
|
|
|
177
|
bool changed = false;
|
|
177
|
bool changed = false;
|
|
178
|
if (d->m_min != min) {
|
|
178
|
if (d->m_min != min) {
|
|
179
|
d->m_min = min;
|
|
179
|
d->m_min = min;
|
|
180
|
changed = true;
|
|
180
|
changed = true;
|
|
181
|
emit minChanged(min);
|
|
181
|
emit minChanged(min);
|
|
182
|
}
|
|
182
|
}
|
|
183
|
|
|
183
|
|
|
184
|
if (d->m_max != max) {
|
|
184
|
if (d->m_max != max) {
|
|
185
|
d->m_max = max;
|
|
185
|
d->m_max = max;
|
|
186
|
changed = true;
|
|
186
|
changed = true;
|
|
187
|
emit maxChanged(max);
|
|
187
|
emit maxChanged(max);
|
|
188
|
}
|
|
188
|
}
|
|
189
|
|
|
189
|
|
|
190
|
// if(d->m_niceNumbers) d->looseNiceNumbers(d->m_min, d->m_max, d->m_tickCount);
|
|
190
|
// if(d->m_niceNumbers) d->looseNiceNumbers(d->m_min, d->m_max, d->m_tickCount);
|
|
191
|
|
|
191
|
|
|
192
|
if (changed) {
|
|
192
|
if (changed) {
|
|
193
|
emit rangeChanged(d->m_min,d->m_max);
|
|
193
|
emit rangeChanged(d->m_min,d->m_max);
|
|
194
|
d->emitUpdated();
|
|
194
|
d->emitUpdated();
|
|
195
|
}
|
|
195
|
}
|
|
196
|
}
|
|
196
|
}
|
|
197
|
|
|
197
|
|
|
198
|
/*!
|
|
198
|
/*!
|
|
199
|
Sets \a format string that is used when creating label for the axis out of the QDateTime object.
|
|
199
|
Sets \a format string that is used when creating label for the axis out of the QDateTime object.
|
|
200
|
Check QDateTime documentation for information on how the string should be defined.
|
|
200
|
Check QDateTime documentation for information on how the string should be defined.
|
|
201
|
\sa formatString()
|
|
201
|
\sa formatString()
|
|
202
|
*/
|
|
202
|
*/
|
|
203
|
void QDateTimeAxis::setFormatString(QString format)
|
|
203
|
void QDateTimeAxis::setFormatString(QString format)
|
|
204
|
{
|
|
204
|
{
|
|
205
|
Q_D(QDateTimeAxis);
|
|
205
|
Q_D(QDateTimeAxis);
|
|
206
|
d->m_format = format;
|
|
206
|
d->m_format = format;
|
|
207
|
}
|
|
207
|
}
|
|
208
|
|
|
208
|
|
|
209
|
/*!
|
|
209
|
/*!
|
|
210
|
Returns the format string that is used when creating label for the axis out of the QDateTime object.
|
|
210
|
Returns the format string that is used when creating label for the axis out of the QDateTime object.
|
|
211
|
Check QDateTime documentation for information on how the string should be defined.
|
|
211
|
Check QDateTime documentation for information on how the string should be defined.
|
|
212
|
\sa setFormatString()
|
|
212
|
\sa setFormatString()
|
|
213
|
*/
|
|
213
|
*/
|
|
214
|
QString QDateTimeAxis::formatString() const
|
|
214
|
QString QDateTimeAxis::formatString() const
|
|
215
|
{
|
|
215
|
{
|
|
216
|
Q_D(const QDateTimeAxis);
|
|
216
|
Q_D(const QDateTimeAxis);
|
|
217
|
return d->m_format;
|
|
217
|
return d->m_format;
|
|
218
|
}
|
|
218
|
}
|
|
219
|
|
|
219
|
|
|
220
|
/*!
|
|
220
|
/*!
|
|
221
|
Sets \a count for ticks on the axis.
|
|
221
|
Sets \a count for ticks on the axis.
|
|
222
|
*/
|
|
222
|
*/
|
|
223
|
void QDateTimeAxis::setTicksCount(int count)
|
|
223
|
void QDateTimeAxis::setTicksCount(int count)
|
|
224
|
{
|
|
224
|
{
|
|
225
|
Q_D(QDateTimeAxis);
|
|
225
|
Q_D(QDateTimeAxis);
|
|
226
|
if (d->m_tickCount != count && count >=2) {
|
|
226
|
if (d->m_tickCount != count && count >=2) {
|
|
227
|
d->m_tickCount = count;
|
|
227
|
d->m_tickCount = count;
|
|
228
|
d->emitUpdated();
|
|
228
|
d->emitUpdated();
|
|
229
|
}
|
|
229
|
}
|
|
230
|
}
|
|
230
|
}
|
|
231
|
|
|
231
|
|
|
232
|
/*!
|
|
232
|
/*!
|
|
233
|
\fn int QDateTimeAxis::ticksCount() const
|
|
233
|
\fn int QDateTimeAxis::ticksCount() const
|
|
234
|
Return number of ticks on the axis
|
|
234
|
Return number of ticks on the axis
|
|
235
|
*/
|
|
235
|
*/
|
|
236
|
int QDateTimeAxis::ticksCount() const
|
|
236
|
int QDateTimeAxis::ticksCount() const
|
|
237
|
{
|
|
237
|
{
|
|
238
|
Q_D(const QDateTimeAxis);
|
|
238
|
Q_D(const QDateTimeAxis);
|
|
239
|
return d->m_tickCount;
|
|
239
|
return d->m_tickCount;
|
|
240
|
}
|
|
240
|
}
|
|
241
|
|
|
241
|
|
|
242
|
/*!
|
|
242
|
/*!
|
|
243
|
Returns the type of the axis
|
|
243
|
Returns the type of the axis
|
|
244
|
*/
|
|
244
|
*/
|
|
245
|
QAbstractAxis::AxisType QDateTimeAxis::type() const
|
|
245
|
QAbstractAxis::AxisType QDateTimeAxis::type() const
|
|
246
|
{
|
|
246
|
{
|
|
247
|
return AxisTypeDateTime;
|
|
247
|
return AxisTypeDateTime;
|
|
248
|
}
|
|
248
|
}
|
|
249
|
|
|
249
|
|
|
250
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
250
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
251
|
|
|
251
|
|
|
252
|
QDateTimeAxisPrivate::QDateTimeAxisPrivate(QDateTimeAxis* q):
|
|
252
|
QDateTimeAxisPrivate::QDateTimeAxisPrivate(QDateTimeAxis* q):
|
|
253
|
QAbstractAxisPrivate(q),
|
|
253
|
QAbstractAxisPrivate(q),
|
|
254
|
m_tickCount(5)
|
|
254
|
m_tickCount(5)
|
|
255
|
{
|
|
255
|
{
|
|
256
|
m_min = QDateTime::fromMSecsSinceEpoch(0);
|
|
256
|
m_min = QDateTime::fromMSecsSinceEpoch(0);
|
|
257
|
m_max = QDateTime::fromMSecsSinceEpoch(0);
|
|
257
|
m_max = QDateTime::fromMSecsSinceEpoch(0);
|
|
258
|
m_format = "hh:mm:ss\ndd-mm-yyyy";
|
|
258
|
m_format = "dd-MMM-yy\nh:mm";
|
|
259
|
}
|
|
259
|
}
|
|
260
|
|
|
260
|
|
|
261
|
QDateTimeAxisPrivate::~QDateTimeAxisPrivate()
|
|
261
|
QDateTimeAxisPrivate::~QDateTimeAxisPrivate()
|
|
262
|
{
|
|
262
|
{
|
|
263
|
|
|
263
|
|
|
264
|
}
|
|
264
|
}
|
|
265
|
|
|
265
|
|
|
266
|
void QDateTimeAxisPrivate::handleDomainUpdated()
|
|
266
|
void QDateTimeAxisPrivate::handleDomainUpdated()
|
|
267
|
{
|
|
267
|
{
|
|
268
|
Q_Q(QDateTimeAxis);
|
|
268
|
Q_Q(QDateTimeAxis);
|
|
269
|
Domain* domain = qobject_cast<Domain*>(sender());
|
|
269
|
Domain* domain = qobject_cast<Domain*>(sender());
|
|
270
|
Q_ASSERT(domain);
|
|
270
|
Q_ASSERT(domain);
|
|
271
|
|
|
271
|
|
|
272
|
if(orientation()==Qt::Horizontal){
|
|
272
|
if(orientation()==Qt::Horizontal){
|
|
273
|
q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minX()), QDateTime::fromMSecsSinceEpoch(domain->maxX()));
|
|
273
|
q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minX()), QDateTime::fromMSecsSinceEpoch(domain->maxX()));
|
|
274
|
}else if(orientation()==Qt::Vertical){
|
|
274
|
}else if(orientation()==Qt::Vertical){
|
|
275
|
q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minY()), QDateTime::fromMSecsSinceEpoch(domain->maxY()));
|
|
275
|
q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minY()), QDateTime::fromMSecsSinceEpoch(domain->maxY()));
|
|
276
|
}
|
|
276
|
}
|
|
277
|
}
|
|
277
|
}
|
|
278
|
|
|
278
|
|
|
279
|
|
|
279
|
|
|
280
|
void QDateTimeAxisPrivate::setMin(const QVariant &min)
|
|
280
|
void QDateTimeAxisPrivate::setMin(const QVariant &min)
|
|
281
|
{
|
|
281
|
{
|
|
282
|
Q_Q(QDateTimeAxis);
|
|
282
|
Q_Q(QDateTimeAxis);
|
|
283
|
if (min.canConvert(QVariant::DateTime))
|
|
283
|
if (min.canConvert(QVariant::DateTime))
|
|
284
|
q->setMin(min.toDateTime());
|
|
284
|
q->setMin(min.toDateTime());
|
|
285
|
}
|
|
285
|
}
|
|
286
|
|
|
286
|
|
|
287
|
void QDateTimeAxisPrivate::setMax(const QVariant &max)
|
|
287
|
void QDateTimeAxisPrivate::setMax(const QVariant &max)
|
|
288
|
{
|
|
288
|
{
|
|
289
|
|
|
289
|
|
|
290
|
Q_Q(QDateTimeAxis);
|
|
290
|
Q_Q(QDateTimeAxis);
|
|
291
|
if (max.canConvert(QVariant::DateTime))
|
|
291
|
if (max.canConvert(QVariant::DateTime))
|
|
292
|
q->setMax(max.toDateTime());
|
|
292
|
q->setMax(max.toDateTime());
|
|
293
|
}
|
|
293
|
}
|
|
294
|
|
|
294
|
|
|
295
|
void QDateTimeAxisPrivate::setRange(const QVariant &min, const QVariant &max)
|
|
295
|
void QDateTimeAxisPrivate::setRange(const QVariant &min, const QVariant &max)
|
|
296
|
{
|
|
296
|
{
|
|
297
|
Q_Q(QDateTimeAxis);
|
|
297
|
Q_Q(QDateTimeAxis);
|
|
298
|
if (min.canConvert(QVariant::DateTime) && max.canConvert(QVariant::DateTime))
|
|
298
|
if (min.canConvert(QVariant::DateTime) && max.canConvert(QVariant::DateTime))
|
|
299
|
q->setRange(min.toDateTime(), max.toDateTime());
|
|
299
|
q->setRange(min.toDateTime(), max.toDateTime());
|
|
300
|
}
|
|
300
|
}
|
|
301
|
|
|
301
|
|
|
302
|
ChartAxis* QDateTimeAxisPrivate::createGraphics(ChartPresenter* presenter)
|
|
302
|
ChartAxis* QDateTimeAxisPrivate::createGraphics(ChartPresenter* presenter)
|
|
303
|
{
|
|
303
|
{
|
|
304
|
Q_Q(QDateTimeAxis);
|
|
304
|
Q_Q(QDateTimeAxis);
|
|
305
|
if(m_orientation == Qt::Vertical){
|
|
305
|
if(m_orientation == Qt::Vertical){
|
|
306
|
return new ChartDateTimeAxisY(q,presenter);
|
|
306
|
return new ChartDateTimeAxisY(q,presenter);
|
|
307
|
}else{
|
|
307
|
}else{
|
|
308
|
return new ChartDateTimeAxisX(q,presenter);
|
|
308
|
return new ChartDateTimeAxisX(q,presenter);
|
|
309
|
}
|
|
309
|
}
|
|
310
|
|
|
310
|
|
|
311
|
}
|
|
311
|
}
|
|
312
|
|
|
312
|
|
|
313
|
void QDateTimeAxisPrivate::intializeDomain(Domain* domain)
|
|
313
|
void QDateTimeAxisPrivate::intializeDomain(Domain* domain)
|
|
314
|
{
|
|
314
|
{
|
|
315
|
Q_Q(QDateTimeAxis);
|
|
315
|
Q_Q(QDateTimeAxis);
|
|
316
|
if(m_max == m_min) {
|
|
316
|
if(m_max == m_min) {
|
|
317
|
if(m_orientation==Qt::Vertical){
|
|
317
|
if(m_orientation==Qt::Vertical){
|
|
318
|
q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minY()), QDateTime::fromMSecsSinceEpoch(domain->maxY()));
|
|
318
|
q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minY()), QDateTime::fromMSecsSinceEpoch(domain->maxY()));
|
|
319
|
}else{
|
|
319
|
}else{
|
|
320
|
q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minX()), QDateTime::fromMSecsSinceEpoch(domain->maxX()));
|
|
320
|
q->setRange(QDateTime::fromMSecsSinceEpoch(domain->minX()), QDateTime::fromMSecsSinceEpoch(domain->maxX()));
|
|
321
|
}
|
|
321
|
}
|
|
322
|
} else {
|
|
322
|
} else {
|
|
323
|
if(m_orientation==Qt::Vertical){
|
|
323
|
if(m_orientation==Qt::Vertical){
|
|
324
|
domain->setRangeY(m_min.toMSecsSinceEpoch(), m_max.toMSecsSinceEpoch());
|
|
324
|
domain->setRangeY(m_min.toMSecsSinceEpoch(), m_max.toMSecsSinceEpoch());
|
|
325
|
}else{
|
|
325
|
}else{
|
|
326
|
domain->setRangeX(m_min.toMSecsSinceEpoch(), m_max.toMSecsSinceEpoch());
|
|
326
|
domain->setRangeX(m_min.toMSecsSinceEpoch(), m_max.toMSecsSinceEpoch());
|
|
327
|
}
|
|
327
|
}
|
|
328
|
}
|
|
328
|
}
|
|
329
|
}
|
|
329
|
}
|
|
330
|
|
|
330
|
|
|
331
|
#include "moc_qdatetimeaxis.cpp"
|
|
331
|
#include "moc_qdatetimeaxis.cpp"
|
|
332
|
#include "moc_qdatetimeaxis_p.cpp"
|
|
332
|
#include "moc_qdatetimeaxis_p.cpp"
|
|
333
|
|
|
333
|
|
|
334
|
QTCOMMERCIALCHART_END_NAMESPACE
|
|
334
|
QTCOMMERCIALCHART_END_NAMESPACE
|