@@ -211,7 +211,7 QChart* ThemeWidget::createBarChart(int valueCount) const | |||
|
211 | 211 | QBarSet *set = new QBarSet("Set" + QString::number(i)); |
|
212 | 212 | foreach (Data data, m_dataTable[i]) |
|
213 | 213 | *set << data.first.y(); |
|
214 |
series->a |
|
|
214 | series->appendBarSet(set); | |
|
215 | 215 | } |
|
216 | 216 | chart->addSeries(series); |
|
217 | 217 | } |
@@ -69,11 +69,11 int main(int argc, char *argv[]) | |||
|
69 | 69 | //![2] |
|
70 | 70 | //![3] |
|
71 | 71 | QBarSeries* series = new QBarSeries(categories); |
|
72 |
series->a |
|
|
73 |
series->a |
|
|
74 |
series->a |
|
|
75 |
series->a |
|
|
76 |
series->a |
|
|
72 | series->appendBarSet(set0); | |
|
73 | series->appendBarSet(set1); | |
|
74 | series->appendBarSet(set2); | |
|
75 | series->appendBarSet(set3); | |
|
76 | series->appendBarSet(set4); | |
|
77 | 77 | //![3] |
|
78 | 78 | //![4] |
|
79 | 79 | QChart* chart = new QChart(); |
@@ -69,11 +69,11 int main(int argc, char *argv[]) | |||
|
69 | 69 | //![2] |
|
70 | 70 | //![3] |
|
71 | 71 | QPercentBarSeries* series = new QPercentBarSeries(categories); |
|
72 |
series->a |
|
|
73 |
series->a |
|
|
74 |
series->a |
|
|
75 |
series->a |
|
|
76 |
series->a |
|
|
72 | series->appendBarSet(set0); | |
|
73 | series->appendBarSet(set1); | |
|
74 | series->appendBarSet(set2); | |
|
75 | series->appendBarSet(set3); | |
|
76 | series->appendBarSet(set4); | |
|
77 | 77 | //![3] |
|
78 | 78 | //![4] |
|
79 | 79 | QChart* chart = new QChart(); |
@@ -69,11 +69,11 int main(int argc, char *argv[]) | |||
|
69 | 69 | //![2] |
|
70 | 70 | //![3] |
|
71 | 71 | QStackedBarSeries* series = new QStackedBarSeries(categories); |
|
72 |
series->a |
|
|
73 |
series->a |
|
|
74 |
series->a |
|
|
75 |
series->a |
|
|
76 |
series->a |
|
|
72 | series->appendBarSet(set0); | |
|
73 | series->appendBarSet(set1); | |
|
74 | series->appendBarSet(set2); | |
|
75 | series->appendBarSet(set3); | |
|
76 | series->appendBarSet(set4); | |
|
77 | 77 | //![3] |
|
78 | 78 | //![4] |
|
79 | 79 | QChart* chart = new QChart(); |
@@ -36,9 +36,9 void DeclarativeBarSeries::componentComplete() | |||
|
36 | 36 | *set1 << 5 << 0 << 0 << 4 << 0 << 7; |
|
37 | 37 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; |
|
38 | 38 | |
|
39 |
m_series->a |
|
|
40 |
m_series->a |
|
|
41 |
m_series->a |
|
|
39 | m_series->appendBarSet(set0); | |
|
40 | m_series->appendBarSet(set1); | |
|
41 | m_series->appendBarSet(set2); | |
|
42 | 42 | |
|
43 | 43 | chart->addSeries(m_series); |
|
44 | 44 | } |
@@ -140,9 +140,9 QVector<QRectF> BarChartItem::calculateLayout() | |||
|
140 | 140 | value->setPen(barSet->floatingValuePen()); |
|
141 | 141 | |
|
142 | 142 | if (!qFuzzyIsNull(m_series->valueAt(set,category))) { |
|
143 |
value->set |
|
|
143 | value->setText(QString::number(m_series->valueAt(set, category))); | |
|
144 | 144 | } else { |
|
145 |
value->set |
|
|
145 | value->setText(QString("")); | |
|
146 | 146 | } |
|
147 | 147 | |
|
148 | 148 | itemIndex++; |
@@ -16,7 +16,7 QStringList BarChartModel::category() | |||
|
16 | 16 | return m_category; |
|
17 | 17 | } |
|
18 | 18 | |
|
19 |
void BarChartModel::a |
|
|
19 | void BarChartModel::appendBarSet(QBarSet *set) | |
|
20 | 20 | { |
|
21 | 21 | m_dataModel.append(set); |
|
22 | 22 | } |
@@ -43,27 +43,27 void BarChartModel::removeCategory(int i) | |||
|
43 | 43 | m_category.removeAt(i); |
|
44 | 44 | } |
|
45 | 45 | |
|
46 | QBarSet* BarChartModel::setAt(int index) | |
|
46 | QBarSet* BarChartModel::barsetAt(int index) const | |
|
47 | 47 | { |
|
48 | 48 | return m_dataModel.at(index); |
|
49 | 49 | } |
|
50 | 50 | |
|
51 | QList<QBarSet*> BarChartModel::barSets() | |
|
51 | QList<QBarSet*> BarChartModel::barSets() const | |
|
52 | 52 | { |
|
53 | 53 | return m_dataModel; |
|
54 | 54 | } |
|
55 | 55 | |
|
56 | int BarChartModel::barsetCount() | |
|
56 | int BarChartModel::barsetCount() const | |
|
57 | 57 | { |
|
58 | 58 | return m_dataModel.count(); |
|
59 | 59 | } |
|
60 | 60 | |
|
61 | int BarChartModel::categoryCount() | |
|
61 | int BarChartModel::categoryCount() const | |
|
62 | 62 | { |
|
63 | 63 | return m_category.count(); |
|
64 | 64 | } |
|
65 | 65 | |
|
66 | qreal BarChartModel::min() | |
|
66 | qreal BarChartModel::min() const | |
|
67 | 67 | { |
|
68 | 68 | Q_ASSERT(m_dataModel.count() > 0); |
|
69 | 69 | // TODO: make min and max members and update them when data changes. |
@@ -81,7 +81,7 qreal BarChartModel::min() | |||
|
81 | 81 | return min; |
|
82 | 82 | } |
|
83 | 83 | |
|
84 | qreal BarChartModel::max() | |
|
84 | qreal BarChartModel::max() const | |
|
85 | 85 | { |
|
86 | 86 | Q_ASSERT(m_dataModel.count() > 0); |
|
87 | 87 | |
@@ -101,7 +101,7 qreal BarChartModel::max() | |||
|
101 | 101 | return max; |
|
102 | 102 | } |
|
103 | 103 | |
|
104 | qreal BarChartModel::valueAt(int set, int category) | |
|
104 | qreal BarChartModel::valueAt(int set, int category) const | |
|
105 | 105 | { |
|
106 | 106 | if ((set < 0) || (set >= m_dataModel.count())) { |
|
107 | 107 | // No set, no value. |
@@ -114,7 +114,7 qreal BarChartModel::valueAt(int set, int category) | |||
|
114 | 114 | return m_dataModel.at(set)->valueAt(category); |
|
115 | 115 | } |
|
116 | 116 | |
|
117 | qreal BarChartModel::percentageAt(int set, int category) | |
|
117 | qreal BarChartModel::percentageAt(int set, int category) const | |
|
118 | 118 | { |
|
119 | 119 | if ((set < 0) || (set >= m_dataModel.count())) { |
|
120 | 120 | // No set, no value. |
@@ -133,7 +133,7 qreal BarChartModel::percentageAt(int set, int category) | |||
|
133 | 133 | } |
|
134 | 134 | |
|
135 | 135 | |
|
136 | qreal BarChartModel::categorySum(int category) | |
|
136 | qreal BarChartModel::categorySum(int category) const | |
|
137 | 137 | { |
|
138 | 138 | qreal sum(0); |
|
139 | 139 | int count = m_dataModel.count(); // Count sets |
@@ -145,7 +145,7 qreal BarChartModel::categorySum(int category) | |||
|
145 | 145 | return sum; |
|
146 | 146 | } |
|
147 | 147 | |
|
148 | qreal BarChartModel::maxCategorySum() | |
|
148 | qreal BarChartModel::maxCategorySum() const | |
|
149 | 149 | { |
|
150 | 150 | qreal max = INT_MIN; |
|
151 | 151 | int count = categoryCount(); |
@@ -20,24 +20,24 public: | |||
|
20 | 20 | explicit BarChartModel(QStringList categories, QObject *parent = 0); |
|
21 | 21 | |
|
22 | 22 | QStringList category(); |
|
23 |
void a |
|
|
23 | void appendBarSet(QBarSet *set); | |
|
24 | 24 | void removeBarSet(QBarSet *set); |
|
25 | 25 | void insertBarSet(int i, QBarSet *set); |
|
26 | 26 | void insertCategory(int i, QString category); |
|
27 | 27 | void removeCategory(int i); |
|
28 | QBarSet *setAt(int index); | |
|
29 | QList<QBarSet *> barSets(); | |
|
28 | QBarSet *barsetAt(int index) const; | |
|
29 | QList<QBarSet *> barSets() const; | |
|
30 | 30 | |
|
31 | int barsetCount(); // Number of sets in model | |
|
32 | int categoryCount(); // Number of categories | |
|
31 | int barsetCount() const; // Number of sets in model | |
|
32 | int categoryCount() const; // Number of categories | |
|
33 | 33 | |
|
34 | qreal max(); // Maximum value of all sets | |
|
35 | qreal min(); // Minimum value of all sets | |
|
36 | qreal valueAt(int set, int category); | |
|
37 | qreal percentageAt(int set, int category); | |
|
34 | qreal max() const; // Maximum value of all sets | |
|
35 | qreal min() const; // Minimum value of all sets | |
|
36 | qreal valueAt(int set, int category) const; | |
|
37 | qreal percentageAt(int set, int category) const; | |
|
38 | 38 | |
|
39 | qreal categorySum(int category); | |
|
40 | qreal maxCategorySum(); // returns maximum sum of sets in all categories. | |
|
39 | qreal categorySum(int category) const; | |
|
40 | qreal maxCategorySum() const; // returns maximum sum of sets in all categories. | |
|
41 | 41 | |
|
42 | 42 | QString categoryName(int category); |
|
43 | 43 |
@@ -15,17 +15,17 BarValue::BarValue(QBarSet &set, QGraphicsItem *parent) | |||
|
15 | 15 | setVisible(false); |
|
16 | 16 | } |
|
17 | 17 | |
|
18 |
void BarValue::set |
|
|
18 | void BarValue::setText(QString str) | |
|
19 | 19 | { |
|
20 | 20 | m_valueString = str; |
|
21 | 21 | } |
|
22 | 22 | |
|
23 |
QString BarValue:: |
|
|
23 | QString BarValue::text() const | |
|
24 | 24 | { |
|
25 | 25 | return m_valueString; |
|
26 | 26 | } |
|
27 | 27 | |
|
28 | void BarValue::setPen(const QPen pen) | |
|
28 | void BarValue::setPen(const QPen &pen) | |
|
29 | 29 | { |
|
30 | 30 | m_pen = pen; |
|
31 | 31 | } |
@@ -17,10 +17,10 class BarValue : public QGraphicsObject | |||
|
17 | 17 | public: |
|
18 | 18 | BarValue(QBarSet &set, QGraphicsItem *parent = 0); |
|
19 | 19 | |
|
20 |
void set |
|
|
21 |
QString |
|
|
20 | void setText(QString str); | |
|
21 | QString text() const; | |
|
22 | 22 | |
|
23 | void setPen(const QPen pen); | |
|
23 | void setPen(const QPen &pen); | |
|
24 | 24 | QPen pen() const; |
|
25 | 25 | |
|
26 | 26 | void resize(qreal w, qreal h); |
@@ -63,9 +63,9 QVector<QRectF> PercentBarChartItem::calculateLayout() | |||
|
63 | 63 | QString vString(QString::number(p)); |
|
64 | 64 | vString.truncate(3); |
|
65 | 65 | vString.append("%"); |
|
66 |
value->set |
|
|
66 | value->setText(vString); | |
|
67 | 67 | } else { |
|
68 |
value->set |
|
|
68 | value->setText(QString("")); | |
|
69 | 69 | } |
|
70 | 70 | |
|
71 | 71 | itemIndex++; |
@@ -50,9 +50,9 QBarSeries::QBarSeries(QBarCategories categories, QObject *parent) : QSeries(par | |||
|
50 | 50 | Connects the clicked(QString) and rightClicked(QString) signals |
|
51 | 51 | of \a set to this series |
|
52 | 52 | */ |
|
53 |
void QBarSeries::a |
|
|
53 | void QBarSeries::appendBarSet(QBarSet *set) | |
|
54 | 54 | { |
|
55 |
m_internalModel->a |
|
|
55 | m_internalModel->appendBarSet(set); | |
|
56 | 56 | connect(set, SIGNAL(clicked(QString)), this, SLOT(barsetClicked(QString))); |
|
57 | 57 | connect(set, SIGNAL(rightClicked(QString)), this, SLOT(barsetRightClicked(QString))); |
|
58 | 58 | connect(set, SIGNAL(valueChanged()), this, SLOT(barsetChanged())); |
@@ -91,7 +91,7 void QBarSeries::removeCategory(int i) | |||
|
91 | 91 | /*! |
|
92 | 92 | Returns number of sets in series. |
|
93 | 93 | */ |
|
94 | int QBarSeries::barsetCount() | |
|
94 | int QBarSeries::barsetCount() const | |
|
95 | 95 | { |
|
96 | 96 | // if(m_model) |
|
97 | 97 | // return m_mapBarTop - m_mapBarBottom; |
@@ -102,7 +102,7 int QBarSeries::barsetCount() | |||
|
102 | 102 | /*! |
|
103 | 103 | Returns number of categories in series |
|
104 | 104 | */ |
|
105 | int QBarSeries::categoryCount() | |
|
105 | int QBarSeries::categoryCount() const | |
|
106 | 106 | { |
|
107 | 107 | return m_internalModel->categoryCount(); |
|
108 | 108 | } |
@@ -110,7 +110,7 int QBarSeries::categoryCount() | |||
|
110 | 110 | /*! |
|
111 | 111 | Returns a list of sets in series. Keeps ownership of sets. |
|
112 | 112 | */ |
|
113 | QList<QBarSet*> QBarSeries::barSets() | |
|
113 | QList<QBarSet*> QBarSeries::barSets() const | |
|
114 | 114 | { |
|
115 | 115 | return m_internalModel->barSets(); |
|
116 | 116 | } |
@@ -120,7 +120,7 QList<QBarSet*> QBarSeries::barSets() | |||
|
120 | 120 | */ |
|
121 | 121 | QBarSet* QBarSeries::barsetAt(int index) |
|
122 | 122 | { |
|
123 | return m_internalModel->setAt(index); | |
|
123 | return m_internalModel->barsetAt(index); | |
|
124 | 124 | } |
|
125 | 125 | |
|
126 | 126 | /*! |
@@ -141,12 +141,12 void QBarSeries::setToolTipEnabled(bool enabled) | |||
|
141 | 141 | // TODO: what if we add sets after call to this function? Those sets won't have tooltip enabled. |
|
142 | 142 | if (enabled) { |
|
143 | 143 | for (int i=0; i<m_internalModel->barsetCount(); i++) { |
|
144 | QBarSet *set = m_internalModel->setAt(i); | |
|
144 | QBarSet *set = m_internalModel->barsetAt(i); | |
|
145 | 145 | connect(set, SIGNAL(showToolTip(QPoint,QString)), this, SIGNAL(showToolTip(QPoint,QString))); |
|
146 | 146 | } |
|
147 | 147 | } else { |
|
148 | 148 | for (int i=0; i<m_internalModel->barsetCount(); i++) { |
|
149 | QBarSet *set = m_internalModel->setAt(i); | |
|
149 | QBarSet *set = m_internalModel->barsetAt(i); | |
|
150 | 150 | disconnect(set, SIGNAL(showToolTip(QPoint,QString)), this, SIGNAL(showToolTip(QPoint,QString))); |
|
151 | 151 | } |
|
152 | 152 | } |
@@ -297,7 +297,7 void QBarSeries::setModelMapping(int categories, int bottomBoundry, int topBound | |||
|
297 | 297 | QBarSet* barSet = new QBarSet(QString("Column: %1").arg(i + 1)); |
|
298 | 298 | for(int m = m_mapFirst; m < m_mapFirst + m_mapCount; m++) |
|
299 | 299 | *barSet << m_model->data(m_model->index(m, i), Qt::DisplayRole).toDouble(); |
|
300 |
a |
|
|
300 | appendBarSet(barSet); | |
|
301 | 301 | } |
|
302 | 302 | } else { |
|
303 | 303 | QStringList categories; |
@@ -309,7 +309,7 void QBarSeries::setModelMapping(int categories, int bottomBoundry, int topBound | |||
|
309 | 309 | QBarSet* barSet = new QBarSet(QString("Row: %1").arg(i + 1)); |
|
310 | 310 | for(int m = m_mapFirst; m < m_mapFirst + m_mapCount; m++) |
|
311 | 311 | *barSet << m_model->data(m_model->index(i, m), Qt::DisplayRole).toDouble(); |
|
312 |
a |
|
|
312 | appendBarSet(barSet); | |
|
313 | 313 | } |
|
314 | 314 | } |
|
315 | 315 | } |
@@ -21,14 +21,14 public: | |||
|
21 | 21 | |
|
22 | 22 | virtual QSeriesType type() const { return QSeries::SeriesTypeBar; } |
|
23 | 23 | |
|
24 |
void a |
|
|
24 | void appendBarSet(QBarSet *set); // Takes ownership of set | |
|
25 | 25 | void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set |
|
26 | 26 | void insertBarSet(int i, QBarSet *set); |
|
27 | 27 | void insertCategory(int i, QString category); |
|
28 | 28 | void removeCategory(int i); |
|
29 | int barsetCount(); | |
|
30 | int categoryCount(); | |
|
31 | QList<QBarSet*> barSets(); | |
|
29 | int barsetCount() const; | |
|
30 | int categoryCount() const; | |
|
31 | QList<QBarSet*> barSets() const; | |
|
32 | 32 | QBarCategories categories() const; |
|
33 | 33 | |
|
34 | 34 | bool setModel(QAbstractItemModel *model); |
@@ -71,7 +71,7 void QBarSet::setName(QString name) | |||
|
71 | 71 | /*! |
|
72 | 72 | Returns name of the set. |
|
73 | 73 | */ |
|
74 | QString QBarSet::name() | |
|
74 | QString QBarSet::name() const | |
|
75 | 75 | { |
|
76 | 76 | return m_name; |
|
77 | 77 | } |
@@ -99,7 +99,7 void QBarSet::removeValue(int i) | |||
|
99 | 99 | /*! |
|
100 | 100 | Returns count of values in set. |
|
101 | 101 | */ |
|
102 | int QBarSet::count() | |
|
102 | int QBarSet::count() const | |
|
103 | 103 | { |
|
104 | 104 | return m_values.count(); |
|
105 | 105 | } |
@@ -107,7 +107,7 int QBarSet::count() | |||
|
107 | 107 | /*! |
|
108 | 108 | Returns value of set indexed by \a index |
|
109 | 109 | */ |
|
110 | qreal QBarSet::valueAt(int index) | |
|
110 | qreal QBarSet::valueAt(int index) const | |
|
111 | 111 | { |
|
112 | 112 | return m_values.at(index); |
|
113 | 113 | } |
@@ -124,7 +124,7 void QBarSet::setValue(int index, qreal value) | |||
|
124 | 124 | /*! |
|
125 | 125 | Returns total sum of all values in barset. |
|
126 | 126 | */ |
|
127 | qreal QBarSet::total() | |
|
127 | qreal QBarSet::total() const | |
|
128 | 128 | { |
|
129 | 129 | qreal total(0); |
|
130 | 130 | for (int i=0; i < m_values.count(); i++) { |
@@ -14,16 +14,16 public: | |||
|
14 | 14 | QBarSet(QString name, QObject *parent = 0); |
|
15 | 15 | |
|
16 | 16 | void setName(QString name); |
|
17 | QString name(); | |
|
17 | QString name() const; | |
|
18 | 18 | QBarSet& operator << (const qreal &value); // appends new value to set |
|
19 | 19 | void insertValue(int i, qreal value); |
|
20 | 20 | void removeValue(int i); |
|
21 | 21 | |
|
22 | 22 | // TODO: remove indices eventually. Use as internal? |
|
23 |
int count(); |
|
|
24 | qreal valueAt(int index); // for modifying individual values | |
|
23 | int count() const; // count of values in set | |
|
24 | qreal valueAt(int index) const; // for modifying individual values | |
|
25 | 25 | void setValue(int index, qreal value); // setter for individual value |
|
26 | qreal total(); // total values in the set | |
|
26 | qreal total() const; // total values in the set | |
|
27 | 27 | |
|
28 | 28 | // TODO: |
|
29 | 29 | //qreal value(QString category); |
@@ -65,9 +65,9 QVector<QRectF> StackedBarChartItem::calculateLayout() | |||
|
65 | 65 | value->setPen(barSet->floatingValuePen()); |
|
66 | 66 | |
|
67 | 67 | if (!qFuzzyIsNull(m_series->valueAt(set, category))) { |
|
68 |
value->set |
|
|
68 | value->setText(QString::number(m_series->valueAt(set,category))); | |
|
69 | 69 | } else { |
|
70 |
value->set |
|
|
70 | value->setText(QString("")); | |
|
71 | 71 | } |
|
72 | 72 | |
|
73 | 73 | itemIndex++; |
General Comments 0
You need to be logged in to leave comments.
Login now