@@ -47,12 +47,23 void DeclarativeCategoryAxis::classBegin() | |||
|
47 | 47 | |
|
48 | 48 | void DeclarativeCategoryAxis::componentComplete() |
|
49 | 49 | { |
|
50 | QList<QPair<QString, qreal> > ranges; | |
|
50 | 51 | foreach(QObject *child, children()) { |
|
51 | 52 | if (qobject_cast<DeclarativeCategoryRange *>(child)) { |
|
52 | 53 | DeclarativeCategoryRange *range = qobject_cast<DeclarativeCategoryRange *>(child); |
|
53 | append(range->label(), range->endValue()); | |
|
54 | ranges.append(QPair<QString, qreal>(range->label(), range->endValue())); | |
|
54 | 55 | } |
|
55 | 56 | } |
|
57 | ||
|
58 | // Sort and append the range objects according to end value | |
|
59 | qSort(ranges.begin(), ranges.end(), endValueLessThan); | |
|
60 | for (int i(0); i < ranges.count(); i++) | |
|
61 | append(ranges.at(i).first, ranges.at(i).second); | |
|
62 | } | |
|
63 | ||
|
64 | bool DeclarativeCategoryAxis::endValueLessThan(const QPair<QString, qreal> &value1, const QPair<QString, qreal> &value2) | |
|
65 | { | |
|
66 | return value1.second < value2.second; | |
|
56 | 67 | } |
|
57 | 68 | |
|
58 | 69 | QDeclarativeListProperty<QObject> DeclarativeCategoryAxis::axisChildren() |
@@ -70,6 +70,9 public Q_SLOTS: | |||
|
70 | 70 | Q_INVOKABLE void remove(const QString &label); |
|
71 | 71 | Q_INVOKABLE void replace(const QString& oldLabel, const QString& newLabel); |
|
72 | 72 | static void appendAxisChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
73 | ||
|
74 | private: | |
|
75 | static bool endValueLessThan(const QPair<QString, qreal> &value1, const QPair<QString, qreal> &value2); | |
|
73 | 76 | }; |
|
74 | 77 | |
|
75 | 78 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now