mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
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>
This commit is contained in:
parent
2d7be7a0e3
commit
f3a2ee8082
2 changed files with 18 additions and 24 deletions
|
@ -32,6 +32,11 @@ PreferencesDialog *PreferencesDialog::instance()
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool abstractpreferenceswidget_lessthan(const AbstractPreferencesWidget *p1, const AbstractPreferencesWidget *p2)
|
||||||
|
{
|
||||||
|
return p1->positionHeight() < p2->positionHeight();
|
||||||
|
}
|
||||||
|
|
||||||
PreferencesDialog::PreferencesDialog()
|
PreferencesDialog::PreferencesDialog()
|
||||||
{
|
{
|
||||||
//FIXME: This looks wrong.
|
//FIXME: This looks wrong.
|
||||||
|
@ -61,18 +66,19 @@ PreferencesDialog::PreferencesDialog()
|
||||||
|
|
||||||
setLayout(v);
|
setLayout(v);
|
||||||
|
|
||||||
addPreferencePage(new PreferencesLanguage());
|
pages.push_back(new PreferencesLanguage);
|
||||||
addPreferencePage(new PreferencesGeoreference());
|
pages.push_back(new PreferencesGeoreference);
|
||||||
addPreferencePage(new PreferencesDefaults());
|
pages.push_back(new PreferencesDefaults);
|
||||||
addPreferencePage(new PreferencesUnits());
|
pages.push_back(new PreferencesUnits);
|
||||||
addPreferencePage(new PreferencesGraph());
|
pages.push_back(new PreferencesGraph);
|
||||||
addPreferencePage(new PreferencesNetwork());
|
pages.push_back(new PreferencesNetwork);
|
||||||
addPreferencePage(new PreferencesCloud());
|
pages.push_back(new PreferencesCloud);
|
||||||
addPreferencePage(new PreferencesEquipment());
|
pages.push_back(new PreferencesEquipment);
|
||||||
addPreferencePage(new PreferencesMedia());
|
pages.push_back(new PreferencesMedia);
|
||||||
addPreferencePage(new PreferencesDc());
|
pages.push_back(new PreferencesDc);
|
||||||
addPreferencePage(new PreferencesLog());
|
pages.push_back(new PreferencesLog);
|
||||||
addPreferencePage(new PreferencesReset());
|
pages.push_back(new PreferencesReset);
|
||||||
|
std::sort(pages.begin(), pages.end(), abstractpreferenceswidget_lessthan);
|
||||||
|
|
||||||
refreshPages();
|
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()
|
void PreferencesDialog::refreshPages()
|
||||||
{
|
{
|
||||||
// Remove things
|
// Remove things
|
||||||
|
|
|
@ -16,7 +16,6 @@ class PreferencesDialog : public QDialog {
|
||||||
public:
|
public:
|
||||||
static PreferencesDialog* instance();
|
static PreferencesDialog* instance();
|
||||||
~PreferencesDialog();
|
~PreferencesDialog();
|
||||||
void addPreferencePage(AbstractPreferencesWidget *page);
|
|
||||||
void refreshPages();
|
void refreshPages();
|
||||||
void defaultsRequested();
|
void defaultsRequested();
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Reference in a new issue