##// END OF EJS Templates
separated categories from barseries constructor
sauimone -
r1112:938a9dbeab71
parent child
Show More
@@ -51,7 +51,8 int main(int argc, char *argv[])
51 //![2]
51 //![2]
52
52
53 //![3]
53 //![3]
54 QBarSeries* series = new QBarSeries(categories);
54 QBarSeries* series = new QBarSeries();
55 series->setCategories(categories);
55 series->appendBarSet(set0);
56 series->appendBarSet(set0);
56 series->appendBarSet(set1);
57 series->appendBarSet(set1);
57 series->appendBarSet(set2);
58 series->appendBarSet(set2);
@@ -51,7 +51,8 int main(int argc, char *argv[])
51 //![2]
51 //![2]
52
52
53 //![3]
53 //![3]
54 QPercentBarSeries* series = new QPercentBarSeries(categories);
54 QPercentBarSeries* series = new QPercentBarSeries();
55 series->setCategories(categories);
55 series->appendBarSet(set0);
56 series->appendBarSet(set0);
56 series->appendBarSet(set1);
57 series->appendBarSet(set1);
57 series->appendBarSet(set2);
58 series->appendBarSet(set2);
@@ -51,7 +51,8 int main(int argc, char *argv[])
51 //![2]
51 //![2]
52
52
53 //![3]
53 //![3]
54 QStackedBarSeries* series = new QStackedBarSeries(categories);
54 QStackedBarSeries* series = new QStackedBarSeries();
55 series->setCategories(categories);
55 series->appendBarSet(set0);
56 series->appendBarSet(set0);
56 series->appendBarSet(set1);
57 series->appendBarSet(set1);
57 series->appendBarSet(set2);
58 series->appendBarSet(set2);
@@ -23,8 +23,9
23 QTCOMMERCIALCHART_USE_NAMESPACE
23 QTCOMMERCIALCHART_USE_NAMESPACE
24
24
25 DrilldownBarSeries::DrilldownBarSeries(QStringList categories, QObject *parent)
25 DrilldownBarSeries::DrilldownBarSeries(QStringList categories, QObject *parent)
26 : QStackedBarSeries(categories, parent)
26 : QStackedBarSeries(parent)
27 {
27 {
28 setCategories(categories);
28 }
29 }
29
30
30 void DrilldownBarSeries::mapDrilldownSeries(QString category, DrilldownBarSeries* drilldownSeries)
31 void DrilldownBarSeries::mapDrilldownSeries(QString category, DrilldownBarSeries* drilldownSeries)
@@ -50,7 +50,9 void DeclarativeBarSeries::setBarCategories(QStringList categories)
50 QChart *chart = qobject_cast<QChart *>(declarativeChart->m_chart);
50 QChart *chart = qobject_cast<QChart *>(declarativeChart->m_chart);
51 Q_ASSERT(chart);
51 Q_ASSERT(chart);
52
52
53 m_series = new QBarSeries(m_categories);
53 // m_series = new QBarSeries(m_categories);
54 m_series = new QBarSeries();
55 m_series->setCategories(m_categories);
54
56
55 // TODO: use data from model
57 // TODO: use data from model
56 QBarSet *set0 = new QBarSet("Bub");
58 QBarSet *set0 = new QBarSet("Bub");
@@ -67,8 +67,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
67 Constructs empty QBarSeries. Parameter \a categories defines the categories for chart.
67 Constructs empty QBarSeries. Parameter \a categories defines the categories for chart.
68 QBarSeries is QObject which is a child of a \a parent.
68 QBarSeries is QObject which is a child of a \a parent.
69 */
69 */
70 QBarSeries::QBarSeries(QBarCategories categories, QObject *parent) :
70 QBarSeries::QBarSeries(/*QBarCategories categories,*/ QObject *parent) :
71 QAbstractSeries(*new QBarSeriesPrivate(categories, this),parent)
71 QAbstractSeries(*new QBarSeriesPrivate(/*categories,*/ this),parent)
72 {
72 {
73 }
73 }
74
74
@@ -96,6 +96,13 QAbstractSeries::SeriesType QBarSeries::type() const
96 return QAbstractSeries::SeriesTypeBar;
96 return QAbstractSeries::SeriesTypeBar;
97 }
97 }
98
98
99 void QBarSeries::setCategories(QBarCategories categories)
100 {
101 Q_D(QBarSeries);
102 d->setCategories(categories);
103 emit d->categoriesUpdated();
104 }
105
99 /*!
106 /*!
100 Adds a set of bars to series. Takes ownership of \a set.
107 Adds a set of bars to series. Takes ownership of \a set.
101 */
108 */
@@ -227,15 +234,21 void QBarSeries::setLabelsVisible(bool visible)
227
234
228 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
235 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
229
236
230 QBarSeriesPrivate::QBarSeriesPrivate(QBarCategories categories, QBarSeries *q) :
237 QBarSeriesPrivate::QBarSeriesPrivate(/*QBarCategories categories,*/ QBarSeries *q) :
231 QAbstractSeriesPrivate(q),
238 QAbstractSeriesPrivate(q),
232 m_categories(categories),
239 // m_categories(categories),
233 m_mapCategories(-1),
240 m_mapCategories(-1),
234 m_mapBarBottom(-1),
241 m_mapBarBottom(-1),
235 m_mapBarTop(-1)
242 m_mapBarTop(-1)
236 {
243 {
237 }
244 }
238
245
246 void QBarSeriesPrivate::setCategories(QBarCategories categories)
247 {
248 m_categories = categories;
249 }
250
251
239 QBarSet* QBarSeriesPrivate::barsetAt(int index)
252 QBarSet* QBarSeriesPrivate::barsetAt(int index)
240 {
253 {
241 return m_barSets.at(index);
254 return m_barSets.at(index);
@@ -39,10 +39,11 class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractSeries
39 {
39 {
40 Q_OBJECT
40 Q_OBJECT
41 public:
41 public:
42 explicit QBarSeries(QBarCategories categories, QObject *parent = 0);
42 explicit QBarSeries(/*QBarCategories categories,*/ QObject *parent = 0);
43 virtual ~QBarSeries();
43 virtual ~QBarSeries();
44
44
45 QAbstractSeries::SeriesType type() const;
45 QAbstractSeries::SeriesType type() const;
46 void setCategories(QBarCategories categories);
46
47
47 void appendBarSet(QBarSet *set); // Takes ownership of set
48 void appendBarSet(QBarSet *set); // Takes ownership of set
48 void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set
49 void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set
@@ -15,7 +15,8 class QBarSeriesPrivate : public QAbstractSeriesPrivate
15 {
15 {
16 Q_OBJECT
16 Q_OBJECT
17 public:
17 public:
18 QBarSeriesPrivate(QBarCategories categories, QBarSeries *parent);
18 QBarSeriesPrivate(/*QBarCategories categories,*/ QBarSeries *parent);
19 void setCategories(QBarCategories categories);
19
20
20 void scaleDomain(Domain& domain);
21 void scaleDomain(Domain& domain);
21 Chart* createGraphics(ChartPresenter* presenter);
22 Chart* createGraphics(ChartPresenter* presenter);
@@ -53,8 +53,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
53 Constructs empty QPercentBarSeries. Parameter \a categories defines the categories for chart.
53 Constructs empty QPercentBarSeries. Parameter \a categories defines the categories for chart.
54 QPercentBarSeries is QObject which is a child of a \a parent.
54 QPercentBarSeries is QObject which is a child of a \a parent.
55 */
55 */
56 QPercentBarSeries::QPercentBarSeries(QBarCategories categories, QObject *parent)
56 QPercentBarSeries::QPercentBarSeries(/*QBarCategories categories,*/ QObject *parent)
57 : QBarSeries(*new QPercentBarSeriesPrivate(categories,this), parent)
57 : QBarSeries(*new QPercentBarSeriesPrivate(/*categories,*/this), parent)
58 {
58 {
59 }
59 }
60
60
@@ -65,7 +65,7 QAbstractSeries::SeriesType QPercentBarSeries::type() const
65
65
66 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
66 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
67
67
68 QPercentBarSeriesPrivate::QPercentBarSeriesPrivate(QBarCategories categories, QPercentBarSeries *q) : QBarSeriesPrivate(categories,q)
68 QPercentBarSeriesPrivate::QPercentBarSeriesPrivate(/*QBarCategories categories,*/ QPercentBarSeries *q) : QBarSeriesPrivate(/*categories,*/q)
69 {
69 {
70
70
71 }
71 }
@@ -32,8 +32,9 class QTCOMMERCIALCHART_EXPORT QPercentBarSeries : public QBarSeries
32 {
32 {
33 Q_OBJECT
33 Q_OBJECT
34 public:
34 public:
35 explicit QPercentBarSeries(QBarCategories categories, QObject *parent = 0);
35 explicit QPercentBarSeries(/*QBarCategories categories,*/ QObject *parent = 0);
36 QAbstractSeries::SeriesType type() const;
36 QAbstractSeries::SeriesType type() const;
37
37 private:
38 private:
38 Q_DECLARE_PRIVATE(QPercentBarSeries)
39 Q_DECLARE_PRIVATE(QPercentBarSeries)
39 Q_DISABLE_COPY(QPercentBarSeries)
40 Q_DISABLE_COPY(QPercentBarSeries)
@@ -39,7 +39,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
39 class QPercentBarSeriesPrivate: public QBarSeriesPrivate
39 class QPercentBarSeriesPrivate: public QBarSeriesPrivate
40 {
40 {
41 public:
41 public:
42 QPercentBarSeriesPrivate(QBarCategories categories,QPercentBarSeries* q);
42 QPercentBarSeriesPrivate(/*QBarCategories categories,*/QPercentBarSeries* q);
43 void scaleDomain(Domain& domain);
43 void scaleDomain(Domain& domain);
44 Chart* createGraphics(ChartPresenter* presenter);
44 Chart* createGraphics(ChartPresenter* presenter);
45
45
@@ -52,8 +52,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
52 Constructs empty QStackedBarSeries. Parameter \a categories defines the categories for chart.
52 Constructs empty QStackedBarSeries. Parameter \a categories defines the categories for chart.
53 QStackedBarSeries is QObject which is a child of a \a parent.
53 QStackedBarSeries is QObject which is a child of a \a parent.
54 */
54 */
55 QStackedBarSeries::QStackedBarSeries(QBarCategories categories, QObject *parent)
55 QStackedBarSeries::QStackedBarSeries(/*QBarCategories categories,*/ QObject *parent)
56 : QBarSeries(*new QStackedBarSeriesPrivate(categories,this), parent)
56 : QBarSeries(*new QStackedBarSeriesPrivate(/*categories,*/this), parent)
57 {
57 {
58 }
58 }
59
59
@@ -64,7 +64,7 QAbstractSeries::SeriesType QStackedBarSeries::type() const
64
64
65 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
65 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
66
66
67 QStackedBarSeriesPrivate::QStackedBarSeriesPrivate(QBarCategories categories, QStackedBarSeries *q) : QBarSeriesPrivate(categories,q)
67 QStackedBarSeriesPrivate::QStackedBarSeriesPrivate(/*QBarCategories categories,*/ QStackedBarSeries *q) : QBarSeriesPrivate(/*categories,*/q)
68 {
68 {
69
69
70 }
70 }
@@ -32,8 +32,9 class QTCOMMERCIALCHART_EXPORT QStackedBarSeries : public QBarSeries
32 {
32 {
33 Q_OBJECT
33 Q_OBJECT
34 public:
34 public:
35 explicit QStackedBarSeries(QBarCategories categories, QObject *parent = 0);
35 explicit QStackedBarSeries(/*QBarCategories categories,*/ QObject *parent = 0);
36 QAbstractSeries::SeriesType type() const;
36 QAbstractSeries::SeriesType type() const;
37
37 private:
38 private:
38 Q_DECLARE_PRIVATE(QStackedBarSeries)
39 Q_DECLARE_PRIVATE(QStackedBarSeries)
39 Q_DISABLE_COPY(QStackedBarSeries)
40 Q_DISABLE_COPY(QStackedBarSeries)
@@ -39,7 +39,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
39 class QStackedBarSeriesPrivate: public QBarSeriesPrivate
39 class QStackedBarSeriesPrivate: public QBarSeriesPrivate
40 {
40 {
41 public:
41 public:
42 QStackedBarSeriesPrivate(QBarCategories categories,QStackedBarSeries* q);
42 QStackedBarSeriesPrivate(/*QBarCategories categories,*/QStackedBarSeries* q);
43 Chart* createGraphics(ChartPresenter* presenter);
43 Chart* createGraphics(ChartPresenter* presenter);
44 void scaleDomain(Domain& domain);
44 void scaleDomain(Domain& domain);
45
45
@@ -78,8 +78,10 void tst_QBarSeries::cleanupTestCase()
78 void tst_QBarSeries::init()
78 void tst_QBarSeries::init()
79 {
79 {
80 m_categories << "category0" << "category1" << "category2";
80 m_categories << "category0" << "category1" << "category2";
81 m_barseries = new QBarSeries(m_categories);
81 m_barseries = new QBarSeries();
82 m_barseries_with_sets = new QBarSeries(m_categories);
82 m_barseries->setCategories(m_categories);
83 m_barseries_with_sets = new QBarSeries();
84 m_barseries_with_sets->setCategories(m_categories);
83
85
84 for (int i=0; i<5; i++) {
86 for (int i=0; i<5; i++) {
85 m_testSets.append(new QBarSet("testset"));
87 m_testSets.append(new QBarSet("testset"));
@@ -113,8 +115,9 void tst_QBarSeries::qbarseries_data()
113 void tst_QBarSeries::qbarseries()
115 void tst_QBarSeries::qbarseries()
114 {
116 {
115 QFETCH(QBarCategories, categories);
117 QFETCH(QBarCategories, categories);
116 QBarSeries *barseries = new QBarSeries(categories);
118 QBarSeries *barseries = new QBarSeries();
117 QVERIFY(barseries != 0);
119 QVERIFY(barseries != 0);
120 barseries->setCategories(categories);
118 QBarCategories verifyCategories = barseries->categories();
121 QBarCategories verifyCategories = barseries->categories();
119
122
120 QVERIFY(verifyCategories.count() == categories.count());
123 QVERIFY(verifyCategories.count() == categories.count());
General Comments 0
You need to be logged in to leave comments. Login now