diff options
| author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-04-09 15:38:59 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-04-16 13:33:03 +0000 |
| commit | 171d16c6fb56c202efb7a3e79e7121dadac85265 (patch) | |
| tree | fd3245838ff30de7af858d67b9f7cde9eccdac18 | |
| parent | 7b1a421fbfb0b5c88f851f2ba088bd07896c10f6 (diff) | |
| download | qt-creator-171d16c6fb56c202efb7a3e79e7121dadac85265.tar.gz | |
Timeline: Be more exact about height of model aggregator
Only emit the change signal if the height has actually changed.
Change-Id: Ic4bf67f25cb4a7f204815b4e6b0c6bd88c71944a
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
| -rw-r--r-- | src/libs/timeline/timelinemodelaggregator.cpp | 9 | ||||
| -rw-r--r-- | tests/auto/timeline/timelinemodelaggregator/tst_timelinemodelaggregator.cpp | 4 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/libs/timeline/timelinemodelaggregator.cpp b/src/libs/timeline/timelinemodelaggregator.cpp index bad5462fc5..b363752058 100644 --- a/src/libs/timeline/timelinemodelaggregator.cpp +++ b/src/libs/timeline/timelinemodelaggregator.cpp @@ -53,10 +53,6 @@ TimelineModelAggregator::TimelineModelAggregator(TimelineNotesModel *notes, QObj : QObject(parent), d(new TimelineModelAggregatorPrivate(this)) { d->notesModel = notes; - connect(this, &TimelineModelAggregator::modelsChanged, - this, &TimelineModelAggregator::heightChanged); - connect(this, &TimelineModelAggregator::stateChanged, - this, &TimelineModelAggregator::heightChanged); } TimelineModelAggregator::~TimelineModelAggregator() @@ -76,6 +72,8 @@ void TimelineModelAggregator::addModel(TimelineModel *m) if (d->notesModel) d->notesModel->addTimelineModel(m); emit modelsChanged(); + if (m->height() != 0) + emit heightChanged(); } const TimelineModel *TimelineModelAggregator::model(int modelIndex) const @@ -98,10 +96,13 @@ TimelineNotesModel *TimelineModelAggregator::notes() const void TimelineModelAggregator::clear() { + int prevHeight = height(); d->modelList.clear(); if (d->notesModel) d->notesModel->clear(); emit modelsChanged(); + if (height() != prevHeight) + emit heightChanged(); } int TimelineModelAggregator::modelOffset(int modelIndex) const diff --git a/tests/auto/timeline/timelinemodelaggregator/tst_timelinemodelaggregator.cpp b/tests/auto/timeline/timelinemodelaggregator/tst_timelinemodelaggregator.cpp index 5eb229c7df..5de05069d1 100644 --- a/tests/auto/timeline/timelinemodelaggregator/tst_timelinemodelaggregator.cpp +++ b/tests/auto/timeline/timelinemodelaggregator/tst_timelinemodelaggregator.cpp @@ -54,13 +54,17 @@ void tst_TimelineModelAggregator::height() Timeline::TimelineModelAggregator aggregator(0); QCOMPARE(aggregator.height(), 0); + QSignalSpy heightSpy(&aggregator, SIGNAL(heightChanged())); Timeline::TimelineModel *model = new Timeline::TimelineModel(25, QString()); aggregator.addModel(model); QCOMPARE(aggregator.height(), 0); + QCOMPARE(heightSpy.count(), 0); aggregator.addModel(new HeightTestModel); QVERIFY(aggregator.height() > 0); + QCOMPARE(heightSpy.count(), 1); aggregator.clear(); QCOMPARE(aggregator.height(), 0); + QCOMPARE(heightSpy.count(), 2); } void tst_TimelineModelAggregator::addRemoveModel() |
