qlegend.h
116 lines
| 2.8 KiB
| text/x-c
|
CLexer
/ src / qlegend.h
sauimone
|
r524 | #ifndef QLEGEND_H | ||
#define QLEGEND_H | ||||
Michal Klocek
|
r790 | #include <QChartGlobal> | ||
#include <QGraphicsWidget> | ||||
sauimone
|
r762 | #include <QPen> | ||
#include <QBrush> | ||||
sauimone
|
r524 | |||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
class Domain; | ||||
sauimone
|
r529 | class LegendMarker; | ||
sauimone
|
r565 | class QPieSlice; | ||
class QXYSeries; | ||||
class QBarSet; | ||||
class QBarSeries; | ||||
class QPieSeries; | ||||
sauimone
|
r716 | class LegendScrollButton; | ||
sauimone
|
r762 | class QSeries; | ||
Michal Klocek
|
r790 | class QChart; | ||
sauimone
|
r524 | |||
sauimone
|
r766 | // TODO: This as widget | ||
Michal Klocek
|
r790 | class QTCOMMERCIALCHART_EXPORT QLegend : public QGraphicsWidget | ||
sauimone
|
r524 | { | ||
Q_OBJECT | ||||
public: | ||||
sauimone
|
r766 | // We only support these alignments (for now) | ||
enum Layout { | ||||
LayoutTop = Qt::AlignTop, | ||||
LayoutBottom = Qt::AlignBottom, | ||||
LayoutLeft = Qt::AlignLeft, | ||||
LayoutRight = Qt::AlignRight | ||||
sauimone
|
r616 | }; | ||
Michal Klocek
|
r790 | private: | ||
explicit QLegend(QChart *chart); | ||||
sauimone
|
r616 | |||
Michal Klocek
|
r790 | public: | ||
sauimone
|
r524 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | ||
QRectF boundingRect() const; | ||||
Tero Ahola
|
r737 | void setBrush(const QBrush &brush); | ||
Michal Klocek
|
r645 | QBrush brush() const; | ||
Tero Ahola
|
r737 | void setPen(const QPen &pen); | ||
Michal Klocek
|
r645 | QPen pen() const; | ||
sauimone
|
r540 | |||
sauimone
|
r766 | void setAlignmnent(QLegend::Layout alignment); | ||
QLegend::Layout alignment() const; | ||||
sauimone
|
r616 | |||
QSizeF maximumSize() const; | ||||
void setMaximumSize(const QSizeF size); | ||||
sauimone
|
r582 | |||
sauimone
|
r724 | QSizeF size() const; | ||
sauimone
|
r626 | void setSize(const QSizeF size); | ||
void setPos(const QPointF &pos); | ||||
Michal Klocek
|
r790 | void scrollButtonClicked(LegendScrollButton *scrollButton); | ||
sauimone
|
r775 | Q_SIGNALS: | ||
sauimone
|
r547 | // for interactions. | ||
Tero Ahola
|
r737 | void clicked(QSeries *series, Qt::MouseButton button); | ||
void clicked(QBarSet *barset, Qt::MouseButton button); | ||||
void clicked(QPieSlice *slice, Qt::MouseButton button); | ||||
sauimone
|
r547 | |||
sauimone
|
r775 | public Q_SLOTS: | ||
sauimone
|
r724 | // PIMPL ---> | ||
Tero Ahola
|
r737 | void handleSeriesAdded(QSeries *series, Domain *domain); | ||
void handleSeriesRemoved(QSeries *series); | ||||
void handleAdded(QList<QPieSlice *> slices); | ||||
void handleRemoved(QList<QPieSlice *> slices); | ||||
sauimone
|
r637 | void handleMarkerDestroyed(); | ||
Michal Klocek
|
r790 | |||
sauimone
|
r724 | // PIMPL <--- | ||
sauimone
|
r524 | |||
private: | ||||
sauimone
|
r565 | // PIMPL ---> | ||
Tero Ahola
|
r737 | void connectSeries(QSeries *series); | ||
void disconnectSeries(QSeries *series); | ||||
void createMarkers(QSeries *series); | ||||
void appendMarkers(QXYSeries *series); // All line series are derived from QXYSeries, so this works for now | ||||
void appendMarkers(QBarSeries *series); | ||||
void appendMarkers(QPieSeries *series); | ||||
void deleteMarkers(QSeries *series); | ||||
sauimone
|
r724 | void updateLayout(); | ||
Tero Ahola
|
r737 | void rescaleScrollButtons(const QSize &size); | ||
sauimone
|
r716 | QSizeF maximumMarkerSize(); | ||
sauimone
|
r724 | void checkFirstMarkerBounds(); | ||
sauimone
|
r716 | bool scrollButtonsVisible(); | ||
sauimone
|
r565 | |||
sauimone
|
r783 | qreal m_margin; | ||
sauimone
|
r766 | QPointF m_pos; | ||
QSizeF m_minimumSize; | ||||
QSizeF m_maximumSize; | ||||
sauimone
|
r783 | QSizeF m_size; | ||
sauimone
|
r626 | |||
sauimone
|
r766 | QList<LegendMarker *> m_markers; | ||
sauimone
|
r540 | |||
Michal Klocek
|
r645 | QBrush m_brush; | ||
QPen m_pen; | ||||
sauimone
|
r766 | QLegend::Layout m_alignment; | ||
sauimone
|
r716 | |||
int mFirstMarker; | ||||
sauimone
|
r766 | LegendScrollButton *m_scrollButtonLeft; | ||
LegendScrollButton *m_scrollButtonRight; | ||||
LegendScrollButton *m_scrollButtonUp; | ||||
LegendScrollButton *m_scrollButtonDown; | ||||
sauimone
|
r716 | |||
Michal Klocek
|
r790 | friend class QChart; | ||
sauimone
|
r716 | // <--- PIMPL | ||
sauimone
|
r524 | }; | ||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
#endif // QLEGEND_H | ||||