Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If no intialValuesSource, use defaultValue #5699

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion QMLComponents/controls/tableviewbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,15 @@ void TableViewBase::setInitialValuesControl()
disconnect(_initialValuesControl->model(), &ListModel::termsChanged, _tableModel, &ListModelTableViewBase::initialValuesChanged);

QString initialValuesSourceName = initialValuesSource().toString();

if (!initialValuesSourceName.isEmpty() && form())
{
_initialValuesControl = qobject_cast<JASPListControl*>(form()->getControl(initialValuesSourceName));
addDependency(_initialValuesControl);
connect(_initialValuesControl->model(), &ListModel::termsChanged, _tableModel, &ListModelTableViewBase::initialValuesChanged);
_tableModel->initialValuesChanged();
}

_tableModel->initialValuesChanged(); //It could also be based on defaultValue https://github.com/jasp-stats/INTERNAL-jasp/issues/2661
}

void TableViewBase::rScriptDoneHandler(const QString & result)
Expand Down
10 changes: 9 additions & 1 deletion QMLComponents/models/listmodelfiltereddataentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,15 @@ void ListModelFilteredDataEntry::initialValuesChanged()
_initialValues.push_back(value.toDouble());
}
}

else if(_tableView->initialValuesSource().toString().isEmpty())
{
int rowCount = requestInfo(VariableInfo::DataSetRowCount).toInt();
QVariant defaultValue = _tableView->defaultValue();
bool isDbl = false;
double dblVal = defaultValue.toDouble(&isDbl);
if(isDbl)
_initialValues = doublevec(rowCount, dblVal);
}
fillTable();
}

Expand Down
Loading