Added ability to change time format string for when you're in System

Clock mode. Fixed code so that editing settings in the settings dialog
will now immediately take effect in the program.
This commit is contained in:
Collin Kidder
2017-07-12 20:02:20 -04:00
parent 2764c9bc52
commit 2d01f695e2
7 changed files with 37 additions and 4 deletions
+9 -1
View File
@@ -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);
+2
View File
@@ -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;
+4
View File
@@ -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();
}
+3
View File
@@ -16,6 +16,9 @@ public:
explicit MainSettingsDialog(QWidget *parent = 0);
~MainSettingsDialog();
signals:
void updatedSettings();
private slots:
void updateSettings();
+3 -1
View File
@@ -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();
}
+1 -1
View File
@@ -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();
};
+15 -1
View File
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>400</width>
<height>687</height>
<height>691</height>
</rect>
</property>
<property name="windowTitle">
@@ -92,6 +92,20 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Time Format String:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineClockFormat"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>