PreferenceDialogs now preserve the sort order of their showCategories.

Specifically, this was to fix the issue with the Neuron plugin preferences being
the top section in the General Preferences dialog, now it is the last.
This commit is contained in:
Anthony J. Thibault 2016-11-23 10:11:28 -08:00
parent 9b0ce556e7
commit cbf514a738

View file

@ -55,22 +55,20 @@ ScrollingWindow {
Component.onCompleted: {
var categories = Preferences.categories;
var categoryMap;
var i;
if (showCategories && showCategories.length) {
categoryMap = {};
for (i = 0; i < showCategories.length; ++i) {
categoryMap[showCategories[i]] = true;
}
// build a map of valid categories.
var categoryMap = {};
for (i = 0; i < categories.length; i++) {
categoryMap[categories[i]] = true;
}
for (i = 0; i < categories.length; ++i) {
var category = categories[i];
if (categoryMap && !categoryMap[category]) {
continue;
// create a section for each valid category in showCategories
// NOTE: the sort order of items in the showCategories array is the same order in the dialog.
for (i = 0; i < showCategories.length; i++) {
if (categoryMap[showCategories[i]]) {
sections.push(sectionBuilder.createObject(prefControls, {name: showCategories[i]}));
}
sections.push(sectionBuilder.createObject(prefControls, { name: category }));
}
if (sections.length) {