CStringEditor: Make use of QSignalBlocker

This commit is contained in:
Lioncash 2020-07-10 11:25:10 -04:00
parent a5d9f41559
commit 942e707626
1 changed files with 8 additions and 9 deletions

View File

@ -228,9 +228,11 @@ void CStringEditor::UpdateUI()
if (OldStringIndex != NewStringIndex) if (OldStringIndex != NewStringIndex)
{ {
pSelectionModel->blockSignals(true); {
pSelectionModel->setCurrentIndex(NewStringIndex, QItemSelectionModel::ClearAndSelect); [[maybe_unused]] const QSignalBlocker blocker{pSelectionModel};
pSelectionModel->blockSignals(false); pSelectionModel->setCurrentIndex(NewStringIndex, QItemSelectionModel::ClearAndSelect);
}
mpUI->StringNameListView->scrollTo(NewStringIndex); mpUI->StringNameListView->scrollTo(NewStringIndex);
mpUI->StringNameListView->update(OldStringIndex); mpUI->StringNameListView->update(OldStringIndex);
} }
@ -247,9 +249,8 @@ void CStringEditor::UpdateUI()
{ {
if (mpStringTable->LanguageByIndex(LangIdx) == mCurrentLanguage) if (mpStringTable->LanguageByIndex(LangIdx) == mCurrentLanguage)
{ {
mpUI->EditLanguageTabBar->blockSignals(true); [[maybe_unused]] const QSignalBlocker blocker{mpUI->EditLanguageTabBar};
mpUI->EditLanguageTabBar->setCurrentIndex(static_cast<int>(LangIdx)); mpUI->EditLanguageTabBar->setCurrentIndex(static_cast<int>(LangIdx));
mpUI->EditLanguageTabBar->blockSignals(false);
break; break;
} }
} }
@ -261,16 +262,14 @@ void CStringEditor::UpdateUI()
if (StringName != mpUI->StringNameLineEdit->text()) if (StringName != mpUI->StringNameLineEdit->text())
{ {
mpUI->StringNameLineEdit->blockSignals(true); [[maybe_unused]] const QSignalBlocker blocker{mpUI->StringNameLineEdit};
mpUI->StringNameLineEdit->setText(StringName); mpUI->StringNameLineEdit->setText(StringName);
mpUI->StringNameLineEdit->blockSignals(false);
} }
if (StringData != mpUI->StringTextEdit->toPlainText()) if (StringData != mpUI->StringTextEdit->toPlainText())
{ {
mpUI->StringTextEdit->blockSignals(true); [[maybe_unused]] const QSignalBlocker blocker{mpUI->StringTextEdit};
mpUI->StringTextEdit->setPlainText(StringData); mpUI->StringTextEdit->setPlainText(StringData);
mpUI->StringTextEdit->blockSignals(false);
} }
UpdateStatusBar(); UpdateStatusBar();