From c09d83291ebb6dc12ecb0b3195f8cf139c8cfa42 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 15 Apr 2020 02:41:05 +1000 Subject: [PATCH] nodeparamviewwidgetbridge: empty combobox entries are separators --- .../nodeparamviewwidgetbridge.cpp | 58 ++++++++++--------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp b/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp index 2be2c7b92..d66a50e9a 100644 --- a/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp +++ b/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp @@ -597,6 +597,37 @@ void NodeParamViewWidgetBridge::PropertyChanged(const QString &key, const QVaria } } + // ComboBox strings changing + if (input_->data_type() & NodeParam::kCombo) { + QComboBox* cb = static_cast(widgets_.first()); + + int old_index = cb->currentIndex(); + + // Block the combobox changed signals since we anticipate the index will be the same and not require a re-render + cb->blockSignals(true); + + cb->clear(); + + QStringList items = input_->get_combobox_strings(); + foreach (const QString& s, items) { + if (s.isEmpty()) { + cb->insertSeparator(cb->count()); + } else { + cb->addItem(s); + } + } + + cb->setCurrentIndex(old_index); + + cb->blockSignals(false); + + // In case the amount of items is LESS and the previous index cannot be set, NOW we trigger a re-cache since the + // value has changed + if (cb->currentIndex() != old_index) { + WidgetCallback(); + } + } + // Parameters for floats and vectors only if (input_->data_type() & NodeParam::kFloat || input_->data_type() & NodeParam::kVector) { if (key == QStringLiteral("view")) { @@ -616,33 +647,6 @@ void NodeParamViewWidgetBridge::PropertyChanged(const QString &key, const QVaria } } } - - // ComboBox strings changing - if (input_->data_type() & NodeParam::kCombo) { - QComboBox* cb = static_cast(widgets_.first()); - - int old_index = cb->currentIndex(); - - // Block the combobox changed signals since we anticipate the index will be the same and not require a re-render - cb->blockSignals(true); - - cb->clear(); - - QStringList items = input_->get_combobox_strings(); - foreach (const QString& s, items) { - cb->addItem(s); - } - - cb->setCurrentIndex(old_index); - - cb->blockSignals(false); - - // In case the amount of items is LESS and the previous index cannot be set, NOW we trigger a re-cache since the - // value has changed - if (cb->currentIndex() != old_index) { - WidgetCallback(); - } - } } OLIVE_NAMESPACE_EXIT