qpieseries.h
127 lines
| 3.0 KiB
| text/x-c
|
CLexer
Jani Honkonen
|
r142 | #ifndef PIESERIES_H | ||
#define PIESERIES_H | ||||
#include "qchartseries.h" | ||||
#include <QObject> | ||||
#include <QRectF> | ||||
#include <QColor> | ||||
Jani Honkonen
|
r174 | #include <QPen> | ||
#include <QBrush> | ||||
Jani Honkonen
|
r203 | #include <QSignalMapper> | ||
Jani Honkonen
|
r142 | |||
class QGraphicsObject; | ||||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
Jani Honkonen
|
r146 | class PiePresenter; | ||
Jani Honkonen
|
r142 | class PieSlice; | ||
Jani Honkonen
|
r203 | class QPieSlice; | ||
Jani Honkonen
|
r157 | |||
Jani Honkonen
|
r142 | class QTCOMMERCIALCHART_EXPORT QPieSeries : public QChartSeries | ||
{ | ||||
Q_OBJECT | ||||
public: | ||||
enum PiePosition { | ||||
PiePositionMaximized = 0, | ||||
PiePositionTopLeft, | ||||
PiePositionTopRight, | ||||
PiePositionBottomLeft, | ||||
PiePositionBottomRight | ||||
}; | ||||
Jani Honkonen
|
r174 | class ChangeSet | ||
{ | ||||
public: | ||||
Jani Honkonen
|
r203 | void appendAdded(QPieSlice* slice); | ||
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; | ||||
Jani Honkonen
|
r174 | }; | ||
Jani Honkonen
|
r142 | public: | ||
QPieSeries(QObject *parent = 0); | ||||
Jani Honkonen
|
r203 | virtual ~QPieSeries(); | ||
Jani Honkonen
|
r142 | |||
public: // from QChartSeries | ||||
QChartSeriesType type() const { return QChartSeries::SeriesTypePie; } | ||||
Jani Honkonen
|
r174 | virtual bool setData(QList<qreal> data); // TODO: remove this | ||
Jani Honkonen
|
r142 | |||
public: | ||||
Jani Honkonen
|
r203 | void set(QList<QPieSlice*> slices); | ||
void add(QList<QPieSlice*> slices); | ||||
void add(QPieSlice* slice); | ||||
QPieSlice* add(qreal value, QString name); | ||||
void remove(QPieSlice* slice); | ||||
void clear(); | ||||
Jani Honkonen
|
r142 | |||
int count() const { return m_slices.count(); } | ||||
Jani Honkonen
|
r203 | QList<QPieSlice*> slices() const { return m_slices; } | ||
Jani Honkonen
|
r174 | |||
Jani Honkonen
|
r203 | // TODO: find slices? | ||
// QList<QPieSlice*> findByValue(qreal value); | ||||
// ... | ||||
Jani Honkonen
|
r142 | |||
Jani Honkonen
|
r203 | // TODO: sorting slices? | ||
// void sort(QPieSeries::SortByValue) | ||||
Jani Honkonen
|
r174 | |||
Jani Honkonen
|
r142 | void setSizeFactor(qreal sizeFactor); | ||
qreal sizeFactor() const { return m_sizeFactor; } | ||||
void setPosition(PiePosition position); | ||||
PiePosition position() const { return m_position; } | ||||
Jani Honkonen
|
r203 | void setSpan(qreal startAngle, qreal span); | ||
void setLabelsVisible(bool visible); | ||||
void enableClickExplodes(bool enable); | ||||
void enableHoverHighlight(bool enable); | ||||
Jani Honkonen
|
r157 | Q_SIGNALS: | ||
Jani Honkonen
|
r174 | void changed(const QPieSeries::ChangeSet& changeSet); | ||
Jani Honkonen
|
r203 | void clicked(QPieSlice* slice); | ||
void hoverEnter(QPieSlice* slice); | ||||
void hoverLeave(QPieSlice* slice); | ||||
Jani Honkonen
|
r157 | void sizeFactorChanged(); | ||
void positionChanged(); | ||||
Jani Honkonen
|
r181 | |||
Jani Honkonen
|
r203 | private Q_SLOTS: // should be private and not in the interface | ||
void sliceChanged(); | ||||
void sliceClicked(); | ||||
void sliceHoverEnter(); | ||||
void sliceHoverLeave(); | ||||
void toggleExploded(QPieSlice* slice); | ||||
void highlightOn(QPieSlice* slice); | ||||
void highlightOff(QPieSlice* slice); | ||||
Jani Honkonen
|
r174 | |||
private: | ||||
void updateDerivativeData(); | ||||
Jani Honkonen
|
r157 | |||
Jani Honkonen
|
r142 | private: | ||
Q_DISABLE_COPY(QPieSeries) | ||||
Jani Honkonen
|
r174 | |||
Jani Honkonen
|
r142 | // TODO: use PIML | ||
Jani Honkonen
|
r174 | friend class PiePresenter; | ||
friend class PieSlice; | ||||
Jani Honkonen
|
r203 | QList<QPieSlice*> m_slices; | ||
Jani Honkonen
|
r142 | qreal m_sizeFactor; | ||
PiePosition m_position; | ||||
Jani Honkonen
|
r174 | qreal m_total; | ||
Jani Honkonen
|
r203 | qreal m_pieStartAngle; | ||
qreal m_pieSpan; | ||||
Jani Honkonen
|
r142 | }; | ||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
#endif // PIESERIES_H | ||||