##// END OF EJS Templates
code cleanup after refactoring. much nicer now.
sauimone -
r282:2a015f15bbd4
parent child
Show More
@@ -15,7 +15,7 class Separator;
15 class BarValue;
15 class BarValue;
16
16
17 // Common implemantation of different presenters. Not to be instantiated.
17 // Common implemantation of different presenters. Not to be instantiated.
18 // TODO: combine this with BarPresenter and derive others from it?
18 // TODO: combine this with BarPresenter and derive other presenters from it?
19 class BarPresenterBase : public QObject, public ChartItem
19 class BarPresenterBase : public QObject, public ChartItem
20 {
20 {
21 Q_OBJECT
21 Q_OBJECT
@@ -32,12 +32,6 public:
32 // TODO: these may change with layout awarness.
32 // TODO: these may change with layout awarness.
33 void setBarWidth( int w );
33 void setBarWidth( int w );
34
34
35 void setPen(QPen pen);
36 QPen pen();
37
38 void setBrush(QBrush brush);
39 QBrush brush();
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
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
42 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
43 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
@@ -68,8 +62,6 protected:
68 QList<BarLabel*> mLabels;
62 QList<BarLabel*> mLabels;
69 QList<Separator*> mSeparators;
63 QList<Separator*> mSeparators;
70 QList<BarValue*> mFloatingValues;
64 QList<BarValue*> mFloatingValues;
71
72 QPen mPen;
73 };
65 };
74
66
75 QTCOMMERCIALCHART_END_NAMESPACE
67 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,8 +1,6
1 #ifndef BARCHARTSERIES_H
1 #ifndef BARCHARTSERIES_H
2 #define BARCHARTSERIES_H
2 #define BARCHARTSERIES_H
3
3
4 #include <QList>
5 #include <QAbstractItemModel>
6 #include "qchartseries.h"
4 #include "qchartseries.h"
7
5
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -1,77 +1,11
1 #include <limits.h>
2 #include <QDebug>
3 #include "qpercentbarchartseries.h"
1 #include "qpercentbarchartseries.h"
4 #include "qbarset.h"
5 #include "qbarcategory.h"
6 #include "barchartmodel_p.h"
7
2
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
4
10 QPercentBarChartSeries::QPercentBarChartSeries(QBarCategory *category, QObject *parent)
5 QPercentBarChartSeries::QPercentBarChartSeries(QBarCategory *category, QObject *parent)
11 : QBarChartSeries(category, parent)
6 : QBarChartSeries(category, parent)
12 // ,mModel(new BarChartModel(category, this))
13 {
7 {
14 }
8 }
15 /*
16 void QPercentBarChartSeries::addBarSet(QBarSet *set)
17 {
18 connect(this,SIGNAL(floatingValuesEnabled(bool)),set,SLOT(enableFloatingValues(bool)));
19 connect(this,SIGNAL(hoverNamesEnabled(bool)),set,SLOT(enableHoverNames(bool)));
20 mModel->addBarSet(set);
21 }
22
23 void QPercentBarChartSeries::removeBarSet(QBarSet *set)
24 {
25 disconnect(set,SLOT(enableFloatingValues(bool)));
26 disconnect(set,SLOT(enableHoverNames(bool)));
27 mModel->removeBarSet(set);
28 }
29
30 int QPercentBarChartSeries::countSets()
31 {
32 return mModel->countSets();
33 }
34
35 QBarSet* QPercentBarChartSeries::nextSet(bool getFirst)
36 {
37 return mModel->nextSet(getFirst);
38 }
39
40 QList<QString> QPercentBarChartSeries::legend()
41 {
42 return mModel->legend();
43 }
44
45 int QPercentBarChartSeries::countCategories()
46 {
47 return mModel->countCategories();
48 }
49
50 qreal QPercentBarChartSeries::min()
51 {
52 return mModel->min();
53 }
54
55 qreal QPercentBarChartSeries::max()
56 {
57 return mModel->max();
58 }
59
60 qreal QPercentBarChartSeries::valueAt(int set, int category)
61 {
62 return mModel->valueAt(set,category);
63 }
64
65 qreal QPercentBarChartSeries::maxCategorySum()
66 {
67 return mModel->maxCategorySum();
68 }
69
70 BarChartModel& QPercentBarChartSeries::model()
71 {
72 return *mModel;
73 }
74 */
75
9
76 #include "moc_qpercentbarchartseries.cpp"
10 #include "moc_qpercentbarchartseries.cpp"
77
11
@@ -1,56 +1,17
1 #ifndef PERCENTBARCHARTSERIES_H
1 #ifndef PERCENTBARCHARTSERIES_H
2 #define PERCENTBARCHARTSERIES_H
2 #define PERCENTBARCHARTSERIES_H
3
3
4 #include <QList>
5 #include <QAbstractItemModel>
6 #include "qbarchartseries.h"
4 #include "qbarchartseries.h"
7
5
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
7
10 class QBarCategory;
11 class QBarSet;
12 class BarChartModel;
13
14 //class QTCOMMERCIALCHART_EXPORT QPercentBarChartSeries : public QChartSeries
15 class QTCOMMERCIALCHART_EXPORT QPercentBarChartSeries : public QBarChartSeries
8 class QTCOMMERCIALCHART_EXPORT QPercentBarChartSeries : public QBarChartSeries
16 {
9 {
17 Q_OBJECT
10 Q_OBJECT
18 public:
11 public:
19 QPercentBarChartSeries(QBarCategory *category, QObject* parent=0);
12 QPercentBarChartSeries(QBarCategory *category, QObject* parent=0);
20
13
21 // from BarChartSeriesBase
22 virtual QChartSeriesType type() const { return QChartSeries::SeriesTypePercentBar; }
14 virtual QChartSeriesType type() const { return QChartSeries::SeriesTypePercentBar; }
23 /*
24 void addBarSet(QBarSet *set); // Takes ownership
25 void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set
26 int countSets();
27 QBarSet* nextSet(bool first=false); // Returns first set, if called with true
28
29 QList<QString> legend(); // Returns legend of series (ie. names of all sets in series)
30
31 // Disabled by default. Call these to change behavior.
32 void enableFloatingValues(bool enabled=true);
33 void enableHoverNames(bool enabled=true);
34
35 // TODO: Functions below this are not part of api and will be moved
36 // to private implementation, when we start using it (not part of api)
37 int countCategories();
38 qreal min();
39 qreal max();
40 qreal valueAt(int set, int category);
41 qreal maxCategorySum();
42
43 BarChartModel& model();
44
45 signals:
46 void changed(int index);
47
48 public Q_SLOTS:
49
50
51 private:
52 BarChartModel* mModel;
53 */
54 };
15 };
55
16
56 QTCOMMERCIALCHART_END_NAMESPACE
17 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,77 +1,11
1 #include <limits.h>
2 #include <QDebug>
3 #include "qstackedbarchartseries.h"
1 #include "qstackedbarchartseries.h"
4 #include "qbarcategory.h"
5 #include "qbarset.h"
6 #include "barchartmodel_p.h"
7
2
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
4
10 QStackedBarChartSeries::QStackedBarChartSeries(QBarCategory *category, QObject *parent)
5 QStackedBarChartSeries::QStackedBarChartSeries(QBarCategory *category, QObject *parent)
11 : QBarChartSeries(category, parent)
6 : QBarChartSeries(category, parent)
12 // ,mModel(new BarChartModel(category, this))
13 {
7 {
14 }
8 }
15 /*
16 void QStackedBarChartSeries::addBarSet(QBarSet *set)
17 {
18 connect(this,SIGNAL(floatingValuesEnabled(bool)),set,SLOT(enableFloatingValues(bool)));
19 connect(this,SIGNAL(hoverNamesEnabled(bool)),set,SLOT(enableHoverNames(bool)));
20 mModel->addBarSet(set);
21 }
22
23 void QStackedBarChartSeries::removeBarSet(QBarSet *set)
24 {
25 disconnect(set,SLOT(enableFloatingValues(bool)));
26 disconnect(set,SLOT(enableHoverNames(bool)));
27 mModel->removeBarSet(set);
28 }
29
30 int QStackedBarChartSeries::countSets()
31 {
32 return mModel->countSets();
33 }
34
35 QBarSet* QStackedBarChartSeries::nextSet(bool getFirst)
36 {
37 return mModel->nextSet(getFirst);
38 }
39
40 QList<QString> QStackedBarChartSeries::legend()
41 {
42 return mModel->legend();
43 }
44
45 int QStackedBarChartSeries::countCategories()
46 {
47 return mModel->countCategories();
48 }
49
50 qreal QStackedBarChartSeries::min()
51 {
52 return mModel->min();
53 }
54
55 qreal QStackedBarChartSeries::max()
56 {
57 return mModel->max();
58 }
59
60 qreal QStackedBarChartSeries::valueAt(int set, int category)
61 {
62 return mModel->valueAt(set,category);
63 }
64
65 qreal QStackedBarChartSeries::maxCategorySum()
66 {
67 return mModel->maxCategorySum();
68 }
69
70 BarChartModel& QStackedBarChartSeries::model()
71 {
72 return *mModel;
73 }
74 */
75
9
76 #include "moc_qstackedbarchartseries.cpp"
10 #include "moc_qstackedbarchartseries.cpp"
77
11
@@ -1,56 +1,19
1 #ifndef STACKEDBARCHARTSERIES_H
1 #ifndef STACKEDBARCHARTSERIES_H
2 #define STACKEDBARCHARTSERIES_H
2 #define STACKEDBARCHARTSERIES_H
3
3
4 #include <QList>
5 #include <QAbstractItemModel>
6 #include "qbarchartseries.h"
4 #include "qbarchartseries.h"
7
5
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
7
10 class QBarCategory;
8 class QBarCategory;
11 class QBarSet;
12 class BarChartModel;
13
9
14 //class QTCOMMERCIALCHART_EXPORT QStackedBarChartSeries : public QChartSeries
15 class QTCOMMERCIALCHART_EXPORT QStackedBarChartSeries : public QBarChartSeries
10 class QTCOMMERCIALCHART_EXPORT QStackedBarChartSeries : public QBarChartSeries
16 {
11 {
17 Q_OBJECT
12 Q_OBJECT
18 public:
13 public:
19 QStackedBarChartSeries(QBarCategory *category, QObject* parent=0);
14 QStackedBarChartSeries(QBarCategory *category, QObject* parent=0);
20
15
21 // from QChartSeries
22 virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeStackedBar; }
16 virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeStackedBar; }
23 /*
24 // Set handling
25 void addBarSet(QBarSet *set); // Takes ownership
26 void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set
27 int countSets();
28 QBarSet* nextSet(bool first=false); // Returns first set, if called with true
29
30 QList<QString> legend(); // Returns legend of series (ie. names of all sets in series)
31
32 // Disabled by default. Call these to change behavior.
33 void enableFloatingValues(bool enabled=true);
34 void enableHoverNames(bool enabled=true);
35
36 // TODO: Functions below this are not part of api and will be moved
37 // to private implementation, when we start using it (not part of api)
38 int countCategories();
39 qreal min();
40 qreal max();
41 qreal valueAt(int set, int category);
42 qreal maxCategorySum();
43
44 BarChartModel& model();
45
46 signals:
47 void changed(int index);
48
49 public Q_SLOTS:
50
51 private:
52 BarChartModel* mModel;
53 */
54 };
17 };
55
18
56 QTCOMMERCIALCHART_END_NAMESPACE
19 QTCOMMERCIALCHART_END_NAMESPACE
@@ -28,7 +28,7 void Separator::setSize(const QSizeF &size)
28
28
29 void Separator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
29 void Separator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
30 {
30 {
31 // qDebug() << "separator::paint" << boundingRect();
31 // TODO: real pen
32 QPen pen(mColor);
32 QPen pen(mColor);
33 painter->setPen(pen);
33 painter->setPen(pen);
34 painter->drawLine(mXpos,mYpos,mXpos,mHeight);
34 painter->drawLine(mXpos,mYpos,mXpos,mHeight);
General Comments 0
You need to be logged in to leave comments. Login now