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

Add option to automatically resize columns after an aircraft is added to the table

This commit is contained in:
Jon Beniston 2020-11-10 14:27:42 +00:00
parent 6aa2943849
commit 27c4802a7f
7 changed files with 116 additions and 87 deletions

View File

@ -20,9 +20,10 @@
#include "adsbdemoddisplaydialog.h" #include "adsbdemoddisplaydialog.h"
ADSBDemodDisplayDialog::ADSBDemodDisplayDialog ADSBDemodDisplayDialog::ADSBDemodDisplayDialog(
(int removeTimeout, float airportRange, ADSBDemodSettings::AirportType airportMinimumSize, int removeTimeout, float airportRange, ADSBDemodSettings::AirportType airportMinimumSize,
bool displayHeliports, bool siUnits, QString fontName, int fontSize, bool displayDemodStats, QWidget* parent) : bool displayHeliports, bool siUnits, QString fontName, int fontSize, bool displayDemodStats,
bool autoResizeTableColumns, QWidget* parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::ADSBDemodDisplayDialog), ui(new Ui::ADSBDemodDisplayDialog),
m_fontName(fontName), m_fontName(fontName),
@ -35,6 +36,7 @@ ADSBDemodDisplayDialog::ADSBDemodDisplayDialog
ui->heliports->setChecked(displayHeliports); ui->heliports->setChecked(displayHeliports);
ui->units->setCurrentIndex((int)siUnits); ui->units->setCurrentIndex((int)siUnits);
ui->displayStats->setChecked(displayDemodStats); ui->displayStats->setChecked(displayDemodStats);
ui->autoResizeTableColumns->setChecked(autoResizeTableColumns);
} }
ADSBDemodDisplayDialog::~ADSBDemodDisplayDialog() ADSBDemodDisplayDialog::~ADSBDemodDisplayDialog()
@ -50,6 +52,7 @@ void ADSBDemodDisplayDialog::accept()
m_displayHeliports = ui->heliports->isChecked(); m_displayHeliports = ui->heliports->isChecked();
m_siUnits = ui->units->currentIndex() == 0 ? false : true; m_siUnits = ui->units->currentIndex() == 0 ? false : true;
m_displayDemodStats = ui->displayStats->isChecked(); m_displayDemodStats = ui->displayStats->isChecked();
m_autoResizeTableColumns = ui->autoResizeTableColumns->isChecked();
QDialog::accept(); QDialog::accept();
} }

View File

