diff --git a/Modules/jaspTestModule b/Modules/jaspTestModule index 50a19622c4..ce341f23a5 160000 --- a/Modules/jaspTestModule +++ b/Modules/jaspTestModule @@ -1 +1 @@ -Subproject commit 50a19622c472b89916c149ad63628c644e77f4a6 +Subproject commit ce341f23a5d7ade567f85e39db56c5f9b5e439a6 diff --git a/QMLComponents/controls/comboboxbase.cpp b/QMLComponents/controls/comboboxbase.cpp index b2f7309b41..43aaa0f4f6 100644 --- a/QMLComponents/controls/comboboxbase.cpp +++ b/QMLComponents/controls/comboboxbase.cpp @@ -82,6 +82,8 @@ void ComboBoxBase::bindTo(const Json::Value& value) index = int(std::distance(values.begin(), itr)); } } + else if (!selectedValue.empty()) + _lostValue = selectedValue; _setCurrentProperties(index); @@ -133,7 +135,7 @@ Json::Value ComboBoxBase::createJson() const bool ComboBoxBase::isJsonValid(const Json::Value &optionValue) const { - return optionValue.type() == Json::stringValue || optionValue.type() == Json::arrayValue; + return optionValue.type() == Json::stringValue || optionValue.type() == Json::objectValue; } void ComboBoxBase::setUp() @@ -151,8 +153,10 @@ void ComboBoxBase::setUp() connect(this, &ComboBoxBase::currentValueChanged, [this] () { if (containsVariables()) checkLevelsConstraints(); } ); if (form()) + { connect(form(), &AnalysisForm::languageChanged, [this] () { _model->resetTermsFromSources(); } ); - + connect(form(), &AnalysisForm::analysisChanged, [this] () { _lostValue = ""; }); + } } void ComboBoxBase::setUpModel() @@ -180,6 +184,17 @@ void ComboBoxBase::termsChangedHandler() { auto itr = std::find(values.begin(), values.end(), fq(_currentValue)); + if (!_lostValue.empty()) + { + auto lostValueItr = std::find(values.begin(), values.end(), _lostValue); + if (lostValueItr != values.end()) + { + itr = lostValueItr; + _orgValue = _lostValue; + _lostValue = ""; + } + } + if (itr == values.end()) index = _getStartIndex(); else index = int(std::distance(values.begin(), itr)); } diff --git a/QMLComponents/controls/comboboxbase.h b/QMLComponents/controls/comboboxbase.h index 6a65ff28ba..02d32b54ce 100644 --- a/QMLComponents/controls/comboboxbase.h +++ b/QMLComponents/controls/comboboxbase.h @@ -92,6 +92,7 @@ protected slots: _currentColumnType, _currentColumnRealType, _currentColumnTypeIcon; + std::string _lostValue; int _currentIndex = -1; bool _fixedWidth = false; diff --git a/QMLComponents/controls/jasplistcontrol.cpp b/QMLComponents/controls/jasplistcontrol.cpp index bb8dec1326..bb2ef6c145 100644 --- a/QMLComponents/controls/jasplistcontrol.cpp +++ b/QMLComponents/controls/jasplistcontrol.cpp @@ -410,7 +410,7 @@ bool JASPListControl::checkLevelsConstraints() QStringList JASPListControl::levels() const { - return initialized() ? model()->allLevels(model()->terms()) : QStringList(); + return model() ? model()->allLevels(model()->terms()) : QStringList(); } QStringList JASPListControl::allowedColumnsIcons() const diff --git a/QMLComponents/models/listmodelinteractionassigned.cpp b/QMLComponents/models/listmodelinteractionassigned.cpp index 568c250e01..aad7bd597a 100644 --- a/QMLComponents/models/listmodelinteractionassigned.cpp +++ b/QMLComponents/models/listmodelinteractionassigned.cpp @@ -166,7 +166,7 @@ Terms ListModelInteractionAssigned::addTerms(const Terms& terms, int , const Row Terms dropped; if (availableModel()) dropped.setSortParent(availableModel()->allTerms()); - dropped.set(terms); + dropped.set(checkTermsTypes(terms)); Terms newTerms = dropped.combineTerms(JASPControl::CombinationType::CombinationCross);