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

Merge pull request #1493 from srcejon/fix_sat_tracker_next_sort

Satellite Tracker: Fix sorting of next column
This commit is contained in:
Edouard Griffiths 2022-10-29 03:15:52 +02:00 committed by GitHub
commit fcb156b5da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1080,6 +1080,29 @@ public:
} }
}; };
// Handle sorting for next column, which can have times as HH:MM:SS or MM:SS
class NextEventTableWidgetItem : public QTableWidgetItem
{
public:
bool operator<(const QTableWidgetItem &other) const override
{
QString t1 = text();
QString t2 = other.text();
int t1Colons = t1.count(":");
int t2Colons = t2.count(":");
if (t1Colons == t2Colons)
{
QCollator coll;
coll.setNumericMode(true);
return coll.compare(t1, t2) < 0;
}
else
{
return t1Colons < t2Colons;
}
}
};
class NaturallySortedTableWidgetItem : public QTableWidgetItem class NaturallySortedTableWidgetItem : public QTableWidgetItem
{ {
public: public:
@ -1129,6 +1152,8 @@ void SatelliteTrackerGUI::updateTable(SatelliteState *satState)
items[i] = new DateTimeSortedTableWidgetItem(); items[i] = new DateTimeSortedTableWidgetItem();
else if ((i == SAT_COL_NAME) || (i == SAT_COL_NORAD_ID)) else if ((i == SAT_COL_NAME) || (i == SAT_COL_NORAD_ID))
items[i] = new QTableWidgetItem(); items[i] = new QTableWidgetItem();
else if (i == SAT_COL_TNE)
items[i] = new NextEventTableWidgetItem();
else else
items[i] = new NaturallySortedTableWidgetItem(); items[i] = new NaturallySortedTableWidgetItem();
items[i]->setToolTip(ui->satTable->horizontalHeaderItem(i)->toolTip()); items[i]->setToolTip(ui->satTable->horizontalHeaderItem(i)->toolTip());