##// END OF EJS Templates
Plugged some memory leaks....
Miikka Heikkinen -
r2733:c6ed50e68438
parent child
Show More
@@ -45,6 +45,11 CustomTableModel::CustomTableModel(QObject *parent) :
45 }
45 }
46 }
46 }
47
47
48 CustomTableModel::~CustomTableModel()
49 {
50 qDeleteAll(m_data);
51 }
52
48 int CustomTableModel::rowCount(const QModelIndex &parent) const
53 int CustomTableModel::rowCount(const QModelIndex &parent) const
49 {
54 {
50 Q_UNUSED(parent)
55 Q_UNUSED(parent)
@@ -30,6 +30,7 class CustomTableModel : public QAbstractTableModel
30 Q_OBJECT
30 Q_OBJECT
31 public:
31 public:
32 explicit CustomTableModel(QObject *parent = 0);
32 explicit CustomTableModel(QObject *parent = 0);
33 virtual ~CustomTableModel();
33
34
34 int rowCount(const QModelIndex &parent = QModelIndex()) const;
35 int rowCount(const QModelIndex &parent = QModelIndex()) const;
35 int columnCount(const QModelIndex &parent = QModelIndex()) const;
36 int columnCount(const QModelIndex &parent = QModelIndex()) const;
@@ -19,7 +19,6
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "tablewidget.h"
21 #include "tablewidget.h"
22 #include "customtablemodel.h"
23 #include <QtWidgets/QGridLayout>
22 #include <QtWidgets/QGridLayout>
24 #include <QtWidgets/QTableView>
23 #include <QtWidgets/QTableView>
25 #include <QtCharts/QChart>
24 #include <QtCharts/QChart>
@@ -40,16 +39,17 TableWidget::TableWidget(QWidget *parent)
40 // create simple model for storing data
39 // create simple model for storing data
41 // user's table data model
40 // user's table data model
42 //! [1]
41 //! [1]
43 CustomTableModel *model = new CustomTableModel;
42 m_model = new CustomTableModel;
44 //! [1]
43 //! [1]
45
44
46 //! [2]
45 //! [2]
47 // create table view and add model to it
46 // create table view and add model to it
48 QTableView *tableView = new QTableView;
47 QTableView *tableView = new QTableView;
49 tableView->setModel(model);
48 tableView->setModel(m_model);
50 tableView->setMinimumWidth(300);
49 tableView->setMinimumWidth(300);
51 tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
50 tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
52 tableView->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
51 tableView->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
52 m_model->setParent(tableView);
53 //! [2]
53 //! [2]
54
54
55 //! [3]
55 //! [3]
@@ -69,7 +69,7 TableWidget::TableWidget(QWidget *parent)
69 mapper->setFirstRow(first);
69 mapper->setFirstRow(first);
70 mapper->setRowCount(count);
70 mapper->setRowCount(count);
71 mapper->setSeries(series);
71 mapper->setSeries(series);
72 mapper->setModel(model);
72 mapper->setModel(m_model);
73 chart->addSeries(series);
73 chart->addSeries(series);
74 //! [4]
74 //! [4]
75
75
@@ -81,7 +81,7 TableWidget::TableWidget(QWidget *parent)
81 QList<QBarSet *> barsets = series->barSets();
81 QList<QBarSet *> barsets = series->barSets();
82 for (int i = 0; i < barsets.count(); i++) {
82 for (int i = 0; i < barsets.count(); i++) {
83 seriesColorHex = "#" + QString::number(barsets.at(i)->brush().color().rgb(), 16).right(6).toUpper();
83 seriesColorHex = "#" + QString::number(barsets.at(i)->brush().color().rgb(), 16).right(6).toUpper();
84 model->addMapping(seriesColorHex, QRect(1 + i, first, 1, barsets.at(i)->count()));
84 m_model->addMapping(seriesColorHex, QRect(1 + i, first, 1, barsets.at(i)->count()));
85 }
85 }
86 //! [5]
86 //! [5]
87
87
@@ -22,6 +22,7
22 #define TABLEWIDGET_H
22 #define TABLEWIDGET_H
23
23
24 #include <QtWidgets/QWidget>
24 #include <QtWidgets/QWidget>
25 #include "customtablemodel.h"
25
26
26 class TableWidget : public QWidget
27 class TableWidget : public QWidget
27 {
28 {
@@ -29,6 +30,9 class TableWidget : public QWidget
29
30
30 public:
31 public:
31 TableWidget(QWidget *parent = 0);
32 TableWidget(QWidget *parent = 0);
33
34 private:
35 CustomTableModel *m_model;
32 };
36 };
33
37
34 #endif // TABLEWIDGET_H
38 #endif // TABLEWIDGET_H
@@ -32,6 +32,7 QT_CHARTS_BEGIN_NAMESPACE
32 BoxWhiskersAnimation::BoxWhiskersAnimation(BoxWhiskers *box, BoxPlotAnimation *boxPlotAnimation)
32 BoxWhiskersAnimation::BoxWhiskersAnimation(BoxWhiskers *box, BoxPlotAnimation *boxPlotAnimation)
33 : ChartAnimation(box),
33 : ChartAnimation(box),
34 m_box(box),
34 m_box(box),
35 m_changeAnimation(false),
35 m_boxPlotAnimation(boxPlotAnimation)
36 m_boxPlotAnimation(boxPlotAnimation)
36 {
37 {
37 setDuration(ChartAnimationDuration);
38 setDuration(ChartAnimationDuration);
@@ -405,6 +405,8 bool QAbstractBarSeries::append(QList<QBarSet *> sets)
405 Q_D(QAbstractBarSeries);
405 Q_D(QAbstractBarSeries);
406 bool success = d->append(sets);
406 bool success = d->append(sets);
407 if (success) {
407 if (success) {
408 foreach (QBarSet *set, sets)
409 set->setParent(this);
408 emit barsetsAdded(sets);
410 emit barsetsAdded(sets);
409 emit countChanged();
411 emit countChanged();
410 }
412 }
@@ -277,6 +277,7 QBoxSetPrivate::QBoxSetPrivate(const QString label, QBoxSet *parent) : QObject(p
277
277
278 QBoxSetPrivate::~QBoxSetPrivate()
278 QBoxSetPrivate::~QBoxSetPrivate()
279 {
279 {
280 delete[] m_values;
280 }
281 }
281
282
282 bool QBoxSetPrivate::append(qreal value)
283 bool QBoxSetPrivate::append(qreal value)
@@ -140,7 +140,7 QLineSeriesPrivate::QLineSeriesPrivate(QLineSeries *q)
140 : QXYSeriesPrivate(q)
140 : QXYSeriesPrivate(q)
141 {
141 {
142
142
143 };
143 }
144
144
145 void QLineSeriesPrivate::initializeGraphics(QGraphicsItem *parent)
145 void QLineSeriesPrivate::initializeGraphics(QGraphicsItem *parent)
146 {
146 {
@@ -769,6 +769,7 QChartPrivate::QChartPrivate(QChart *q, QChart::ChartType type):
769
769
770 QChartPrivate::~QChartPrivate()
770 QChartPrivate::~QChartPrivate()
771 {
771 {
772 delete m_themeManager;
772 }
773 }
773
774
774 // Hackish solution to the problem of explicitly assigning the default pen/brush/font
775 // Hackish solution to the problem of explicitly assigning the default pen/brush/font
@@ -111,19 +111,20 void tst_ChartDataSet::initTestCase()
111
111
112 void tst_ChartDataSet::cleanupTestCase()
112 void tst_ChartDataSet::cleanupTestCase()
113 {
113 {
114 QTest::qWait(1); // Allow final deleteLaters to run
114 }
115 }
115
116
116 void tst_ChartDataSet::init()
117 void tst_ChartDataSet::init()
117 {
118 {
118 Q_ASSERT(!m_dataset);
119 Q_ASSERT(!m_dataset);
119 m_dataset = new ChartDataSet(0);
120 m_dataset = new ChartDataSet(0);
120 }
121 }
121
122
122
123
123 void tst_ChartDataSet::cleanup()
124 void tst_ChartDataSet::cleanup()
124 {
125 {
125 delete m_dataset;
126 delete m_dataset;
126 m_dataset=0;
127 m_dataset = 0;
127 }
128 }
128
129
129 void tst_ChartDataSet::chartdataset_data()
130 void tst_ChartDataSet::chartdataset_data()
@@ -209,6 +210,8 void tst_ChartDataSet::removeSeries()
209 TRY_COMPARE(spy1.count(), 0);
210 TRY_COMPARE(spy1.count(), 0);
210 TRY_COMPARE(spy2.count(), 0);
211 TRY_COMPARE(spy2.count(), 0);
211 TRY_COMPARE(spy3.count(), 1);
212 TRY_COMPARE(spy3.count(), 1);
213
214 delete series;
212 }
215 }
213
216
214 void tst_ChartDataSet::addAxis_data()
217 void tst_ChartDataSet::addAxis_data()
@@ -272,6 +275,8 void tst_ChartDataSet::removeAxis()
272 TRY_COMPARE(spy1.count(), 1);
275 TRY_COMPARE(spy1.count(), 1);
273 TRY_COMPARE(spy2.count(), 0);
276 TRY_COMPARE(spy2.count(), 0);
274 TRY_COMPARE(spy3.count(), 0);
277 TRY_COMPARE(spy3.count(), 0);
278
279 delete axis;
275 }
280 }
276
281
277 void tst_ChartDataSet::attachAxis_data()
282 void tst_ChartDataSet::attachAxis_data()
@@ -150,6 +150,7 void tst_Domain::initTestCase()
150
150
151 void tst_Domain::cleanupTestCase()
151 void tst_Domain::cleanupTestCase()
152 {
152 {
153 QTest::qWait(1); // Allow final deleteLaters to run
153 }
154 }
154
155
155 void tst_Domain::init()
156 void tst_Domain::init()
@@ -449,6 +450,9 void tst_Domain::operatorEquals()
449 TRY_COMPARE(spy0.count(), 0);
450 TRY_COMPARE(spy0.count(), 0);
450 TRY_COMPARE(spy1.count(), 0);
451 TRY_COMPARE(spy1.count(), 0);
451 TRY_COMPARE(spy2.count(), 0);
452 TRY_COMPARE(spy2.count(), 0);
453
454 delete domain1;
455 delete domain2;
452 }
456 }
453
457
454 void tst_Domain::setRange_data()
458 void tst_Domain::setRange_data()
@@ -29,6 +29,7 void tst_QAbstractAxis::initTestCase()
29
29
30 void tst_QAbstractAxis::cleanupTestCase()
30 void tst_QAbstractAxis::cleanupTestCase()
31 {
31 {
32 QTest::qWait(1); // Allow final deleteLaters to run
32 }
33 }
33
34
34 void tst_QAbstractAxis::init(QAbstractAxis* axis, QAbstractSeries* series)
35 void tst_QAbstractAxis::init(QAbstractAxis* axis, QAbstractSeries* series)
@@ -87,6 +87,7 void tst_QBarCategoriesAxis::initTestCase()
87
87
88 void tst_QBarCategoriesAxis::cleanupTestCase()
88 void tst_QBarCategoriesAxis::cleanupTestCase()
89 {
89 {
90 QTest::qWait(1); // Allow final deleteLaters to run
90 }
91 }
91
92
92 void tst_QBarCategoriesAxis::init()
93 void tst_QBarCategoriesAxis::init()
@@ -76,6 +76,7 class tst_qbarmodelmapper : public QObject
76
76
77 QBarSeries *m_series;
77 QBarSeries *m_series;
78 QChart *m_chart;
78 QChart *m_chart;
79 QChartView *m_chartView;
79 };
80 };
80
81
81 tst_qbarmodelmapper::tst_qbarmodelmapper():
82 tst_qbarmodelmapper::tst_qbarmodelmapper():
@@ -85,7 +86,8 tst_qbarmodelmapper::tst_qbarmodelmapper():
85 m_vMapper(0),
86 m_vMapper(0),
86 m_hMapper(0),
87 m_hMapper(0),
87 m_series(0),
88 m_series(0),
88 m_chart(0)
89 m_chart(0),
90 m_chartView(0)
89 {
91 {
90 }
92 }
91
93
@@ -146,12 +148,14 void tst_qbarmodelmapper::cleanup()
146 void tst_qbarmodelmapper::initTestCase()
148 void tst_qbarmodelmapper::initTestCase()
147 {
149 {
148 m_chart = new QChart;
150 m_chart = new QChart;
149 QChartView *chartView = new QChartView(m_chart);
151 m_chartView = new QChartView(m_chart);
150 chartView->show();
152 m_chartView->show();
151 }
153 }
152
154
153 void tst_qbarmodelmapper::cleanupTestCase()
155 void tst_qbarmodelmapper::cleanupTestCase()
154 {
156 {
157 delete m_chartView;
158 QTest::qWait(1); // Allow final deleteLaters to run
155 }
159 }
156
160
157 void tst_qbarmodelmapper::verticalMapper_data()
161 void tst_qbarmodelmapper::verticalMapper_data()
@@ -173,22 +177,23 void tst_qbarmodelmapper::verticalMapper()
173 QFETCH(int, lastBarSetColumn);
177 QFETCH(int, lastBarSetColumn);
174 QFETCH(int, expectedBarSetCount);
178 QFETCH(int, expectedBarSetCount);
175
179
176 m_series = new QBarSeries;
180 QBarSeries *series = new QBarSeries;
177
181
178 QVBarModelMapper *mapper = new QVBarModelMapper;
182 QVBarModelMapper *mapper = new QVBarModelMapper;
179 mapper->setFirstBarSetColumn(firstBarSetColumn);
183 mapper->setFirstBarSetColumn(firstBarSetColumn);
180 mapper->setLastBarSetColumn(lastBarSetColumn);
184 mapper->setLastBarSetColumn(lastBarSetColumn);
181 mapper->setModel(m_model);
185 mapper->setModel(m_model);
182 mapper->setSeries(m_series);
186 mapper->setSeries(series);
183
187
184 m_chart->addSeries(m_series);
188 m_chart->addSeries(series);
185
189
186 QCOMPARE(m_series->count(), expectedBarSetCount);
190 QCOMPARE(series->count(), expectedBarSetCount);
187 QCOMPARE(mapper->firstBarSetColumn(), qMax(-1, firstBarSetColumn));
191 QCOMPARE(mapper->firstBarSetColumn(), qMax(-1, firstBarSetColumn));
188 QCOMPARE(mapper->lastBarSetColumn(), qMax(-1, lastBarSetColumn));
192 QCOMPARE(mapper->lastBarSetColumn(), qMax(-1, lastBarSetColumn));
189
193
190 delete mapper;
194 delete mapper;
191 mapper = 0;
195 m_chart->removeSeries(series);
196 delete series;
192 }
197 }
193
198
194 void tst_qbarmodelmapper::verticalMapperCustomMapping_data()
199 void tst_qbarmodelmapper::verticalMapperCustomMapping_data()
@@ -216,32 +221,33 void tst_qbarmodelmapper::verticalMapperCustomMapping()
216 QFETCH(int, expectedBarSetCount);
221 QFETCH(int, expectedBarSetCount);
217 QFETCH(int, expectedCount);
222 QFETCH(int, expectedCount);
218
223
219 m_series = new QBarSeries;
224 QBarSeries *series = new QBarSeries;
220
225
221 QCOMPARE(m_series->count(), 0);
226 QCOMPARE(series->count(), 0);
222
227
223 QVBarModelMapper *mapper = new QVBarModelMapper;
228 QVBarModelMapper *mapper = new QVBarModelMapper;
224 mapper->setFirstBarSetColumn(0);
229 mapper->setFirstBarSetColumn(0);
225 mapper->setLastBarSetColumn(1);
230 mapper->setLastBarSetColumn(1);
226 mapper->setModel(m_model);
231 mapper->setModel(m_model);
227 mapper->setSeries(m_series);
232 mapper->setSeries(series);
228 mapper->setFirstRow(first);
233 mapper->setFirstRow(first);
229 mapper->setRowCount(countLimit);
234 mapper->setRowCount(countLimit);
230 m_chart->addSeries(m_series);
235 m_chart->addSeries(series);
231
236
232 QCOMPARE(m_series->count(), expectedBarSetCount);
237 QCOMPARE(series->count(), expectedBarSetCount);
233
238
234 if (expectedBarSetCount > 0)
239 if (expectedBarSetCount > 0)
235 QCOMPARE(m_series->barSets().first()->count(), expectedCount);
240 QCOMPARE(series->barSets().first()->count(), expectedCount);
236
241
237 // change values column mapping to invalid
242 // change values column mapping to invalid
238 mapper->setFirstBarSetColumn(-1);
243 mapper->setFirstBarSetColumn(-1);
239 mapper->setLastBarSetColumn(1);
244 mapper->setLastBarSetColumn(1);
240
245
241 QCOMPARE(m_series->count(), 0);
246 QCOMPARE(series->count(), 0);
242
247
243 delete mapper;
248 delete mapper;
244 mapper = 0;
249 m_chart->removeSeries(series);
250 delete series;
245 }
251 }
246
252
247 void tst_qbarmodelmapper::horizontalMapper_data()
253 void tst_qbarmodelmapper::horizontalMapper_data()
@@ -263,22 +269,23 void tst_qbarmodelmapper::horizontalMapper()
263 QFETCH(int, lastBarSetRow);
269 QFETCH(int, lastBarSetRow);
264 QFETCH(int, expectedBarSetCount);
270 QFETCH(int, expectedBarSetCount);
265
271
266 m_series = new QBarSeries;
272 QBarSeries *series = new QBarSeries;
267
273
268 QHBarModelMapper *mapper = new QHBarModelMapper;
274 QHBarModelMapper *mapper = new QHBarModelMapper;
269 mapper->setFirstBarSetRow(firstBarSetRow);
275 mapper->setFirstBarSetRow(firstBarSetRow);
270 mapper->setLastBarSetRow(lastBarSetRow);
276 mapper->setLastBarSetRow(lastBarSetRow);
271 mapper->setModel(m_model);
277 mapper->setModel(m_model);
272 mapper->setSeries(m_series);
278 mapper->setSeries(series);
273
279
274 m_chart->addSeries(m_series);
280 m_chart->addSeries(series);
275
281
276 QCOMPARE(m_series->count(), expectedBarSetCount);
282 QCOMPARE(series->count(), expectedBarSetCount);
277 QCOMPARE(mapper->firstBarSetRow(), qMax(-1, firstBarSetRow));
283 QCOMPARE(mapper->firstBarSetRow(), qMax(-1, firstBarSetRow));
278 QCOMPARE(mapper->lastBarSetRow(), qMax(-1, lastBarSetRow));
284 QCOMPARE(mapper->lastBarSetRow(), qMax(-1, lastBarSetRow));
279
285
280 delete mapper;
286 delete mapper;
281 mapper = 0;
287 m_chart->removeSeries(series);
288 delete series;
282 }
289 }
283
290
284 void tst_qbarmodelmapper::horizontalMapperCustomMapping_data()
291 void tst_qbarmodelmapper::horizontalMapperCustomMapping_data()
@@ -306,32 +313,33 void tst_qbarmodelmapper::horizontalMapperCustomMapping()
306 QFETCH(int, expectedBarSetCount);
313 QFETCH(int, expectedBarSetCount);
307 QFETCH(int, expectedCount);
314 QFETCH(int, expectedCount);
308
315
309 m_series = new QBarSeries;
316 QBarSeries *series = new QBarSeries;
310
317
311 QCOMPARE(m_series->count(), 0);
318 QCOMPARE(series->count(), 0);
312
319
313 QHBarModelMapper *mapper = new QHBarModelMapper;
320 QHBarModelMapper *mapper = new QHBarModelMapper;
314 mapper->setFirstBarSetRow(0);
321 mapper->setFirstBarSetRow(0);
315 mapper->setLastBarSetRow(1);
322 mapper->setLastBarSetRow(1);
316 mapper->setModel(m_model);
323 mapper->setModel(m_model);
317 mapper->setSeries(m_series);
324 mapper->setSeries(series);
318 mapper->setFirstColumn(first);
325 mapper->setFirstColumn(first);
319 mapper->setColumnCount(countLimit);
326 mapper->setColumnCount(countLimit);
320 m_chart->addSeries(m_series);
327 m_chart->addSeries(series);
321
328
322 QCOMPARE(m_series->count(), expectedBarSetCount);
329 QCOMPARE(series->count(), expectedBarSetCount);
323
330
324 if (expectedBarSetCount > 0)
331 if (expectedBarSetCount > 0)
325 QCOMPARE(m_series->barSets().first()->count(), expectedCount);
332 QCOMPARE(series->barSets().first()->count(), expectedCount);
326
333
327 // change values column mapping to invalid
334 // change values column mapping to invalid
328 mapper->setFirstBarSetRow(-1);
335 mapper->setFirstBarSetRow(-1);
329 mapper->setLastBarSetRow(1);
336 mapper->setLastBarSetRow(1);
330
337
331 QCOMPARE(m_series->count(), 0);
338 QCOMPARE(series->count(), 0);
332
339
333 delete mapper;
340 delete mapper;
334 mapper = 0;
341 m_chart->removeSeries(series);
342 delete series;
335 }
343 }
336
344
337 void tst_qbarmodelmapper::seriesUpdated()
345 void tst_qbarmodelmapper::seriesUpdated()
@@ -636,6 +644,7 void tst_qbarmodelmapper::verticalMapperSignals()
636 QCOMPARE(spy4.count(), 1);
644 QCOMPARE(spy4.count(), 1);
637 QCOMPARE(spy5.count(), 1);
645 QCOMPARE(spy5.count(), 1);
638
646
647 delete mapper;
639 }
648 }
640
649
641 void tst_qbarmodelmapper::horizontalMapperSignals()
650 void tst_qbarmodelmapper::horizontalMapperSignals()
@@ -662,6 +671,8 void tst_qbarmodelmapper::horizontalMapperSignals()
662 QCOMPARE(spy3.count(), 1);
671 QCOMPARE(spy3.count(), 1);
663 QCOMPARE(spy4.count(), 1);
672 QCOMPARE(spy4.count(), 1);
664 QCOMPARE(spy5.count(), 1);
673 QCOMPARE(spy5.count(), 1);
674
675 delete mapper;
665 }
676 }
666
677
667 QTEST_MAIN(tst_qbarmodelmapper)
678 QTEST_MAIN(tst_qbarmodelmapper)
@@ -87,6 +87,7 void tst_QBarSeries::initTestCase()
87
87
88 void tst_QBarSeries::cleanupTestCase()
88 void tst_QBarSeries::cleanupTestCase()
89 {
89 {
90 QTest::qWait(1); // Allow final deleteLaters to run
90 }
91 }
91
92
92 void tst_QBarSeries::init()
93 void tst_QBarSeries::init()
@@ -121,6 +122,7 void tst_QBarSeries::qbarseries()
121 {
122 {
122 QBarSeries *barseries = new QBarSeries();
123 QBarSeries *barseries = new QBarSeries();
123 QVERIFY(barseries != 0);
124 QVERIFY(barseries != 0);
125 delete barseries;
124 }
126 }
125
127
126 void tst_QBarSeries::type_data()
128 void tst_QBarSeries::type_data()
@@ -281,6 +283,7 void tst_QBarSeries::appendList()
281 ret = m_barseries->append(invalidList);
283 ret = m_barseries->append(invalidList);
282 QVERIFY(ret == false);
284 QVERIFY(ret == false);
283 QVERIFY(m_barseries->count() == count);
285 QVERIFY(m_barseries->count() == count);
286 delete invalidList.at(0);
284
287
285 // Try append list with null pointers (should fail, count remains same)
288 // Try append list with null pointers (should fail, count remains same)
286 QList<QBarSet*> invalidList2;
289 QList<QBarSet*> invalidList2;
@@ -71,6 +71,7 void tst_QBarSet::initTestCase()
71
71
72 void tst_QBarSet::cleanupTestCase()
72 void tst_QBarSet::cleanupTestCase()
73 {
73 {
74 QTest::qWait(1); // Allow final deleteLaters to run
74 }
75 }
75
76
76 void tst_QBarSet::init()
77 void tst_QBarSet::init()
@@ -69,6 +69,7 void tst_QCategoryAxis::initTestCase()
69
69
70 void tst_QCategoryAxis::cleanupTestCase()
70 void tst_QCategoryAxis::cleanupTestCase()
71 {
71 {
72 QTest::qWait(1); // Allow final deleteLaters to run
72 }
73 }
73
74
74 void tst_QCategoryAxis::init()
75 void tst_QCategoryAxis::init()
@@ -125,7 +125,7 void tst_QChart::initTestCase()
125
125
126 void tst_QChart::cleanupTestCase()
126 void tst_QChart::cleanupTestCase()
127 {
127 {
128
128 QTest::qWait(1); // Allow final deleteLaters to run
129 }
129 }
130
130
131 void tst_QChart::init()
131 void tst_QChart::init()
@@ -197,7 +197,7 void tst_QChart::addSeries_data()
197 QTest::addColumn<QAbstractSeries *>("series");
197 QTest::addColumn<QAbstractSeries *>("series");
198
198
199 QAbstractSeries* line = new QLineSeries(this);
199 QAbstractSeries* line = new QLineSeries(this);
200 QAbstractSeries* area = new QAreaSeries(static_cast<QLineSeries*>(line));
200 QAbstractSeries* area = new QAreaSeries(new QLineSeries(this));
201 QAbstractSeries* scatter = new QScatterSeries(this);
201 QAbstractSeries* scatter = new QScatterSeries(this);
202 QAbstractSeries* spline = new QSplineSeries(this);
202 QAbstractSeries* spline = new QSplineSeries(this);
203
203
@@ -240,6 +240,7 void tst_QChart::addSeries()
240 m_chart->removeSeries(series);
240 m_chart->removeSeries(series);
241 QVERIFY(!series->chart());
241 QVERIFY(!series->chart());
242 QCOMPARE(m_chart->series().count(), 0);
242 QCOMPARE(m_chart->series().count(), 0);
243 delete series;
243 }
244 }
244
245
245 void tst_QChart::animationOptions_data()
246 void tst_QChart::animationOptions_data()
@@ -535,6 +536,7 void tst_QChart::removeSeries()
535 QVERIFY(m_chart->axisY() != 0);
536 QVERIFY(m_chart->axisY() != 0);
536 QVERIFY(m_chart->axisY(series)==0);
537 QVERIFY(m_chart->axisY(series)==0);
537 QCOMPARE(deleteSpy.count(), 0);
538 QCOMPARE(deleteSpy.count(), 0);
539 delete series;
538 }
540 }
539
541
540 void tst_QChart::scroll_right_data()
542 void tst_QChart::scroll_right_data()
@@ -1010,6 +1012,7 void tst_QChart::createDefaultAxesForLineSeries()
1010 QCOMPARE(xAxis->max(), overallmaxX);
1012 QCOMPARE(xAxis->max(), overallmaxX);
1011 QCOMPARE(yAxis->min(), overallminY);
1013 QCOMPARE(yAxis->min(), overallminY);
1012 QCOMPARE(yAxis->max(), overallmaxY);
1014 QCOMPARE(yAxis->max(), overallmaxY);
1015 delete chart;
1013 }
1016 }
1014
1017
1015 void tst_QChart::axisPolarOrientation()
1018 void tst_QChart::axisPolarOrientation()
@@ -63,6 +63,7 void tst_QChartView::initTestCase()
63
63
64 void tst_QChartView::cleanupTestCase()
64 void tst_QChartView::cleanupTestCase()
65 {
65 {
66 QTest::qWait(1); // Allow final deleteLaters to run
66 }
67 }
67
68
68 void tst_QChartView::init()
69 void tst_QChartView::init()
@@ -69,6 +69,7 void tst_QDateTimeAxis::initTestCase()
69
69
70 void tst_QDateTimeAxis::cleanupTestCase()
70 void tst_QDateTimeAxis::cleanupTestCase()
71 {
71 {
72 QTest::qWait(1); // Allow final deleteLaters to run
72 }
73 }
73
74
74 void tst_QDateTimeAxis::init()
75 void tst_QDateTimeAxis::init()
@@ -81,6 +81,7 void tst_QHorizontalBarSeries::initTestCase()
81
81
82 void tst_QHorizontalBarSeries::cleanupTestCase()
82 void tst_QHorizontalBarSeries::cleanupTestCase()
83 {
83 {
84 QTest::qWait(1); // Allow final deleteLaters to run
84 }
85 }
85
86
86 void tst_QHorizontalBarSeries::init()
87 void tst_QHorizontalBarSeries::init()
@@ -115,6 +116,7 void tst_QHorizontalBarSeries::qhorizontalbarseries()
115 {
116 {
116 QHorizontalBarSeries *barseries = new QHorizontalBarSeries();
117 QHorizontalBarSeries *barseries = new QHorizontalBarSeries();
117 QVERIFY(barseries != 0);
118 QVERIFY(barseries != 0);
119 delete barseries;
118 }
120 }
119
121
120 void tst_QHorizontalBarSeries::type_data()
122 void tst_QHorizontalBarSeries::type_data()
@@ -246,6 +248,7 void tst_QHorizontalBarSeries::appendList()
246 ret = m_barseries->append(invalidList);
248 ret = m_barseries->append(invalidList);
247 QVERIFY(ret == false);
249 QVERIFY(ret == false);
248 QVERIFY(m_barseries->count() == count);
250 QVERIFY(m_barseries->count() == count);
251 delete invalidList.at(0);
249
252
250 // Try append list with null pointers (should fail, count remains same)
253 // Try append list with null pointers (should fail, count remains same)
251 QList<QBarSet*> invalidList2;
254 QList<QBarSet*> invalidList2;
@@ -65,6 +65,7 void tst_QHorizontalPercentBarSeries::initTestCase()
65
65
66 void tst_QHorizontalPercentBarSeries::cleanupTestCase()
66 void tst_QHorizontalPercentBarSeries::cleanupTestCase()
67 {
67 {
68 QTest::qWait(1); // Allow final deleteLaters to run
68 }
69 }
69
70
70 void tst_QHorizontalPercentBarSeries::init()
71 void tst_QHorizontalPercentBarSeries::init()
@@ -86,6 +87,7 void tst_QHorizontalPercentBarSeries::qhorizontalpercentbarseries()
86 {
87 {
87 QHorizontalPercentBarSeries *barseries = new QHorizontalPercentBarSeries();
88 QHorizontalPercentBarSeries *barseries = new QHorizontalPercentBarSeries();
88 QVERIFY(barseries != 0);
89 QVERIFY(barseries != 0);
90 delete barseries;
89 }
91 }
90
92
91 void tst_QHorizontalPercentBarSeries::type_data()
93 void tst_QHorizontalPercentBarSeries::type_data()
@@ -64,6 +64,7 void tst_QHorizontalStackedBarSeries::initTestCase()
64
64
65 void tst_QHorizontalStackedBarSeries::cleanupTestCase()
65 void tst_QHorizontalStackedBarSeries::cleanupTestCase()
66 {
66 {
67 QTest::qWait(1); // Allow final deleteLaters to run
67 }
68 }
68
69
69 void tst_QHorizontalStackedBarSeries::init()
70 void tst_QHorizontalStackedBarSeries::init()
@@ -85,6 +86,7 void tst_QHorizontalStackedBarSeries::qhorizontalstackedbarseries()
85 {
86 {
86 QHorizontalStackedBarSeries *barseries = new QHorizontalStackedBarSeries();
87 QHorizontalStackedBarSeries *barseries = new QHorizontalStackedBarSeries();
87 QVERIFY(barseries != 0);
88 QVERIFY(barseries != 0);
89 delete barseries;
88 }
90 }
89
91
90 void tst_QHorizontalStackedBarSeries::type_data()
92 void tst_QHorizontalStackedBarSeries::type_data()
@@ -71,6 +71,7 void tst_QLegend::initTestCase()
71
71
72 void tst_QLegend::cleanupTestCase()
72 void tst_QLegend::cleanupTestCase()
73 {
73 {
74 QTest::qWait(1); // Allow final deleteLaters to run
74 }
75 }
75
76
76 void tst_QLegend::init()
77 void tst_QLegend::init()
@@ -144,8 +145,8 void tst_QLegend::qareaLegendMarker()
144 QLegend *legend = m_chart->legend();
145 QLegend *legend = m_chart->legend();
145 QAreaSeries *series = new QAreaSeries();
146 QAreaSeries *series = new QAreaSeries();
146
147
147 QLineSeries *upper = new QLineSeries();
148 QLineSeries *upper = new QLineSeries(series);
148 QLineSeries *lower = new QLineSeries();
149 QLineSeries *lower = new QLineSeries(series);
149
150
150 upper->append(1,1);
151 upper->append(1,1);
151 lower->append(1,0);
152 lower->append(1,0);
@@ -257,8 +258,8 void tst_QLegend::markers()
257 m_chart->addSeries(line);
258 m_chart->addSeries(line);
258
259
259 QAreaSeries *area = new QAreaSeries();
260 QAreaSeries *area = new QAreaSeries();
260 QLineSeries *upper = new QLineSeries();
261 QLineSeries *upper = new QLineSeries(area);
261 QLineSeries *lower = new QLineSeries();
262 QLineSeries *lower = new QLineSeries(area);
262 upper->append(1,1);
263 upper->append(1,1);
263 lower->append(1,0);
264 lower->append(1,0);
264 area->setUpperSeries(upper);
265 area->setUpperSeries(upper);
@@ -294,6 +295,8 void tst_QLegend::addAndRemoveSeries()
294
295
295 markers = legend->markers();
296 markers = legend->markers();
296 QVERIFY(markers.count() == 0);
297 QVERIFY(markers.count() == 0);
298
299 delete pie;
297 }
300 }
298
301
299 void tst_QLegend::pieMarkerProperties()
302 void tst_QLegend::pieMarkerProperties()
@@ -381,8 +384,8 void tst_QLegend::areaMarkerProperties()
381
384
382 QAreaSeries *area = new QAreaSeries();
385 QAreaSeries *area = new QAreaSeries();
383 area->setName(QString("Area"));
386 area->setName(QString("Area"));
384 QLineSeries *upper = new QLineSeries();
387 QLineSeries *upper = new QLineSeries(area);
385 QLineSeries *lower = new QLineSeries();
388 QLineSeries *lower = new QLineSeries(area);
386 upper->append(1,1);
389 upper->append(1,1);
387 lower->append(1,0);
390 lower->append(1,0);
388 area->setUpperSeries(upper);
391 area->setUpperSeries(upper);
@@ -522,8 +525,8 void tst_QLegend::markerSignals()
522
525
523 QAreaSeries *area = new QAreaSeries();
526 QAreaSeries *area = new QAreaSeries();
524 area->setName(QString("Area 1"));
527 area->setName(QString("Area 1"));
525 QLineSeries *upper = new QLineSeries();
528 QLineSeries *upper = new QLineSeries(area);
526 QLineSeries *lower = new QLineSeries();
529 QLineSeries *lower = new QLineSeries(area);
527 upper->append(2,2);
530 upper->append(2,2);
528 lower->append(1,1);
531 lower->append(1,1);
529 area->setUpperSeries(upper);
532 area->setUpperSeries(upper);
@@ -46,6 +46,7 void tst_QLineSeries::initTestCase()
46
46
47 void tst_QLineSeries::cleanupTestCase()
47 void tst_QLineSeries::cleanupTestCase()
48 {
48 {
49 QTest::qWait(1); // Allow final deleteLaters to run
49 }
50 }
50
51
51 void tst_QLineSeries::init()
52 void tst_QLineSeries::init()
@@ -71,6 +71,7 void tst_QLogValueAxis::initTestCase()
71
71
72 void tst_QLogValueAxis::cleanupTestCase()
72 void tst_QLogValueAxis::cleanupTestCase()
73 {
73 {
74 QTest::qWait(1); // Allow final deleteLaters to run
74 }
75 }
75
76
76 void tst_QLogValueAxis::init()
77 void tst_QLogValueAxis::init()
@@ -65,6 +65,7 void tst_QPercentBarSeries::initTestCase()
65
65
66 void tst_QPercentBarSeries::cleanupTestCase()
66 void tst_QPercentBarSeries::cleanupTestCase()
67 {
67 {
68 QTest::qWait(1); // Allow final deleteLaters to run
68 }
69 }
69
70
70 void tst_QPercentBarSeries::init()
71 void tst_QPercentBarSeries::init()
@@ -86,6 +87,7 void tst_QPercentBarSeries::qpercentbarseries()
86 {
87 {
87 QPercentBarSeries *barseries = new QPercentBarSeries();
88 QPercentBarSeries *barseries = new QPercentBarSeries();
88 QVERIFY(barseries != 0);
89 QVERIFY(barseries != 0);
90 delete barseries;
89 }
91 }
90
92
91 void tst_QPercentBarSeries::type_data()
93 void tst_QPercentBarSeries::type_data()
@@ -75,6 +75,7 class tst_qpiemodelmapper : public QObject
75
75
76 QPieSeries *m_series;
76 QPieSeries *m_series;
77 QChart *m_chart;
77 QChart *m_chart;
78 QChartView *m_chartView;
78 };
79 };
79
80
80 tst_qpiemodelmapper::tst_qpiemodelmapper():
81 tst_qpiemodelmapper::tst_qpiemodelmapper():
@@ -84,7 +85,8 tst_qpiemodelmapper::tst_qpiemodelmapper():
84 m_vMapper(0),
85 m_vMapper(0),
85 m_hMapper(0),
86 m_hMapper(0),
86 m_series(0),
87 m_series(0),
87 m_chart(0)
88 m_chart(0),
89 m_chartView(0)
88 {
90 {
89 }
91 }
90
92
@@ -145,13 +147,14 void tst_qpiemodelmapper::cleanup()
145 void tst_qpiemodelmapper::initTestCase()
147 void tst_qpiemodelmapper::initTestCase()
146 {
148 {
147 m_chart = new QChart;
149 m_chart = new QChart;
148 QChartView *chartView = new QChartView(m_chart);
150 m_chartView = new QChartView(m_chart);
149 chartView->show();
151 m_chartView->show();
150 }
152 }
151
153
152 void tst_qpiemodelmapper::cleanupTestCase()
154 void tst_qpiemodelmapper::cleanupTestCase()
153 {
155 {
154 //
156 delete m_chartView;
157 QTest::qWait(1); // Allow final deleteLaters to run
155 }
158 }
156
159
157 void tst_qpiemodelmapper::verticalMapper_data()
160 void tst_qpiemodelmapper::verticalMapper_data()
@@ -550,6 +553,7 void tst_qpiemodelmapper::verticalMapperSignals()
550 QCOMPARE(spy4.count(), 1);
553 QCOMPARE(spy4.count(), 1);
551 QCOMPARE(spy5.count(), 1);
554 QCOMPARE(spy5.count(), 1);
552
555
556 delete mapper;
553 }
557 }
554
558
555 void tst_qpiemodelmapper::horizontalMapperSignals()
559 void tst_qpiemodelmapper::horizontalMapperSignals()
@@ -75,6 +75,7 void tst_qpieseries::initTestCase()
75
75
76 void tst_qpieseries::cleanupTestCase()
76 void tst_qpieseries::cleanupTestCase()
77 {
77 {
78 QTest::qWait(1); // Allow final deleteLaters to run
78 }
79 }
79
80
80 void tst_qpieseries::init()
81 void tst_qpieseries::init()
@@ -57,6 +57,7 void tst_qpieslice::initTestCase()
57
57
58 void tst_qpieslice::cleanupTestCase()
58 void tst_qpieslice::cleanupTestCase()
59 {
59 {
60 QTest::qWait(1); // Allow final deleteLaters to run
60 }
61 }
61
62
62 void tst_qpieslice::init()
63 void tst_qpieslice::init()
@@ -47,6 +47,7 void tst_QScatterSeries::initTestCase()
47
47
48 void tst_QScatterSeries::cleanupTestCase()
48 void tst_QScatterSeries::cleanupTestCase()
49 {
49 {
50 QTest::qWait(1); // Allow final deleteLaters to run
50 }
51 }
51
52
52 void tst_QScatterSeries::init()
53 void tst_QScatterSeries::init()
@@ -45,6 +45,7 void tst_QSplineSeries::initTestCase()
45
45
46 void tst_QSplineSeries::cleanupTestCase()
46 void tst_QSplineSeries::cleanupTestCase()
47 {
47 {
48 QTest::qWait(1); // Allow final deleteLaters to run
48 }
49 }
49
50
50 void tst_QSplineSeries::init()
51 void tst_QSplineSeries::init()
@@ -64,6 +64,7 void tst_QStackedBarSeries::initTestCase()
64
64
65 void tst_QStackedBarSeries::cleanupTestCase()
65 void tst_QStackedBarSeries::cleanupTestCase()
66 {
66 {
67 QTest::qWait(1); // Allow final deleteLaters to run
67 }
68 }
68
69
69 void tst_QStackedBarSeries::init()
70 void tst_QStackedBarSeries::init()
@@ -85,6 +86,7 void tst_QStackedBarSeries::qstackedbarseries()
85 {
86 {
86 QStackedBarSeries *barseries = new QStackedBarSeries();
87 QStackedBarSeries *barseries = new QStackedBarSeries();
87 QVERIFY(barseries != 0);
88 QVERIFY(barseries != 0);
89 delete barseries;
88 }
90 }
89
91
90 void tst_QStackedBarSeries::type_data()
92 void tst_QStackedBarSeries::type_data()
@@ -73,6 +73,7 void tst_QValueAxis::initTestCase()
73
73
74 void tst_QValueAxis::cleanupTestCase()
74 void tst_QValueAxis::cleanupTestCase()
75 {
75 {
76 QTest::qWait(1); // Allow final deleteLaters to run
76 }
77 }
77
78
78 void tst_QValueAxis::init()
79 void tst_QValueAxis::init()
@@ -77,6 +77,7 class tst_qxymodelmapper : public QObject
77
77
78 QXYSeries *m_series;
78 QXYSeries *m_series;
79 QChart *m_chart;
79 QChart *m_chart;
80 QChartView *m_chartView;
80 };
81 };
81
82
82 tst_qxymodelmapper::tst_qxymodelmapper():
83 tst_qxymodelmapper::tst_qxymodelmapper():
@@ -86,7 +87,8 tst_qxymodelmapper::tst_qxymodelmapper():
86 m_hMapper(0),
87 m_hMapper(0),
87 m_vMapper(0),
88 m_vMapper(0),
88 m_series(0),
89 m_series(0),
89 m_chart(0)
90 m_chart(0),
91 m_chartView(0)
90 {
92 {
91 }
93 }
92
94
@@ -147,13 +149,14 void tst_qxymodelmapper::cleanup()
147 void tst_qxymodelmapper::initTestCase()
149 void tst_qxymodelmapper::initTestCase()
148 {
150 {
149 m_chart = newQChartOrQPolarChart();
151 m_chart = newQChartOrQPolarChart();
150 QChartView *chartView = new QChartView(m_chart);
152 m_chartView = new QChartView(m_chart);
151 chartView->show();
153 m_chartView->show();
152 }
154 }
153
155
154 void tst_qxymodelmapper::cleanupTestCase()
156 void tst_qxymodelmapper::cleanupTestCase()
155 {
157 {
156 //
158 delete m_chartView;
159 QTest::qWait(1); // Allow final deleteLaters to run
157 }
160 }
158
161
159 void tst_qxymodelmapper::verticalMapper_data()
162 void tst_qxymodelmapper::verticalMapper_data()
@@ -552,6 +555,7 void tst_qxymodelmapper::verticalMapperSignals()
552 QCOMPARE(spy4.count(), 1);
555 QCOMPARE(spy4.count(), 1);
553 QCOMPARE(spy5.count(), 1);
556 QCOMPARE(spy5.count(), 1);
554
557
558 delete mapper;
555 }
559 }
556
560
557 void tst_qxymodelmapper::horizontalMapperSignals()
561 void tst_qxymodelmapper::horizontalMapperSignals()
@@ -578,6 +582,8 void tst_qxymodelmapper::horizontalMapperSignals()
578 QCOMPARE(spy3.count(), 1);
582 QCOMPARE(spy3.count(), 1);
579 QCOMPARE(spy4.count(), 1);
583 QCOMPARE(spy4.count(), 1);
580 QCOMPARE(spy5.count(), 1);
584 QCOMPARE(spy5.count(), 1);
585
586 delete mapper;
581 }
587 }
582
588
583 QTEST_MAIN(tst_qxymodelmapper)
589 QTEST_MAIN(tst_qxymodelmapper)
@@ -28,6 +28,7 void tst_QXYSeries::initTestCase()
28
28
29 void tst_QXYSeries::cleanupTestCase()
29 void tst_QXYSeries::cleanupTestCase()
30 {
30 {
31 QTest::qWait(1); // Allow final deleteLaters to run
31 }
32 }
32
33
33 void tst_QXYSeries::init()
34 void tst_QXYSeries::init()
@@ -80,6 +80,11 CustomTableModel::CustomTableModel(QObject *parent) :
80 m_data.append(dataVec_Jun);
80 m_data.append(dataVec_Jun);
81 }
81 }
82
82
83 CustomTableModel::~CustomTableModel()
84 {
85 qDeleteAll(m_data);
86 }
87
83 int CustomTableModel::rowCount(const QModelIndex &parent) const
88 int CustomTableModel::rowCount(const QModelIndex &parent) const
84 {
89 {
85 Q_UNUSED(parent)
90 Q_UNUSED(parent)
@@ -30,6 +30,7 class CustomTableModel : public QAbstractTableModel
30 Q_OBJECT
30 Q_OBJECT
31 public:
31 public:
32 explicit CustomTableModel(QObject *parent = 0);
32 explicit CustomTableModel(QObject *parent = 0);
33 virtual ~CustomTableModel();
33
34
34 int rowCount(const QModelIndex &parent = QModelIndex()) const;
35 int rowCount(const QModelIndex &parent = QModelIndex()) const;
35 int columnCount(const QModelIndex &parent = QModelIndex()) const;
36 int columnCount(const QModelIndex &parent = QModelIndex()) const;
@@ -124,8 +124,8 MainWidget::MainWidget(QWidget *parent) :
124 initThemeCombo(grid);
124 initThemeCombo(grid);
125 initCheckboxes(grid);
125 initCheckboxes(grid);
126
126
127 m_model = new CustomTableModel();
128 QTableView *tableView = new QTableView;
127 QTableView *tableView = new QTableView;
128 m_model = new CustomTableModel(tableView);
129 tableView->setModel(m_model);
129 tableView->setModel(m_model);
130 tableView->setMaximumWidth(200);
130 tableView->setMaximumWidth(200);
131 grid->addWidget(tableView, m_rowPos++, 0, 3, 2, Qt::AlignLeft);
131 grid->addWidget(tableView, m_rowPos++, 0, 3, 2, Qt::AlignLeft);
General Comments 0
You need to be logged in to leave comments. Login now