From b334955b5e361939895466d1555159720b7ed495 2012-03-02 14:47:02 From: Jani Honkonen Date: 2012-03-02 14:47:02 Subject: [PATCH] Remove click exploding and hover highlighting from pie series API. User should always implement their own. --- diff --git a/example/piechart/main.cpp b/example/piechart/main.cpp index 95b7eec..d33c198 100644 --- a/example/piechart/main.cpp +++ b/example/piechart/main.cpp @@ -25,11 +25,6 @@ int main(int argc, char *argv[]) chartView->addSeries(series); //! [1] - //! [2] - series->setHoverHighlighting(); - series->setClickExplodes(); - //! [2] - window.setCentralWidget(chartView); window.resize(600, 600); window.show(); diff --git a/example/piechartdrilldown/main.cpp b/example/piechartdrilldown/main.cpp index 7a2fcb4..3bfadb7 100644 --- a/example/piechartdrilldown/main.cpp +++ b/example/piechartdrilldown/main.cpp @@ -79,7 +79,6 @@ int main(int argc, char *argv[]) QPieSeries* yearSeries = new QPieSeries(drilldownChart); yearSeries->setTitle("Sales by year - All"); - yearSeries->setHoverHighlighting(); QList months; months << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec"; @@ -89,7 +88,6 @@ int main(int argc, char *argv[]) foreach (QString name, names) { QPieSeries* series = new QPieSeries(drilldownChart); series->setTitle("Sales by month - " + name); - series->setHoverHighlighting(); foreach (QString month, months) *series << new DrilldownSlice(qrand() % 1000, month, yearSeries); diff --git a/src/piechart/qpieseries.cpp b/src/piechart/qpieseries.cpp index 5e0802d..8922cdb 100644 --- a/src/piechart/qpieseries.cpp +++ b/src/piechart/qpieseries.cpp @@ -110,9 +110,6 @@ bool QPieSeries::ChangeSet::isEmpty() const By default the pie is defined as a full pie but it can be a partial pie. This can be done by setting a starting angle and angle span to the series. - - To help with the most common user interaction scenarions there some convenience functions. - Like exploding a slice when clicked and higlighting when user hovers over a slice. */ /*! @@ -341,36 +338,6 @@ void QPieSeries::setLabelsVisible(bool visible) } /*! - Convenience method for exploding a slice when user clicks the pie. Set \a enable to true to - explode slices by clicking. - - \sa QPieSlice::isExploded(), QPieSlice::setExploded(), QPieSlice::setExplodeDistance() -*/ -void QPieSeries::setClickExplodes(bool enable) -{ - if (enable) - connect(this, SIGNAL(clicked(QPieSlice*)), this, SLOT(toggleExploded(QPieSlice*))); - else - disconnect(this, SLOT(toggleExploded(QPieSlice*))); -} - -/*! - Convenience method for highlighting a slice when user hovers over the slice. - It changes the slice color to be lighter and shows the label of the slice. - Set \a enable to true to highlight a slice when user hovers on top of it. -*/ -void QPieSeries::setHoverHighlighting(bool enable) -{ - if (enable) { - connect(this, SIGNAL(hoverEnter(QPieSlice*)), this, SLOT(highlightOn(QPieSlice*))); - connect(this, SIGNAL(hoverLeave(QPieSlice*)), this, SLOT(highlightOff(QPieSlice*))); - } else { - disconnect(this, SLOT(hoverEnter(QPieSlice*))); - disconnect(this, SLOT(hoverLeave(QPieSlice*))); - } -} - -/*! Returns the sum of all slice values in this series. \sa QPieSlice::value(), QPieSlice::setValue() @@ -462,26 +429,6 @@ void QPieSeries::sliceHoverLeave() emit hoverLeave(slice); } -void QPieSeries::toggleExploded(QPieSlice* slice) -{ - Q_ASSERT(slice); - slice->setExploded(!slice->isExploded()); -} - -void QPieSeries::highlightOn(QPieSlice* slice) -{ - Q_ASSERT(slice); - QColor c = slice->brush().color().lighter(); - slice->setBrush(c); -} - -void QPieSeries::highlightOff(QPieSlice* slice) -{ - Q_ASSERT(slice); - QColor c = slice->brush().color().darker(150); - slice->setBrush(c); -} - void QPieSeries::updateDerivativeData() { m_total = 0; diff --git a/src/piechart/qpieseries.h b/src/piechart/qpieseries.h index 96bd797..dff1be2 100644 --- a/src/piechart/qpieseries.h +++ b/src/piechart/qpieseries.h @@ -76,8 +76,6 @@ public: void setSpan(qreal startAngle, qreal angleSpan); void setLabelsVisible(bool visible = true); - void setClickExplodes(bool enable = true); - void setHoverHighlighting(bool enable = true); qreal total() const; @@ -105,9 +103,6 @@ private Q_SLOTS: // TODO: should be private and not visible in the interface at void sliceClicked(); void sliceHoverEnter(); void sliceHoverLeave(); - void toggleExploded(QPieSlice* slice); - void highlightOn(QPieSlice* slice); - void highlightOff(QPieSlice* slice); private: void updateDerivativeData(); diff --git a/src/piechart/qpieslice.cpp b/src/piechart/qpieslice.cpp index 600fe27..b42cf75 100644 --- a/src/piechart/qpieslice.cpp +++ b/src/piechart/qpieslice.cpp @@ -284,7 +284,7 @@ void QPieSlice::setLabelVisible(bool visible) /*! Sets this slice \a exploded. - \sa isExploded(), setExplodeDistance(), QPieSeries::setClickExplodes() + \sa isExploded(), setExplodeDistance() */ void QPieSlice::setExploded(bool exploded) { @@ -297,7 +297,7 @@ void QPieSlice::setExploded(bool exploded) /*! Sets the explosion \a distance of this slice. It is the distance the slice is moved away from the pie center. - \sa explodeDistance(), isExploded(), QPieSeries::setClickExplodes() + \sa explodeDistance(), isExploded() */ void QPieSlice::setExplodeDistance(qreal distance) {