@@ -547,6 +547,19 void QAbstractAxis::hide() | |||||
547 | } |
|
547 | } | |
548 |
|
548 | |||
549 |
|
549 | |||
|
550 | void QAbstractAxis::setMin(const QVariant& min) | |||
|
551 | { | |||
|
552 | d_ptr->setMin(min); | |||
|
553 | } | |||
|
554 | void QAbstractAxis::setMax(const QVariant& max) | |||
|
555 | { | |||
|
556 | d_ptr->setMax(max); | |||
|
557 | } | |||
|
558 | void QAbstractAxis::setRange(const QVariant& min, const QVariant& max) | |||
|
559 | { | |||
|
560 | d_ptr->setRange(min,max); | |||
|
561 | } | |||
|
562 | ||||
550 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
563 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
551 |
|
564 | |||
552 | QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis* q): |
|
565 | QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis* q): |
@@ -44,8 +44,6 class QTCOMMERCIALCHART_EXPORT QAbstractAxis : public QObject | |||||
44 | Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged) |
|
44 | Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged) | |
45 | Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged) |
|
45 | Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged) | |
46 | Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged) |
|
46 | Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged) | |
47 | //Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged) |
|
|||
48 | //Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged) |
|
|||
49 |
|
47 | |||
50 | public: |
|
48 | public: | |
51 |
|
49 | |||
@@ -103,11 +101,9 public: | |||||
103 | QColor shadesBorderColor() const; |
|
101 | QColor shadesBorderColor() const; | |
104 |
|
102 | |||
105 | //range handling |
|
103 | //range handling | |
106 |
|
|
104 | void setMin(const QVariant& min); | |
107 |
|
|
105 | void setMax(const QVariant& max); | |
108 | virtual void setRange(QVariant min, QVariant max) = 0; |
|
106 | void setRange(const QVariant& min, const QVariant& max); | |
109 |
|
||||
110 | virtual int ticksCount() const = 0; |
|
|||
111 |
|
107 | |||
112 | void show(); |
|
108 | void show(); | |
113 | void hide(); |
|
109 | void hide(); |
@@ -45,6 +45,12 Q_SIGNALS: | |||||
45 | void updated(); |
|
45 | void updated(); | |
46 |
|
46 | |||
47 | protected: |
|
47 | protected: | |
|
48 | virtual void setMin(const QVariant& min) = 0; | |||
|
49 | virtual void setMax(const QVariant& max) = 0; | |||
|
50 | virtual void setRange(const QVariant& min, const QVariant& max) = 0; | |||
|
51 | virtual int ticksCount() const = 0; | |||
|
52 | ||||
|
53 | protected: | |||
48 | QAbstractAxis *q_ptr; |
|
54 | QAbstractAxis *q_ptr; | |
49 |
|
55 | |||
50 | bool m_axisVisible; |
|
56 | bool m_axisVisible; |
@@ -112,7 +112,7 QString QCategoriesAxis::at(int index) const | |||||
112 | /*! |
|
112 | /*! | |
113 | Sets minimum category to \a minCategory. |
|
113 | Sets minimum category to \a minCategory. | |
114 | */ |
|
114 | */ | |
115 | void QCategoriesAxis::setMin(QString minCategory) |
|
115 | void QCategoriesAxis::setMin(const QString& minCategory) | |
116 | { |
|
116 | { | |
117 | Q_D(QCategoriesAxis); |
|
117 | Q_D(QCategoriesAxis); | |
118 | int minIndex = d->m_categories.indexOf(minCategory); |
|
118 | int minIndex = d->m_categories.indexOf(minCategory); | |
@@ -125,7 +125,7 void QCategoriesAxis::setMin(QString minCategory) | |||||
125 | /*! |
|
125 | /*! | |
126 | Sets maximum category to \a maxCategory. |
|
126 | Sets maximum category to \a maxCategory. | |
127 | */ |
|
127 | */ | |
128 | void QCategoriesAxis::setMax(QString maxCategory) |
|
128 | void QCategoriesAxis::setMax(const QString& maxCategory) | |
129 | { |
|
129 | { | |
130 | Q_D(QCategoriesAxis); |
|
130 | Q_D(QCategoriesAxis); | |
131 | int maxIndex = d->m_categories.indexOf(maxCategory); |
|
131 | int maxIndex = d->m_categories.indexOf(maxCategory); | |
@@ -138,7 +138,7 void QCategoriesAxis::setMax(QString maxCategory) | |||||
138 | /*! |
|
138 | /*! | |
139 | Sets range from \a minCategory to \a maxCategory |
|
139 | Sets range from \a minCategory to \a maxCategory | |
140 | */ |
|
140 | */ | |
141 | void QCategoriesAxis::setRange(QString minCategory, QString maxCategory) |
|
141 | void QCategoriesAxis::setRange(const QString& minCategory, const QString& maxCategory) | |
142 | { |
|
142 | { | |
143 | // TODO: what if maxCategory < minCategory? |
|
143 | // TODO: what if maxCategory < minCategory? | |
144 | setMin(minCategory); |
|
144 | setMin(minCategory); | |
@@ -153,36 +153,41 QAbstractAxis::AxisType QCategoriesAxis::type() const | |||||
153 | return AxisTypeCategories; |
|
153 | return AxisTypeCategories; | |
154 | } |
|
154 | } | |
155 |
|
155 | |||
156 | void QCategoriesAxis::setMin(QVariant min) |
|
156 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
|
157 | ||||
|
158 | QCategoriesAxisPrivate::QCategoriesAxisPrivate(QCategoriesAxis* q): | |||
|
159 | QAbstractAxisPrivate(q) | |||
157 | { |
|
160 | { | |
158 | setMin(min.toString()); |
|
161 | ||
159 | } |
|
162 | } | |
160 |
|
163 | |||
161 | void QCategoriesAxis::setMax(QVariant max) |
|
164 | QCategoriesAxisPrivate::~QCategoriesAxisPrivate() | |
162 | { |
|
165 | { | |
163 | setMax(max.toString()); |
|
166 | ||
164 | } |
|
167 | } | |
165 |
|
168 | |||
166 | void QCategoriesAxis::setRange(QVariant min, QVariant max) |
|
169 | ||
|
170 | void QCategoriesAxisPrivate::setMin(const QVariant& min) | |||
167 | { |
|
171 | { | |
168 | setRange(min.toString(),max.toString()); |
|
172 | Q_Q(QCategoriesAxis); | |
|
173 | q->setMin(min.toString()); | |||
169 | } |
|
174 | } | |
170 |
|
175 | |||
171 | int QCategoriesAxis::ticksCount() const |
|
176 | void QCategoriesAxisPrivate::setMax(const QVariant& max) | |
172 | { |
|
177 | { | |
173 | return count(); |
|
178 | Q_Q(QCategoriesAxis); | |
|
179 | q->setMax(max.toString()); | |||
174 | } |
|
180 | } | |
175 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|||
176 |
|
181 | |||
177 | QCategoriesAxisPrivate::QCategoriesAxisPrivate(QCategoriesAxis* q): |
|
182 | void QCategoriesAxisPrivate::setRange(const QVariant& min, const QVariant& max) | |
178 | QAbstractAxisPrivate(q) |
|
|||
179 | { |
|
183 | { | |
180 |
|
184 | Q_Q(QCategoriesAxis); | ||
|
185 | q->setRange(min.toString(),max.toString()); | |||
181 | } |
|
186 | } | |
182 |
|
187 | |||
183 | QCategoriesAxisPrivate::~QCategoriesAxisPrivate() |
|
188 | int QCategoriesAxisPrivate::ticksCount() const | |
184 | { |
|
189 | { | |
185 |
|
190 | return m_categories.count()+1; | ||
186 | } |
|
191 | } | |
187 |
|
192 | |||
188 | #include "moc_qcategoriesaxis.cpp" |
|
193 | #include "moc_qcategoriesaxis.cpp" |
@@ -50,16 +50,9 public: | |||||
50 | QString at(int index) const; |
|
50 | QString at(int index) const; | |
51 |
|
51 | |||
52 | //range handling convenience functions |
|
52 | //range handling convenience functions | |
53 | void setMin(QString minCategory); |
|
53 | void setMin(const QString& minCategory); | |
54 | void setMax(QString maxCategory); |
|
54 | void setMax(const QString& maxCategory); | |
55 | void setRange(QString minCategory, QString maxCategory); |
|
55 | void setRange(const QString& minCategory, const QString& maxCategory); | |
56 |
|
||||
57 | private: |
|
|||
58 | //range handling |
|
|||
59 | void setMin(QVariant min); |
|
|||
60 | void setMax(QVariant max); |
|
|||
61 | void setRange(QVariant min, QVariant max); |
|
|||
62 | int ticksCount() const; |
|
|||
63 |
|
56 | |||
64 | Q_SIGNALS: |
|
57 | Q_SIGNALS: | |
65 | void categoriesChanged(); |
|
58 | void categoriesChanged(); |
@@ -44,6 +44,13 public: | |||||
44 | ~QCategoriesAxisPrivate(); |
|
44 | ~QCategoriesAxisPrivate(); | |
45 |
|
45 | |||
46 | private: |
|
46 | private: | |
|
47 | //range handling | |||
|
48 | void setMin(const QVariant& min); | |||
|
49 | void setMax(const QVariant& max); | |||
|
50 | void setRange(const QVariant& min, const QVariant& max); | |||
|
51 | int ticksCount() const; | |||
|
52 | ||||
|
53 | private: | |||
47 | QStringList m_categories; |
|
54 | QStringList m_categories; | |
48 | QString m_minCategory; |
|
55 | QString m_minCategory; | |
49 | QString m_maxCategory; |
|
56 | QString m_maxCategory; |
@@ -130,30 +130,6 QAbstractAxis::AxisType QValuesAxis::type() const | |||||
130 | return AxisTypeValues; |
|
130 | return AxisTypeValues; | |
131 | } |
|
131 | } | |
132 |
|
132 | |||
133 | void QValuesAxis::setMin(QVariant min) |
|
|||
134 | { |
|
|||
135 | bool ok; |
|
|||
136 | qreal value = min.toReal(&ok); |
|
|||
137 | if(ok) setMin(value); |
|
|||
138 | } |
|
|||
139 |
|
||||
140 | void QValuesAxis::setMax(QVariant max) |
|
|||
141 | { |
|
|||
142 | bool ok; |
|
|||
143 | qreal value = max.toReal(&ok); |
|
|||
144 | if(ok) setMax(value); |
|
|||
145 | } |
|
|||
146 |
|
||||
147 | void QValuesAxis::setRange(QVariant min, QVariant max) |
|
|||
148 | { |
|
|||
149 | bool ok1; |
|
|||
150 | bool ok2; |
|
|||
151 | qreal value1 = min.toReal(&ok1); |
|
|||
152 | qreal value2 = max.toReal(&ok2); |
|
|||
153 | if(ok1&&ok2) setRange(value1,value2); |
|
|||
154 | } |
|
|||
155 |
|
||||
156 |
|
||||
157 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
133 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
158 |
|
134 | |||
159 | QValuesAxisPrivate::QValuesAxisPrivate(QValuesAxis* q): |
|
135 | QValuesAxisPrivate::QValuesAxisPrivate(QValuesAxis* q): | |
@@ -178,6 +154,38 void QValuesAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) | |||||
178 | q->setTicksCount(count); |
|
154 | q->setTicksCount(count); | |
179 | } |
|
155 | } | |
180 |
|
156 | |||
|
157 | ||||
|
158 | void QValuesAxisPrivate::setMin(const QVariant& min) | |||
|
159 | { | |||
|
160 | Q_Q(QValuesAxis); | |||
|
161 | bool ok; | |||
|
162 | qreal value = min.toReal(&ok); | |||
|
163 | if(ok) q->setMin(value); | |||
|
164 | } | |||
|
165 | ||||
|
166 | void QValuesAxisPrivate::setMax(const QVariant& max) | |||
|
167 | { | |||
|
168 | Q_Q(QValuesAxis); | |||
|
169 | bool ok; | |||
|
170 | qreal value = max.toReal(&ok); | |||
|
171 | if(ok) q->setMax(value); | |||
|
172 | } | |||
|
173 | ||||
|
174 | void QValuesAxisPrivate::setRange(const QVariant& min, const QVariant& max) | |||
|
175 | { | |||
|
176 | Q_Q(QValuesAxis); | |||
|
177 | bool ok1; | |||
|
178 | bool ok2; | |||
|
179 | qreal value1 = min.toReal(&ok1); | |||
|
180 | qreal value2 = max.toReal(&ok2); | |||
|
181 | if(ok1&&ok2) q->setRange(value1,value2); | |||
|
182 | } | |||
|
183 | ||||
|
184 | int QValuesAxisPrivate::ticksCount() const | |||
|
185 | { | |||
|
186 | return m_ticksCount; | |||
|
187 | } | |||
|
188 | ||||
181 | #include "moc_qvaluesaxis.cpp" |
|
189 | #include "moc_qvaluesaxis.cpp" | |
182 | #include "moc_qvaluesaxis_p.cpp" |
|
190 | #include "moc_qvaluesaxis_p.cpp" | |
183 |
|
191 |
@@ -59,12 +59,6 public: | |||||
59 | void setNiceNumbersEnabled(bool enable = true); |
|
59 | void setNiceNumbersEnabled(bool enable = true); | |
60 | bool niceNumbersEnabled() const; |
|
60 | bool niceNumbersEnabled() const; | |
61 |
|
61 | |||
62 | private: |
|
|||
63 | //range handling |
|
|||
64 | void setMin(QVariant min); |
|
|||
65 | void setMax(QVariant max); |
|
|||
66 | void setRange(QVariant min, QVariant max); |
|
|||
67 |
|
||||
68 | Q_SIGNALS: |
|
62 | Q_SIGNALS: | |
69 | void minChanged(qreal min); |
|
63 | void minChanged(qreal min); | |
70 | void maxChanged(qreal max); |
|
64 | void maxChanged(qreal max); |
@@ -48,6 +48,12 Q_SIGNALS: | |||||
48 | public Q_SLOTS: |
|
48 | public Q_SLOTS: | |
49 | void handleAxisRangeChanged(qreal min, qreal max,int count); |
|
49 | void handleAxisRangeChanged(qreal min, qreal max,int count); | |
50 |
|
50 | |||
|
51 | protected: | |||
|
52 | void setMin(const QVariant& min); | |||
|
53 | void setMax(const QVariant& max); | |||
|
54 | void setRange(const QVariant& min, const QVariant& max); | |||
|
55 | int ticksCount() const; | |||
|
56 | ||||
51 | private: |
|
57 | private: | |
52 | qreal m_min; |
|
58 | qreal m_min; | |
53 | qreal m_max; |
|
59 | qreal m_max; |
General Comments 0
You need to be logged in to leave comments.
Login now