mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-17 13:51:47 -05:00
Sort presets before display in the presets window
This commit is contained in:
parent
7fc2b431a4
commit
fed6b9a3bd
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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(); }
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user