diff --git a/canframemodel.cpp b/canframemodel.cpp
index 93aff03..959dc5b 100644
--- a/canframemodel.cpp
+++ b/canframemodel.cpp
@@ -69,6 +69,7 @@ CANFrameModel::CANFrameModel(QObject *parent)
timeOffset = 0;
needFilterRefresh = false;
lastUpdateNumFrames = 0;
+ timeFormat = "MMM-dd HH:mm:ss.zzz";
}
void CANFrameModel::setHexMode(bool mode)
@@ -114,6 +115,13 @@ void CANFrameModel::setInterpetMode(bool mode)
}
}
+void CANFrameModel::setTimeFormat(QString format)
+{
+ timeFormat = format;
+ beginResetModel(); //reset model to show new time format
+ endResetModel();
+}
+
void CANFrameModel::normalizeTiming()
{
mutex.lock();
@@ -252,7 +260,7 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
if (!timeSeconds) return QString::number(thisFrame.timestamp);
else return QString::number((double)thisFrame.timestamp / 1000000.0, 'f', 6);
}
- else return QDateTime::fromMSecsSinceEpoch(thisFrame.timestamp / 1000).toString("MMM-dd HH:mm:ss.zzz");
+ else return QDateTime::fromMSecsSinceEpoch(thisFrame.timestamp / 1000).toString(timeFormat);
break;
case 1: //id
return Utility::formatNumber(thisFrame.ID);
diff --git a/canframemodel.h b/canframemodel.h
index a934eff..42fd66b 100644
--- a/canframemodel.h
+++ b/canframemodel.h
@@ -36,6 +36,7 @@ public:
void setFilterState(unsigned int ID, bool state);
void setAllFilters(bool state);
void setSecondsMode(bool);
+ void setTimeFormat(QString);
void loadFilterFile(QString filename);
void saveFilterFile(QString filename);
void normalizeTiming();
@@ -62,6 +63,7 @@ private:
QMutex mutex;
bool interpretFrames; //should we use the dbcHandler?
bool overwriteDups; //should we display all frames or only the newest for each ID?
+ QString timeFormat;
bool useHexMode;
bool timeSeconds;
bool useSystemTime;
diff --git a/mainsettingsdialog.cpp b/mainsettingsdialog.cpp
index caa242a..7e2745b 100644
--- a/mainsettingsdialog.cpp
+++ b/mainsettingsdialog.cpp
@@ -26,6 +26,7 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
ui->cbRestorePositions->setChecked(settings->value("Main/SaveRestorePositions", true).toBool());
ui->cbValidate->setChecked(settings->value("Main/ValidateComm", true).toBool());
ui->spinPlaybackSpeed->setValue(settings->value("Playback/DefSpeed", 5).toInt());
+ ui->lineClockFormat->setText(settings->value("Main/TimeFormat", "MMM-dd HH:mm:ss.zzz").toString());
bool secondsMode = settings->value("Main/TimeSeconds", false).toBool();
bool clockMode = settings->value("Main/TimeClock", false).toBool();
@@ -69,6 +70,7 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
connect(ui->rbSysClock, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
connect(ui->comboSendingBus, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSettings()));
connect(ui->cbUseFiltered, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
+ connect(ui->lineClockFormat, SIGNAL(editingFinished()), this, SLOT(updateSettings()));
}
MainSettingsDialog::~MainSettingsDialog()
@@ -98,6 +100,8 @@ void MainSettingsDialog::updateSettings()
settings->setValue("Main/TimeClock", ui->rbSysClock->isChecked());
settings->setValue("Playback/SendingBus", ui->comboSendingBus->currentIndex());
settings->setValue("Main/UseFiltered", ui->cbUseFiltered->isChecked());
+ settings->setValue("Main/TimeFormat", ui->lineClockFormat->text());
settings->sync();
+ emit updatedSettings();
}
diff --git a/mainsettingsdialog.h b/mainsettingsdialog.h
index d350d00..62c24c9 100644
--- a/mainsettingsdialog.h
+++ b/mainsettingsdialog.h
@@ -16,6 +16,9 @@ public:
explicit MainSettingsDialog(QWidget *parent = 0);
~MainSettingsDialog();
+signals:
+ void updatedSettings();
+
private slots:
void updateSettings();
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 667c87a..ceca5fc 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -270,6 +270,8 @@ void MainWindow::readUpdateableSettings()
useSystemClock = settings.value("Main/TimeClock", false).toBool();
model->setSysTimeMode(useSystemClock);
useFiltered = settings.value("Main/UseFiltered", false).toBool();
+ model->setTimeFormat(settings.value("Main/TimeFormat", "MMM-dd HH:mm:ss.zzz").toString());
+
}
void MainWindow::writeSettings()
@@ -673,7 +675,7 @@ void MainWindow::showSettingsDialog()
if (!settingsDialog)
{
settingsDialog = new MainSettingsDialog();
- connect(settingsDialog, SIGNAL(finished(int)), this, SLOT(updateSettings()));
+ connect (settingsDialog, SIGNAL(updatedSettings()), this, SLOT(readUpdateableSettings()));
}
settingsDialog->show();
}
diff --git a/mainwindow.h b/mainwindow.h
index a75c9c6..6f79c09 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -97,6 +97,7 @@ private slots:
public slots:
void gotFrames(int);
void updateSettings();
+ void readUpdateableSettings();
void gotCenterTimeID(int32_t ID, double timestamp);
void updateConnectionSettings(QString connectionType, QString port, int speed0, int speed1);
@@ -168,7 +169,6 @@ private:
void killEmAll();
void killWindow(QDialog *win);
void readSettings();
- void readUpdateableSettings();
void writeSettings();
};
diff --git a/ui/mainsettingsdialog.ui b/ui/mainsettingsdialog.ui
index b1f38d9..6399632 100644
--- a/ui/mainsettingsdialog.ui
+++ b/ui/mainsettingsdialog.ui
@@ -7,7 +7,7 @@
0
0
400
- 687
+ 691
@@ -92,6 +92,20 @@
+ -
+
+
-
+
+
+ Time Format String:
+
+
+
+ -
+
+
+
+