diff --git a/src/libs/timeline/timelinemodelaggregator.cpp b/src/libs/timeline/timelinemodelaggregator.cpp index bad5462fc5eaaf4b2394a431387d9bf9c87ab3e2..b363752058a05955471353a7167aa93d8ce86d4d 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 5eb229c7df7640849f5197fd7cc1936217e2691c..5de05069d1c81fe9933f18838427448d53cfc03b 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()