##// END OF EJS Templates
Enabled dummy bar chart impl in QML again
Tero Ahola -
r1004:5a2832f9c305
parent child
Show More
@@ -1,89 +1,79
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "declarativebarseries.h"
21 #include "declarativebarseries.h"
22 #include "declarativechart.h"
22 #include "declarativechart.h"
23 #include "qchart.h"
23 #include "qchart.h"
24 #include "qbarseries.h"
24 #include "qbarseries.h"
25 #include "qbarset.h"
25 #include "qbarset.h"
26
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
28
29 DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) :
29 DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) :
30 QDeclarativeItem(parent)
30 QDeclarativeItem(parent)
31 {
31 {
32 setFlag(QGraphicsItem::ItemHasNoContents, false);
32 setFlag(QGraphicsItem::ItemHasNoContents, false);
33 }
33 }
34
34
35 void DeclarativeBarSeries::componentComplete()
35 void DeclarativeBarSeries::componentComplete()
36 {
36 {
37 if (!m_series) {
37 }
38 DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(parent());
39
38
40 if (declarativeChart) {
39 void DeclarativeBarSeries::setBarCategories(QStringList categories)
41 QChart *chart = qobject_cast<QChart *>(declarativeChart->m_chart);
40 {
42 Q_ASSERT(chart);
41 m_categories = categories;
43
42
44 // QStringList categories;
43 if (m_series) {
45 // categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun";
44 delete m_series;
46 // m_series = new QBarSeries(categories);
45 m_series = 0;
47 // m_series = new QBarSeries(m_categories);
46 }
48 m_series = new QBarSeries(m_categories);
49
47
50 // TODO: use data from model
48 DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(parent());
51 QBarSet *set0 = new QBarSet("Bub");
49 if (declarativeChart) {
52 QBarSet *set1 = new QBarSet("Bob");
50 QChart *chart = qobject_cast<QChart *>(declarativeChart->m_chart);
53 QBarSet *set2 = new QBarSet("Guybrush");
51 Q_ASSERT(chart);
54
52
55 *set0 << 1 << 2 << 3 << 4 << 5 << 6;
53 m_series = new QBarSeries(m_categories);
56 *set1 << 5 << 1 << 2 << 4 << 1 << 7;
57 *set2 << 3 << 5 << 8 << 13 << 8 << 5;
58
54
59 m_series->appendBarSet(set0);
55 // TODO: use data from model
60 m_series->appendBarSet(set1);
56 QBarSet *set0 = new QBarSet("Bub");
61 m_series->appendBarSet(set2);
57 QBarSet *set1 = new QBarSet("Bob");
58 QBarSet *set2 = new QBarSet("Guybrush");
62
59
63 chart->addSeries(m_series);
60 *set0 << 1 << 2 << 3 << 4 << 5 << 6;
64 }
61 *set1 << 5 << 1 << 2 << 4 << 1 << 7;
65 }
62 *set2 << 3 << 5 << 8 << 13 << 8 << 5;
66 }
67
63
68 void DeclarativeBarSeries::setBarCategories(QStringList /*categories*/)
64 m_series->appendBarSet(set0);
69 {
65 m_series->appendBarSet(set1);
70 // m_categories = categories;
66 m_series->appendBarSet(set2);
71 // if (m_series) {
67
72 // // Replace categories of the QBarSeries with the new categories
68 chart->addSeries(m_series);
73 // for (int i(0); i < m_categories.count(); i++) {
69 }
74 // if (m_series->categories().at(i) != m_categories.at(i))
75 // m_series->insertCategory(m_series->categoryCount(), m_categories.at(i));
76 // }
77 // while (m_series->categoryCount() > m_categories.count())
78 // m_series->removeCategory(m_series->categoryCount() - 1);
79 // }
80 }
70 }
81
71
82 QStringList DeclarativeBarSeries::barCategories()
72 QStringList DeclarativeBarSeries::barCategories()
83 {
73 {
84 return m_categories;
74 return m_categories;
85 }
75 }
86
76
87 #include "moc_declarativebarseries.cpp"
77 #include "moc_declarativebarseries.cpp"
88
78
89 QTCOMMERCIALCHART_END_NAMESPACE
79 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now