@@ -1,76 +1,77 | |||||
1 | #ifndef BARPRESENTERBASE_H |
|
1 | #ifndef BARPRESENTERBASE_H | |
2 | #define BARPRESENTERBASE_H |
|
2 | #define BARPRESENTERBASE_H | |
3 |
|
3 | |||
4 | #include "chartitem_p.h" |
|
4 | #include "chartitem_p.h" | |
5 | #include "barchartmodel_p.h" |
|
5 | #include "barchartmodel_p.h" | |
6 | #include <QPen> |
|
6 | #include <QPen> | |
7 | #include <QBrush> |
|
7 | #include <QBrush> | |
8 | #include <QGraphicsItem> |
|
8 | #include <QGraphicsItem> | |
9 |
|
9 | |||
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
11 |
|
11 | |||
12 | class Bar; |
|
12 | class Bar; | |
13 | class BarLabel; |
|
13 | class BarLabel; | |
14 | class Separator; |
|
14 | class Separator; | |
15 | class BarValue; |
|
15 | class BarValue; | |
16 |
|
16 | |||
17 | // Common implemantation of different presenters. Not to be instantiated. |
|
17 | // Common implemantation of different presenters. Not to be instantiated. | |
|
18 | // TODO: combine this with BarPresenter and derive others from it? | |||
18 | class BarPresenterBase : public QObject, public ChartItem |
|
19 | class BarPresenterBase : public QObject, public ChartItem | |
19 | { |
|
20 | { | |
20 | Q_OBJECT |
|
21 | Q_OBJECT | |
21 | public: |
|
22 | public: | |
22 | BarPresenterBase(BarChartModel& model, QGraphicsItem *parent = 0); |
|
23 | BarPresenterBase(BarChartModel& model, QGraphicsItem *parent = 0); | |
23 | void setSeparatorsVisible(bool visible = true); |
|
24 | void setSeparatorsVisible(bool visible = true); | |
24 |
|
25 | |||
25 | public: |
|
26 | public: | |
26 |
|
27 | |||
27 | // From QGraphicsItem |
|
28 | // From QGraphicsItem | |
28 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); |
|
29 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); | |
29 | QRectF boundingRect() const; |
|
30 | QRectF boundingRect() const; | |
30 |
|
31 | |||
31 | // TODO: these may change with layout awarness. |
|
32 | // TODO: these may change with layout awarness. | |
32 | void setBarWidth( int w ); |
|
33 | void setBarWidth( int w ); | |
33 |
|
34 | |||
34 | void setPen(QPen pen); |
|
35 | void setPen(QPen pen); | |
35 | QPen pen(); |
|
36 | QPen pen(); | |
36 |
|
37 | |||
37 | void setBrush(QBrush brush); |
|
38 | void setBrush(QBrush brush); | |
38 | QBrush brush(); |
|
39 | QBrush brush(); | |
39 |
|
40 | |||
40 | // TODO: Consider the domain for layoutChanged. May be use case, may not be. If it is, then the derived classes need to implement it |
|
41 | // TODO: Consider the domain for layoutChanged. May be use case, may not be. If it is, then the derived classes need to implement it | |
41 | virtual void dataChanged(); // data of series has changed -> need to recalculate bar sizes |
|
42 | virtual void dataChanged(); // data of series has changed -> need to recalculate bar sizes | |
42 | virtual void layoutChanged() = 0; // layout has changed -> need to recalculate bar sizes |
|
43 | virtual void layoutChanged() = 0; // layout has changed -> need to recalculate bar sizes | |
43 |
|
44 | |||
44 | protected slots: |
|
45 | protected slots: | |
45 | void handleModelChanged(int index); |
|
46 | void handleModelChanged(int index); | |
46 | void handleDomainChanged(const Domain& domain); |
|
47 | void handleDomainChanged(const Domain& domain); | |
47 | void handleGeometryChanged(const QRectF& size); |
|
48 | void handleGeometryChanged(const QRectF& size); | |
48 |
|
49 | |||
49 | void barHoverEntered(QGraphicsSceneHoverEvent *event); // Internal. |
|
50 | void barHoverEntered(QGraphicsSceneHoverEvent *event); // Internal. | |
50 | void barHoverLeaved(QGraphicsSceneHoverEvent *event); |
|
51 | void barHoverLeaved(QGraphicsSceneHoverEvent *event); | |
51 |
|
52 | |||
52 | protected: |
|
53 | protected: | |
53 |
|
54 | |||
54 | // TODO: consider these. |
|
55 | // TODO: consider these. | |
55 | int mHeight; // Layout spesific |
|
56 | int mHeight; // Layout spesific | |
56 | int mWidth; |
|
57 | int mWidth; | |
57 | int mBarDefaultWidth; |
|
58 | int mBarDefaultWidth; | |
58 |
|
59 | |||
59 | bool mLayoutSet; // True, if component has been laid out. |
|
60 | bool mLayoutSet; // True, if component has been laid out. | |
60 | bool mLayoutDirty; |
|
61 | bool mLayoutDirty; | |
61 |
|
62 | |||
62 | bool mSeparatorsVisible; |
|
63 | bool mSeparatorsVisible; | |
63 | BarChartModel& mModel; |
|
64 | BarChartModel& mModel; | |
64 |
|
65 | |||
65 | // Not owned. |
|
66 | // Not owned. | |
66 | QList<Bar*> mBars; |
|
67 | QList<Bar*> mBars; | |
67 | QList<BarLabel*> mLabels; |
|
68 | QList<BarLabel*> mLabels; | |
68 | QList<Separator*> mSeparators; |
|
69 | QList<Separator*> mSeparators; | |
69 | QList<BarValue*> mFloatingValues; |
|
70 | QList<BarValue*> mFloatingValues; | |
70 |
|
71 | |||
71 | QPen mPen; |
|
72 | QPen mPen; | |
72 | }; |
|
73 | }; | |
73 |
|
74 | |||
74 | QTCOMMERCIALCHART_END_NAMESPACE |
|
75 | QTCOMMERCIALCHART_END_NAMESPACE | |
75 |
|
76 | |||
76 | #endif // BARPRESENTERBASE_H |
|
77 | #endif // BARPRESENTERBASE_H |
@@ -1,62 +1,61 | |||||
1 | #ifndef BARCHARTSERIES_H |
|
1 | #ifndef BARCHARTSERIES_H | |
2 | #define BARCHARTSERIES_H |
|
2 | #define BARCHARTSERIES_H | |
3 |
|
3 | |||
4 | #include <QList> |
|
4 | #include <QList> | |
5 | #include <QAbstractItemModel> |
|
5 | #include <QAbstractItemModel> | |
6 | #include "qchartseries.h" |
|
6 | #include "qchartseries.h" | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | class QBarCategory; |
|
10 | class QBarCategory; | |
11 | class QBarSet; |
|
11 | class QBarSet; | |
12 | class BarChartModel; |
|
12 | class BarChartModel; | |
13 |
|
13 | |||
14 | // Container for series |
|
14 | // Container for series | |
15 | // TODO: derive Stacked and percent bar charts from this? |
|
|||
16 | class QTCOMMERCIALCHART_EXPORT QBarChartSeries : public QChartSeries |
|
15 | class QTCOMMERCIALCHART_EXPORT QBarChartSeries : public QChartSeries | |
17 | { |
|
16 | { | |
18 | Q_OBJECT |
|
17 | Q_OBJECT | |
19 | public: |
|
18 | public: | |
20 | QBarChartSeries(QBarCategory *category, QObject* parent=0); |
|
19 | QBarChartSeries(QBarCategory *category, QObject* parent=0); | |
21 |
|
20 | |||
22 | virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeBar; } |
|
21 | virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeBar; } | |
23 |
|
22 | |||
24 | void addBarSet(QBarSet *set); // Takes ownership of set |
|
23 | void addBarSet(QBarSet *set); // Takes ownership of set | |
25 | void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set |
|
24 | void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set | |
26 | int countSets(); |
|
25 | int countSets(); | |
27 | QBarSet* nextSet(bool getFirst=false); // Returns first set, if called with true |
|
26 | QBarSet* nextSet(bool getFirst=false); // Returns first set, if called with true | |
28 |
|
27 | |||
29 | QList<QString> legend(); // Returns legend of series (ie. names of all sets in series) |
|
28 | QList<QString> legend(); // Returns legend of series (ie. names of all sets in series) | |
30 |
|
29 | |||
31 | // Disabled by default. Call these to change behavior. |
|
30 | // Disabled by default. Call these to change behavior. | |
32 | void enableFloatingValues(bool enabled=true); |
|
31 | void enableFloatingValues(bool enabled=true); | |
33 | void enableHoverNames(bool enabled=true); |
|
32 | void enableHoverNames(bool enabled=true); | |
34 |
|
33 | |||
35 | // TODO: Functions below this are not part of api and will be moved |
|
34 | // TODO: Functions below this are not part of api and will be moved | |
36 | // to private implementation, when we start using it (not part of api) |
|
35 | // to private implementation, when we start using it (not part of api) | |
37 | int countCategories(); |
|
36 | int countCategories(); | |
38 | qreal min(); |
|
37 | qreal min(); | |
39 | qreal max(); |
|
38 | qreal max(); | |
40 | qreal valueAt(int set, int category); |
|
39 | qreal valueAt(int set, int category); | |
41 | qreal maxCategorySum(); |
|
40 | qreal maxCategorySum(); | |
42 |
|
41 | |||
43 | BarChartModel& model(); |
|
42 | BarChartModel& model(); | |
44 |
|
43 | |||
45 | signals: |
|
44 | signals: | |
46 | void changed(int index); |
|
45 | void changed(int index); | |
47 |
|
46 | |||
48 | // TODO: these to private implementation. |
|
47 | // TODO: these to private implementation. | |
49 | void floatingValuesEnabled(bool enabled); |
|
48 | void floatingValuesEnabled(bool enabled); | |
50 | void hoverNamesEnabled(bool enabled); |
|
49 | void hoverNamesEnabled(bool enabled); | |
51 |
|
50 | |||
52 |
|
51 | |||
53 | //public Q_SLOTS: |
|
52 | //public Q_SLOTS: | |
54 |
|
53 | |||
55 | private: |
|
54 | protected: | |
56 | BarChartModel* mModel; |
|
55 | BarChartModel* mModel; | |
57 |
|
56 | |||
58 | }; |
|
57 | }; | |
59 |
|
58 | |||
60 | QTCOMMERCIALCHART_END_NAMESPACE |
|
59 | QTCOMMERCIALCHART_END_NAMESPACE | |
61 |
|
60 | |||
62 | #endif // BARCHARTSERIES_H |
|
61 | #endif // BARCHARTSERIES_H |
@@ -1,79 +1,79 | |||||
1 | #include <limits.h> |
|
1 | #include <limits.h> | |
2 | #include <QDebug> |
|
2 | #include <QDebug> | |
3 | #include "qpercentbarchartseries.h" |
|
3 | #include "qpercentbarchartseries.h" | |
4 | #include "qbarset.h" |
|
4 | #include "qbarset.h" | |
5 | #include "qbarcategory.h" |
|
5 | #include "qbarcategory.h" | |
6 | #include "barchartmodel_p.h" |
|
6 | #include "barchartmodel_p.h" | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | QPercentBarChartSeries::QPercentBarChartSeries(QBarCategory *category, QObject *parent) |
|
10 | QPercentBarChartSeries::QPercentBarChartSeries(QBarCategory *category, QObject *parent) | |
11 | : QChartSeries(parent) |
|
11 | : QBarChartSeries(category, parent) | |
12 | ,mModel(new BarChartModel(category, this)) |
|
12 | // ,mModel(new BarChartModel(category, this)) | |
13 | { |
|
13 | { | |
14 | } |
|
14 | } | |
15 |
|
15 | /* | ||
16 | void QPercentBarChartSeries::addBarSet(QBarSet *set) |
|
16 | void QPercentBarChartSeries::addBarSet(QBarSet *set) | |
17 |
|
|
17 | { | |
18 | connect(this,SIGNAL(floatingValuesEnabled(bool)),set,SLOT(enableFloatingValues(bool))); |
|
18 | connect(this,SIGNAL(floatingValuesEnabled(bool)),set,SLOT(enableFloatingValues(bool))); | |
19 | connect(this,SIGNAL(hoverNamesEnabled(bool)),set,SLOT(enableHoverNames(bool))); |
|
19 | connect(this,SIGNAL(hoverNamesEnabled(bool)),set,SLOT(enableHoverNames(bool))); | |
20 | mModel->addBarSet(set); |
|
20 | mModel->addBarSet(set); | |
21 |
|
|
21 | } | |
22 |
|
|
22 | ||
23 | void QPercentBarChartSeries::removeBarSet(QBarSet *set) |
|
23 | void QPercentBarChartSeries::removeBarSet(QBarSet *set) | |
24 |
|
|
24 | { | |
25 | disconnect(set,SLOT(enableFloatingValues(bool))); |
|
25 | disconnect(set,SLOT(enableFloatingValues(bool))); | |
26 | disconnect(set,SLOT(enableHoverNames(bool))); |
|
26 | disconnect(set,SLOT(enableHoverNames(bool))); | |
27 | mModel->removeBarSet(set); |
|
27 | mModel->removeBarSet(set); | |
28 |
|
|
28 | } | |
29 |
|
|
29 | ||
30 | int QPercentBarChartSeries::countSets() |
|
30 | int QPercentBarChartSeries::countSets() | |
31 |
|
|
31 | { | |
32 | return mModel->countSets(); |
|
32 | return mModel->countSets(); | |
33 |
|
|
33 | } | |
34 |
|
|
34 | ||
35 | QBarSet* QPercentBarChartSeries::nextSet(bool getFirst) |
|
35 | QBarSet* QPercentBarChartSeries::nextSet(bool getFirst) | |
36 |
|
|
36 | { | |
37 | return mModel->nextSet(getFirst); |
|
37 | return mModel->nextSet(getFirst); | |
38 |
|
|
38 | } | |
39 |
|
|
39 | ||
40 | QList<QString> QPercentBarChartSeries::legend() |
|
40 | QList<QString> QPercentBarChartSeries::legend() | |
41 |
|
|
41 | { | |
42 | return mModel->legend(); |
|
42 | return mModel->legend(); | |
43 |
|
|
43 | } | |
44 |
|
|
44 | ||
45 | int QPercentBarChartSeries::countCategories() |
|
45 | int QPercentBarChartSeries::countCategories() | |
46 |
|
|
46 | { | |
47 | return mModel->countCategories(); |
|
47 | return mModel->countCategories(); | |
48 |
|
|
48 | } | |
49 |
|
|
49 | ||
50 | qreal QPercentBarChartSeries::min() |
|
50 | qreal QPercentBarChartSeries::min() | |
51 |
|
|
51 | { | |
52 | return mModel->min(); |
|
52 | return mModel->min(); | |
53 |
|
|
53 | } | |
54 |
|
|
54 | ||
55 | qreal QPercentBarChartSeries::max() |
|
55 | qreal QPercentBarChartSeries::max() | |
56 |
|
|
56 | { | |
57 | return mModel->max(); |
|
57 | return mModel->max(); | |
58 |
|
|
58 | } | |
59 |
|
|
59 | ||
60 | qreal QPercentBarChartSeries::valueAt(int set, int category) |
|
60 | qreal QPercentBarChartSeries::valueAt(int set, int category) | |
61 |
|
|
61 | { | |
62 | return mModel->valueAt(set,category); |
|
62 | return mModel->valueAt(set,category); | |
63 |
|
|
63 | } | |
64 |
|
|
64 | ||
65 | qreal QPercentBarChartSeries::maxCategorySum() |
|
65 | qreal QPercentBarChartSeries::maxCategorySum() | |
66 |
|
|
66 | { | |
67 | return mModel->maxCategorySum(); |
|
67 | return mModel->maxCategorySum(); | |
68 |
|
|
68 | } | |
69 |
|
|
69 | ||
70 | BarChartModel& QPercentBarChartSeries::model() |
|
70 | BarChartModel& QPercentBarChartSeries::model() | |
71 |
|
|
71 | { | |
72 | return *mModel; |
|
72 | return *mModel; | |
73 |
|
|
73 | } | |
74 |
|
74 | */ | ||
75 |
|
75 | |||
76 | #include "moc_qpercentbarchartseries.cpp" |
|
76 | #include "moc_qpercentbarchartseries.cpp" | |
77 |
|
77 | |||
78 | QTCOMMERCIALCHART_END_NAMESPACE |
|
78 | QTCOMMERCIALCHART_END_NAMESPACE | |
79 |
|
79 |
@@ -1,58 +1,59 | |||||
1 | #ifndef PERCENTBARCHARTSERIES_H |
|
1 | #ifndef PERCENTBARCHARTSERIES_H | |
2 | #define PERCENTBARCHARTSERIES_H |
|
2 | #define PERCENTBARCHARTSERIES_H | |
3 |
|
3 | |||
4 | #include <QList> |
|
4 | #include <QList> | |
5 | #include <QAbstractItemModel> |
|
5 | #include <QAbstractItemModel> | |
6 | #include "qchartseries.h" |
|
6 | #include "qbarchartseries.h" | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | class QBarCategory; |
|
10 | class QBarCategory; | |
11 | class QBarSet; |
|
11 | class QBarSet; | |
12 | class BarChartModel; |
|
12 | class BarChartModel; | |
13 |
|
13 | |||
14 | class QTCOMMERCIALCHART_EXPORT QPercentBarChartSeries : public QChartSeries |
|
14 | //class QTCOMMERCIALCHART_EXPORT QPercentBarChartSeries : public QChartSeries | |
|
15 | class QTCOMMERCIALCHART_EXPORT QPercentBarChartSeries : public QBarChartSeries | |||
15 | { |
|
16 | { | |
16 | Q_OBJECT |
|
17 | Q_OBJECT | |
17 | public: |
|
18 | public: | |
18 | QPercentBarChartSeries(QBarCategory *category, QObject* parent=0); |
|
19 | QPercentBarChartSeries(QBarCategory *category, QObject* parent=0); | |
19 |
|
20 | |||
20 | // from BarChartSeriesBase |
|
21 | // from BarChartSeriesBase | |
21 | virtual QChartSeriesType type() const { return QChartSeries::SeriesTypePercentBar; } |
|
22 | virtual QChartSeriesType type() const { return QChartSeries::SeriesTypePercentBar; } | |
22 |
|
23 | /* | ||
23 | void addBarSet(QBarSet *set); // Takes ownership |
|
24 | void addBarSet(QBarSet *set); // Takes ownership | |
24 | void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set |
|
25 | void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set | |
25 | int countSets(); |
|
26 | int countSets(); | |
26 | QBarSet* nextSet(bool first=false); // Returns first set, if called with true |
|
27 | QBarSet* nextSet(bool first=false); // Returns first set, if called with true | |
27 |
|
|
28 | ||
28 | QList<QString> legend(); // Returns legend of series (ie. names of all sets in series) |
|
29 | QList<QString> legend(); // Returns legend of series (ie. names of all sets in series) | |
29 |
|
|
30 | ||
30 | // Disabled by default. Call these to change behavior. |
|
31 | // Disabled by default. Call these to change behavior. | |
31 | void enableFloatingValues(bool enabled=true); |
|
32 | void enableFloatingValues(bool enabled=true); | |
32 | void enableHoverNames(bool enabled=true); |
|
33 | void enableHoverNames(bool enabled=true); | |
33 |
|
|
34 | ||
34 | // TODO: Functions below this are not part of api and will be moved |
|
35 | // TODO: Functions below this are not part of api and will be moved | |
35 | // to private implementation, when we start using it (not part of api) |
|
36 | // to private implementation, when we start using it (not part of api) | |
36 | int countCategories(); |
|
37 | int countCategories(); | |
37 | qreal min(); |
|
38 | qreal min(); | |
38 | qreal max(); |
|
39 | qreal max(); | |
39 | qreal valueAt(int set, int category); |
|
40 | qreal valueAt(int set, int category); | |
40 | qreal maxCategorySum(); |
|
41 | qreal maxCategorySum(); | |
41 |
|
|
42 | ||
42 | BarChartModel& model(); |
|
43 | BarChartModel& model(); | |
43 |
|
|
44 | ||
44 | signals: |
|
45 | signals: | |
45 | void changed(int index); |
|
46 | void changed(int index); | |
46 |
|
|
47 | ||
47 | public Q_SLOTS: |
|
48 | public Q_SLOTS: | |
48 |
|
|
49 | ||
49 |
|
|
50 | ||
50 | private: |
|
51 | private: | |
51 | BarChartModel* mModel; |
|
52 | BarChartModel* mModel; | |
52 |
|
53 | */ | ||
53 | }; |
|
54 | }; | |
54 |
|
55 | |||
55 | QTCOMMERCIALCHART_END_NAMESPACE |
|
56 | QTCOMMERCIALCHART_END_NAMESPACE | |
56 |
|
57 | |||
57 |
|
58 | |||
58 | #endif // PERCENTBARCHARTSERIES_H |
|
59 | #endif // PERCENTBARCHARTSERIES_H |
@@ -1,79 +1,79 | |||||
1 | #include <limits.h> |
|
1 | #include <limits.h> | |
2 | #include <QDebug> |
|
2 | #include <QDebug> | |
3 | #include "qstackedbarchartseries.h" |
|
3 | #include "qstackedbarchartseries.h" | |
4 | #include "qbarcategory.h" |
|
4 | #include "qbarcategory.h" | |
5 | #include "qbarset.h" |
|
5 | #include "qbarset.h" | |
6 | #include "barchartmodel_p.h" |
|
6 | #include "barchartmodel_p.h" | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | QStackedBarChartSeries::QStackedBarChartSeries(QBarCategory *category, QObject *parent) |
|
10 | QStackedBarChartSeries::QStackedBarChartSeries(QBarCategory *category, QObject *parent) | |
11 | : QChartSeries(parent) |
|
11 | : QBarChartSeries(category, parent) | |
12 | ,mModel(new BarChartModel(category, this)) |
|
12 | // ,mModel(new BarChartModel(category, this)) | |
13 | { |
|
13 | { | |
14 | } |
|
14 | } | |
15 |
|
15 | /* | ||
16 | void QStackedBarChartSeries::addBarSet(QBarSet *set) |
|
16 | void QStackedBarChartSeries::addBarSet(QBarSet *set) | |
17 |
|
|
17 | { | |
18 | connect(this,SIGNAL(floatingValuesEnabled(bool)),set,SLOT(enableFloatingValues(bool))); |
|
18 | connect(this,SIGNAL(floatingValuesEnabled(bool)),set,SLOT(enableFloatingValues(bool))); | |
19 | connect(this,SIGNAL(hoverNamesEnabled(bool)),set,SLOT(enableHoverNames(bool))); |
|
19 | connect(this,SIGNAL(hoverNamesEnabled(bool)),set,SLOT(enableHoverNames(bool))); | |
20 | mModel->addBarSet(set); |
|
20 | mModel->addBarSet(set); | |
21 |
|
|
21 | } | |
22 |
|
|
22 | ||
23 | void QStackedBarChartSeries::removeBarSet(QBarSet *set) |
|
23 | void QStackedBarChartSeries::removeBarSet(QBarSet *set) | |
24 |
|
|
24 | { | |
25 | disconnect(set,SLOT(enableFloatingValues(bool))); |
|
25 | disconnect(set,SLOT(enableFloatingValues(bool))); | |
26 | disconnect(set,SLOT(enableHoverNames(bool))); |
|
26 | disconnect(set,SLOT(enableHoverNames(bool))); | |
27 | mModel->removeBarSet(set); |
|
27 | mModel->removeBarSet(set); | |
28 |
|
|
28 | } | |
29 |
|
|
29 | ||
30 | int QStackedBarChartSeries::countSets() |
|
30 | int QStackedBarChartSeries::countSets() | |
31 |
|
|
31 | { | |
32 | return mModel->countSets(); |
|
32 | return mModel->countSets(); | |
33 |
|
|
33 | } | |
34 |
|
|
34 | ||
35 | QBarSet* QStackedBarChartSeries::nextSet(bool getFirst) |
|
35 | QBarSet* QStackedBarChartSeries::nextSet(bool getFirst) | |
36 |
|
|
36 | { | |
37 | return mModel->nextSet(getFirst); |
|
37 | return mModel->nextSet(getFirst); | |
38 |
|
|
38 | } | |
39 |
|
|
39 | ||
40 | QList<QString> QStackedBarChartSeries::legend() |
|
40 | QList<QString> QStackedBarChartSeries::legend() | |
41 |
|
|
41 | { | |
42 | return mModel->legend(); |
|
42 | return mModel->legend(); | |
43 |
|
|
43 | } | |
44 |
|
|
44 | ||
45 | int QStackedBarChartSeries::countCategories() |
|
45 | int QStackedBarChartSeries::countCategories() | |
46 |
|
|
46 | { | |
47 | return mModel->countCategories(); |
|
47 | return mModel->countCategories(); | |
48 |
|
|
48 | } | |
49 |
|
|
49 | ||
50 | qreal QStackedBarChartSeries::min() |
|
50 | qreal QStackedBarChartSeries::min() | |
51 |
|
|
51 | { | |
52 | return mModel->min(); |
|
52 | return mModel->min(); | |
53 |
|
|
53 | } | |
54 |
|
|
54 | ||
55 | qreal QStackedBarChartSeries::max() |
|
55 | qreal QStackedBarChartSeries::max() | |
56 |
|
|
56 | { | |
57 | return mModel->max(); |
|
57 | return mModel->max(); | |
58 |
|
|
58 | } | |
59 |
|
|
59 | ||
60 | qreal QStackedBarChartSeries::valueAt(int set, int category) |
|
60 | qreal QStackedBarChartSeries::valueAt(int set, int category) | |
61 |
|
|
61 | { | |
62 | return mModel->valueAt(set,category); |
|
62 | return mModel->valueAt(set,category); | |
63 |
|
|
63 | } | |
64 |
|
|
64 | ||
65 | qreal QStackedBarChartSeries::maxCategorySum() |
|
65 | qreal QStackedBarChartSeries::maxCategorySum() | |
66 |
|
|
66 | { | |
67 | return mModel->maxCategorySum(); |
|
67 | return mModel->maxCategorySum(); | |
68 |
|
|
68 | } | |
69 |
|
|
69 | ||
70 | BarChartModel& QStackedBarChartSeries::model() |
|
70 | BarChartModel& QStackedBarChartSeries::model() | |
71 |
|
|
71 | { | |
72 | return *mModel; |
|
72 | return *mModel; | |
73 |
|
|
73 | } | |
74 |
|
74 | */ | ||
75 |
|
75 | |||
76 | #include "moc_qstackedbarchartseries.cpp" |
|
76 | #include "moc_qstackedbarchartseries.cpp" | |
77 |
|
77 | |||
78 | QTCOMMERCIALCHART_END_NAMESPACE |
|
78 | QTCOMMERCIALCHART_END_NAMESPACE | |
79 |
|
79 |
@@ -1,56 +1,58 | |||||
1 | #ifndef STACKEDBARCHARTSERIES_H |
|
1 | #ifndef STACKEDBARCHARTSERIES_H | |
2 | #define STACKEDBARCHARTSERIES_H |
|
2 | #define STACKEDBARCHARTSERIES_H | |
3 |
|
3 | |||
4 | #include <QList> |
|
4 | #include <QList> | |
5 | #include <QAbstractItemModel> |
|
5 | #include <QAbstractItemModel> | |
6 | #include "qchartseries.h" |
|
6 | #include "qbarchartseries.h" | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | class QBarCategory; |
|
10 | class QBarCategory; | |
11 | class QBarSet; |
|
11 | class QBarSet; | |
12 | class BarChartModel; |
|
12 | class BarChartModel; | |
13 |
|
13 | |||
14 | class QTCOMMERCIALCHART_EXPORT QStackedBarChartSeries : public QChartSeries |
|
14 | //class QTCOMMERCIALCHART_EXPORT QStackedBarChartSeries : public QChartSeries | |
|
15 | class QTCOMMERCIALCHART_EXPORT QStackedBarChartSeries : public QBarChartSeries | |||
15 | { |
|
16 | { | |
16 | Q_OBJECT |
|
17 | Q_OBJECT | |
17 | public: |
|
18 | public: | |
18 | QStackedBarChartSeries(QBarCategory *category, QObject* parent=0); |
|
19 | QStackedBarChartSeries(QBarCategory *category, QObject* parent=0); | |
19 |
|
20 | |||
20 | // from QChartSeries |
|
21 | // from QChartSeries | |
21 | virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeStackedBar; } |
|
22 | virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeStackedBar; } | |
22 |
|
23 | /* | ||
23 | // Set handling |
|
24 | // Set handling | |
24 | void addBarSet(QBarSet *set); // Takes ownership |
|
25 | void addBarSet(QBarSet *set); // Takes ownership | |
25 | void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set |
|
26 | void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set | |
26 | int countSets(); |
|
27 | int countSets(); | |
27 | QBarSet* nextSet(bool first=false); // Returns first set, if called with true |
|
28 | QBarSet* nextSet(bool first=false); // Returns first set, if called with true | |
28 |
|
|
29 | ||
29 | QList<QString> legend(); // Returns legend of series (ie. names of all sets in series) |
|
30 | QList<QString> legend(); // Returns legend of series (ie. names of all sets in series) | |
30 |
|
|
31 | ||
31 | // Disabled by default. Call these to change behavior. |
|
32 | // Disabled by default. Call these to change behavior. | |
32 | void enableFloatingValues(bool enabled=true); |
|
33 | void enableFloatingValues(bool enabled=true); | |
33 | void enableHoverNames(bool enabled=true); |
|
34 | void enableHoverNames(bool enabled=true); | |
34 |
|
|
35 | ||
35 | // TODO: Functions below this are not part of api and will be moved |
|
36 | // TODO: Functions below this are not part of api and will be moved | |
36 | // to private implementation, when we start using it (not part of api) |
|
37 | // to private implementation, when we start using it (not part of api) | |
37 | int countCategories(); |
|
38 | int countCategories(); | |
38 | qreal min(); |
|
39 | qreal min(); | |
39 | qreal max(); |
|
40 | qreal max(); | |
40 | qreal valueAt(int set, int category); |
|
41 | qreal valueAt(int set, int category); | |
41 | qreal maxCategorySum(); |
|
42 | qreal maxCategorySum(); | |
42 |
|
|
43 | ||
43 | BarChartModel& model(); |
|
44 | BarChartModel& model(); | |
44 |
|
|
45 | ||
45 | signals: |
|
46 | signals: | |
46 | void changed(int index); |
|
47 | void changed(int index); | |
47 |
|
|
48 | ||
48 | public Q_SLOTS: |
|
49 | public Q_SLOTS: | |
49 |
|
|
50 | ||
50 | private: |
|
51 | private: | |
51 | BarChartModel* mModel; |
|
52 | BarChartModel* mModel; | |
|
53 | */ | |||
52 | }; |
|
54 | }; | |
53 |
|
55 | |||
54 | QTCOMMERCIALCHART_END_NAMESPACE |
|
56 | QTCOMMERCIALCHART_END_NAMESPACE | |
55 |
|
57 | |||
56 | #endif // STACKEDBARCHARTSERIES_H |
|
58 | #endif // STACKEDBARCHARTSERIES_H |
General Comments 0
You need to be logged in to leave comments.
Login now