@@ -1,96 +1,127 | |||||
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 "qaxiscategories.h" |
|
21 | #include "qaxiscategories.h" | |
22 | #include "qaxiscategories_p.h" |
|
22 | #include "qaxiscategories_p.h" | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
|
26 | /*! | |||
|
27 | \class QAxisCategories | |||
|
28 | \brief The QAxisCategoriess class is used for manipulating axis's categories. | |||
|
29 | \mainclass | |||
|
30 | ||||
|
31 | Each axis can have categories instead of numerical representation. The typical use case | |||
|
32 | is bar chart, where categories are always show on X axis. | |||
|
33 | */ | |||
|
34 | ||||
|
35 | ||||
26 | QAxisCategories::QAxisCategories(): |
|
36 | QAxisCategories::QAxisCategories(): | |
27 | d_ptr(new QAxisCategoriesPrivate(this)) |
|
37 | d_ptr(new QAxisCategoriesPrivate(this)) | |
28 | { |
|
38 | { | |
29 |
|
39 | |||
30 | } |
|
40 | } | |
31 |
|
41 | |||
32 | QAxisCategories::~QAxisCategories() |
|
42 | QAxisCategories::~QAxisCategories() | |
33 | { |
|
43 | { | |
34 |
|
44 | |||
35 | } |
|
45 | } | |
36 |
|
46 | |||
|
47 | /*! | |||
|
48 | Inserts bar \a categories. | |||
|
49 | */ | |||
37 | void QAxisCategories::insert(const QBarCategories &categories) |
|
50 | void QAxisCategories::insert(const QBarCategories &categories) | |
38 | { |
|
51 | { | |
39 | int i=1; |
|
52 | int i=1; | |
40 | foreach (const QString& string , categories) { |
|
53 | foreach (const QString& string , categories) { | |
41 | d_ptr->m_map.insert(i,string); |
|
54 | d_ptr->m_map.insert(i,string); | |
42 | i++; |
|
55 | i++; | |
43 | } |
|
56 | } | |
44 | emit d_ptr->updated(); |
|
57 | emit d_ptr->updated(); | |
45 | } |
|
58 | } | |
46 |
|
59 | |||
|
60 | /*! | |||
|
61 | Inserts category, instead of \a value on axis a \a label will be shown. | |||
|
62 | */ | |||
47 | void QAxisCategories::insert(qreal value,QString label) |
|
63 | void QAxisCategories::insert(qreal value,QString label) | |
48 | { |
|
64 | { | |
49 | d_ptr->m_map.insert(value,label); |
|
65 | d_ptr->m_map.insert(value,label); | |
50 | emit d_ptr->updated(); |
|
66 | emit d_ptr->updated(); | |
51 | } |
|
67 | } | |
52 |
|
68 | |||
|
69 | /*! | |||
|
70 | Removes category for \a value. | |||
|
71 | */ | |||
53 | void QAxisCategories::remove(qreal value) |
|
72 | void QAxisCategories::remove(qreal value) | |
54 | { |
|
73 | { | |
55 | d_ptr->m_map.remove(value); |
|
74 | d_ptr->m_map.remove(value); | |
56 | emit d_ptr->updated(); |
|
75 | emit d_ptr->updated(); | |
57 | } |
|
76 | } | |
58 |
|
77 | |||
|
78 | /*! | |||
|
79 | Removes all categories. | |||
|
80 | */ | |||
59 | void QAxisCategories::clear() |
|
81 | void QAxisCategories::clear() | |
60 | { |
|
82 | { | |
61 | d_ptr->m_map.clear(); |
|
83 | d_ptr->m_map.clear(); | |
62 | emit d_ptr->updated(); |
|
84 | emit d_ptr->updated(); | |
63 | } |
|
85 | } | |
64 |
|
86 | |||
|
87 | /*! | |||
|
88 | Returns number of categories. | |||
|
89 | */ | |||
65 | int QAxisCategories::count() |
|
90 | int QAxisCategories::count() | |
66 | { |
|
91 | { | |
67 | return d_ptr->m_map.count(); |
|
92 | return d_ptr->m_map.count(); | |
68 | } |
|
93 | } | |
69 |
|
94 | |||
|
95 | /*! | |||
|
96 | Returns all values of categories. | |||
|
97 | */ | |||
70 | QList<qreal> QAxisCategories::values() const |
|
98 | QList<qreal> QAxisCategories::values() const | |
71 | { |
|
99 | { | |
72 | return d_ptr->m_map.keys(); |
|
100 | return d_ptr->m_map.keys(); | |
73 | } |
|
101 | } | |
74 |
|
102 | |||
|
103 | /*! | |||
|
104 | Returns label for given \a value. | |||
|
105 | */ | |||
75 | QString QAxisCategories::label(qreal value) const |
|
106 | QString QAxisCategories::label(qreal value) const | |
76 | { |
|
107 | { | |
77 | return d_ptr->m_map.value(value); |
|
108 | return d_ptr->m_map.value(value); | |
78 | } |
|
109 | } | |
79 |
|
110 | |||
80 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
111 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
81 |
|
112 | |||
82 | QAxisCategoriesPrivate::QAxisCategoriesPrivate(QAxisCategories *q): |
|
113 | QAxisCategoriesPrivate::QAxisCategoriesPrivate(QAxisCategories *q): | |
83 | q_ptr(q) |
|
114 | q_ptr(q) | |
84 | { |
|
115 | { | |
85 |
|
116 | |||
86 | } |
|
117 | } | |
87 |
|
118 | |||
88 | QAxisCategoriesPrivate::~QAxisCategoriesPrivate() |
|
119 | QAxisCategoriesPrivate::~QAxisCategoriesPrivate() | |
89 | { |
|
120 | { | |
90 |
|
121 | |||
91 | } |
|
122 | } | |
92 |
|
123 | |||
93 | #include "moc_qaxiscategories.cpp" |
|
124 | #include "moc_qaxiscategories.cpp" | |
94 | #include "moc_qaxiscategories_p.cpp" |
|
125 | #include "moc_qaxiscategories_p.cpp" | |
95 |
|
126 | |||
96 | QTCOMMERCIALCHART_END_NAMESPACE |
|
127 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now