Utils: Do not emit SelectionAspect::changed if nothing changed

Change-Id: Iac2e19d1a093f650ecde6fa9cfdec4714a8e9db4
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2020-10-05 18:23:17 +02:00
parent 3c281aa483
commit 2ecb7ceb06

View File

@@ -846,8 +846,10 @@ void SelectionAspect::addToLayout(LayoutBuilder &builder)
d->m_buttons.append(button); d->m_buttons.append(button);
d->m_buttonGroup->addButton(button); d->m_buttonGroup->addButton(button);
connect(button, &QAbstractButton::clicked, this, [this, i] { connect(button, &QAbstractButton::clicked, this, [this, i] {
d->m_value = i; if (d->m_value != i) {
emit changed(); d->m_value = i;
emit changed();
}
}); });
} }
break; break;
@@ -859,7 +861,12 @@ void SelectionAspect::addToLayout(LayoutBuilder &builder)
for (int i = 0, n = d->m_options.size(); i < n; ++i) for (int i = 0, n = d->m_options.size(); i < n; ++i)
d->m_comboBox->addItem(d->m_options.at(i).displayName); d->m_comboBox->addItem(d->m_options.at(i).displayName);
connect(d->m_comboBox.data(), QOverload<int>::of(&QComboBox::activated), this, connect(d->m_comboBox.data(), QOverload<int>::of(&QComboBox::activated), this,
[this](int index) { d->m_value = index; emit changed(); }); [this](int index) {
if (d->m_value != index) {
d->m_value = index;
emit changed();
}
});
d->m_comboBox->setCurrentIndex(d->m_value); d->m_comboBox->setCurrentIndex(d->m_value);
builder.addItems({d->m_label.data(), d->m_comboBox.data()}); builder.addItems({d->m_label.data(), d->m_comboBox.data()});
break; break;