@@ -1,60 +1,56 | |||
|
1 | 1 | #ifndef BARGROUPBASE_H |
|
2 | 2 | #define BARGROUPBASE_H |
|
3 | 3 | |
|
4 | 4 | #include "chartitem_p.h" |
|
5 | 5 | #include "barchartmodel_p.h" |
|
6 | 6 | #include <QGraphicsItem> |
|
7 | 7 | |
|
8 | 8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
9 | 9 | |
|
10 | 10 | // Base Class for bar groups. Common implemantation of different groups. Not to be instantiated. |
|
11 | 11 | class BarGroupBase : public QObject, public ChartItem |
|
12 | 12 | { |
|
13 | 13 | Q_OBJECT |
|
14 | 14 | public: |
|
15 | 15 | BarGroupBase(BarChartModel& model, QGraphicsItem *parent = 0); |
|
16 | 16 | void setSeparatorsVisible(bool visible = true); |
|
17 | 17 | |
|
18 | public: // From ChartItem | |
|
19 | // void setSize(const QSizeF &size){}; | |
|
18 | public: | |
|
20 | 19 | |
|
21 | 20 | // From QGraphicsItem |
|
22 | 21 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); |
|
23 | 22 | QRectF boundingRect() const; |
|
24 | 23 | |
|
25 | 24 | // TODO: these may change with layout awarness. |
|
26 | 25 | void setBarWidth( int w ); |
|
27 | 26 | int addColor( QColor color ); |
|
28 | 27 | void resetColors(); |
|
29 | 28 | |
|
30 | 29 | // TODO: Consider the domain for layoutChanged. May be use case, may not be. If it is, then the derived classes need to implement it |
|
31 | 30 | virtual void dataChanged(); // data of series has changed -> need to recalculate bar sizes |
|
32 | 31 | virtual void layoutChanged() = 0; // layout has changed -> need to recalculate bar sizes |
|
33 | 32 | |
|
34 | 33 | protected slots: |
|
35 | 34 | void handleModelChanged(int index); |
|
36 | 35 | void handleDomainChanged(const Domain& domain); |
|
37 | 36 | void handleGeometryChanged(const QRectF& size); |
|
38 | 37 | |
|
39 | 38 | protected: |
|
40 | 39 | |
|
41 | 40 | // TODO: consider these. |
|
42 | //int mMin; // Min and max values of data. (updated when data is changed, used when drawing) | |
|
43 | //int mMax; | |
|
44 | ||
|
45 | 41 | int mHeight; // Layout spesific |
|
46 | 42 | int mWidth; |
|
47 | 43 | int mBarDefaultWidth; |
|
48 | 44 | |
|
49 | 45 | bool mLayoutSet; // True, if component has been laid out. |
|
50 | 46 | bool mLayoutDirty; |
|
51 | 47 | |
|
52 | 48 | QList<QColor> mColors; // List of colors for series for now |
|
53 | 49 | bool mSeparatorsVisible; |
|
54 | 50 | BarChartModel& mModel; |
|
55 | 51 | |
|
56 | 52 | }; |
|
57 | 53 | |
|
58 | 54 | QTCOMMERCIALCHART_END_NAMESPACE |
|
59 | 55 | |
|
60 | 56 | #endif // BARGROUPBASE_H |
@@ -1,50 +1,45 | |||
|
1 | 1 | #ifndef QCHARTSERIES_H |
|
2 | 2 | #define QCHARTSERIES_H |
|
3 | 3 | |
|
4 | 4 | #include "qchartglobal.h" |
|
5 | 5 | #include <QObject> |
|
6 | 6 | #include <QAbstractItemModel> |
|
7 | 7 | |
|
8 | 8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
9 | 9 | |
|
10 | 10 | class QTCOMMERCIALCHART_EXPORT QChartSeries : public QObject |
|
11 | 11 | { |
|
12 | 12 | Q_OBJECT |
|
13 | 13 | public: |
|
14 | 14 | enum QChartSeriesType { |
|
15 | 15 | SeriesTypeInvalid = -1, |
|
16 | 16 | SeriesTypeLine, |
|
17 | 17 | // SeriesTypeArea, |
|
18 | 18 | SeriesTypeBar, |
|
19 | 19 | SeriesTypeStackedBar, |
|
20 | 20 | SeriesTypePercentBar, |
|
21 | 21 | SeriesTypePie, |
|
22 | 22 | SeriesTypeScatter |
|
23 | 23 | // SeriesTypeSpline |
|
24 | 24 | }; |
|
25 | 25 | |
|
26 | 26 | protected: |
|
27 | 27 | QChartSeries(QObject *parent = 0):QObject(parent){}; |
|
28 | 28 | |
|
29 | 29 | public: |
|
30 | 30 | virtual ~QChartSeries(){}; |
|
31 | 31 | |
|
32 | 32 | // Pure virtual |
|
33 | 33 | virtual QChartSeriesType type() const = 0; |
|
34 | 34 | |
|
35 | virtual bool setData(QList<int> /*data*/) { return false; } | |
|
36 | 35 | virtual bool setData(QList<qreal> /*data*/) { return false; } |
|
37 | 36 | virtual bool setData(QList<qreal> /*x*/, QList<qreal> /*y*/){ return false; } |
|
38 | 37 | |
|
39 | 38 | // Prototype for data model. TODO: remove the other setData methods and use something like this for now? |
|
40 |
virtual bool set |
|
|
41 | ||
|
42 | // Methods for building a table for bar chart. Call repeatedly to add more than one series | |
|
43 | virtual int addData(QList<qreal> data) {return -1;} | |
|
44 | virtual void removeData(int id) {} | |
|
39 | virtual bool setModel(QAbstractItemModel* /*model*/) { return false; } | |
|
45 | 40 | }; |
|
46 | 41 | |
|
47 | 42 | QTCOMMERCIALCHART_END_NAMESPACE |
|
48 | 43 | |
|
49 | 44 | #endif |
|
50 | 45 |
General Comments 0
You need to be logged in to leave comments.
Login now