##// END OF EJS Templates
documentation fix
sauimone -
r1243:f8551f41dd87
parent child
Show More
@@ -1,363 +1,363
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 "qbarset.h"
22 22 #include "qbarset_p.h"
23 23
24 24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25 25
26 26 /*!
27 27 \class QBarSet
28 28 \brief part of QtCommercial chart API.
29 29
30 30 QBarSet represents one set of bars. Set of bars contains one data value for each category.
31 31 First value of set is assumed to belong to first category, second to second category and so on.
32 32 If set has fewer values than there are categories, then the missing values are assumed to be
33 33 at the end of set. For missing values in middle of a set, numerical value of zero is used.
34 34
35 35 \mainclass
36 36
37 37 \sa QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries
38 38 */
39 39
40 40 /*!
41 41 \fn void QBarSet::clicked(QString category)
42 42 \brief signals that set has been clicked
43 43 Parameter \a category describes on which category was clicked
44 44 */
45 45
46 46 /*!
47 47 \fn void QBarSet::hovered(bool status)
48 48 \brief signals that mouse has hovered over the set. If \a status is true, then mouse was entered. If \a status is false, then mouse was left.
49 49
50 50 The signal is emitted if mouse is hovered on top of set
51 51 Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series.
52 52 */
53 53
54 54 /*!
55 55 Constructs QBarSet with a name of \a name and with parent of \a parent
56 56 */
57 57 QBarSet::QBarSet(const QString name, QObject *parent)
58 58 : QObject(parent)
59 59 ,d_ptr(new QBarSetPrivate(name,this))
60 60 {
61 61 }
62 62
63 63 /*!
64 64 Destroys the barset
65 65 */
66 66 QBarSet::~QBarSet()
67 67 {
68 68 // NOTE: d_ptr destroyed by QObject
69 69 }
70 70
71 71 /*!
72 72 Sets new \a name for set.
73 73 */
74 74 void QBarSet::setName(const QString name)
75 75 {
76 76 d_ptr->m_name = name;
77 77 }
78 78
79 79 /*!
80 80 Returns name of the set.
81 81 */
82 82 QString QBarSet::name() const
83 83 {
84 84 return d_ptr->m_name;
85 85 }
86 86
87 87 /*!
88 88 Appends a point to set. Parameter \a value x coordinate defines the
89 89 position in x-axis and y coordinate defines the height of bar.
90 90 Depending on presentation (QBarSeries, QGroupedBarSeries, QStackedBarSeries, QPercentBarSeries)
91 91 the x values are used or ignored.
92 92 */
93 93 void QBarSet::append(const QPointF value)
94 94 {
95 95 d_ptr->m_values.append(value);
96 96 emit d_ptr->restructuredBars();
97 97 }
98 98
99 99 /*!
100 Appends a list of \a points to set. Works like append with single point.
100 Appends a list of \a values to set. Works like append with single point.
101 101 \sa append()
102 102 */
103 103 void QBarSet::append(const QList<QPointF> values)
104 104 {
105 105 for (int i=0; i<values.count(); i++) {
106 106 d_ptr->m_values.append(values.at(i));
107 107 }
108 108 emit d_ptr->restructuredBars();
109 109 }
110 110
111 111 /*!
112 112 Appends new value \a value to the end of set. Internally the value is converted to QPointF,
113 113 with x coordinate being the index of appended value and y coordinate is the value.
114 114 */
115 115 void QBarSet::append(const qreal value)
116 116 {
117 117 append(QPointF(d_ptr->m_values.count(), value));
118 118 }
119 119
120 120 /*!
121 121 Appends a list of reals to set. Works like append with single real value. The values in list
122 122 are converted to QPointF, where x coordinate is the index of point and y coordinate is the value.
123 123 \sa append()
124 124 */
125 125 void QBarSet::append(const QList<qreal> values)
126 126 {
127 127 int index = d_ptr->m_values.count();
128 128 for (int i=0; i<values.count(); i++) {
129 129 d_ptr->m_values.append(QPointF(index,values.at(i)));
130 130 index++;
131 131 }
132 132 emit d_ptr->restructuredBars();
133 133 }
134 134
135 135 /*!
136 136 Convinience operator. Same as append, with real \a value.
137 137 \sa append()
138 138 */
139 139 QBarSet& QBarSet::operator << (const qreal &value)
140 140 {
141 141 append(value);
142 142 return *this;
143 143 }
144 144
145 145 /*!
146 146 Convinience operator. Same as append, with QPointF \a value.
147 147 \sa append()
148 148 */
149 149 QBarSet& QBarSet::operator << (const QPointF &value)
150 150 {
151 151 append(value);
152 152 return *this;
153 153 }
154 154
155 155 /*!
156 156 Inserts new \a value on the \a index position.
157 157 The value that is currently at this postion is moved to postion index + 1
158 158 \sa remove()
159 159 */
160 160 void QBarSet::insert(const int index, const qreal value)
161 161 {
162 162 d_ptr->m_values.insert(index, QPointF(index, value));
163 163 // emit d_ptr->updatedBars();
164 164 }
165 165
166 166 /*!
167 167 Removes the value specified by \a index
168 168 \sa insert()
169 169 */
170 170 void QBarSet::remove(const int index)
171 171 {
172 172 d_ptr->m_values.removeAt(index);
173 173 // emit d_ptr->updatedBars();
174 174 }
175 175
176 176 /*!
177 177 Sets a new value \a value to set, indexed by \a index
178 178 */
179 179 void QBarSet::replace(const int index, const qreal value)
180 180 {
181 181 d_ptr->m_values.replace(index,QPointF(index,value));
182 182 emit d_ptr->updatedBars();
183 183 }
184 184
185 185 /*!
186 186 Returns value of set indexed by \a index. Note that all appended values are stored internally as QPointF.
187 187 The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value
188 188 of the QPointF (if appended with QPointF append).
189 189 If the index is out of bounds QPointF(0, 0.0) is returned.
190 190 */
191 191 QPointF QBarSet::at(const int index) const
192 192 {
193 193 if (index < 0 || index >= d_ptr->m_values.count()) {
194 194 return QPointF(index, 0.0);
195 195 }
196 196
197 197 return d_ptr->m_values.at(index);
198 198 }
199 199
200 200 /*!
201 201 Returns value of set indexed by \a index. ote that all appended values are stored internally as QPointF.
202 202 The returned QPointF has x coordinate, which is index (if appended with qreal append) or the x value
203 203 of the QPointF (if appended with QPointF append).
204 204 */
205 205 QPointF QBarSet::operator [](const int index) const
206 206 {
207 207 return d_ptr->m_values.at(index);
208 208 }
209 209
210 210 /*!
211 211 Returns count of values in set.
212 212 */
213 213 int QBarSet::count() const
214 214 {
215 215 return d_ptr->m_values.count();
216 216 }
217 217
218 218 /*!
219 219 Returns sum of all values in barset. The sum is sum of y coordinates in the QPointF representation.
220 220 */
221 221 qreal QBarSet::sum() const
222 222 {
223 223 qreal total(0);
224 224 for (int i=0; i < d_ptr->m_values.count(); i++) {
225 225 //total += d_ptr->m_values.at(i);
226 226 total += d_ptr->m_values.at(i).y();
227 227 }
228 228 return total;
229 229 }
230 230
231 231 /*!
232 232 Sets pen for set. Bars of this set are drawn using \a pen
233 233 */
234 234 void QBarSet::setPen(const QPen &pen)
235 235 {
236 236 if(d_ptr->m_pen!=pen){
237 237 d_ptr->m_pen = pen;
238 238 emit d_ptr->updatedBars();
239 239 }
240 240 }
241 241
242 242 /*!
243 243 Returns pen of the set.
244 244 */
245 245 QPen QBarSet::pen() const
246 246 {
247 247 return d_ptr->m_pen;
248 248 }
249 249
250 250 /*!
251 251 Sets brush for the set. Bars of this set are drawn using \a brush
252 252 */
253 253 void QBarSet::setBrush(const QBrush &brush)
254 254 {
255 255 if(d_ptr->m_brush!=brush){
256 256 d_ptr->m_brush = brush;
257 257 emit d_ptr->updatedBars();
258 258 }
259 259 }
260 260
261 261 /*!
262 262 Returns brush of the set.
263 263 */
264 264 QBrush QBarSet::brush() const
265 265 {
266 266 return d_ptr->m_brush;
267 267 }
268 268
269 269 /*!
270 270 Sets \a pen of the values that are drawn on top of this barset
271 271 */
272 272 void QBarSet::setLabelPen(const QPen &pen)
273 273 {
274 274 if(d_ptr->m_labelPen!=pen){
275 275 d_ptr->m_labelPen = pen;
276 276 emit d_ptr->updatedBars();
277 277 }
278 278 }
279 279
280 280 /*!
281 281 Returns pen of the values that are drawn on top of this barset
282 282 */
283 283 QPen QBarSet::labelPen() const
284 284 {
285 285 return d_ptr->m_labelPen;
286 286 }
287 287
288 288 /*!
289 289 Sets \a brush of the values that are drawn on top of this barset
290 290 */
291 291 void QBarSet::setLabelBrush(const QBrush &brush)
292 292 {
293 293 if(d_ptr->m_labelBrush!=brush){
294 294 d_ptr->m_labelBrush = brush;
295 295 emit d_ptr->updatedBars();
296 296 }
297 297 }
298 298
299 299 /*!
300 300 Returns brush of the values that are drawn on top of this barset
301 301 */
302 302 QBrush QBarSet::labelBrush() const
303 303 {
304 304 return d_ptr->m_labelBrush;
305 305 }
306 306
307 307 /*!
308 308 Sets the \a font for values that are drawn on top of this barset
309 309 */
310 310 void QBarSet::setLabelFont(const QFont &font)
311 311 {
312 312 if(d_ptr->m_labelFont!=font) {
313 313 d_ptr->m_labelFont = font;
314 314 emit d_ptr->updatedBars();
315 315 }
316 316
317 317 }
318 318
319 319 /*!
320 320 Returns the pen for values that are drawn on top of this set
321 321 */
322 322 QFont QBarSet::labelFont() const
323 323 {
324 324 return d_ptr->m_labelFont;
325 325 }
326 326
327 327 /*!
328 328 Sets visibility of bar labels. If \a visible is true, labels are drawn on top of barsets.
329 329 */
330 330
331 331 void QBarSet::setLabelsVisible(bool visible)
332 332 {
333 333 if(d_ptr->m_labelsVisible!=visible) {
334 334 d_ptr->m_labelsVisible = visible;
335 335 emit d_ptr->labelsVisibleChanged(visible);
336 336 }
337 337 }
338 338
339 339 /*!
340 340 Returns the visibility of values
341 341 */
342 342 bool QBarSet::labelsVisible() const
343 343 {
344 344 return d_ptr->m_labelsVisible;
345 345 }
346 346
347 347 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
348 348
349 349 QBarSetPrivate::QBarSetPrivate(const QString name, QBarSet *parent) : QObject(parent),
350 350 q_ptr(parent),
351 351 m_name(name),
352 352 m_labelsVisible(false)
353 353 {
354 354 }
355 355
356 356 QBarSetPrivate::~QBarSetPrivate()
357 357 {
358 358 }
359 359
360 360 #include "moc_qbarset.cpp"
361 361 #include "moc_qbarset_p.cpp"
362 362
363 363 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now