Skip to content

Commit

Permalink
Fix some issues found in the Test Module
Browse files Browse the repository at this point in the history
. In Test Variable Encoding, if you drag & drop 2 variables in an Interaction VariablesList, it adds automatically the interaction term. If there is an allowed type, the terms should get automatically this type even if they have another type. This does not work for the interaction term: in the result, we can still see that it keeps the original types.
. In Test Sources with special attributes analysis, in the source with levels section. If you set a nominal/ordinal variable, you see the levels of the variable in the dropdown. If you duplicate the analysis, it loses these values.
  • Loading branch information
boutinb committed Nov 20, 2024
1 parent 1990b5e commit a1474c6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Modules/jaspTestModule
19 changes: 17 additions & 2 deletions QMLComponents/controls/comboboxbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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));
}
Expand Down
1 change: 1 addition & 0 deletions QMLComponents/controls/comboboxbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ protected slots:
_currentColumnType,
_currentColumnRealType,
_currentColumnTypeIcon;
std::string _lostValue;
int _currentIndex = -1;
bool _fixedWidth = false;

Expand Down
2 changes: 1 addition & 1 deletion QMLComponents/controls/jasplistcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion QMLComponents/models/listmodelinteractionassigned.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit a1474c6

Please sign in to comment.