##// END OF EJS Templates
PieModelMapper properties first and count moved to Vertical and Horizontal mappers with more descriptive names
Marek Rosa -
r1499:436d384fa943
parent child
Show More
@@ -149,7 +149,7 Rectangle {
149 model: customModel
149 model: customModel
150 labelsColumn: 1
150 labelsColumn: 1
151 valuesColumn: 2
151 valuesColumn: 2
152 first: 1
152 firstRow: 1
153 }
153 }
154 }
154 }
155 }
155 }
@@ -48,6 +48,28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
48 */
48 */
49
49
50 /*!
50 /*!
51 \property QHPieModelMapper::firstColumn
52 \brief Defines which column of the model contains the first slice value.
53 Minimal and default value is: 0
54 */
55 /*!
56 \qmlproperty int QHPieModelMapper::firstColumn
57 Defines which column of the model contains the first slice value.
58 The default value is 0.
59 */
60
61 /*!
62 \property QHPieModelMapper::columnCount
63 \brief Defines the number of columns of the model that are mapped as the data for QPieSeries
64 Minimal and default value is: -1 (count limited by the number of columns in the model)
65 */
66 /*!
67 \qmlproperty int QHPieModelMapper::columnCount
68 Defines the number of columns of the model that are mapped as the data for QPieSeries. The default value is
69 -1 (count limited by the number of columns in the model)
70 */
71
72 /*!
51 \fn void QHPieModelMapper::valuesRowChanged()
73 \fn void QHPieModelMapper::valuesRowChanged()
52
74
53 Emitted when the valuesRow has changed.
75 Emitted when the valuesRow has changed.
@@ -60,12 +82,22 QTCOMMERCIALCHART_BEGIN_NAMESPACE
60 */
82 */
61
83
62 /*!
84 /*!
85 \fn void QHPieModelMapper::firstColumnChanged()
86 Emitted when the firstColumn has changed.
87 */
88
89 /*!
90 \fn void QHPieModelMapper::columnCountChanged()
91 Emitted when the columnCount has changed.
92 */
93
94 /*!
63 Constructs a mapper object which is a child of \a parent.
95 Constructs a mapper object which is a child of \a parent.
64 */
96 */
65 QHPieModelMapper::QHPieModelMapper(QObject *parent) :
97 QHPieModelMapper::QHPieModelMapper(QObject *parent) :
66 QPieModelMapper(parent)
98 QPieModelMapper(parent)
67 {
99 {
68 QPieModelMapper::setOrientation(Qt::Horizontal);
100 setOrientation(Qt::Horizontal);
69 }
101 }
70
102
71 /*!
103 /*!
@@ -73,7 +105,7 QHPieModelMapper::QHPieModelMapper(QObject *parent) :
73 */
105 */
74 int QHPieModelMapper::valuesRow() const
106 int QHPieModelMapper::valuesRow() const
75 {
107 {
76 return QPieModelMapper::valuesSection();
108 return valuesSection();
77 }
109 }
78
110
79 /*!
111 /*!
@@ -83,7 +115,7 int QHPieModelMapper::valuesRow() const
83 void QHPieModelMapper::setValuesRow(int valuesRow)
115 void QHPieModelMapper::setValuesRow(int valuesRow)
84 {
116 {
85 if (valuesRow != valuesSection()) {
117 if (valuesRow != valuesSection()) {
86 QPieModelMapper::setValuesSection(valuesRow);
118 setValuesSection(valuesRow);
87 emit valuesRowChanged();
119 emit valuesRowChanged();
88 }
120 }
89 }
121 }
@@ -93,7 +125,7 void QHPieModelMapper::setValuesRow(int valuesRow)
93 */
125 */
94 int QHPieModelMapper::labelsRow() const
126 int QHPieModelMapper::labelsRow() const
95 {
127 {
96 return QPieModelMapper::labelsSection();
128 return labelsSection();
97 }
129 }
98
130
99 /*!
131 /*!
@@ -103,11 +135,37 int QHPieModelMapper::labelsRow() const
103 void QHPieModelMapper::setLabelsRow(int labelsRow)
135 void QHPieModelMapper::setLabelsRow(int labelsRow)
104 {
136 {
105 if (labelsRow != labelsSection()) {
137 if (labelsRow != labelsSection()) {
106 QPieModelMapper::setLabelsSection(labelsRow);
138 setLabelsSection(labelsRow);
107 emit labelsRowChanged();
139 emit labelsRowChanged();
108 }
140 }
109 }
141 }
110
142
143 int QHPieModelMapper::firstColumn() const
144 {
145 return first();
146 }
147
148 void QHPieModelMapper::setFirstColumn(int firstColumn)
149 {
150 if (firstColumn != first()) {
151 setFirst(firstColumn);
152 emit firstColumnChanged();
153 }
154 }
155
156 int QHPieModelMapper::columnCount() const
157 {
158 return count();
159 }
160
161 void QHPieModelMapper::setColumnCount(int columnCount)
162 {
163 if (columnCount != count()) {
164 setCount(columnCount);
165 emit firstColumnChanged();
166 }
167 }
168
111 #include "moc_qhpiemodelmapper.cpp"
169 #include "moc_qhpiemodelmapper.cpp"
112
170
113 QTCOMMERCIALCHART_END_NAMESPACE
171 QTCOMMERCIALCHART_END_NAMESPACE
@@ -30,6 +30,8 class QTCOMMERCIALCHART_EXPORT QHPieModelMapper : public QPieModelMapper
30 Q_OBJECT
30 Q_OBJECT
31 Q_PROPERTY(int valuesRow READ valuesRow WRITE setValuesRow NOTIFY valuesRowChanged)
31 Q_PROPERTY(int valuesRow READ valuesRow WRITE setValuesRow NOTIFY valuesRowChanged)
32 Q_PROPERTY(int labelsRow READ labelsRow WRITE setLabelsRow NOTIFY labelsRowChanged)
32 Q_PROPERTY(int labelsRow READ labelsRow WRITE setLabelsRow NOTIFY labelsRowChanged)
33 Q_PROPERTY(int firstColumn READ firstColumn WRITE setFirstColumn NOTIFY firstColumnChanged)
34 Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount NOTIFY columnCountChanged)
33
35
34 public:
36 public:
35 explicit QHPieModelMapper(QObject *parent = 0);
37 explicit QHPieModelMapper(QObject *parent = 0);
@@ -40,9 +42,17 public:
40 int labelsRow() const;
42 int labelsRow() const;
41 void setLabelsRow(int labelsRow);
43 void setLabelsRow(int labelsRow);
42
44
45 int firstColumn() const;
46 void setFirstColumn(int firstColumn);
47
48 int columnCount() const;
49 void setColumnCount(int columnCount);
50
43 Q_SIGNALS:
51 Q_SIGNALS:
44 void valuesRowChanged();
52 void valuesRowChanged();
45 void labelsRowChanged();
53 void labelsRowChanged();
54 void firstColumnChanged();
55 void columnCountChanged();
46 };
56 };
47
57
48 QTCOMMERCIALCHART_END_NAMESPACE
58 QTCOMMERCIALCHART_END_NAMESPACE
@@ -51,20 +51,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
51 */
51 */
52
52
53 /*!
53 /*!
54 \property QPieModelMapper::first
55 \brief Defines which item of the model's row/column should be mapped as the value/label of the first slice of the pie
56
57 Minimal and default value is: 0
58 */
59
60 /*!
61 \property QPieModelMapper::count
62 \brief Defines the number of rows/columns of the model that are mapped as the data for the pie.
63
64 Minimal and default value is: -1 (count limited by the number of rows/columns in the model)
65 */
66
67 /*!
68 \fn void QPieModelMapper::seriesReplaced()
54 \fn void QPieModelMapper::seriesReplaced()
69
55
70 Emitted when the series to which mapper is connected to has changed.
56 Emitted when the series to which mapper is connected to has changed.
@@ -77,18 +63,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
77 */
63 */
78
64
79 /*!
65 /*!
80 \fn void QPieModelMapper::firstChanged()
81
82 Emitted when the value for the first has changed.
83 */
84
85 /*!
86 \fn void QPieModelMapper::countChanged()
87
88 Emitted when the value for the count has changed.
89 */
90
91 /*!
92 Constructs a mapper object which is a child of \a parent.
66 Constructs a mapper object which is a child of \a parent.
93 */
67 */
94 QPieModelMapper::QPieModelMapper(QObject *parent) :
68 QPieModelMapper::QPieModelMapper(QObject *parent) :
@@ -150,38 +124,46 void QPieModelMapper::setSeries(QPieSeries *series)
150 emit seriesReplaced();
124 emit seriesReplaced();
151 }
125 }
152
126
127 /*!
128 Defines which row/column of the model contains the first slice value.
129 Minimal and default value is: 0
130 */
153 int QPieModelMapper::first() const
131 int QPieModelMapper::first() const
154 {
132 {
155 Q_D(const QPieModelMapper);
133 Q_D(const QPieModelMapper);
156 return d->m_first;
134 return d->m_first;
157 }
135 }
158
136
137 /*!
138 Sets which row/column of the model contains the \a first slice value.
139 Minimal and default value is: 0
140 */
159 void QPieModelMapper::setFirst(int first)
141 void QPieModelMapper::setFirst(int first)
160 {
142 {
161 Q_D(QPieModelMapper);
143 Q_D(QPieModelMapper);
162 if (first != d->m_first) {
144 d->m_first = qMax(first, 0);
163 d->m_first = qMax(first, 0);
145 d->initializePieFromModel();
164 d->initializePieFromModel();
165
166 emit firstChanged();
167 }
168 }
146 }
169
147
148 /*!
149 Defines the number of rows/columns of the model that are mapped as the data for QPieSeries
150 Minimal and default value is: -1 (count limited by the number of rows/columns in the model)
151 */
170 int QPieModelMapper::count() const
152 int QPieModelMapper::count() const
171 {
153 {
172 Q_D(const QPieModelMapper);
154 Q_D(const QPieModelMapper);
173 return d->m_count;
155 return d->m_count;
174 }
156 }
175
157
158 /*!
159 Defines the \a count of rows/columns of the model that are mapped as the data for QPieSeries
160 Minimal and default value is: -1 (count limited by the number of rows/columns in the model)
161 */
176 void QPieModelMapper::setCount(int count)
162 void QPieModelMapper::setCount(int count)
177 {
163 {
178 Q_D(QPieModelMapper);
164 Q_D(QPieModelMapper);
179 if (count != d->m_count) {
165 d->m_count = qMax(count, -1);
180 d->m_count = qMax(count, -1);
166 d->initializePieFromModel();
181 d->initializePieFromModel();
182
183 emit countChanged();
184 }
185 }
167 }
186
168
187 /*!
169 /*!
@@ -36,8 +36,6 class QTCOMMERCIALCHART_EXPORT QPieModelMapper : public QObject
36 Q_OBJECT
36 Q_OBJECT
37 Q_PROPERTY(QPieSeries *series READ series WRITE setSeries NOTIFY seriesReplaced)
37 Q_PROPERTY(QPieSeries *series READ series WRITE setSeries NOTIFY seriesReplaced)
38 Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelReplaced)
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)
39 Q_ENUMS(Qt::Orientation)
42
40
43 protected:
41 protected:
@@ -50,15 +48,15 public:
50 QPieSeries* series() const;
48 QPieSeries* series() const;
51 void setSeries(QPieSeries *series);
49 void setSeries(QPieSeries *series);
52
50
51 void reset();
52
53 protected:
53 int first() const;
54 int first() const;
54 void setFirst(int first);
55 void setFirst(int first);
55
56
56 int count() const;
57 int count() const;
57 void setCount(int count);
58 void setCount(int count);
58
59
59 void reset();
60
61 protected:
62 int valuesSection() const;
60 int valuesSection() const;
63 void setValuesSection(int valuesSection);
61 void setValuesSection(int valuesSection);
64
62
@@ -71,8 +69,6 protected:
71 Q_SIGNALS:
69 Q_SIGNALS:
72 void seriesReplaced();
70 void seriesReplaced();
73 void modelReplaced();
71 void modelReplaced();
74 void firstChanged();
75 void countChanged();
76
72
77 protected:
73 protected:
78 QPieModelMapperPrivate * const d_ptr;
74 QPieModelMapperPrivate * const d_ptr;
@@ -48,6 +48,28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
48 */
48 */
49
49
50 /*!
50 /*!
51 \property QVPieModelMapper::firstRow
52 \brief Defines which row of the model contains the first slice value.
53 Minimal and default value is: 0
54 */
55 /*!
56 \qmlproperty int QVPieModelMapper::firstRow
57 Defines which row of the model contains the first slice value.
58 The default value is 0.
59 */
60
61 /*!
62 \property QVPieModelMapper::rowCount
63 \brief Defines the number of rows of the model that are mapped as the data for QPieSeries
64 Minimal and default value is: -1 (count limited by the number of rows in the model)
65 */
66 /*!
67 \qmlproperty int QVPieModelMapper::columnCount
68 Defines the number of rows of the model that are mapped as the data for QPieSeries. The default value is
69 -1 (count limited by the number of rows in the model)
70 */
71
72 /*!
51 \fn void QVPieModelMapper::valuesColumnChanged()
73 \fn void QVPieModelMapper::valuesColumnChanged()
52
74
53 Emitted when the valuesColumn has changed.
75 Emitted when the valuesColumn has changed.
@@ -60,6 +82,16 QTCOMMERCIALCHART_BEGIN_NAMESPACE
60 */
82 */
61
83
62 /*!
84 /*!
85 \fn void QVPieModelMapper::firstRowChanged()
86 Emitted when the firstRow has changed.
87 */
88
89 /*!
90 \fn void QVPieModelMapper::rowCountChanged()
91 Emitted when the rowCount has changed.
92 */
93
94 /*!
63 Constructs a mapper object which is a child of \a parent.
95 Constructs a mapper object which is a child of \a parent.
64 */
96 */
65 QVPieModelMapper::QVPieModelMapper(QObject *parent) :
97 QVPieModelMapper::QVPieModelMapper(QObject *parent) :
@@ -108,6 +140,32 void QVPieModelMapper::setLabelsColumn(int labelsColumn)
108 }
140 }
109 }
141 }
110
142
143 int QVPieModelMapper::firstRow() const
144 {
145 return first();
146 }
147
148 void QVPieModelMapper::setFirstRow(int firstRow)
149 {
150 if (firstRow != first()) {
151 setFirst(firstRow);
152 emit firstRowChanged();
153 }
154 }
155
156 int QVPieModelMapper::rowCount() const
157 {
158 return count();
159 }
160
161 void QVPieModelMapper::setRowCount(int rowCount)
162 {
163 if (rowCount != count()) {
164 setCount(rowCount);
165 emit firstRowChanged();
166 }
167 }
168
111 #include "moc_qvpiemodelmapper.cpp"
169 #include "moc_qvpiemodelmapper.cpp"
112
170
113 QTCOMMERCIALCHART_END_NAMESPACE
171 QTCOMMERCIALCHART_END_NAMESPACE
@@ -30,6 +30,8 class QTCOMMERCIALCHART_EXPORT QVPieModelMapper : public QPieModelMapper
30 Q_OBJECT
30 Q_OBJECT
31 Q_PROPERTY(int valuesColumn READ valuesColumn WRITE setValuesColumn NOTIFY valuesColumnChanged)
31 Q_PROPERTY(int valuesColumn READ valuesColumn WRITE setValuesColumn NOTIFY valuesColumnChanged)
32 Q_PROPERTY(int labelsColumn READ labelsColumn WRITE setLabelsColumn NOTIFY labelsColumnChanged)
32 Q_PROPERTY(int labelsColumn READ labelsColumn WRITE setLabelsColumn NOTIFY labelsColumnChanged)
33 Q_PROPERTY(int firstRow READ firstRow WRITE setFirstRow NOTIFY firstRowChanged)
34 Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged)
33
35
34 public:
36 public:
35 explicit QVPieModelMapper(QObject *parent = 0);
37 explicit QVPieModelMapper(QObject *parent = 0);
@@ -40,9 +42,17 public:
40 int labelsColumn() const;
42 int labelsColumn() const;
41 void setLabelsColumn(int labelsColumn);
43 void setLabelsColumn(int labelsColumn);
42
44
45 int firstRow() const;
46 void setFirstRow(int firstRow);
47
48 int rowCount() const;
49 void setRowCount(int rowCount);
50
43 Q_SIGNALS:
51 Q_SIGNALS:
44 void valuesColumnChanged();
52 void valuesColumnChanged();
45 void labelsColumnChanged();
53 void labelsColumnChanged();
54 void firstRowChanged();
55 void rowCountChanged();
46 };
56 };
47
57
48 QTCOMMERCIALCHART_END_NAMESPACE
58 QTCOMMERCIALCHART_END_NAMESPACE
@@ -215,8 +215,8 void tst_qpiemodelmapper::verticalMapperCustomMapping()
215 mapper->setLabelsColumn(1);
215 mapper->setLabelsColumn(1);
216 mapper->setModel(m_model);
216 mapper->setModel(m_model);
217 mapper->setSeries(m_series);
217 mapper->setSeries(m_series);
218 mapper->setFirst(first);
218 mapper->setFirstRow(first);
219 mapper->setCount(countLimit);
219 mapper->setRowCount(countLimit);
220
220
221 QCOMPARE(m_series->count(), expectedCount);
221 QCOMPARE(m_series->count(), expectedCount);
222
222
@@ -292,8 +292,8 void tst_qpiemodelmapper::horizontalMapperCustomMapping()
292 mapper->setLabelsRow(1);
292 mapper->setLabelsRow(1);
293 mapper->setModel(m_model);
293 mapper->setModel(m_model);
294 mapper->setSeries(m_series);
294 mapper->setSeries(m_series);
295 mapper->setFirst(first);
295 mapper->setFirstColumn(first);
296 mapper->setCount(countLimit);
296 mapper->setColumnCount(countLimit);
297
297
298 QCOMPARE(m_series->count(), expectedCount);
298 QCOMPARE(m_series->count(), expectedCount);
299
299
@@ -312,15 +312,15 void tst_qpiemodelmapper::seriesUpdated()
312 // setup the mapper
312 // setup the mapper
313 createVerticalMapper();
313 createVerticalMapper();
314 QCOMPARE(m_series->count(), m_modelRowCount);
314 QCOMPARE(m_series->count(), m_modelRowCount);
315 QCOMPARE(m_vMapper->count(), -1);
315 QCOMPARE(m_vMapper->rowCount(), -1);
316
316
317 m_series->append("1000", 1000);
317 m_series->append("1000", 1000);
318 QCOMPARE(m_series->count(), m_modelRowCount + 1);
318 QCOMPARE(m_series->count(), m_modelRowCount + 1);
319 QCOMPARE(m_vMapper->count(), -1); // the value should not change as it indicates 'all' items there are in the model
319 QCOMPARE(m_vMapper->rowCount(), -1); // the value should not change as it indicates 'all' items there are in the model
320
320
321 m_series->remove(m_series->slices().last());
321 m_series->remove(m_series->slices().last());
322 QCOMPARE(m_series->count(), m_modelRowCount);
322 QCOMPARE(m_series->count(), m_modelRowCount);
323 QCOMPARE(m_vMapper->count(), -1); // the value should not change as it indicates 'all' items there are in the model
323 QCOMPARE(m_vMapper->rowCount(), -1); // the value should not change as it indicates 'all' items there are in the model
324
324
325 QPieSlice *slice = m_series->slices().first();
325 QPieSlice *slice = m_series->slices().first();
326 slice->setValue(25.0);
326 slice->setValue(25.0);
@@ -341,23 +341,23 void tst_qpiemodelmapper::verticalModelInsertRows()
341 QCOMPARE(m_series->count(), m_modelRowCount + insertCount);
341 QCOMPARE(m_series->count(), m_modelRowCount + insertCount);
342
342
343 int first = 3;
343 int first = 3;
344 m_vMapper->setFirst(3);
344 m_vMapper->setFirstRow(3);
345 QCOMPARE(m_series->count(), m_modelRowCount + insertCount - first);
345 QCOMPARE(m_series->count(), m_modelRowCount + insertCount - first);
346
346
347 m_model->insertRows(3, insertCount);
347 m_model->insertRows(3, insertCount);
348 QCOMPARE(m_series->count(), m_modelRowCount + 2 * insertCount - first);
348 QCOMPARE(m_series->count(), m_modelRowCount + 2 * insertCount - first);
349
349
350 int countLimit = 6;
350 int countLimit = 6;
351 m_vMapper->setCount(countLimit);
351 m_vMapper->setRowCount(countLimit);
352 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 2 * insertCount - first));
352 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 2 * insertCount - first));
353
353
354 m_model->insertRows(3, insertCount);
354 m_model->insertRows(3, insertCount);
355 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount - first));
355 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount - first));
356
356
357 m_vMapper->setFirst(0);
357 m_vMapper->setFirstRow(0);
358 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount));
358 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount));
359
359
360 m_vMapper->setCount(-1);
360 m_vMapper->setRowCount(-1);
361 QCOMPARE(m_series->count(), m_modelRowCount + 3 * insertCount);
361 QCOMPARE(m_series->count(), m_modelRowCount + 3 * insertCount);
362 }
362 }
363
363
@@ -373,23 +373,23 void tst_qpiemodelmapper::verticalModelRemoveRows()
373 QCOMPARE(m_series->count(), m_modelRowCount - removeCount);
373 QCOMPARE(m_series->count(), m_modelRowCount - removeCount);
374
374
375 int first = 1;
375 int first = 1;
376 m_vMapper->setFirst(first);
376 m_vMapper->setFirstRow(first);
377 QCOMPARE(m_series->count(), m_modelRowCount - removeCount - first);
377 QCOMPARE(m_series->count(), m_modelRowCount - removeCount - first);
378
378
379 m_model->removeRows(1, removeCount);
379 m_model->removeRows(1, removeCount);
380 QCOMPARE(m_series->count(), m_modelRowCount - 2 * removeCount - first);
380 QCOMPARE(m_series->count(), m_modelRowCount - 2 * removeCount - first);
381
381
382 int countLimit = 3;
382 int countLimit = 3;
383 m_vMapper->setCount(countLimit);
383 m_vMapper->setRowCount(countLimit);
384 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 2 * removeCount - first));
384 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 2 * removeCount - first));
385
385
386 m_model->removeRows(1, removeCount);
386 m_model->removeRows(1, removeCount);
387 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount - first));
387 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount - first));
388
388
389 m_vMapper->setFirst(0);
389 m_vMapper->setFirstRow(0);
390 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount));
390 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount));
391
391
392 m_vMapper->setCount(-1);
392 m_vMapper->setRowCount(-1);
393 QCOMPARE(m_series->count(), m_modelRowCount - 3 * removeCount);
393 QCOMPARE(m_series->count(), m_modelRowCount - 3 * removeCount);
394 }
394 }
395
395
@@ -461,23 +461,23 void tst_qpiemodelmapper::horizontalModelInsertColumns()
461 QCOMPARE(m_series->count(), m_modelColumnCount + insertCount);
461 QCOMPARE(m_series->count(), m_modelColumnCount + insertCount);
462
462
463 int first = 3;
463 int first = 3;
464 m_hMapper->setFirst(3);
464 m_hMapper->setFirstColumn(3);
465 QCOMPARE(m_series->count(), m_modelColumnCount + insertCount - first);
465 QCOMPARE(m_series->count(), m_modelColumnCount + insertCount - first);
466
466
467 m_model->insertColumns(3, insertCount);
467 m_model->insertColumns(3, insertCount);
468 QCOMPARE(m_series->count(), m_modelColumnCount + 2 * insertCount - first);
468 QCOMPARE(m_series->count(), m_modelColumnCount + 2 * insertCount - first);
469
469
470 int countLimit = 6;
470 int countLimit = 6;
471 m_hMapper->setCount(countLimit);
471 m_hMapper->setColumnCount(countLimit);
472 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 2 * insertCount - first));
472 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 2 * insertCount - first));
473
473
474 m_model->insertColumns(3, insertCount);
474 m_model->insertColumns(3, insertCount);
475 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount - first));
475 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount - first));
476
476
477 m_hMapper->setFirst(0);
477 m_hMapper->setFirstColumn(0);
478 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount));
478 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount));
479
479
480 m_hMapper->setCount(-1);
480 m_hMapper->setColumnCount(-1);
481 QCOMPARE(m_series->count(), m_modelColumnCount + 3 * insertCount);
481 QCOMPARE(m_series->count(), m_modelColumnCount + 3 * insertCount);
482 }
482 }
483
483
@@ -493,23 +493,23 void tst_qpiemodelmapper::horizontalModelRemoveColumns()
493 QCOMPARE(m_series->count(), m_modelColumnCount - removeCount);
493 QCOMPARE(m_series->count(), m_modelColumnCount - removeCount);
494
494
495 int first = 1;
495 int first = 1;
496 m_hMapper->setFirst(first);
496 m_hMapper->setFirstColumn(first);
497 QCOMPARE(m_series->count(), m_modelColumnCount - removeCount - first);
497 QCOMPARE(m_series->count(), m_modelColumnCount - removeCount - first);
498
498
499 m_model->removeColumns(1, removeCount);
499 m_model->removeColumns(1, removeCount);
500 QCOMPARE(m_series->count(), m_modelColumnCount - 2 * removeCount - first);
500 QCOMPARE(m_series->count(), m_modelColumnCount - 2 * removeCount - first);
501
501
502 int countLimit = 3;
502 int countLimit = 3;
503 m_hMapper->setCount(countLimit);
503 m_hMapper->setColumnCount(countLimit);
504 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 2 * removeCount - first));
504 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 2 * removeCount - first));
505
505
506 m_model->removeColumns(1, removeCount);
506 m_model->removeColumns(1, removeCount);
507 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount - first));
507 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount - first));
508
508
509 m_hMapper->setFirst(0);
509 m_hMapper->setFirstColumn(0);
510 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount));
510 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount));
511
511
512 m_hMapper->setCount(-1);
512 m_hMapper->setColumnCount(-1);
513 QCOMPARE(m_series->count(), m_modelColumnCount - 3 * removeCount);
513 QCOMPARE(m_series->count(), m_modelColumnCount - 3 * removeCount);
514 }
514 }
515
515
General Comments 0
You need to be logged in to leave comments. Login now