@@ -1,96 +1,127 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qaxiscategories.h" |
|
22 | 22 | #include "qaxiscategories_p.h" |
|
23 | 23 | |
|
24 | 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 | 36 | QAxisCategories::QAxisCategories(): |
|
27 | 37 | d_ptr(new QAxisCategoriesPrivate(this)) |
|
28 | 38 | { |
|
29 | 39 | |
|
30 | 40 | } |
|
31 | 41 | |
|
32 | 42 | QAxisCategories::~QAxisCategories() |
|
33 | 43 | { |
|
34 | 44 | |
|
35 | 45 | } |
|
36 | 46 | |
|
47 | /*! | |
|
48 | Inserts bar \a categories. | |
|
49 | */ | |
|
37 | 50 | void QAxisCategories::insert(const QBarCategories &categories) |
|
38 | 51 | { |
|
39 | 52 | int i=1; |
|
40 | 53 | foreach (const QString& string , categories) { |
|
41 | 54 | d_ptr->m_map.insert(i,string); |
|
42 | 55 | i++; |
|
43 | 56 | } |
|
44 | 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 | 63 | void QAxisCategories::insert(qreal value,QString label) |
|
48 | 64 | { |
|
49 | 65 | d_ptr->m_map.insert(value,label); |
|
50 | 66 | emit d_ptr->updated(); |
|
51 | 67 | } |
|
52 | 68 | |
|
69 | /*! | |
|
70 | Removes category for \a value. | |
|
71 | */ | |
|
53 | 72 | void QAxisCategories::remove(qreal value) |
|
54 | 73 | { |
|
55 | 74 | d_ptr->m_map.remove(value); |
|
56 | 75 | emit d_ptr->updated(); |
|
57 | 76 | } |
|
58 | 77 | |
|
78 | /*! | |
|
79 | Removes all categories. | |
|
80 | */ | |
|
59 | 81 | void QAxisCategories::clear() |
|
60 | 82 | { |
|
61 | 83 | d_ptr->m_map.clear(); |
|
62 | 84 | emit d_ptr->updated(); |
|
63 | 85 | } |
|
64 | 86 | |
|
87 | /*! | |
|
88 | Returns number of categories. | |
|
89 | */ | |
|
65 | 90 | int QAxisCategories::count() |
|
66 | 91 | { |
|
67 | 92 | return d_ptr->m_map.count(); |
|
68 | 93 | } |
|
69 | 94 | |
|
95 | /*! | |
|
96 | Returns all values of categories. | |
|
97 | */ | |
|
70 | 98 | QList<qreal> QAxisCategories::values() const |
|
71 | 99 | { |
|
72 | 100 | return d_ptr->m_map.keys(); |
|
73 | 101 | } |
|
74 | 102 | |
|
103 | /*! | |
|
104 | Returns label for given \a value. | |
|
105 | */ | |
|
75 | 106 | QString QAxisCategories::label(qreal value) const |
|
76 | 107 | { |
|
77 | 108 | return d_ptr->m_map.value(value); |
|
78 | 109 | } |
|
79 | 110 | |
|
80 | 111 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
81 | 112 | |
|
82 | 113 | QAxisCategoriesPrivate::QAxisCategoriesPrivate(QAxisCategories *q): |
|
83 | 114 | q_ptr(q) |
|
84 | 115 | { |
|
85 | 116 | |
|
86 | 117 | } |
|
87 | 118 | |
|
88 | 119 | QAxisCategoriesPrivate::~QAxisCategoriesPrivate() |
|
89 | 120 | { |
|
90 | 121 | |
|
91 | 122 | } |
|
92 | 123 | |
|
93 | 124 | #include "moc_qaxiscategories.cpp" |
|
94 | 125 | #include "moc_qaxiscategories_p.cpp" |
|
95 | 126 | |
|
96 | 127 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now