Parameters InList can't parse default value if there's no "index" in JSON
in file dtkCoreParameters.tpp, line 1019:
if (v.canConvert<dtkCoreParameterInList>()) {
*this = v.value<dtkCoreParameterInList>();
} else if (v.canConvert<QVariantHash>()) {
auto map = v.toHash();
m_label = map["label"].toString();
m_doc = map["doc"].toString();
m_value_index = map["index"].value<int>();
m_values.clear();
auto list = map["values"].toList();
for(auto item : list) {
m_values << item.value<T>();
}
} else if (v.canConvert<T>()) {
int index = m_values.indexOf(v.value<T>());
if (index < 0) {
dtkWarn() << Q_FUNC_INFO << "Value is not part of the admissible ones.";
this->syncFail();
return;
} else {
m_value_index = index;
}
} else { ...
If if (v.canConvert<QVariantHash>())
is true, the function tries to find the default value only with the value linked to the key "index". If there's none, it takes the default value.
In the JSON, if the default value is set only by using the "value" key, it can't be parsed. It is only parsed if v
is not converted to a QVariantHash and converted afterwards as a single type as shown on line `else if (v.canConvert())".
Either we decide that default values must be set using the "index" key, or we should implement both getting the default value with "value" (and checking the index with indexOf, see above) and with the index value stored in the key "index".