@@ -1,458 +1,478 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
1 | #include "qbarmodelmapper.h" |
|
21 | #include "qbarmodelmapper.h" | |
2 | #include "qbarmodelmapper_p.h" |
|
22 | #include "qbarmodelmapper_p.h" | |
3 | #include "qbarseries.h" |
|
23 | #include "qbarseries.h" | |
4 | #include "qbarset.h" |
|
24 | #include "qbarset.h" | |
5 | #include "qchart.h" |
|
25 | #include "qchart.h" | |
6 | #include "qaxis.h" |
|
26 | #include "qaxis.h" | |
7 | #include <QAbstractItemModel> |
|
27 | #include <QAbstractItemModel> | |
8 |
|
28 | |||
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
10 |
|
30 | |||
11 | /*! |
|
31 | /*! | |
12 | \property QBarModelMapper::series |
|
32 | \property QBarModelMapper::series | |
13 | \brief Defines the QPieSeries object that is used by the mapper. |
|
33 | \brief Defines the QPieSeries object that is used by the mapper. | |
14 |
|
34 | |||
15 | All the data in the series in the series is discarded when it is set to the mapper. |
|
35 | All the data in the series in the series is discarded when it is set to the mapper. | |
16 | When new series is specified the old series is disconnected (it preserves its data) |
|
36 | When new series is specified the old series is disconnected (it preserves its data) | |
17 | */ |
|
37 | */ | |
18 |
|
38 | |||
19 | /*! |
|
39 | /*! | |
20 | \property QBarModelMapper::model |
|
40 | \property QBarModelMapper::model | |
21 | \brief Defines the model that is used by the mapper. |
|
41 | \brief Defines the model that is used by the mapper. | |
22 | */ |
|
42 | */ | |
23 |
|
43 | |||
24 | /*! |
|
44 | /*! | |
25 | \property QBarModelMapper::first |
|
45 | \property QBarModelMapper::first | |
26 | \brief Defines which item of the model's row/column should be mapped as the value of the first QBarSet in the series. |
|
46 | \brief Defines which item of the model's row/column should be mapped as the value of the first QBarSet in the series. | |
27 |
|
47 | |||
28 | Minimal and default value is: 0 |
|
48 | Minimal and default value is: 0 | |
29 | */ |
|
49 | */ | |
30 |
|
50 | |||
31 | /*! |
|
51 | /*! | |
32 | \property QBarModelMapper::count |
|
52 | \property QBarModelMapper::count | |
33 | \brief Defines the number of rows/columns of the model that are mapped as the data for QBarSeries |
|
53 | \brief Defines the number of rows/columns of the model that are mapped as the data for QBarSeries | |
34 |
|
54 | |||
35 | Minimal and default value is: -1 (count limited by the number of rows/columns in the model) |
|
55 | Minimal and default value is: -1 (count limited by the number of rows/columns in the model) | |
36 | */ |
|
56 | */ | |
37 |
|
57 | |||
38 | /*! |
|
58 | /*! | |
39 | \class QBarModelMapper |
|
59 | \class QBarModelMapper | |
40 | \brief part of QtCommercial chart API. |
|
60 | \brief part of QtCommercial chart API. | |
41 | \mainclass |
|
61 | \mainclass | |
42 |
|
62 | |||
43 | The instance of this class cannot be created directly. QHBarModelMapper of QVBarModelMapper should be used instead. This class is used to create a connection between QBarSeries and QAbstractItemModel derived model object. |
|
63 | The instance of this class cannot be created directly. QHBarModelMapper of QVBarModelMapper should be used instead. This class is used to create a connection between QBarSeries and QAbstractItemModel derived model object. | |
44 | Curently it is NOT possible to use both QAbstractItemModel and QXYSeries model API. |
|
64 | Curently it is NOT possible to use both QAbstractItemModel and QXYSeries model API. | |
45 | When the series is set to the mapper the QBarSeries and QBarSet API that affect the data (append, setValue, remove) should not be used. |
|
65 | When the series is set to the mapper the QBarSeries and QBarSet API that affect the data (append, setValue, remove) should not be used. | |
46 | The model and the QBarSeries won't be kept in sync. Model API should be used to insert,remove,modify BarSets. |
|
66 | The model and the QBarSeries won't be kept in sync. Model API should be used to insert,remove,modify BarSets. | |
47 | NOTE: used model has to support adding/removing rows/columns and modifying the data of the cells. |
|
67 | NOTE: used model has to support adding/removing rows/columns and modifying the data of the cells. | |
48 | */ |
|
68 | */ | |
49 |
|
69 | |||
50 | /*! |
|
70 | /*! | |
51 | Constructs a mapper object which is a child of \a parent. |
|
71 | Constructs a mapper object which is a child of \a parent. | |
52 | */ |
|
72 | */ | |
53 | QBarModelMapper::QBarModelMapper(QObject *parent) : |
|
73 | QBarModelMapper::QBarModelMapper(QObject *parent) : | |
54 | QObject(parent), |
|
74 | QObject(parent), | |
55 | d_ptr(new QBarModelMapperPrivate(this)) |
|
75 | d_ptr(new QBarModelMapperPrivate(this)) | |
56 | { |
|
76 | { | |
57 | } |
|
77 | } | |
58 |
|
78 | |||
59 | QAbstractItemModel* QBarModelMapper::model() const |
|
79 | QAbstractItemModel* QBarModelMapper::model() const | |
60 | { |
|
80 | { | |
61 | Q_D(const QBarModelMapper); |
|
81 | Q_D(const QBarModelMapper); | |
62 | return d->m_model; |
|
82 | return d->m_model; | |
63 | } |
|
83 | } | |
64 |
|
84 | |||
65 | void QBarModelMapper::setModel(QAbstractItemModel *model) |
|
85 | void QBarModelMapper::setModel(QAbstractItemModel *model) | |
66 | { |
|
86 | { | |
67 | if (model == 0) |
|
87 | if (model == 0) | |
68 | return; |
|
88 | return; | |
69 |
|
89 | |||
70 | Q_D(QBarModelMapper); |
|
90 | Q_D(QBarModelMapper); | |
71 | if (d->m_model) { |
|
91 | if (d->m_model) { | |
72 | disconnect(d->m_model, 0, d, 0); |
|
92 | disconnect(d->m_model, 0, d, 0); | |
73 | } |
|
93 | } | |
74 |
|
94 | |||
75 | d->m_model = model; |
|
95 | d->m_model = model; | |
76 | d->initializeBarFromModel(); |
|
96 | d->initializeBarFromModel(); | |
77 | // connect signals from the model |
|
97 | // connect signals from the model | |
78 | connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); |
|
98 | connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); | |
79 | connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); |
|
99 | connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); | |
80 | connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); |
|
100 | connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); | |
81 | connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); |
|
101 | connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); | |
82 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); |
|
102 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); | |
83 | } |
|
103 | } | |
84 |
|
104 | |||
85 | QBarSeries* QBarModelMapper::series() const |
|
105 | QBarSeries* QBarModelMapper::series() const | |
86 | { |
|
106 | { | |
87 | Q_D(const QBarModelMapper); |
|
107 | Q_D(const QBarModelMapper); | |
88 | return d->m_series; |
|
108 | return d->m_series; | |
89 | } |
|
109 | } | |
90 |
|
110 | |||
91 | void QBarModelMapper::setSeries(QBarSeries *series) |
|
111 | void QBarModelMapper::setSeries(QBarSeries *series) | |
92 | { |
|
112 | { | |
93 | Q_D(QBarModelMapper); |
|
113 | Q_D(QBarModelMapper); | |
94 | if (d->m_series) { |
|
114 | if (d->m_series) { | |
95 | disconnect(d->m_series, 0, d, 0); |
|
115 | disconnect(d->m_series, 0, d, 0); | |
96 | } |
|
116 | } | |
97 |
|
117 | |||
98 | if (series == 0) |
|
118 | if (series == 0) | |
99 | return; |
|
119 | return; | |
100 |
|
120 | |||
101 | d->m_series = series; |
|
121 | d->m_series = series; | |
102 | d->initializeBarFromModel(); |
|
122 | d->initializeBarFromModel(); | |
103 | // connect the signals from the series |
|
123 | // connect the signals from the series | |
104 | // connect(d->m_series, SIGNAL(pointAdded(int)), d, SLOT(handlePointAdded(int))); |
|
124 | // connect(d->m_series, SIGNAL(pointAdded(int)), d, SLOT(handlePointAdded(int))); | |
105 | // connect(d->m_series, SIGNAL(pointRemoved(int)), d, SLOT(handlePointRemoved(int))); |
|
125 | // connect(d->m_series, SIGNAL(pointRemoved(int)), d, SLOT(handlePointRemoved(int))); | |
106 | // connect(d->m_series, SIGNAL(pointReplaced(int)), d, SLOT(handlePointReplaced(int))); |
|
126 | // connect(d->m_series, SIGNAL(pointReplaced(int)), d, SLOT(handlePointReplaced(int))); | |
107 | } |
|
127 | } | |
108 |
|
128 | |||
109 | int QBarModelMapper::first() const |
|
129 | int QBarModelMapper::first() const | |
110 | { |
|
130 | { | |
111 | Q_D(const QBarModelMapper); |
|
131 | Q_D(const QBarModelMapper); | |
112 | return d->m_first; |
|
132 | return d->m_first; | |
113 | } |
|
133 | } | |
114 |
|
134 | |||
115 | void QBarModelMapper::setFirst(int first) |
|
135 | void QBarModelMapper::setFirst(int first) | |
116 | { |
|
136 | { | |
117 | Q_D(QBarModelMapper); |
|
137 | Q_D(QBarModelMapper); | |
118 | d->m_first = qMax(first, 0); |
|
138 | d->m_first = qMax(first, 0); | |
119 | d->initializeBarFromModel(); |
|
139 | d->initializeBarFromModel(); | |
120 | } |
|
140 | } | |
121 |
|
141 | |||
122 | int QBarModelMapper::count() const |
|
142 | int QBarModelMapper::count() const | |
123 | { |
|
143 | { | |
124 | Q_D(const QBarModelMapper); |
|
144 | Q_D(const QBarModelMapper); | |
125 | return d->m_count; |
|
145 | return d->m_count; | |
126 | } |
|
146 | } | |
127 |
|
147 | |||
128 | void QBarModelMapper::setCount(int count) |
|
148 | void QBarModelMapper::setCount(int count) | |
129 | { |
|
149 | { | |
130 | Q_D(QBarModelMapper); |
|
150 | Q_D(QBarModelMapper); | |
131 | d->m_count = qMax(count, -1); |
|
151 | d->m_count = qMax(count, -1); | |
132 | d->initializeBarFromModel(); |
|
152 | d->initializeBarFromModel(); | |
133 | } |
|
153 | } | |
134 |
|
154 | |||
135 | /*! |
|
155 | /*! | |
136 | Returns the orientation that is used when QBarModelMapper accesses the model. |
|
156 | Returns the orientation that is used when QBarModelMapper accesses the model. | |
137 | This mean whether the consecutive values of the bar set are read from row (Qt::Horizontal) |
|
157 | This mean whether the consecutive values of the bar set are read from row (Qt::Horizontal) | |
138 | or from columns (Qt::Vertical) |
|
158 | or from columns (Qt::Vertical) | |
139 | */ |
|
159 | */ | |
140 | Qt::Orientation QBarModelMapper::orientation() const |
|
160 | Qt::Orientation QBarModelMapper::orientation() const | |
141 | { |
|
161 | { | |
142 | Q_D(const QBarModelMapper); |
|
162 | Q_D(const QBarModelMapper); | |
143 | return d->m_orientation; |
|
163 | return d->m_orientation; | |
144 | } |
|
164 | } | |
145 |
|
165 | |||
146 | /*! |
|
166 | /*! | |
147 | Returns the \a orientation that is used when QBarModelMapper accesses the model. |
|
167 | Returns the \a orientation that is used when QBarModelMapper accesses the model. | |
148 | This mean whether the consecutive values of the pie are read from row (Qt::Horizontal) |
|
168 | This mean whether the consecutive values of the pie are read from row (Qt::Horizontal) | |
149 | or from columns (Qt::Vertical) |
|
169 | or from columns (Qt::Vertical) | |
150 | */ |
|
170 | */ | |
151 | void QBarModelMapper::setOrientation(Qt::Orientation orientation) |
|
171 | void QBarModelMapper::setOrientation(Qt::Orientation orientation) | |
152 | { |
|
172 | { | |
153 | Q_D(QBarModelMapper); |
|
173 | Q_D(QBarModelMapper); | |
154 | d->m_orientation = orientation; |
|
174 | d->m_orientation = orientation; | |
155 | d->initializeBarFromModel(); |
|
175 | d->initializeBarFromModel(); | |
156 | } |
|
176 | } | |
157 |
|
177 | |||
158 | /*! |
|
178 | /*! | |
159 | Returns which section of the model is used as the data source for the first bar set |
|
179 | Returns which section of the model is used as the data source for the first bar set | |
160 | */ |
|
180 | */ | |
161 | int QBarModelMapper::firstBarSetSection() const |
|
181 | int QBarModelMapper::firstBarSetSection() const | |
162 | { |
|
182 | { | |
163 | Q_D(const QBarModelMapper); |
|
183 | Q_D(const QBarModelMapper); | |
164 | return d->m_firstBarSetSection; |
|
184 | return d->m_firstBarSetSection; | |
165 | } |
|
185 | } | |
166 |
|
186 | |||
167 | /*! |
|
187 | /*! | |
168 | Sets the model section that is used as the data source for the first bar set |
|
188 | Sets the model section that is used as the data source for the first bar set | |
169 | Parameter \a firstBarSetSection specifies the section of the model. |
|
189 | Parameter \a firstBarSetSection specifies the section of the model. | |
170 | */ |
|
190 | */ | |
171 | void QBarModelMapper::setFirstBarSetSection(int firstBarSetSection) |
|
191 | void QBarModelMapper::setFirstBarSetSection(int firstBarSetSection) | |
172 | { |
|
192 | { | |
173 | Q_D(QBarModelMapper); |
|
193 | Q_D(QBarModelMapper); | |
174 | d->m_firstBarSetSection = firstBarSetSection; |
|
194 | d->m_firstBarSetSection = firstBarSetSection; | |
175 | d->initializeBarFromModel(); |
|
195 | d->initializeBarFromModel(); | |
176 | } |
|
196 | } | |
177 |
|
197 | |||
178 | /*! |
|
198 | /*! | |
179 | Returns which section of the model is used as the data source for the last bar set |
|
199 | Returns which section of the model is used as the data source for the last bar set | |
180 | */ |
|
200 | */ | |
181 | int QBarModelMapper::lastBarSetSection() const |
|
201 | int QBarModelMapper::lastBarSetSection() const | |
182 | { |
|
202 | { | |
183 | Q_D(const QBarModelMapper); |
|
203 | Q_D(const QBarModelMapper); | |
184 | return d->m_lastBarSetSection; |
|
204 | return d->m_lastBarSetSection; | |
185 | } |
|
205 | } | |
186 |
|
206 | |||
187 | /*! |
|
207 | /*! | |
188 | Sets the model section that is used as the data source for the last bar set |
|
208 | Sets the model section that is used as the data source for the last bar set | |
189 | Parameter \a lastBarSetSection specifies the section of the model. |
|
209 | Parameter \a lastBarSetSection specifies the section of the model. | |
190 | */ |
|
210 | */ | |
191 | void QBarModelMapper::setLastBarSetSection(int lastBarSetSection) |
|
211 | void QBarModelMapper::setLastBarSetSection(int lastBarSetSection) | |
192 | { |
|
212 | { | |
193 | Q_D(QBarModelMapper); |
|
213 | Q_D(QBarModelMapper); | |
194 | d->m_lastBarSetSection = lastBarSetSection; |
|
214 | d->m_lastBarSetSection = lastBarSetSection; | |
195 | d->initializeBarFromModel(); |
|
215 | d->initializeBarFromModel(); | |
196 | } |
|
216 | } | |
197 |
|
217 | |||
198 | /*! |
|
218 | /*! | |
199 | Resets the QBarModelMapper to the default state. |
|
219 | Resets the QBarModelMapper to the default state. | |
200 | first: 0; count: -1; firstBarSetSection: -1; lastBarSetSection: -1; categoriesSection: -1 |
|
220 | first: 0; count: -1; firstBarSetSection: -1; lastBarSetSection: -1; categoriesSection: -1 | |
201 | */ |
|
221 | */ | |
202 | void QBarModelMapper::reset() |
|
222 | void QBarModelMapper::reset() | |
203 | { |
|
223 | { | |
204 | Q_D(QBarModelMapper); |
|
224 | Q_D(QBarModelMapper); | |
205 | d->m_first = 0; |
|
225 | d->m_first = 0; | |
206 | d->m_count = -1; |
|
226 | d->m_count = -1; | |
207 | d->m_firstBarSetSection = -1; |
|
227 | d->m_firstBarSetSection = -1; | |
208 | d->m_lastBarSetSection = -1; |
|
228 | d->m_lastBarSetSection = -1; | |
209 | d->initializeBarFromModel(); |
|
229 | d->initializeBarFromModel(); | |
210 | } |
|
230 | } | |
211 |
|
231 | |||
212 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
232 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
213 |
|
233 | |||
214 | QBarModelMapperPrivate::QBarModelMapperPrivate(QBarModelMapper *q) : |
|
234 | QBarModelMapperPrivate::QBarModelMapperPrivate(QBarModelMapper *q) : | |
215 | m_series(0), |
|
235 | m_series(0), | |
216 | m_model(0), |
|
236 | m_model(0), | |
217 | m_first(0), |
|
237 | m_first(0), | |
218 | m_count(-1), |
|
238 | m_count(-1), | |
219 | m_orientation(Qt::Vertical), |
|
239 | m_orientation(Qt::Vertical), | |
220 | m_firstBarSetSection(-1), |
|
240 | m_firstBarSetSection(-1), | |
221 | m_lastBarSetSection(-1), |
|
241 | m_lastBarSetSection(-1), | |
222 | m_seriesSignalsBlock(false), |
|
242 | m_seriesSignalsBlock(false), | |
223 | m_modelSignalsBlock(false), |
|
243 | m_modelSignalsBlock(false), | |
224 | q_ptr(q) |
|
244 | q_ptr(q) | |
225 | { |
|
245 | { | |
226 | } |
|
246 | } | |
227 |
|
247 | |||
228 | void QBarModelMapperPrivate::blockModelSignals(bool block) |
|
248 | void QBarModelMapperPrivate::blockModelSignals(bool block) | |
229 | { |
|
249 | { | |
230 | m_modelSignalsBlock = block; |
|
250 | m_modelSignalsBlock = block; | |
231 | } |
|
251 | } | |
232 |
|
252 | |||
233 | void QBarModelMapperPrivate::blockSeriesSignals(bool block) |
|
253 | void QBarModelMapperPrivate::blockSeriesSignals(bool block) | |
234 | { |
|
254 | { | |
235 | m_seriesSignalsBlock = block; |
|
255 | m_seriesSignalsBlock = block; | |
236 | } |
|
256 | } | |
237 |
|
257 | |||
238 | QBarSet* QBarModelMapperPrivate::barSet(QModelIndex index) |
|
258 | QBarSet* QBarModelMapperPrivate::barSet(QModelIndex index) | |
239 | { |
|
259 | { | |
240 | if (!index.isValid()) |
|
260 | if (!index.isValid()) | |
241 | return 0; |
|
261 | return 0; | |
242 |
|
262 | |||
243 | if (m_orientation == Qt::Vertical && index.column() >= m_firstBarSetSection && index.column() <= m_lastBarSetSection) { |
|
263 | if (m_orientation == Qt::Vertical && index.column() >= m_firstBarSetSection && index.column() <= m_lastBarSetSection) { | |
244 | if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) { |
|
264 | if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) { | |
245 | // if (m_model->index(index.row(), m_valuesSection).isValid() && m_model->index(index.row(), m_labelsSection).isValid()) |
|
265 | // if (m_model->index(index.row(), m_valuesSection).isValid() && m_model->index(index.row(), m_labelsSection).isValid()) | |
246 | return m_series->barSets().at(index.column() - m_firstBarSetSection); |
|
266 | return m_series->barSets().at(index.column() - m_firstBarSetSection); | |
247 | // else |
|
267 | // else | |
248 | // return 0; |
|
268 | // return 0; | |
249 | } |
|
269 | } | |
250 | } else if (m_orientation == Qt::Horizontal && index.row() >= m_firstBarSetSection && index.row() <= m_lastBarSetSection) { |
|
270 | } else if (m_orientation == Qt::Horizontal && index.row() >= m_firstBarSetSection && index.row() <= m_lastBarSetSection) { | |
251 | if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) |
|
271 | if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) | |
252 | return m_series->barSets().at(index.row() - m_firstBarSetSection); |
|
272 | return m_series->barSets().at(index.row() - m_firstBarSetSection); | |
253 | } |
|
273 | } | |
254 | return 0; // This part of model has not been mapped to any slice |
|
274 | return 0; // This part of model has not been mapped to any slice | |
255 | } |
|
275 | } | |
256 |
|
276 | |||
257 | QModelIndex QBarModelMapperPrivate::barModelIndex(int barSection, int posInBar) |
|
277 | QModelIndex QBarModelMapperPrivate::barModelIndex(int barSection, int posInBar) | |
258 | { |
|
278 | { | |
259 | if (m_count != -1 && posInBar >= m_count) |
|
279 | if (m_count != -1 && posInBar >= m_count) | |
260 | return QModelIndex(); // invalid |
|
280 | return QModelIndex(); // invalid | |
261 |
|
281 | |||
262 | if (barSection < m_firstBarSetSection || barSection > m_lastBarSetSection) |
|
282 | if (barSection < m_firstBarSetSection || barSection > m_lastBarSetSection) | |
263 | return QModelIndex(); // invalid |
|
283 | return QModelIndex(); // invalid | |
264 |
|
284 | |||
265 | if (m_orientation == Qt::Vertical) |
|
285 | if (m_orientation == Qt::Vertical) | |
266 | return m_model->index(posInBar + m_first, barSection); |
|
286 | return m_model->index(posInBar + m_first, barSection); | |
267 | else |
|
287 | else | |
268 | return m_model->index(barSection, posInBar + m_first); |
|
288 | return m_model->index(barSection, posInBar + m_first); | |
269 | } |
|
289 | } | |
270 |
|
290 | |||
271 | void QBarModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) |
|
291 | void QBarModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) | |
272 | { |
|
292 | { | |
273 | Q_UNUSED(topLeft) |
|
293 | Q_UNUSED(topLeft) | |
274 | Q_UNUSED(bottomRight) |
|
294 | Q_UNUSED(bottomRight) | |
275 |
|
295 | |||
276 | if (m_model == 0 || m_series == 0) |
|
296 | if (m_model == 0 || m_series == 0) | |
277 | return; |
|
297 | return; | |
278 |
|
298 | |||
279 | if (m_modelSignalsBlock) |
|
299 | if (m_modelSignalsBlock) | |
280 | return; |
|
300 | return; | |
281 |
|
301 | |||
282 | blockSeriesSignals(); |
|
302 | blockSeriesSignals(); | |
283 | QModelIndex index; |
|
303 | QModelIndex index; | |
284 | for (int row = topLeft.row(); row <= bottomRight.row(); row++) { |
|
304 | for (int row = topLeft.row(); row <= bottomRight.row(); row++) { | |
285 | for (int column = topLeft.column(); column <= bottomRight.column(); column++) { |
|
305 | for (int column = topLeft.column(); column <= bottomRight.column(); column++) { | |
286 | index = topLeft.sibling(row, column); |
|
306 | index = topLeft.sibling(row, column); | |
287 | QBarSet* bar = barSet(index); |
|
307 | QBarSet* bar = barSet(index); | |
288 | if (bar) { |
|
308 | if (bar) { | |
289 | if (m_orientation == Qt::Vertical) |
|
309 | if (m_orientation == Qt::Vertical) | |
290 | bar->replace(row - m_first, m_model->data(index).toReal()); |
|
310 | bar->replace(row - m_first, m_model->data(index).toReal()); | |
291 | else |
|
311 | else | |
292 | bar->replace(column - m_first, m_model->data(index).toReal()); |
|
312 | bar->replace(column - m_first, m_model->data(index).toReal()); | |
293 | } |
|
313 | } | |
294 | } |
|
314 | } | |
295 | } |
|
315 | } | |
296 | blockSeriesSignals(false); |
|
316 | blockSeriesSignals(false); | |
297 | } |
|
317 | } | |
298 |
|
318 | |||
299 | void QBarModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end) |
|
319 | void QBarModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end) | |
300 | { |
|
320 | { | |
301 | Q_UNUSED(parent); |
|
321 | Q_UNUSED(parent); | |
302 | Q_UNUSED(end) |
|
322 | Q_UNUSED(end) | |
303 | if (m_modelSignalsBlock) |
|
323 | if (m_modelSignalsBlock) | |
304 | return; |
|
324 | return; | |
305 |
|
325 | |||
306 | blockSeriesSignals(); |
|
326 | blockSeriesSignals(); | |
307 | if (m_orientation == Qt::Vertical) |
|
327 | if (m_orientation == Qt::Vertical) | |
308 | // insertData(start, end); |
|
328 | // insertData(start, end); | |
309 | initializeBarFromModel(); |
|
329 | initializeBarFromModel(); | |
310 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize |
|
330 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize | |
311 | initializeBarFromModel(); |
|
331 | initializeBarFromModel(); | |
312 | blockSeriesSignals(false); |
|
332 | blockSeriesSignals(false); | |
313 | } |
|
333 | } | |
314 |
|
334 | |||
315 | void QBarModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end) |
|
335 | void QBarModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end) | |
316 | { |
|
336 | { | |
317 | Q_UNUSED(parent); |
|
337 | Q_UNUSED(parent); | |
318 | Q_UNUSED(end) |
|
338 | Q_UNUSED(end) | |
319 | if (m_modelSignalsBlock) |
|
339 | if (m_modelSignalsBlock) | |
320 | return; |
|
340 | return; | |
321 |
|
341 | |||
322 | blockSeriesSignals(); |
|
342 | blockSeriesSignals(); | |
323 | if (m_orientation == Qt::Vertical) |
|
343 | if (m_orientation == Qt::Vertical) | |
324 | // removeData(start, end); |
|
344 | // removeData(start, end); | |
325 | initializeBarFromModel(); |
|
345 | initializeBarFromModel(); | |
326 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize |
|
346 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize | |
327 | initializeBarFromModel(); |
|
347 | initializeBarFromModel(); | |
328 | blockSeriesSignals(false); |
|
348 | blockSeriesSignals(false); | |
329 | } |
|
349 | } | |
330 |
|
350 | |||
331 | void QBarModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end) |
|
351 | void QBarModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end) | |
332 | { |
|
352 | { | |
333 | Q_UNUSED(parent); |
|
353 | Q_UNUSED(parent); | |
334 | Q_UNUSED(end) |
|
354 | Q_UNUSED(end) | |
335 | if (m_modelSignalsBlock) |
|
355 | if (m_modelSignalsBlock) | |
336 | return; |
|
356 | return; | |
337 |
|
357 | |||
338 | blockSeriesSignals(); |
|
358 | blockSeriesSignals(); | |
339 | if (m_orientation == Qt::Horizontal) |
|
359 | if (m_orientation == Qt::Horizontal) | |
340 | // insertData(start, end); |
|
360 | // insertData(start, end); | |
341 | initializeBarFromModel(); |
|
361 | initializeBarFromModel(); | |
342 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize |
|
362 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize | |
343 | initializeBarFromModel(); |
|
363 | initializeBarFromModel(); | |
344 | blockSeriesSignals(false); |
|
364 | blockSeriesSignals(false); | |
345 | } |
|
365 | } | |
346 |
|
366 | |||
347 | void QBarModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end) |
|
367 | void QBarModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end) | |
348 | { |
|
368 | { | |
349 | Q_UNUSED(parent); |
|
369 | Q_UNUSED(parent); | |
350 | Q_UNUSED(end) |
|
370 | Q_UNUSED(end) | |
351 | if (m_modelSignalsBlock) |
|
371 | if (m_modelSignalsBlock) | |
352 | return; |
|
372 | return; | |
353 |
|
373 | |||
354 | blockSeriesSignals(); |
|
374 | blockSeriesSignals(); | |
355 | if (m_orientation == Qt::Horizontal) |
|
375 | if (m_orientation == Qt::Horizontal) | |
356 | // removeData(start, end); |
|
376 | // removeData(start, end); | |
357 | initializeBarFromModel(); |
|
377 | initializeBarFromModel(); | |
358 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize |
|
378 | else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize | |
359 | initializeBarFromModel(); |
|
379 | initializeBarFromModel(); | |
360 | blockSeriesSignals(false); |
|
380 | blockSeriesSignals(false); | |
361 | } |
|
381 | } | |
362 |
|
382 | |||
363 | void QBarModelMapperPrivate::insertData(int start, int end) |
|
383 | void QBarModelMapperPrivate::insertData(int start, int end) | |
364 | { |
|
384 | { | |
365 | Q_UNUSED(end) |
|
385 | Q_UNUSED(end) | |
366 | if (m_model == 0 || m_series == 0) |
|
386 | if (m_model == 0 || m_series == 0) | |
367 | return; |
|
387 | return; | |
368 |
|
388 | |||
369 | if (m_count != -1 && start >= m_first + m_count) { |
|
389 | if (m_count != -1 && start >= m_first + m_count) { | |
370 | return; |
|
390 | return; | |
371 | } /*else { |
|
391 | } /*else { | |
372 | int addedCount = end - start + 1; |
|
392 | int addedCount = end - start + 1; | |
373 | if (m_count != -1 && addedCount > m_count) |
|
393 | if (m_count != -1 && addedCount > m_count) | |
374 | addedCount = m_count; |
|
394 | addedCount = m_count; | |
375 | int first = qMax(start, m_first); |
|
395 | int first = qMax(start, m_first); | |
376 | int last = qMin(first + addedCount - 1, m_orientation == Qt::Vertical ? m_model->rowCount() - 1 : m_model->columnCount() - 1); |
|
396 | int last = qMin(first + addedCount - 1, m_orientation == Qt::Vertical ? m_model->rowCount() - 1 : m_model->columnCount() - 1); | |
377 | for (int k = 0; k < m_series->barSets().count(); k++) { |
|
397 | for (int k = 0; k < m_series->barSets().count(); k++) { | |
378 | for (int i = first; i <= last; i++) { |
|
398 | for (int i = first; i <= last; i++) { | |
379 | QBar point; |
|
399 | QBar point; | |
380 | point.setX(m_model->data(xModelIndex(i - m_first), Qt::DisplayRole).toDouble()); |
|
400 | point.setX(m_model->data(xModelIndex(i - m_first), Qt::DisplayRole).toDouble()); | |
381 | point.setY(m_model->data(yModelIndex(i - m_first), Qt::DisplayRole).toDouble()); |
|
401 | point.setY(m_model->data(yModelIndex(i - m_first), Qt::DisplayRole).toDouble()); | |
382 | m_series->insert(i - m_first, point); |
|
402 | m_series->insert(i - m_first, point); | |
383 | } |
|
403 | } | |
384 | >>>>>>> Stashed changes |
|
404 | >>>>>>> Stashed changes | |
385 | } |
|
405 | } | |
386 |
|
406 | |||
387 | // remove excess of slices (abouve m_count) |
|
407 | // remove excess of slices (abouve m_count) | |
388 | if (m_count != -1 && m_series->points().size() > m_count) |
|
408 | if (m_count != -1 && m_series->points().size() > m_count) | |
389 | for (int i = m_series->points().size() - 1; i >= m_count; i--) { |
|
409 | for (int i = m_series->points().size() - 1; i >= m_count; i--) { | |
390 | m_series->remove(m_series->points().at(i)); |
|
410 | m_series->remove(m_series->points().at(i)); | |
391 | } |
|
411 | } | |
392 | }*/ |
|
412 | }*/ | |
393 | } |
|
413 | } | |
394 |
|
414 | |||
395 | void QBarModelMapperPrivate::removeData(int start, int end) |
|
415 | void QBarModelMapperPrivate::removeData(int start, int end) | |
396 | { |
|
416 | { | |
397 | Q_UNUSED(end) |
|
417 | Q_UNUSED(end) | |
398 | if (m_model == 0 || m_series == 0) |
|
418 | if (m_model == 0 || m_series == 0) | |
399 | return; |
|
419 | return; | |
400 |
|
420 | |||
401 | // int removedCount = end - start + 1; |
|
421 | // int removedCount = end - start + 1; | |
402 | if (m_count != -1 && start >= m_first + m_count) { |
|
422 | if (m_count != -1 && start >= m_first + m_count) { | |
403 | return; |
|
423 | return; | |
404 | } /*else { |
|
424 | } /*else { | |
405 | int toRemove = qMin(m_series->count(), removedCount); // first find how many items can actually be removed |
|
425 | int toRemove = qMin(m_series->count(), removedCount); // first find how many items can actually be removed | |
406 | int first = qMax(start, m_first); // get the index of the first item that will be removed. |
|
426 | int first = qMax(start, m_first); // get the index of the first item that will be removed. | |
407 | int last = qMin(first + toRemove - 1, m_series->count() + m_first - 1); // get the index of the last item that will be removed. |
|
427 | int last = qMin(first + toRemove - 1, m_series->count() + m_first - 1); // get the index of the last item that will be removed. | |
408 | for (int i = last; i >= first; i--) { |
|
428 | for (int i = last; i >= first; i--) { | |
409 | m_series->remove(m_series->points().at(i - m_first)); |
|
429 | m_series->remove(m_series->points().at(i - m_first)); | |
410 | } |
|
430 | } | |
411 |
|
431 | |||
412 | if (m_count != -1) { |
|
432 | if (m_count != -1) { | |
413 | int itemsAvailable; // check how many are available to be added |
|
433 | int itemsAvailable; // check how many are available to be added | |
414 | if (m_orientation == Qt::Vertical) |
|
434 | if (m_orientation == Qt::Vertical) | |
415 | itemsAvailable = m_model->rowCount() - m_first - m_series->count(); |
|
435 | itemsAvailable = m_model->rowCount() - m_first - m_series->count(); | |
416 | else |
|
436 | else | |
417 | itemsAvailable = m_model->columnCount() - m_first - m_series->count(); |
|
437 | itemsAvailable = m_model->columnCount() - m_first - m_series->count(); | |
418 | int toBeAdded = qMin(itemsAvailable, m_count - m_series->count()); // add not more items than there is space left to be filled. |
|
438 | int toBeAdded = qMin(itemsAvailable, m_count - m_series->count()); // add not more items than there is space left to be filled. | |
419 | int currentSize = m_series->count(); |
|
439 | int currentSize = m_series->count(); | |
420 | if (toBeAdded > 0) |
|
440 | if (toBeAdded > 0) | |
421 | for (int i = m_series->count(); i < currentSize + toBeAdded; i++) { |
|
441 | for (int i = m_series->count(); i < currentSize + toBeAdded; i++) { | |
422 | QPointF point; |
|
442 | QPointF point; | |
423 | point.setX(m_model->data(xModelIndex(i), Qt::DisplayRole).toDouble()); |
|
443 | point.setX(m_model->data(xModelIndex(i), Qt::DisplayRole).toDouble()); | |
424 | point.setY(m_model->data(yModelIndex(i), Qt::DisplayRole).toDouble()); |
|
444 | point.setY(m_model->data(yModelIndex(i), Qt::DisplayRole).toDouble()); | |
425 | m_series->insert(i, point); |
|
445 | m_series->insert(i, point); | |
426 | } |
|
446 | } | |
427 | } |
|
447 | } | |
428 | }*/ |
|
448 | }*/ | |
429 | } |
|
449 | } | |
430 |
|
450 | |||
431 | void QBarModelMapperPrivate::initializeBarFromModel() |
|
451 | void QBarModelMapperPrivate::initializeBarFromModel() | |
432 | { |
|
452 | { | |
433 | if (m_model == 0 || m_series == 0) |
|
453 | if (m_model == 0 || m_series == 0) | |
434 | return; |
|
454 | return; | |
435 |
|
455 | |||
436 | blockSeriesSignals(); |
|
456 | blockSeriesSignals(); | |
437 | // clear current content |
|
457 | // clear current content | |
438 | m_series->clear(); |
|
458 | m_series->clear(); | |
439 |
|
459 | |||
440 | // create the initial bar sets |
|
460 | // create the initial bar sets | |
441 | for (int i = m_firstBarSetSection; i <= m_lastBarSetSection; i++) { |
|
461 | for (int i = m_firstBarSetSection; i <= m_lastBarSetSection; i++) { | |
442 | int posInBar = 0; |
|
462 | int posInBar = 0; | |
443 | QModelIndex barIndex = barModelIndex(i, posInBar); |
|
463 | QModelIndex barIndex = barModelIndex(i, posInBar); | |
444 | QBarSet *barSet = new QBarSet(m_model->headerData(i, Qt::Horizontal).toString()); |
|
464 | QBarSet *barSet = new QBarSet(m_model->headerData(i, Qt::Horizontal).toString()); | |
445 | while (barIndex.isValid()) { |
|
465 | while (barIndex.isValid()) { | |
446 | barSet->append(m_model->data(barIndex, Qt::DisplayRole).toDouble()); |
|
466 | barSet->append(m_model->data(barIndex, Qt::DisplayRole).toDouble()); | |
447 | posInBar++; |
|
467 | posInBar++; | |
448 | barIndex = barModelIndex(i, posInBar); |
|
468 | barIndex = barModelIndex(i, posInBar); | |
449 | } |
|
469 | } | |
450 | m_series->append(barSet); |
|
470 | m_series->append(barSet); | |
451 | } |
|
471 | } | |
452 | blockSeriesSignals(false); |
|
472 | blockSeriesSignals(false); | |
453 | } |
|
473 | } | |
454 |
|
474 | |||
455 | #include "moc_qbarmodelmapper.cpp" |
|
475 | #include "moc_qbarmodelmapper.cpp" | |
456 | #include "moc_qbarmodelmapper_p.cpp" |
|
476 | #include "moc_qbarmodelmapper_p.cpp" | |
457 |
|
477 | |||
458 | QTCOMMERCIALCHART_END_NAMESPACE |
|
478 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,59 +1,79 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
1 | #ifndef QBARMODELMAPPER_H |
|
21 | #ifndef QBARMODELMAPPER_H | |
2 | #define QBARMODELMAPPER_H |
|
22 | #define QBARMODELMAPPER_H | |
3 |
|
23 | |||
4 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
5 | #include <QObject> |
|
25 | #include <QObject> | |
6 |
|
26 | |||
7 | class QAbstractItemModel; |
|
27 | class QAbstractItemModel; | |
8 |
|
28 | |||
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
10 |
|
30 | |||
11 | class QBarModelMapperPrivate; |
|
31 | class QBarModelMapperPrivate; | |
12 | class QBarSeries; |
|
32 | class QBarSeries; | |
13 | class QChart; |
|
33 | class QChart; | |
14 |
|
34 | |||
15 | class QTCOMMERCIALCHART_EXPORT QBarModelMapper : public QObject |
|
35 | class QTCOMMERCIALCHART_EXPORT QBarModelMapper : public QObject | |
16 | { |
|
36 | { | |
17 | Q_OBJECT |
|
37 | Q_OBJECT | |
18 | Q_PROPERTY(QBarSeries *series READ series WRITE setSeries) |
|
38 | Q_PROPERTY(QBarSeries *series READ series WRITE setSeries) | |
19 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel) |
|
39 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel) | |
20 | Q_PROPERTY(int first READ first WRITE setFirst) |
|
40 | Q_PROPERTY(int first READ first WRITE setFirst) | |
21 | Q_PROPERTY(int count READ count WRITE setCount) |
|
41 | Q_PROPERTY(int count READ count WRITE setCount) | |
22 | Q_ENUMS(Qt::Orientation) |
|
42 | Q_ENUMS(Qt::Orientation) | |
23 |
|
43 | |||
24 | protected: |
|
44 | protected: | |
25 | explicit QBarModelMapper(QObject *parent = 0); |
|
45 | explicit QBarModelMapper(QObject *parent = 0); | |
26 |
|
46 | |||
27 | public: |
|
47 | public: | |
28 | QAbstractItemModel* model() const; |
|
48 | QAbstractItemModel* model() const; | |
29 | void setModel(QAbstractItemModel *model); |
|
49 | void setModel(QAbstractItemModel *model); | |
30 |
|
50 | |||
31 | QBarSeries* series() const; |
|
51 | QBarSeries* series() const; | |
32 | void setSeries(QBarSeries *series); |
|
52 | void setSeries(QBarSeries *series); | |
33 |
|
53 | |||
34 | int first() const; |
|
54 | int first() const; | |
35 | void setFirst(int first); |
|
55 | void setFirst(int first); | |
36 |
|
56 | |||
37 | int count() const; |
|
57 | int count() const; | |
38 | void setCount(int count); |
|
58 | void setCount(int count); | |
39 |
|
59 | |||
40 | void reset(); |
|
60 | void reset(); | |
41 |
|
61 | |||
42 | protected: |
|
62 | protected: | |
43 | int firstBarSetSection() const; |
|
63 | int firstBarSetSection() const; | |
44 | void setFirstBarSetSection(int firstBarSetSection); |
|
64 | void setFirstBarSetSection(int firstBarSetSection); | |
45 |
|
65 | |||
46 | int lastBarSetSection() const; |
|
66 | int lastBarSetSection() const; | |
47 | void setLastBarSetSection(int lastBarSetSection); |
|
67 | void setLastBarSetSection(int lastBarSetSection); | |
48 |
|
68 | |||
49 | Qt::Orientation orientation() const; |
|
69 | Qt::Orientation orientation() const; | |
50 | void setOrientation(Qt::Orientation orientation); |
|
70 | void setOrientation(Qt::Orientation orientation); | |
51 |
|
71 | |||
52 | protected: |
|
72 | protected: | |
53 | QBarModelMapperPrivate * const d_ptr; |
|
73 | QBarModelMapperPrivate * const d_ptr; | |
54 | Q_DECLARE_PRIVATE(QBarModelMapper) |
|
74 | Q_DECLARE_PRIVATE(QBarModelMapper) | |
55 | }; |
|
75 | }; | |
56 |
|
76 | |||
57 | QTCOMMERCIALCHART_END_NAMESPACE |
|
77 | QTCOMMERCIALCHART_END_NAMESPACE | |
58 |
|
78 | |||
59 | #endif // QBARMODELMAPPER_H |
|
79 | #endif // QBARMODELMAPPER_H |
@@ -1,61 +1,90 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | // W A R N I N G | |||
|
22 | // ------------- | |||
|
23 | // | |||
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |||
|
25 | // implementation detail. This header file may change from version to | |||
|
26 | // version without notice, or even be removed. | |||
|
27 | // | |||
|
28 | // We mean it. | |||
|
29 | ||||
1 | #ifndef QBARMODELMAPPER_P_H |
|
30 | #ifndef QBARMODELMAPPER_P_H | |
2 | #define QBARMODELMAPPER_P_H |
|
31 | #define QBARMODELMAPPER_P_H | |
3 |
|
32 | |||
4 | #include "qchartglobal.h" |
|
33 | #include "qchartglobal.h" | |
5 | #include <QObject> |
|
34 | #include <QObject> | |
6 | #include "qbarmodelmapper.h" |
|
35 | #include "qbarmodelmapper.h" | |
7 |
|
36 | |||
8 | class QModelIndex; |
|
37 | class QModelIndex; | |
9 |
|
38 | |||
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
39 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
11 |
|
40 | |||
12 | class QBarSet; |
|
41 | class QBarSet; | |
13 |
|
42 | |||
14 | class QBarModelMapperPrivate : public QObject |
|
43 | class QBarModelMapperPrivate : public QObject | |
15 | { |
|
44 | { | |
16 | Q_OBJECT |
|
45 | Q_OBJECT | |
17 | public: |
|
46 | public: | |
18 | explicit QBarModelMapperPrivate(QBarModelMapper *q); |
|
47 | explicit QBarModelMapperPrivate(QBarModelMapper *q); | |
19 |
|
48 | |||
20 | public Q_SLOTS: |
|
49 | public Q_SLOTS: | |
21 | // for the model |
|
50 | // for the model | |
22 | void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); |
|
51 | void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); | |
23 | void modelRowsAdded(QModelIndex parent, int start, int end); |
|
52 | void modelRowsAdded(QModelIndex parent, int start, int end); | |
24 | void modelRowsRemoved(QModelIndex parent, int start, int end); |
|
53 | void modelRowsRemoved(QModelIndex parent, int start, int end); | |
25 | void modelColumnsAdded(QModelIndex parent, int start, int end); |
|
54 | void modelColumnsAdded(QModelIndex parent, int start, int end); | |
26 | void modelColumnsRemoved(QModelIndex parent, int start, int end); |
|
55 | void modelColumnsRemoved(QModelIndex parent, int start, int end); | |
27 |
|
56 | |||
28 | // // for the series |
|
57 | // // for the series | |
29 | // void handlePointAdded(int pointPos); |
|
58 | // void handlePointAdded(int pointPos); | |
30 | // void handlePointRemoved(int pointPos); |
|
59 | // void handlePointRemoved(int pointPos); | |
31 | // void handlePointReplaced(int pointPos); |
|
60 | // void handlePointReplaced(int pointPos); | |
32 |
|
61 | |||
33 | void initializeBarFromModel(); |
|
62 | void initializeBarFromModel(); | |
34 |
|
63 | |||
35 | private: |
|
64 | private: | |
36 | QBarSet* barSet(QModelIndex index); |
|
65 | QBarSet* barSet(QModelIndex index); | |
37 | QModelIndex barModelIndex(int barSection, int posInBar); |
|
66 | QModelIndex barModelIndex(int barSection, int posInBar); | |
38 | void insertData(int start, int end); |
|
67 | void insertData(int start, int end); | |
39 | void removeData(int start, int end); |
|
68 | void removeData(int start, int end); | |
40 | void blockModelSignals(bool block = true); |
|
69 | void blockModelSignals(bool block = true); | |
41 | void blockSeriesSignals(bool block = true); |
|
70 | void blockSeriesSignals(bool block = true); | |
42 |
|
71 | |||
43 | private: |
|
72 | private: | |
44 | QBarSeries *m_series; |
|
73 | QBarSeries *m_series; | |
45 | QAbstractItemModel *m_model; |
|
74 | QAbstractItemModel *m_model; | |
46 | int m_first; |
|
75 | int m_first; | |
47 | int m_count; |
|
76 | int m_count; | |
48 | Qt::Orientation m_orientation; |
|
77 | Qt::Orientation m_orientation; | |
49 | int m_firstBarSetSection; |
|
78 | int m_firstBarSetSection; | |
50 | int m_lastBarSetSection; |
|
79 | int m_lastBarSetSection; | |
51 | bool m_seriesSignalsBlock; |
|
80 | bool m_seriesSignalsBlock; | |
52 | bool m_modelSignalsBlock; |
|
81 | bool m_modelSignalsBlock; | |
53 |
|
82 | |||
54 | private: |
|
83 | private: | |
55 | QBarModelMapper *q_ptr; |
|
84 | QBarModelMapper *q_ptr; | |
56 | Q_DECLARE_PUBLIC(QBarModelMapper) |
|
85 | Q_DECLARE_PUBLIC(QBarModelMapper) | |
57 | }; |
|
86 | }; | |
58 |
|
87 | |||
59 | QTCOMMERCIALCHART_END_NAMESPACE |
|
88 | QTCOMMERCIALCHART_END_NAMESPACE | |
60 |
|
89 | |||
61 | #endif // QBARMODELMAPPER_P_H |
|
90 | #endif // QBARMODELMAPPER_P_H |
@@ -1,58 +1,78 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
1 | #include "qhbarmodelmapper.h" |
|
21 | #include "qhbarmodelmapper.h" | |
2 |
|
22 | |||
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
4 |
|
24 | |||
5 | /*! |
|
25 | /*! | |
6 | \class QHBarModelMapper |
|
26 | \class QHBarModelMapper | |
7 | \brief part of QtCommercial chart API. |
|
27 | \brief part of QtCommercial chart API. | |
8 | \mainclass |
|
28 | \mainclass | |
9 |
|
29 | |||
10 | Nothing here yet |
|
30 | Nothing here yet | |
11 | */ |
|
31 | */ | |
12 |
|
32 | |||
13 | /*! |
|
33 | /*! | |
14 | \property QHBarModelMapper::firstBarSetRow |
|
34 | \property QHBarModelMapper::firstBarSetRow | |
15 | \brief Defines which column of the model is used as the data source for the first bar set |
|
35 | \brief Defines which column of the model is used as the data source for the first bar set | |
16 |
|
36 | |||
17 | Default value is: -1 (invalid mapping) |
|
37 | Default value is: -1 (invalid mapping) | |
18 | */ |
|
38 | */ | |
19 |
|
39 | |||
20 | /*! |
|
40 | /*! | |
21 | \property QHBarModelMapper::lastBarSetRow |
|
41 | \property QHBarModelMapper::lastBarSetRow | |
22 | \brief Defines which column of the model is used as the data source for the last bar set |
|
42 | \brief Defines which column of the model is used as the data source for the last bar set | |
23 |
|
43 | |||
24 | Default value is: -1 (invalid mapping) |
|
44 | Default value is: -1 (invalid mapping) | |
25 | */ |
|
45 | */ | |
26 |
|
46 | |||
27 | /*! |
|
47 | /*! | |
28 | Constructs a mapper object which is a child of \a parent. |
|
48 | Constructs a mapper object which is a child of \a parent. | |
29 | */ |
|
49 | */ | |
30 | QHBarModelMapper::QHBarModelMapper(QObject *parent) : |
|
50 | QHBarModelMapper::QHBarModelMapper(QObject *parent) : | |
31 | QBarModelMapper(parent) |
|
51 | QBarModelMapper(parent) | |
32 | { |
|
52 | { | |
33 | QBarModelMapper::setOrientation(Qt::Horizontal); |
|
53 | QBarModelMapper::setOrientation(Qt::Horizontal); | |
34 | } |
|
54 | } | |
35 |
|
55 | |||
36 | int QHBarModelMapper::firstBarSetRow() const |
|
56 | int QHBarModelMapper::firstBarSetRow() const | |
37 | { |
|
57 | { | |
38 | return QBarModelMapper::firstBarSetSection(); |
|
58 | return QBarModelMapper::firstBarSetSection(); | |
39 | } |
|
59 | } | |
40 |
|
60 | |||
41 | void QHBarModelMapper::setFirstBarSetRow(int firstBarSetRow) |
|
61 | void QHBarModelMapper::setFirstBarSetRow(int firstBarSetRow) | |
42 | { |
|
62 | { | |
43 | return QBarModelMapper::setFirstBarSetSection(firstBarSetRow); |
|
63 | return QBarModelMapper::setFirstBarSetSection(firstBarSetRow); | |
44 | } |
|
64 | } | |
45 |
|
65 | |||
46 | int QHBarModelMapper::lastBarSetRow() const |
|
66 | int QHBarModelMapper::lastBarSetRow() const | |
47 | { |
|
67 | { | |
48 | return QBarModelMapper::lastBarSetSection(); |
|
68 | return QBarModelMapper::lastBarSetSection(); | |
49 | } |
|
69 | } | |
50 |
|
70 | |||
51 | void QHBarModelMapper::setLastBarSetRow(int lastBarSetRow) |
|
71 | void QHBarModelMapper::setLastBarSetRow(int lastBarSetRow) | |
52 | { |
|
72 | { | |
53 | return QBarModelMapper::setLastBarSetSection(lastBarSetRow); |
|
73 | return QBarModelMapper::setLastBarSetSection(lastBarSetRow); | |
54 | } |
|
74 | } | |
55 |
|
75 | |||
56 | #include "moc_qhbarmodelmapper.cpp" |
|
76 | #include "moc_qhbarmodelmapper.cpp" | |
57 |
|
77 | |||
58 | QTCOMMERCIALCHART_END_NAMESPACE |
|
78 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,26 +1,46 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
1 | #ifndef QHBARMODELMAPPER_H |
|
21 | #ifndef QHBARMODELMAPPER_H | |
2 | #define QHBARMODELMAPPER_H |
|
22 | #define QHBARMODELMAPPER_H | |
3 |
|
23 | |||
4 | #include <QBarModelMapper> |
|
24 | #include <QBarModelMapper> | |
5 |
|
25 | |||
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
7 |
|
27 | |||
8 | class QTCOMMERCIALCHART_EXPORT QHBarModelMapper : public QBarModelMapper |
|
28 | class QTCOMMERCIALCHART_EXPORT QHBarModelMapper : public QBarModelMapper | |
9 | { |
|
29 | { | |
10 | Q_OBJECT |
|
30 | Q_OBJECT | |
11 | Q_PROPERTY(int firstBarSetRow READ firstBarSetRow WRITE setFirstBarSetRow) |
|
31 | Q_PROPERTY(int firstBarSetRow READ firstBarSetRow WRITE setFirstBarSetRow) | |
12 | Q_PROPERTY(int lastBarSetRow READ lastBarSetRow WRITE setLastBarSetRow) |
|
32 | Q_PROPERTY(int lastBarSetRow READ lastBarSetRow WRITE setLastBarSetRow) | |
13 |
|
33 | |||
14 | public: |
|
34 | public: | |
15 | explicit QHBarModelMapper(QObject *parent = 0); |
|
35 | explicit QHBarModelMapper(QObject *parent = 0); | |
16 |
|
36 | |||
17 | int firstBarSetRow() const; |
|
37 | int firstBarSetRow() const; | |
18 | void setFirstBarSetRow(int firstBarSetRow); |
|
38 | void setFirstBarSetRow(int firstBarSetRow); | |
19 |
|
39 | |||
20 | int lastBarSetRow() const; |
|
40 | int lastBarSetRow() const; | |
21 | void setLastBarSetRow(int lastBarSetRow); |
|
41 | void setLastBarSetRow(int lastBarSetRow); | |
22 | }; |
|
42 | }; | |
23 |
|
43 | |||
24 | QTCOMMERCIALCHART_END_NAMESPACE |
|
44 | QTCOMMERCIALCHART_END_NAMESPACE | |
25 |
|
45 | |||
26 | #endif // QHBARMODELMAPPER_H |
|
46 | #endif // QHBARMODELMAPPER_H |
@@ -1,58 +1,78 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
1 | #include "qvbarmodelmapper.h" |
|
21 | #include "qvbarmodelmapper.h" | |
2 |
|
22 | |||
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
4 |
|
24 | |||
5 | /*! |
|
25 | /*! | |
6 | \class QVBarModelMapper |
|
26 | \class QVBarModelMapper | |
7 | \brief part of QtCommercial chart API. |
|
27 | \brief part of QtCommercial chart API. | |
8 | \mainclass |
|
28 | \mainclass | |
9 |
|
29 | |||
10 | Nothing here yet |
|
30 | Nothing here yet | |
11 | */ |
|
31 | */ | |
12 |
|
32 | |||
13 | /*! |
|
33 | /*! | |
14 | \property QVBarModelMapper::firstBarSetColumn |
|
34 | \property QVBarModelMapper::firstBarSetColumn | |
15 | \brief Defines which column of the model is used as the data source for the first bar set |
|
35 | \brief Defines which column of the model is used as the data source for the first bar set | |
16 |
|
36 | |||
17 | Default value is: -1 (invalid mapping) |
|
37 | Default value is: -1 (invalid mapping) | |
18 | */ |
|
38 | */ | |
19 |
|
39 | |||
20 | /*! |
|
40 | /*! | |
21 | \property QVBarModelMapper::lastBarSetColumn |
|
41 | \property QVBarModelMapper::lastBarSetColumn | |
22 | \brief Defines which column of the model is used as the data source for the last bar set |
|
42 | \brief Defines which column of the model is used as the data source for the last bar set | |
23 |
|
43 | |||
24 | Default value is: -1 (invalid mapping) |
|
44 | Default value is: -1 (invalid mapping) | |
25 | */ |
|
45 | */ | |
26 |
|
46 | |||
27 | /*! |
|
47 | /*! | |
28 | Constructs a mapper object which is a child of \a parent. |
|
48 | Constructs a mapper object which is a child of \a parent. | |
29 | */ |
|
49 | */ | |
30 | QVBarModelMapper::QVBarModelMapper(QObject *parent) : |
|
50 | QVBarModelMapper::QVBarModelMapper(QObject *parent) : | |
31 | QBarModelMapper(parent) |
|
51 | QBarModelMapper(parent) | |
32 | { |
|
52 | { | |
33 | QBarModelMapper::setOrientation(Qt::Vertical); |
|
53 | QBarModelMapper::setOrientation(Qt::Vertical); | |
34 | } |
|
54 | } | |
35 |
|
55 | |||
36 | int QVBarModelMapper::firstBarSetColumn() const |
|
56 | int QVBarModelMapper::firstBarSetColumn() const | |
37 | { |
|
57 | { | |
38 | return QBarModelMapper::firstBarSetSection(); |
|
58 | return QBarModelMapper::firstBarSetSection(); | |
39 | } |
|
59 | } | |
40 |
|
60 | |||
41 | void QVBarModelMapper::setFirstBarSetColumn(int firstBarSetColumn) |
|
61 | void QVBarModelMapper::setFirstBarSetColumn(int firstBarSetColumn) | |
42 | { |
|
62 | { | |
43 | return QBarModelMapper::setFirstBarSetSection(firstBarSetColumn); |
|
63 | return QBarModelMapper::setFirstBarSetSection(firstBarSetColumn); | |
44 | } |
|
64 | } | |
45 |
|
65 | |||
46 | int QVBarModelMapper::lastBarSetColumn() const |
|
66 | int QVBarModelMapper::lastBarSetColumn() const | |
47 | { |
|
67 | { | |
48 | return QBarModelMapper::lastBarSetSection(); |
|
68 | return QBarModelMapper::lastBarSetSection(); | |
49 | } |
|
69 | } | |
50 |
|
70 | |||
51 | void QVBarModelMapper::setLastBarSetColumn(int lastBarSetColumn) |
|
71 | void QVBarModelMapper::setLastBarSetColumn(int lastBarSetColumn) | |
52 | { |
|
72 | { | |
53 | return QBarModelMapper::setLastBarSetSection(lastBarSetColumn); |
|
73 | return QBarModelMapper::setLastBarSetSection(lastBarSetColumn); | |
54 | } |
|
74 | } | |
55 |
|
75 | |||
56 | #include "moc_qvbarmodelmapper.cpp" |
|
76 | #include "moc_qvbarmodelmapper.cpp" | |
57 |
|
77 | |||
58 | QTCOMMERCIALCHART_END_NAMESPACE |
|
78 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,26 +1,46 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
1 | #ifndef QVBARMODELMAPPER_H |
|
21 | #ifndef QVBARMODELMAPPER_H | |
2 | #define QVBARMODELMAPPER_H |
|
22 | #define QVBARMODELMAPPER_H | |
3 |
|
23 | |||
4 | #include <QBarModelMapper> |
|
24 | #include <QBarModelMapper> | |
5 |
|
25 | |||
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
7 |
|
27 | |||
8 | class QTCOMMERCIALCHART_EXPORT QVBarModelMapper : public QBarModelMapper |
|
28 | class QTCOMMERCIALCHART_EXPORT QVBarModelMapper : public QBarModelMapper | |
9 | { |
|
29 | { | |
10 | Q_OBJECT |
|
30 | Q_OBJECT | |
11 | Q_PROPERTY(int firstBarSetColumn READ firstBarSetColumn WRITE setFirstBarSetColumn) |
|
31 | Q_PROPERTY(int firstBarSetColumn READ firstBarSetColumn WRITE setFirstBarSetColumn) | |
12 | Q_PROPERTY(int lastBarSetColumn READ lastBarSetColumn WRITE setLastBarSetColumn) |
|
32 | Q_PROPERTY(int lastBarSetColumn READ lastBarSetColumn WRITE setLastBarSetColumn) | |
13 |
|
33 | |||
14 | public: |
|
34 | public: | |
15 | explicit QVBarModelMapper(QObject *parent = 0); |
|
35 | explicit QVBarModelMapper(QObject *parent = 0); | |
16 |
|
36 | |||
17 | int firstBarSetColumn() const; |
|
37 | int firstBarSetColumn() const; | |
18 | void setFirstBarSetColumn(int firstBarSetColumn); |
|
38 | void setFirstBarSetColumn(int firstBarSetColumn); | |
19 |
|
39 | |||
20 | int lastBarSetColumn() const; |
|
40 | int lastBarSetColumn() const; | |
21 | void setLastBarSetColumn(int lastBarSetColumn); |
|
41 | void setLastBarSetColumn(int lastBarSetColumn); | |
22 | }; |
|
42 | }; | |
23 |
|
43 | |||
24 | QTCOMMERCIALCHART_END_NAMESPACE |
|
44 | QTCOMMERCIALCHART_END_NAMESPACE | |
25 |
|
45 | |||
26 | #endif // QVBARMODELMAPPER_H |
|
46 | #endif // QVBARMODELMAPPER_H |
@@ -1,57 +1,77 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
1 | #include "qhxymodelmapper.h" |
|
21 | #include "qhxymodelmapper.h" | |
2 |
|
22 | |||
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
4 |
|
24 | |||
5 | /*! |
|
25 | /*! | |
6 | \class QHXYModelMapper |
|
26 | \class QHXYModelMapper | |
7 | \brief part of QtCommercial chart API. |
|
27 | \brief part of QtCommercial chart API. | |
8 | \mainclass |
|
28 | \mainclass | |
9 |
|
29 | |||
10 | Nothing here yet |
|
30 | Nothing here yet | |
11 | */ |
|
31 | */ | |
12 |
|
32 | |||
13 | /*! |
|
33 | /*! | |
14 | \property QHXYModelMapper::xRow |
|
34 | \property QHXYModelMapper::xRow | |
15 | \brief Defines which row of the model is kept in sync with the x values of the QXYSeries |
|
35 | \brief Defines which row of the model is kept in sync with the x values of the QXYSeries | |
16 | Default value is: -1 (invalid mapping) |
|
36 | Default value is: -1 (invalid mapping) | |
17 | */ |
|
37 | */ | |
18 |
|
38 | |||
19 | /*! |
|
39 | /*! | |
20 | \property QHXYModelMapper::yRow |
|
40 | \property QHXYModelMapper::yRow | |
21 | \brief Defines which row of the model is kept in sync with the y values of the QXYSeries |
|
41 | \brief Defines which row of the model is kept in sync with the y values of the QXYSeries | |
22 |
|
42 | |||
23 | Default value is: -1 (invalid mapping) |
|
43 | Default value is: -1 (invalid mapping) | |
24 | */ |
|
44 | */ | |
25 |
|
45 | |||
26 | /*! |
|
46 | /*! | |
27 | Constructs a mapper object which is a child of \a parent. |
|
47 | Constructs a mapper object which is a child of \a parent. | |
28 | */ |
|
48 | */ | |
29 | QHXYModelMapper::QHXYModelMapper(QObject *parent) : |
|
49 | QHXYModelMapper::QHXYModelMapper(QObject *parent) : | |
30 | QXYModelMapper(parent) |
|
50 | QXYModelMapper(parent) | |
31 | { |
|
51 | { | |
32 | QXYModelMapper::setOrientation(Qt::Horizontal); |
|
52 | QXYModelMapper::setOrientation(Qt::Horizontal); | |
33 | } |
|
53 | } | |
34 |
|
54 | |||
35 | int QHXYModelMapper::xRow() const |
|
55 | int QHXYModelMapper::xRow() const | |
36 | { |
|
56 | { | |
37 | return QXYModelMapper::xSection(); |
|
57 | return QXYModelMapper::xSection(); | |
38 | } |
|
58 | } | |
39 |
|
59 | |||
40 | void QHXYModelMapper::setXRow(int xRow) |
|
60 | void QHXYModelMapper::setXRow(int xRow) | |
41 | { |
|
61 | { | |
42 | return QXYModelMapper::setXSection(xRow); |
|
62 | return QXYModelMapper::setXSection(xRow); | |
43 | } |
|
63 | } | |
44 |
|
64 | |||
45 | int QHXYModelMapper::yRow() const |
|
65 | int QHXYModelMapper::yRow() const | |
46 | { |
|
66 | { | |
47 | return QXYModelMapper::ySection(); |
|
67 | return QXYModelMapper::ySection(); | |
48 | } |
|
68 | } | |
49 |
|
69 | |||
50 | void QHXYModelMapper::setYRow(int yRow) |
|
70 | void QHXYModelMapper::setYRow(int yRow) | |
51 | { |
|
71 | { | |
52 | return QXYModelMapper::setYSection(yRow); |
|
72 | return QXYModelMapper::setYSection(yRow); | |
53 | } |
|
73 | } | |
54 |
|
74 | |||
55 | #include "moc_qhxymodelmapper.cpp" |
|
75 | #include "moc_qhxymodelmapper.cpp" | |
56 |
|
76 | |||
57 | QTCOMMERCIALCHART_END_NAMESPACE |
|
77 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,27 +1,47 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
1 | #ifndef QHXYMODELMAPPER_H |
|
21 | #ifndef QHXYMODELMAPPER_H | |
2 | #define QHXYMODELMAPPER_H |
|
22 | #define QHXYMODELMAPPER_H | |
3 |
|
23 | |||
4 | #include <QXYModelMapper> |
|
24 | #include <QXYModelMapper> | |
5 |
|
25 | |||
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
7 |
|
27 | |||
8 | class QTCOMMERCIALCHART_EXPORT QHXYModelMapper : public QXYModelMapper |
|
28 | class QTCOMMERCIALCHART_EXPORT QHXYModelMapper : public QXYModelMapper | |
9 | { |
|
29 | { | |
10 | Q_OBJECT |
|
30 | Q_OBJECT | |
11 | Q_PROPERTY(int xRow READ xRow WRITE setXRow) |
|
31 | Q_PROPERTY(int xRow READ xRow WRITE setXRow) | |
12 | Q_PROPERTY(int yRow READ yRow WRITE setYRow) |
|
32 | Q_PROPERTY(int yRow READ yRow WRITE setYRow) | |
13 |
|
33 | |||
14 | public: |
|
34 | public: | |
15 | explicit QHXYModelMapper(QObject *parent = 0); |
|
35 | explicit QHXYModelMapper(QObject *parent = 0); | |
16 |
|
36 | |||
17 | int xRow() const; |
|
37 | int xRow() const; | |
18 | void setXRow(int xRow); |
|
38 | void setXRow(int xRow); | |
19 |
|
39 | |||
20 | int yRow() const; |
|
40 | int yRow() const; | |
21 | void setYRow(int yRow); |
|
41 | void setYRow(int yRow); | |
22 |
|
42 | |||
23 | }; |
|
43 | }; | |
24 |
|
44 | |||
25 | QTCOMMERCIALCHART_END_NAMESPACE |
|
45 | QTCOMMERCIALCHART_END_NAMESPACE | |
26 |
|
46 | |||
27 | #endif // QHXYMODELMAPPER_H |
|
47 | #endif // QHXYMODELMAPPER_H |
@@ -1,58 +1,78 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
1 | #include "qvxymodelmapper.h" |
|
21 | #include "qvxymodelmapper.h" | |
2 |
|
22 | |||
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
4 |
|
24 | |||
5 | /*! |
|
25 | /*! | |
6 | \class QVXYModelMapper |
|
26 | \class QVXYModelMapper | |
7 | \brief part of QtCommercial chart API. |
|
27 | \brief part of QtCommercial chart API. | |
8 | \mainclass |
|
28 | \mainclass | |
9 |
|
29 | |||
10 | Nothing here yet |
|
30 | Nothing here yet | |
11 | */ |
|
31 | */ | |
12 |
|
32 | |||
13 | /*! |
|
33 | /*! | |
14 | \property QVXYModelMapper::xColumn |
|
34 | \property QVXYModelMapper::xColumn | |
15 | \brief Defines which column of the model is kept in sync with the x values of QXYSeries |
|
35 | \brief Defines which column of the model is kept in sync with the x values of QXYSeries | |
16 |
|
36 | |||
17 | Default value is: -1 (invalid mapping) |
|
37 | Default value is: -1 (invalid mapping) | |
18 | */ |
|
38 | */ | |
19 |
|
39 | |||
20 | /*! |
|
40 | /*! | |
21 | \property QVXYModelMapper::yColumn |
|
41 | \property QVXYModelMapper::yColumn | |
22 | \brief Defines which column of the model is kept in sync with the y values of QXYSeries |
|
42 | \brief Defines which column of the model is kept in sync with the y values of QXYSeries | |
23 |
|
43 | |||
24 | Default value is: -1 (invalid mapping) |
|
44 | Default value is: -1 (invalid mapping) | |
25 | */ |
|
45 | */ | |
26 |
|
46 | |||
27 | /*! |
|
47 | /*! | |
28 | Constructs a mapper object which is a child of \a parent. |
|
48 | Constructs a mapper object which is a child of \a parent. | |
29 | */ |
|
49 | */ | |
30 | QVXYModelMapper::QVXYModelMapper(QObject *parent) : |
|
50 | QVXYModelMapper::QVXYModelMapper(QObject *parent) : | |
31 | QXYModelMapper(parent) |
|
51 | QXYModelMapper(parent) | |
32 | { |
|
52 | { | |
33 | QXYModelMapper::setOrientation(Qt::Vertical); |
|
53 | QXYModelMapper::setOrientation(Qt::Vertical); | |
34 | } |
|
54 | } | |
35 |
|
55 | |||
36 | int QVXYModelMapper::xColumn() const |
|
56 | int QVXYModelMapper::xColumn() const | |
37 | { |
|
57 | { | |
38 | return QXYModelMapper::xSection(); |
|
58 | return QXYModelMapper::xSection(); | |
39 | } |
|
59 | } | |
40 |
|
60 | |||
41 | void QVXYModelMapper::setXColumn(int xColumn) |
|
61 | void QVXYModelMapper::setXColumn(int xColumn) | |
42 | { |
|
62 | { | |
43 | return QXYModelMapper::setXSection(xColumn); |
|
63 | return QXYModelMapper::setXSection(xColumn); | |
44 | } |
|
64 | } | |
45 |
|
65 | |||
46 | int QVXYModelMapper::yColumn() const |
|
66 | int QVXYModelMapper::yColumn() const | |
47 | { |
|
67 | { | |
48 | return QXYModelMapper::ySection(); |
|
68 | return QXYModelMapper::ySection(); | |
49 | } |
|
69 | } | |
50 |
|
70 | |||
51 | void QVXYModelMapper::setYColumn(int yColumn) |
|
71 | void QVXYModelMapper::setYColumn(int yColumn) | |
52 | { |
|
72 | { | |
53 | return QXYModelMapper::setYSection(yColumn); |
|
73 | return QXYModelMapper::setYSection(yColumn); | |
54 | } |
|
74 | } | |
55 |
|
75 | |||
56 | #include "moc_qvxymodelmapper.cpp" |
|
76 | #include "moc_qvxymodelmapper.cpp" | |
57 |
|
77 | |||
58 | QTCOMMERCIALCHART_END_NAMESPACE |
|
78 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,27 +1,47 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
1 | #ifndef QVXYMODELMAPPER_H |
|
21 | #ifndef QVXYMODELMAPPER_H | |
2 | #define QVXYMODELMAPPER_H |
|
22 | #define QVXYMODELMAPPER_H | |
3 |
|
23 | |||
4 | #include <QXYModelMapper> |
|
24 | #include <QXYModelMapper> | |
5 |
|
25 | |||
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
7 |
|
27 | |||
8 | class QTCOMMERCIALCHART_EXPORT QVXYModelMapper : public QXYModelMapper |
|
28 | class QTCOMMERCIALCHART_EXPORT QVXYModelMapper : public QXYModelMapper | |
9 | { |
|
29 | { | |
10 | Q_OBJECT |
|
30 | Q_OBJECT | |
11 | Q_PROPERTY(int xColumn READ xColumn WRITE setXColumn) |
|
31 | Q_PROPERTY(int xColumn READ xColumn WRITE setXColumn) | |
12 | Q_PROPERTY(int yColumn READ yColumn WRITE setYColumn) |
|
32 | Q_PROPERTY(int yColumn READ yColumn WRITE setYColumn) | |
13 |
|
33 | |||
14 | public: |
|
34 | public: | |
15 | explicit QVXYModelMapper(QObject *parent = 0); |
|
35 | explicit QVXYModelMapper(QObject *parent = 0); | |
16 |
|
36 | |||
17 | int xColumn() const; |
|
37 | int xColumn() const; | |
18 | void setXColumn(int xColumn); |
|
38 | void setXColumn(int xColumn); | |
19 |
|
39 | |||
20 | int yColumn() const; |
|
40 | int yColumn() const; | |
21 | void setYColumn(int yColumn); |
|
41 | void setYColumn(int yColumn); | |
22 |
|
42 | |||
23 | }; |
|
43 | }; | |
24 |
|
44 | |||
25 | QTCOMMERCIALCHART_END_NAMESPACE |
|
45 | QTCOMMERCIALCHART_END_NAMESPACE | |
26 |
|
46 | |||
27 | #endif // QVXYMODELMAPPER_H |
|
47 | #endif // QVXYMODELMAPPER_H |
@@ -1,501 +1,521 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
1 | #include "qxymodelmapper.h" |
|
21 | #include "qxymodelmapper.h" | |
2 | #include "qxymodelmapper_p.h" |
|
22 | #include "qxymodelmapper_p.h" | |
3 | #include "qxyseries.h" |
|
23 | #include "qxyseries.h" | |
4 | #include <QAbstractItemModel> |
|
24 | #include <QAbstractItemModel> | |
5 |
|
25 | |||
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
7 |
|
27 | |||
8 | /*! |
|
28 | /*! | |
9 | \property QXYModelMapper::series |
|
29 | \property QXYModelMapper::series | |
10 | \brief Defines the QPieSeries object that is used by the mapper. |
|
30 | \brief Defines the QPieSeries object that is used by the mapper. | |
11 |
|
31 | |||
12 | All the data in the series in the series is discarded when it is set to the mapper. |
|
32 | All the data in the series in the series is discarded when it is set to the mapper. | |
13 | When new series is specified the old series is disconnected (it preserves its data) |
|
33 | When new series is specified the old series is disconnected (it preserves its data) | |
14 | */ |
|
34 | */ | |
15 |
|
35 | |||
16 | /*! |
|
36 | /*! | |
17 | \property QXYModelMapper::model |
|
37 | \property QXYModelMapper::model | |
18 | \brief Defines the model that is used by the mapper. |
|
38 | \brief Defines the model that is used by the mapper. | |
19 | */ |
|
39 | */ | |
20 |
|
40 | |||
21 | /*! |
|
41 | /*! | |
22 | \property QXYModelMapper::first |
|
42 | \property QXYModelMapper::first | |
23 | \brief Defines which item of the model's row/column should be mapped as the first x/y pair |
|
43 | \brief Defines which item of the model's row/column should be mapped as the first x/y pair | |
24 |
|
44 | |||
25 | Minimal and default value is: 0 |
|
45 | Minimal and default value is: 0 | |
26 | */ |
|
46 | */ | |
27 |
|
47 | |||
28 | /*! |
|
48 | /*! | |
29 | \property QXYModelMapper::count |
|
49 | \property QXYModelMapper::count | |
30 | \brief Defines the number of rows/columns of the model that are mapped as the data for QXYSeries |
|
50 | \brief Defines the number of rows/columns of the model that are mapped as the data for QXYSeries | |
31 |
|
51 | |||
32 | Minimal and default value is: -1 (count limited by the number of rows/columns in the model) |
|
52 | Minimal and default value is: -1 (count limited by the number of rows/columns in the model) | |
33 | */ |
|
53 | */ | |
34 |
|
54 | |||
35 | /*! |
|
55 | /*! | |
36 | \class QXYModelMapper |
|
56 | \class QXYModelMapper | |
37 | \brief part of QtCommercial chart API. |
|
57 | \brief part of QtCommercial chart API. | |
38 | \mainclass |
|
58 | \mainclass | |
39 |
|
59 | |||
40 | The instance of this class cannot be created directly. QHXYModelMapper of QVXYModelMapper should be used instead. This class is used to create a connection between QXYSeries and QAbstractItemModel derived model object. |
|
60 | The instance of this class cannot be created directly. QHXYModelMapper of QVXYModelMapper should be used instead. This class is used to create a connection between QXYSeries and QAbstractItemModel derived model object. | |
41 | It is possible to use both QAbstractItemModel and QXYSeries model API. QXYModelMapper makes sure that QXYSeries and the model are kept in sync. |
|
61 | It is possible to use both QAbstractItemModel and QXYSeries model API. QXYModelMapper makes sure that QXYSeries and the model are kept in sync. | |
42 | NOTE: used model has to support adding/removing rows/columns and modifying the data of the cells. |
|
62 | NOTE: used model has to support adding/removing rows/columns and modifying the data of the cells. | |
43 | */ |
|
63 | */ | |
44 |
|
64 | |||
45 | /*! |
|
65 | /*! | |
46 | Constructs a mapper object which is a child of \a parent. |
|
66 | Constructs a mapper object which is a child of \a parent. | |
47 | */ |
|
67 | */ | |
48 | QXYModelMapper::QXYModelMapper(QObject *parent): |
|
68 | QXYModelMapper::QXYModelMapper(QObject *parent): | |
49 | QObject(parent), |
|
69 | QObject(parent), | |
50 | d_ptr(new QXYModelMapperPrivate(this)) |
|
70 | d_ptr(new QXYModelMapperPrivate(this)) | |
51 | { |
|
71 | { | |
52 | } |
|
72 | } | |
53 |
|
73 | |||
54 | QAbstractItemModel* QXYModelMapper::model() const |
|
74 | QAbstractItemModel* QXYModelMapper::model() const | |
55 | { |
|
75 | { | |
56 | Q_D(const QXYModelMapper); |
|
76 | Q_D(const QXYModelMapper); | |
57 | return d->m_model; |
|
77 | return d->m_model; | |
58 | } |
|
78 | } | |
59 |
|
79 | |||
60 | void QXYModelMapper::setModel(QAbstractItemModel *model) |
|
80 | void QXYModelMapper::setModel(QAbstractItemModel *model) | |
61 | { |
|
81 | { | |
62 | if (model == 0) |
|
82 | if (model == 0) | |
63 | return; |
|
83 | return; | |
64 |
|
84 | |||
65 | Q_D(QXYModelMapper); |
|
85 | Q_D(QXYModelMapper); | |
66 | if (d->m_model) { |
|
86 | if (d->m_model) { | |
67 | disconnect(d->m_model, 0, d, 0); |
|
87 | disconnect(d->m_model, 0, d, 0); | |
68 | } |
|
88 | } | |
69 |
|
89 | |||
70 | d->m_model = model; |
|
90 | d->m_model = model; | |
71 | d->initializeXYFromModel(); |
|
91 | d->initializeXYFromModel(); | |
72 | // connect signals from the model |
|
92 | // connect signals from the model | |
73 | connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); |
|
93 | connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); | |
74 | connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); |
|
94 | connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int))); | |
75 | connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); |
|
95 | connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int))); | |
76 | connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); |
|
96 | connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int))); | |
77 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); |
|
97 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int))); | |
78 | } |
|
98 | } | |
79 |
|
99 | |||
80 | QXYSeries* QXYModelMapper::series() const |
|
100 | QXYSeries* QXYModelMapper::series() const | |
81 | { |
|
101 | { | |
82 | Q_D(const QXYModelMapper); |
|
102 | Q_D(const QXYModelMapper); | |
83 | return d->m_series; |
|
103 | return d->m_series; | |
84 | } |
|
104 | } | |
85 |
|
105 | |||
86 | void QXYModelMapper::setSeries(QXYSeries *series) |
|
106 | void QXYModelMapper::setSeries(QXYSeries *series) | |
87 | { |
|
107 | { | |
88 | Q_D(QXYModelMapper); |
|
108 | Q_D(QXYModelMapper); | |
89 | if (d->m_series) { |
|
109 | if (d->m_series) { | |
90 | disconnect(d->m_series, 0, d, 0); |
|
110 | disconnect(d->m_series, 0, d, 0); | |
91 | } |
|
111 | } | |
92 |
|
112 | |||
93 | if (series == 0) |
|
113 | if (series == 0) | |
94 | return; |
|
114 | return; | |
95 |
|
115 | |||
96 | d->m_series = series; |
|
116 | d->m_series = series; | |
97 | d->initializeXYFromModel(); |
|
117 | d->initializeXYFromModel(); | |
98 | // connect the signals from the series |
|
118 | // connect the signals from the series | |
99 | connect(d->m_series, SIGNAL(pointAdded(int)), d, SLOT(handlePointAdded(int))); |
|
119 | connect(d->m_series, SIGNAL(pointAdded(int)), d, SLOT(handlePointAdded(int))); | |
100 | connect(d->m_series, SIGNAL(pointRemoved(int)), d, SLOT(handlePointRemoved(int))); |
|
120 | connect(d->m_series, SIGNAL(pointRemoved(int)), d, SLOT(handlePointRemoved(int))); | |
101 | connect(d->m_series, SIGNAL(pointReplaced(int)), d, SLOT(handlePointReplaced(int))); |
|
121 | connect(d->m_series, SIGNAL(pointReplaced(int)), d, SLOT(handlePointReplaced(int))); | |
102 | } |
|
122 | } | |
103 |
|
123 | |||
104 | int QXYModelMapper::first() const |
|
124 | int QXYModelMapper::first() const | |
105 | { |
|
125 | { | |
106 | Q_D(const QXYModelMapper); |
|
126 | Q_D(const QXYModelMapper); | |
107 | return d->m_first; |
|
127 | return d->m_first; | |
108 | } |
|
128 | } | |
109 |
|
129 | |||
110 | void QXYModelMapper::setFirst(int first) |
|
130 | void QXYModelMapper::setFirst(int first) | |
111 | { |
|
131 | { | |
112 | Q_D(QXYModelMapper); |
|
132 | Q_D(QXYModelMapper); | |
113 | d->m_first = qMax(first, 0); |
|
133 | d->m_first = qMax(first, 0); | |
114 | d->initializeXYFromModel(); |
|
134 | d->initializeXYFromModel(); | |
115 | } |
|
135 | } | |
116 |
|
136 | |||
117 | int QXYModelMapper::count() const |
|
137 | int QXYModelMapper::count() const | |
118 | { |
|
138 | { | |
119 | Q_D(const QXYModelMapper); |
|
139 | Q_D(const QXYModelMapper); | |
120 | return d->m_count; |
|
140 | return d->m_count; | |
121 | } |
|
141 | } | |
122 |
|
142 | |||
123 | void QXYModelMapper::setCount(int count) |
|
143 | void QXYModelMapper::setCount(int count) | |
124 | { |
|
144 | { | |
125 | Q_D(QXYModelMapper); |
|
145 | Q_D(QXYModelMapper); | |
126 | d->m_count = qMax(count, -1); |
|
146 | d->m_count = qMax(count, -1); | |
127 | d->initializeXYFromModel(); |
|
147 | d->initializeXYFromModel(); | |
128 | } |
|
148 | } | |
129 |
|
149 | |||
130 | /*! |
|
150 | /*! | |
131 | Returns the orientation that is used when QXYModelMapper accesses the model. |
|
151 | Returns the orientation that is used when QXYModelMapper accesses the model. | |
132 | This mean whether the consecutive x/y values of the QXYSeries are read from rows (Qt::Horizontal) |
|
152 | This mean whether the consecutive x/y values of the QXYSeries are read from rows (Qt::Horizontal) | |
133 | or from columns (Qt::Vertical) |
|
153 | or from columns (Qt::Vertical) | |
134 | */ |
|
154 | */ | |
135 | Qt::Orientation QXYModelMapper::orientation() const |
|
155 | Qt::Orientation QXYModelMapper::orientation() const | |
136 | { |
|
156 | { | |
137 | Q_D(const QXYModelMapper); |
|
157 | Q_D(const QXYModelMapper); | |
138 | return d->m_orientation; |
|
158 | return d->m_orientation; | |
139 | } |
|
159 | } | |
140 |
|
160 | |||
141 | /*! |
|
161 | /*! | |
142 | Returns the \a orientation that is used when QXYModelMapper accesses the model. |
|
162 | Returns the \a orientation that is used when QXYModelMapper accesses the model. | |
143 | This mean whether the consecutive x/y values of the QXYSeries are read from rows (Qt::Horizontal) |
|
163 | This mean whether the consecutive x/y values of the QXYSeries are read from rows (Qt::Horizontal) | |
144 | or from columns (Qt::Vertical) |
|
164 | or from columns (Qt::Vertical) | |
145 | */ |
|
165 | */ | |
146 | void QXYModelMapper::setOrientation(Qt::Orientation orientation) |
|
166 | void QXYModelMapper::setOrientation(Qt::Orientation orientation) | |
147 | { |
|
167 | { | |
148 | Q_D(QXYModelMapper); |
|
168 | Q_D(QXYModelMapper); | |
149 | d->m_orientation = orientation; |
|
169 | d->m_orientation = orientation; | |
150 | d->initializeXYFromModel(); |
|
170 | d->initializeXYFromModel(); | |
151 | } |
|
171 | } | |
152 |
|
172 | |||
153 | /*! |
|
173 | /*! | |
154 | Returns which section of the model is kept in sync with the x values of the QXYSeries |
|
174 | Returns which section of the model is kept in sync with the x values of the QXYSeries | |
155 | */ |
|
175 | */ | |
156 | int QXYModelMapper::xSection() const |
|
176 | int QXYModelMapper::xSection() const | |
157 | { |
|
177 | { | |
158 | Q_D(const QXYModelMapper); |
|
178 | Q_D(const QXYModelMapper); | |
159 | return d->m_xSection; |
|
179 | return d->m_xSection; | |
160 | } |
|
180 | } | |
161 |
|
181 | |||
162 | /*! |
|
182 | /*! | |
163 | Sets the model section that is kept in sync with the x values of the QXYSeries. |
|
183 | Sets the model section that is kept in sync with the x values of the QXYSeries. | |
164 | Parameter \a xSection specifies the section of the model. |
|
184 | Parameter \a xSection specifies the section of the model. | |
165 | */ |
|
185 | */ | |
166 | void QXYModelMapper::setXSection(int xSection) |
|
186 | void QXYModelMapper::setXSection(int xSection) | |
167 | { |
|
187 | { | |
168 | Q_D(QXYModelMapper); |
|
188 | Q_D(QXYModelMapper); | |
169 | d->m_xSection = qMax(-1, xSection); |
|
189 | d->m_xSection = qMax(-1, xSection); | |
170 | d->initializeXYFromModel(); |
|
190 | d->initializeXYFromModel(); | |
171 | } |
|
191 | } | |
172 |
|
192 | |||
173 | /*! |
|
193 | /*! | |
174 | Returns which section of the model is kept in sync with the y values of the QXYSeries |
|
194 | Returns which section of the model is kept in sync with the y values of the QXYSeries | |
175 | */ |
|
195 | */ | |
176 | int QXYModelMapper::ySection() const |
|
196 | int QXYModelMapper::ySection() const | |
177 | { |
|
197 | { | |
178 | Q_D(const QXYModelMapper); |
|
198 | Q_D(const QXYModelMapper); | |
179 | return d->m_ySection; |
|
199 | return d->m_ySection; | |
180 | } |
|
200 | } | |
181 |
|
201 | |||
182 | /*! |
|
202 | /*! | |
183 | Sets the model section that is kept in sync with the y values of the QXYSeries. |
|
203 | Sets the model section that is kept in sync with the y values of the QXYSeries. | |
184 | Parameter \a ySection specifies the section of the model. |
|
204 | Parameter \a ySection specifies the section of the model. | |
185 | */ |
|
205 | */ | |
186 | void QXYModelMapper::setYSection(int ySection) |
|
206 | void QXYModelMapper::setYSection(int ySection) | |
187 | { |
|
207 | { | |
188 | Q_D(QXYModelMapper); |
|
208 | Q_D(QXYModelMapper); | |
189 | d->m_ySection = qMax(-1, ySection); |
|
209 | d->m_ySection = qMax(-1, ySection); | |
190 | d->initializeXYFromModel(); |
|
210 | d->initializeXYFromModel(); | |
191 | } |
|
211 | } | |
192 |
|
212 | |||
193 | /*! |
|
213 | /*! | |
194 | Resets the QXYModelMapper to the default state. |
|
214 | Resets the QXYModelMapper to the default state. | |
195 | first: 0; count: -1; xSection: -1; ySection: -1; |
|
215 | first: 0; count: -1; xSection: -1; ySection: -1; | |
196 | */ |
|
216 | */ | |
197 | void QXYModelMapper::reset() |
|
217 | void QXYModelMapper::reset() | |
198 | { |
|
218 | { | |
199 | Q_D(QXYModelMapper); |
|
219 | Q_D(QXYModelMapper); | |
200 | d->m_first = 0; |
|
220 | d->m_first = 0; | |
201 | d->m_count = -1; |
|
221 | d->m_count = -1; | |
202 | d->m_orientation = Qt::Vertical; |
|
222 | d->m_orientation = Qt::Vertical; | |
203 | d->m_xSection = -1; |
|
223 | d->m_xSection = -1; | |
204 | d->m_ySection = -1; |
|
224 | d->m_ySection = -1; | |
205 | d->initializeXYFromModel(); |
|
225 | d->initializeXYFromModel(); | |
206 | } |
|
226 | } | |
207 |
|
227 | |||
208 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
228 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
209 |
|
229 | |||
210 | QXYModelMapperPrivate::QXYModelMapperPrivate(QXYModelMapper *q) : |
|
230 | QXYModelMapperPrivate::QXYModelMapperPrivate(QXYModelMapper *q) : | |
211 | m_series(0), |
|
231 | m_series(0), | |
212 | m_model(0), |
|
232 | m_model(0), | |
213 | m_first(0), |
|
233 | m_first(0), | |
214 | m_count(-1), |
|
234 | m_count(-1), | |
215 | m_orientation(Qt::Vertical), |
|
235 | m_orientation(Qt::Vertical), | |
216 | m_xSection(-1), |
|
236 | m_xSection(-1), | |
217 | m_ySection(-1), |
|
237 | m_ySection(-1), | |
218 | m_seriesSignalsBlock(false), |
|
238 | m_seriesSignalsBlock(false), | |
219 | m_modelSignalsBlock(false), |
|
239 | m_modelSignalsBlock(false), | |
220 | q_ptr(q) |
|
240 | q_ptr(q) | |
221 | { |
|
241 | { | |
222 | } |
|
242 | } | |
223 |
|
243 | |||
224 | void QXYModelMapperPrivate::blockModelSignals(bool block) |
|
244 | void QXYModelMapperPrivate::blockModelSignals(bool block) | |
225 | { |
|
245 | { | |
226 | m_modelSignalsBlock = block; |
|
246 | m_modelSignalsBlock = block; | |
227 | } |
|
247 | } | |
228 |
|
248 | |||
229 | void QXYModelMapperPrivate::blockSeriesSignals(bool block) |
|
249 | void QXYModelMapperPrivate::blockSeriesSignals(bool block) | |
230 | { |
|
250 | { | |
231 | m_seriesSignalsBlock = block; |
|
251 | m_seriesSignalsBlock = block; | |
232 | } |
|
252 | } | |
233 |
|
253 | |||
234 | QModelIndex QXYModelMapperPrivate::xModelIndex(int xPos) |
|
254 | QModelIndex QXYModelMapperPrivate::xModelIndex(int xPos) | |
235 | { |
|
255 | { | |
236 | if (m_count != -1 && xPos >= m_count) |
|
256 | if (m_count != -1 && xPos >= m_count) | |
237 | return QModelIndex(); // invalid |
|
257 | return QModelIndex(); // invalid | |
238 |
|
258 | |||
239 | if (m_orientation == Qt::Vertical) |
|
259 | if (m_orientation == Qt::Vertical) | |
240 | return m_model->index(xPos + m_first, m_xSection); |
|
260 | return m_model->index(xPos + m_first, m_xSection); | |
241 | else |
|
261 | else | |
242 | return m_model->index(m_xSection, xPos + m_first); |
|
262 | return m_model->index(m_xSection, xPos + m_first); | |
243 | } |
|
263 | } | |
244 |
|
264 | |||
245 | QModelIndex QXYModelMapperPrivate::yModelIndex(int yPos) |
|
265 | QModelIndex QXYModelMapperPrivate::yModelIndex(int yPos) | |
246 | { |
|
266 | { | |
247 | if (m_count != -1 && yPos >= m_count) |
|
267 | if (m_count != -1 && yPos >= m_count) | |
248 | return QModelIndex(); // invalid |
|
268 | return QModelIndex(); // invalid | |
249 |
|
269 | |||
250 | if (m_orientation == Qt::Vertical) |
|
270 | if (m_orientation == Qt::Vertical) | |
251 | return m_model->index(yPos + m_first, m_ySection); |
|
271 | return m_model->index(yPos + m_first, m_ySection); | |
252 | else |
|
272 | else | |
253 | return m_model->index(m_ySection, yPos + m_first); |
|
273 | return m_model->index(m_ySection, yPos + m_first); | |
254 | } |
|
274 | } | |
255 |
|
275 | |||
256 | void QXYModelMapperPrivate::handlePointAdded(int pointPos) |
|
276 | void QXYModelMapperPrivate::handlePointAdded(int pointPos) | |
257 | { |
|
277 | { | |
258 | if (m_seriesSignalsBlock) |
|
278 | if (m_seriesSignalsBlock) | |
259 | return; |
|
279 | return; | |
260 |
|
280 | |||
261 | if (m_count != -1) |
|
281 | if (m_count != -1) | |
262 | m_count += 1; |
|
282 | m_count += 1; | |
263 |
|
283 | |||
264 | blockModelSignals(); |
|
284 | blockModelSignals(); | |
265 | if (m_orientation == Qt::Vertical) |
|
285 | if (m_orientation == Qt::Vertical) | |
266 | m_model->insertRows(pointPos + m_first, 1); |
|
286 | m_model->insertRows(pointPos + m_first, 1); | |
267 | else |
|
287 | else | |
268 | m_model->insertColumns(pointPos + m_first, 1); |
|
288 | m_model->insertColumns(pointPos + m_first, 1); | |
269 |
|
289 | |||
270 | m_model->setData(xModelIndex(pointPos), m_series->points().at(pointPos).x()); |
|
290 | m_model->setData(xModelIndex(pointPos), m_series->points().at(pointPos).x()); | |
271 | m_model->setData(yModelIndex(pointPos), m_series->points().at(pointPos).y()); |
|
291 | m_model->setData(yModelIndex(pointPos), m_series->points().at(pointPos).y()); | |
272 | blockModelSignals(false); |
|
292 | blockModelSignals(false); | |
273 | } |
|
293 | } | |
274 |
|
294 | |||
275 | void QXYModelMapperPrivate::handlePointRemoved(int pointPos) |
|
295 | void QXYModelMapperPrivate::handlePointRemoved(int pointPos) | |
276 | { |
|
296 | { | |
277 | if (m_seriesSignalsBlock) |
|
297 | if (m_seriesSignalsBlock) | |
278 | return; |
|
298 | return; | |
279 |
|
299 | |||
280 | if (m_count != -1) |
|
300 | if (m_count != -1) | |
281 | m_count -= 1; |
|
301 | m_count -= 1; | |
282 |
|
302 | |||
283 | blockModelSignals(); |
|
303 | blockModelSignals(); | |
284 | if (m_orientation == Qt::Vertical) |
|
304 | if (m_orientation == Qt::Vertical) | |
285 | m_model->removeRow(pointPos + m_first); |
|
305 | m_model->removeRow(pointPos + m_first); | |
286 | else |
|
306 | else | |
287 | m_model->removeColumn(pointPos + m_first); |
|
307 | m_model->removeColumn(pointPos + m_first); | |
288 | blockModelSignals(false); |
|
308 | blockModelSignals(false); | |
289 | } |
|
309 | } | |
290 |
|
310 | |||
291 | void QXYModelMapperPrivate::handlePointReplaced(int pointPos) |
|
311 | void QXYModelMapperPrivate::handlePointReplaced(int pointPos) | |
292 | { |
|
312 | { | |
293 | if (m_seriesSignalsBlock) |
|
313 | if (m_seriesSignalsBlock) | |
294 | return; |
|
314 | return; | |
295 |
|
315 | |||
296 | blockModelSignals(); |
|
316 | blockModelSignals(); | |
297 | m_model->setData(xModelIndex(pointPos), m_series->points().at(pointPos).x()); |
|
317 | m_model->setData(xModelIndex(pointPos), m_series->points().at(pointPos).x()); | |
298 | m_model->setData(yModelIndex(pointPos), m_series->points().at(pointPos).y()); |
|
318 | m_model->setData(yModelIndex(pointPos), m_series->points().at(pointPos).y()); | |
299 | blockModelSignals(false); |
|
319 | blockModelSignals(false); | |
300 | } |
|
320 | } | |
301 |
|
321 | |||
302 | void QXYModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) |
|
322 | void QXYModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) | |
303 | { |
|
323 | { | |
304 | if (m_model == 0 || m_series == 0) |
|
324 | if (m_model == 0 || m_series == 0) | |
305 | return; |
|
325 | return; | |
306 |
|
326 | |||
307 | if (m_modelSignalsBlock) |
|
327 | if (m_modelSignalsBlock) | |
308 | return; |
|
328 | return; | |
309 |
|
329 | |||
310 | blockSeriesSignals(); |
|
330 | blockSeriesSignals(); | |
311 | QModelIndex index; |
|
331 | QModelIndex index; | |
312 | QPointF oldPoint; |
|
332 | QPointF oldPoint; | |
313 | QPointF newPoint; |
|
333 | QPointF newPoint; | |
314 | for (int row = topLeft.row(); row <= bottomRight.row(); row++) { |
|
334 | for (int row = topLeft.row(); row <= bottomRight.row(); row++) { | |
315 | for (int column = topLeft.column(); column <= bottomRight.column(); column++) { |
|
335 | for (int column = topLeft.column(); column <= bottomRight.column(); column++) { | |
316 | index = topLeft.sibling(row, column); |
|
336 | index = topLeft.sibling(row, column); | |
317 | if (m_orientation == Qt::Vertical && (index.column() == m_xSection || index.column() == m_ySection)) { |
|
337 | if (m_orientation == Qt::Vertical && (index.column() == m_xSection || index.column() == m_ySection)) { | |
318 | if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) { |
|
338 | if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) { | |
319 | QModelIndex xIndex = xModelIndex(index.row() - m_first); |
|
339 | QModelIndex xIndex = xModelIndex(index.row() - m_first); | |
320 | QModelIndex yIndex = yModelIndex(index.row() - m_first); |
|
340 | QModelIndex yIndex = yModelIndex(index.row() - m_first); | |
321 | if (xIndex.isValid() && yIndex.isValid()) { |
|
341 | if (xIndex.isValid() && yIndex.isValid()) { | |
322 | oldPoint = m_series->points().at(index.row() - m_first); |
|
342 | oldPoint = m_series->points().at(index.row() - m_first); | |
323 | newPoint.setX(m_model->data(xIndex).toReal()); |
|
343 | newPoint.setX(m_model->data(xIndex).toReal()); | |
324 | newPoint.setY(m_model->data(yIndex).toReal()); |
|
344 | newPoint.setY(m_model->data(yIndex).toReal()); | |
325 | } |
|
345 | } | |
326 | } |
|
346 | } | |
327 | } else if (m_orientation == Qt::Horizontal && (index.row() == m_xSection || index.row() == m_ySection)) { |
|
347 | } else if (m_orientation == Qt::Horizontal && (index.row() == m_xSection || index.row() == m_ySection)) { | |
328 | if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) { |
|
348 | if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) { | |
329 | QModelIndex xIndex = xModelIndex(index.column() - m_first); |
|
349 | QModelIndex xIndex = xModelIndex(index.column() - m_first); | |
330 | QModelIndex yIndex = yModelIndex(index.column() - m_first); |
|
350 | QModelIndex yIndex = yModelIndex(index.column() - m_first); | |
331 | if (xIndex.isValid() && yIndex.isValid()) { |
|
351 | if (xIndex.isValid() && yIndex.isValid()) { | |
332 | oldPoint = m_series->points().at(index.column() - m_first); |
|
352 | oldPoint = m_series->points().at(index.column() - m_first); | |
333 | newPoint.setX(m_model->data(xIndex).toReal()); |
|
353 | newPoint.setX(m_model->data(xIndex).toReal()); | |
334 | newPoint.setY(m_model->data(yIndex).toReal()); |
|
354 | newPoint.setY(m_model->data(yIndex).toReal()); | |
335 | } |
|
355 | } | |
336 | } |
|
356 | } | |
337 | } else { |
|
357 | } else { | |
338 | continue; |
|
358 | continue; | |
339 | } |
|
359 | } | |
340 | m_series->replace(oldPoint, newPoint); |
|
360 | m_series->replace(oldPoint, newPoint); | |
341 | } |
|
361 | } | |
342 | } |
|
362 | } | |
343 | blockSeriesSignals(false); |
|
363 | blockSeriesSignals(false); | |
344 | } |
|
364 | } | |
345 |
|
365 | |||
346 | void QXYModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end) |
|
366 | void QXYModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end) | |
347 | { |
|
367 | { | |
348 | Q_UNUSED(parent); |
|
368 | Q_UNUSED(parent); | |
349 | if (m_modelSignalsBlock) |
|
369 | if (m_modelSignalsBlock) | |
350 | return; |
|
370 | return; | |
351 |
|
371 | |||
352 | blockSeriesSignals(); |
|
372 | blockSeriesSignals(); | |
353 | if (m_orientation == Qt::Vertical) |
|
373 | if (m_orientation == Qt::Vertical) | |
354 | insertData(start, end); |
|
374 | insertData(start, end); | |
355 | else if (start <= m_xSection || start <= m_ySection) // if the changes affect the map - reinitialize the xy |
|
375 | else if (start <= m_xSection || start <= m_ySection) // if the changes affect the map - reinitialize the xy | |
356 | initializeXYFromModel(); |
|
376 | initializeXYFromModel(); | |
357 | blockSeriesSignals(false); |
|
377 | blockSeriesSignals(false); | |
358 | } |
|
378 | } | |
359 |
|
379 | |||
360 | void QXYModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end) |
|
380 | void QXYModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end) | |
361 | { |
|
381 | { | |
362 | Q_UNUSED(parent); |
|
382 | Q_UNUSED(parent); | |
363 | if (m_modelSignalsBlock) |
|
383 | if (m_modelSignalsBlock) | |
364 | return; |
|
384 | return; | |
365 |
|
385 | |||
366 | blockSeriesSignals(); |
|
386 | blockSeriesSignals(); | |
367 | if (m_orientation == Qt::Vertical) |
|
387 | if (m_orientation == Qt::Vertical) | |
368 | removeData(start, end); |
|
388 | removeData(start, end); | |
369 | else if (start <= m_xSection || start <= m_ySection) // if the changes affect the map - reinitialize the xy |
|
389 | else if (start <= m_xSection || start <= m_ySection) // if the changes affect the map - reinitialize the xy | |
370 | initializeXYFromModel(); |
|
390 | initializeXYFromModel(); | |
371 | blockSeriesSignals(false); |
|
391 | blockSeriesSignals(false); | |
372 | } |
|
392 | } | |
373 |
|
393 | |||
374 | void QXYModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end) |
|
394 | void QXYModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end) | |
375 | { |
|
395 | { | |
376 | Q_UNUSED(parent); |
|
396 | Q_UNUSED(parent); | |
377 | if (m_modelSignalsBlock) |
|
397 | if (m_modelSignalsBlock) | |
378 | return; |
|
398 | return; | |
379 |
|
399 | |||
380 | blockSeriesSignals(); |
|
400 | blockSeriesSignals(); | |
381 | if (m_orientation == Qt::Horizontal) |
|
401 | if (m_orientation == Qt::Horizontal) | |
382 | insertData(start, end); |
|
402 | insertData(start, end); | |
383 | else if (start <= m_xSection || start <= m_ySection) // if the changes affect the map - reinitialize the xy |
|
403 | else if (start <= m_xSection || start <= m_ySection) // if the changes affect the map - reinitialize the xy | |
384 | initializeXYFromModel(); |
|
404 | initializeXYFromModel(); | |
385 | blockSeriesSignals(false); |
|
405 | blockSeriesSignals(false); | |
386 | } |
|
406 | } | |
387 |
|
407 | |||
388 | void QXYModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end) |
|
408 | void QXYModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end) | |
389 | { |
|
409 | { | |
390 | Q_UNUSED(parent); |
|
410 | Q_UNUSED(parent); | |
391 | if (m_modelSignalsBlock) |
|
411 | if (m_modelSignalsBlock) | |
392 | return; |
|
412 | return; | |
393 |
|
413 | |||
394 | blockSeriesSignals(); |
|
414 | blockSeriesSignals(); | |
395 | if (m_orientation == Qt::Horizontal) |
|
415 | if (m_orientation == Qt::Horizontal) | |
396 | removeData(start, end); |
|
416 | removeData(start, end); | |
397 | else if (start <= m_xSection || start <= m_ySection) // if the changes affect the map - reinitialize the xy |
|
417 | else if (start <= m_xSection || start <= m_ySection) // if the changes affect the map - reinitialize the xy | |
398 | initializeXYFromModel(); |
|
418 | initializeXYFromModel(); | |
399 | blockSeriesSignals(false); |
|
419 | blockSeriesSignals(false); | |
400 | } |
|
420 | } | |
401 |
|
421 | |||
402 | void QXYModelMapperPrivate::insertData(int start, int end) |
|
422 | void QXYModelMapperPrivate::insertData(int start, int end) | |
403 | { |
|
423 | { | |
404 | if (m_model == 0 || m_series == 0) |
|
424 | if (m_model == 0 || m_series == 0) | |
405 | return; |
|
425 | return; | |
406 |
|
426 | |||
407 | if (m_count != -1 && start >= m_first + m_count) { |
|
427 | if (m_count != -1 && start >= m_first + m_count) { | |
408 | return; |
|
428 | return; | |
409 | } else { |
|
429 | } else { | |
410 | int addedCount = end - start + 1; |
|
430 | int addedCount = end - start + 1; | |
411 | if (m_count != -1 && addedCount > m_count) |
|
431 | if (m_count != -1 && addedCount > m_count) | |
412 | addedCount = m_count; |
|
432 | addedCount = m_count; | |
413 | int first = qMax(start, m_first); |
|
433 | int first = qMax(start, m_first); | |
414 | int last = qMin(first + addedCount - 1, m_orientation == Qt::Vertical ? m_model->rowCount() - 1 : m_model->columnCount() - 1); |
|
434 | int last = qMin(first + addedCount - 1, m_orientation == Qt::Vertical ? m_model->rowCount() - 1 : m_model->columnCount() - 1); | |
415 | for (int i = first; i <= last; i++) { |
|
435 | for (int i = first; i <= last; i++) { | |
416 | QPointF point; |
|
436 | QPointF point; | |
417 | QModelIndex xIndex = xModelIndex(i - m_first); |
|
437 | QModelIndex xIndex = xModelIndex(i - m_first); | |
418 | QModelIndex yIndex = yModelIndex(i - m_first); |
|
438 | QModelIndex yIndex = yModelIndex(i - m_first); | |
419 | if (xIndex.isValid() && yIndex.isValid()) { |
|
439 | if (xIndex.isValid() && yIndex.isValid()) { | |
420 | point.setX(m_model->data(xIndex, Qt::DisplayRole).toDouble()); |
|
440 | point.setX(m_model->data(xIndex, Qt::DisplayRole).toDouble()); | |
421 | point.setY(m_model->data(yIndex, Qt::DisplayRole).toDouble()); |
|
441 | point.setY(m_model->data(yIndex, Qt::DisplayRole).toDouble()); | |
422 | m_series->insert(i - m_first, point); |
|
442 | m_series->insert(i - m_first, point); | |
423 | } |
|
443 | } | |
424 | } |
|
444 | } | |
425 |
|
445 | |||
426 | // remove excess of slices (abouve m_count) |
|
446 | // remove excess of slices (abouve m_count) | |
427 | if (m_count != -1 && m_series->points().size() > m_count) |
|
447 | if (m_count != -1 && m_series->points().size() > m_count) | |
428 | for (int i = m_series->points().size() - 1; i >= m_count; i--) { |
|
448 | for (int i = m_series->points().size() - 1; i >= m_count; i--) { | |
429 | m_series->remove(m_series->points().at(i)); |
|
449 | m_series->remove(m_series->points().at(i)); | |
430 | } |
|
450 | } | |
431 | } |
|
451 | } | |
432 | } |
|
452 | } | |
433 |
|
453 | |||
434 | void QXYModelMapperPrivate::removeData(int start, int end) |
|
454 | void QXYModelMapperPrivate::removeData(int start, int end) | |
435 | { |
|
455 | { | |
436 | if (m_model == 0 || m_series == 0) |
|
456 | if (m_model == 0 || m_series == 0) | |
437 | return; |
|
457 | return; | |
438 |
|
458 | |||
439 | int removedCount = end - start + 1; |
|
459 | int removedCount = end - start + 1; | |
440 | if (m_count != -1 && start >= m_first + m_count) { |
|
460 | if (m_count != -1 && start >= m_first + m_count) { | |
441 | return; |
|
461 | return; | |
442 | } else { |
|
462 | } else { | |
443 | int toRemove = qMin(m_series->count(), removedCount); // first find how many items can actually be removed |
|
463 | int toRemove = qMin(m_series->count(), removedCount); // first find how many items can actually be removed | |
444 | int first = qMax(start, m_first); // get the index of the first item that will be removed. |
|
464 | int first = qMax(start, m_first); // get the index of the first item that will be removed. | |
445 | int last = qMin(first + toRemove - 1, m_series->count() + m_first - 1); // get the index of the last item that will be removed. |
|
465 | int last = qMin(first + toRemove - 1, m_series->count() + m_first - 1); // get the index of the last item that will be removed. | |
446 | for (int i = last; i >= first; i--) { |
|
466 | for (int i = last; i >= first; i--) { | |
447 | m_series->remove(m_series->points().at(i - m_first)); |
|
467 | m_series->remove(m_series->points().at(i - m_first)); | |
448 | } |
|
468 | } | |
449 |
|
469 | |||
450 | if (m_count != -1) { |
|
470 | if (m_count != -1) { | |
451 | int itemsAvailable; // check how many are available to be added |
|
471 | int itemsAvailable; // check how many are available to be added | |
452 | if (m_orientation == Qt::Vertical) |
|
472 | if (m_orientation == Qt::Vertical) | |
453 | itemsAvailable = m_model->rowCount() - m_first - m_series->count(); |
|
473 | itemsAvailable = m_model->rowCount() - m_first - m_series->count(); | |
454 | else |
|
474 | else | |
455 | itemsAvailable = m_model->columnCount() - m_first - m_series->count(); |
|
475 | itemsAvailable = m_model->columnCount() - m_first - m_series->count(); | |
456 | int toBeAdded = qMin(itemsAvailable, m_count - m_series->count()); // add not more items than there is space left to be filled. |
|
476 | int toBeAdded = qMin(itemsAvailable, m_count - m_series->count()); // add not more items than there is space left to be filled. | |
457 | int currentSize = m_series->count(); |
|
477 | int currentSize = m_series->count(); | |
458 | if (toBeAdded > 0) |
|
478 | if (toBeAdded > 0) | |
459 | for (int i = m_series->count(); i < currentSize + toBeAdded; i++) { |
|
479 | for (int i = m_series->count(); i < currentSize + toBeAdded; i++) { | |
460 | QPointF point; |
|
480 | QPointF point; | |
461 | QModelIndex xIndex = xModelIndex(i); |
|
481 | QModelIndex xIndex = xModelIndex(i); | |
462 | QModelIndex yIndex = yModelIndex(i); |
|
482 | QModelIndex yIndex = yModelIndex(i); | |
463 | if (xIndex.isValid() && yIndex.isValid()) { |
|
483 | if (xIndex.isValid() && yIndex.isValid()) { | |
464 | point.setX(m_model->data(xIndex, Qt::DisplayRole).toDouble()); |
|
484 | point.setX(m_model->data(xIndex, Qt::DisplayRole).toDouble()); | |
465 | point.setY(m_model->data(yIndex, Qt::DisplayRole).toDouble()); |
|
485 | point.setY(m_model->data(yIndex, Qt::DisplayRole).toDouble()); | |
466 | m_series->insert(i, point); |
|
486 | m_series->insert(i, point); | |
467 | } |
|
487 | } | |
468 | } |
|
488 | } | |
469 | } |
|
489 | } | |
470 | } |
|
490 | } | |
471 | } |
|
491 | } | |
472 |
|
492 | |||
473 | void QXYModelMapperPrivate::initializeXYFromModel() |
|
493 | void QXYModelMapperPrivate::initializeXYFromModel() | |
474 | { |
|
494 | { | |
475 | if (m_model == 0 || m_series == 0) |
|
495 | if (m_model == 0 || m_series == 0) | |
476 | return; |
|
496 | return; | |
477 |
|
497 | |||
478 | blockSeriesSignals(); |
|
498 | blockSeriesSignals(); | |
479 | // clear current content |
|
499 | // clear current content | |
480 | m_series->clear(); |
|
500 | m_series->clear(); | |
481 |
|
501 | |||
482 | // create the initial slices set |
|
502 | // create the initial slices set | |
483 | int pointPos = 0; |
|
503 | int pointPos = 0; | |
484 | QModelIndex xIndex = xModelIndex(pointPos); |
|
504 | QModelIndex xIndex = xModelIndex(pointPos); | |
485 | QModelIndex yIndex = yModelIndex(pointPos); |
|
505 | QModelIndex yIndex = yModelIndex(pointPos); | |
486 | while (xIndex.isValid() && yIndex.isValid()) { |
|
506 | while (xIndex.isValid() && yIndex.isValid()) { | |
487 | QPointF point; |
|
507 | QPointF point; | |
488 | point.setX(m_model->data(xIndex, Qt::DisplayRole).toDouble()); |
|
508 | point.setX(m_model->data(xIndex, Qt::DisplayRole).toDouble()); | |
489 | point.setY(m_model->data(yIndex, Qt::DisplayRole).toDouble()); |
|
509 | point.setY(m_model->data(yIndex, Qt::DisplayRole).toDouble()); | |
490 | m_series->append(point); |
|
510 | m_series->append(point); | |
491 | pointPos++; |
|
511 | pointPos++; | |
492 | xIndex = xModelIndex(pointPos); |
|
512 | xIndex = xModelIndex(pointPos); | |
493 | yIndex = yModelIndex(pointPos); |
|
513 | yIndex = yModelIndex(pointPos); | |
494 | } |
|
514 | } | |
495 | blockSeriesSignals(false); |
|
515 | blockSeriesSignals(false); | |
496 | } |
|
516 | } | |
497 |
|
517 | |||
498 | #include "moc_qxymodelmapper.cpp" |
|
518 | #include "moc_qxymodelmapper.cpp" | |
499 | #include "moc_qxymodelmapper_p.cpp" |
|
519 | #include "moc_qxymodelmapper_p.cpp" | |
500 |
|
520 | |||
501 | QTCOMMERCIALCHART_END_NAMESPACE |
|
521 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,57 +1,78 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
1 | #ifndef QXYMODELMAPPER_H |
|
21 | #ifndef QXYMODELMAPPER_H | |
2 | #define QXYMODELMAPPER_H |
|
22 | #define QXYMODELMAPPER_H | |
3 |
|
23 | |||
4 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
5 | #include <QObject> |
|
25 | #include <QObject> | |
6 |
|
26 | |||
7 | class QAbstractItemModel; |
|
27 | class QAbstractItemModel; | |
8 |
|
28 | |||
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
10 |
|
30 | |||
11 | class QXYModelMapperPrivate; |
|
31 | class QXYModelMapperPrivate; | |
12 | class QXYSeries; |
|
32 | class QXYSeries; | |
13 |
|
33 | |||
14 | class QTCOMMERCIALCHART_EXPORT QXYModelMapper : public QObject |
|
34 | class QTCOMMERCIALCHART_EXPORT QXYModelMapper : public QObject | |
15 | { |
|
35 | { | |
16 | Q_OBJECT |
|
36 | Q_OBJECT | |
17 | Q_PROPERTY(QXYSeries *series READ series WRITE setSeries) |
|
37 | Q_PROPERTY(QXYSeries *series READ series WRITE setSeries) | |
18 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel) |
|
38 | Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel) | |
19 | Q_PROPERTY(int first READ first WRITE setFirst) |
|
39 | Q_PROPERTY(int first READ first WRITE setFirst) | |
20 | Q_PROPERTY(int count READ count WRITE setCount) |
|
40 | Q_PROPERTY(int count READ count WRITE setCount) | |
21 | Q_ENUMS(Qt::Orientation) |
|
41 | Q_ENUMS(Qt::Orientation) | |
22 |
|
42 | |||
|
43 | protected: | |||
|
44 | explicit QXYModelMapper(QObject *parent = 0); | |||
|
45 | ||||
23 | public: |
|
46 | public: | |
24 | QAbstractItemModel* model() const; |
|
47 | QAbstractItemModel* model() const; | |
25 | void setModel(QAbstractItemModel *model); |
|
48 | void setModel(QAbstractItemModel *model); | |
26 |
|
49 | |||
27 | QXYSeries* series() const; |
|
50 | QXYSeries* series() const; | |
28 | void setSeries(QXYSeries *series); |
|
51 | void setSeries(QXYSeries *series); | |
29 |
|
52 | |||
30 | int first() const; |
|
53 | int first() const; | |
31 | void setFirst(int first); |
|
54 | void setFirst(int first); | |
32 |
|
55 | |||
33 | int count() const; |
|
56 | int count() const; | |
34 | void setCount(int count); |
|
57 | void setCount(int count); | |
35 |
|
58 | |||
36 | void reset(); |
|
59 | void reset(); | |
37 |
|
60 | |||
38 | protected: |
|
61 | protected: | |
39 | explicit QXYModelMapper(QObject *parent = 0); |
|
|||
40 |
|
||||
41 | Qt::Orientation orientation() const; |
|
62 | Qt::Orientation orientation() const; | |
42 | void setOrientation(Qt::Orientation orientation); |
|
63 | void setOrientation(Qt::Orientation orientation); | |
43 |
|
64 | |||
44 | int xSection() const; |
|
65 | int xSection() const; | |
45 | void setXSection(int xSection); |
|
66 | void setXSection(int xSection); | |
46 |
|
67 | |||
47 | int ySection() const; |
|
68 | int ySection() const; | |
48 | void setYSection(int ySection); |
|
69 | void setYSection(int ySection); | |
49 |
|
70 | |||
50 | protected: |
|
71 | protected: | |
51 | QXYModelMapperPrivate * const d_ptr; |
|
72 | QXYModelMapperPrivate * const d_ptr; | |
52 | Q_DECLARE_PRIVATE(QXYModelMapper) |
|
73 | Q_DECLARE_PRIVATE(QXYModelMapper) | |
53 | }; |
|
74 | }; | |
54 |
|
75 | |||
55 | QTCOMMERCIALCHART_END_NAMESPACE |
|
76 | QTCOMMERCIALCHART_END_NAMESPACE | |
56 |
|
77 | |||
57 | #endif // QXYMODELMAPPER_H |
|
78 | #endif // QXYMODELMAPPER_H |
@@ -1,64 +1,93 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | // W A R N I N G | |||
|
22 | // ------------- | |||
|
23 | // | |||
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |||
|
25 | // implementation detail. This header file may change from version to | |||
|
26 | // version without notice, or even be removed. | |||
|
27 | // | |||
|
28 | // We mean it. | |||
|
29 | ||||
1 | #ifndef QXYMODELMAPPER_P_H |
|
30 | #ifndef QXYMODELMAPPER_P_H | |
2 | #define QXYMODELMAPPER_P_H |
|
31 | #define QXYMODELMAPPER_P_H | |
3 |
|
32 | |||
4 | #include "qxymodelmapper.h" |
|
33 | #include "qxymodelmapper.h" | |
5 | #include <QObject> |
|
34 | #include <QObject> | |
6 |
|
35 | |||
7 | class QModelIndex; |
|
36 | class QModelIndex; | |
8 | class QAbstractItemModel; |
|
37 | class QAbstractItemModel; | |
9 | class QPointF; |
|
38 | class QPointF; | |
10 |
|
39 | |||
11 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
40 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
12 |
|
41 | |||
13 | class QXYModelMapper; |
|
42 | class QXYModelMapper; | |
14 | class QXYSeries; |
|
43 | class QXYSeries; | |
15 |
|
44 | |||
16 | class QXYModelMapperPrivate : public QObject |
|
45 | class QXYModelMapperPrivate : public QObject | |
17 | { |
|
46 | { | |
18 | Q_OBJECT |
|
47 | Q_OBJECT | |
19 |
|
48 | |||
20 | public: |
|
49 | public: | |
21 | QXYModelMapperPrivate(QXYModelMapper *q); |
|
50 | QXYModelMapperPrivate(QXYModelMapper *q); | |
22 |
|
51 | |||
23 | public Q_SLOTS: |
|
52 | public Q_SLOTS: | |
24 | // for the model |
|
53 | // for the model | |
25 | void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); |
|
54 | void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); | |
26 | void modelRowsAdded(QModelIndex parent, int start, int end); |
|
55 | void modelRowsAdded(QModelIndex parent, int start, int end); | |
27 | void modelRowsRemoved(QModelIndex parent, int start, int end); |
|
56 | void modelRowsRemoved(QModelIndex parent, int start, int end); | |
28 | void modelColumnsAdded(QModelIndex parent, int start, int end); |
|
57 | void modelColumnsAdded(QModelIndex parent, int start, int end); | |
29 | void modelColumnsRemoved(QModelIndex parent, int start, int end); |
|
58 | void modelColumnsRemoved(QModelIndex parent, int start, int end); | |
30 |
|
59 | |||
31 | // for the series |
|
60 | // for the series | |
32 | void handlePointAdded(int pointPos); |
|
61 | void handlePointAdded(int pointPos); | |
33 | void handlePointRemoved(int pointPos); |
|
62 | void handlePointRemoved(int pointPos); | |
34 | void handlePointReplaced(int pointPos); |
|
63 | void handlePointReplaced(int pointPos); | |
35 |
|
64 | |||
36 | void initializeXYFromModel(); |
|
65 | void initializeXYFromModel(); | |
37 |
|
66 | |||
38 | private: |
|
67 | private: | |
39 | QModelIndex xModelIndex(int xPos); |
|
68 | QModelIndex xModelIndex(int xPos); | |
40 | QModelIndex yModelIndex(int yPos); |
|
69 | QModelIndex yModelIndex(int yPos); | |
41 | void insertData(int start, int end); |
|
70 | void insertData(int start, int end); | |
42 | void removeData(int start, int end); |
|
71 | void removeData(int start, int end); | |
43 | void blockModelSignals(bool block = true); |
|
72 | void blockModelSignals(bool block = true); | |
44 | void blockSeriesSignals(bool block = true); |
|
73 | void blockSeriesSignals(bool block = true); | |
45 |
|
74 | |||
46 | private: |
|
75 | private: | |
47 | QXYSeries *m_series; |
|
76 | QXYSeries *m_series; | |
48 | QAbstractItemModel *m_model; |
|
77 | QAbstractItemModel *m_model; | |
49 | int m_first; |
|
78 | int m_first; | |
50 | int m_count; |
|
79 | int m_count; | |
51 | Qt::Orientation m_orientation; |
|
80 | Qt::Orientation m_orientation; | |
52 | int m_xSection; |
|
81 | int m_xSection; | |
53 | int m_ySection; |
|
82 | int m_ySection; | |
54 | bool m_seriesSignalsBlock; |
|
83 | bool m_seriesSignalsBlock; | |
55 | bool m_modelSignalsBlock; |
|
84 | bool m_modelSignalsBlock; | |
56 |
|
85 | |||
57 | private: |
|
86 | private: | |
58 | QXYModelMapper *q_ptr; |
|
87 | QXYModelMapper *q_ptr; | |
59 | Q_DECLARE_PUBLIC(QXYModelMapper) |
|
88 | Q_DECLARE_PUBLIC(QXYModelMapper) | |
60 | }; |
|
89 | }; | |
61 |
|
90 | |||
62 | QTCOMMERCIALCHART_END_NAMESPACE |
|
91 | QTCOMMERCIALCHART_END_NAMESPACE | |
63 |
|
92 | |||
64 | #endif // QXYMODELMAPPER_P_H |
|
93 | #endif // QXYMODELMAPPER_P_H |
General Comments 0
You need to be logged in to leave comments.
Login now