@ -26,8 +26,8 @@ class ADSBDemodDisplayDialog : public QDialog {
public: public:
explicit ADSBDemodDisplayDialog(int removeTimeout, float airportRange, ADSBDemodSettings::AirportType airportMinimumSize, explicit ADSBDemodDisplayDialog(int removeTimeout, float airportRange, ADSBDemodSettings::AirportType airportMinimumSize,
bool displayHeliports, bool siUnits, QString fontName, int fontSize, bool displayDemodStats bool displayHeliports, bool siUnits, QString fontName, int fontSize, bool displayDemodStats,
, QWidget* parent = 0); bool autoResizeTableColumns, QWidget* parent = 0);
~ADSBDemodDisplayDialog(); ~ADSBDemodDisplayDialog();
int m_removeTimeout; int m_removeTimeout;
@ -38,6 +38,7 @@ public:
QString m_fontName; QString m_fontName;
int m_fontSize; int m_fontSize;
bool m_displayDemodStats; bool m_displayDemodStats;
bool m_autoResizeTableColumns;
private slots: private slots:
void accept(); void accept();

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>351</width> <width>351</width>
<height>275</height> <height>289</height>
</rect> </rect>
</property> </property>
<property name="font"> <property name="font">
@ -22,29 +22,52 @@
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<layout class="QFormLayout" name="formLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="5" column="1">
<widget class="QLabel" name="unitsLabel"> <widget class="QPushButton" name="font">
<property name="toolTip">
<string>Select a font for the table</string>
</property>
<property name="text"> <property name="text">
<string>Units</string> <string>Select...</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="4" column="0">
<widget class="QComboBox" name="units"> <widget class="QLabel" name="timeoutLabel">
<property name="text">
<string>Aircraft timeout (s)</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="airportRange">
<property name="toolTip"> <property name="toolTip">
<string>The units to use for altitude, speed and climb rate</string> <string>Displays airports within the specified distance in kilometres from My Position</string>
</property> </property>
<item> <property name="maximum">
<property name="text"> <number>20000</number>
<string>ft, kn, ft/min</string>
</property> </property>
</widget>
</item> </item>
<item> <item row="2" column="0">
<property name="text"> <widget class="QCheckBox" name="heliports">
<string>m, kph, m/s</string> <property name="toolTip">
<string>When checked, heliports are displayed on the map</string>
</property> </property>
<property name="text">
<string>Display heliports</string>
</property>
</widget>
</item> </item>
<item row="4" column="1">
<widget class="QSpinBox" name="timeout">
<property name="toolTip">
<string>How long in seconds after not receving any frames will an aircraft be removed from the table and map</string>
</property>
<property name="maximum">
<number>1000000</number>
</property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
@ -54,6 +77,43 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0">
<widget class="QLabel" name="airportRangeLabel">
<property name="text">
<string>Airport display distance (km)</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="fontLabel">
<property name="text">
<string>Table font</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="displayStats">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Display demodulator statistics</string>
</property>
<property name="text">
<string>Display demodulator statistics</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="unitsLabel">
<property name="text">
<string>Units</string>
</property>
</widget>
</item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QComboBox" name="airportSize"> <widget class="QComboBox" name="airportSize">
<property name="toolTip"> <property name="toolTip">
@ -76,75 +136,31 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="heliports"> <widget class="QCheckBox" name="autoResizeTableColumns">
<property name="toolTip"> <property name="toolTip">
<string>When checked, heliports are displayed on the map</string> <string>Resize the columns in the table after an aircraft is added to it</string>
</property> </property>
<property name="text"> <property name="text">
<string>Display heliports</string> <string>Resize columns after adding aircraft</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="0" column="1">
<widget class="QLabel" name="airportRangeLabel"> <widget class="QComboBox" name="units">
<property name="text">
<string>Airport display distance (km)</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="airportRange">
<property name="toolTip"> <property name="toolTip">
<string>Displays airports within the specified distance in kilometres from My Position</string> <string>The units to use for altitude, speed and climb rate</string>
</property> </property>
<property name="maximum"> <item>
<number>20000</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="timeoutLabel">
<property name="text"> <property name="text">
<string>Aircraft timeout (s)</string> <string>ft, kn, ft/min</string>
</property> </property>
</widget>
</item> </item>
<item row="4" column="1"> <item>
<widget class="QSpinBox" name="timeout">
<property name="toolTip">
<string>How long in seconds after not receving any frames will an aircraft be removed from the table and map</string>
</property>
<property name="maximum">
<number>1000000</number>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="fontLabel">
<property name="text"> <property name="text">
<string>Table font</string> <string>m, kph, m/s</string>
</property> </property>
</widget>
</item> </item>
<item row="6" column="1">
<widget class="QPushButton" name="font">
<property name="toolTip">
<string>Select a font for the table</string>
</property>
<property name="text">
<string>Select...</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="displayStats">
<property name="toolTip">
<string>Display demodulator statistics</string>
</property>
<property name="text">
<string>Display demodulator statistics</string>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -703,6 +703,8 @@ void ADSBDemodGUI::handleADSB(
} }
} }
} }
if (m_settings.m_autoResizeTableColumns)
ui->adsbData->resizeColumnsToContents();
ui->adsbData->setSortingEnabled(true); ui->adsbData->setSortingEnabled(true);
} }
aircraft->m_time = dateTime; aircraft->m_time = dateTime;
@ -1604,7 +1606,7 @@ void ADSBDemodGUI::on_displaySettings_clicked(bool checked)
ADSBDemodDisplayDialog dialog(m_settings.m_removeTimeout, m_settings.m_airportRange, m_settings.m_airportMinimumSize, ADSBDemodDisplayDialog dialog(m_settings.m_removeTimeout, m_settings.m_airportRange, m_settings.m_airportMinimumSize,
m_settings.m_displayHeliports, m_settings.m_siUnits, m_settings.m_displayHeliports, m_settings.m_siUnits,
m_settings.m_tableFontName, m_settings.m_tableFontSize, m_settings.m_tableFontName, m_settings.m_tableFontSize,
m_settings.m_displayDemodStats); m_settings.m_displayDemodStats, m_settings.m_autoResizeTableColumns);
if (dialog.exec() == QDialog::Accepted) if (dialog.exec() == QDialog::Accepted)
{ {
bool unitsChanged = m_settings.m_siUnits != dialog.m_siUnits; bool unitsChanged = m_settings.m_siUnits != dialog.m_siUnits;
@ -1617,6 +1619,7 @@ void ADSBDemodGUI::on_displaySettings_clicked(bool checked)
m_settings.m_tableFontName = dialog.m_fontName; m_settings.m_tableFontName = dialog.m_fontName;
m_settings.m_tableFontSize = dialog.m_fontSize; m_settings.m_tableFontSize = dialog.m_fontSize;
m_settings.m_displayDemodStats = dialog.m_displayDemodStats; m_settings.m_displayDemodStats = dialog.m_displayDemodStats;
m_settings.m_autoResizeTableColumns = dialog.m_autoResizeTableColumns;
if (unitsChanged) if (unitsChanged)
m_aircraftModel.allAircraftUpdated(); m_aircraftModel.allAircraftUpdated();
@ -1947,7 +1950,7 @@ void ADSBDemodGUI::resizeTable()
ui->adsbData->setItem(row, ADSB_COL_RANGE, new QTableWidgetItem("D (km)")); ui->adsbData->setItem(row, ADSB_COL_RANGE, new QTableWidgetItem("D (km)"));
ui->adsbData->setItem(row, ADSB_COL_AZEL, new QTableWidgetItem("Az/El (o)")); ui->adsbData->setItem(row, ADSB_COL_AZEL, new QTableWidgetItem("Az/El (o)"));
ui->adsbData->setItem(row, ADSB_COL_LATITUDE, new QTableWidgetItem("-90.00000")); ui->adsbData->setItem(row, ADSB_COL_LATITUDE, new QTableWidgetItem("-90.00000"));
ui->adsbData->setItem(row, ADSB_COL_LONGITUDE, new QTableWidgetItem("-180.00000")); ui->adsbData->setItem(row, ADSB_COL_LONGITUDE, new QTableWidgetItem("-180.000000"));
ui->adsbData->setItem(row, ADSB_COL_CATEGORY, new QTableWidgetItem("Heavy")); ui->adsbData->setItem(row, ADSB_COL_CATEGORY, new QTableWidgetItem("Heavy"));
ui->adsbData->setItem(row, ADSB_COL_STATUS, new QTableWidgetItem("No emergency")); ui->adsbData->setItem(row, ADSB_COL_STATUS, new QTableWidgetItem("No emergency"));
ui->adsbData->setItem(row, ADSB_COL_SQUAWK, new QTableWidgetItem("Squawk")); ui->adsbData->setItem(row, ADSB_COL_SQUAWK, new QTableWidgetItem("Squawk"));

View File

@ -60,6 +60,7 @@ void ADSBDemodSettings::resetToDefaults()
m_correlateFullPreamble = true; m_correlateFullPreamble = true;
m_demodModeS = false; m_demodModeS = false;
m_deviceIndex = -1; m_deviceIndex = -1;
m_autoResizeTableColumns = false;
for (int i = 0; i < ADSBDEMOD_COLUMNS; i++) for (int i = 0; i < ADSBDEMOD_COLUMNS; i++)
{ {
m_columnIndexes[i] = i; m_columnIndexes[i] = i;
@ -103,6 +104,7 @@ QByteArray ADSBDemodSettings::serialize() const
s.writeBool(27, m_displayDemodStats); s.writeBool(27, m_displayDemodStats);
s.writeBool(28, m_correlateFullPreamble); s.writeBool(28, m_correlateFullPreamble);
s.writeBool(29, m_demodModeS); s.writeBool(29, m_demodModeS);
s.writeBool(30, m_autoResizeTableColumns);
for (int i = 0; i < ADSBDEMOD_COLUMNS; i++) for (int i = 0; i < ADSBDEMOD_COLUMNS; i++)
s.writeS32(100 + i, m_columnIndexes[i]); s.writeS32(100 + i, m_columnIndexes[i]);
@ -179,6 +181,7 @@ bool ADSBDemodSettings::deserialize(const QByteArray& data)
d.readBool(27, &m_displayDemodStats, false); d.readBool(27, &m_displayDemodStats, false);
d.readBool(28, &m_correlateFullPreamble, true); d.readBool(28, &m_correlateFullPreamble, true);
d.readBool(29, &m_demodModeS, false); d.readBool(29, &m_demodModeS, false);
d.readBool(30, &m_autoResizeTableColumns, false);
for (int i = 0; i < ADSBDEMOD_COLUMNS; i++) for (int i = 0; i < ADSBDEMOD_COLUMNS; i++)
d.readS32(100 + i, &m_columnIndexes[i], i); d.readS32(100 + i, &m_columnIndexes[i], i);

View File

@ -73,6 +73,7 @@ struct ADSBDemodSettings
bool m_correlateFullPreamble; bool m_correlateFullPreamble;
bool m_demodModeS; //!< Demodulate all Mode-S frames, not just ADS-B bool m_demodModeS; //!< Demodulate all Mode-S frames, not just ADS-B
int m_deviceIndex; //!< Device to set to ATC frequencies int m_deviceIndex; //!< Device to set to ATC frequencies
bool m_autoResizeTableColumns;
ADSBDemodSettings(); ADSBDemodSettings();
void resetToDefaults(); void resetToDefaults();

View File

@ -64,6 +64,8 @@ Clicking the Display Settings button will open the Display Settings dialog, whic
* The distance (in kilometres), from the location set under Preferences > My Position, at which airports will be displayed on the map. * The distance (in kilometres), from the location set under Preferences > My Position, at which airports will be displayed on the map.
* The timeout, in seconds, after which an aircraft will be removed from the table and map, if an ADS-B frame has not been received from it. * The timeout, in seconds, after which an aircraft will be removed from the table and map, if an ADS-B frame has not been received from it.
* The font used for the table. * The font used for the table.
* Whether demodulator statistics are displayed (primarily an option for developers).
* Whether the columns in the table are automatically resized after an aircraft is added to it. If unchecked, columns can be resized manually and should be saved with presets.
<h3>12: Display Flight Paths</h3> <h3>12: Display Flight Paths</h3>