Make timestamp formatting use QVariant for better sorting by timestamp.

This commit is contained in:
Collin Kidder
2019-02-17 14:43:13 -05:00
parent b92b909fc4
commit f6269dd5f4
3 changed files with 15 additions and 6 deletions
+6 -1
View File
@@ -179,6 +179,7 @@ void ISOTP_InterpreterWindow::updatedFrames(int numFrames)
void ISOTP_InterpreterWindow::headerClicked(int logicalIndex) void ISOTP_InterpreterWindow::headerClicked(int logicalIndex)
{ {
ui->tableIsoFrames->setSortingEnabled(false);
ui->tableIsoFrames->sortByColumn(logicalIndex); ui->tableIsoFrames->sortByColumn(logicalIndex);
} }
@@ -261,9 +262,13 @@ void ISOTP_InterpreterWindow::newISOMessage(ISOTP_MESSAGE msg)
messages.append(msg); messages.append(msg);
rowNum = ui->tableIsoFrames->rowCount(); rowNum = ui->tableIsoFrames->rowCount();
ui->tableIsoFrames->insertRow(rowNum); ui->tableIsoFrames->insertRow(rowNum);
ui->tableIsoFrames->setItem(rowNum, 0, new QTableWidgetItem(Utility::formatTimestamp(msg.timestamp))); QTableWidgetItem *item = new QTableWidgetItem;
item->setData(Qt::EditRole, Utility::formatTimestamp(msg.timestamp));
//ui->tableIsoFrames->setItem(rowNum, 0, (double)msg.timestamp, Utility::formatTimestamp(msg.timestamp)));
ui->tableIsoFrames->setItem(rowNum, 0, item);
ui->tableIsoFrames->setItem(rowNum, 1, new QTableWidgetItem(QString::number(msg.ID, 16))); ui->tableIsoFrames->setItem(rowNum, 1, new QTableWidgetItem(QString::number(msg.ID, 16)));
ui->tableIsoFrames->setItem(rowNum, 2, new QTableWidgetItem(QString::number(msg.bus))); ui->tableIsoFrames->setItem(rowNum, 2, new QTableWidgetItem(QString::number(msg.bus)));
if (msg.isReceived) ui->tableIsoFrames->setItem(rowNum, 3, new QTableWidgetItem("Rx")); if (msg.isReceived) ui->tableIsoFrames->setItem(rowNum, 3, new QTableWidgetItem("Rx"));
+5 -1
View File
@@ -89,7 +89,11 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QListWidget" name="listFilter"/> <widget class="QListWidget" name="listFilter">
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
+4 -4
View File
@@ -128,13 +128,13 @@ public:
return output; return output;
} }
static QString formatTimestamp(uint64_t timestamp) static QVariant formatTimestamp(uint64_t timestamp)
{ {
if (!sysTimeMode) { if (!sysTimeMode) {
if (!secondsMode) return QString::number(timestamp); if (!secondsMode) return (unsigned long long)(timestamp);
else return QString::number((double)timestamp / 1000000.0, 'f', 6); else return (double)timestamp / 1000000.0;
} }
else return QDateTime::fromMSecsSinceEpoch(timestamp / 1000).toString(timeFormat); else return QDateTime::fromMSecsSinceEpoch(timestamp / 1000);
} }
//parses the input string to grab as much of it as possible while staying alpha numeric //parses the input string to grab as much of it as possible while staying alpha numeric