##// END OF EJS Templates
QML BarSeries added/removed signals
Tero Ahola -
r1506:1adeb672d1e0
parent child
Show More
@@ -62,6 +62,24 void DeclarativeBarSet::setValues(QVariantList values)
62 62 DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) :
63 63 QBarSeries(parent)
64 64 {
65 connect(this, SIGNAL(barsetsAdded(QList<QBarSet*>)), this, SLOT(handleAdded(QList<QBarSet*>)));
66 connect(this, SIGNAL(barsetsRemoved(QList<QBarSet*>)), this, SLOT(handleRemoved(QList<QBarSet*>)));
67 }
68
69 void DeclarativeBarSeries::handleAdded(QList<QBarSet* > barsets)
70 {
71 foreach(QBarSet *b, barsets) {
72 DeclarativeBarSet *barset = qobject_cast<DeclarativeBarSet *>(b);
73 emit added(barset);
74 }
75 }
76
77 void DeclarativeBarSeries::handleRemoved(QList<QBarSet* > barsets)
78 {
79 foreach(QBarSet *b, barsets) {
80 DeclarativeBarSet *barset = qobject_cast<DeclarativeBarSet *>(b);
81 emit removed(barset);
82 }
65 83 }
66 84
67 85 void DeclarativeBarSeries::classBegin()
@@ -71,8 +71,14 public: // from QDeclarativeParserStatus
71 71 void classBegin();
72 72 void componentComplete();
73 73
74 Q_SIGNALS:
75 void added(DeclarativeBarSet *barset);
76 void removed(DeclarativeBarSet *barset);
77
74 78 public Q_SLOTS:
75 79 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
80 void handleAdded(QList<QBarSet* > barsets);
81 void handleRemoved(QList<QBarSet* > barsets);
76 82 };
77 83
78 84 class DeclarativeGroupedBarSeries : public QGroupedBarSeries, public QDeclarativeParserStatus
@@ -139,12 +139,20 QTCOMMERCIALCHART_BEGIN_NAMESPACE
139 139 This signal is emitted when \a sets have been added to the series.
140 140 \sa append(), insert()
141 141 */
142 /*!
143 \qmlsignal BarSeries::added(BarSet barset)
144 Emitted when \a barset has been added to the series.
145 */
142 146
143 147 /*!
144 148 \fn void QBarSeries::barsetsRemoved(QList<QBarSet*> sets)
145 149 This signal is emitted when \a sets have been removed from the series.
146 150 \sa remove()
147 151 */
152 /*!
153 \qmlsignal BarSeries::removed(BarSet barset)
154 Emitted when \a barset has been removed from the series.
155 */
148 156
149 157 /*!
150 158 Constructs empty QBarSeries.
@@ -50,5 +50,9 ChartView {
50 50 onHovered: console.log("barSeries.onHovered: " + barset + " " + status);
51 51 onLabelsVisibleChanged: console.log("barSeries.onLabelsVisibleChanged: " + series.labelsVisible);
52 52 onCountChanged: console.log("barSeries.onCountChanged: " + count);
53 onBarsetsAdded: console.log("barSeries.onBarsetsAdded: " + sets); // There is no point in this signal on QML side
54 onAdded: console.log("barSeries.onBarsetAdded: " + barset);
55 onBarsetsRemoved: console.log("barSeries.onBarsetsRemoved: " + sets); // There is no point in this signal on QML side
56 onRemoved: console.log("barSeries.onBarsetRemoved: " + barset);
53 57 }
54 58 }
@@ -44,6 +44,10 Flow {
44 44 onClicked: series.barWidth -= 0.1;
45 45 }
46 46 Button {
47 text: "remove set"
48 onClicked: series.remove(series.count - 1);
49 }
50 Button {
47 51 text: "set 1 color"
48 52 onClicked: series.at(0).color = main.nextColor();
49 53 }
General Comments 0
You need to be logged in to leave comments. Login now