1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-24 02:36:15 -05:00

Sort presets before display in the presets window

This commit is contained in:
f4exb 2016-09-11 18:58:40 +02:00
parent 7fc2b431a4
commit fed6b9a3bd
4 changed files with 16 additions and 0 deletions

View File

@ -287,6 +287,7 @@ void MainWindow::loadSettings()
qDebug() << "MainWindow::loadSettings";
m_settings.load();
m_settings.sortPresets();
for(int i = 0; i < m_settings.getPresetCount(); ++i)
{

View File

@ -92,3 +92,8 @@ void MainSettings::deletePreset(const Preset* preset)
m_presets.removeAll((Preset*)preset);
delete (Preset*)preset;
}
void MainSettings::sortPresets()
{
qSort(m_presets.begin(), m_presets.end(), Preset::presetCompare);
}

View File

@ -19,6 +19,7 @@ public:
void deletePreset(const Preset* preset);
int getPresetCount() const { return m_presets.count(); }
const Preset* getPreset(int index) const { return m_presets[index]; }
void sortPresets();
Preset* getWorkingPreset() { return &m_workingPreset; }
int getSourceIndex() const { return m_preferences.getSourceIndex(); }

View File

@ -75,6 +75,15 @@ public:
const QString& sourceSerial,
int sourceSequence) const;
static bool presetCompare(const Preset *p1, Preset *p2)
{
if (p1->m_centerFrequency != p2->m_centerFrequency) {
return p1->m_centerFrequency < p2->m_centerFrequency;
} else {
return p1->m_description < p2->m_description;
}
}
protected:
// group and preset description
QString m_group;