qpieseries.h
134 lines
| 3.0 KiB
| text/x-c
|
CLexer
|
r142 | #ifndef PIESERIES_H | ||
#define PIESERIES_H | ||||
|
r360 | #include "qseries.h" | ||
|
r142 | #include <QObject> | ||
#include <QRectF> | ||||
#include <QColor> | ||||
|
r174 | #include <QPen> | ||
#include <QBrush> | ||||
|
r203 | #include <QSignalMapper> | ||
|
r142 | |||
class QGraphicsObject; | ||||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
|
r146 | class PiePresenter; | ||
|
r142 | class PieSlice; | ||
|
r203 | class QPieSlice; | ||
|
r157 | |||
|
r360 | class QTCOMMERCIALCHART_EXPORT QPieSeries : public QSeries | ||
|
r142 | { | ||
Q_OBJECT | ||||
public: | ||||
|
r437 | |||
|
r174 | class ChangeSet | ||
{ | ||||
public: | ||||
|
r314 | |||
// TODO: these should not really be exposed to the public API | ||||
|
r203 | void appendAdded(QPieSlice* slice); | ||
|
r289 | void appendAdded(QList<QPieSlice*> slices); | ||
|
r203 | void appendChanged(QPieSlice* slice); | ||
void appendRemoved(QPieSlice* slice); | ||||
QList<QPieSlice*> added() const; | ||||
QList<QPieSlice*> changed() const; | ||||
QList<QPieSlice*> removed() const; | ||||
bool isEmpty() const; | ||||
private: | ||||
QList<QPieSlice*> m_added; | ||||
QList<QPieSlice*> m_changed; | ||||
QList<QPieSlice*> m_removed; | ||||
|
r174 | }; | ||
|
r142 | public: | ||
QPieSeries(QObject *parent = 0); | ||||
|
r203 | virtual ~QPieSeries(); | ||
|
r142 | |||
public: // from QChartSeries | ||||
|
r360 | QSeriesType type() const; | ||
|
r142 | |||
public: | ||||
|
r437 | |||
// slice setters | ||||
|
r203 | void add(QPieSlice* slice); | ||
|
r437 | void add(QList<QPieSlice*> slices); | ||
void replace(QList<QPieSlice*> slices); | ||||
|
r203 | void remove(QPieSlice* slice); | ||
void clear(); | ||||
|
r142 | |||
|
r437 | // sluce getters | ||
|
r314 | QList<QPieSlice*> slices() const; | ||
|
r174 | |||
|
r437 | // calculated data | ||
int count() const; | ||||
qreal total() const; | ||||
// pie customization | ||||
|
r454 | void setPositionFactors(qreal horizontalFactor, qreal verticalFactor); | ||
qreal horizontalPositionFactor() const; | ||||
qreal verticalPositionFactor() const; | ||||
|
r437 | void setSizeFactor(qreal sizeFactor); | ||
qreal sizeFactor() const; | ||||
void setStartAngle(qreal startAngle); | ||||
qreal startAngle() const; | ||||
void setEndAngle(qreal endAngle); | ||||
qreal endAngle() const; | ||||
|
r203 | |||
|
r437 | // convenience function | ||
QPieSeries& operator << (QPieSlice* slice); | ||||
QPieSlice* add(qreal value, QString name); | ||||
|
r386 | void setLabelsVisible(bool visible = true); | ||
|
r203 | |||
|
r289 | // TODO: find slices? | ||
// QList<QPieSlice*> findByValue(qreal value); | ||||
// ... | ||||
// TODO: sorting slices? | ||||
// void sort(QPieSeries::SortByValue|label|??) | ||||
// TODO: general graphics customization | ||||
// setDrawStyle(2d|3d) | ||||
|
r437 | // setDropShadows | ||
|
r289 | |||
|
r157 | Q_SIGNALS: | ||
|
r437 | |||
|
r174 | void changed(const QPieSeries::ChangeSet& changeSet); | ||
|
r437 | |||
|
r203 | void clicked(QPieSlice* slice); | ||
void hoverEnter(QPieSlice* slice); | ||||
void hoverLeave(QPieSlice* slice); | ||||
|
r437 | |||
|
r157 | void sizeFactorChanged(); | ||
void positionChanged(); | ||||
|
r181 | |||
|
r289 | private Q_SLOTS: // TODO: should be private and not visible in the interface at all | ||
|
r203 | void sliceChanged(); | ||
void sliceClicked(); | ||||
void sliceHoverEnter(); | ||||
void sliceHoverLeave(); | ||||
|
r174 | |||
private: | ||||
void updateDerivativeData(); | ||||
|
r157 | |||
|
r142 | private: | ||
Q_DISABLE_COPY(QPieSeries) | ||||
|
r174 | |||
|
r142 | // TODO: use PIML | ||
|
r174 | friend class PiePresenter; | ||
friend class PieSlice; | ||||
|
r203 | QList<QPieSlice*> m_slices; | ||
|
r454 | qreal m_hPositionFactor; | ||
qreal m_vPositionFactor; | ||||
qreal m_pieSizeFactor; | ||||
|
r203 | qreal m_pieStartAngle; | ||
|
r437 | qreal m_pieEndAngle; | ||
|
r454 | qreal m_total; | ||
|
r142 | }; | ||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
#endif // PIESERIES_H | ||||