Sort presets before display in the presets window

pull/27/head
f4exb 2016-09-11 18:58:40 +02:00
rodzic 7fc2b431a4
commit fed6b9a3bd
4 zmienionych plików z 16 dodań i 0 usunięć

Wyświetl plik

@ -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)
{

Wyświetl plik

@ -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);
}

Wyświetl plik

@ -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(); }

Wyświetl plik

@ -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;