Qt Editor: Do not reset value to default parameter when re-selecting an already selected index

qteditor
Sven Eberhardt 2016-07-12 23:28:31 -04:00
parent 3c84f9e6f8
commit dfb709df6b
2 changed files with 11 additions and 4 deletions

View File

@ -867,6 +867,7 @@ void C4PropertyDelegateEnum::SetEditorData(QWidget *aeditor, const C4Value &val,
int32_t index = std::max<int32_t>(GetOptionByValue(val), 0);
QStandardItemModel *model = static_cast<QStandardItemModel *>(editor->option_box->model());
editor->option_box->setCurrentModelIndex(GetModelIndexByID(model, model->invisibleRootItem(), index, QModelIndex()));
editor->last_selection_index = index;
// Update parameter
UpdateEditorParameter(editor, false);
editor->updating = false;
@ -943,9 +944,14 @@ QWidget *C4PropertyDelegateEnum::CreateEditor(const C4PropertyDelegateFactory *p
void C4PropertyDelegateEnum::UpdateOptionIndex(C4PropertyDelegateEnum::Editor *editor, int newval) const
{
editor->option_changed = true;
UpdateEditorParameter(editor, true);
emit EditorValueChangedSignal(editor);
// Update value and parameter delegate if selection changed
if (newval != editor->last_selection_index)
{
editor->option_changed = true;
editor->last_selection_index = newval;
UpdateEditorParameter(editor, true);
emit EditorValueChangedSignal(editor);
}
}
void C4PropertyDelegateEnum::EnsureOptionDelegateResolved(const Option &option) const

View File

@ -237,6 +237,7 @@ class C4PropertyDelegateEnumEditor : public QWidget
public:
C4Value last_val;
int32_t last_selection_index;
C4PropertyPath last_get_path;
C4DeepQComboBox *option_box;
QHBoxLayout *layout;
@ -244,7 +245,7 @@ public:
bool updating, option_changed;
C4PropertyDelegateEnumEditor(QWidget *parent)
: QWidget(parent), option_box(NULL), layout(NULL), parameter_widget(NULL), updating(false), option_changed(false) { }
: QWidget(parent), last_selection_index(-1), option_box(NULL), layout(NULL), parameter_widget(NULL), updating(false), option_changed(false) { }
};
class C4PropertyDelegateEnum : public C4PropertyDelegate