summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/preferences/preferencesdialog.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-11-24 12:55:59 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-12-12 15:52:40 -0800
commitf3a2ee8082fd5b9e54564b77ac49efdf9444e802 (patch)
tree02fe8ca95fed6af53019f0a9451fb2cf9ab3e613 /desktop-widgets/preferences/preferencesdialog.cpp
parent2d7be7a0e366b562fdff914e92219ab1852cd3c8 (diff)
downloadsubsurface-f3a2ee8082fd5b9e54564b77ac49efdf9444e802.tar.gz
preferences: sort pages only once
After each addition of a page in the constructor, the list was resorted. This appears pointless. Instead, sort the list only after all pages were added. Since the add-page function is now a single line, remove it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/preferences/preferencesdialog.cpp')
-rw-r--r--desktop-widgets/preferences/preferencesdialog.cpp41
1 files changed, 18 insertions, 23 deletions
diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp
index ca5e606cd..1b4119e81 100644
--- a/desktop-widgets/preferences/preferencesdialog.cpp
+++ b/desktop-widgets/preferences/preferencesdialog.cpp
@@ -32,6 +32,11 @@ PreferencesDialog *PreferencesDialog::instance()
return self;
}
+static bool abstractpreferenceswidget_lessthan(const AbstractPreferencesWidget *p1, const AbstractPreferencesWidget *p2)
+{
+ return p1->positionHeight() < p2->positionHeight();
+}
+
PreferencesDialog::PreferencesDialog()
{
//FIXME: This looks wrong.
@@ -61,18 +66,19 @@ PreferencesDialog::PreferencesDialog()
setLayout(v);
- addPreferencePage(new PreferencesLanguage());
- addPreferencePage(new PreferencesGeoreference());
- addPreferencePage(new PreferencesDefaults());
- addPreferencePage(new PreferencesUnits());
- addPreferencePage(new PreferencesGraph());
- addPreferencePage(new PreferencesNetwork());
- addPreferencePage(new PreferencesCloud());
- addPreferencePage(new PreferencesEquipment());
- addPreferencePage(new PreferencesMedia());
- addPreferencePage(new PreferencesDc());
- addPreferencePage(new PreferencesLog());
- addPreferencePage(new PreferencesReset());
+ pages.push_back(new PreferencesLanguage);
+ pages.push_back(new PreferencesGeoreference);
+ pages.push_back(new PreferencesDefaults);
+ pages.push_back(new PreferencesUnits);
+ pages.push_back(new PreferencesGraph);
+ pages.push_back(new PreferencesNetwork);
+ pages.push_back(new PreferencesCloud);
+ pages.push_back(new PreferencesEquipment);
+ pages.push_back(new PreferencesMedia);
+ pages.push_back(new PreferencesDc);
+ pages.push_back(new PreferencesLog);
+ pages.push_back(new PreferencesReset);
+ std::sort(pages.begin(), pages.end(), abstractpreferenceswidget_lessthan);
refreshPages();
@@ -98,17 +104,6 @@ void PreferencesDialog::buttonClicked(QAbstractButton* btn)
}
}
-bool abstractpreferenceswidget_lessthan(AbstractPreferencesWidget *p1, AbstractPreferencesWidget *p2)
-{
- return p1->positionHeight() < p2->positionHeight();
-}
-
-void PreferencesDialog::addPreferencePage(AbstractPreferencesWidget *page)
-{
- pages.push_back(page);
- std::sort(pages.begin(), pages.end(), abstractpreferenceswidget_lessthan);
-}
-
void PreferencesDialog::refreshPages()
{
// Remove things