##// END OF EJS Templates
removed barchartseriesbase. functionality is now in model
sauimone -
r172:aba5dff73719
parent child
Show More
@@ -25,11 +25,11 int main(int argc, char *argv[])
25 QBarSet barSet4;
25 QBarSet barSet4;
26
26
27 // Create some test data to chart
27 // Create some test data to chart
28 barSet0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10;
28 barSet0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12;
29 barSet1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0;
29 barSet1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0 << 4 << 2;
30 barSet2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1;
30 barSet2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1 << 3 << 5;
31 barSet3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5;
31 barSet3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7;
32 barSet4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10;
32 barSet4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6;
33
33
34 series0->addBarSet(barSet0);
34 series0->addBarSet(barSet0);
35 series0->addBarSet(barSet1);
35 series0->addBarSet(barSet1);
@@ -25,11 +25,11 int main(int argc, char *argv[])
25 QBarSet barSet4;
25 QBarSet barSet4;
26
26
27 // Create some test data to chart
27 // Create some test data to chart
28 barSet0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10;
28 barSet0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12;
29 barSet1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0;
29 barSet1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0 << 4 << 2;
30 barSet2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1;
30 barSet2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1 << 3 << 5;
31 barSet3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5;
31 barSet3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7;
32 barSet4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10;
32 barSet4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6;
33
33
34 series0->addBarSet(barSet0);
34 series0->addBarSet(barSet0);
35 series0->addBarSet(barSet1);
35 series0->addBarSet(barSet1);
@@ -25,11 +25,11 int main(int argc, char *argv[])
25 QBarSet barSet4;
25 QBarSet barSet4;
26
26
27 // Create some test data to chart
27 // Create some test data to chart
28 barSet0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10;
28 barSet0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12;
29 barSet1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0;
29 barSet1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0 << 4 << 2;
30 barSet2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1;
30 barSet2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1 << 3 << 5;
31 barSet3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5;
31 barSet3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7;
32 barSet4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10;
32 barSet4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6;
33
33
34 series0->addBarSet(barSet0);
34 series0->addBarSet(barSet0);
35 series0->addBarSet(barSet1);
35 series0->addBarSet(barSet1);
@@ -133,6 +133,11 qreal BarChartModel::maxCategorySum()
133 return max;
133 return max;
134 }
134 }
135
135
136 QString BarChartModel::label(int category)
137 {
138 return mCategory.label(category);
139 }
140
136 #include "moc_barchartmodel_p.cpp"
141 #include "moc_barchartmodel_p.cpp"
137
142
138 QTCOMMERCIALCHART_END_NAMESPACE
143 QTCOMMERCIALCHART_END_NAMESPACE
@@ -33,6 +33,8 public:
33 qreal categorySum(int column);
33 qreal categorySum(int column);
34 qreal maxCategorySum(); // returns maximum sum of sets in all categories.
34 qreal maxCategorySum(); // returns maximum sum of sets in all categories.
35
35
36 QString label(int category);
37
36 signals:
38 signals:
37 void modelUpdated();
39 void modelUpdated();
38
40
@@ -1,23 +1,59
1 #include <QDebug>
1 #include <QDebug>
2 #include "barchartseries.h"
2 #include "barchartseries.h"
3 #include "qbarcategory.h"
4 #include "qbarset.h"
5 #include "barchartmodel_p.h"
6
3
7
4 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
5
9
6 BarChartSeries::BarChartSeries(QBarCategory &category, QObject *parent)
10 BarChartSeries::BarChartSeries(QBarCategory &category, QObject *parent)
7 : BarChartSeriesBase(category, parent)
11 : QChartSeries(parent)
12 ,mModel(new BarChartModel(category, this))
8 {
13 {
9 }
14 }
10
15
11 void BarChartSeries::addBarSet(QBarSet &set)
16 void BarChartSeries::addBarSet(QBarSet &set)
12 {
17 {
13 BarChartSeriesBase::addBarSet(set);
18 mModel->addBarSet(set);
14 }
19 }
15
20
16 void BarChartSeries::removeBarSet(QBarSet &set)
21 void BarChartSeries::removeBarSet(QBarSet &set)
17 {
22 {
18 BarChartSeriesBase::removeBarSet(set);
23 mModel->removeBarSet(set);
24 }
25
26 int BarChartSeries::countCategories()
27 {
28 return mModel->countCategories();
29 }
30
31 qreal BarChartSeries::min()
32 {
33 return mModel->min();
34 }
35
36 qreal BarChartSeries::max()
37 {
38 return mModel->max();
19 }
39 }
20
40
41 qreal BarChartSeries::valueAt(int set, int category)
42 {
43 return mModel->valueAt(set,category);
44 }
45
46 qreal BarChartSeries::maxCategorySum()
47 {
48 return mModel->maxCategorySum();
49 }
50
51 BarChartModel& BarChartSeries::model()
52 {
53 return *mModel;
54 }
55
56
21 #include "moc_barchartseries.cpp"
57 #include "moc_barchartseries.cpp"
22
58
23 QTCOMMERCIALCHART_END_NAMESPACE
59 QTCOMMERCIALCHART_END_NAMESPACE
@@ -3,14 +3,17
3
3
4 #include <QList>
4 #include <QList>
5 #include <QAbstractItemModel>
5 #include <QAbstractItemModel>
6 #include "barchartseriesbase.h"
6 #include "qchartseries.h"
7
8 class BarGroup;
9
7
10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
11
9
10 class QBarCategory;
11 class QBarSet;
12 class BarGroup;
13 class BarChartModel;
14
12 // Container for series
15 // Container for series
13 class QTCOMMERCIALCHART_EXPORT BarChartSeries : public BarChartSeriesBase
16 class QTCOMMERCIALCHART_EXPORT BarChartSeries : public QChartSeries
14 {
17 {
15 Q_OBJECT
18 Q_OBJECT
16 public:
19 public:
@@ -22,11 +25,24 public:
22 void addBarSet(QBarSet &set);
25 void addBarSet(QBarSet &set);
23 void removeBarSet(QBarSet &set);
26 void removeBarSet(QBarSet &set);
24
27
28 int countCategories();
29 qreal min();
30 qreal max();
31 qreal valueAt(int set, int category);
32 qreal maxCategorySum();
33
34 BarChartModel& model();
35
36 signals:
37 void changed(int index);
38
25 public Q_SLOTS:
39 public Q_SLOTS:
26
40
27 private:
41 private:
28
42
29 BarGroup* mBarGroup;
43 BarGroup* mBarGroup;
44 BarChartModel* mModel;
45
30 };
46 };
31
47
32 QTCOMMERCIALCHART_END_NAMESPACE
48 QTCOMMERCIALCHART_END_NAMESPACE
@@ -5,8 +5,8
5
5
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7
7
8 BarGroup::BarGroup(BarChartSeries& series, QGraphicsItem *parent) :
8 BarGroup::BarGroup(BarChartModel& model, QGraphicsItem *parent) :
9 BarGroupBase(series,parent)
9 BarGroupBase(model,parent)
10 {
10 {
11 mBarDefaultWidth = 10;
11 mBarDefaultWidth = 10;
12 }
12 }
@@ -12,7 +12,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
12 class BarGroup : public BarGroupBase
12 class BarGroup : public BarGroupBase
13 {
13 {
14 public:
14 public:
15 explicit BarGroup(BarChartSeries& series, QGraphicsItem *parent = 0);
15 explicit BarGroup(BarChartModel& model, QGraphicsItem *parent = 0);
16
16
17 private:
17 private:
18
18
@@ -2,19 +2,18
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 "barchartseriesbase.h"
6 #include <QDebug>
5 #include <QDebug>
7
6
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
8
10 BarGroupBase::BarGroupBase(BarChartSeriesBase& series, QGraphicsItem *parent)
9 BarGroupBase::BarGroupBase(BarChartModel& model, QGraphicsItem *parent)
11 : ChartItem(parent)
10 : ChartItem(parent)
12 ,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
13 ,mLayoutSet(false)
12 ,mLayoutSet(false)
14 ,mLayoutDirty(true)
13 ,mLayoutDirty(true)
15 ,mSeparatorsVisible(true)
14 ,mSeparatorsVisible(true)
16 ,mModel(series.model())
15 ,mModel(model)
17 ,mSeries(series)
16 // ,mSeries(series)
18 {
17 {
19 dataChanged();
18 dataChanged();
20 }
19 }
@@ -65,7 +64,7 void BarGroupBase::resetColors()
65
64
66 void BarGroupBase::dataChanged()
65 void BarGroupBase::dataChanged()
67 {
66 {
68 // qDebug() << "BarGroupBase::dataChanged";
67 // TODO: performance optimizations. Do we really need to delete and create items every time data is changed or can we reuse them?
69
68
70 // Delete old bars
69 // Delete old bars
71 foreach (QGraphicsItem* item, childItems()) {
70 foreach (QGraphicsItem* item, childItems()) {
@@ -79,12 +78,10 void BarGroupBase::dataChanged()
79 childItems().append(bar);
78 childItems().append(bar);
80 }
79 }
81
80
82 // TODO: labels from series. This creates just some example labels
83 int count = mModel.countCategories(); // mSeries.countColumns();
81 int count = mModel.countCategories(); // mSeries.countColumns();
84 for (int i=0; i<count; i++) {
82 for (int i=0; i<count; i++) {
85 BarLabel* label = new BarLabel(this);
83 BarLabel* label = new BarLabel(this);
86 // QString text("Label " + QString::number(i));
84 label->set(mModel.label(i));
87 label->set(mSeries.label(i));
88 childItems().append(label);
85 childItems().append(label);
89 }
86 }
90
87
@@ -2,7 +2,6
2 #define BARGROUPBASE_H
2 #define BARGROUPBASE_H
3
3
4 #include "chartitem_p.h"
4 #include "chartitem_p.h"
5 #include "barchartseriesbase.h"
6 #include "barchartmodel_p.h"
5 #include "barchartmodel_p.h"
7 #include <QGraphicsItem>
6 #include <QGraphicsItem>
8
7
@@ -13,7 +12,7 class BarGroupBase : public QObject, public ChartItem
13 {
12 {
14 Q_OBJECT
13 Q_OBJECT
15 public:
14 public:
16 BarGroupBase(BarChartSeriesBase& series, QGraphicsItem *parent = 0);
15 BarGroupBase(BarChartModel& model, QGraphicsItem *parent = 0);
17 void setSeparatorsVisible(bool visible = true);
16 void setSeparatorsVisible(bool visible = true);
18
17
19 public: // From ChartItem
18 public: // From ChartItem
@@ -53,7 +52,6 protected:
53 QList<QColor> mColors; // List of colors for series for now
52 QList<QColor> mColors; // List of colors for series for now
54 bool mSeparatorsVisible;
53 bool mSeparatorsVisible;
55 BarChartModel& mModel;
54 BarChartModel& mModel;
56 BarChartSeriesBase& mSeries;
57
55
58 };
56 };
59
57
@@ -3,24 +3,59
3 #include <limits.h>
3 #include <limits.h>
4 #include <QDebug>
4 #include <QDebug>
5 #include "percentbarchartseries.h"
5 #include "percentbarchartseries.h"
6 #include "qbarset.h"
7 #include "qbarcategory.h"
8 #include "barchartmodel_p.h"
6
9
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8
11
9 PercentBarChartSeries::PercentBarChartSeries(QBarCategory &category, QObject *parent) :
12 PercentBarChartSeries::PercentBarChartSeries(QBarCategory &category, QObject *parent)
10 BarChartSeriesBase(category, parent)
13 : QChartSeries(parent)
14 ,mModel(new BarChartModel(category, this))
11 {
15 {
12 }
16 }
13
17
14 void PercentBarChartSeries::addBarSet(QBarSet &set)
18 void PercentBarChartSeries::addBarSet(QBarSet &set)
15 {
19 {
16 BarChartSeriesBase::addBarSet(set);
20 mModel->addBarSet(set);
17 }
21 }
18
22
19 void PercentBarChartSeries::removeBarSet(QBarSet &set)
23 void PercentBarChartSeries::removeBarSet(QBarSet &set)
20 {
24 {
21 BarChartSeriesBase::removeBarSet(set);
25 mModel->removeBarSet(set);
22 }
26 }
23
27
28 int PercentBarChartSeries::countCategories()
29 {
30 return mModel->countCategories();
31 }
32
33 qreal PercentBarChartSeries::min()
34 {
35 return mModel->min();
36 }
37
38 qreal PercentBarChartSeries::max()
39 {
40 return mModel->max();
41 }
42
43 qreal PercentBarChartSeries::valueAt(int set, int category)
44 {
45 return mModel->valueAt(set,category);
46 }
47
48 qreal PercentBarChartSeries::maxCategorySum()
49 {
50 return mModel->maxCategorySum();
51 }
52
53 BarChartModel& PercentBarChartSeries::model()
54 {
55 return *mModel;
56 }
57
58
24 #include "moc_percentbarchartseries.cpp"
59 #include "moc_percentbarchartseries.cpp"
25
60
26 QTCOMMERCIALCHART_END_NAMESPACE
61 QTCOMMERCIALCHART_END_NAMESPACE
@@ -3,13 +3,16
3
3
4 #include <QList>
4 #include <QList>
5 #include <QAbstractItemModel>
5 #include <QAbstractItemModel>
6 #include "barchartseriesbase.h"
6 #include "qchartseries.h"
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 class PercentBarGroup;
10 class PercentBarGroup;
11 class QBarCategory;
12 class QBarSet;
13 class BarChartModel;
11
14
12 class QTCOMMERCIALCHART_EXPORT PercentBarChartSeries : public BarChartSeriesBase
15 class QTCOMMERCIALCHART_EXPORT PercentBarChartSeries : public QChartSeries
13 {
16 {
14 Q_OBJECT
17 Q_OBJECT
15 public:
18 public:
@@ -21,11 +24,25 public:
21 void addBarSet(QBarSet &set);
24 void addBarSet(QBarSet &set);
22 void removeBarSet(QBarSet &set);
25 void removeBarSet(QBarSet &set);
23
26
27 int countCategories();
28 qreal min();
29 qreal max();
30 qreal valueAt(int set, int category);
31 qreal maxCategorySum();
32
33 BarChartModel& model();
34
35 signals:
36 void changed(int index);
37
24 public Q_SLOTS:
38 public Q_SLOTS:
25
39
40
26 private:
41 private:
27
42
28 PercentBarGroup* mPercentBarGroup;
43 PercentBarGroup* mPercentBarGroup;
44 BarChartModel* mModel;
45
29 };
46 };
30
47
31 QTCOMMERCIALCHART_END_NAMESPACE
48 QTCOMMERCIALCHART_END_NAMESPACE
@@ -7,8 +7,8
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8
8
9
9
10 PercentBarGroup::PercentBarGroup(PercentBarChartSeries& series, QGraphicsItem *parent) :
10 PercentBarGroup::PercentBarGroup(BarChartModel& model, QGraphicsItem *parent) :
11 BarGroupBase(series, parent)
11 BarGroupBase(model, parent)
12 {
12 {
13 }
13 }
14
14
@@ -12,7 +12,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
12 class PercentBarGroup : public BarGroupBase
12 class PercentBarGroup : public BarGroupBase
13 {
13 {
14 public:
14 public:
15 PercentBarGroup(PercentBarChartSeries& series, QGraphicsItem *parent = 0);
15 PercentBarGroup(BarChartModel& model, QGraphicsItem *parent = 0);
16
16
17 private:
17 private:
18
18
@@ -17,9 +17,9 int QBarCategory::count()
17 return mList.count();
17 return mList.count();
18 }
18 }
19
19
20 QList<QString>& QBarCategory::items()
20 QString QBarCategory::label(int category)
21 {
21 {
22 return mList;
22 return mList.at(category);
23 }
23 }
24
24
25
25
@@ -5,7 +5,7
5
5
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7
7
8 class QTCOMMERCIALCHART_EXPORT QBarCategory // : pubclic QObject // TODO: Need for this?
8 class QTCOMMERCIALCHART_EXPORT QBarCategory // TODO? : pubclic QObject
9 {
9 {
10 public:
10 public:
11 QBarCategory();
11 QBarCategory();
@@ -14,7 +14,7 public:
14
14
15 // Number of items in category
15 // Number of items in category
16 int count();
16 int count();
17 QList<QString>& items();
17 QString label(int category);
18
18
19 public:
19 public:
20
20
@@ -1,24 +1,59
1 #include <limits.h>
1 #include <limits.h>
2 #include <QDebug>
2 #include <QDebug>
3 #include "stackedbarchartseries.h"
3 #include "stackedbarchartseries.h"
4 #include "qbarcategory.h"
5 #include "qbarset.h"
6 #include "barchartmodel_p.h"
4
7
5 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
6
9
7 StackedBarChartSeries::StackedBarChartSeries(QBarCategory &category, QObject *parent) :
10 StackedBarChartSeries::StackedBarChartSeries(QBarCategory &category, QObject *parent)
8 BarChartSeriesBase(category, parent)
11 : QChartSeries(parent)
12 ,mModel(new BarChartModel(category, this))
9 {
13 {
10 }
14 }
11
15
12 void StackedBarChartSeries::addBarSet(QBarSet &set)
16 void StackedBarChartSeries::addBarSet(QBarSet &set)
13 {
17 {
14 BarChartSeriesBase::addBarSet(set);
18 mModel->addBarSet(set);
15 }
19 }
16
20
17 void StackedBarChartSeries::removeBarSet(QBarSet &set)
21 void StackedBarChartSeries::removeBarSet(QBarSet &set)
18 {
22 {
19 BarChartSeriesBase::removeBarSet(set);
23 mModel->removeBarSet(set);
20 }
24 }
21
25
26 int StackedBarChartSeries::countCategories()
27 {
28 return mModel->countCategories();
29 }
30
31 qreal StackedBarChartSeries::min()
32 {
33 return mModel->min();
34 }
35
36 qreal StackedBarChartSeries::max()
37 {
38 return mModel->max();
39 }
40
41 qreal StackedBarChartSeries::valueAt(int set, int category)
42 {
43 return mModel->valueAt(set,category);
44 }
45
46 qreal StackedBarChartSeries::maxCategorySum()
47 {
48 return mModel->maxCategorySum();
49 }
50
51 BarChartModel& StackedBarChartSeries::model()
52 {
53 return *mModel;
54 }
55
56
22 #include "moc_stackedbarchartseries.cpp"
57 #include "moc_stackedbarchartseries.cpp"
23
58
24 QTCOMMERCIALCHART_END_NAMESPACE
59 QTCOMMERCIALCHART_END_NAMESPACE
@@ -3,13 +3,16
3
3
4 #include <QList>
4 #include <QList>
5 #include <QAbstractItemModel>
5 #include <QAbstractItemModel>
6 #include "barchartseriesbase.h"
6 #include "qchartseries.h"
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 class StackedBarGroup;
10 class StackedBarGroup;
11 class QBarCategory;
12 class QBarSet;
13 class BarChartModel;
11
14
12 class QTCOMMERCIALCHART_EXPORT StackedBarChartSeries : public BarChartSeriesBase
15 class QTCOMMERCIALCHART_EXPORT StackedBarChartSeries : public QChartSeries
13 {
16 {
14 Q_OBJECT
17 Q_OBJECT
15 public:
18 public:
@@ -21,11 +24,23 public:
21 void addBarSet(QBarSet &set);
24 void addBarSet(QBarSet &set);
22 void removeBarSet(QBarSet &set);
25 void removeBarSet(QBarSet &set);
23
26
27 int countCategories();
28 qreal min();
29 qreal max();
30 qreal valueAt(int set, int category);
31 qreal maxCategorySum();
32
33 BarChartModel& model();
34
35 signals:
36 void changed(int index);
37
24 public Q_SLOTS:
38 public Q_SLOTS:
25
39
26 private:
40 private:
27
41
28 StackedBarGroup* mStackedBarGroup;
42 StackedBarGroup* mStackedBarGroup;
43 BarChartModel* mModel;
29 };
44 };
30
45
31 QTCOMMERCIALCHART_END_NAMESPACE
46 QTCOMMERCIALCHART_END_NAMESPACE
@@ -6,8 +6,8
6
6
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8
8
9 StackedBarGroup::StackedBarGroup(StackedBarChartSeries& series, QGraphicsItem *parent) :
9 StackedBarGroup::StackedBarGroup(BarChartModel& model, QGraphicsItem *parent) :
10 BarGroupBase(series,parent)
10 BarGroupBase(model,parent)
11 {
11 {
12 }
12 }
13
13
@@ -10,7 +10,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 class StackedBarGroup : public BarGroupBase
10 class StackedBarGroup : public BarGroupBase
11 {
11 {
12 public:
12 public:
13 StackedBarGroup(StackedBarChartSeries& series, QGraphicsItem *parent = 0);
13 StackedBarGroup(BarChartModel& model, QGraphicsItem *parent = 0);
14
14
15 private:
15 private:
16 // From BarGroupBase
16 // From BarGroupBase
@@ -54,7 +54,7 void ChartDataSet::addSeries(QChartSeries* series)
54 case QChartSeries::SeriesTypeBar: {
54 case QChartSeries::SeriesTypeBar: {
55
55
56 BarChartSeries* barSeries = static_cast<BarChartSeries*>(series);
56 BarChartSeries* barSeries = static_cast<BarChartSeries*>(series);
57 qreal x = barSeries->countColumns();
57 qreal x = barSeries->countCategories();
58 qreal y = barSeries->max();
58 qreal y = barSeries->max();
59 domain.m_minX = qMin(domain.m_minX,x);
59 domain.m_minX = qMin(domain.m_minX,x);
60 domain.m_minY = qMin(domain.m_minY,y);
60 domain.m_minY = qMin(domain.m_minY,y);
@@ -65,8 +65,8 void ChartDataSet::addSeries(QChartSeries* series)
65 case QChartSeries::SeriesTypeStackedBar: {
65 case QChartSeries::SeriesTypeStackedBar: {
66
66
67 StackedBarChartSeries* stackedBarSeries = static_cast<StackedBarChartSeries*>(series);
67 StackedBarChartSeries* stackedBarSeries = static_cast<StackedBarChartSeries*>(series);
68 qreal x = stackedBarSeries->countColumns();
68 qreal x = stackedBarSeries->countCategories();
69 qreal y = stackedBarSeries->maxColumnSum();
69 qreal y = stackedBarSeries->maxCategorySum();
70 domain.m_minX = qMin(domain.m_minX,x);
70 domain.m_minX = qMin(domain.m_minX,x);
71 domain.m_minY = qMin(domain.m_minY,y);
71 domain.m_minY = qMin(domain.m_minY,y);
72 domain.m_maxX = qMax(domain.m_maxX,x);
72 domain.m_maxX = qMax(domain.m_maxX,x);
@@ -76,7 +76,7 void ChartDataSet::addSeries(QChartSeries* series)
76 case QChartSeries::SeriesTypePercentBar: {
76 case QChartSeries::SeriesTypePercentBar: {
77
77
78 PercentBarChartSeries* percentBarSeries = static_cast<PercentBarChartSeries*>(series);
78 PercentBarChartSeries* percentBarSeries = static_cast<PercentBarChartSeries*>(series);
79 qreal x = percentBarSeries->countColumns();
79 qreal x = percentBarSeries->countCategories();
80 domain.m_minX = qMin(domain.m_minX,x);
80 domain.m_minX = qMin(domain.m_minX,x);
81 domain.m_minY = 0;
81 domain.m_minY = 0;
82 domain.m_maxX = qMax(domain.m_maxX,x);
82 domain.m_maxX = qMax(domain.m_maxX,x);
@@ -91,7 +91,7 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
91
91
92 case QChartSeries::SeriesTypeBar: {
92 case QChartSeries::SeriesTypeBar: {
93 BarChartSeries* barSeries = static_cast<BarChartSeries*>(series);
93 BarChartSeries* barSeries = static_cast<BarChartSeries*>(series);
94 BarGroup* item = new BarGroup(*barSeries,m_chart);
94 BarGroup* item = new BarGroup(barSeries->model(),m_chart);
95 m_chartTheme->decorate(item,barSeries,m_chartItems.count());
95 m_chartTheme->decorate(item,barSeries,m_chartItems.count());
96 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
96 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
97 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
97 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
@@ -104,7 +104,7 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
104 case QChartSeries::SeriesTypeStackedBar: {
104 case QChartSeries::SeriesTypeStackedBar: {
105
105
106 StackedBarChartSeries* stackedBarSeries = static_cast<StackedBarChartSeries*>(series);
106 StackedBarChartSeries* stackedBarSeries = static_cast<StackedBarChartSeries*>(series);
107 StackedBarGroup* item = new StackedBarGroup(*stackedBarSeries,m_chart);
107 StackedBarGroup* item = new StackedBarGroup(stackedBarSeries->model(),m_chart);
108 m_chartTheme->decorate(item,stackedBarSeries,m_chartItems.count());
108 m_chartTheme->decorate(item,stackedBarSeries,m_chartItems.count());
109 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
109 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
110 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
110 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
@@ -116,7 +116,7 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
116 case QChartSeries::SeriesTypePercentBar: {
116 case QChartSeries::SeriesTypePercentBar: {
117
117
118 PercentBarChartSeries* percentBarSeries = static_cast<PercentBarChartSeries*>(series);
118 PercentBarChartSeries* percentBarSeries = static_cast<PercentBarChartSeries*>(series);
119 PercentBarGroup* item = new PercentBarGroup(*percentBarSeries,m_chart);
119 PercentBarGroup* item = new PercentBarGroup(percentBarSeries->model(),m_chart);
120 m_chartTheme->decorate(item,percentBarSeries ,m_chartItems.count());
120 m_chartTheme->decorate(item,percentBarSeries ,m_chartItems.count());
121 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
121 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
122 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
122 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
@@ -17,7 +17,6 SOURCES += barchart/barchartseries.cpp \
17 barchart/barchartmodel.cpp \
17 barchart/barchartmodel.cpp \
18 barchart/separator.cpp \
18 barchart/separator.cpp \
19 barchart/bargroupbase.cpp \
19 barchart/bargroupbase.cpp \
20 barchart/barchartseriesbase.cpp \
21 barchart/qbarset.cpp \
20 barchart/qbarset.cpp \
22 barchart/qbarcategory.cpp \
21 barchart/qbarcategory.cpp \
23 linechart/linechartanimationitem.cpp \
22 linechart/linechartanimationitem.cpp \
@@ -56,7 +55,6 PUBLIC_HEADERS += linechart/qlinechartseries.h \
56 barchart/stackedbargroup.h \
55 barchart/stackedbargroup.h \
57 barchart/percentbarchartseries.h \
56 barchart/percentbarchartseries.h \
58 barchart/percentbargroup.h \
57 barchart/percentbargroup.h \
59 barchart/barchartseriesbase.h \
60 barchart/bargroupbase.h \
58 barchart/bargroupbase.h \
61 barchart/qbarset.h \
59 barchart/qbarset.h \
62 barchart/qbarcategory.h \
60 barchart/qbarcategory.h \
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now