qpieseries.h
143 lines
| 3.5 KiB
| text/x-c
|
CLexer
Jani Honkonen
|
r142 | #ifndef PIESERIES_H | ||
#define PIESERIES_H | ||||
Michal Klocek
|
r360 | #include "qseries.h" | ||
Jani Honkonen
|
r142 | #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
|
r568 | class PieChartItem; | ||
Jani Honkonen
|
r142 | class PieSlice; | ||
Jani Honkonen
|
r203 | class QPieSlice; | ||
Jani Honkonen
|
r157 | |||
Michal Klocek
|
r360 | class QTCOMMERCIALCHART_EXPORT QPieSeries : public QSeries | ||
Jani Honkonen
|
r142 | { | ||
Q_OBJECT | ||||
public: | ||||
Jani Honkonen
|
r437 | |||
Jani Honkonen
|
r174 | class ChangeSet | ||
{ | ||||
public: | ||||
Jani Honkonen
|
r314 | |||
// TODO: these should not really be exposed to the public API | ||||
Jani Honkonen
|
r203 | void appendAdded(QPieSlice* slice); | ||
Jani Honkonen
|
r289 | void appendAdded(QList<QPieSlice*> slices); | ||
Jani Honkonen
|
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; | ||||
Jani Honkonen
|
r174 | }; | ||
Jani Honkonen
|
r142 | public: | ||
QPieSeries(QObject *parent = 0); | ||||
Jani Honkonen
|
r203 | virtual ~QPieSeries(); | ||
Jani Honkonen
|
r142 | |||
public: // from QChartSeries | ||||
Michal Klocek
|
r360 | QSeriesType type() const; | ||
Jani Honkonen
|
r142 | |||
public: | ||||
Jani Honkonen
|
r437 | |||
// slice setters | ||||
Jani Honkonen
|
r203 | void add(QPieSlice* slice); | ||
Jani Honkonen
|
r437 | void add(QList<QPieSlice*> slices); | ||
void replace(QList<QPieSlice*> slices); | ||||
Jani Honkonen
|
r203 | void remove(QPieSlice* slice); | ||
void clear(); | ||||
Jani Honkonen
|
r142 | |||
Jani Honkonen
|
r437 | // sluce getters | ||
Jani Honkonen
|
r314 | QList<QPieSlice*> slices() const; | ||
Jani Honkonen
|
r174 | |||
Jani Honkonen
|
r437 | // calculated data | ||
int count() const; | ||||
qreal total() const; | ||||
// pie customization | ||||
Jani Honkonen
|
r498 | void setPiePosition(qreal relativeHorizontalPosition, qreal relativeVerticalPosition); | ||
qreal pieHorizontalPosition() const; | ||||
qreal pieVerticalPosition() const; | ||||
void setPieSize(qreal relativeSize); | ||||
qreal pieSize() const; | ||||
void setPieStartAngle(qreal startAngle); | ||||
qreal pieStartAngle() const; | ||||
void setPieEndAngle(qreal endAngle); | ||||
qreal pieEndAngle() const; | ||||
Jani Honkonen
|
r203 | |||
Jani Honkonen
|
r437 | // convenience function | ||
QPieSeries& operator << (QPieSlice* slice); | ||||
QPieSlice* add(qreal value, QString name); | ||||
Jani Honkonen
|
r386 | void setLabelsVisible(bool visible = true); | ||
Jani Honkonen
|
r203 | |||
Marek Rosa
|
r597 | // data from model | ||
bool setModel(QAbstractItemModel* model); | ||||
void setModelMapping(int modelValuesLine, int modelLabelsLine, Qt::Orientation orientation = Qt::Vertical); | ||||
Jani Honkonen
|
r289 | // TODO: find slices? | ||
// QList<QPieSlice*> findByValue(qreal value); | ||||
// ... | ||||
// TODO: sorting slices? | ||||
// void sort(QPieSeries::SortByValue|label|??) | ||||
// TODO: general graphics customization | ||||
// setDrawStyle(2d|3d) | ||||
Jani Honkonen
|
r437 | // setDropShadows | ||
Jani Honkonen
|
r289 | |||
Jani Honkonen
|
r157 | Q_SIGNALS: | ||
Jani Honkonen
|
r203 | void clicked(QPieSlice* slice); | ||
void hoverEnter(QPieSlice* slice); | ||||
void hoverLeave(QPieSlice* slice); | ||||
Jani Honkonen
|
r566 | void changed(); // TODO: hide this in PIMPL | ||
Jani Honkonen
|
r181 | |||
Jani Honkonen
|
r289 | private Q_SLOTS: // TODO: should be private and not visible in the interface at all | ||
Jani Honkonen
|
r203 | void sliceChanged(); | ||
void sliceClicked(); | ||||
void sliceHoverEnter(); | ||||
void sliceHoverLeave(); | ||||
Jani Honkonen
|
r174 | |||
Marek Rosa
|
r597 | // slots for updating pie when data in model changes | ||
void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); | ||||
void modelDataAdded(QModelIndex parent, int start, int end); | ||||
void modelDataRemoved(QModelIndex parent, int start, int end); | ||||
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
|
r568 | friend class PieChartItem; | ||
Jani Honkonen
|
r174 | friend class PieSlice; | ||
Jani Honkonen
|
r203 | QList<QPieSlice*> m_slices; | ||
Jani Honkonen
|
r498 | qreal m_pieRelativeHorPos; | ||
qreal m_pieRelativeVerPos; | ||||
qreal m_pieRelativeSize; | ||||
Jani Honkonen
|
r203 | qreal m_pieStartAngle; | ||
Jani Honkonen
|
r437 | qreal m_pieEndAngle; | ||
Jani Honkonen
|
r454 | qreal m_total; | ||
Marek Rosa
|
r597 | |||
// model map | ||||
int m_mapValues; | ||||
int m_mapLabels; | ||||
Qt::Orientation m_mapOrientation; | ||||
Jani Honkonen
|
r142 | }; | ||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
#endif // PIESERIES_H | ||||