@@ -1,310 +1,310 | |||||
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 "tablewidget.h" |
|
21 | #include "tablewidget.h" | |
22 | #include <QGridLayout> |
|
22 | #include <QGridLayout> | |
23 | #include <QTableView> |
|
23 | #include <QTableView> | |
24 | #include <QStyledItemDelegate> |
|
24 | #include <QStyledItemDelegate> | |
25 | #include <QLineSeries> |
|
25 | #include <QLineSeries> | |
26 | #include <QSplineSeries> |
|
26 | #include <QSplineSeries> | |
27 | #include <QScatterSeries> |
|
27 | #include <QScatterSeries> | |
28 | #include "customtablemodel.h" |
|
28 | #include "customtablemodel.h" | |
29 | #include <QPieSeries> |
|
29 | #include <QPieSeries> | |
30 | #include <QPieSlice> |
|
30 | #include <QPieSlice> | |
31 | #include <QAreaSeries> |
|
31 | #include <QAreaSeries> | |
32 | #include <QBarSeries> |
|
32 | #include <QBarSeries> | |
33 | #include <QBarSet> |
|
33 | #include <QBarSet> | |
34 | #include <QPushButton> |
|
34 | #include <QPushButton> | |
35 | #include <QRadioButton> |
|
35 | #include <QRadioButton> | |
36 | #include <QSpinBox> |
|
36 | #include <QSpinBox> | |
37 | #include <QTime> |
|
37 | #include <QTime> | |
38 |
|
38 | |||
39 | TableWidget::TableWidget(QWidget *parent) |
|
39 | TableWidget::TableWidget(QWidget *parent) | |
40 | : QWidget(parent) |
|
40 | : QWidget(parent) | |
41 | { |
|
41 | { | |
42 | setGeometry(100, 100, 1000, 600); |
|
42 | setGeometry(100, 100, 1000, 600); | |
43 | qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); |
|
43 | qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); | |
44 | // create simple model for storing data |
|
44 | // create simple model for storing data | |
45 | // user's table data model |
|
45 | // user's table data model | |
46 | m_model = new CustomTableModel; |
|
46 | m_model = new CustomTableModel; | |
47 | m_tableView = new QTableView; |
|
47 | m_tableView = new QTableView; | |
48 | m_tableView->setModel(m_model); |
|
48 | m_tableView->setModel(m_model); | |
49 | m_tableView->setMinimumHeight(300); |
|
49 | m_tableView->setMinimumHeight(300); | |
50 | // tableView->setMinimumSize(340, 480); |
|
50 | // tableView->setMinimumSize(340, 480); | |
51 | // tableView->setItemDelegate(new QStyledItemDelegate); |
|
51 | // tableView->setItemDelegate(new QStyledItemDelegate); | |
52 | m_chart = new QChart; |
|
52 | m_chart = new QChart; | |
53 | m_chartView = new QChartView(m_chart); |
|
53 | m_chartView = new QChartView(m_chart); | |
54 | m_chartView->setRenderHint(QPainter::Antialiasing); |
|
54 | m_chartView->setRenderHint(QPainter::Antialiasing); | |
55 | m_chartView->setMinimumSize(640, 480); |
|
55 | m_chartView->setMinimumSize(640, 480); | |
56 |
|
56 | |||
57 | // add, remove data buttons |
|
57 | // add, remove data buttons | |
58 | QPushButton* addRowAboveButton = new QPushButton("Add row above"); |
|
58 | QPushButton* addRowAboveButton = new QPushButton("Add row above"); | |
59 | connect(addRowAboveButton, SIGNAL(clicked()), this, SLOT(addRowAbove())); |
|
59 | connect(addRowAboveButton, SIGNAL(clicked()), this, SLOT(addRowAbove())); | |
60 |
|
60 | |||
61 | QPushButton* addRowBelowButton = new QPushButton("Add row below"); |
|
61 | QPushButton* addRowBelowButton = new QPushButton("Add row below"); | |
62 | connect(addRowBelowButton, SIGNAL(clicked()), this, SLOT(addRowBelow())); |
|
62 | connect(addRowBelowButton, SIGNAL(clicked()), this, SLOT(addRowBelow())); | |
63 |
|
63 | |||
64 | QPushButton* removeRowButton = new QPushButton("Remove row"); |
|
64 | QPushButton* removeRowButton = new QPushButton("Remove row"); | |
65 | connect(removeRowButton, SIGNAL(clicked()), this, SLOT(removeRow())); |
|
65 | connect(removeRowButton, SIGNAL(clicked()), this, SLOT(removeRow())); | |
66 |
|
66 | |||
67 | m_linesCountSpinBox = new QSpinBox; |
|
67 | m_linesCountSpinBox = new QSpinBox; | |
68 | m_linesCountSpinBox->setRange(1, 10); |
|
68 | m_linesCountSpinBox->setRange(1, 10); | |
69 | m_linesCountSpinBox->setValue(1); |
|
69 | m_linesCountSpinBox->setValue(1); | |
70 |
|
70 | |||
71 | // buttons layout |
|
71 | // buttons layout | |
72 | QVBoxLayout* buttonsLayout = new QVBoxLayout; |
|
72 | QVBoxLayout* buttonsLayout = new QVBoxLayout; | |
73 | buttonsLayout->addWidget(m_linesCountSpinBox); |
|
73 | buttonsLayout->addWidget(m_linesCountSpinBox); | |
74 | buttonsLayout->addWidget(addRowAboveButton); |
|
74 | buttonsLayout->addWidget(addRowAboveButton); | |
75 | buttonsLayout->addWidget(addRowBelowButton); |
|
75 | buttonsLayout->addWidget(addRowBelowButton); | |
76 | buttonsLayout->addWidget(removeRowButton); |
|
76 | buttonsLayout->addWidget(removeRowButton); | |
77 | buttonsLayout->addStretch(); |
|
77 | buttonsLayout->addStretch(); | |
78 |
|
78 | |||
79 | // chart type radio buttons |
|
79 | // chart type radio buttons | |
80 | m_lineRadioButton = new QRadioButton("Line"); |
|
80 | m_lineRadioButton = new QRadioButton("Line"); | |
81 | m_splineRadioButton = new QRadioButton("Spline"); |
|
81 | m_splineRadioButton = new QRadioButton("Spline"); | |
82 | m_scatterRadioButton = new QRadioButton("Scatter"); |
|
82 | m_scatterRadioButton = new QRadioButton("Scatter"); | |
83 | m_pieRadioButton = new QRadioButton("Pie"); |
|
83 | m_pieRadioButton = new QRadioButton("Pie"); | |
84 | m_areaRadioButton = new QRadioButton("Area"); |
|
84 | m_areaRadioButton = new QRadioButton("Area"); | |
85 | m_barRadioButton = new QRadioButton("Bar"); |
|
85 | m_barRadioButton = new QRadioButton("Bar"); | |
86 |
|
86 | |||
87 | connect(m_lineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType())); |
|
87 | connect(m_lineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType())); | |
88 | connect(m_splineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType())); |
|
88 | connect(m_splineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType())); | |
89 | connect(m_scatterRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType())); |
|
89 | connect(m_scatterRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType())); | |
90 | connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType())); |
|
90 | connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType())); | |
91 | connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType())); |
|
91 | connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType())); | |
92 | connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType())); |
|
92 | connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType())); | |
93 | m_lineRadioButton->setChecked(true); |
|
93 | m_lineRadioButton->setChecked(true); | |
94 |
|
94 | |||
95 | // radio buttons layout |
|
95 | // radio buttons layout | |
96 | QVBoxLayout* radioLayout = new QVBoxLayout; |
|
96 | QVBoxLayout* radioLayout = new QVBoxLayout; | |
97 | radioLayout->addWidget(m_lineRadioButton); |
|
97 | radioLayout->addWidget(m_lineRadioButton); | |
98 | radioLayout->addWidget(m_splineRadioButton); |
|
98 | radioLayout->addWidget(m_splineRadioButton); | |
99 | radioLayout->addWidget(m_scatterRadioButton); |
|
99 | radioLayout->addWidget(m_scatterRadioButton); | |
100 | radioLayout->addWidget(m_pieRadioButton); |
|
100 | radioLayout->addWidget(m_pieRadioButton); | |
101 | radioLayout->addWidget(m_areaRadioButton); |
|
101 | radioLayout->addWidget(m_areaRadioButton); | |
102 | radioLayout->addWidget(m_barRadioButton); |
|
102 | radioLayout->addWidget(m_barRadioButton); | |
103 | radioLayout->addStretch(); |
|
103 | radioLayout->addStretch(); | |
104 |
|
104 | |||
105 | // create main layout |
|
105 | // create main layout | |
106 | QGridLayout* mainLayout = new QGridLayout; |
|
106 | QGridLayout* mainLayout = new QGridLayout; | |
107 | mainLayout->addLayout(buttonsLayout, 1, 1); |
|
107 | mainLayout->addLayout(buttonsLayout, 1, 1); | |
108 | mainLayout->addLayout(radioLayout, 2, 1); |
|
108 | mainLayout->addLayout(radioLayout, 2, 1); | |
109 | mainLayout->addWidget(m_tableView, 1, 0); |
|
109 | mainLayout->addWidget(m_tableView, 1, 0); | |
110 | mainLayout->addWidget(m_chartView, 2, 0); |
|
110 | mainLayout->addWidget(m_chartView, 2, 0); | |
111 | setLayout(mainLayout); |
|
111 | setLayout(mainLayout); | |
112 | m_lineRadioButton->setFocus(); |
|
112 | m_lineRadioButton->setFocus(); | |
113 | } |
|
113 | } | |
114 |
|
114 | |||
115 | void TableWidget::addRowAbove() |
|
115 | void TableWidget::addRowAbove() | |
116 | { |
|
116 | { | |
117 | m_model->insertRows(m_tableView->currentIndex().row(), m_linesCountSpinBox->value()); |
|
117 | m_model->insertRows(m_tableView->currentIndex().row(), m_linesCountSpinBox->value()); | |
118 |
|
118 | |||
119 | } |
|
119 | } | |
120 |
|
120 | |||
121 | void TableWidget::addRowBelow() |
|
121 | void TableWidget::addRowBelow() | |
122 | { |
|
122 | { | |
123 | m_model->insertRows(m_tableView->currentIndex().row() + 1, m_linesCountSpinBox->value()); |
|
123 | m_model->insertRows(m_tableView->currentIndex().row() + 1, m_linesCountSpinBox->value()); | |
124 |
|
124 | |||
125 | } |
|
125 | } | |
126 |
|
126 | |||
127 | void TableWidget::removeRow() |
|
127 | void TableWidget::removeRow() | |
128 | { |
|
128 | { | |
129 | m_model->removeRows(m_tableView->currentIndex().row(), qMin(m_model->rowCount() - m_tableView->currentIndex().row(), m_linesCountSpinBox->value())); |
|
129 | m_model->removeRows(m_tableView->currentIndex().row(), qMin(m_model->rowCount() - m_tableView->currentIndex().row(), m_linesCountSpinBox->value())); | |
130 | } |
|
130 | } | |
131 |
|
131 | |||
132 | void TableWidget::updateChartType() |
|
132 | void TableWidget::updateChartType() | |
133 | { |
|
133 | { | |
134 | m_chart->removeAllSeries(); |
|
134 | m_chart->removeAllSeries(); | |
135 | m_model->clearMapping(); |
|
135 | m_model->clearMapping(); | |
136 |
|
136 | |||
137 | QString seriesColorHex = "#000000"; |
|
137 | QString seriesColorHex = "#000000"; | |
138 | QPen pen; |
|
138 | QPen pen; | |
139 | pen.setWidth(2); |
|
139 | pen.setWidth(2); | |
140 |
|
140 | |||
141 | if (m_lineRadioButton->isChecked()) |
|
141 | if (m_lineRadioButton->isChecked()) | |
142 | { |
|
142 | { | |
143 | // series 1 |
|
143 | // series 1 | |
144 | m_series = new QLineSeries; |
|
144 | m_series = new QLineSeries; | |
145 | m_series->setModel(m_model); |
|
145 | m_series->setModel(m_model); | |
146 | m_series->setModelMapping(0,1, Qt::Vertical); |
|
146 | m_series->setModelMapping(0,1, Qt::Vertical); | |
147 |
m_series->setModelMapping |
|
147 | m_series->setModelMappingRange(1, 4); | |
148 | m_chart->addSeries(m_series); |
|
148 | m_chart->addSeries(m_series); | |
149 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
149 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); | |
150 | m_model->addMapping(seriesColorHex, QRect(0, 1, 2, 4)); |
|
150 | m_model->addMapping(seriesColorHex, QRect(0, 1, 2, 4)); | |
151 |
|
151 | |||
152 | // series 2 |
|
152 | // series 2 | |
153 | m_series = new QLineSeries; |
|
153 | m_series = new QLineSeries; | |
154 | m_series->setModel(m_model); |
|
154 | m_series->setModel(m_model); | |
155 | m_series->setModelMapping(2,3, Qt::Vertical); |
|
155 | m_series->setModelMapping(2,3, Qt::Vertical); | |
156 | m_chart->addSeries(m_series); |
|
156 | m_chart->addSeries(m_series); | |
157 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
157 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); | |
158 | m_model->addMapping(seriesColorHex, QRect(2, 0, 2, 1000)); |
|
158 | m_model->addMapping(seriesColorHex, QRect(2, 0, 2, 1000)); | |
159 |
|
159 | |||
160 | // series 3 |
|
160 | // series 3 | |
161 | m_series = new QLineSeries; |
|
161 | m_series = new QLineSeries; | |
162 | m_series->setModel(m_model); |
|
162 | m_series->setModel(m_model); | |
163 | m_series->setModelMapping(4,5, Qt::Vertical); |
|
163 | m_series->setModelMapping(4,5, Qt::Vertical); | |
164 |
m_series->setModelMapping |
|
164 | m_series->setModelMappingRange(2, 0); | |
165 | m_chart->addSeries(m_series); |
|
165 | m_chart->addSeries(m_series); | |
166 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
166 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); | |
167 | m_model->addMapping(seriesColorHex, QRect(4, 2, 2, 1000)); |
|
167 | m_model->addMapping(seriesColorHex, QRect(4, 2, 2, 1000)); | |
168 | } |
|
168 | } | |
169 | else if (m_splineRadioButton->isChecked()) |
|
169 | else if (m_splineRadioButton->isChecked()) | |
170 | { |
|
170 | { | |
171 | // series 1 |
|
171 | // series 1 | |
172 | m_series = new QSplineSeries; |
|
172 | m_series = new QSplineSeries; | |
173 | m_series->setModel(m_model); |
|
173 | m_series->setModel(m_model); | |
174 | m_series->setModelMapping(0,1, Qt::Vertical); |
|
174 | m_series->setModelMapping(0,1, Qt::Vertical); | |
175 |
m_series->setModelMapping |
|
175 | m_series->setModelMappingRange(1, 4); | |
176 | // series->setModelMapping(0,1, Qt::Horizontal); |
|
176 | // series->setModelMapping(0,1, Qt::Horizontal); | |
177 | m_chart->addSeries(m_series); |
|
177 | m_chart->addSeries(m_series); | |
178 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
178 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); | |
179 | m_model->addMapping(seriesColorHex, QRect(0, 1, 2, 4)); |
|
179 | m_model->addMapping(seriesColorHex, QRect(0, 1, 2, 4)); | |
180 |
|
180 | |||
181 | // series 2 |
|
181 | // series 2 | |
182 | m_series = new QSplineSeries; |
|
182 | m_series = new QSplineSeries; | |
183 | m_series->setModel(m_model); |
|
183 | m_series->setModel(m_model); | |
184 | m_series->setModelMapping(2,3, Qt::Vertical); |
|
184 | m_series->setModelMapping(2,3, Qt::Vertical); | |
185 |
m_series->setModelMapping |
|
185 | m_series->setModelMappingRange(0, 0); | |
186 | // series->setModelMapping(2,3, Qt::Horizontal); |
|
186 | // series->setModelMapping(2,3, Qt::Horizontal); | |
187 | m_chart->addSeries(m_series); |
|
187 | m_chart->addSeries(m_series); | |
188 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
188 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); | |
189 | m_model->addMapping(seriesColorHex, QRect(2, 0, 2, 1000)); |
|
189 | m_model->addMapping(seriesColorHex, QRect(2, 0, 2, 1000)); | |
190 |
|
190 | |||
191 | // series 3 |
|
191 | // series 3 | |
192 | m_series = new QSplineSeries; |
|
192 | m_series = new QSplineSeries; | |
193 | m_series->setModel(m_model); |
|
193 | m_series->setModel(m_model); | |
194 | m_series->setModelMapping(4,5, Qt::Vertical); |
|
194 | m_series->setModelMapping(4,5, Qt::Vertical); | |
195 |
m_series->setModelMapping |
|
195 | m_series->setModelMappingRange(2, 0); | |
196 | // series->setModelMapping(4,5, Qt::Horizontal); |
|
196 | // series->setModelMapping(4,5, Qt::Horizontal); | |
197 | m_chart->addSeries(m_series); |
|
197 | m_chart->addSeries(m_series); | |
198 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
198 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); | |
199 | m_model->addMapping(seriesColorHex, QRect(4, 2, 2, 1000)); |
|
199 | m_model->addMapping(seriesColorHex, QRect(4, 2, 2, 1000)); | |
200 | } |
|
200 | } | |
201 | else if (m_scatterRadioButton->isChecked()) |
|
201 | else if (m_scatterRadioButton->isChecked()) | |
202 | { |
|
202 | { | |
203 | // series 1 |
|
203 | // series 1 | |
204 | m_series = new QScatterSeries; |
|
204 | m_series = new QScatterSeries; | |
205 | m_series->setModel(m_model); |
|
205 | m_series->setModel(m_model); | |
206 | m_series->setModelMapping(0,1, Qt::Vertical); |
|
206 | m_series->setModelMapping(0,1, Qt::Vertical); | |
207 |
m_series->setModelMapping |
|
207 | m_series->setModelMappingRange(2, 0); | |
208 | // series->setModelMapping(0,1, Qt::Horizontal); |
|
208 | // series->setModelMapping(0,1, Qt::Horizontal); | |
209 | m_chart->addSeries(m_series); |
|
209 | m_chart->addSeries(m_series); | |
210 |
|
210 | |||
211 | seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); |
|
211 | seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); | |
212 | m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 1000)); |
|
212 | m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 1000)); | |
213 |
|
213 | |||
214 | // series 2 |
|
214 | // series 2 | |
215 | m_series = new QScatterSeries; |
|
215 | m_series = new QScatterSeries; | |
216 | m_series->setModel(m_model); |
|
216 | m_series->setModel(m_model); | |
217 | m_series->setModelMapping(2,3, Qt::Vertical); |
|
217 | m_series->setModelMapping(2,3, Qt::Vertical); | |
218 |
m_series->setModelMapping |
|
218 | m_series->setModelMappingRange(1, 6); | |
219 | // series->setModelMapping(2,3, Qt::Horizontal); |
|
219 | // series->setModelMapping(2,3, Qt::Horizontal); | |
220 | m_chart->addSeries(m_series); |
|
220 | m_chart->addSeries(m_series); | |
221 |
|
221 | |||
222 | seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); |
|
222 | seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); | |
223 | m_model->addMapping(seriesColorHex, QRect(2, 1, 2, 6)); |
|
223 | m_model->addMapping(seriesColorHex, QRect(2, 1, 2, 6)); | |
224 |
|
224 | |||
225 | // series 3 |
|
225 | // series 3 | |
226 | m_series = new QScatterSeries; |
|
226 | m_series = new QScatterSeries; | |
227 | m_series->setModel(m_model); |
|
227 | m_series->setModel(m_model); | |
228 | m_series->setModelMapping(4,5, Qt::Vertical); |
|
228 | m_series->setModelMapping(4,5, Qt::Vertical); | |
229 | // series->setModelMapping(4,5, Qt::Horizontal); |
|
229 | // series->setModelMapping(4,5, Qt::Horizontal); | |
230 | m_chart->addSeries(m_series); |
|
230 | m_chart->addSeries(m_series); | |
231 | seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); |
|
231 | seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); | |
232 | m_model->addMapping(seriesColorHex, QRect(4, 0, 2, 1000)); |
|
232 | m_model->addMapping(seriesColorHex, QRect(4, 0, 2, 1000)); | |
233 | } |
|
233 | } | |
234 | else if (m_pieRadioButton->isChecked()) |
|
234 | else if (m_pieRadioButton->isChecked()) | |
235 | { |
|
235 | { | |
236 | // pie 1 |
|
236 | // pie 1 | |
237 | QPieSeries* pieSeries = new QPieSeries; |
|
237 | QPieSeries* pieSeries = new QPieSeries; | |
238 | pieSeries->setModel(m_model); |
|
238 | pieSeries->setModel(m_model); | |
239 | pieSeries->setModelMapping(0,0, Qt::Vertical); |
|
239 | pieSeries->setModelMapping(0,0, Qt::Vertical); | |
240 | pieSeries->setLabelsVisible(true); |
|
240 | pieSeries->setLabelsVisible(true); | |
241 | pieSeries->setPieSize(0.4); |
|
241 | pieSeries->setPieSize(0.4); | |
242 | pieSeries->setPiePosition(0.2, 0.35); |
|
242 | pieSeries->setPiePosition(0.2, 0.35); | |
243 |
|
243 | |||
244 | m_chart->addSeries(pieSeries); |
|
244 | m_chart->addSeries(pieSeries); | |
245 | seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); |
|
245 | seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); | |
246 | m_model->addMapping(seriesColorHex, QRect(0, 0, 1, 1000)); |
|
246 | m_model->addMapping(seriesColorHex, QRect(0, 0, 1, 1000)); | |
247 |
|
247 | |||
248 | // pie 2 |
|
248 | // pie 2 | |
249 | pieSeries = new QPieSeries; |
|
249 | pieSeries = new QPieSeries; | |
250 | pieSeries->setModel(m_model); |
|
250 | pieSeries->setModel(m_model); | |
251 | pieSeries->setModelMapping(1,1, Qt::Vertical); |
|
251 | pieSeries->setModelMapping(1,1, Qt::Vertical); | |
252 | pieSeries->setLabelsVisible(true); |
|
252 | pieSeries->setLabelsVisible(true); | |
253 | pieSeries->setPieSize(0.4); |
|
253 | pieSeries->setPieSize(0.4); | |
254 | pieSeries->setPiePosition(0.8, 0.35); |
|
254 | pieSeries->setPiePosition(0.8, 0.35); | |
255 | m_chart->addSeries(pieSeries); |
|
255 | m_chart->addSeries(pieSeries); | |
256 | seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); |
|
256 | seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); | |
257 | m_model->addMapping(seriesColorHex, QRect(1, 0, 1, 1000)); |
|
257 | m_model->addMapping(seriesColorHex, QRect(1, 0, 1, 1000)); | |
258 |
|
258 | |||
259 | // pie 3 |
|
259 | // pie 3 | |
260 | pieSeries = new QPieSeries; |
|
260 | pieSeries = new QPieSeries; | |
261 | pieSeries->setModel(m_model); |
|
261 | pieSeries->setModel(m_model); | |
262 | pieSeries->setModelMapping(2,2, Qt::Vertical); |
|
262 | pieSeries->setModelMapping(2,2, Qt::Vertical); | |
263 | pieSeries->setLabelsVisible(true); |
|
263 | pieSeries->setLabelsVisible(true); | |
264 | pieSeries->setPieSize(0.4); |
|
264 | pieSeries->setPieSize(0.4); | |
265 | pieSeries->setPiePosition(0.5, 0.65); |
|
265 | pieSeries->setPiePosition(0.5, 0.65); | |
266 | m_chart->addSeries(pieSeries); |
|
266 | m_chart->addSeries(pieSeries); | |
267 | seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); |
|
267 | seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); | |
268 | m_model->addMapping(seriesColorHex, QRect(2, 0, 1, 1000)); |
|
268 | m_model->addMapping(seriesColorHex, QRect(2, 0, 1, 1000)); | |
269 | } |
|
269 | } | |
270 | else if (m_areaRadioButton->isChecked()) |
|
270 | else if (m_areaRadioButton->isChecked()) | |
271 | { |
|
271 | { | |
272 | QLineSeries* upperLineSeries = new QLineSeries; |
|
272 | QLineSeries* upperLineSeries = new QLineSeries; | |
273 | upperLineSeries->setModel(m_model); |
|
273 | upperLineSeries->setModel(m_model); | |
274 | upperLineSeries->setModelMapping(0, 1, Qt::Vertical); |
|
274 | upperLineSeries->setModelMapping(0, 1, Qt::Vertical); | |
275 |
upperLineSeries->setModelMapping |
|
275 | upperLineSeries->setModelMappingRange(1, 5); | |
276 | QLineSeries* lowerLineSeries = new QLineSeries; |
|
276 | QLineSeries* lowerLineSeries = new QLineSeries; | |
277 | lowerLineSeries->setModel(m_model); |
|
277 | lowerLineSeries->setModel(m_model); | |
278 | lowerLineSeries->setModelMapping(2, 3, Qt::Vertical); |
|
278 | lowerLineSeries->setModelMapping(2, 3, Qt::Vertical); | |
279 | QAreaSeries* areaSeries = new QAreaSeries(upperLineSeries, lowerLineSeries); |
|
279 | QAreaSeries* areaSeries = new QAreaSeries(upperLineSeries, lowerLineSeries); | |
280 | m_chart->addSeries(areaSeries); |
|
280 | m_chart->addSeries(areaSeries); | |
281 | seriesColorHex = "#" + QString::number(areaSeries->brush().color().rgb(), 16).right(6).toUpper(); |
|
281 | seriesColorHex = "#" + QString::number(areaSeries->brush().color().rgb(), 16).right(6).toUpper(); | |
282 | m_model->addMapping(seriesColorHex, QRect(0, 1, 2, 5)); |
|
282 | m_model->addMapping(seriesColorHex, QRect(0, 1, 2, 5)); | |
283 | m_model->addMapping(seriesColorHex, QRect(2, 0, 2, 1000)); |
|
283 | m_model->addMapping(seriesColorHex, QRect(2, 0, 2, 1000)); | |
284 | } |
|
284 | } | |
285 | else if (m_barRadioButton->isChecked()) |
|
285 | else if (m_barRadioButton->isChecked()) | |
286 | { |
|
286 | { | |
287 | QBarSeries* barSeries = new QBarSeries(QStringList()); |
|
287 | QBarSeries* barSeries = new QBarSeries(QStringList()); | |
288 | barSeries->setModel(m_model); |
|
288 | barSeries->setModel(m_model); | |
289 | barSeries->setModelMapping(5, 2, 4, Qt::Vertical); |
|
289 | barSeries->setModelMapping(5, 2, 4, Qt::Vertical); | |
290 | barSeries->setToolTipEnabled(true); |
|
290 | barSeries->setToolTipEnabled(true); | |
291 | m_chart->addSeries(barSeries); |
|
291 | m_chart->addSeries(barSeries); | |
292 | for (int i = 0; i < barSeries->barsetCount(); i++) { |
|
292 | for (int i = 0; i < barSeries->barsetCount(); i++) { | |
293 | seriesColorHex = "#" + QString::number(barSeries->barsetAt(i)->brush().color().rgb(), 16).right(6).toUpper(); |
|
293 | seriesColorHex = "#" + QString::number(barSeries->barsetAt(i)->brush().color().rgb(), 16).right(6).toUpper(); | |
294 | m_model->addMapping(seriesColorHex, QRect(2 + i, 0, 1, 1000)); |
|
294 | m_model->addMapping(seriesColorHex, QRect(2 + i, 0, 1, 1000)); | |
295 | } |
|
295 | } | |
296 | } |
|
296 | } | |
297 |
|
297 | |||
298 |
|
298 | |||
299 | m_chart->axisX()->setRange(0, 500); |
|
299 | m_chart->axisX()->setRange(0, 500); | |
300 | m_chart->axisY()->setRange(0, 120); |
|
300 | m_chart->axisY()->setRange(0, 120); | |
301 |
|
301 | |||
302 | // repaint table view colors |
|
302 | // repaint table view colors | |
303 | m_tableView->repaint(); |
|
303 | m_tableView->repaint(); | |
304 | m_tableView->setFocus(); |
|
304 | m_tableView->setFocus(); | |
305 | } |
|
305 | } | |
306 |
|
306 | |||
307 | TableWidget::~TableWidget() |
|
307 | TableWidget::~TableWidget() | |
308 | { |
|
308 | { | |
309 |
|
309 | |||
310 | } |
|
310 | } |
@@ -1,179 +1,179 | |||||
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 "qsplineseries.h" |
|
21 | #include "qsplineseries.h" | |
22 |
|
22 | |||
23 | /*! |
|
23 | /*! | |
24 | \class QSplineSeries |
|
24 | \class QSplineSeries | |
25 | \brief Series type used to store data needed to draw a spline. |
|
25 | \brief Series type used to store data needed to draw a spline. | |
26 |
|
26 | |||
27 | QSplineSeries stores the data points along with the segment control points needed by QPainterPath to draw spline |
|
27 | QSplineSeries stores the data points along with the segment control points needed by QPainterPath to draw spline | |
28 | Control points are automatically calculated when data changes. The algorithm computes the points so that the normal spline can be drawn. |
|
28 | Control points are automatically calculated when data changes. The algorithm computes the points so that the normal spline can be drawn. | |
29 | */ |
|
29 | */ | |
30 |
|
30 | |||
31 | /*! |
|
31 | /*! | |
32 | \fn QSeriesType QSplineSeries::type() const |
|
32 | \fn QSeriesType QSplineSeries::type() const | |
33 | Returns the type of the series |
|
33 | Returns the type of the series | |
34 | */ |
|
34 | */ | |
35 |
|
35 | |||
36 | /*! |
|
36 | /*! | |
37 | \fn QSeriesType QSplineSeries::controlPoint(int index) const |
|
37 | \fn QSeriesType QSplineSeries::controlPoint(int index) const | |
38 | Returns the control point specified by \a index |
|
38 | Returns the control point specified by \a index | |
39 | */ |
|
39 | */ | |
40 |
|
40 | |||
41 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
41 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
42 |
|
42 | |||
43 | /*! |
|
43 | /*! | |
44 | Constructs empty series object which is a child of \a parent. |
|
44 | Constructs empty series object which is a child of \a parent. | |
45 | When series object is added to QChartView or QChart instance then the ownerships is transfered. |
|
45 | When series object is added to QChartView or QChart instance then the ownerships is transfered. | |
46 | */ |
|
46 | */ | |
47 |
|
47 | |||
48 | QSplineSeries::QSplineSeries(QObject *parent) : |
|
48 | QSplineSeries::QSplineSeries(QObject *parent) : | |
49 | QLineSeries(parent) |
|
49 | QLineSeries(parent) | |
50 | { |
|
50 | { | |
51 | connect(this,SIGNAL(pointAdded(int)), this, SLOT(updateControlPoints())); |
|
51 | connect(this,SIGNAL(pointAdded(int)), this, SLOT(updateControlPoints())); | |
52 | connect(this,SIGNAL(pointRemoved(int)), this, SLOT(updateControlPoints())); |
|
52 | connect(this,SIGNAL(pointRemoved(int)), this, SLOT(updateControlPoints())); | |
53 | connect(this,SIGNAL(pointReplaced(int)), this, SLOT(updateControlPoints())); |
|
53 | connect(this,SIGNAL(pointReplaced(int)), this, SLOT(updateControlPoints())); | |
54 | } |
|
54 | } | |
55 |
|
55 | |||
56 | /*! |
|
56 | /*! | |
57 | \internal |
|
57 | \internal | |
58 | Calculates control points which are needed by QPainterPath.cubicTo function to draw the cubic Bezier cureve between two points. |
|
58 | Calculates control points which are needed by QPainterPath.cubicTo function to draw the cubic Bezier cureve between two points. | |
59 | */ |
|
59 | */ | |
60 | void QSplineSeries::calculateControlPoints() |
|
60 | void QSplineSeries::calculateControlPoints() | |
61 | { |
|
61 | { | |
62 |
|
62 | |||
63 | // Based on http://www.codeproject.com/Articles/31859/Draw-a-Smooth-Curve-through-a-Set-of-2D-Points-wit |
|
63 | // Based on http://www.codeproject.com/Articles/31859/Draw-a-Smooth-Curve-through-a-Set-of-2D-Points-wit | |
64 | // CPOL License |
|
64 | // CPOL License | |
65 |
|
65 | |||
66 | int n = count() - 1; |
|
66 | int n = count() - 1; | |
67 | if (n == 1) |
|
67 | if (n == 1) | |
68 | { // Special case: Bezier curve should be a straight line. |
|
68 | { // Special case: Bezier curve should be a straight line. | |
69 | // firstControlPoints = new Point[1]; |
|
69 | // firstControlPoints = new Point[1]; | |
70 | // 3P1 = 2P0 + P3 |
|
70 | // 3P1 = 2P0 + P3 | |
71 | m_controlPoints.append(QPointF((2 * x(0) + x(1)) / 3, (2 * y(0) + y(1)) / 3)); |
|
71 | m_controlPoints.append(QPointF((2 * x(0) + x(1)) / 3, (2 * y(0) + y(1)) / 3)); | |
72 |
|
72 | |||
73 | // P2 = 2P1 P0 |
|
73 | // P2 = 2P1 P0 | |
74 | m_controlPoints.append(QPointF(2 * m_controlPoints[0].x() - x(0), 2 * m_controlPoints[0].y() - y(0))); |
|
74 | m_controlPoints.append(QPointF(2 * m_controlPoints[0].x() - x(0), 2 * m_controlPoints[0].y() - y(0))); | |
75 | return; |
|
75 | return; | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 | // Calculate first Bezier control points |
|
78 | // Calculate first Bezier control points | |
79 | // Right hand side vector |
|
79 | // Right hand side vector | |
80 | // Set of equations for P0 to Pn points. |
|
80 | // Set of equations for P0 to Pn points. | |
81 | // |
|
81 | // | |
82 | // | 2 1 0 0 ... 0 0 0 ... 0 0 0 | | P1_1 | | P0 + 2 * P1 | |
|
82 | // | 2 1 0 0 ... 0 0 0 ... 0 0 0 | | P1_1 | | P0 + 2 * P1 | | |
83 | // | 1 4 1 0 ... 0 0 0 ... 0 0 0 | | P1_2 | | 4 * P1 + 2 * P2 | |
|
83 | // | 1 4 1 0 ... 0 0 0 ... 0 0 0 | | P1_2 | | 4 * P1 + 2 * P2 | | |
84 | // | 0 1 4 1 ... 0 0 0 ... 0 0 0 | | P1_3 | | 4 * P2 + 2 * P3 | |
|
84 | // | 0 1 4 1 ... 0 0 0 ... 0 0 0 | | P1_3 | | 4 * P2 + 2 * P3 | | |
85 | // | . . . . . . . . . . . . | | ... | | ... | |
|
85 | // | . . . . . . . . . . . . | | ... | | ... | | |
86 | // | 0 0 0 0 ... 1 4 1 ... 0 0 0 | * | P1_i | = | 4 * P(i-1) + 2 * Pi | |
|
86 | // | 0 0 0 0 ... 1 4 1 ... 0 0 0 | * | P1_i | = | 4 * P(i-1) + 2 * Pi | | |
87 | // | . . . . . . . . . . . . | | ... | | ... | |
|
87 | // | . . . . . . . . . . . . | | ... | | ... | | |
88 | // | 0 0 0 0 0 0 0 0 ... 1 4 1 | | P1_(n-1)| | 4 * P(n-2) + 2 * P(n-1) | |
|
88 | // | 0 0 0 0 0 0 0 0 ... 1 4 1 | | P1_(n-1)| | 4 * P(n-2) + 2 * P(n-1) | | |
89 | // | 0 0 0 0 0 0 0 0 ... 0 2 7 | | P1_n | | 8 * P(n-1) + Pn | |
|
89 | // | 0 0 0 0 0 0 0 0 ... 0 2 7 | | P1_n | | 8 * P(n-1) + Pn | | |
90 | // |
|
90 | // | |
91 | QList<qreal> rhs; |
|
91 | QList<qreal> rhs; | |
92 | rhs.append(x(0) + 2 * x(1)); |
|
92 | rhs.append(x(0) + 2 * x(1)); | |
93 |
|
93 | |||
94 | // Set right hand side X values |
|
94 | // Set right hand side X values | |
95 | for (int i = 1; i < n - 1; ++i) |
|
95 | for (int i = 1; i < n - 1; ++i) | |
96 | rhs.append(4 * x(i) + 2 * x(i + 1)); |
|
96 | rhs.append(4 * x(i) + 2 * x(i + 1)); | |
97 |
|
97 | |||
98 | rhs.append((8 * x(n - 1) + x(n)) / 2.0); |
|
98 | rhs.append((8 * x(n - 1) + x(n)) / 2.0); | |
99 | // Get first control points X-values |
|
99 | // Get first control points X-values | |
100 | QList<qreal> xControl = getFirstControlPoints(rhs); |
|
100 | QList<qreal> xControl = getFirstControlPoints(rhs); | |
101 | rhs[0] = y(0) + 2 * y(1); |
|
101 | rhs[0] = y(0) + 2 * y(1); | |
102 |
|
102 | |||
103 | // Set right hand side Y values |
|
103 | // Set right hand side Y values | |
104 | for (int i = 1; i < n - 1; ++i) |
|
104 | for (int i = 1; i < n - 1; ++i) | |
105 | rhs[i] = 4 * y(i) + 2 * y(i + 1); |
|
105 | rhs[i] = 4 * y(i) + 2 * y(i + 1); | |
106 |
|
106 | |||
107 | rhs[n - 1] = (8 * y(n - 1) + y(n)) / 2.0; |
|
107 | rhs[n - 1] = (8 * y(n - 1) + y(n)) / 2.0; | |
108 | // Get first control points Y-values |
|
108 | // Get first control points Y-values | |
109 | QList<qreal> yControl = getFirstControlPoints(rhs); |
|
109 | QList<qreal> yControl = getFirstControlPoints(rhs); | |
110 |
|
110 | |||
111 | // Fill output arrays. |
|
111 | // Fill output arrays. | |
112 | for (int i = 0; i < n; ++i) { |
|
112 | for (int i = 0; i < n; ++i) { | |
113 | // First control point |
|
113 | // First control point | |
114 | m_controlPoints.append(QPointF(xControl[i], yControl[i])); |
|
114 | m_controlPoints.append(QPointF(xControl[i], yControl[i])); | |
115 | // Second control point |
|
115 | // Second control point | |
116 | if (i < n - 1) |
|
116 | if (i < n - 1) | |
117 | m_controlPoints.append(QPointF(2 * x(i + 1) - xControl[i + 1], 2 * y(i + 1) - yControl[i + 1])); |
|
117 | m_controlPoints.append(QPointF(2 * x(i + 1) - xControl[i + 1], 2 * y(i + 1) - yControl[i + 1])); | |
118 | else |
|
118 | else | |
119 | m_controlPoints.append(QPointF((x(n) + xControl[n - 1]) / 2, (y(n) + yControl[n - 1]) / 2)); |
|
119 | m_controlPoints.append(QPointF((x(n) + xControl[n - 1]) / 2, (y(n) + yControl[n - 1]) / 2)); | |
120 | } |
|
120 | } | |
121 | } |
|
121 | } | |
122 |
|
122 | |||
123 | /*! |
|
123 | /*! | |
124 | \internal |
|
124 | \internal | |
125 | */ |
|
125 | */ | |
126 | QList<qreal> QSplineSeries::getFirstControlPoints(QList<qreal> rhs) |
|
126 | QList<qreal> QSplineSeries::getFirstControlPoints(QList<qreal> rhs) | |
127 | { |
|
127 | { | |
128 | QList<qreal> x; // Solution vector. |
|
128 | QList<qreal> x; // Solution vector. | |
129 | QList<qreal> tmp; // Temp workspace. |
|
129 | QList<qreal> tmp; // Temp workspace. | |
130 |
|
130 | |||
131 | qreal b = 2.0; |
|
131 | qreal b = 2.0; | |
132 | x.append(rhs[0] / b); |
|
132 | x.append(rhs[0] / b); | |
133 | tmp.append(0); |
|
133 | tmp.append(0); | |
134 | for (int i = 1; i < rhs.size(); i++) { |
|
134 | for (int i = 1; i < rhs.size(); i++) { | |
135 | // Decomposition and forward substitution. |
|
135 | // Decomposition and forward substitution. | |
136 | tmp.append(1 / b); |
|
136 | tmp.append(1 / b); | |
137 | b = (i < rhs.size() - 1 ? 4.0 : 3.5) - tmp[i]; |
|
137 | b = (i < rhs.size() - 1 ? 4.0 : 3.5) - tmp[i]; | |
138 | x.append((rhs[i] - x[i - 1]) / b); |
|
138 | x.append((rhs[i] - x[i - 1]) / b); | |
139 | } |
|
139 | } | |
140 | for (int i = 1; i < rhs.size(); i++) |
|
140 | for (int i = 1; i < rhs.size(); i++) | |
141 | x[rhs.size() - i - 1] -= tmp[rhs.size() - i] * x[rhs.size() - i]; // Backsubstitution. |
|
141 | x[rhs.size() - i - 1] -= tmp[rhs.size() - i] * x[rhs.size() - i]; // Backsubstitution. | |
142 |
|
142 | |||
143 | return x; |
|
143 | return x; | |
144 | } |
|
144 | } | |
145 |
|
145 | |||
146 | /*! |
|
146 | /*! | |
147 | \internal |
|
147 | \internal | |
148 | Updates the control points, besed on currently avaiable knots. |
|
148 | Updates the control points, besed on currently avaiable knots. | |
149 | */ |
|
149 | */ | |
150 | void QSplineSeries::updateControlPoints() |
|
150 | void QSplineSeries::updateControlPoints() | |
151 | { |
|
151 | { | |
152 | if (count() > 1) { |
|
152 | if (count() > 1) { | |
153 | m_controlPoints.clear(); |
|
153 | m_controlPoints.clear(); | |
154 | calculateControlPoints(); |
|
154 | calculateControlPoints(); | |
155 | } |
|
155 | } | |
156 | } |
|
156 | } | |
157 |
|
157 | |||
158 | bool QSplineSeries::setModel(QAbstractItemModel* model) |
|
158 | bool QSplineSeries::setModel(QAbstractItemModel* model) | |
159 | { |
|
159 | { | |
160 | QXYSeries::setModel(model); |
|
160 | QXYSeries::setModel(model); | |
161 | // calculateControlPoints(); |
|
161 | // calculateControlPoints(); | |
162 | return true; |
|
162 | return true; | |
163 | } |
|
163 | } | |
164 |
|
164 | |||
165 | void QSplineSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation) |
|
165 | void QSplineSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation) | |
166 | { |
|
166 | { | |
167 | QLineSeries::setModelMapping(modelX, modelY, orientation); |
|
167 | QLineSeries::setModelMapping(modelX, modelY, orientation); | |
168 | // calculateControlPoints(); |
|
168 | // calculateControlPoints(); | |
169 | } |
|
169 | } | |
170 |
|
170 | |||
171 |
void QSplineSeries::setModelMapping |
|
171 | void QSplineSeries::setModelMappingRange(int first, int count) | |
172 | { |
|
172 | { | |
173 |
QLineSeries::setModelMapping |
|
173 | QLineSeries::setModelMappingRange(first, count); | |
174 | calculateControlPoints(); |
|
174 | calculateControlPoints(); | |
175 | } |
|
175 | } | |
176 |
|
176 | |||
177 | #include "moc_qsplineseries.cpp" |
|
177 | #include "moc_qsplineseries.cpp" | |
178 |
|
178 | |||
179 | QTCOMMERCIALCHART_END_NAMESPACE |
|
179 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,60 +1,60 | |||||
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 | #ifndef QSPLINESERIES_H |
|
21 | #ifndef QSPLINESERIES_H | |
22 | #define QSPLINESERIES_H |
|
22 | #define QSPLINESERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qlineseries.h> |
|
25 | #include <qlineseries.h> | |
26 | #include <QList> |
|
26 | #include <QList> | |
27 | #include <QPointF> |
|
27 | #include <QPointF> | |
28 | #include <QtGlobal> |
|
28 | #include <QtGlobal> | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | class QTCOMMERCIALCHART_EXPORT QSplineSeries : public QLineSeries |
|
32 | class QTCOMMERCIALCHART_EXPORT QSplineSeries : public QLineSeries | |
33 | { |
|
33 | { | |
34 | Q_OBJECT |
|
34 | Q_OBJECT | |
35 | public: |
|
35 | public: | |
36 |
|
36 | |||
37 | QSplineSeries(QObject *parent = 0); |
|
37 | QSplineSeries(QObject *parent = 0); | |
38 | QSeriesType type() const {return QSeries::SeriesTypeSpline;} |
|
38 | QSeriesType type() const {return QSeries::SeriesTypeSpline;} | |
39 |
|
39 | |||
40 | QPointF controlPoint(int index) const {return m_controlPoints[index];} |
|
40 | QPointF controlPoint(int index) const {return m_controlPoints[index];} | |
41 | bool setModel(QAbstractItemModel *model); |
|
41 | bool setModel(QAbstractItemModel *model); | |
42 |
|
42 | |||
43 | void setModelMapping(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical); |
|
43 | void setModelMapping(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical); | |
44 |
void setModelMapping |
|
44 | void setModelMappingRange(int first, int count); | |
45 |
|
45 | |||
46 | private: |
|
46 | private: | |
47 | void calculateControlPoints(); |
|
47 | void calculateControlPoints(); | |
48 | QList<qreal> getFirstControlPoints(QList<qreal> rhs); |
|
48 | QList<qreal> getFirstControlPoints(QList<qreal> rhs); | |
49 |
|
49 | |||
50 | private Q_SLOTS: |
|
50 | private Q_SLOTS: | |
51 | void updateControlPoints(); |
|
51 | void updateControlPoints(); | |
52 |
|
52 | |||
53 | private: |
|
53 | private: | |
54 | QList<QPointF> m_controlPoints; |
|
54 | QList<QPointF> m_controlPoints; | |
55 |
|
55 | |||
56 | }; |
|
56 | }; | |
57 |
|
57 | |||
58 | QTCOMMERCIALCHART_END_NAMESPACE |
|
58 | QTCOMMERCIALCHART_END_NAMESPACE | |
59 |
|
59 | |||
60 | #endif // QSPLINESERIES_H |
|
60 | #endif // QSPLINESERIES_H |
@@ -1,512 +1,512 | |||||
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 "qxyseries.h" |
|
21 | #include "qxyseries.h" | |
22 | #include <QAbstractItemModel> |
|
22 | #include <QAbstractItemModel> | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | /*! |
|
26 | /*! | |
27 | \class QXYSeries |
|
27 | \class QXYSeries | |
28 | \brief The QXYSeries class is a base class for line, spline and scatter series. |
|
28 | \brief The QXYSeries class is a base class for line, spline and scatter series. | |
29 | */ |
|
29 | */ | |
30 |
|
30 | |||
31 | /*! |
|
31 | /*! | |
32 | \fn QPen QXYSeries::pen() const |
|
32 | \fn QPen QXYSeries::pen() const | |
33 | \brief Returns pen used to draw points for series. |
|
33 | \brief Returns pen used to draw points for series. | |
34 | \sa setPen() |
|
34 | \sa setPen() | |
35 | */ |
|
35 | */ | |
36 |
|
36 | |||
37 | /*! |
|
37 | /*! | |
38 | \fn QBrush QXYSeries::brush() const |
|
38 | \fn QBrush QXYSeries::brush() const | |
39 | \brief Returns brush used to draw points for series. |
|
39 | \brief Returns brush used to draw points for series. | |
40 | \sa setBrush() |
|
40 | \sa setBrush() | |
41 | */ |
|
41 | */ | |
42 |
|
42 | |||
43 | /*! |
|
43 | /*! | |
44 | \fn void QXYSeries::clicked(const QPointF& point) |
|
44 | \fn void QXYSeries::clicked(const QPointF& point) | |
45 | \brief Signal is emitted when user clicks the \a point on chart. |
|
45 | \brief Signal is emitted when user clicks the \a point on chart. | |
46 | */ |
|
46 | */ | |
47 |
|
47 | |||
48 | /*! |
|
48 | /*! | |
49 | \fn void QXYSeries::pointReplaced(int index) |
|
49 | \fn void QXYSeries::pointReplaced(int index) | |
50 | \brief \internal \a index |
|
50 | \brief \internal \a index | |
51 | */ |
|
51 | */ | |
52 |
|
52 | |||
53 | /*! |
|
53 | /*! | |
54 | \fn void QXYSeries::pointAdded(int index) |
|
54 | \fn void QXYSeries::pointAdded(int index) | |
55 | \brief \internal \a index |
|
55 | \brief \internal \a index | |
56 | */ |
|
56 | */ | |
57 |
|
57 | |||
58 | /*! |
|
58 | /*! | |
59 | \fn void QXYSeries::pointRemoved(int index) |
|
59 | \fn void QXYSeries::pointRemoved(int index) | |
60 | \brief \internal \a index |
|
60 | \brief \internal \a index | |
61 | */ |
|
61 | */ | |
62 |
|
62 | |||
63 | /*! |
|
63 | /*! | |
64 | \fn void QXYSeries::updated() |
|
64 | \fn void QXYSeries::updated() | |
65 | \brief \internal |
|
65 | \brief \internal | |
66 | */ |
|
66 | */ | |
67 |
|
67 | |||
68 | /*! |
|
68 | /*! | |
69 | Constructs empty series object which is a child of \a parent. |
|
69 | Constructs empty series object which is a child of \a parent. | |
70 | When series object is added to QChartView or QChart instance ownerships is transfered. |
|
70 | When series object is added to QChartView or QChart instance ownerships is transfered. | |
71 | */ |
|
71 | */ | |
72 | QXYSeries::QXYSeries(QObject *parent):QSeries(parent) |
|
72 | QXYSeries::QXYSeries(QObject *parent):QSeries(parent) | |
73 | { |
|
73 | { | |
74 | m_mapX = -1; |
|
74 | m_mapX = -1; | |
75 | m_mapY = -1; |
|
75 | m_mapY = -1; | |
76 | m_mapFirst = 0; |
|
76 | m_mapFirst = 0; | |
77 | m_mapCount = 0; |
|
77 | m_mapCount = 0; | |
78 | m_mapLimited = false; |
|
78 | m_mapLimited = false; | |
79 | m_mapOrientation = Qt::Vertical; |
|
79 | m_mapOrientation = Qt::Vertical; | |
80 | // m_mapYOrientation = Qt::Vertical; |
|
80 | // m_mapYOrientation = Qt::Vertical; | |
81 | } |
|
81 | } | |
82 | /*! |
|
82 | /*! | |
83 | Destroys the object. Series added to QChartView or QChart instances are owned by those, |
|
83 | Destroys the object. Series added to QChartView or QChart instances are owned by those, | |
84 | and are deleted when mentioned object are destroyed. |
|
84 | and are deleted when mentioned object are destroyed. | |
85 | */ |
|
85 | */ | |
86 | QXYSeries::~QXYSeries() |
|
86 | QXYSeries::~QXYSeries() | |
87 | { |
|
87 | { | |
88 | } |
|
88 | } | |
89 |
|
89 | |||
90 | /*! |
|
90 | /*! | |
91 | Adds data point \a x \a y to the series. Points are connected with lines on the chart. |
|
91 | Adds data point \a x \a y to the series. Points are connected with lines on the chart. | |
92 | */ |
|
92 | */ | |
93 | void QXYSeries::append(qreal x,qreal y) |
|
93 | void QXYSeries::append(qreal x,qreal y) | |
94 | { |
|
94 | { | |
95 | Q_ASSERT(m_x.size() == m_y.size()); |
|
95 | Q_ASSERT(m_x.size() == m_y.size()); | |
96 | m_x<<x; |
|
96 | m_x<<x; | |
97 | m_y<<y; |
|
97 | m_y<<y; | |
98 | emit pointAdded(m_x.size()-1); |
|
98 | emit pointAdded(m_x.size()-1); | |
99 | } |
|
99 | } | |
100 |
|
100 | |||
101 | /*! |
|
101 | /*! | |
102 | This is an overloaded function. |
|
102 | This is an overloaded function. | |
103 | Adds data \a point to the series. Points are connected with lines on the chart. |
|
103 | Adds data \a point to the series. Points are connected with lines on the chart. | |
104 | */ |
|
104 | */ | |
105 | void QXYSeries::append(const QPointF &point) |
|
105 | void QXYSeries::append(const QPointF &point) | |
106 | { |
|
106 | { | |
107 | append(point.x(),point.y()); |
|
107 | append(point.x(),point.y()); | |
108 | } |
|
108 | } | |
109 |
|
109 | |||
110 | /*! |
|
110 | /*! | |
111 | This is an overloaded function. |
|
111 | This is an overloaded function. | |
112 | Adds list of data \a points to the series. Points are connected with lines on the chart. |
|
112 | Adds list of data \a points to the series. Points are connected with lines on the chart. | |
113 | */ |
|
113 | */ | |
114 | void QXYSeries::append(const QList<QPointF> points) |
|
114 | void QXYSeries::append(const QList<QPointF> points) | |
115 | { |
|
115 | { | |
116 | foreach(const QPointF& point , points) { |
|
116 | foreach(const QPointF& point , points) { | |
117 | append(point.x(),point.y()); |
|
117 | append(point.x(),point.y()); | |
118 | } |
|
118 | } | |
119 | } |
|
119 | } | |
120 |
|
120 | |||
121 | /*! |
|
121 | /*! | |
122 | Modifies \a y value for given \a x a value. |
|
122 | Modifies \a y value for given \a x a value. | |
123 | */ |
|
123 | */ | |
124 | void QXYSeries::replace(qreal x,qreal y) |
|
124 | void QXYSeries::replace(qreal x,qreal y) | |
125 | { |
|
125 | { | |
126 | int index = m_x.indexOf(x); |
|
126 | int index = m_x.indexOf(x); | |
127 | m_x[index] = x; |
|
127 | m_x[index] = x; | |
128 | m_y[index] = y; |
|
128 | m_y[index] = y; | |
129 | emit pointReplaced(index); |
|
129 | emit pointReplaced(index); | |
130 | } |
|
130 | } | |
131 |
|
131 | |||
132 | /*! |
|
132 | /*! | |
133 | This is an overloaded function. |
|
133 | This is an overloaded function. | |
134 | Replaces current y value of for given \a point x value with \a point y value. |
|
134 | Replaces current y value of for given \a point x value with \a point y value. | |
135 | */ |
|
135 | */ | |
136 | void QXYSeries::replace(const QPointF &point) |
|
136 | void QXYSeries::replace(const QPointF &point) | |
137 | { |
|
137 | { | |
138 | replace(point.x(),point.y()); |
|
138 | replace(point.x(),point.y()); | |
139 | } |
|
139 | } | |
140 |
|
140 | |||
141 | /*! |
|
141 | /*! | |
142 | Removes first \a x value and related y value. |
|
142 | Removes first \a x value and related y value. | |
143 | */ |
|
143 | */ | |
144 | void QXYSeries::remove(qreal x) |
|
144 | void QXYSeries::remove(qreal x) | |
145 | { |
|
145 | { | |
146 | int index = m_x.indexOf(x); |
|
146 | int index = m_x.indexOf(x); | |
147 |
|
147 | |||
148 | if (index == -1) return; |
|
148 | if (index == -1) return; | |
149 |
|
149 | |||
150 | m_x.remove(index); |
|
150 | m_x.remove(index); | |
151 | m_y.remove(index); |
|
151 | m_y.remove(index); | |
152 |
|
152 | |||
153 | emit pointRemoved(index); |
|
153 | emit pointRemoved(index); | |
154 | } |
|
154 | } | |
155 |
|
155 | |||
156 | /*! |
|
156 | /*! | |
157 | Removes current \a x and \a y value. |
|
157 | Removes current \a x and \a y value. | |
158 | */ |
|
158 | */ | |
159 | void QXYSeries::remove(qreal x,qreal y) |
|
159 | void QXYSeries::remove(qreal x,qreal y) | |
160 | { |
|
160 | { | |
161 | int index =-1; |
|
161 | int index =-1; | |
162 | do { |
|
162 | do { | |
163 | index = m_x.indexOf(x,index+1); |
|
163 | index = m_x.indexOf(x,index+1); | |
164 | } while (index !=-1 && m_y.at(index)!=y); |
|
164 | } while (index !=-1 && m_y.at(index)!=y); | |
165 |
|
165 | |||
166 | if (index==-1) return; |
|
166 | if (index==-1) return; | |
167 |
|
167 | |||
168 | m_x.remove(index); |
|
168 | m_x.remove(index); | |
169 | m_y.remove(index); |
|
169 | m_y.remove(index); | |
170 | emit pointRemoved(index); |
|
170 | emit pointRemoved(index); | |
171 | } |
|
171 | } | |
172 |
|
172 | |||
173 | /*! |
|
173 | /*! | |
174 | Removes current \a point x value. Note \a point y value is ignored. |
|
174 | Removes current \a point x value. Note \a point y value is ignored. | |
175 | */ |
|
175 | */ | |
176 | void QXYSeries::remove(const QPointF &point) |
|
176 | void QXYSeries::remove(const QPointF &point) | |
177 | { |
|
177 | { | |
178 | remove(point.x(),point.y()); |
|
178 | remove(point.x(),point.y()); | |
179 | } |
|
179 | } | |
180 |
|
180 | |||
181 | /*! |
|
181 | /*! | |
182 | Removes all data points from the series. |
|
182 | Removes all data points from the series. | |
183 | */ |
|
183 | */ | |
184 | void QXYSeries::removeAll() |
|
184 | void QXYSeries::removeAll() | |
185 | { |
|
185 | { | |
186 | m_x.clear(); |
|
186 | m_x.clear(); | |
187 | m_y.clear(); |
|
187 | m_y.clear(); | |
188 | } |
|
188 | } | |
189 |
|
189 | |||
190 | /*! |
|
190 | /*! | |
191 | \internal \a pos |
|
191 | \internal \a pos | |
192 | */ |
|
192 | */ | |
193 | qreal QXYSeries::x(int pos) const |
|
193 | qreal QXYSeries::x(int pos) const | |
194 | { |
|
194 | { | |
195 | if (m_model) { |
|
195 | if (m_model) { | |
196 | if (m_mapOrientation == Qt::Vertical) |
|
196 | if (m_mapOrientation == Qt::Vertical) | |
197 | // consecutive data is read from model's column |
|
197 | // consecutive data is read from model's column | |
198 | return m_model->data(m_model->index(pos + m_mapFirst, m_mapX), Qt::DisplayRole).toDouble(); |
|
198 | return m_model->data(m_model->index(pos + m_mapFirst, m_mapX), Qt::DisplayRole).toDouble(); | |
199 | else |
|
199 | else | |
200 | // consecutive data is read from model's row |
|
200 | // consecutive data is read from model's row | |
201 | return m_model->data(m_model->index(m_mapX, pos + m_mapFirst), Qt::DisplayRole).toDouble(); |
|
201 | return m_model->data(m_model->index(m_mapX, pos + m_mapFirst), Qt::DisplayRole).toDouble(); | |
202 | } else { |
|
202 | } else { | |
203 | // model is not specified, return the data from series' internal data store |
|
203 | // model is not specified, return the data from series' internal data store | |
204 | return m_x.at(pos); |
|
204 | return m_x.at(pos); | |
205 | } |
|
205 | } | |
206 | } |
|
206 | } | |
207 |
|
207 | |||
208 | /*! |
|
208 | /*! | |
209 | \internal \a pos |
|
209 | \internal \a pos | |
210 | */ |
|
210 | */ | |
211 | qreal QXYSeries::y(int pos) const |
|
211 | qreal QXYSeries::y(int pos) const | |
212 | { |
|
212 | { | |
213 | if (m_model) { |
|
213 | if (m_model) { | |
214 | if (m_mapOrientation == Qt::Vertical) |
|
214 | if (m_mapOrientation == Qt::Vertical) | |
215 | // consecutive data is read from model's column |
|
215 | // consecutive data is read from model's column | |
216 | return m_model->data(m_model->index(pos + m_mapFirst, m_mapY), Qt::DisplayRole).toDouble(); |
|
216 | return m_model->data(m_model->index(pos + m_mapFirst, m_mapY), Qt::DisplayRole).toDouble(); | |
217 | else |
|
217 | else | |
218 | // consecutive data is read from model's row |
|
218 | // consecutive data is read from model's row | |
219 | return m_model->data(m_model->index(m_mapY, pos + m_mapFirst), Qt::DisplayRole).toDouble(); |
|
219 | return m_model->data(m_model->index(m_mapY, pos + m_mapFirst), Qt::DisplayRole).toDouble(); | |
220 | } else { |
|
220 | } else { | |
221 | // model is not specified, return the data from series' internal data store |
|
221 | // model is not specified, return the data from series' internal data store | |
222 | return m_y.at(pos); |
|
222 | return m_y.at(pos); | |
223 | } |
|
223 | } | |
224 | } |
|
224 | } | |
225 |
|
225 | |||
226 | /*! |
|
226 | /*! | |
227 | Returns number of data points within series. |
|
227 | Returns number of data points within series. | |
228 | */ |
|
228 | */ | |
229 | int QXYSeries::count() const |
|
229 | int QXYSeries::count() const | |
230 | { |
|
230 | { | |
231 | Q_ASSERT(m_x.size() == m_y.size()); |
|
231 | Q_ASSERT(m_x.size() == m_y.size()); | |
232 |
|
232 | |||
233 | if (m_model) { |
|
233 | if (m_model) { | |
234 | if (m_mapOrientation == Qt::Vertical) { |
|
234 | if (m_mapOrientation == Qt::Vertical) { | |
235 | // data is in a column. Return the number of mapped items if the model's column have enough items |
|
235 | // data is in a column. Return the number of mapped items if the model's column have enough items | |
236 | // or the number of items that can be mapped |
|
236 | // or the number of items that can be mapped | |
237 | if (m_mapLimited) |
|
237 | if (m_mapLimited) | |
238 | return qMin(m_mapCount, qMax(m_model->rowCount() - m_mapFirst, 0)); |
|
238 | return qMin(m_mapCount, qMax(m_model->rowCount() - m_mapFirst, 0)); | |
239 | else |
|
239 | else | |
240 | return qMax(m_model->rowCount() - m_mapFirst, 0); |
|
240 | return qMax(m_model->rowCount() - m_mapFirst, 0); | |
241 | } else { |
|
241 | } else { | |
242 | // data is in a row. Return the number of mapped items if the model's row have enough items |
|
242 | // data is in a row. Return the number of mapped items if the model's row have enough items | |
243 | // or the number of items that can be mapped |
|
243 | // or the number of items that can be mapped | |
244 | if (m_mapLimited) |
|
244 | if (m_mapLimited) | |
245 | return qMin(m_mapCount, qMax(m_model->columnCount() - m_mapFirst, 0)); |
|
245 | return qMin(m_mapCount, qMax(m_model->columnCount() - m_mapFirst, 0)); | |
246 | else |
|
246 | else | |
247 | return qMax(m_model->columnCount() - m_mapFirst, 0); |
|
247 | return qMax(m_model->columnCount() - m_mapFirst, 0); | |
248 | } |
|
248 | } | |
249 | } |
|
249 | } | |
250 |
|
250 | |||
251 | // model is not specified, return the number of points in the series internal data store |
|
251 | // model is not specified, return the number of points in the series internal data store | |
252 | return m_x.size(); |
|
252 | return m_x.size(); | |
253 | } |
|
253 | } | |
254 |
|
254 | |||
255 | /*! |
|
255 | /*! | |
256 | Returns the data points of the series. |
|
256 | Returns the data points of the series. | |
257 | */ |
|
257 | */ | |
258 | QList<QPointF> QXYSeries::data() |
|
258 | QList<QPointF> QXYSeries::data() | |
259 | { |
|
259 | { | |
260 | QList<QPointF> data; |
|
260 | QList<QPointF> data; | |
261 | for (int i(0); i < m_x.count() && i < m_y.count(); i++) |
|
261 | for (int i(0); i < m_x.count() && i < m_y.count(); i++) | |
262 | data.append(QPointF(m_x.at(i), m_y.at(i))); |
|
262 | data.append(QPointF(m_x.at(i), m_y.at(i))); | |
263 | return data; |
|
263 | return data; | |
264 | } |
|
264 | } | |
265 |
|
265 | |||
266 |
|
266 | |||
267 | /*! |
|
267 | /*! | |
268 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the |
|
268 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the | |
269 | pen from chart theme is used. |
|
269 | pen from chart theme is used. | |
270 | \sa QChart::setChartTheme() |
|
270 | \sa QChart::setChartTheme() | |
271 | */ |
|
271 | */ | |
272 | void QXYSeries::setPen(const QPen &pen) |
|
272 | void QXYSeries::setPen(const QPen &pen) | |
273 | { |
|
273 | { | |
274 | if (pen != m_pen) { |
|
274 | if (pen != m_pen) { | |
275 | m_pen = pen; |
|
275 | m_pen = pen; | |
276 | emit updated(); |
|
276 | emit updated(); | |
277 | } |
|
277 | } | |
278 | } |
|
278 | } | |
279 |
|
279 | |||
280 | /*! |
|
280 | /*! | |
281 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush |
|
281 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush | |
282 | from chart theme setting is used. |
|
282 | from chart theme setting is used. | |
283 | \sa QChart::setChartTheme() |
|
283 | \sa QChart::setChartTheme() | |
284 | */ |
|
284 | */ | |
285 |
|
285 | |||
286 | void QXYSeries::setBrush(const QBrush &brush) |
|
286 | void QXYSeries::setBrush(const QBrush &brush) | |
287 | { |
|
287 | { | |
288 | if (brush != m_brush) { |
|
288 | if (brush != m_brush) { | |
289 | m_brush = brush; |
|
289 | m_brush = brush; | |
290 | emit updated(); |
|
290 | emit updated(); | |
291 | } |
|
291 | } | |
292 | } |
|
292 | } | |
293 |
|
293 | |||
294 |
|
294 | |||
295 | /*! |
|
295 | /*! | |
296 | Stream operator for adding a data \a point to the series. |
|
296 | Stream operator for adding a data \a point to the series. | |
297 | \sa append() |
|
297 | \sa append() | |
298 | */ |
|
298 | */ | |
299 |
|
299 | |||
300 | QXYSeries& QXYSeries::operator<< (const QPointF &point) |
|
300 | QXYSeries& QXYSeries::operator<< (const QPointF &point) | |
301 | { |
|
301 | { | |
302 | append(point); |
|
302 | append(point); | |
303 | return *this; |
|
303 | return *this; | |
304 | } |
|
304 | } | |
305 |
|
305 | |||
306 |
|
306 | |||
307 | /*! |
|
307 | /*! | |
308 | Stream operator for adding a list of \a points to the series. |
|
308 | Stream operator for adding a list of \a points to the series. | |
309 | \sa append() |
|
309 | \sa append() | |
310 | */ |
|
310 | */ | |
311 |
|
311 | |||
312 | QXYSeries& QXYSeries::operator<< (const QList<QPointF> points) |
|
312 | QXYSeries& QXYSeries::operator<< (const QList<QPointF> points) | |
313 | { |
|
313 | { | |
314 | append(points); |
|
314 | append(points); | |
315 | return *this; |
|
315 | return *this; | |
316 | } |
|
316 | } | |
317 |
|
317 | |||
318 |
|
318 | |||
319 | void QXYSeries::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) |
|
319 | void QXYSeries::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) | |
320 | { |
|
320 | { | |
321 | Q_UNUSED(bottomRight) |
|
321 | Q_UNUSED(bottomRight) | |
322 |
|
322 | |||
323 | if (m_mapOrientation == Qt::Vertical) { |
|
323 | if (m_mapOrientation == Qt::Vertical) { | |
324 | if (topLeft.row() >= m_mapFirst && (!m_mapLimited || topLeft.row() < m_mapFirst + m_mapCount)) |
|
324 | if (topLeft.row() >= m_mapFirst && (!m_mapLimited || topLeft.row() < m_mapFirst + m_mapCount)) | |
325 | emit pointReplaced(topLeft.row() - m_mapFirst); |
|
325 | emit pointReplaced(topLeft.row() - m_mapFirst); | |
326 | } else { |
|
326 | } else { | |
327 | if (topLeft.column() >= m_mapFirst && (!m_mapLimited || topLeft.column() < m_mapFirst + m_mapCount)) |
|
327 | if (topLeft.column() >= m_mapFirst && (!m_mapLimited || topLeft.column() < m_mapFirst + m_mapCount)) | |
328 | emit pointReplaced(topLeft.column() - m_mapFirst); |
|
328 | emit pointReplaced(topLeft.column() - m_mapFirst); | |
329 | } |
|
329 | } | |
330 | } |
|
330 | } | |
331 |
|
331 | |||
332 | void QXYSeries::modelDataAboutToBeAdded(QModelIndex parent, int start, int end) |
|
332 | void QXYSeries::modelDataAboutToBeAdded(QModelIndex parent, int start, int end) | |
333 | { |
|
333 | { | |
334 | Q_UNUSED(parent) |
|
334 | Q_UNUSED(parent) | |
335 | // Q_UNUSED(end) |
|
335 | // Q_UNUSED(end) | |
336 |
|
336 | |||
337 | if (m_mapLimited) { |
|
337 | if (m_mapLimited) { | |
338 | if (start >= m_mapFirst + m_mapCount) { |
|
338 | if (start >= m_mapFirst + m_mapCount) { | |
339 | // the added data is below mapped area |
|
339 | // the added data is below mapped area | |
340 | // therefore it has no relevance |
|
340 | // therefore it has no relevance | |
341 | return; |
|
341 | return; | |
342 | } else { |
|
342 | } else { | |
343 | // the added data is in the mapped area or before it and update is needed |
|
343 | // the added data is in the mapped area or before it and update is needed | |
344 |
|
344 | |||
345 | // check how many mapped items there is currently (before new items are added) |
|
345 | // check how many mapped items there is currently (before new items are added) | |
346 | // if the number of items currently is equal the m_mapCount then some needs to be removed from xychartitem |
|
346 | // if the number of items currently is equal the m_mapCount then some needs to be removed from xychartitem | |
347 | // internal storage before new ones can be added |
|
347 | // internal storage before new ones can be added | |
348 |
|
348 | |||
349 | int itemsToRemove = qMin(count() - qMax(start - m_mapFirst, 0), end - start + 1); |
|
349 | int itemsToRemove = qMin(count() - qMax(start - m_mapFirst, 0), end - start + 1); | |
350 | if (m_mapCount == count()) { |
|
350 | if (m_mapCount == count()) { | |
351 | for (int i = 0; i < itemsToRemove; i++) |
|
351 | for (int i = 0; i < itemsToRemove; i++) | |
352 | emit pointRemoved(qMin(end, count()) - i); |
|
352 | emit pointRemoved(qMin(end, count()) - i); | |
353 | } |
|
353 | } | |
354 | } |
|
354 | } | |
355 | } else { |
|
355 | } else { | |
356 | // map is not limited (it includes all the items starting from m_mapFirst till the end of model) |
|
356 | // map is not limited (it includes all the items starting from m_mapFirst till the end of model) | |
357 | // nothing to do |
|
357 | // nothing to do | |
358 | // emit pointAdded(qMax(start - m_mapFirst, 0)); |
|
358 | // emit pointAdded(qMax(start - m_mapFirst, 0)); | |
359 | } |
|
359 | } | |
360 | } |
|
360 | } | |
361 |
|
361 | |||
362 | void QXYSeries::modelDataAdded(QModelIndex parent, int start, int end) |
|
362 | void QXYSeries::modelDataAdded(QModelIndex parent, int start, int end) | |
363 | { |
|
363 | { | |
364 | Q_UNUSED(parent) |
|
364 | Q_UNUSED(parent) | |
365 | // Q_UNUSED(end) |
|
365 | // Q_UNUSED(end) | |
366 |
|
366 | |||
367 | if (m_mapLimited) { |
|
367 | if (m_mapLimited) { | |
368 | if (start >= m_mapFirst + m_mapCount) { |
|
368 | if (start >= m_mapFirst + m_mapCount) { | |
369 | // the added data is below mapped area |
|
369 | // the added data is below mapped area | |
370 | // therefore it has no relevance |
|
370 | // therefore it has no relevance | |
371 | return; |
|
371 | return; | |
372 | } else { |
|
372 | } else { | |
373 | // the added data is in the mapped area or before it |
|
373 | // the added data is in the mapped area or before it | |
374 | // update needed |
|
374 | // update needed | |
375 | if (count() > 0) { |
|
375 | if (count() > 0) { | |
376 | int toBeAdded = qMin(m_mapCount - (start - m_mapFirst), end - start + 1); |
|
376 | int toBeAdded = qMin(m_mapCount - (start - m_mapFirst), end - start + 1); | |
377 | for (int i = 0; i < toBeAdded; i++) |
|
377 | for (int i = 0; i < toBeAdded; i++) | |
378 | if (start + i >= m_mapFirst) |
|
378 | if (start + i >= m_mapFirst) | |
379 | emit pointAdded(start + i); |
|
379 | emit pointAdded(start + i); | |
380 | } |
|
380 | } | |
381 | } |
|
381 | } | |
382 | } else { |
|
382 | } else { | |
383 | // map is not limited (it included all the items starting from m_mapFirst till the end of model) |
|
383 | // map is not limited (it included all the items starting from m_mapFirst till the end of model) | |
384 | for (int i = 0; i < end - start + 1; i++) |
|
384 | for (int i = 0; i < end - start + 1; i++) | |
385 | emit pointAdded(start + i); |
|
385 | emit pointAdded(start + i); | |
386 | } |
|
386 | } | |
387 | } |
|
387 | } | |
388 |
|
388 | |||
389 | void QXYSeries::modelDataAboutToBeRemoved(QModelIndex parent, int start, int end) |
|
389 | void QXYSeries::modelDataAboutToBeRemoved(QModelIndex parent, int start, int end) | |
390 | { |
|
390 | { | |
391 | Q_UNUSED(parent) |
|
391 | Q_UNUSED(parent) | |
392 | // Q_UNUSED(end) |
|
392 | // Q_UNUSED(end) | |
393 |
|
393 | |||
394 | if (m_mapLimited) { |
|
394 | if (m_mapLimited) { | |
395 | if (start >= m_mapFirst + m_mapCount) { |
|
395 | if (start >= m_mapFirst + m_mapCount) { | |
396 | // the removed data is below mapped area |
|
396 | // the removed data is below mapped area | |
397 | // therefore it has no relevance |
|
397 | // therefore it has no relevance | |
398 | return; |
|
398 | return; | |
399 | } else { |
|
399 | } else { | |
400 | // the removed data is in the mapped area or before it |
|
400 | // the removed data is in the mapped area or before it | |
401 | // update needed |
|
401 | // update needed | |
402 |
|
402 | |||
403 | // check how many items need to be removed from the xychartitem storage |
|
403 | // check how many items need to be removed from the xychartitem storage | |
404 | // the number equals the number of items that are removed and that lay before |
|
404 | // the number equals the number of items that are removed and that lay before | |
405 | // or in the mapped area. Items that lay beyond the map do not count |
|
405 | // or in the mapped area. Items that lay beyond the map do not count | |
406 | // the max is the current number of items in storage (count()) |
|
406 | // the max is the current number of items in storage (count()) | |
407 | int itemsToRemove = qMin(count(), qMin(end, m_mapFirst + m_mapCount - 1) - start + 1); |
|
407 | int itemsToRemove = qMin(count(), qMin(end, m_mapFirst + m_mapCount - 1) - start + 1); | |
408 | for (int i = 0; i < itemsToRemove; i++) |
|
408 | for (int i = 0; i < itemsToRemove; i++) | |
409 | emit pointRemoved(start); |
|
409 | emit pointRemoved(start); | |
410 | } |
|
410 | } | |
411 | } else { |
|
411 | } else { | |
412 | // map is not limited (it included all the items starting from m_mapFirst till the end of model) |
|
412 | // map is not limited (it included all the items starting from m_mapFirst till the end of model) | |
413 | for (int i = 0; i < end - start + 1; i++) |
|
413 | for (int i = 0; i < end - start + 1; i++) | |
414 | emit pointRemoved(start); |
|
414 | emit pointRemoved(start); | |
415 | } |
|
415 | } | |
416 | } |
|
416 | } | |
417 |
|
417 | |||
418 | void QXYSeries::modelDataRemoved(QModelIndex parent, int start, int end) |
|
418 | void QXYSeries::modelDataRemoved(QModelIndex parent, int start, int end) | |
419 | { |
|
419 | { | |
420 | Q_UNUSED(parent) |
|
420 | Q_UNUSED(parent) | |
421 | Q_UNUSED(end) |
|
421 | Q_UNUSED(end) | |
422 |
|
422 | |||
423 | // how many items there were before data was removed |
|
423 | // how many items there were before data was removed | |
424 | // int oldCount = count() - 1; |
|
424 | // int oldCount = count() - 1; | |
425 |
|
425 | |||
426 | if (m_mapLimited) { |
|
426 | if (m_mapLimited) { | |
427 | if (start >= m_mapFirst + m_mapCount) { |
|
427 | if (start >= m_mapFirst + m_mapCount) { | |
428 | // the removed data is below mapped area |
|
428 | // the removed data is below mapped area | |
429 | // therefore it has no relevance |
|
429 | // therefore it has no relevance | |
430 | return; |
|
430 | return; | |
431 | } else { |
|
431 | } else { | |
432 | // if the current items count in the whole model is bigger than the index of the last item |
|
432 | // if the current items count in the whole model is bigger than the index of the last item | |
433 | // that was removed than it means there are some extra items available |
|
433 | // that was removed than it means there are some extra items available | |
434 |
|
434 | |||
435 | int removedItemsCount = qMin(count(), qMin(end, m_mapFirst + m_mapCount - 1) - start + 1); |
|
435 | int removedItemsCount = qMin(count(), qMin(end, m_mapFirst + m_mapCount - 1) - start + 1); | |
436 | int extraItemsAvailable = 0; |
|
436 | int extraItemsAvailable = 0; | |
437 | if (m_mapOrientation == Qt::Vertical) { |
|
437 | if (m_mapOrientation == Qt::Vertical) { | |
438 | extraItemsAvailable = qMax(m_model->rowCount() + (end - start + 1) - qMax(end + 1, m_mapFirst + m_mapCount), 0); |
|
438 | extraItemsAvailable = qMax(m_model->rowCount() + (end - start + 1) - qMax(end + 1, m_mapFirst + m_mapCount), 0); | |
439 | } else { |
|
439 | } else { | |
440 | extraItemsAvailable = qMax(m_model->columnCount() + (end - start + 1) - qMax(end + 1, m_mapFirst + m_mapCount), 0); |
|
440 | extraItemsAvailable = qMax(m_model->columnCount() + (end - start + 1) - qMax(end + 1, m_mapFirst + m_mapCount), 0); | |
441 | } |
|
441 | } | |
442 |
|
442 | |||
443 | // if there are excess items available (below the mapped area) use them to repopulate mapped area |
|
443 | // if there are excess items available (below the mapped area) use them to repopulate mapped area | |
444 | int toBeAdded = qMin(extraItemsAvailable, removedItemsCount); |
|
444 | int toBeAdded = qMin(extraItemsAvailable, removedItemsCount); | |
445 | for (int k = 0; k < toBeAdded; k++) |
|
445 | for (int k = 0; k < toBeAdded; k++) | |
446 | emit pointAdded(m_mapFirst + m_mapCount - removedItemsCount + k); |
|
446 | emit pointAdded(m_mapFirst + m_mapCount - removedItemsCount + k); | |
447 | } |
|
447 | } | |
448 | } else { |
|
448 | } else { | |
449 | // data was removed from XYSeries interal storage. Nothing more to do |
|
449 | // data was removed from XYSeries interal storage. Nothing more to do | |
450 | } |
|
450 | } | |
451 | } |
|
451 | } | |
452 |
|
452 | |||
453 | bool QXYSeries::setModel(QAbstractItemModel *model) { |
|
453 | bool QXYSeries::setModel(QAbstractItemModel *model) { | |
454 |
|
454 | |||
455 | // disconnect signals from old model |
|
455 | // disconnect signals from old model | |
456 | if (m_model) { |
|
456 | if (m_model) { | |
457 | disconnect(m_model, 0, this, 0); |
|
457 | disconnect(m_model, 0, this, 0); | |
458 | m_mapX = -1; |
|
458 | m_mapX = -1; | |
459 | m_mapY = -1; |
|
459 | m_mapY = -1; | |
460 | m_mapFirst = 0; |
|
460 | m_mapFirst = 0; | |
461 | m_mapCount = 0; |
|
461 | m_mapCount = 0; | |
462 | m_mapLimited = false; |
|
462 | m_mapLimited = false; | |
463 | m_mapOrientation = Qt::Vertical; |
|
463 | m_mapOrientation = Qt::Vertical; | |
464 | } |
|
464 | } | |
465 |
|
465 | |||
466 | // set new model |
|
466 | // set new model | |
467 | if (model) { |
|
467 | if (model) { | |
468 | m_model = model; |
|
468 | m_model = model; | |
469 | return true; |
|
469 | return true; | |
470 | } else { |
|
470 | } else { | |
471 | m_model = 0; |
|
471 | m_model = 0; | |
472 | return false; |
|
472 | return false; | |
473 | } |
|
473 | } | |
474 | } |
|
474 | } | |
475 |
|
475 | |||
476 | void QXYSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation) |
|
476 | void QXYSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation) | |
477 | { |
|
477 | { | |
478 | if (m_model == 0) |
|
478 | if (m_model == 0) | |
479 | return; |
|
479 | return; | |
480 | m_mapX = modelX; |
|
480 | m_mapX = modelX; | |
481 | m_mapY = modelY; |
|
481 | m_mapY = modelY; | |
482 | m_mapFirst = 0; |
|
482 | m_mapFirst = 0; | |
483 | m_mapOrientation = orientation; |
|
483 | m_mapOrientation = orientation; | |
484 | if (m_mapOrientation == Qt::Vertical) { |
|
484 | if (m_mapOrientation == Qt::Vertical) { | |
485 | connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex))); |
|
485 | connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex))); | |
486 | connect(m_model,SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeAdded(QModelIndex,int,int))); |
|
486 | connect(m_model,SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeAdded(QModelIndex,int,int))); | |
487 | connect(m_model,SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int))); |
|
487 | connect(m_model,SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int))); | |
488 | connect(m_model, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeRemoved(QModelIndex,int,int))); |
|
488 | connect(m_model, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeRemoved(QModelIndex,int,int))); | |
489 | connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int))); |
|
489 | connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int))); | |
490 | } else { |
|
490 | } else { | |
491 | connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex))); |
|
491 | connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex))); | |
492 | connect(m_model,SIGNAL(columnsAboutToBeInserted(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeAdded(QModelIndex,int,int))); |
|
492 | connect(m_model,SIGNAL(columnsAboutToBeInserted(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeAdded(QModelIndex,int,int))); | |
493 | connect(m_model,SIGNAL(columnsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int))); |
|
493 | connect(m_model,SIGNAL(columnsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int))); | |
494 | connect(m_model, SIGNAL(columnsAboutToBeRemoved(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeRemoved(QModelIndex,int,int))); |
|
494 | connect(m_model, SIGNAL(columnsAboutToBeRemoved(QModelIndex, int, int)), this, SLOT(modelDataAboutToBeRemoved(QModelIndex,int,int))); | |
495 | connect(m_model, SIGNAL(columnsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int))); |
|
495 | connect(m_model, SIGNAL(columnsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int))); | |
496 | } |
|
496 | } | |
497 | } |
|
497 | } | |
498 |
|
498 | |||
499 |
void QXYSeries::setModelMapping |
|
499 | void QXYSeries::setModelMappingRange(int first, int count) | |
500 | { |
|
500 | { | |
501 | m_mapFirst = first; |
|
501 | m_mapFirst = first; | |
502 | if (count == 0) { |
|
502 | if (count == 0) { | |
503 | m_mapLimited = false; |
|
503 | m_mapLimited = false; | |
504 | } else { |
|
504 | } else { | |
505 | m_mapCount = count; |
|
505 | m_mapCount = count; | |
506 | m_mapLimited = true; |
|
506 | m_mapLimited = true; | |
507 | } |
|
507 | } | |
508 | } |
|
508 | } | |
509 |
|
509 | |||
510 | #include "moc_qxyseries.cpp" |
|
510 | #include "moc_qxyseries.cpp" | |
511 |
|
511 | |||
512 | QTCOMMERCIALCHART_END_NAMESPACE |
|
512 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now