##// END OF EJS Templates
Fix compilation issue with scatterpresenter.cpp
Fix compilation issue with scatterpresenter.cpp

File last commit:

r181:f52f5b858a82
r202:384e4e17c6c1
Show More
qpieseries.h
163 lines | 4.3 KiB | text/x-c | CLexer
Jani Honkonen
Pie chart refactoring
r142 #ifndef PIESERIES_H
#define PIESERIES_H
#include "qchartseries.h"
#include <QObject>
#include <QRectF>
#include <QColor>
Jani Honkonen
Refactoring piechart API (and internals)
r174 #include <QPen>
#include <QBrush>
Jani Honkonen
Pie chart refactoring
r142
class QGraphicsObject;
QTCOMMERCIALCHART_BEGIN_NAMESPACE
Jani Honkonen
Moved pie stuff to own .pri file and rename stuff
r146 class PiePresenter;
Jani Honkonen
Pie chart refactoring
r142 class PieSlice;
Jani Honkonen
Refactoring piechart API (and internals)
r174 typedef quint64 QPieSliceId;
Jani Honkonen
Pie chart refactoring
r142 class QPieSlice
{
public:
QPieSlice()
Jani Honkonen
Refactoring piechart API (and internals)
r174 :m_id(-1), m_value(0), m_isLabelVisible(true), m_isExploded(false), m_percentage(0) {}
Jani Honkonen
Pie chart refactoring
r142
Jani Honkonen
Refactoring piechart API (and internals)
r174 QPieSlice(qreal value, QString label = QString(), bool labelVisible = true, bool exploded = false, QPen pen = QPen(), QBrush brush = QBrush())
:m_id(-1), m_value(value), m_label(label), m_isLabelVisible(labelVisible), m_isExploded(exploded), m_pen(pen), m_brush(brush), m_percentage(0) {}
QPieSliceId id() const { return m_id; }
void setValue(qreal value) { m_value = value; }
qreal value() const { return m_value; }
void setLabel(QString label) { m_label = label; }
QString label() const { return m_label; }
void setLabelVisible(bool visible) { m_isLabelVisible = visible; }
bool isLabelVisible() const { return m_isLabelVisible; }
Jani Honkonen
Implementing slice label
r181 // TODO:
//void setLabelPen(QPen pen) {};
//QPen labelPen() const {};
//void setLabelFont(QFont font);
//QFont labelFont() const;
//void setLabelArmLenght(qreal len) {};
//qreal labelArmLenght() const {};
Jani Honkonen
Refactoring piechart API (and internals)
r174 void setExploded(bool exploded) { m_isExploded = exploded; }
bool isExploded() const { return m_isExploded; }
void setPen(QPen pen) { m_pen = pen; }
QPen pen() const { return m_pen; }
void setBrush(QBrush brush) { m_brush = brush; }
QBrush brush() const { return m_brush; }
qreal percentage() const { return m_percentage; }
private:
// TODO: use private class
friend class QPieSeries;
QPieSliceId m_id;
Jani Honkonen
Pie chart refactoring
r142 qreal m_value;
QString m_label;
Jani Honkonen
Refactoring piechart API (and internals)
r174 bool m_isLabelVisible;
Jani Honkonen
Pie chart refactoring
r142 bool m_isExploded;
Jani Honkonen
Refactoring piechart API (and internals)
r174 QPen m_pen;
QBrush m_brush;
qreal m_percentage; // generated content
Jani Honkonen
Use signals from pieseries, visible hover and exploding slices
r157 };
Jani Honkonen
Pie chart refactoring
r142 class QTCOMMERCIALCHART_EXPORT QPieSeries : public QChartSeries
{
Q_OBJECT
public:
enum PiePosition {
PiePositionMaximized = 0,
PiePositionTopLeft,
PiePositionTopRight,
PiePositionBottomLeft,
PiePositionBottomRight
};
Jani Honkonen
Refactoring piechart API (and internals)
r174 class ChangeSet
{
public:
QList<QPieSliceId> m_added;
QList<QPieSliceId> m_removed;
QList<QPieSliceId> m_changed;
};
Jani Honkonen
Pie chart refactoring
r142 public:
QPieSeries(QObject *parent = 0);
~QPieSeries();
public: // from QChartSeries
QChartSeriesType type() const { return QChartSeries::SeriesTypePie; }
Jani Honkonen
Refactoring piechart API (and internals)
r174 virtual bool setData(QList<qreal> data); // TODO: remove this
Jani Honkonen
Pie chart refactoring
r142
public:
Jani Honkonen
Refactoring piechart API (and internals)
r174 // TODO: should we return id/bool or what?
// TODO: should we prefer passing a modifiable reference?
bool set(const QList<QPieSlice>& slices);
bool add(const QList<QPieSlice>& slices);
bool add(const QPieSlice& slice);
bool update(const QPieSlice& slice);
bool remove(QPieSliceId id);
Jani Honkonen
Pie chart refactoring
r142
int count() const { return m_slices.count(); }
Jani Honkonen
Refactoring piechart API (and internals)
r174 QList<QPieSlice> slices() const { return m_slices.values(); }
QList<QPieSliceId> ids() const { return m_slices.keys(); }
QPieSlice slice(QPieSliceId id) const;
// TODO: sorting?
Jani Honkonen
Pie chart refactoring
r142
Jani Honkonen
Implementing slice label
r181 // TODO: convenience functions?
//void setValue(QPieSliceId id, qreal value);
//void setLabel(QPieSliceId id, QString label);
//void setPen(QPieSliceId id, QPen pen);
//void setBrush(QPieSliceId id, QBrush brush);
//void setExploded(QPieSliceId id, bool exploded);
Jani Honkonen
Refactoring piechart API (and internals)
r174
Jani Honkonen
Pie chart refactoring
r142 void setSizeFactor(qreal sizeFactor);
qreal sizeFactor() const { return m_sizeFactor; }
void setPosition(PiePosition position);
PiePosition position() const { return m_position; }
Jani Honkonen
Use signals from pieseries, visible hover and exploding slices
r157 Q_SIGNALS:
Jani Honkonen
Refactoring piechart API (and internals)
r174 void changed(const QPieSeries::ChangeSet& changeSet);
Jani Honkonen
Use signals from pieseries, visible hover and exploding slices
r157 void sizeFactorChanged();
void positionChanged();
Jani Honkonen
Implementing slice label
r181
// TODO:
Jani Honkonen
Refactoring piechart API (and internals)
r174 //void sliceClicked(QPieSliceId id);
Jani Honkonen
Implementing slice label
r181 // ?? void sliceHoverEnter(QPieSliceId id);
// ?? void sliceHoverLeave(QPieSliceId id);
Jani Honkonen
Refactoring piechart API (and internals)
r174
private:
QPieSliceId generateSliceId();
void updateDerivativeData();
Jani Honkonen
Use signals from pieseries, visible hover and exploding slices
r157
Jani Honkonen
Pie chart refactoring
r142 private:
Q_DISABLE_COPY(QPieSeries)
Jani Honkonen
Refactoring piechart API (and internals)
r174
Jani Honkonen
Pie chart refactoring
r142 // TODO: use PIML
Jani Honkonen
Refactoring piechart API (and internals)
r174 friend class PiePresenter;
friend class PieSlice;
QHash<QPieSliceId, QPieSlice> m_slices;
Jani Honkonen
Pie chart refactoring
r142 qreal m_sizeFactor;
PiePosition m_position;
Jani Honkonen
Refactoring piechart API (and internals)
r174 qreal m_total;
QPieSliceId m_sliceIdSeed;
Jani Honkonen
Pie chart refactoring
r142 };
QTCOMMERCIALCHART_END_NAMESPACE
#endif // PIESERIES_H