##// END OF EJS Templates
removed old code from barcharts
sauimone -
r162:646d6bcb9a35
parent child
Show More
@@ -10,115 +10,10 BarChartSeriesBase::BarChartSeriesBase(QObject *parent)
10 10 : QChartSeries(parent)
11 11 ,mModel(*(new BarChartModel(this))) // TODO: is this ok?
12 12 {
13 qDebug() << "BarChartSeriesBase::BarChartSeriesBase";
14 13 }
15 /*
16 bool BarChartSeriesBase::setModel(QAbstractItemModel* model)
17 {
18 mModel = model;
19 return true;
20 }
21 */
22 /*
23 bool BarChartSeriesBase::setData(QList<qreal>& data)
24 {
25 mData = &data;
26 return true;
27 }
28 */
29 /*
30 int BarChartSeriesBase::min()
31 {
32 Q_ASSERT(mModel->rowCount() > 0);
33 Q_ASSERT(mModel->columnCount() > 0);
34
35 // TODO: make min and max members and update them when data changes.
36 // This is slower since they are checked every time, even if data is same since previous call.
37 int min = INT_MAX;
38
39 for (int i=0; i <mModel->rowCount(); i++) {
40 for(int j=0; j<mModel->columnCount(); j++) {
41 int temp = mModel->data(mModel->index(i,j)).toInt();
42 if (temp < min) {
43 min = temp;
44 }
45 }
46 }
47 return min;
48 }
49
50 int BarChartSeriesBase::max()
51 {
52 Q_ASSERT(mModel->rowCount() > 0);
53 Q_ASSERT(mModel->columnCount() > 0);
54
55 // TODO: make min and max members and update them when data changes.
56 // This is slower since they are checked every time, even if data is same since previous call.
57 int max = INT_MIN;
58
59 for (int i=0; i <mModel->rowCount(); i++) {
60 for(int j=0; j<mModel->columnCount(); j++) {
61 int temp = mModel->data(mModel->index(i,j)).toInt();
62 if (temp > max) {
63 max = temp;
64 }
65 }
66 }
67 return max;
68 }
69
70 int BarChartSeriesBase::maxColumnSum()
71 {
72 Q_ASSERT(mModel->rowCount() > 0);
73 Q_ASSERT(mModel->columnCount() > 0);
74
75 int max = INT_MIN;
76
77 for (int col=0; col <mModel->columnCount(); col++) {
78 int sum = columnSum(col);
79 if (sum > max) {
80 max = sum;
81 }
82 }
83 return max;
84 }
85
86 int BarChartSeriesBase::countRows()
87 {
88 return mModel->rowCount();
89 }
90
91 int BarChartSeriesBase::countColumns()
92 {
93 return mModel->columnCount();
94 }
95
96 int BarChartSeriesBase::countTotalItems()
97 {
98 return mModel->rowCount() * mModel->columnCount();
99 }
100
101 int BarChartSeriesBase::valueAt(int row, int column)
102 {
103 QModelIndex index = mModel->index(row,column);
104 return mModel->data(index).toInt();
105 }
106
107 int BarChartSeriesBase::columnSum(int column)
108 {
109 int sum(0);
110 int count = mModel->rowCount();
111
112 for (int row = 0; row < count; row++) {
113 sum += mModel->data(mModel->index(row,column)).toInt();
114 }
115 return sum;
116 }
117 */
118 14
119 15 int BarChartSeriesBase::addData(QList<qreal> data)
120 16 {
121 qDebug() << "BarChartSeriesBase::addData";
122 17 return mModel.addData(data);
123 18 }
124 19
@@ -130,45 +25,21 void BarChartSeriesBase::removeData(int id)
130 25 qreal BarChartSeriesBase::min()
131 26 {
132 27 return mModel.min();
133 /* Delegated to model
134 int count = mData->count();
135 int min = INT_MAX;
136
137 for (int i=0; i<count; i++) {
138 if (mData->at(i) < min) {
139 min = mData->at(i);
140 }
141 }
142 return min;
143 */
144 28 }
145 29
146 30 qreal BarChartSeriesBase::max()
147 31 {
148 32 return mModel.max();
149 /* Delegated to model
150 int count = mData->count();
151 int max = INT_MIN;
152
153 for (int i=0; i<count; i++) {
154 if (mData->at(i) > max) {
155 max = mData->at(i);
156 }
157 }
158 return max;
159 */
160 33 }
161 34
162 35 int BarChartSeriesBase::countColumns()
163 36 {
164 37 return mModel.countColumns();
165 // return mData->count();
166 38 }
167 39
168 40 qreal BarChartSeriesBase::valueAt(int series, int item)
169 41 {
170 42 return mModel.valueAt(series,item);
171 // return mData->at(item);
172 43 }
173 44
174 45 qreal BarChartSeriesBase::maxColumnSum()
@@ -6,7 +6,6 BarLabel::BarLabel(QGraphicsItem* parent) : ChartItem(parent)
6 6 {
7 7 }
8 8
9
10 9 void BarLabel::set(QString label)
11 10 {
12 11 mLabel = label;
@@ -3,7 +3,6
3 3 #include "barlabel_p.h"
4 4 #include "separator_p.h"
5 5 #include <QDebug>
6 //#include <QPainter>
7 6
8 7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 8
@@ -48,7 +47,7 void StackedBarGroup::layoutChanged()
48 47 Bar* bar = reinterpret_cast<Bar*> (childItems().at(itemIndex));
49 48
50 49 // TODO: width settable per bar?
51 // TODO: how to get color for series(x) from theme?
50 // TODO: theme stuff
52 51 // mTheme->themeForSeries();
53 52 bar->resize(mBarDefaultWidth, barHeight);
54 53 bar->setColor(mColors.at(row));
General Comments 0
You need to be logged in to leave comments. Login now