1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

Fix updateVORs so it doesn't delete selected VORs. For #1590

This commit is contained in:
Jon Beniston 2023-03-06 17:11:34 +00:00
parent 1b2162d88f
commit e930cf3c90
2 changed files with 29 additions and 11 deletions

View File

@ -496,7 +496,7 @@ void VORLocalizerGUI::selectVOR(VORGUI *vorGUI, bool selected)
void VORLocalizerGUI::updateVORs()
{
m_vorModel.removeAllVORs();
m_vorModel.removeAllExceptSelected();
AzEl azEl = m_azEl;
for (const auto vor : *m_vors)
@ -509,7 +509,7 @@ void VORLocalizerGUI::updateVORs()
// Only display VOR if in range
if (azEl.getDistance() <= 200000) {
m_vorModel.addVOR(vor);
m_vorModel.addVOR(vor); // addVOR checks for duplicates
}
}
}

View File

@ -101,12 +101,15 @@ public:
}
Q_INVOKABLE void addVOR(NavAid *vor) {
beginInsertRows(QModelIndex(), rowCount(), rowCount());
m_vors.append(vor);
m_selected.append(false);
m_radials.append(-1.0f);
m_vorGUIs.append(nullptr);
endInsertRows();
if (!m_vors.contains(vor))
{
beginInsertRows(QModelIndex(), rowCount(), rowCount());
m_vors.append(vor);
m_selected.append(false);
m_radials.append(-1.0f);
m_vorGUIs.append(nullptr);
endInsertRows();
}
}
int rowCount(const QModelIndex &parent = QModelIndex()) const override {
@ -123,7 +126,8 @@ public:
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
}
void allVORUpdated() {
void allVORUpdated()
{
for (int i = 0; i < m_vors.count(); i++)
{
QModelIndex idx = index(i);
@ -131,7 +135,8 @@ public:
}
}
void removeVOR(NavAid *vor) {
void removeVOR(NavAid *vor)
{
int row = m_vors.indexOf(vor);
if (row >= 0)
{
@ -144,7 +149,8 @@ public:
}
}
void removeAllVORs() {
void removeAllVORs()
{
if (m_vors.count() > 0)
{
beginRemoveRows(QModelIndex(), 0, m_vors.count() - 1);
@ -156,6 +162,18 @@ public:
}
}
void removeAllExceptSelected()
{
for (int i = 0; i < m_vors.count(); i++)
{
if (!m_selected[i])
{
removeVOR(m_vors[i]);
i--;
}
}
}
QHash<int, QByteArray> roleNames() const {
QHash<int, QByteArray> roles;
roles[positionRole] = "position";