##// END OF EJS Templates
QXYModelMapper removed from the docs
Marek Rosa -
r1507:4d1b1b063da8
parent child
Show More
@@ -75,7 +75,7 Rectangle {
75 model: customModel
75 model: customModel
76 xRow: 0
76 xRow: 0
77 yRow: 1
77 yRow: 1
78 first: 2
78 firstColumn: 2
79 }
79 }
80 }
80 }
81 //![4]
81 //![4]
@@ -87,7 +87,7 Rectangle {
87 model: customModel
87 model: customModel
88 xRow: 0
88 xRow: 0
89 yRow: 2
89 yRow: 2
90 first: 2
90 firstColumn: 2
91 }
91 }
92 }
92 }
93
93
@@ -98,7 +98,7 Rectangle {
98 model: customModel
98 model: customModel
99 xRow: 0
99 xRow: 0
100 yRow: 3
100 yRow: 3
101 first: 2
101 firstColumn: 2
102 }
102 }
103 }
103 }
104
104
@@ -109,7 +109,7 Rectangle {
109 model: customModel
109 model: customModel
110 xRow: 0
110 xRow: 0
111 yRow: 4
111 yRow: 4
112 first: 2
112 firstColumn: 2
113 }
113 }
114 }
114 }
115
115
@@ -120,7 +120,7 Rectangle {
120 model: customModel
120 model: customModel
121 xRow: 0
121 xRow: 0
122 yRow: 5
122 yRow: 5
123 first: 2
123 firstColumn: 2
124 }
124 }
125 }
125 }
126
126
@@ -52,11 +52,11
52 </td>
52 </td>
53 <td valign="top">
53 <td valign="top">
54 <ul>
54 <ul>
55 <li><a href="qxyseries.html">QXYSeries</a></li>
55 <li><a href="qlineseries.html">QLineSeries</a></li>
56 <li><a href="qlineseries.html">QLineSeries</a></li>
56 <li><a href="qareaseries.html">QAreaSeries</a></li>
57 <li><a href="qareaseries.html">QAreaSeries</a></li>
57 <li><a href="qscatterseries.html">QScatterSeries</a></li>
58 <li><a href="qscatterseries.html">QScatterSeries</a></li>
58 <li><a href="qsplineseries.html">QSplineSeries</a></li>
59 <li><a href="qsplineseries.html">QSplineSeries</a></li>
59 <li><a href="qxymodelmapper.html">QXYModelMapper</a></li>
60 <li><a href="qhxymodelmapper.html">QHXYModelMapper</a></li>
60 <li><a href="qhxymodelmapper.html">QHXYModelMapper</a></li>
61 <li><a href="qvxymodelmapper.html">QVXYModelMapper</a></li>
61 <li><a href="qvxymodelmapper.html">QVXYModelMapper</a></li>
62 </ul>
62 </ul>
@@ -24,7 +24,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24
24
25 /*!
25 /*!
26 \class QHXYModelMapper
26 \class QHXYModelMapper
27 \brief part of QtCommercial chart API.
28 \mainclass
27 \mainclass
29
28
30 Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series.
29 Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series.
@@ -34,6 +33,19 QTCOMMERCIALCHART_BEGIN_NAMESPACE
34 */
33 */
35
34
36 /*!
35 /*!
36 \property QHXYModelMapper::series
37 \brief Defines the QXYSeries object that is used by the mapper.
38
39 All the data in the series is discarded when it is set to the mapper.
40 When new series is specified the old series is disconnected (it preserves its data)
41 */
42
43 /*!
44 \property QHXYModelMapper::model
45 \brief Defines the model that is used by the mapper.
46 */
47
48 /*!
37 \property QHXYModelMapper::xRow
49 \property QHXYModelMapper::xRow
38 \brief Defines which row of the model is kept in sync with the x values of the QXYSeries
50 \brief Defines which row of the model is kept in sync with the x values of the QXYSeries
39 Default value is: -1 (invalid mapping)
51 Default value is: -1 (invalid mapping)
@@ -47,6 +59,40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
47 */
59 */
48
60
49 /*!
61 /*!
62 \property QHXYModelMapper::firstColumn
63 \brief Defines which column of the model contains the data for the first point of the series.
64 Minimal and default value is: 0
65 */
66 /*!
67 \qmlproperty int QHXYModelMapper::firstColumn
68 Defines which column of the model contains the data for the first point of the series.
69 The default value is 0.
70 */
71
72 /*!
73 \property QHXYModelMapper::columnCount
74 \brief Defines the number of columns of the model that are mapped as the data for series
75 Minimal and default value is: -1 (count limited by the number of columns in the model)
76 */
77 /*!
78 \qmlproperty int QHXYModelMapper::columnCount
79 Defines the number of columns of the model that are mapped as the data for series. The default value is
80 -1 (count limited by the number of columns in the model)
81 */
82
83 /*!
84 \fn void QHXYModelMapper::seriesReplaced()
85
86 Emitted when the series to which mapper is connected to has changed.
87 */
88
89 /*!
90 \fn void QHXYModelMapper::modelReplaced()
91
92 Emitted when the model to which mapper is connected to has changed.
93 */
94
95 /*!
50 \fn void QHXYModelMapper::xRowChanged()
96 \fn void QHXYModelMapper::xRowChanged()
51
97
52 Emitted when the xRow has changed.
98 Emitted when the xRow has changed.
@@ -59,6 +105,16 QTCOMMERCIALCHART_BEGIN_NAMESPACE
59 */
105 */
60
106
61 /*!
107 /*!
108 \fn void QHXYModelMapper::firstColumnChanged()
109 Emitted when the firstColumn has changed.
110 */
111
112 /*!
113 \fn void QHXYModelMapper::columnCountChanged()
114 Emitted when the columnCount has changed.
115 */
116
117 /*!
62 Constructs a mapper object which is a child of \a parent.
118 Constructs a mapper object which is a child of \a parent.
63 */
119 */
64 QHXYModelMapper::QHXYModelMapper(QObject *parent) :
120 QHXYModelMapper::QHXYModelMapper(QObject *parent) :
@@ -67,6 +123,32 QHXYModelMapper::QHXYModelMapper(QObject *parent) :
67 QXYModelMapper::setOrientation(Qt::Horizontal);
123 QXYModelMapper::setOrientation(Qt::Horizontal);
68 }
124 }
69
125
126 QAbstractItemModel* QHXYModelMapper::model() const
127 {
128 return QXYModelMapper::model();
129 }
130
131 void QHXYModelMapper::setModel(QAbstractItemModel *model)
132 {
133 if (model != QXYModelMapper::model()) {
134 QXYModelMapper::setModel(model);
135 emit modelReplaced();
136 }
137 }
138
139 QXYSeries* QHXYModelMapper::series() const
140 {
141 return QXYModelMapper::series();
142 }
143
144 void QHXYModelMapper::setSeries(QXYSeries *series)
145 {
146 if (series != QXYModelMapper::series()) {
147 QXYModelMapper::setSeries(series);
148 emit seriesReplaced();
149 }
150 }
151
70 int QHXYModelMapper::xRow() const
152 int QHXYModelMapper::xRow() const
71 {
153 {
72 return QXYModelMapper::xSection();
154 return QXYModelMapper::xSection();
@@ -93,6 +175,32 void QHXYModelMapper::setYRow(int yRow)
93 }
175 }
94 }
176 }
95
177
178 int QHXYModelMapper::firstColumn() const
179 {
180 return first();
181 }
182
183 void QHXYModelMapper::setFirstColumn(int firstColumn)
184 {
185 if (firstColumn != first()) {
186 setFirst(firstColumn);
187 emit firstColumnChanged();
188 }
189 }
190
191 int QHXYModelMapper::columnCount() const
192 {
193 return count();
194 }
195
196 void QHXYModelMapper::setColumnCount(int columnCount)
197 {
198 if (columnCount != count()) {
199 setCount(columnCount);
200 emit firstColumnChanged();
201 }
202 }
203
96 #include "moc_qhxymodelmapper.cpp"
204 #include "moc_qhxymodelmapper.cpp"
97
205
98 QTCOMMERCIALCHART_END_NAMESPACE
206 QTCOMMERCIALCHART_END_NAMESPACE
@@ -28,21 +28,41 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 class QTCOMMERCIALCHART_EXPORT QHXYModelMapper : public QXYModelMapper
28 class QTCOMMERCIALCHART_EXPORT QHXYModelMapper : public QXYModelMapper
29 {
29 {
30 Q_OBJECT
30 Q_OBJECT
31 Q_PROPERTY(QXYSeries *series READ series WRITE setSeries NOTIFY seriesReplaced)
32 Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced)
31 Q_PROPERTY(int xRow READ xRow WRITE setXRow NOTIFY xRowChanged)
33 Q_PROPERTY(int xRow READ xRow WRITE setXRow NOTIFY xRowChanged)
32 Q_PROPERTY(int yRow READ yRow WRITE setYRow NOTIFY yRowChanged)
34 Q_PROPERTY(int yRow READ yRow WRITE setYRow NOTIFY yRowChanged)
35 Q_PROPERTY(int firstColumn READ firstColumn WRITE setFirstColumn NOTIFY firstColumnChanged)
36 Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount NOTIFY columnCountChanged)
33
37
34 public:
38 public:
35 explicit QHXYModelMapper(QObject *parent = 0);
39 explicit QHXYModelMapper(QObject *parent = 0);
36
40
41 QAbstractItemModel* model() const;
42 void setModel(QAbstractItemModel *model);
43
44 QXYSeries* series() const;
45 void setSeries(QXYSeries *series);
46
37 int xRow() const;
47 int xRow() const;
38 void setXRow(int xRow);
48 void setXRow(int xRow);
39
49
40 int yRow() const;
50 int yRow() const;
41 void setYRow(int yRow);
51 void setYRow(int yRow);
42
52
53 int firstColumn() const;
54 void setFirstColumn(int firstColumn);
55
56 int columnCount() const;
57 void setColumnCount(int columnCount);
58
43 Q_SIGNALS:
59 Q_SIGNALS:
60 void seriesReplaced();
61 void modelReplaced();
44 void xRowChanged();
62 void xRowChanged();
45 void yRowChanged();
63 void yRowChanged();
64 void firstColumnChanged();
65 void columnCountChanged();
46 };
66 };
47
67
48 QTCOMMERCIALCHART_END_NAMESPACE
68 QTCOMMERCIALCHART_END_NAMESPACE
@@ -24,7 +24,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24
24
25 /*!
25 /*!
26 \class QVXYModelMapper
26 \class QVXYModelMapper
27 \brief part of QtCommercial chart API.
28 \mainclass
27 \mainclass
29
28
30 Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series.
29 Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series.
@@ -34,6 +33,19 QTCOMMERCIALCHART_BEGIN_NAMESPACE
34 */
33 */
35
34
36 /*!
35 /*!
36 \property QVXYModelMapper::series
37 \brief Defines the QXYSeries object that is used by the mapper.
38
39 All the data in the series is discarded when it is set to the mapper.
40 When new series is specified the old series is disconnected (it preserves its data)
41 */
42
43 /*!
44 \property QVXYModelMapper::model
45 \brief Defines the model that is used by the mapper.
46 */
47
48 /*!
37 \property QVXYModelMapper::xColumn
49 \property QVXYModelMapper::xColumn
38 \brief Defines which column of the model is kept in sync with the x values of QXYSeries
50 \brief Defines which column of the model is kept in sync with the x values of QXYSeries
39
51
@@ -48,6 +60,40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
48 */
60 */
49
61
50 /*!
62 /*!
63 \property QVXYModelMapper::firstRow
64 \brief Defines which row of the model contains the data for the first point of the series.
65 Minimal and default value is: 0
66 */
67 /*!
68 \qmlproperty int QVXYModelMapper::firstRow
69 Defines which row of the model contains the data for the first point of the series.
70 The default value is 0.
71 */
72
73 /*!
74 \property QVXYModelMapper::rowCount
75 \brief Defines the number of rows of the model that are mapped as the data for series
76 Minimal and default value is: -1 (count limited by the number of rows in the model)
77 */
78 /*!
79 \qmlproperty int QVXYModelMapper::columnCount
80 Defines the number of rows of the model that are mapped as the data for series. The default value is
81 -1 (count limited by the number of rows in the model)
82 */
83
84 /*!
85 \fn void QVXYModelMapper::seriesReplaced()
86
87 Emitted when the series to which mapper is connected to has changed.
88 */
89
90 /*!
91 \fn void QVXYModelMapper::modelReplaced()
92
93 Emitted when the model to which mapper is connected to has changed.
94 */
95
96 /*!
51 \fn void QVXYModelMapper::xColumnChanged()
97 \fn void QVXYModelMapper::xColumnChanged()
52
98
53 Emitted when the xColumn has changed.
99 Emitted when the xColumn has changed.
@@ -60,6 +106,16 QTCOMMERCIALCHART_BEGIN_NAMESPACE
60 */
106 */
61
107
62 /*!
108 /*!
109 \fn void QVXYModelMapper::firstRowChanged()
110 Emitted when the firstRow has changed.
111 */
112
113 /*!
114 \fn void QVXYModelMapper::rowCountChanged()
115 Emitted when the rowCount has changed.
116 */
117
118 /*!
63 Constructs a mapper object which is a child of \a parent.
119 Constructs a mapper object which is a child of \a parent.
64 */
120 */
65 QVXYModelMapper::QVXYModelMapper(QObject *parent) :
121 QVXYModelMapper::QVXYModelMapper(QObject *parent) :
@@ -68,6 +124,32 QVXYModelMapper::QVXYModelMapper(QObject *parent) :
68 QXYModelMapper::setOrientation(Qt::Vertical);
124 QXYModelMapper::setOrientation(Qt::Vertical);
69 }
125 }
70
126
127 QAbstractItemModel* QVXYModelMapper::model() const
128 {
129 return QXYModelMapper::model();
130 }
131
132 void QVXYModelMapper::setModel(QAbstractItemModel *model)
133 {
134 if (model != QXYModelMapper::model()) {
135 QXYModelMapper::setModel(model);
136 emit modelReplaced();
137 }
138 }
139
140 QXYSeries* QVXYModelMapper::series() const
141 {
142 return QXYModelMapper::series();
143 }
144
145 void QVXYModelMapper::setSeries(QXYSeries *series)
146 {
147 if (series != QXYModelMapper::series()) {
148 QXYModelMapper::setSeries(series);
149 emit seriesReplaced();
150 }
151 }
152
71 int QVXYModelMapper::xColumn() const
153 int QVXYModelMapper::xColumn() const
72 {
154 {
73 return QXYModelMapper::xSection();
155 return QXYModelMapper::xSection();
@@ -94,6 +176,32 void QVXYModelMapper::setYColumn(int yColumn)
94 }
176 }
95 }
177 }
96
178
179 int QVXYModelMapper::firstRow() const
180 {
181 return first();
182 }
183
184 void QVXYModelMapper::setFirstRow(int firstRow)
185 {
186 if (firstRow != first()) {
187 setFirst(firstRow);
188 emit firstRowChanged();
189 }
190 }
191
192 int QVXYModelMapper::rowCount() const
193 {
194 return count();
195 }
196
197 void QVXYModelMapper::setRowCount(int rowCount)
198 {
199 if (rowCount != count()) {
200 setCount(rowCount);
201 emit firstRowChanged();
202 }
203 }
204
97 #include "moc_qvxymodelmapper.cpp"
205 #include "moc_qvxymodelmapper.cpp"
98
206
99 QTCOMMERCIALCHART_END_NAMESPACE
207 QTCOMMERCIALCHART_END_NAMESPACE
@@ -28,21 +28,41 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 class QTCOMMERCIALCHART_EXPORT QVXYModelMapper : public QXYModelMapper
28 class QTCOMMERCIALCHART_EXPORT QVXYModelMapper : public QXYModelMapper
29 {
29 {
30 Q_OBJECT
30 Q_OBJECT
31 Q_PROPERTY(QXYSeries *series READ series WRITE setSeries NOTIFY seriesReplaced)
32 Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced)
31 Q_PROPERTY(int xColumn READ xColumn WRITE setXColumn NOTIFY xColumnChanged)
33 Q_PROPERTY(int xColumn READ xColumn WRITE setXColumn NOTIFY xColumnChanged)
32 Q_PROPERTY(int yColumn READ yColumn WRITE setYColumn NOTIFY yColumnChanged)
34 Q_PROPERTY(int yColumn READ yColumn WRITE setYColumn NOTIFY yColumnChanged)
35 Q_PROPERTY(int firstRow READ firstRow WRITE setFirstRow NOTIFY firstRowChanged)
36 Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged)
33
37
34 public:
38 public:
35 explicit QVXYModelMapper(QObject *parent = 0);
39 explicit QVXYModelMapper(QObject *parent = 0);
36
40
41 QAbstractItemModel* model() const;
42 void setModel(QAbstractItemModel *model);
43
44 QXYSeries* series() const;
45 void setSeries(QXYSeries *series);
46
37 int xColumn() const;
47 int xColumn() const;
38 void setXColumn(int xColumn);
48 void setXColumn(int xColumn);
39
49
40 int yColumn() const;
50 int yColumn() const;
41 void setYColumn(int yColumn);
51 void setYColumn(int yColumn);
42
52
53 int firstRow() const;
54 void setFirstRow(int firstRow);
55
56 int rowCount() const;
57 void setRowCount(int rowCount);
58
43 Q_SIGNALS:
59 Q_SIGNALS:
60 void seriesReplaced();
61 void modelReplaced();
44 void xColumnChanged();
62 void xColumnChanged();
45 void yColumnChanged();
63 void yColumnChanged();
64 void firstRowChanged();
65 void rowCountChanged();
46 };
66 };
47
67
48 QTCOMMERCIALCHART_END_NAMESPACE
68 QTCOMMERCIALCHART_END_NAMESPACE
@@ -26,68 +26,6
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 /*!
28 /*!
29 \class QXYModelMapper
30 \brief part of QtCommercial chart API.
31 \mainclass
32
33 Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series.
34 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.
35 It is possible to use both QAbstractItemModel and QXYSeries model API. QXYModelMapper makes sure that QXYSeries and the model are kept in sync.
36 NOTE: used model has to support adding/removing rows/columns and modifying the data of the cells.
37 */
38
39 /*!
40 \property QXYModelMapper::series
41 \brief Defines the QPieSeries object that is used by the mapper.
42
43 All the data in the series is discarded when it is set to the mapper.
44 When new series is specified the old series is disconnected (it preserves its data)
45 */
46
47 /*!
48 \property QXYModelMapper::model
49 \brief Defines the model that is used by the mapper.
50 */
51
52 /*!
53 \property QXYModelMapper::first
54 \brief Defines which item of the model's row/column should be mapped as the first x/y pair
55
56 Minimal and default value is: 0
57 */
58
59 /*!
60 \property QXYModelMapper::count
61 \brief Defines the number of rows/columns of the model that are mapped as the data for QXYSeries
62
63 Minimal and default value is: -1 (count limited by the number of rows/columns in the model)
64 */
65
66 /*!
67 \fn void QXYModelMapper::seriesReplaced()
68
69 Emitted when the series to which mapper is connected to has changed.
70 */
71
72 /*!
73 \fn void QXYModelMapper::modelReplaced()
74
75 Emitted when the model to which mapper is connected to has changed.
76 */
77
78 /*!
79 \fn void QXYModelMapper::firstChanged()
80
81 Emitted when the value for the first has changed.
82 */
83
84 /*!
85 \fn void QXYModelMapper::countChanged()
86
87 Emitted when the value for the count has changed.
88 */
89
90 /*!
91 Constructs a mapper object which is a child of \a parent.
29 Constructs a mapper object which is a child of \a parent.
92 */
30 */
93 QXYModelMapper::QXYModelMapper(QObject *parent):
31 QXYModelMapper::QXYModelMapper(QObject *parent):
@@ -96,12 +34,18 QXYModelMapper::QXYModelMapper(QObject *parent):
96 {
34 {
97 }
35 }
98
36
37 /*!
38 \internal
39 */
99 QAbstractItemModel* QXYModelMapper::model() const
40 QAbstractItemModel* QXYModelMapper::model() const
100 {
41 {
101 Q_D(const QXYModelMapper);
42 Q_D(const QXYModelMapper);
102 return d->m_model;
43 return d->m_model;
103 }
44 }
104
45
46 /*!
47 \internal
48 */
105 void QXYModelMapper::setModel(QAbstractItemModel *model)
49 void QXYModelMapper::setModel(QAbstractItemModel *model)
106 {
50 {
107 if (model == 0)
51 if (model == 0)
@@ -120,16 +64,20 void QXYModelMapper::setModel(QAbstractItemModel *model)
120 connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int)));
64 connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int)));
121 connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int)));
65 connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int)));
122 connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int)));
66 connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int)));
123
124 emit modelReplaced();
125 }
67 }
126
68
69 /*!
70 \internal
71 */
127 QXYSeries* QXYModelMapper::series() const
72 QXYSeries* QXYModelMapper::series() const
128 {
73 {
129 Q_D(const QXYModelMapper);
74 Q_D(const QXYModelMapper);
130 return d->m_series;
75 return d->m_series;
131 }
76 }
132
77
78 /*!
79 \internal
80 */
133 void QXYModelMapper::setSeries(QXYSeries *series)
81 void QXYModelMapper::setSeries(QXYSeries *series)
134 {
82 {
135 Q_D(QXYModelMapper);
83 Q_D(QXYModelMapper);
@@ -146,42 +94,44 void QXYModelMapper::setSeries(QXYSeries *series)
146 connect(d->m_series, SIGNAL(pointAdded(int)), d, SLOT(handlePointAdded(int)));
94 connect(d->m_series, SIGNAL(pointAdded(int)), d, SLOT(handlePointAdded(int)));
147 connect(d->m_series, SIGNAL(pointRemoved(int)), d, SLOT(handlePointRemoved(int)));
95 connect(d->m_series, SIGNAL(pointRemoved(int)), d, SLOT(handlePointRemoved(int)));
148 connect(d->m_series, SIGNAL(pointReplaced(int)), d, SLOT(handlePointReplaced(int)));
96 connect(d->m_series, SIGNAL(pointReplaced(int)), d, SLOT(handlePointReplaced(int)));
149
150 emit seriesReplaced();
151 }
97 }
152
98
99 /*!
100 \internal
101 */
153 int QXYModelMapper::first() const
102 int QXYModelMapper::first() const
154 {
103 {
155 Q_D(const QXYModelMapper);
104 Q_D(const QXYModelMapper);
156 return d->m_first;
105 return d->m_first;
157 }
106 }
158
107
108 /*!
109 \internal
110 */
159 void QXYModelMapper::setFirst(int first)
111 void QXYModelMapper::setFirst(int first)
160 {
112 {
161 Q_D(QXYModelMapper);
113 Q_D(QXYModelMapper);
162 if (first != d->m_first) {
163 d->m_first = qMax(first, 0);
114 d->m_first = qMax(first, 0);
164 d->initializeXYFromModel();
115 d->initializeXYFromModel();
165
166 emit firstChanged();
167 }
168 }
116 }
169
117
118 /*!
119 \internal
120 */
170 int QXYModelMapper::count() const
121 int QXYModelMapper::count() const
171 {
122 {
172 Q_D(const QXYModelMapper);
123 Q_D(const QXYModelMapper);
173 return d->m_count;
124 return d->m_count;
174 }
125 }
175
126
127 /*!
128 \internal
129 */
176 void QXYModelMapper::setCount(int count)
130 void QXYModelMapper::setCount(int count)
177 {
131 {
178 Q_D(QXYModelMapper);
132 Q_D(QXYModelMapper);
179 if (count != d->m_count) {
180 d->m_count = qMax(count, -1);
133 d->m_count = qMax(count, -1);
181 d->initializeXYFromModel();
134 d->initializeXYFromModel();
182
183 emit countChanged();
184 }
185 }
135 }
186
136
187 /*!
137 /*!
@@ -247,21 +197,6 void QXYModelMapper::setYSection(int ySection)
247 d->initializeXYFromModel();
197 d->initializeXYFromModel();
248 }
198 }
249
199
250 /*!
251 Resets the QXYModelMapper to the default state.
252 first: 0; count: -1; xSection: -1; ySection: -1;
253 */
254 void QXYModelMapper::reset()
255 {
256 Q_D(QXYModelMapper);
257 d->m_first = 0;
258 d->m_count = -1;
259 d->m_orientation = Qt::Vertical;
260 d->m_xSection = -1;
261 d->m_ySection = -1;
262 d->initializeXYFromModel();
263 }
264
265 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
200 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
266
201
267 QXYModelMapperPrivate::QXYModelMapperPrivate(QXYModelMapper *q) :
202 QXYModelMapperPrivate::QXYModelMapperPrivate(QXYModelMapper *q) :
@@ -34,16 +34,10 class QXYSeries;
34 class QTCOMMERCIALCHART_EXPORT QXYModelMapper : public QObject
34 class QTCOMMERCIALCHART_EXPORT QXYModelMapper : public QObject
35 {
35 {
36 Q_OBJECT
36 Q_OBJECT
37 Q_PROPERTY(QXYSeries *series READ series WRITE setSeries NOTIFY seriesReplaced)
38 Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced)
39 Q_PROPERTY(int first READ first WRITE setFirst NOTIFY firstChanged)
40 Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged)
41 Q_ENUMS(Qt::Orientation)
42
37
43 protected:
38 protected:
44 explicit QXYModelMapper(QObject *parent = 0);
39 explicit QXYModelMapper(QObject *parent = 0);
45
40
46 public:
47 QAbstractItemModel* model() const;
41 QAbstractItemModel* model() const;
48 void setModel(QAbstractItemModel *model);
42 void setModel(QAbstractItemModel *model);
49
43
@@ -56,9 +50,6 public:
56 int count() const;
50 int count() const;
57 void setCount(int count);
51 void setCount(int count);
58
52
59 void reset();
60
61 protected:
62 Qt::Orientation orientation() const;
53 Qt::Orientation orientation() const;
63 void setOrientation(Qt::Orientation orientation);
54 void setOrientation(Qt::Orientation orientation);
64
55
@@ -68,12 +59,6 protected:
68 int ySection() const;
59 int ySection() const;
69 void setYSection(int ySection);
60 void setYSection(int ySection);
70
61
71 Q_SIGNALS:
72 void seriesReplaced();
73 void modelReplaced();
74 void firstChanged();
75 void countChanged();
76
77 protected:
62 protected:
78 QXYModelMapperPrivate * const d_ptr;
63 QXYModelMapperPrivate * const d_ptr;
79 Q_DECLARE_PRIVATE(QXYModelMapper)
64 Q_DECLARE_PRIVATE(QXYModelMapper)
@@ -218,8 +218,8 void tst_qxymodelmapper::verticalMapperCustomMapping()
218 mapper->setYColumn(1);
218 mapper->setYColumn(1);
219 mapper->setModel(m_model);
219 mapper->setModel(m_model);
220 mapper->setSeries(m_series);
220 mapper->setSeries(m_series);
221 mapper->setFirst(first);
221 mapper->setFirstRow(first);
222 mapper->setCount(countLimit);
222 mapper->setRowCount(countLimit);
223
223
224 QCOMPARE(m_series->count(), expectedCount);
224 QCOMPARE(m_series->count(), expectedCount);
225
225
@@ -295,8 +295,8 void tst_qxymodelmapper::horizontalMapperCustomMapping()
295 mapper->setYRow(1);
295 mapper->setYRow(1);
296 mapper->setModel(m_model);
296 mapper->setModel(m_model);
297 mapper->setSeries(m_series);
297 mapper->setSeries(m_series);
298 mapper->setFirst(first);
298 mapper->setFirstColumn(first);
299 mapper->setCount(countLimit);
299 mapper->setColumnCount(countLimit);
300
300
301 QCOMPARE(m_series->count(), expectedCount);
301 QCOMPARE(m_series->count(), expectedCount);
302
302
@@ -315,15 +315,15 void tst_qxymodelmapper::seriesUpdated()
315 // setup the mapper
315 // setup the mapper
316 createVerticalMapper();
316 createVerticalMapper();
317 QCOMPARE(m_series->count(), m_modelRowCount);
317 QCOMPARE(m_series->count(), m_modelRowCount);
318 QCOMPARE(m_vMapper->count(), -1);
318 QCOMPARE(m_vMapper->rowCount(), -1);
319
319
320 m_series->append(QPointF(100, 100));
320 m_series->append(QPointF(100, 100));
321 QCOMPARE(m_series->count(), m_modelRowCount + 1);
321 QCOMPARE(m_series->count(), m_modelRowCount + 1);
322 QCOMPARE(m_vMapper->count(), -1); // the value should not change as it indicates 'all' items there are in the model
322 QCOMPARE(m_vMapper->rowCount(), -1); // the value should not change as it indicates 'all' items there are in the model
323
323
324 m_series->remove(m_series->points().last());
324 m_series->remove(m_series->points().last());
325 QCOMPARE(m_series->count(), m_modelRowCount);
325 QCOMPARE(m_series->count(), m_modelRowCount);
326 QCOMPARE(m_vMapper->count(), -1); // the value should not change as it indicates 'all' items there are in the model
326 QCOMPARE(m_vMapper->rowCount(), -1); // the value should not change as it indicates 'all' items there are in the model
327
327
328 m_series->replace(m_series->points().first(), QPointF(25.0, 75.0));
328 m_series->replace(m_series->points().first(), QPointF(25.0, 75.0));
329 QCOMPARE(m_model->data(m_model->index(0, 0)).toReal(), 25.0);
329 QCOMPARE(m_model->data(m_model->index(0, 0)).toReal(), 25.0);
@@ -342,23 +342,23 void tst_qxymodelmapper::verticalModelInsertRows()
342 QCOMPARE(m_series->count(), m_modelRowCount + insertCount);
342 QCOMPARE(m_series->count(), m_modelRowCount + insertCount);
343
343
344 int first = 3;
344 int first = 3;
345 m_vMapper->setFirst(3);
345 m_vMapper->setFirstRow(3);
346 QCOMPARE(m_series->count(), m_modelRowCount + insertCount - first);
346 QCOMPARE(m_series->count(), m_modelRowCount + insertCount - first);
347
347
348 m_model->insertRows(3, insertCount);
348 m_model->insertRows(3, insertCount);
349 QCOMPARE(m_series->count(), m_modelRowCount + 2 * insertCount - first);
349 QCOMPARE(m_series->count(), m_modelRowCount + 2 * insertCount - first);
350
350
351 int countLimit = 6;
351 int countLimit = 6;
352 m_vMapper->setCount(countLimit);
352 m_vMapper->setRowCount(countLimit);
353 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 2 * insertCount - first));
353 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 2 * insertCount - first));
354
354
355 m_model->insertRows(3, insertCount);
355 m_model->insertRows(3, insertCount);
356 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount - first));
356 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount - first));
357
357
358 m_vMapper->setFirst(0);
358 m_vMapper->setFirstRow(0);
359 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount));
359 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount));
360
360
361 m_vMapper->setCount(-1);
361 m_vMapper->setRowCount(-1);
362 QCOMPARE(m_series->count(), m_modelRowCount + 3 * insertCount);
362 QCOMPARE(m_series->count(), m_modelRowCount + 3 * insertCount);
363 }
363 }
364
364
@@ -374,23 +374,23 void tst_qxymodelmapper::verticalModelRemoveRows()
374 QCOMPARE(m_series->count(), m_modelRowCount - removeCount);
374 QCOMPARE(m_series->count(), m_modelRowCount - removeCount);
375
375
376 int first = 1;
376 int first = 1;
377 m_vMapper->setFirst(first);
377 m_vMapper->setFirstRow(first);
378 QCOMPARE(m_series->count(), m_modelRowCount - removeCount - first);
378 QCOMPARE(m_series->count(), m_modelRowCount - removeCount - first);
379
379
380 m_model->removeRows(1, removeCount);
380 m_model->removeRows(1, removeCount);
381 QCOMPARE(m_series->count(), m_modelRowCount - 2 * removeCount - first);
381 QCOMPARE(m_series->count(), m_modelRowCount - 2 * removeCount - first);
382
382
383 int countLimit = 3;
383 int countLimit = 3;
384 m_vMapper->setCount(countLimit);
384 m_vMapper->setRowCount(countLimit);
385 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 2 * removeCount - first));
385 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 2 * removeCount - first));
386
386
387 m_model->removeRows(1, removeCount);
387 m_model->removeRows(1, removeCount);
388 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount - first));
388 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount - first));
389
389
390 m_vMapper->setFirst(0);
390 m_vMapper->setFirstRow(0);
391 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount));
391 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount));
392
392
393 m_vMapper->setCount(-1);
393 m_vMapper->setRowCount(-1);
394 QCOMPARE(m_series->count(), m_modelRowCount - 3 * removeCount);
394 QCOMPARE(m_series->count(), m_modelRowCount - 3 * removeCount);
395 }
395 }
396
396
@@ -462,23 +462,23 void tst_qxymodelmapper::horizontalModelInsertColumns()
462 QCOMPARE(m_series->count(), m_modelColumnCount + insertCount);
462 QCOMPARE(m_series->count(), m_modelColumnCount + insertCount);
463
463
464 int first = 3;
464 int first = 3;
465 m_hMapper->setFirst(3);
465 m_hMapper->setFirstColumn(3);
466 QCOMPARE(m_series->count(), m_modelColumnCount + insertCount - first);
466 QCOMPARE(m_series->count(), m_modelColumnCount + insertCount - first);
467
467
468 m_model->insertColumns(3, insertCount);
468 m_model->insertColumns(3, insertCount);
469 QCOMPARE(m_series->count(), m_modelColumnCount + 2 * insertCount - first);
469 QCOMPARE(m_series->count(), m_modelColumnCount + 2 * insertCount - first);
470
470
471 int countLimit = 6;
471 int countLimit = 6;
472 m_hMapper->setCount(countLimit);
472 m_hMapper->setColumnCount(countLimit);
473 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 2 * insertCount - first));
473 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 2 * insertCount - first));
474
474
475 m_model->insertColumns(3, insertCount);
475 m_model->insertColumns(3, insertCount);
476 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount - first));
476 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount - first));
477
477
478 m_hMapper->setFirst(0);
478 m_hMapper->setFirstColumn(0);
479 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount));
479 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount));
480
480
481 m_hMapper->setCount(-1);
481 m_hMapper->setColumnCount(-1);
482 QCOMPARE(m_series->count(), m_modelColumnCount + 3 * insertCount);
482 QCOMPARE(m_series->count(), m_modelColumnCount + 3 * insertCount);
483 }
483 }
484
484
@@ -494,23 +494,23 void tst_qxymodelmapper::horizontalModelRemoveColumns()
494 QCOMPARE(m_series->count(), m_modelColumnCount - removeCount);
494 QCOMPARE(m_series->count(), m_modelColumnCount - removeCount);
495
495
496 int first = 1;
496 int first = 1;
497 m_hMapper->setFirst(first);
497 m_hMapper->setFirstColumn(first);
498 QCOMPARE(m_series->count(), m_modelColumnCount - removeCount - first);
498 QCOMPARE(m_series->count(), m_modelColumnCount - removeCount - first);
499
499
500 m_model->removeColumns(1, removeCount);
500 m_model->removeColumns(1, removeCount);
501 QCOMPARE(m_series->count(), m_modelColumnCount - 2 * removeCount - first);
501 QCOMPARE(m_series->count(), m_modelColumnCount - 2 * removeCount - first);
502
502
503 int countLimit = 3;
503 int countLimit = 3;
504 m_hMapper->setCount(countLimit);
504 m_hMapper->setColumnCount(countLimit);
505 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 2 * removeCount - first));
505 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 2 * removeCount - first));
506
506
507 m_model->removeColumns(1, removeCount);
507 m_model->removeColumns(1, removeCount);
508 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount - first));
508 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount - first));
509
509
510 m_hMapper->setFirst(0);
510 m_hMapper->setFirstColumn(0);
511 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount));
511 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount));
512
512
513 m_hMapper->setCount(-1);
513 m_hMapper->setColumnCount(-1);
514 QCOMPARE(m_series->count(), m_modelColumnCount - 3 * removeCount);
514 QCOMPARE(m_series->count(), m_modelColumnCount - 3 * removeCount);
515 }
515 }
516
516
General Comments 0
You need to be logged in to leave comments. Login now