Skip to content

Commit

Permalink
If userOptions specifies an order, use that to sort the form
Browse files Browse the repository at this point in the history
Fix OpenChemistry#1498

Signed-off-by: Geoff Hutchison <[email protected]>
  • Loading branch information
ghutchis committed Dec 5, 2023
1 parent e00b952 commit ea531ac
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion avogadro/qtgui/jsonwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,26 @@ void JsonWidget::buildOptionGui()
}

// Add remaining keys at bottom.
// look for "order" key to determine order
QStringList keys;
for (QJsonObject::const_iterator it = userOptions.constBegin(),
itEnd = userOptions.constEnd();
it != itEnd; ++it) {
addOptionRow(it.key(), it.key(), it.value());
if (it.value().isObject()) {
QJsonObject obj = it.value().toObject();
if (obj.contains("order") && obj.value("order").isDouble()) {
keys.insert(obj.value("order").toInt(), it.key());
} else {
keys.append(it.key());
}
} else {
keys.append(it.key());
}
}

// now loop over keys and add them
for (const QString& key : keys) {
addOptionRow(key, key, userOptions.take(key));
}

// Make connections for standard options:
Expand Down

1 comment on commit ea531ac

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ERROR: clang-format-diff detected formatting issues. See the artifact for a patch or run clang-format on your branch.

Please sign in to comment.