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