1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

enable natural numeric sorting in satellite tracker table

This commit is contained in:
DreamNik 2021-09-01 20:59:00 +03:00
parent 95f5e9ec7a
commit feaacd390f

View File

@ -1036,6 +1036,20 @@ public:
}
};
class NaturallySortedTableWidgetItem : public QTableWidgetItem
{
public:
bool operator<(const QTableWidgetItem &other) const override
{
QCollator coll;
coll.setNumericMode(true);
return coll.compare( text() , other.text() ) < 0;
}
};
#define SPEED_OF_LIGHT 299792458.0
// Frequency in Hz, speed in m/s
@ -1071,8 +1085,10 @@ void SatelliteTrackerGUI::updateTable(SatelliteState *satState)
{
if ((i == SAT_COL_AOS) || (i == SAT_COL_LOS))
items[i] = new DateTimeSortedTableWidgetItem();
else
else if((i == SAT_COL_NAME) || (i == SAT_COL_NORAD_ID))
items[i] = new QTableWidgetItem();
else
items[i] = new NaturallySortedTableWidgetItem();
items[i]->setToolTip(ui->satTable->horizontalHeaderItem(i)->toolTip());
ui->satTable->setItem(row, i, items[i]);
}