Commit 7fa188aa authored by Chuck Atkins's avatar Chuck Atkins
Browse files

PVSC: Add default="random" capability to Enumeration options

parent a5f99fd7
......@@ -369,6 +369,7 @@ bool createWidgets(QMap<QString, pqWidget*>& widgets, QDialog& dialog,
}
else if (strcmp(typeNode->GetName(), "Enumeration") == 0)
{
std::vector<QString> entry_values;
QComboBox* widget = new QComboBox(&dialog);
for (unsigned int kk = 0; kk < typeNode->GetNumberOfNestedElements(); kk++)
{
......@@ -379,8 +380,25 @@ bool createWidgets(QMap<QString, pqWidget*>& widgets, QDialog& dialog,
QString xml_label =
child->GetAttributeOrDefault("label", xml_value.toLocal8Bit().data());
widget->addItem(xml_label, xml_value);
entry_values.push_back(xml_value);
if (xml_value == "random")
{
qWarning() << "Enumeration entry has a value of 'random' "
<< "which is a reserved keyword used for default "
<< "selection.";
}
}
}
if (default_is_random)
{
size_t default_random_idx = entry_values.size() * noise;
if (default_random_idx >= entry_values.size())
{
default_random_idx = entry_values.size()-1;
}
default_value = entry_values[default_random_idx];
}
widgets[name] = new pqWidgetForComboBox(widget);
}
else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment