1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-10 18:43:28 -05:00

Use a QSpinBox for Filter Distance with a maximum of 10 000 kilometres

This commit is contained in:
Daniele Forsi 2024-06-26 21:48:06 +02:00
parent 91862a582e
commit cc0e0c0f28
3 changed files with 10 additions and 13 deletions

View File

@ -26,6 +26,8 @@
#include <QHash>
#include <QRegularExpression>
#define MAX_FILTER_DISTANCE_KM 10000
class Serializable;
struct MapSettings

View File

@ -47,9 +47,15 @@ MapItemSettingsGUI::MapItemSettingsGUI(QTableWidget *table, int row, MapSettings
m_labelScale->setRange(0.01, 10.0);
m_labelScale->setValue(settings->m_3DLabelScale);
m_labelScale->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
m_filterDistance = new QSpinBox(table);
m_filterDistance->setRange(0, MAX_FILTER_DISTANCE_KM);
m_filterDistance->setValue(settings->m_filterDistance / 1000);
m_filterDistance->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
m_filterDistance->setSpecialValueText(" ");
table->setCellWidget(row, MapSettingsDialog::COL_2D_MIN_ZOOM, m_minZoom);
table->setCellWidget(row, MapSettingsDialog::COL_3D_MIN_PIXELS, m_minPixels);
table->setCellWidget(row, MapSettingsDialog::COL_3D_LABEL_SCALE, m_labelScale);
table->setCellWidget(row, MapSettingsDialog::COL_FILTER_DISTANCE, m_filterDistance);
}
MapSettingsDialog::MapSettingsDialog(MapSettings *settings, QWidget* parent) :
@ -124,12 +130,6 @@ MapSettingsDialog::MapSettingsDialog(MapSettings *settings, QWidget* parent) :
item = new QTableWidgetItem(itemSettings->m_filterName);
ui->mapItemSettings->setItem(row, COL_FILTER_NAME, item);
item = new QTableWidgetItem();
if (itemSettings->m_filterDistance > 0) {
item->setText(QString::number(itemSettings->m_filterDistance / 1000));
}
ui->mapItemSettings->setItem(row, COL_FILTER_DISTANCE, item);
ui->mapItemSettings->item(row, COL_FILTER_DISTANCE)->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
MapItemSettingsGUI *gui = new MapItemSettingsGUI(ui->mapItemSettings, row, itemSettings);
m_mapItemSettingsGUIs.append(gui);
@ -266,13 +266,7 @@ void MapSettingsDialog::accept()
itemSettings->m_filterName = ui->mapItemSettings->item(row, COL_FILTER_NAME)->text();
itemSettings->m_filterNameRE.setPattern(itemSettings->m_filterName);
itemSettings->m_filterNameRE.optimize();
bool ok;
int filterDistance = ui->mapItemSettings->item(row, COL_FILTER_DISTANCE)->text().toInt(&ok);
if (ok && filterDistance > 0) {
itemSettings->m_filterDistance = filterDistance * 1000;
} else {
itemSettings->m_filterDistance = 0;
}
itemSettings->m_filterDistance = gui->m_filterDistance->value() * 1000;
}
QDialog::accept();

View File

@ -47,6 +47,7 @@ public:
QSpinBox *m_minZoom;
QSpinBox *m_minPixels;
QDoubleSpinBox *m_labelScale;
QSpinBox *m_filterDistance;
};
class MapSettingsDialog : public QDialog {