#ifndef PIESERIES_H #define PIESERIES_H #include "qseries.h" #include #include #include #include #include #include class QGraphicsObject; QTCOMMERCIALCHART_BEGIN_NAMESPACE class PiePresenter; class PieSlice; class QPieSlice; class QTCOMMERCIALCHART_EXPORT QPieSeries : public QSeries { Q_OBJECT public: enum PiePosition { PiePositionMaximized = 0, PiePositionTopLeft, PiePositionTopRight, PiePositionBottomLeft, PiePositionBottomRight }; class ChangeSet { public: // TODO: these should not really be exposed to the public API void appendAdded(QPieSlice* slice); void appendAdded(QList slices); void appendChanged(QPieSlice* slice); void appendRemoved(QPieSlice* slice); QList added() const; QList changed() const; QList removed() const; bool isEmpty() const; private: QList m_added; QList m_changed; QList m_removed; }; public: QPieSeries(QObject *parent = 0); virtual ~QPieSeries(); public: // from QChartSeries QSeriesType type() const; public: void replace(QList slices); void add(QList slices); void add(QPieSlice* slice); QPieSlice* add(qreal value, QString name); QPieSeries& operator << (QPieSlice* slice); void remove(QPieSlice* slice); void clear(); int count() const; QList slices() const; void setSizeFactor(qreal sizeFactor); qreal sizeFactor() const; void setPosition(PiePosition position); PiePosition position() const; void setSpan(qreal startAngle, qreal angleSpan); void setLabelsVisible(bool visible = true); void setClickExplodes(bool enable = true); void setHoverHighlighting(bool enable = true); qreal total() const; // TODO: find slices? // QList findByValue(qreal value); // ... // TODO: sorting slices? // void sort(QPieSeries::SortByValue|label|??) // TODO: general graphics customization // setDrawStyle(2d|3d) // setDropShadows(bool) Q_SIGNALS: void changed(const QPieSeries::ChangeSet& changeSet); void clicked(QPieSlice* slice); void hoverEnter(QPieSlice* slice); void hoverLeave(QPieSlice* slice); void sizeFactorChanged(); void positionChanged(); private Q_SLOTS: // TODO: should be private and not visible in the interface at all void sliceChanged(); void sliceClicked(); void sliceHoverEnter(); void sliceHoverLeave(); void toggleExploded(QPieSlice* slice); void highlightOn(QPieSlice* slice); void highlightOff(QPieSlice* slice); private: void updateDerivativeData(); private: Q_DISABLE_COPY(QPieSeries) // TODO: use PIML friend class PiePresenter; friend class PieSlice; QList m_slices; qreal m_sizeFactor; PiePosition m_position; qreal m_total; qreal m_pieStartAngle; qreal m_pieAngleSpan; }; QTCOMMERCIALCHART_END_NAMESPACE #endif // PIESERIES_H