barpresenterbase.h
77 lines
| 2.0 KiB
| text/x-c
|
CLexer
|
r217 | #ifndef BARPRESENTERBASE_H | ||
#define BARPRESENTERBASE_H | ||||
|
r126 | |||
#include "chartitem_p.h" | ||||
|
r159 | #include "barchartmodel_p.h" | ||
|
r183 | #include <QPen> | ||
#include <QBrush> | ||||
|
r126 | #include <QGraphicsItem> | ||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
|
r256 | class Bar; | ||
class BarLabel; | ||||
class Separator; | ||||
|
r263 | class BarValue; | ||
|
r256 | |||
// Common implemantation of different presenters. Not to be instantiated. | ||||
|
r281 | // TODO: combine this with BarPresenter and derive others from it? | ||
|
r216 | class BarPresenterBase : public QObject, public ChartItem | ||
|
r126 | { | ||
|
r139 | Q_OBJECT | ||
|
r126 | public: | ||
|
r216 | BarPresenterBase(BarChartModel& model, QGraphicsItem *parent = 0); | ||
|
r126 | void setSeparatorsVisible(bool visible = true); | ||
|
r175 | public: | ||
|
r126 | |||
// From QGraphicsItem | ||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); | ||||
QRectF boundingRect() const; | ||||
// TODO: these may change with layout awarness. | ||||
void setBarWidth( int w ); | ||||
|
r183 | |||
void setPen(QPen pen); | ||||
QPen pen(); | ||||
void setBrush(QBrush brush); | ||||
QBrush brush(); | ||||
|
r167 | // TODO: Consider the domain for layoutChanged. May be use case, may not be. If it is, then the derived classes need to implement it | ||
|
r126 | virtual void dataChanged(); // data of series has changed -> need to recalculate bar sizes | ||
virtual void layoutChanged() = 0; // layout has changed -> need to recalculate bar sizes | ||||
|
r139 | protected slots: | ||
void handleModelChanged(int index); | ||||
void handleDomainChanged(const Domain& domain); | ||||
void handleGeometryChanged(const QRectF& size); | ||||
|
r280 | void barHoverEntered(QGraphicsSceneHoverEvent *event); // Internal. | ||
void barHoverLeaved(QGraphicsSceneHoverEvent *event); | ||||
|
r126 | protected: | ||
|
r159 | // TODO: consider these. | ||
|
r126 | int mHeight; // Layout spesific | ||
int mWidth; | ||||
int mBarDefaultWidth; | ||||
bool mLayoutSet; // True, if component has been laid out. | ||||
bool mLayoutDirty; | ||||
bool mSeparatorsVisible; | ||||
|
r161 | BarChartModel& mModel; | ||
|
r159 | |||
|
r256 | // Not owned. | ||
QList<Bar*> mBars; | ||||
QList<BarLabel*> mLabels; | ||||
QList<Separator*> mSeparators; | ||||
|
r263 | QList<BarValue*> mFloatingValues; | ||
|
r256 | |||
|
r183 | QPen mPen; | ||
|
r126 | }; | ||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
|
r217 | #endif // BARPRESENTERBASE_H | ||