##// END OF EJS Templates
Added insert method to QBarSeries
Marek Rosa -
r1362:978d41b59ab7
parent child
Show More
@@ -25,7 +25,7
25 series->add(0, 6);
25 series->add(0, 6);
26 series->add(2, 4);
26 series->add(2, 4);
27 ...
27 ...
28 chartView->addSeries(series);
28 chart->addSeries(series);
29 \endcode
29 \endcode
30
30
31 \raw HTML
31 \raw HTML
@@ -88,7 +88,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
88
88
89 This signal is emitted when labels visibility have changed.
89 This signal is emitted when labels visibility have changed.
90
90
91 \sa labelsVisible(), setLabelsVisible()
91 \sa isLabelsVisible(), setLabelsVisible()
92 */
92 */
93
93
94 /*!
94 /*!
@@ -225,6 +225,23 bool QBarSeries::remove(QList<QBarSet* > sets)
225 }
225 }
226
226
227 /*!
227 /*!
228 Insert a set of bars to series at \a index postion. Takes ownership of \a set. If the set is null or is already in series, it won't be appended.
229 Returns true, if inserting succeeded.
230
231 */
232 bool QBarSeries::insert(int index, QBarSet *set)
233 {
234 Q_D(QBarSeries);
235 bool success = d->insert(index, set);
236 if (success) {
237 QList<QBarSet*> sets;
238 sets.append(set);
239 emit barsetsAdded(sets);
240 }
241 return success;
242 }
243
244 /*!
228 Removes all of the bar sets from the series
245 Removes all of the bar sets from the series
229 */
246 */
230 void QBarSeries::clear()
247 void QBarSeries::clear()
@@ -266,7 +283,7 void QBarSeries::setLabelsVisible(bool visible)
266 /*!
283 /*!
267 Returns the visibility of labels
284 Returns the visibility of labels
268 */
285 */
269 bool QBarSeries::labelsVisible() const
286 bool QBarSeries::isLabelsVisible() const
270 {
287 {
271 Q_D(const QBarSeries);
288 Q_D(const QBarSeries);
272 return d->m_labelsVisible;
289 return d->m_labelsVisible;
@@ -610,6 +627,23 bool QBarSeriesPrivate::remove(QList<QBarSet* > sets)
610 return true;
627 return true;
611 }
628 }
612
629
630 bool QBarSeriesPrivate::insert(int index, QBarSet *set)
631 {
632 Q_Q(QBarSeries);
633 if ((m_barSets.contains(set)) || (set == 0)) {
634 // Fail if set is already in list or set is null.
635 return false;
636 }
637 m_barSets.insert(index, set);
638 QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SIGNAL(updatedBars()));
639 QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBars()), this, SIGNAL(restructuredBars()));
640 if (m_dataset) {
641 m_dataset->updateSeries(q); // this notifies legend
642 }
643 emit restructuredBars(); // this notifies barchartitem
644 return true;
645 }
646
613 #include "moc_qbarseries.cpp"
647 #include "moc_qbarseries.cpp"
614 #include "moc_qbarseries_p.cpp"
648 #include "moc_qbarseries_p.cpp"
615
649
@@ -35,7 +35,7 class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractSeries
35 Q_OBJECT
35 Q_OBJECT
36 Q_PROPERTY(qreal barMargin READ barMargin WRITE setBarMargin)
36 Q_PROPERTY(qreal barMargin READ barMargin WRITE setBarMargin)
37 Q_PROPERTY(int count READ barsetCount)
37 Q_PROPERTY(int count READ barsetCount)
38 Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible)
38 Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible)
39
39
40 public:
40 public:
41 explicit QBarSeries(QObject *parent = 0);
41 explicit QBarSeries(QObject *parent = 0);
@@ -50,12 +50,13 public:
50 bool remove(QBarSet *set);
50 bool remove(QBarSet *set);
51 bool append(QList<QBarSet* > sets);
51 bool append(QList<QBarSet* > sets);
52 bool remove(QList<QBarSet* > sets);
52 bool remove(QList<QBarSet* > sets);
53 bool insert(int index, QBarSet *set);
53 int barsetCount() const;
54 int barsetCount() const;
54 QList<QBarSet*> barSets() const;
55 QList<QBarSet*> barSets() const;
55 void clear();
56 void clear();
56
57
57 void setLabelsVisible(bool visible = true);
58 void setLabelsVisible(bool visible = true);
58 bool labelsVisible() const;
59 bool isLabelsVisible() const;
59
60
60 protected:
61 protected:
61 explicit QBarSeries(QBarSeriesPrivate &d,QObject *parent = 0);
62 explicit QBarSeries(QBarSeriesPrivate &d,QObject *parent = 0);
@@ -65,6 +65,7 public:
65 bool remove(QBarSet *set);
65 bool remove(QBarSet *set);
66 bool append(QList<QBarSet* > sets);
66 bool append(QList<QBarSet* > sets);
67 bool remove(QList<QBarSet* > sets);
67 bool remove(QList<QBarSet* > sets);
68 bool insert(int index, QBarSet *set);
68
69
69 QBarSet* barsetAt(int index);
70 QBarSet* barsetAt(int index);
70 QString categoryName(int category);
71 QString categoryName(int category);
General Comments 0
You need to be logged in to leave comments. Login now