Reformat timestamps to look a bit nicer
This commit is contained in:
+14
-1
@@ -134,25 +134,33 @@ void CANFrameModel::setTimeFormat(QString format)
|
|||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Scan all frames for the smallest timestamp and offset all timestamps so that smallest one is at 0
|
||||||
|
*/
|
||||||
void CANFrameModel::normalizeTiming()
|
void CANFrameModel::normalizeTiming()
|
||||||
{
|
{
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
if (frames.count() == 0) return;
|
if (frames.count() == 0) return;
|
||||||
timeOffset = frames[0].timestamp;
|
timeOffset = frames[0].timestamp;
|
||||||
|
|
||||||
|
//find the absolute lowest timestamp in the whole time. Needed because maybe timestamp was reset in the middle.
|
||||||
for (int j = 0; j < frames.count(); j++)
|
for (int j = 0; j < frames.count(); j++)
|
||||||
{
|
{
|
||||||
if (frames[j].timestamp < timeOffset) timeOffset = frames[j].timestamp;
|
if (frames[j].timestamp < timeOffset) timeOffset = frames[j].timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < frames.count(); i++)
|
for (int i = 0; i < frames.count(); i++)
|
||||||
{
|
{
|
||||||
frames[i].timestamp -= timeOffset;
|
frames[i].timestamp -= timeOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->beginResetModel();
|
this->beginResetModel();
|
||||||
for (int i = 0; i < filteredFrames.count(); i++)
|
for (int i = 0; i < filteredFrames.count(); i++)
|
||||||
{
|
{
|
||||||
filteredFrames[i].timestamp -= timeOffset;
|
filteredFrames[i].timestamp -= timeOffset;
|
||||||
}
|
}
|
||||||
this->endResetModel();
|
this->endResetModel();
|
||||||
|
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,6 +236,7 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
|||||||
QString tempString;
|
QString tempString;
|
||||||
CANFrame thisFrame;
|
CANFrame thisFrame;
|
||||||
static bool rowFlip = false;
|
static bool rowFlip = false;
|
||||||
|
QVariant ts;
|
||||||
|
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@@ -274,7 +283,11 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
|||||||
switch (Column(index.column()))
|
switch (Column(index.column()))
|
||||||
{
|
{
|
||||||
case Column::TimeStamp:
|
case Column::TimeStamp:
|
||||||
return Utility::formatTimestamp(thisFrame.timestamp);
|
//Reformatting the output a bit with custom code
|
||||||
|
ts = Utility::formatTimestamp(thisFrame.timestamp);
|
||||||
|
if (ts.type() == QVariant::Double) return QString::number(ts.toDouble(), 'f', 5); //never scientific notation, 5 decimal places
|
||||||
|
if (ts.type() == QVariant::LongLong) return QString::number(ts.toLongLong()); //never scientific notion, all digits shown
|
||||||
|
if (ts.type() == QVariant::DateTime) return ts.toDateTime().toString(timeFormat); //custom set format for dates and times
|
||||||
case Column::FrameId:
|
case Column::FrameId:
|
||||||
return Utility::formatCANID(thisFrame.ID, thisFrame.extended);
|
return Utility::formatCANID(thisFrame.ID, thisFrame.extended);
|
||||||
case Column::Extended:
|
case Column::Extended:
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#include "frameviewdelegate.h"
|
||||||
|
|
||||||
|
FrameViewDelegate::FrameViewDelegate()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#ifndef FRAMEVIEWDELEGATE_H
|
||||||
|
#define FRAMEVIEWDELEGATE_H
|
||||||
|
|
||||||
|
|
||||||
|
class FrameViewDelegate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FrameViewDelegate();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FRAMEVIEWDELEGATE_H
|
||||||
Reference in New Issue
Block a user