##// END OF EJS Templates
Common naming convention for barcharts
sauimone -
r216:abacdc3682d1
parent child
Show More
@@ -1,7 +1,7
1 1 #include <QApplication>
2 2 #include <QMainWindow>
3 3 #include <QStandardItemModel>
4 #include <barchartseries.h>
4 #include <qbarchartseries.h>
5 5 #include <qbarcategory.h>
6 6 #include <qbarset.h>
7 7 #include "chartwidget.h"
@@ -16,7 +16,7 int main(int argc, char *argv[])
16 16 QBarCategory *category = new QBarCategory;
17 17 *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
18 18
19 BarChartSeries* series0 = new BarChartSeries(category);
19 QBarChartSeries* series0 = new QBarChartSeries(category);
20 20
21 21 QBarSet *set0 = new QBarSet;
22 22 QBarSet *set1 = new QBarSet;
@@ -7,7 +7,7
7 7 #include <qscatterseries.h>
8 8 #include <qchartview.h>
9 9 #include <qchartaxis.h>
10 #include <barchartseries.h>
10 #include <qbarchartseries.h>
11 11 #include <qbarcategory.h>
12 12 #include <qbarset.h>
13 13 #include <QListWidget>
@@ -91,7 +91,7 void Widget::refreshChart()
91 91 QBarCategory* category = new QBarCategory;
92 92 for (int i = 0; i < selectedCountriesStrings.size(); i++)
93 93 *category << selectedCountriesStrings[i];
94 BarChartSeries* series0 = new BarChartSeries(category);
94 QBarChartSeries* series0 = new QBarChartSeries(category);
95 95
96 96 // prepare the selected counries SQL query
97 97 QString countriesQuery = "country IN (";
@@ -1,7 +1,7
1 1 #include <QApplication>
2 2 #include <QMainWindow>
3 3 #include <QStandardItemModel>
4 #include <percentbarchartseries.h>
4 #include <qpercentbarchartseries.h>
5 5 #include "chartwidget.h"
6 6 #include <qbarcategory.h>
7 7 #include <qbarset.h>
@@ -16,7 +16,7 int main(int argc, char *argv[])
16 16 QBarCategory *category = new QBarCategory;
17 17 *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
18 18
19 PercentBarChartSeries* series0 = new PercentBarChartSeries(category);
19 QPercentBarChartSeries* series0 = new QPercentBarChartSeries(category);
20 20
21 21 QBarSet *set0 = new QBarSet;
22 22 QBarSet *set1 = new QBarSet;
@@ -1,7 +1,7
1 1 #include <QApplication>
2 2 #include <QMainWindow>
3 3 #include <QStandardItemModel>
4 #include <stackedbarchartseries.h>
4 #include <qstackedbarchartseries.h>
5 5 #include "chartwidget.h"
6 6 #include <qbarset.h>
7 7 #include <qbarcategory.h>
@@ -16,7 +16,7 int main(int argc, char *argv[])
16 16 QBarCategory *category = new QBarCategory;
17 17 *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
18 18
19 StackedBarChartSeries* series0 = new StackedBarChartSeries(category);
19 QStackedBarChartSeries* series0 = new QStackedBarChartSeries(category);
20 20
21 21 QBarSet *set0 = new QBarSet;
22 22 QBarSet *set1 = new QBarSet;
@@ -1,4 +1,4
1 #include "bargroup.h"
1 #include "barpresenter.h"
2 2 #include "bar_p.h"
3 3 #include "barlabel_p.h"
4 4 #include "qbarset.h"
@@ -6,13 +6,13
6 6
7 7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 8
9 BarGroup::BarGroup(BarChartModel& model, QGraphicsItem *parent) :
10 BarGroupBase(model,parent)
9 BarPresenter::BarPresenter(BarChartModel& model, QGraphicsItem *parent) :
10 BarPresenterBase(model,parent)
11 11 {
12 12 mBarDefaultWidth = 5;
13 13 }
14 14
15 void BarGroup::layoutChanged()
15 void BarPresenter::layoutChanged()
16 16 {
17 17 // qDebug() << "BarGroup::layoutChanged";
18 18 // Scale bars to new layout
@@ -1,18 +1,18
1 1 #ifndef QBARGROUP_H
2 2 #define QBARGROUP_H
3 3
4 #include "bargroupbase.h"
5 #include "barchartseries.h"
4 #include "barpresenterbase.h"
5 #include "qbarchartseries.h"
6 6 #include <QGraphicsItem>
7 7
8 8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 9
10 10 // Base class for bar groups
11 11
12 class BarGroup : public BarGroupBase
12 class BarPresenter : public BarPresenterBase
13 13 {
14 14 public:
15 explicit BarGroup(BarChartModel& model, QGraphicsItem *parent = 0);
15 explicit BarPresenter(BarChartModel& model, QGraphicsItem *parent = 0);
16 16
17 17 private:
18 18
@@ -1,4 +1,4
1 #include "bargroupbase.h"
1 #include "barpresenterbase.h"
2 2 #include "bar_p.h"
3 3 #include "barlabel_p.h"
4 4 #include "separator_p.h"
@@ -6,7 +6,7
6 6
7 7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 8
9 BarGroupBase::BarGroupBase(BarChartModel& model, QGraphicsItem *parent)
9 BarPresenterBase::BarPresenterBase(BarChartModel& model, QGraphicsItem *parent)
10 10 : ChartItem(parent)
11 11 ,mBarDefaultWidth(20) // TODO: remove hard coding, when we have layout code ready
12 12 ,mLayoutSet(false)
@@ -17,12 +17,12 BarGroupBase::BarGroupBase(BarChartModel& model, QGraphicsItem *parent)
17 17 dataChanged();
18 18 }
19 19
20 void BarGroupBase::setSeparatorsVisible(bool visible)
20 void BarPresenterBase::setSeparatorsVisible(bool visible)
21 21 {
22 22 mSeparatorsVisible = visible;
23 23 }
24 24
25 void BarGroupBase::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
25 void BarPresenterBase::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
26 26 {
27 27 // qDebug() << "BarGroupBase::paint" << childItems().count();
28 28 if (!mLayoutSet) {
@@ -37,12 +37,12 void BarGroupBase::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
37 37 // }
38 38 }
39 39
40 QRectF BarGroupBase::boundingRect() const
40 QRectF BarPresenterBase::boundingRect() const
41 41 {
42 42 return QRectF(0,0,mWidth,mHeight);
43 43 }
44 44
45 void BarGroupBase::setBarWidth( int w )
45 void BarPresenterBase::setBarWidth( int w )
46 46 {
47 47 mBarDefaultWidth = w;
48 48 }
@@ -57,7 +57,7 void BarGroupBase::addBrush(QBrush brush)
57 57 mBrushes.append(brush);
58 58 }
59 59 */
60 void BarGroupBase::dataChanged()
60 void BarPresenterBase::dataChanged()
61 61 {
62 62 // TODO: performance optimizations. Do we really need to delete and create items every time data is changed or can we reuse them?
63 63
@@ -93,13 +93,13 void BarGroupBase::dataChanged()
93 93
94 94 //handlers
95 95
96 void BarGroupBase::handleModelChanged(int index)
96 void BarPresenterBase::handleModelChanged(int index)
97 97 {
98 98 // qDebug() << "BarGroupBase::handleModelChanged" << index;
99 99 dataChanged();
100 100 }
101 101
102 void BarGroupBase::handleDomainChanged(const Domain& domain)
102 void BarPresenterBase::handleDomainChanged(const Domain& domain)
103 103 {
104 104 // qDebug() << "BarGroupBase::handleDomainChanged";
105 105 // TODO: Figure out the use case for this.
@@ -107,7 +107,7 void BarGroupBase::handleDomainChanged(const Domain& domain)
107 107 // layoutChanged();
108 108 }
109 109
110 void BarGroupBase::handleGeometryChanged(const QRectF& rect)
110 void BarPresenterBase::handleGeometryChanged(const QRectF& rect)
111 111 {
112 112 mWidth = rect.width();
113 113 mHeight = rect.height();
@@ -116,6 +116,6 void BarGroupBase::handleGeometryChanged(const QRectF& rect)
116 116 setPos(rect.topLeft());
117 117 }
118 118
119 #include "moc_bargroupbase.cpp"
119 #include "moc_barpresenterbase.cpp"
120 120
121 121 QTCOMMERCIALCHART_END_NAMESPACE
@@ -10,11 +10,11
10 10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
11 11
12 12 // Base Class for bar groups. Common implemantation of different groups. Not to be instantiated.
13 class BarGroupBase : public QObject, public ChartItem
13 class BarPresenterBase : public QObject, public ChartItem
14 14 {
15 15 Q_OBJECT
16 16 public:
17 BarGroupBase(BarChartModel& model, QGraphicsItem *parent = 0);
17 BarPresenterBase(BarChartModel& model, QGraphicsItem *parent = 0);
18 18 void setSeparatorsVisible(bool visible = true);
19 19
20 20 public:
@@ -1,4 +1,4
1 #include "percentbargroup.h"
1 #include "percentbarpresenter.h"
2 2 #include "bar_p.h"
3 3 #include "barlabel_p.h"
4 4 #include "separator_p.h"
@@ -8,12 +8,12
8 8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 9
10 10
11 PercentBarGroup::PercentBarGroup(BarChartModel& model, QGraphicsItem *parent) :
12 BarGroupBase(model, parent)
11 PercentBarPresenter::PercentBarPresenter(BarChartModel& model, QGraphicsItem *parent) :
12 BarPresenterBase(model, parent)
13 13 {
14 14 }
15 15
16 void PercentBarGroup::layoutChanged()
16 void PercentBarPresenter::layoutChanged()
17 17 {
18 18 // qDebug() << "PercentBarGroup::layoutChanged";
19 19 // Scale bars to new layout
@@ -3,16 +3,16
3 3
4 4 #include "chartitem_p.h"
5 5 #include "bar_p.h"
6 #include "percentbarchartseries.h"
7 #include "bargroupbase.h"
6 #include "qpercentbarchartseries.h"
7 #include "barpresenterbase.h"
8 8 #include <QGraphicsItem>
9 9
10 10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
11 11
12 class PercentBarGroup : public BarGroupBase
12 class PercentBarPresenter : public BarPresenterBase
13 13 {
14 14 public:
15 PercentBarGroup(BarChartModel& model, QGraphicsItem *parent = 0);
15 PercentBarPresenter(BarChartModel& model, QGraphicsItem *parent = 0);
16 16
17 17 private:
18 18
@@ -1,5 +1,5
1 1 #include <QDebug>
2 #include "barchartseries.h"
2 #include "qbarchartseries.h"
3 3 #include "qbarcategory.h"
4 4 #include "qbarset.h"
5 5 #include "barchartmodel_p.h"
@@ -7,63 +7,63
7 7
8 8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 9
10 BarChartSeries::BarChartSeries(QBarCategory *category, QObject *parent)
10 QBarChartSeries::QBarChartSeries(QBarCategory *category, QObject *parent)
11 11 : QChartSeries(parent)
12 12 ,mModel(new BarChartModel(category, this))
13 13 {
14 14 }
15 15
16 void BarChartSeries::addBarSet(QBarSet *set)
16 void QBarChartSeries::addBarSet(QBarSet *set)
17 17 {
18 18 mModel->addBarSet(set);
19 19 }
20 20
21 void BarChartSeries::removeBarSet(QBarSet *set)
21 void QBarChartSeries::removeBarSet(QBarSet *set)
22 22 {
23 23 mModel->removeBarSet(set);
24 24 }
25 25
26 int BarChartSeries::countSets()
26 int QBarChartSeries::countSets()
27 27 {
28 28 return mModel->countSets();
29 29 }
30 30
31 QBarSet* BarChartSeries::nextSet(bool getFirst)
31 QBarSet* QBarChartSeries::nextSet(bool getFirst)
32 32 {
33 33 return mModel->nextSet(getFirst);
34 34 }
35 35
36 int BarChartSeries::countCategories()
36 int QBarChartSeries::countCategories()
37 37 {
38 38 return mModel->countCategories();
39 39 }
40 40
41 qreal BarChartSeries::min()
41 qreal QBarChartSeries::min()
42 42 {
43 43 return mModel->min();
44 44 }
45 45
46 qreal BarChartSeries::max()
46 qreal QBarChartSeries::max()
47 47 {
48 48 return mModel->max();
49 49 }
50 50
51 qreal BarChartSeries::valueAt(int set, int category)
51 qreal QBarChartSeries::valueAt(int set, int category)
52 52 {
53 53 return mModel->valueAt(set,category);
54 54 }
55 55
56 qreal BarChartSeries::maxCategorySum()
56 qreal QBarChartSeries::maxCategorySum()
57 57 {
58 58 return mModel->maxCategorySum();
59 59 }
60 60
61 BarChartModel& BarChartSeries::model()
61 BarChartModel& QBarChartSeries::model()
62 62 {
63 63 return *mModel;
64 64 }
65 65
66 66
67 #include "moc_barchartseries.cpp"
67 #include "moc_qbarchartseries.cpp"
68 68
69 69 QTCOMMERCIALCHART_END_NAMESPACE
@@ -9,15 +9,15 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 9
10 10 class QBarCategory;
11 11 class QBarSet;
12 class BarGroup;
12 class BarPresenter;
13 13 class BarChartModel;
14 14
15 15 // Container for series
16 class QTCOMMERCIALCHART_EXPORT BarChartSeries : public QChartSeries
16 class QTCOMMERCIALCHART_EXPORT QBarChartSeries : public QChartSeries
17 17 {
18 18 Q_OBJECT
19 19 public:
20 BarChartSeries(QBarCategory *category, QObject* parent=0);
20 QBarChartSeries(QBarCategory *category, QObject* parent=0);
21 21
22 22 virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeBar; }
23 23
@@ -46,7 +46,7 public Q_SLOTS:
46 46
47 47 private:
48 48
49 BarGroup* mBarGroup;
49 BarPresenter* mBarGroup;
50 50 BarChartModel* mModel;
51 51
52 52 };
@@ -1,70 +1,70
1 1 #include <limits.h>
2 2 #include <QDebug>
3 #include "stackedbarchartseries.h"
4 #include "qbarcategory.h"
3 #include "qpercentbarchartseries.h"
5 4 #include "qbarset.h"
5 #include "qbarcategory.h"
6 6 #include "barchartmodel_p.h"
7 7
8 8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 9
10 StackedBarChartSeries::StackedBarChartSeries(QBarCategory *category, QObject *parent)
10 QPercentBarChartSeries::QPercentBarChartSeries(QBarCategory *category, QObject *parent)
11 11 : QChartSeries(parent)
12 12 ,mModel(new BarChartModel(category, this))
13 13 {
14 14 }
15 15
16 void StackedBarChartSeries::addBarSet(QBarSet *set)
16 void QPercentBarChartSeries::addBarSet(QBarSet *set)
17 17 {
18 18 mModel->addBarSet(set);
19 19 }
20 20
21 void StackedBarChartSeries::removeBarSet(QBarSet *set)
21 void QPercentBarChartSeries::removeBarSet(QBarSet *set)
22 22 {
23 23 mModel->removeBarSet(set);
24 24 }
25 25
26 int StackedBarChartSeries::countSets()
26 int QPercentBarChartSeries::countSets()
27 27 {
28 28 return mModel->countSets();
29 29 }
30 30
31 QBarSet* StackedBarChartSeries::nextSet(bool getFirst)
31 QBarSet* QPercentBarChartSeries::nextSet(bool getFirst)
32 32 {
33 33 return mModel->nextSet(getFirst);
34 34 }
35 35
36 int StackedBarChartSeries::countCategories()
36 int QPercentBarChartSeries::countCategories()
37 37 {
38 38 return mModel->countCategories();
39 39 }
40 40
41 qreal StackedBarChartSeries::min()
41 qreal QPercentBarChartSeries::min()
42 42 {
43 43 return mModel->min();
44 44 }
45 45
46 qreal StackedBarChartSeries::max()
46 qreal QPercentBarChartSeries::max()
47 47 {
48 48 return mModel->max();
49 49 }
50 50
51 qreal StackedBarChartSeries::valueAt(int set, int category)
51 qreal QPercentBarChartSeries::valueAt(int set, int category)
52 52 {
53 53 return mModel->valueAt(set,category);
54 54 }
55 55
56 qreal StackedBarChartSeries::maxCategorySum()
56 qreal QPercentBarChartSeries::maxCategorySum()
57 57 {
58 58 return mModel->maxCategorySum();
59 59 }
60 60
61 BarChartModel& StackedBarChartSeries::model()
61 BarChartModel& QPercentBarChartSeries::model()
62 62 {
63 63 return *mModel;
64 64 }
65 65
66 66
67 #include "moc_stackedbarchartseries.cpp"
67 #include "moc_qpercentbarchartseries.cpp"
68 68
69 69 QTCOMMERCIALCHART_END_NAMESPACE
70 70
@@ -7,16 +7,16
7 7
8 8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 9
10 class PercentBarGroup;
10 class PercentBarPresenter;
11 11 class QBarCategory;
12 12 class QBarSet;
13 13 class BarChartModel;
14 14
15 class QTCOMMERCIALCHART_EXPORT PercentBarChartSeries : public QChartSeries
15 class QTCOMMERCIALCHART_EXPORT QPercentBarChartSeries : public QChartSeries
16 16 {
17 17 Q_OBJECT
18 18 public:
19 PercentBarChartSeries(QBarCategory *category, QObject* parent=0);
19 QPercentBarChartSeries(QBarCategory *category, QObject* parent=0);
20 20
21 21 // from BarChartSeriesBase
22 22 virtual QChartSeriesType type() const { return QChartSeries::SeriesTypePercentBar; }
@@ -47,7 +47,7 public Q_SLOTS:
47 47
48 48 private:
49 49
50 PercentBarGroup* mPercentBarGroup;
50 PercentBarPresenter* mPercentBarGroup;
51 51 BarChartModel* mModel;
52 52
53 53 };
@@ -1,72 +1,70
1 #include "percentbarchartseries.h"
2
3 1 #include <limits.h>
4 2 #include <QDebug>
5 #include "percentbarchartseries.h"
6 #include "qbarset.h"
3 #include "qstackedbarchartseries.h"
7 4 #include "qbarcategory.h"
5 #include "qbarset.h"
8 6 #include "barchartmodel_p.h"
9 7
10 8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
11 9
12 PercentBarChartSeries::PercentBarChartSeries(QBarCategory *category, QObject *parent)
10 QStackedBarChartSeries::QStackedBarChartSeries(QBarCategory *category, QObject *parent)
13 11 : QChartSeries(parent)
14 12 ,mModel(new BarChartModel(category, this))
15 13 {
16 14 }
17 15
18 void PercentBarChartSeries::addBarSet(QBarSet *set)
16 void QStackedBarChartSeries::addBarSet(QBarSet *set)
19 17 {
20 18 mModel->addBarSet(set);
21 19 }
22 20
23 void PercentBarChartSeries::removeBarSet(QBarSet *set)
21 void QStackedBarChartSeries::removeBarSet(QBarSet *set)
24 22 {
25 23 mModel->removeBarSet(set);
26 24 }
27 25
28 int PercentBarChartSeries::countSets()
26 int QStackedBarChartSeries::countSets()
29 27 {
30 28 return mModel->countSets();
31 29 }
32 30
33 QBarSet* PercentBarChartSeries::nextSet(bool getFirst)
31 QBarSet* QStackedBarChartSeries::nextSet(bool getFirst)
34 32 {
35 33 return mModel->nextSet(getFirst);
36 34 }
37 35
38 int PercentBarChartSeries::countCategories()
36 int QStackedBarChartSeries::countCategories()
39 37 {
40 38 return mModel->countCategories();
41 39 }
42 40
43 qreal PercentBarChartSeries::min()
41 qreal QStackedBarChartSeries::min()
44 42 {
45 43 return mModel->min();
46 44 }
47 45
48 qreal PercentBarChartSeries::max()
46 qreal QStackedBarChartSeries::max()
49 47 {
50 48 return mModel->max();
51 49 }
52 50
53 qreal PercentBarChartSeries::valueAt(int set, int category)
51 qreal QStackedBarChartSeries::valueAt(int set, int category)
54 52 {
55 53 return mModel->valueAt(set,category);
56 54 }
57 55
58 qreal PercentBarChartSeries::maxCategorySum()
56 qreal QStackedBarChartSeries::maxCategorySum()
59 57 {
60 58 return mModel->maxCategorySum();
61 59 }
62 60
63 BarChartModel& PercentBarChartSeries::model()
61 BarChartModel& QStackedBarChartSeries::model()
64 62 {
65 63 return *mModel;
66 64 }
67 65
68 66
69 #include "moc_percentbarchartseries.cpp"
67 #include "moc_qstackedbarchartseries.cpp"
70 68
71 69 QTCOMMERCIALCHART_END_NAMESPACE
72 70
@@ -7,16 +7,16
7 7
8 8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 9
10 class StackedBarGroup;
10 class StackedBarPresenter;
11 11 class QBarCategory;
12 12 class QBarSet;
13 13 class BarChartModel;
14 14
15 class QTCOMMERCIALCHART_EXPORT StackedBarChartSeries : public QChartSeries
15 class QTCOMMERCIALCHART_EXPORT QStackedBarChartSeries : public QChartSeries
16 16 {
17 17 Q_OBJECT
18 18 public:
19 StackedBarChartSeries(QBarCategory *category, QObject* parent=0);
19 QStackedBarChartSeries(QBarCategory *category, QObject* parent=0);
20 20
21 21 // from QChartSeries
22 22 virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeStackedBar; }
@@ -46,7 +46,7 public Q_SLOTS:
46 46
47 47 private:
48 48
49 StackedBarGroup* mStackedBarGroup;
49 StackedBarPresenter* mStackedBarGroup;
50 50 BarChartModel* mModel;
51 51 };
52 52
@@ -1,4 +1,4
1 #include "stackedbargroup.h"
1 #include "stackedbarpresenter.h"
2 2 #include "bar_p.h"
3 3 #include "barlabel_p.h"
4 4 #include "separator_p.h"
@@ -7,12 +7,12
7 7
8 8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 9
10 StackedBarGroup::StackedBarGroup(BarChartModel& model, QGraphicsItem *parent) :
11 BarGroupBase(model,parent)
10 StackedBarPresenter::StackedBarPresenter(BarChartModel& model, QGraphicsItem *parent) :
11 BarPresenterBase(model,parent)
12 12 {
13 13 }
14 14
15 void StackedBarGroup::layoutChanged()
15 void StackedBarPresenter::layoutChanged()
16 16 {
17 17 // qDebug() << "StackedBarGroup::layoutChanged";
18 18 // Scale bars to new layout
@@ -1,16 +1,16
1 1 #ifndef STACKEDBARGROUP_H
2 2 #define STACKEDBARGROUP_H
3 3
4 #include "bargroupbase.h"
5 #include "stackedbarchartseries.h"
4 #include "barpresenterbase.h"
5 #include "qstackedbarchartseries.h"
6 6 #include <QGraphicsItem>
7 7
8 8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 9
10 class StackedBarGroup : public BarGroupBase
10 class StackedBarPresenter : public BarPresenterBase
11 11 {
12 12 public:
13 StackedBarGroup(BarChartModel& model, QGraphicsItem *parent = 0);
13 StackedBarPresenter(BarChartModel& model, QGraphicsItem *parent = 0);
14 14
15 15 private:
16 16 // From BarGroupBase
@@ -1,9 +1,9
1 1 #include "chartdataset_p.h"
2 2 //series
3 3 #include "qlinechartseries.h"
4 #include "barchartseries.h"
5 #include "stackedbarchartseries.h"
6 #include "percentbarchartseries.h"
4 #include "qbarchartseries.h"
5 #include "qstackedbarchartseries.h"
6 #include "qpercentbarchartseries.h"
7 7 #include "qpieseries.h"
8 8 #include "qscatterseries.h"
9 9
@@ -54,7 +54,7 void ChartDataSet::addSeries(QChartSeries* series)
54 54 }
55 55 case QChartSeries::SeriesTypeBar: {
56 56 qDebug() << "QChartSeries::SeriesTypeBar";
57 BarChartSeries* barSeries = static_cast<BarChartSeries*>(series);
57 QBarChartSeries* barSeries = static_cast<QBarChartSeries*>(series);
58 58 qreal x = barSeries->countCategories();
59 59 qreal y = barSeries->max();
60 60 domain.m_minX = qMin(domain.m_minX,x);
@@ -66,7 +66,7 void ChartDataSet::addSeries(QChartSeries* series)
66 66 case QChartSeries::SeriesTypeStackedBar: {
67 67 qDebug() << "QChartSeries::SeriesTypeStackedBar";
68 68
69 StackedBarChartSeries* stackedBarSeries = static_cast<StackedBarChartSeries*>(series);
69 QStackedBarChartSeries* stackedBarSeries = static_cast<QStackedBarChartSeries*>(series);
70 70 qreal x = stackedBarSeries->countCategories();
71 71 qreal y = stackedBarSeries->maxCategorySum();
72 72 domain.m_minX = qMin(domain.m_minX,x);
@@ -78,7 +78,7 void ChartDataSet::addSeries(QChartSeries* series)
78 78 case QChartSeries::SeriesTypePercentBar: {
79 79 qDebug() << "QChartSeries::SeriesTypePercentBar";
80 80
81 PercentBarChartSeries* percentBarSeries = static_cast<PercentBarChartSeries*>(series);
81 QPercentBarChartSeries* percentBarSeries = static_cast<QPercentBarChartSeries*>(series);
82 82 qreal x = percentBarSeries->countCategories();
83 83 domain.m_minX = qMin(domain.m_minX,x);
84 84 domain.m_minY = 0;
@@ -4,18 +4,18
4 4 #include "chartdataset_p.h"
5 5 #include "charttheme_p.h"
6 6 //series
7 #include "barchartseries.h"
8 #include "stackedbarchartseries.h"
9 #include "percentbarchartseries.h"
7 #include "qbarchartseries.h"
8 #include "qstackedbarchartseries.h"
9 #include "qpercentbarchartseries.h"
10 10 #include "qlinechartseries.h"
11 11 #include "qpieseries.h"
12 12 #include "qscatterseries.h"
13 13 //items
14 14 #include "axisitem_p.h"
15 #include "bargroup.h"
16 #include "stackedbargroup.h"
15 #include "barpresenter.h"
16 #include "stackedbarpresenter.h"
17 17 #include "linechartitem_p.h"
18 #include "percentbargroup.h"
18 #include "percentbarpresenter.h"
19 19 #include "linechartanimationitem_p.h"
20 20 #include "piepresenter.h"
21 21 #include "scatterpresenter_p.h"
@@ -85,8 +85,8 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
85 85 }
86 86
87 87 case QChartSeries::SeriesTypeBar: {
88 BarChartSeries* barSeries = static_cast<BarChartSeries*>(series);
89 BarGroup* item = new BarGroup(barSeries->model(),m_chart);
88 QBarChartSeries* barSeries = static_cast<QBarChartSeries*>(series);
89 BarPresenter* item = new BarPresenter(barSeries->model(),m_chart);
90 90 m_chartTheme->decorate(item,barSeries,m_chartItems.count());
91 91 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
92 92 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
@@ -98,8 +98,8 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
98 98
99 99 case QChartSeries::SeriesTypeStackedBar: {
100 100
101 StackedBarChartSeries* stackedBarSeries = static_cast<StackedBarChartSeries*>(series);
102 StackedBarGroup* item = new StackedBarGroup(stackedBarSeries->model(),m_chart);
101 QStackedBarChartSeries* stackedBarSeries = static_cast<QStackedBarChartSeries*>(series);
102 StackedBarPresenter* item = new StackedBarPresenter(stackedBarSeries->model(),m_chart);
103 103 m_chartTheme->decorate(item,stackedBarSeries,m_chartItems.count());
104 104 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
105 105 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
@@ -110,8 +110,8 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
110 110
111 111 case QChartSeries::SeriesTypePercentBar: {
112 112
113 PercentBarChartSeries* percentBarSeries = static_cast<PercentBarChartSeries*>(series);
114 PercentBarGroup* item = new PercentBarGroup(percentBarSeries->model(),m_chart);
113 QPercentBarChartSeries* percentBarSeries = static_cast<QPercentBarChartSeries*>(series);
114 PercentBarPresenter* item = new PercentBarPresenter(percentBarSeries->model(),m_chart);
115 115 m_chartTheme->decorate(item,percentBarSeries ,m_chartItems.count());
116 116 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
117 117 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&)));
@@ -5,9 +5,9
5 5
6 6 //series
7 7 #include "qbarset.h"
8 #include "barchartseries.h"
9 #include "stackedbarchartseries.h"
10 #include "percentbarchartseries.h"
8 #include "qbarchartseries.h"
9 #include "qstackedbarchartseries.h"
10 #include "qpercentbarchartseries.h"
11 11 #include "qlinechartseries.h"
12 12 #include "qscatterseries.h"
13 13 #include "qpieseries.h"
@@ -15,10 +15,10
15 15
16 16 //items
17 17 #include "axisitem_p.h"
18 #include "bargroup.h"
19 #include "stackedbargroup.h"
18 #include "barpresenter.h"
19 #include "stackedbarpresenter.h"
20 20 #include "linechartitem_p.h"
21 #include "percentbargroup.h"
21 #include "percentbarpresenter.h"
22 22 #include "scatterpresenter_p.h"
23 23 #include "piepresenter.h"
24 24
@@ -89,20 +89,20 void ChartTheme::decorate(ChartItem* item, QChartSeries* series,int count)
89 89 break;
90 90 }
91 91 case QChartSeries::SeriesTypeBar: {
92 BarChartSeries* b = static_cast<BarChartSeries*>(series);
93 BarGroup* i = static_cast<BarGroup*>(item);
92 QBarChartSeries* b = static_cast<QBarChartSeries*>(series);
93 BarPresenter* i = static_cast<BarPresenter*>(item);
94 94 decorate(i,b,count);
95 95 break;
96 96 }
97 97 case QChartSeries::SeriesTypeStackedBar: {
98 StackedBarChartSeries* s = static_cast<StackedBarChartSeries*>(series);
99 StackedBarGroup* i = static_cast<StackedBarGroup*>(item);
98 QStackedBarChartSeries* s = static_cast<QStackedBarChartSeries*>(series);
99 StackedBarPresenter* i = static_cast<StackedBarPresenter*>(item);
100 100 decorate(i,s,count);
101 101 break;
102 102 }
103 103 case QChartSeries::SeriesTypePercentBar: {
104 PercentBarChartSeries* s = static_cast<PercentBarChartSeries*>(series);
105 PercentBarGroup* i = static_cast<PercentBarGroup*>(item);
104 QPercentBarChartSeries* s = static_cast<QPercentBarChartSeries*>(series);
105 PercentBarPresenter* i = static_cast<PercentBarPresenter*>(item);
106 106 decorate(i,s,count);
107 107 break;
108 108 }
@@ -139,21 +139,21 void ChartTheme::decorate(LineChartItem* item, QLineChartSeries* series,int coun
139 139 item->setPen(pen);
140 140 }
141 141
142 void ChartTheme::decorate(BarGroup* item, BarChartSeries* series,int count)
142 void ChartTheme::decorate(BarPresenter* item, QBarChartSeries* series,int count)
143 143 {
144 144 for (int i=0; i<series->countSets(); i++) {
145 145 series->nextSet(0==i)->setBrush(QBrush(m_seriesColor.at(i%m_seriesColor.count())));
146 146 }
147 147 }
148 148
149 void ChartTheme::decorate(StackedBarGroup* item, StackedBarChartSeries* series,int count)
149 void ChartTheme::decorate(StackedBarPresenter* item, QStackedBarChartSeries* series,int count)
150 150 {
151 151 for (int i=0; i<series->countSets(); i++) {
152 152 series->nextSet(0==i)->setBrush(QBrush(m_seriesColor.at(i%m_seriesColor.count())));
153 153 }
154 154 }
155 155
156 void ChartTheme::decorate(PercentBarGroup* item, PercentBarChartSeries* series,int count)
156 void ChartTheme::decorate(PercentBarPresenter* item, QPercentBarChartSeries* series,int count)
157 157 {
158 158 for (int i=0; i<series->countSets(); i++) {
159 159 series->nextSet(0==i)->setBrush(QBrush(m_seriesColor.at(i%m_seriesColor.count())));
@@ -11,12 +11,12 class ChartItem;
11 11 class QChartSeries;
12 12 class LineChartItem;
13 13 class QLineChartSeries;
14 class BarGroup;
15 class BarChartSeries;
16 class StackedBarGroup;
17 class StackedBarChartSeries;
18 class PercentBarChartSeries;
19 class PercentBarGroup;
14 class BarPresenter;
15 class QBarChartSeries;
16 class StackedBarPresenter;
17 class QStackedBarChartSeries;
18 class QPercentBarChartSeries;
19 class PercentBarPresenter;
20 20 class QScatterSeries;
21 21 class ScatterPresenter;
22 22 class PiePresenter;
@@ -32,9 +32,9 public:
32 32 void decorate(QChart* chart);
33 33 void decorate(ChartItem* item, QChartSeries* series,int count);
34 34 void decorate(LineChartItem* item, QLineChartSeries*, int count);
35 void decorate(BarGroup* item, BarChartSeries* series,int count);
36 void decorate(StackedBarGroup* item, StackedBarChartSeries* series,int count);
37 void decorate(PercentBarGroup* item, PercentBarChartSeries* series,int count);
35 void decorate(BarPresenter* item, QBarChartSeries* series,int count);
36 void decorate(StackedBarPresenter* item, QStackedBarChartSeries* series,int count);
37 void decorate(PercentBarPresenter* item, QPercentBarChartSeries* series,int count);
38 38 void decorate(ScatterPresenter* presenter, QScatterSeries* series, int count);
39 39 void decorate(PiePresenter* item, QPieSeries* series, int count);
40 40 void decorate(QChartAxis& axis,AxisItem* item);
@@ -4,9 +4,9
4 4 #include "chartdataset_p.h"
5 5
6 6 //series
7 #include "barchartseries.h"
8 #include "stackedbarchartseries.h"
9 #include "percentbarchartseries.h"
7 #include "qbarchartseries.h"
8 #include "qstackedbarchartseries.h"
9 #include "qpercentbarchartseries.h"
10 10 #include "qlinechartseries.h"
11 11 #include "qscatterseries.h"
12 12 //#include "scatterseries_p.h"
@@ -14,7 +14,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
14 14 class AxisItem;
15 15 class QChartSeries;
16 16 class PlotDomain;
17 class BarGroup;
17 class BarPresenter;
18 18 class QChartAxis;
19 19 class ChartTheme;
20 20 class ChartItem;
@@ -6,19 +6,20 QT += core \
6 6 gui
7 7 CONFIG += debug_and_release
8 8 CONFIG(debug, debug|release):TARGET = QtCommercialChartd
9 SOURCES += barchart/barchartseries.cpp \
10 barchart/bargroup.cpp \
9 SOURCES += \
11 10 barchart/bar.cpp \
12 barchart/stackedbarchartseries.cpp \
13 barchart/stackedbargroup.cpp \
14 barchart/percentbarchartseries.cpp \
15 barchart/percentbargroup.cpp \
16 11 barchart/barlabel.cpp \
17 12 barchart/barchartmodel.cpp \
18 13 barchart/separator.cpp \
19 barchart/bargroupbase.cpp \
20 14 barchart/qbarset.cpp \
21 15 barchart/qbarcategory.cpp \
16 barchart/qbarchartseries.cpp \
17 barchart/qpercentbarchartseries.cpp \
18 barchart/qstackedbarchartseries.cpp \
19 barchart/barpresenterbase.cpp \
20 barchart/barpresenter.cpp \
21 barchart/stackedbarpresenter.cpp \
22 barchart/percentbarpresenter.cpp \
22 23 linechart/linechartanimationitem.cpp \
23 24 linechart/linechartitem.cpp \
24 25 linechart/qlinechartseries.cpp \
@@ -44,13 +45,13 PRIVATE_HEADERS += linechart/linechartitem_p.h \
44 45 chartpresenter_p.h \
45 46 domain_p.h
46 47 PUBLIC_HEADERS += linechart/qlinechartseries.h \
47 barchart/barchartseries.h \
48 barchart/bargroup.h \
49 barchart/stackedbarchartseries.h \
50 barchart/stackedbargroup.h \
51 barchart/percentbarchartseries.h \
52 barchart/percentbargroup.h \
53 barchart/bargroupbase.h \
48 barchart/qbarchartseries.h \
49 barchart/barpresenter.h \
50 barchart/qstackedbarchartseries.h \
51 barchart/stackedbarpresenter.h \
52 barchart/qpercentbarchartseries.h \
53 barchart/percentbarpresenter.h \
54 barchart/barpresenterbase.h \
54 55 barchart/qbarset.h \
55 56 barchart/qbarcategory.h \
56 57 qchartseries.h \
@@ -6,9 +6,9
6 6 #include <qlinechartseries.h>
7 7 #include <qbarset.h>
8 8 #include <qbarcategory.h>
9 #include <barchartseries.h>
10 #include <stackedbarchartseries.h>
11 #include <percentbarchartseries.h>
9 #include <qbarchartseries.h>
10 #include <qstackedbarchartseries.h>
11 #include <qpercentbarchartseries.h>
12 12 #include <QPushButton>
13 13 #include <QComboBox>
14 14 #include <QSpinBox>
General Comments 0
You need to be logged in to leave comments. Login now