diff --git a/examples/stackedbarchartdrilldown/drilldownchart.cpp b/examples/stackedbarchartdrilldown/drilldownchart.cpp index 870af4b..14405fa 100644 --- a/examples/stackedbarchartdrilldown/drilldownchart.cpp +++ b/examples/stackedbarchartdrilldown/drilldownchart.cpp @@ -40,7 +40,7 @@ void DrilldownChart::changeSeries(QAbstractSeries *series) axisY()->setNiceNumbersEnabled(true); } -void DrilldownChart::handleClicked(QBarSet *barset, QString category, Qt::MouseButtons button) +void DrilldownChart::handleClicked(QBarSet *barset, QString category) { Q_UNUSED(barset) Q_UNUSED(button) diff --git a/examples/stackedbarchartdrilldown/drilldownchart.h b/examples/stackedbarchartdrilldown/drilldownchart.h index 7a84f96..3011cd4 100644 --- a/examples/stackedbarchartdrilldown/drilldownchart.h +++ b/examples/stackedbarchartdrilldown/drilldownchart.h @@ -36,7 +36,7 @@ public: void changeSeries(QAbstractSeries *series); public Q_SLOTS: - void handleClicked(QBarSet *barset, QString category, Qt::MouseButtons button); + void handleClicked(QBarSet *barset, QString category); private: QAbstractSeries* m_currentSeries; diff --git a/examples/stackedbarchartdrilldown/main.cpp b/examples/stackedbarchartdrilldown/main.cpp index 4423ca2..6bcc6ea 100644 --- a/examples/stackedbarchartdrilldown/main.cpp +++ b/examples/stackedbarchartdrilldown/main.cpp @@ -70,11 +70,11 @@ int main(int argc, char *argv[]) } // Use right click signal to implement drilldown - QObject::connect(weeklySeries, SIGNAL(clicked(QBarSet*,QString,Qt::MouseButtons)), drilldownChart, SLOT(handleClicked(QBarSet*,QString,Qt::MouseButtons))); + QObject::connect(weeklySeries, SIGNAL(clicked(QBarSet*,QString)), drilldownChart, SLOT(handleClicked(QBarSet*,QString))); } // Enable drilldown from season series using right click. - QObject::connect(seasonSeries, SIGNAL(clicked(QBarSet*,QString,Qt::MouseButtons)), drilldownChart, SLOT(handleClicked(QBarSet*,QString,Qt::MouseButtons))); + QObject::connect(seasonSeries, SIGNAL(clicked(QBarSet*,QString)), drilldownChart, SLOT(handleClicked(QBarSet*,QString))); //! [4] //! [5] diff --git a/src/barchart/bar.cpp b/src/barchart/bar.cpp index e66e790..1576d0a 100644 --- a/src/barchart/bar.cpp +++ b/src/barchart/bar.cpp @@ -35,8 +35,8 @@ Bar::Bar(QBarSet *barset, QString category, QGraphicsItem *parent) : QGraphicsRe void Bar::mousePressEvent(QGraphicsSceneMouseEvent *event) { - emit clicked(m_category, event->button()); - emit clicked(m_barset, m_category, event->button()); + emit clicked(m_category); + emit clicked(m_barset, m_category); } void Bar::hoverEnterEvent(QGraphicsSceneHoverEvent *event) diff --git a/src/barchart/bar_p.h b/src/barchart/bar_p.h index 29ba46b..a49586c 100644 --- a/src/barchart/bar_p.h +++ b/src/barchart/bar_p.h @@ -41,8 +41,8 @@ public: void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); Q_SIGNALS: - void clicked(QString category, Qt::MouseButtons button); - void clicked(QBarSet *barset, QString category, Qt::MouseButtons button); + void clicked(QString category); + void clicked(QBarSet *barset, QString category); void hovered(bool status); void hovered(QBarSet *barset, bool status); diff --git a/src/barchart/barchartitem.cpp b/src/barchart/barchartitem.cpp index e482697..25f8720 100644 --- a/src/barchart/barchartitem.cpp +++ b/src/barchart/barchartitem.cpp @@ -80,8 +80,8 @@ void BarChartItem::dataChanged() QBarSet *set = m_series->d_func()->barsetAt(s); Bar *bar = new Bar(set,category,this); m_bars.append(bar); - connect(bar, SIGNAL(clicked(QString,Qt::MouseButtons)), set, SIGNAL(clicked(QString,Qt::MouseButtons))); - connect(bar, SIGNAL(clicked(QBarSet*,QString,Qt::MouseButtons)), m_series, SIGNAL(clicked(QBarSet*,QString,Qt::MouseButtons))); + connect(bar, SIGNAL(clicked(QString)), set, SIGNAL(clicked(QString))); + connect(bar, SIGNAL(clicked(QBarSet*,QString)), m_series, SIGNAL(clicked(QBarSet*,QString))); connect(bar, SIGNAL(hovered(bool)), set, SIGNAL(hovered(bool))); connect(bar, SIGNAL(hovered(QBarSet*,bool)), m_series, SIGNAL(hovered(QBarSet*,bool))); m_layout.append(QRectF(0, 0, 0, 0)); diff --git a/src/barchart/qbarseries.cpp b/src/barchart/qbarseries.cpp index 7b2b429..08eea91 100644 --- a/src/barchart/qbarseries.cpp +++ b/src/barchart/qbarseries.cpp @@ -49,20 +49,13 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! - \fn void QBarSeries::clicked(QBarSet *barset, QString category, Qt::MouseButtons button) + \fn void QBarSeries::clicked(QBarSet *barset, QString category) - The signal is emitted if the user clicks with a mouse \a button on top of QBarSet \a barset of category \a category + The signal is emitted if the user clicks with a mouse on top of QBarSet \a barset of category \a category contained by the series. */ /*! - \fn void QBarSeries::selected() - - The signal is emitted if the user selects/deselects the series. The logic for storing selections should be - implemented by the user of QBarSeries API. -*/ - -/*! \fn void QBarSeries::hovered(QBarSet* barset, bool status) The signal is emitted if mouse is hovered on top of series. @@ -105,58 +98,52 @@ QAbstractSeries::QSeriesType QBarSeries::type() const /*! Adds a set of bars to series. Takes ownership of \a set. - Connects the clicked(QString, Qt::MouseButtons) signal - of \a set to this series */ void QBarSeries::appendBarSet(QBarSet *set) { Q_D(QBarSeries); d->m_barSets.append(set); - QObject::connect(set->d_ptr.data(), SIGNAL(valueChanged()), d, SLOT(barsetChanged())); + QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), d, SLOT(barsetChanged())); emit d->restructuredBars(); } /*! Removes a set of bars from series. Releases ownership of \a set. Doesn't delete \a set. - Disconnects the clicked(QString, Qt::MouseButtons) signal - of \a set from this series */ void QBarSeries::removeBarSet(QBarSet *set) { Q_D(QBarSeries); if (d->m_barSets.contains(set)) { d->m_barSets.removeOne(set); + QObject::disconnect(set, SIGNAL(updatedBars()), this, SLOT(barsetChanged())); emit d->restructuredBars(); } } /*! Adds a list of barsets to series. Takes ownership of \a sets. - Connects the clicked(QString, Qt::MouseButtons) signals - of \a sets to this series */ void QBarSeries::appendBarSets(QList sets) { Q_D(QBarSeries); - foreach (QBarSet* barset, sets) { - d->m_barSets.append(barset); - QObject::connect(barset, SIGNAL(valueChanged()), this, SLOT(barsetChanged())); + foreach (QBarSet* set, sets) { + d->m_barSets.append(set); + QObject::connect(set, SIGNAL(updatedBars()), this, SLOT(barsetChanged())); } emit d->restructuredBars(); } /*! Removes a list of barsets from series. Releases ownership of \a sets. Doesn't delete \a sets. - Disconnects the clicked(QString, Qt::MouseButtons) signal - of \a sets from this series */ void QBarSeries::removeBarSets(QList sets) { Q_D(QBarSeries); - foreach (QBarSet* barset, sets) { - if (d->m_barSets.contains(barset)) { - d->m_barSets.removeOne(barset); + foreach (QBarSet* set, sets) { + if (d->m_barSets.contains(set)) { + d->m_barSets.removeOne(set); + QObject::disconnect(set, SIGNAL(updatedBars()), this, SLOT(barsetChanged())); } } emit d->restructuredBars(); diff --git a/src/barchart/qbarseries.h b/src/barchart/qbarseries.h index 1b9969d..b85124e 100644 --- a/src/barchart/qbarseries.h +++ b/src/barchart/qbarseries.h @@ -62,8 +62,7 @@ protected: explicit QBarSeries(QBarSeriesPrivate &d,QObject *parent = 0); Q_SIGNALS: - void clicked(QBarSet *barset, QString category, Qt::MouseButtons button); - void selected(); + void clicked(QBarSet *barset, QString category); void hovered(QBarSet* barset, bool status); protected: diff --git a/src/barchart/qbarseries_p.h b/src/barchart/qbarseries_p.h index c3a0b8e..c480773 100644 --- a/src/barchart/qbarseries_p.h +++ b/src/barchart/qbarseries_p.h @@ -35,8 +35,7 @@ public: qreal maxCategorySum(); Q_SIGNALS: - void clicked(QBarSet *barset, QString category, Qt::MouseButtons button); - void selected(); + void clicked(QBarSet *barset, QString category); void updatedBars(); void restructuredBars(); diff --git a/src/barchart/qbarset.cpp b/src/barchart/qbarset.cpp index f90f532..48ad461 100644 --- a/src/barchart/qbarset.cpp +++ b/src/barchart/qbarset.cpp @@ -38,15 +38,9 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! - \fn void QBarSet::clicked(QString category, Qt::MouseButtons button) + \fn void QBarSet::clicked(QString category) \brief signals that set has been clicked Parameter \a category describes on which category was clicked - Parameter \a button mouse button -*/ - -/*! - \fn void QBarSet::selected() - \brief signals that set has been selected */ /*! @@ -96,7 +90,7 @@ QString QBarSet::name() const void QBarSet::append(const qreal value) { d_ptr->m_values.append(value); - emit d_ptr->structureChanged(); + emit d_ptr->restructuredBars(); } /*! @@ -116,6 +110,7 @@ QBarSet& QBarSet::operator << (const qreal &value) void QBarSet::insert(const int index, const qreal value) { d_ptr->m_values.insert(index, value); + emit d_ptr->updatedBars(); } /*! @@ -125,6 +120,7 @@ void QBarSet::insert(const int index, const qreal value) void QBarSet::remove(const int index) { d_ptr->m_values.removeAt(index); + emit d_ptr->updatedBars(); } /*! @@ -133,7 +129,7 @@ void QBarSet::remove(const int index) void QBarSet::replace(const int index, const qreal value) { d_ptr->m_values.replace(index,value); - emit d_ptr->valueChanged(); + emit d_ptr->updatedBars(); } /*! @@ -179,7 +175,7 @@ void QBarSet::setPen(const QPen &pen) { if(d_ptr->m_pen!=pen){ d_ptr->m_pen = pen; - emit d_ptr->valueChanged(); + emit d_ptr->updatedBars(); } } @@ -198,7 +194,7 @@ void QBarSet::setBrush(const QBrush &brush) { if(d_ptr->m_brush!=brush){ d_ptr->m_brush = brush; - emit d_ptr->valueChanged(); + emit d_ptr->updatedBars(); } } @@ -217,7 +213,7 @@ void QBarSet::setLabelPen(const QPen &pen) { if(d_ptr->m_labelPen!=pen){ d_ptr->m_labelPen = pen; - emit d_ptr->valueChanged(); + emit d_ptr->updatedBars(); } } @@ -236,7 +232,7 @@ void QBarSet::setLabelBrush(const QBrush &brush) { if(d_ptr->m_labelBrush!=brush){ d_ptr->m_labelBrush = brush; - emit d_ptr->valueChanged(); + emit d_ptr->updatedBars(); } } @@ -255,7 +251,7 @@ void QBarSet::setLabelFont(const QFont &font) { if(d_ptr->m_labelFont!=font) { d_ptr->m_labelFont = font; - emit d_ptr->valueChanged(); + emit d_ptr->updatedBars(); } } diff --git a/src/barchart/qbarset.h b/src/barchart/qbarset.h index 8aa3f25..135c21a 100644 --- a/src/barchart/qbarset.h +++ b/src/barchart/qbarset.h @@ -68,8 +68,7 @@ public: bool labelsVisible() const; Q_SIGNALS: - void clicked(QString category, Qt::MouseButtons button); - void selected(); + void clicked(QString category); void hovered(bool status); private: diff --git a/src/barchart/qbarset_p.h b/src/barchart/qbarset_p.h index cc1a745..ac738b8 100644 --- a/src/barchart/qbarset_p.h +++ b/src/barchart/qbarset_p.h @@ -15,9 +15,9 @@ public: ~QBarSetPrivate(); Q_SIGNALS: - void clicked(QString category, Qt::MouseButtons button); - void structureChanged(); - void valueChanged(); + void clicked(QString category); + void restructuredBars(); + void updatedBars(); void labelsVisibleChanged(bool visible); public: diff --git a/src/legend/legendmarker.cpp b/src/legend/legendmarker.cpp index 2302f85..fbf9ec6 100644 --- a/src/legend/legendmarker.cpp +++ b/src/legend/legendmarker.cpp @@ -139,7 +139,7 @@ BarLegendMarker::BarLegendMarker(QBarSeries *barseries,QBarSet *barset, QLegend m_barset(barset) { QObject::connect(this, SIGNAL(selected()),barseries, SIGNAL(selected())); - QObject::connect(barset->d_ptr.data(), SIGNAL(valueChanged()), this, SLOT(updated())); + QObject::connect(barset->d_ptr.data(), SIGNAL(updatedBars()), this, SLOT(updated())); updated(); }