forked from Mirrors/openclonk
Qt Editor: Do not reset value to default parameter when re-selecting an already selected index
parent
3c84f9e6f8
commit
dfb709df6b
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue