@@ -1,28 +1,28 | |||||
1 |
#ifndef |
|
1 | #ifndef BARPRESENTER_H | |
2 |
#define |
|
2 | #define BARPRESENTER_H | |
3 |
|
3 | |||
4 | #include "barpresenterbase.h" |
|
4 | #include "barpresenterbase.h" | |
5 | #include "qbarchartseries.h" |
|
5 | #include "qbarchartseries.h" | |
6 | #include <QGraphicsItem> |
|
6 | #include <QGraphicsItem> | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | // Base class for bar groups |
|
10 | // Base class for bar groups | |
11 |
|
11 | |||
12 | class BarPresenter : public BarPresenterBase |
|
12 | class BarPresenter : public BarPresenterBase | |
13 | { |
|
13 | { | |
14 | public: |
|
14 | public: | |
15 | explicit BarPresenter(BarChartModel& model, QGraphicsItem *parent = 0); |
|
15 | explicit BarPresenter(BarChartModel& model, QGraphicsItem *parent = 0); | |
16 |
|
16 | |||
17 | private: |
|
17 | private: | |
18 |
|
18 | |||
19 |
// From Bar |
|
19 | // From BarPresenterBase | |
20 | void layoutChanged(); // layout has changed -> need to recalculate bar sizes |
|
20 | void layoutChanged(); // layout has changed -> need to recalculate bar sizes | |
21 |
|
21 | |||
22 | private: |
|
22 | private: | |
23 | // Data |
|
23 | // Data | |
24 | }; |
|
24 | }; | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_END_NAMESPACE |
|
26 | QTCOMMERCIALCHART_END_NAMESPACE | |
27 |
|
27 | |||
28 |
#endif // |
|
28 | #endif // BARPRESENTER_H |
@@ -1,121 +1,111 | |||||
1 | #include "barpresenterbase.h" |
|
1 | #include "barpresenterbase.h" | |
2 | #include "bar_p.h" |
|
2 | #include "bar_p.h" | |
3 | #include "barlabel_p.h" |
|
3 | #include "barlabel_p.h" | |
4 | #include "separator_p.h" |
|
4 | #include "separator_p.h" | |
5 | #include <QDebug> |
|
5 | #include <QDebug> | |
6 |
|
6 | |||
7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
8 |
|
8 | |||
9 | BarPresenterBase::BarPresenterBase(BarChartModel& model, QGraphicsItem *parent) |
|
9 | BarPresenterBase::BarPresenterBase(BarChartModel& model, QGraphicsItem *parent) | |
10 | : ChartItem(parent) |
|
10 | : ChartItem(parent) | |
11 | ,mBarDefaultWidth(20) // TODO: remove hard coding, when we have layout code ready |
|
11 | ,mBarDefaultWidth(20) // TODO: remove hard coding, when we have layout code ready | |
12 | ,mLayoutSet(false) |
|
12 | ,mLayoutSet(false) | |
13 | ,mLayoutDirty(true) |
|
13 | ,mLayoutDirty(true) | |
14 | ,mSeparatorsVisible(true) |
|
14 | ,mSeparatorsVisible(true) | |
15 | ,mModel(model) |
|
15 | ,mModel(model) | |
16 | { |
|
16 | { | |
17 | dataChanged(); |
|
17 | dataChanged(); | |
18 | } |
|
18 | } | |
19 |
|
19 | |||
20 | void BarPresenterBase::setSeparatorsVisible(bool visible) |
|
20 | void BarPresenterBase::setSeparatorsVisible(bool visible) | |
21 | { |
|
21 | { | |
22 | mSeparatorsVisible = visible; |
|
22 | mSeparatorsVisible = visible; | |
23 | } |
|
23 | } | |
24 |
|
24 | |||
25 | void BarPresenterBase::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
25 | void BarPresenterBase::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
26 | { |
|
26 | { | |
27 | // qDebug() << "BarGroupBase::paint" << childItems().count(); |
|
27 | // qDebug() << "BarGroupBase::paint" << childItems().count(); | |
28 | if (!mLayoutSet) { |
|
28 | if (!mLayoutSet) { | |
29 | qDebug() << "BarGroupBase::paint called without layout set. Aborting."; |
|
29 | qDebug() << "BarGroupBase::paint called without layout set. Aborting."; | |
30 | return; |
|
30 | return; | |
31 | } |
|
31 | } | |
32 | // if (mLayoutDirty) { |
|
32 | // if (mLayoutDirty) { | |
33 | // Layout or data has changed. Need to redraw. |
|
33 | // Layout or data has changed. Need to redraw. | |
34 | foreach(QGraphicsItem* i, childItems()) { |
|
34 | foreach(QGraphicsItem* i, childItems()) { | |
35 | i->paint(painter,option,widget); |
|
35 | i->paint(painter,option,widget); | |
36 | } |
|
36 | } | |
37 | // } |
|
37 | // } | |
38 | } |
|
38 | } | |
39 |
|
39 | |||
40 | QRectF BarPresenterBase::boundingRect() const |
|
40 | QRectF BarPresenterBase::boundingRect() const | |
41 | { |
|
41 | { | |
42 | return QRectF(0,0,mWidth,mHeight); |
|
42 | return QRectF(0,0,mWidth,mHeight); | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | void BarPresenterBase::setBarWidth( int w ) |
|
45 | void BarPresenterBase::setBarWidth( int w ) | |
46 | { |
|
46 | { | |
47 | mBarDefaultWidth = w; |
|
47 | mBarDefaultWidth = w; | |
48 | } |
|
48 | } | |
49 | /* |
|
|||
50 | void BarGroupBase::resetBrushes() |
|
|||
51 | { |
|
|||
52 | mBrushes.clear(); |
|
|||
53 | } |
|
|||
54 |
|
49 | |||
55 | void BarGroupBase::addBrush(QBrush brush) |
|
|||
56 | { |
|
|||
57 | mBrushes.append(brush); |
|
|||
58 | } |
|
|||
59 | */ |
|
|||
60 | void BarPresenterBase::dataChanged() |
|
50 | void BarPresenterBase::dataChanged() | |
61 | { |
|
51 | { | |
62 | // TODO: performance optimizations. Do we really need to delete and create items every time data is changed or can we reuse them? |
|
52 | // TODO: performance optimizations. Do we really need to delete and create items every time data is changed or can we reuse them? | |
63 |
|
53 | |||
64 | // Delete old bars |
|
54 | // Delete old bars | |
65 | foreach (QGraphicsItem* item, childItems()) { |
|
55 | foreach (QGraphicsItem* item, childItems()) { | |
66 | delete item; |
|
56 | delete item; | |
67 | } |
|
57 | } | |
68 |
|
58 | |||
69 | // Create new graphic items for bars |
|
59 | // Create new graphic items for bars | |
70 | int totalItems = mModel.countTotalItems(); |
|
60 | int totalItems = mModel.countTotalItems(); | |
71 | for (int i=0; i<totalItems; i++) { |
|
61 | for (int i=0; i<totalItems; i++) { | |
72 | Bar *bar = new Bar(this); |
|
62 | Bar *bar = new Bar(this); | |
73 | childItems().append(bar); |
|
63 | childItems().append(bar); | |
74 | } |
|
64 | } | |
75 |
|
65 | |||
76 | int count = mModel.countCategories(); |
|
66 | int count = mModel.countCategories(); | |
77 | for (int i=0; i<count; i++) { |
|
67 | for (int i=0; i<count; i++) { | |
78 | BarLabel* label = new BarLabel(this); |
|
68 | BarLabel* label = new BarLabel(this); | |
79 | label->set(mModel.label(i)); |
|
69 | label->set(mModel.label(i)); | |
80 | childItems().append(label); |
|
70 | childItems().append(label); | |
81 | } |
|
71 | } | |
82 |
|
72 | |||
83 | count = mModel.countCategories() - 1; // There is one less separator than columns |
|
73 | count = mModel.countCategories() - 1; // There is one less separator than columns | |
84 | for (int i=0; i<count; i++) { |
|
74 | for (int i=0; i<count; i++) { | |
85 | Separator* sep = new Separator(this); |
|
75 | Separator* sep = new Separator(this); | |
86 | sep->setColor(QColor(255,0,0,255)); // TODO: color for separations from theme |
|
76 | sep->setColor(QColor(255,0,0,255)); // TODO: color for separations from theme | |
87 | childItems().append(sep); |
|
77 | childItems().append(sep); | |
88 | } |
|
78 | } | |
89 |
|
79 | |||
90 | // TODO: if (autolayout) { layoutChanged() } or something |
|
80 | // TODO: if (autolayout) { layoutChanged() } or something | |
91 | mLayoutDirty = true; |
|
81 | mLayoutDirty = true; | |
92 | } |
|
82 | } | |
93 |
|
83 | |||
94 | //handlers |
|
84 | //handlers | |
95 |
|
85 | |||
96 | void BarPresenterBase::handleModelChanged(int index) |
|
86 | void BarPresenterBase::handleModelChanged(int index) | |
97 | { |
|
87 | { | |
98 | // qDebug() << "BarGroupBase::handleModelChanged" << index; |
|
88 | // qDebug() << "BarGroupBase::handleModelChanged" << index; | |
99 | dataChanged(); |
|
89 | dataChanged(); | |
100 | } |
|
90 | } | |
101 |
|
91 | |||
102 | void BarPresenterBase::handleDomainChanged(const Domain& domain) |
|
92 | void BarPresenterBase::handleDomainChanged(const Domain& domain) | |
103 | { |
|
93 | { | |
104 | // qDebug() << "BarGroupBase::handleDomainChanged"; |
|
94 | // qDebug() << "BarGroupBase::handleDomainChanged"; | |
105 | // TODO: Figure out the use case for this. |
|
95 | // TODO: Figure out the use case for this. | |
106 | // Affects the size of visible item, so layout is changed. |
|
96 | // Affects the size of visible item, so layout is changed. | |
107 | // layoutChanged(); |
|
97 | // layoutChanged(); | |
108 | } |
|
98 | } | |
109 |
|
99 | |||
110 | void BarPresenterBase::handleGeometryChanged(const QRectF& rect) |
|
100 | void BarPresenterBase::handleGeometryChanged(const QRectF& rect) | |
111 | { |
|
101 | { | |
112 | mWidth = rect.width(); |
|
102 | mWidth = rect.width(); | |
113 | mHeight = rect.height(); |
|
103 | mHeight = rect.height(); | |
114 | layoutChanged(); |
|
104 | layoutChanged(); | |
115 | mLayoutSet = true; |
|
105 | mLayoutSet = true; | |
116 | setPos(rect.topLeft()); |
|
106 | setPos(rect.topLeft()); | |
117 | } |
|
107 | } | |
118 |
|
108 | |||
119 | #include "moc_barpresenterbase.cpp" |
|
109 | #include "moc_barpresenterbase.cpp" | |
120 |
|
110 | |||
121 | QTCOMMERCIALCHART_END_NAMESPACE |
|
111 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,68 +1,63 | |||||
1 |
#ifndef BAR |
|
1 | #ifndef BARPRESENTERBASE_H | |
2 |
#define BAR |
|
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 | // Base Class for bar groups. Common implemantation of different groups. Not to be instantiated. |
|
12 | // Base Class for bar groups. Common implemantation of different groups. Not to be instantiated. | |
13 | class BarPresenterBase : public QObject, public ChartItem |
|
13 | class BarPresenterBase : public QObject, public ChartItem | |
14 | { |
|
14 | { | |
15 | Q_OBJECT |
|
15 | Q_OBJECT | |
16 | public: |
|
16 | public: | |
17 | BarPresenterBase(BarChartModel& model, QGraphicsItem *parent = 0); |
|
17 | BarPresenterBase(BarChartModel& model, QGraphicsItem *parent = 0); | |
18 | void setSeparatorsVisible(bool visible = true); |
|
18 | void setSeparatorsVisible(bool visible = true); | |
19 |
|
19 | |||
20 | public: |
|
20 | public: | |
21 |
|
21 | |||
22 | // From QGraphicsItem |
|
22 | // From QGraphicsItem | |
23 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); |
|
23 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); | |
24 | QRectF boundingRect() const; |
|
24 | QRectF boundingRect() const; | |
25 |
|
25 | |||
26 | // TODO: these may change with layout awarness. |
|
26 | // TODO: these may change with layout awarness. | |
27 | void setBarWidth( int w ); |
|
27 | void setBarWidth( int w ); | |
28 |
|
28 | |||
29 | // void resetBrushes(); |
|
|||
30 | // void addBrush(QBrush brush); |
|
|||
31 |
|
||||
32 | void setPen(QPen pen); |
|
29 | void setPen(QPen pen); | |
33 | QPen pen(); |
|
30 | QPen pen(); | |
34 |
|
31 | |||
35 | void setBrush(QBrush brush); |
|
32 | void setBrush(QBrush brush); | |
36 | QBrush brush(); |
|
33 | QBrush brush(); | |
37 |
|
34 | |||
38 |
|
||||
39 | // TODO: Consider the domain for layoutChanged. May be use case, may not be. If it is, then the derived classes need to implement it |
|
35 | // TODO: Consider the domain for layoutChanged. May be use case, may not be. If it is, then the derived classes need to implement it | |
40 | virtual void dataChanged(); // data of series has changed -> need to recalculate bar sizes |
|
36 | virtual void dataChanged(); // data of series has changed -> need to recalculate bar sizes | |
41 | virtual void layoutChanged() = 0; // layout has changed -> need to recalculate bar sizes |
|
37 | virtual void layoutChanged() = 0; // layout has changed -> need to recalculate bar sizes | |
42 |
|
38 | |||
43 | protected slots: |
|
39 | protected slots: | |
44 | void handleModelChanged(int index); |
|
40 | void handleModelChanged(int index); | |
45 | void handleDomainChanged(const Domain& domain); |
|
41 | void handleDomainChanged(const Domain& domain); | |
46 | void handleGeometryChanged(const QRectF& size); |
|
42 | void handleGeometryChanged(const QRectF& size); | |
47 |
|
43 | |||
48 | protected: |
|
44 | protected: | |
49 |
|
45 | |||
50 | // TODO: consider these. |
|
46 | // TODO: consider these. | |
51 | int mHeight; // Layout spesific |
|
47 | int mHeight; // Layout spesific | |
52 | int mWidth; |
|
48 | int mWidth; | |
53 | int mBarDefaultWidth; |
|
49 | int mBarDefaultWidth; | |
54 |
|
50 | |||
55 | bool mLayoutSet; // True, if component has been laid out. |
|
51 | bool mLayoutSet; // True, if component has been laid out. | |
56 | bool mLayoutDirty; |
|
52 | bool mLayoutDirty; | |
57 |
|
53 | |||
58 | QList<QColor> mColors; // List of colors for series for now |
|
54 | QList<QColor> mColors; // List of colors for series for now | |
59 | bool mSeparatorsVisible; |
|
55 | bool mSeparatorsVisible; | |
60 | BarChartModel& mModel; |
|
56 | BarChartModel& mModel; | |
61 |
|
57 | |||
62 | QPen mPen; |
|
58 | QPen mPen; | |
63 | // QList<QBrush> mBrushes; |
|
|||
64 | }; |
|
59 | }; | |
65 |
|
60 | |||
66 | QTCOMMERCIALCHART_END_NAMESPACE |
|
61 | QTCOMMERCIALCHART_END_NAMESPACE | |
67 |
|
62 | |||
68 |
#endif // BAR |
|
63 | #endif // BARPRESENTERBASE_H |
@@ -1,28 +1,28 | |||||
1 |
#ifndef PERCENTBAR |
|
1 | #ifndef PERCENTBARPRESENTER_H | |
2 |
#define PERCENTBAR |
|
2 | #define PERCENTBARPRESENTER_H | |
3 |
|
3 | |||
4 | #include "chartitem_p.h" |
|
4 | #include "chartitem_p.h" | |
5 | #include "bar_p.h" |
|
5 | #include "bar_p.h" | |
6 | #include "qpercentbarchartseries.h" |
|
6 | #include "qpercentbarchartseries.h" | |
7 | #include "barpresenterbase.h" |
|
7 | #include "barpresenterbase.h" | |
8 | #include <QGraphicsItem> |
|
8 | #include <QGraphicsItem> | |
9 |
|
9 | |||
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
11 |
|
11 | |||
12 | class PercentBarPresenter : public BarPresenterBase |
|
12 | class PercentBarPresenter : public BarPresenterBase | |
13 | { |
|
13 | { | |
14 | public: |
|
14 | public: | |
15 | PercentBarPresenter(BarChartModel& model, QGraphicsItem *parent = 0); |
|
15 | PercentBarPresenter(BarChartModel& model, QGraphicsItem *parent = 0); | |
16 |
|
16 | |||
17 | private: |
|
17 | private: | |
18 |
|
18 | |||
19 | void layoutChanged(); // layout has changed -> need to recalculate bar sizes |
|
19 | void layoutChanged(); // layout has changed -> need to recalculate bar sizes | |
20 |
|
20 | |||
21 | private: |
|
21 | private: | |
22 |
|
22 | |||
23 | // Data |
|
23 | // Data | |
24 | }; |
|
24 | }; | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_END_NAMESPACE |
|
26 | QTCOMMERCIALCHART_END_NAMESPACE | |
27 |
|
27 | |||
28 |
#endif // PERCENTBAR |
|
28 | #endif // PERCENTBARPRESENTER_H |
@@ -1,56 +1,53 | |||||
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 BarPresenter; |
|
|||
13 | class BarChartModel; |
|
12 | class BarChartModel; | |
14 |
|
13 | |||
15 | // Container for series |
|
14 | // Container for series | |
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); // Removes set, releases ownership. |
|
24 | void removeBarSet(QBarSet *set); // Removes set, releases ownership. | |
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 | //TODO: |
|
28 | //TODO: | |
30 | //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) | |
31 |
|
30 | |||
32 | // TODO: Functions below this are not part of api and will be moved |
|
31 | // TODO: Functions below this are not part of api and will be moved | |
33 | // to private implementation, when we start using it (not part of api) |
|
32 | // to private implementation, when we start using it (not part of api) | |
34 | int countCategories(); |
|
33 | int countCategories(); | |
35 | qreal min(); |
|
34 | qreal min(); | |
36 | qreal max(); |
|
35 | qreal max(); | |
37 | qreal valueAt(int set, int category); |
|
36 | qreal valueAt(int set, int category); | |
38 | qreal maxCategorySum(); |
|
37 | qreal maxCategorySum(); | |
39 |
|
38 | |||
40 | BarChartModel& model(); |
|
39 | BarChartModel& model(); | |
41 |
|
40 | |||
42 | signals: |
|
41 | signals: | |
43 | void changed(int index); |
|
42 | void changed(int index); | |
44 |
|
43 | |||
45 | public Q_SLOTS: |
|
44 | public Q_SLOTS: | |
46 |
|
45 | |||
47 | private: |
|
46 | private: | |
48 |
|
47 | |||
49 | BarPresenter* mBarGroup; |
|
|||
50 | BarChartModel* mModel; |
|
48 | BarChartModel* mModel; | |
51 |
|
||||
52 | }; |
|
49 | }; | |
53 |
|
50 | |||
54 | QTCOMMERCIALCHART_END_NAMESPACE |
|
51 | QTCOMMERCIALCHART_END_NAMESPACE | |
55 |
|
52 | |||
56 | #endif // BARCHARTSERIES_H |
|
53 | #endif // BARCHARTSERIES_H |
@@ -1,58 +1,56 | |||||
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 "qchartseries.h" | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | class PercentBarPresenter; |
|
|||
11 | class QBarCategory; |
|
10 | class QBarCategory; | |
12 | class QBarSet; |
|
11 | class QBarSet; | |
13 | class BarChartModel; |
|
12 | class BarChartModel; | |
14 |
|
13 | |||
15 | class QTCOMMERCIALCHART_EXPORT QPercentBarChartSeries : public QChartSeries |
|
14 | class QTCOMMERCIALCHART_EXPORT QPercentBarChartSeries : public QChartSeries | |
16 | { |
|
15 | { | |
17 | Q_OBJECT |
|
16 | Q_OBJECT | |
18 | public: |
|
17 | public: | |
19 | QPercentBarChartSeries(QBarCategory *category, QObject* parent=0); |
|
18 | QPercentBarChartSeries(QBarCategory *category, QObject* parent=0); | |
20 |
|
19 | |||
21 | // from BarChartSeriesBase |
|
20 | // from BarChartSeriesBase | |
22 | virtual QChartSeriesType type() const { return QChartSeries::SeriesTypePercentBar; } |
|
21 | virtual QChartSeriesType type() const { return QChartSeries::SeriesTypePercentBar; } | |
23 |
|
22 | |||
24 | void addBarSet(QBarSet *set); // Takes ownership |
|
23 | void addBarSet(QBarSet *set); // Takes ownership | |
25 | void removeBarSet(QBarSet *set); // Also deletes the set, if set is owned. |
|
24 | void removeBarSet(QBarSet *set); // Also deletes the set, if set is owned. | |
26 | int countSets(); |
|
25 | int countSets(); | |
27 | QBarSet* nextSet(bool first=false); // Returns first set, if called with true |
|
26 | QBarSet* nextSet(bool first=false); // Returns first set, if called with true | |
28 |
|
27 | |||
29 | //TODO: |
|
28 | //TODO: | |
30 | //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) | |
31 |
|
30 | |||
32 | // TODO: Functions below this are not part of api and will be moved |
|
31 | // TODO: Functions below this are not part of api and will be moved | |
33 | // to private implementation, when we start using it (not part of api) |
|
32 | // to private implementation, when we start using it (not part of api) | |
34 | int countCategories(); |
|
33 | int countCategories(); | |
35 | qreal min(); |
|
34 | qreal min(); | |
36 | qreal max(); |
|
35 | qreal max(); | |
37 | qreal valueAt(int set, int category); |
|
36 | qreal valueAt(int set, int category); | |
38 | qreal maxCategorySum(); |
|
37 | qreal maxCategorySum(); | |
39 |
|
38 | |||
40 | BarChartModel& model(); |
|
39 | BarChartModel& model(); | |
41 |
|
40 | |||
42 | signals: |
|
41 | signals: | |
43 | void changed(int index); |
|
42 | void changed(int index); | |
44 |
|
43 | |||
45 | public Q_SLOTS: |
|
44 | public Q_SLOTS: | |
46 |
|
45 | |||
47 |
|
46 | |||
48 | private: |
|
47 | private: | |
49 |
|
48 | |||
50 | PercentBarPresenter* mPercentBarGroup; |
|
|||
51 | BarChartModel* mModel; |
|
49 | BarChartModel* mModel; | |
52 |
|
50 | |||
53 | }; |
|
51 | }; | |
54 |
|
52 | |||
55 | QTCOMMERCIALCHART_END_NAMESPACE |
|
53 | QTCOMMERCIALCHART_END_NAMESPACE | |
56 |
|
54 | |||
57 |
|
55 | |||
58 | #endif // PERCENTBARCHARTSERIES_H |
|
56 | #endif // PERCENTBARCHARTSERIES_H |
@@ -1,55 +1,53 | |||||
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 "qchartseries.h" | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | class StackedBarPresenter; |
|
|||
11 | class QBarCategory; |
|
10 | class QBarCategory; | |
12 | class QBarSet; |
|
11 | class QBarSet; | |
13 | class BarChartModel; |
|
12 | class BarChartModel; | |
14 |
|
13 | |||
15 | class QTCOMMERCIALCHART_EXPORT QStackedBarChartSeries : public QChartSeries |
|
14 | class QTCOMMERCIALCHART_EXPORT QStackedBarChartSeries : public QChartSeries | |
16 | { |
|
15 | { | |
17 | Q_OBJECT |
|
16 | Q_OBJECT | |
18 | public: |
|
17 | public: | |
19 | QStackedBarChartSeries(QBarCategory *category, QObject* parent=0); |
|
18 | QStackedBarChartSeries(QBarCategory *category, QObject* parent=0); | |
20 |
|
19 | |||
21 | // from QChartSeries |
|
20 | // from QChartSeries | |
22 | virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeStackedBar; } |
|
21 | virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeStackedBar; } | |
23 |
|
22 | |||
24 | void addBarSet(QBarSet *set); // Takes ownership |
|
23 | void addBarSet(QBarSet *set); // Takes ownership | |
25 | void removeBarSet(QBarSet *set); // Also deletes the set, if set is owned. |
|
24 | void removeBarSet(QBarSet *set); // Also deletes the set, if set is owned. | |
26 | int countSets(); |
|
25 | int countSets(); | |
27 | QBarSet* nextSet(bool first=false); // Returns first set, if called with true |
|
26 | QBarSet* nextSet(bool first=false); // Returns first set, if called with true | |
28 |
|
27 | |||
29 | //TODO: |
|
28 | //TODO: | |
30 | //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) | |
31 |
|
30 | |||
32 | // TODO: Functions below this are not part of api and will be moved |
|
31 | // TODO: Functions below this are not part of api and will be moved | |
33 | // to private implementation, when we start using it (not part of api) |
|
32 | // to private implementation, when we start using it (not part of api) | |
34 | int countCategories(); |
|
33 | int countCategories(); | |
35 | qreal min(); |
|
34 | qreal min(); | |
36 | qreal max(); |
|
35 | qreal max(); | |
37 | qreal valueAt(int set, int category); |
|
36 | qreal valueAt(int set, int category); | |
38 | qreal maxCategorySum(); |
|
37 | qreal maxCategorySum(); | |
39 |
|
38 | |||
40 | BarChartModel& model(); |
|
39 | BarChartModel& model(); | |
41 |
|
40 | |||
42 | signals: |
|
41 | signals: | |
43 | void changed(int index); |
|
42 | void changed(int index); | |
44 |
|
43 | |||
45 | public Q_SLOTS: |
|
44 | public Q_SLOTS: | |
46 |
|
45 | |||
47 | private: |
|
46 | private: | |
48 |
|
47 | |||
49 | StackedBarPresenter* mStackedBarGroup; |
|
|||
50 | BarChartModel* mModel; |
|
48 | BarChartModel* mModel; | |
51 | }; |
|
49 | }; | |
52 |
|
50 | |||
53 | QTCOMMERCIALCHART_END_NAMESPACE |
|
51 | QTCOMMERCIALCHART_END_NAMESPACE | |
54 |
|
52 | |||
55 | #endif // STACKEDBARCHARTSERIES_H |
|
53 | #endif // STACKEDBARCHARTSERIES_H |
@@ -1,120 +1,120 | |||||
1 | !include( ../common.pri ):error( Couldn't find the common.pri file! ) |
|
1 | !include( ../common.pri ):error( Couldn't find the common.pri file! ) | |
2 | TARGET = QtCommercialChart |
|
2 | TARGET = QtCommercialChart | |
3 | DESTDIR = $$CHART_BUILD_LIB_DIR |
|
3 | DESTDIR = $$CHART_BUILD_LIB_DIR | |
4 | TEMPLATE = lib |
|
4 | TEMPLATE = lib | |
5 | QT += core \ |
|
5 | QT += core \ | |
6 | gui |
|
6 | gui | |
7 | CONFIG += debug_and_release |
|
7 | CONFIG += debug_and_release | |
8 | CONFIG(debug, debug|release):TARGET = QtCommercialChartd |
|
8 | CONFIG(debug, debug|release):TARGET = QtCommercialChartd | |
9 | SOURCES += \ |
|
9 | SOURCES += \ | |
10 | barchart/bar.cpp \ |
|
10 | barchart/bar.cpp \ | |
11 | barchart/barlabel.cpp \ |
|
11 | barchart/barlabel.cpp \ | |
12 | barchart/barchartmodel.cpp \ |
|
12 | barchart/barchartmodel.cpp \ | |
13 | barchart/separator.cpp \ |
|
13 | barchart/separator.cpp \ | |
14 | barchart/qbarset.cpp \ |
|
14 | barchart/qbarset.cpp \ | |
15 | barchart/qbarcategory.cpp \ |
|
15 | barchart/qbarcategory.cpp \ | |
16 | barchart/qbarchartseries.cpp \ |
|
16 | barchart/qbarchartseries.cpp \ | |
17 | barchart/qpercentbarchartseries.cpp \ |
|
17 | barchart/qpercentbarchartseries.cpp \ | |
18 | barchart/qstackedbarchartseries.cpp \ |
|
18 | barchart/qstackedbarchartseries.cpp \ | |
19 | barchart/barpresenterbase.cpp \ |
|
19 | barchart/barpresenterbase.cpp \ | |
20 | barchart/barpresenter.cpp \ |
|
20 | barchart/barpresenter.cpp \ | |
21 | barchart/stackedbarpresenter.cpp \ |
|
21 | barchart/stackedbarpresenter.cpp \ | |
22 | barchart/percentbarpresenter.cpp \ |
|
22 | barchart/percentbarpresenter.cpp \ | |
23 | linechart/linechartanimationitem.cpp \ |
|
23 | linechart/linechartanimationitem.cpp \ | |
24 | linechart/linechartitem.cpp \ |
|
24 | linechart/linechartitem.cpp \ | |
25 | linechart/qlinechartseries.cpp \ |
|
25 | linechart/qlinechartseries.cpp \ | |
26 | qchart.cpp \ |
|
26 | qchart.cpp \ | |
27 | axisitem.cpp \ |
|
27 | axisitem.cpp \ | |
28 | qchartview.cpp \ |
|
28 | qchartview.cpp \ | |
29 | qchartseries.cpp \ |
|
29 | qchartseries.cpp \ | |
30 | qchartaxis.cpp \ |
|
30 | qchartaxis.cpp \ | |
31 | charttheme.cpp \ |
|
31 | charttheme.cpp \ | |
32 | chartdataset.cpp \ |
|
32 | chartdataset.cpp \ | |
33 | chartpresenter.cpp \ |
|
33 | chartpresenter.cpp \ | |
34 | domain.cpp |
|
34 | domain.cpp | |
35 | PRIVATE_HEADERS += linechart/linechartitem_p.h \ |
|
35 | PRIVATE_HEADERS += linechart/linechartitem_p.h \ | |
36 | linechart/linechartanimationitem_p.h \ |
|
36 | linechart/linechartanimationitem_p.h \ | |
37 | barchart/barlabel_p.h \ |
|
37 | barchart/barlabel_p.h \ | |
38 | barchart/bar_p.h \ |
|
38 | barchart/bar_p.h \ | |
39 | barchart/separator_p.h \ |
|
39 | barchart/separator_p.h \ | |
40 | barchart/barchartmodel_p.h \ |
|
40 | barchart/barchartmodel_p.h \ | |
|
41 | barchart/barpresenter.h \ | |||
|
42 | barchart/stackedbarpresenter.h \ | |||
|
43 | barchart/percentbarpresenter.h \ | |||
|
44 | barchart/barpresenterbase.h \ | |||
41 | axisitem_p.h \ |
|
45 | axisitem_p.h \ | |
42 | chartitem_p.h \ |
|
46 | chartitem_p.h \ | |
43 | charttheme_p.h \ |
|
47 | charttheme_p.h \ | |
44 | chartdataset_p.h \ |
|
48 | chartdataset_p.h \ | |
45 | chartpresenter_p.h \ |
|
49 | chartpresenter_p.h \ | |
46 | domain_p.h |
|
50 | domain_p.h | |
47 | PUBLIC_HEADERS += linechart/qlinechartseries.h \ |
|
51 | PUBLIC_HEADERS += linechart/qlinechartseries.h \ | |
48 | barchart/qbarchartseries.h \ |
|
52 | barchart/qbarchartseries.h \ | |
49 | barchart/barpresenter.h \ |
|
|||
50 | barchart/qstackedbarchartseries.h \ |
|
53 | barchart/qstackedbarchartseries.h \ | |
51 | barchart/stackedbarpresenter.h \ |
|
|||
52 | barchart/qpercentbarchartseries.h \ |
|
54 | barchart/qpercentbarchartseries.h \ | |
53 | barchart/percentbarpresenter.h \ |
|
|||
54 | barchart/barpresenterbase.h \ |
|
|||
55 | barchart/qbarset.h \ |
|
55 | barchart/qbarset.h \ | |
56 | barchart/qbarcategory.h \ |
|
56 | barchart/qbarcategory.h \ | |
57 | qchartseries.h \ |
|
57 | qchartseries.h \ | |
58 | qchart.h \ |
|
58 | qchart.h \ | |
59 | qchartglobal.h \ |
|
59 | qchartglobal.h \ | |
60 | qchartview.h \ |
|
60 | qchartview.h \ | |
61 | qchartaxis.h |
|
61 | qchartaxis.h | |
62 |
|
62 | |||
63 | include(piechart/piechart.pri) |
|
63 | include(piechart/piechart.pri) | |
64 | include(scatterseries/scatter.pri) |
|
64 | include(scatterseries/scatter.pri) | |
65 |
|
65 | |||
66 | THEMES += themes/chartthemeicy_p.h \ |
|
66 | THEMES += themes/chartthemeicy_p.h \ | |
67 | themes/chartthemegrayscale_p.h \ |
|
67 | themes/chartthemegrayscale_p.h \ | |
68 | themes/chartthemescientific_p.h \ |
|
68 | themes/chartthemescientific_p.h \ | |
69 | themes/chartthemevanilla_p.h |
|
69 | themes/chartthemevanilla_p.h | |
70 | HEADERS += $$PUBLIC_HEADERS |
|
70 | HEADERS += $$PUBLIC_HEADERS | |
71 | HEADERS += $$PRIVATE_HEADERS |
|
71 | HEADERS += $$PRIVATE_HEADERS | |
72 | HEADERS += $$THEMES |
|
72 | HEADERS += $$THEMES | |
73 | INCLUDEPATH += linechart \ |
|
73 | INCLUDEPATH += linechart \ | |
74 | barchart \ |
|
74 | barchart \ | |
75 | themes \ |
|
75 | themes \ | |
76 | . |
|
76 | . | |
77 | OBJECTS_DIR = $$CHART_BUILD_DIR/lib |
|
77 | OBJECTS_DIR = $$CHART_BUILD_DIR/lib | |
78 | MOC_DIR = $$CHART_BUILD_DIR/lib |
|
78 | MOC_DIR = $$CHART_BUILD_DIR/lib | |
79 | UI_DIR = $$CHART_BUILD_DIR/lib |
|
79 | UI_DIR = $$CHART_BUILD_DIR/lib | |
80 | RCC_DIR = $$CHART_BUILD_DIR/lib |
|
80 | RCC_DIR = $$CHART_BUILD_DIR/lib | |
81 | DEFINES += QTCOMMERCIALCHART_LIBRARY |
|
81 | DEFINES += QTCOMMERCIALCHART_LIBRARY | |
82 | public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart |
|
82 | public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart | |
83 | public_headers.files = $$PUBLIC_HEADERS |
|
83 | public_headers.files = $$PUBLIC_HEADERS | |
84 | target.path = $$[QT_INSTALL_LIBS] |
|
84 | target.path = $$[QT_INSTALL_LIBS] | |
85 | INSTALLS += target \ |
|
85 | INSTALLS += target \ | |
86 | public_headers |
|
86 | public_headers | |
87 | install_build_public_headers.name = bild_public_headers |
|
87 | install_build_public_headers.name = bild_public_headers | |
88 | install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h |
|
88 | install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h | |
89 | install_build_public_headers.input = PUBLIC_HEADERS |
|
89 | install_build_public_headers.input = PUBLIC_HEADERS | |
90 | install_build_public_headers.commands = $$QMAKE_COPY \ |
|
90 | install_build_public_headers.commands = $$QMAKE_COPY \ | |
91 | ${QMAKE_FILE_NAME} \ |
|
91 | ${QMAKE_FILE_NAME} \ | |
92 | $$CHART_BUILD_PUBLIC_HEADER_DIR |
|
92 | $$CHART_BUILD_PUBLIC_HEADER_DIR | |
93 | install_build_public_headers.CONFIG += target_predeps \ |
|
93 | install_build_public_headers.CONFIG += target_predeps \ | |
94 | no_link |
|
94 | no_link | |
95 | install_build_private_headers.name = bild_private_headers |
|
95 | install_build_private_headers.name = bild_private_headers | |
96 | install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h |
|
96 | install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h | |
97 | install_build_private_headers.input = PRIVATE_HEADERS |
|
97 | install_build_private_headers.input = PRIVATE_HEADERS | |
98 | install_build_private_headers.commands = $$QMAKE_COPY \ |
|
98 | install_build_private_headers.commands = $$QMAKE_COPY \ | |
99 | ${QMAKE_FILE_NAME} \ |
|
99 | ${QMAKE_FILE_NAME} \ | |
100 | $$CHART_BUILD_PRIVATE_HEADER_DIR |
|
100 | $$CHART_BUILD_PRIVATE_HEADER_DIR | |
101 | install_build_private_headers.CONFIG += target_predeps \ |
|
101 | install_build_private_headers.CONFIG += target_predeps \ | |
102 | no_link |
|
102 | no_link | |
103 | QMAKE_EXTRA_COMPILERS += install_build_public_headers install_build_private_headers |
|
103 | QMAKE_EXTRA_COMPILERS += install_build_public_headers install_build_private_headers | |
104 | chartversion.target = qchartversion_p.h |
|
104 | chartversion.target = qchartversion_p.h | |
105 | chartversion.commands = @echo \ |
|
105 | chartversion.commands = @echo \ | |
106 | "build_time" \ |
|
106 | "build_time" \ | |
107 | > \ |
|
107 | > \ | |
108 | $$chartversion.target; |
|
108 | $$chartversion.target; | |
109 | chartversion.depends = $$HEADERS \ |
|
109 | chartversion.depends = $$HEADERS \ | |
110 | $$SOURCES |
|
110 | $$SOURCES | |
111 | PRE_TARGETDEPS += qchartversion_p.h |
|
111 | PRE_TARGETDEPS += qchartversion_p.h | |
112 | QMAKE_CLEAN += qchartversion_p.h |
|
112 | QMAKE_CLEAN += qchartversion_p.h | |
113 | QMAKE_EXTRA_TARGETS += chartversion |
|
113 | QMAKE_EXTRA_TARGETS += chartversion | |
114 | unix:QMAKE_DISTCLEAN += -r \ |
|
114 | unix:QMAKE_DISTCLEAN += -r \ | |
115 | $$CHART_BUILD_HEADER_DIR \ |
|
115 | $$CHART_BUILD_HEADER_DIR \ | |
116 | $$CHART_BUILD_LIB_DIR |
|
116 | $$CHART_BUILD_LIB_DIR | |
117 | win32:QMAKE_DISTCLEAN += /Q \ |
|
117 | win32:QMAKE_DISTCLEAN += /Q \ | |
118 | $$CHART_BUILD_HEADER_DIR \ |
|
118 | $$CHART_BUILD_HEADER_DIR \ | |
119 | $$CHART_BUILD_LIB_DIR |
|
119 | $$CHART_BUILD_LIB_DIR | |
120 |
|
120 |
General Comments 0
You need to be logged in to leave comments.
Login now