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:
+9
-1
@@ -69,6 +69,7 @@ CANFrameModel::CANFrameModel(QObject *parent)
|
|||||||
timeOffset = 0;
|
timeOffset = 0;
|
||||||
needFilterRefresh = false;
|
needFilterRefresh = false;
|
||||||
lastUpdateNumFrames = 0;
|
lastUpdateNumFrames = 0;
|
||||||
|
timeFormat = "MMM-dd HH:mm:ss.zzz";
|
||||||
}
|
}
|
||||||
|
|
||||||
void CANFrameModel::setHexMode(bool mode)
|
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()
|
void CANFrameModel::normalizeTiming()
|
||||||
{
|
{
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
@@ -252,7 +260,7 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
|||||||
if (!timeSeconds) return QString::number(thisFrame.timestamp);
|
if (!timeSeconds) return QString::number(thisFrame.timestamp);
|
||||||
else return QString::number((double)thisFrame.timestamp / 1000000.0, 'f', 6);
|
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;
|
break;
|
||||||
case 1: //id
|
case 1: //id
|
||||||
return Utility::formatNumber(thisFrame.ID);
|
return Utility::formatNumber(thisFrame.ID);
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ public:
|
|||||||
void setFilterState(unsigned int ID, bool state);
|
void setFilterState(unsigned int ID, bool state);
|
||||||
void setAllFilters(bool state);
|
void setAllFilters(bool state);
|
||||||
void setSecondsMode(bool);
|
void setSecondsMode(bool);
|
||||||
|
void setTimeFormat(QString);
|
||||||
void loadFilterFile(QString filename);
|
void loadFilterFile(QString filename);
|
||||||
void saveFilterFile(QString filename);
|
void saveFilterFile(QString filename);
|
||||||
void normalizeTiming();
|
void normalizeTiming();
|
||||||
@@ -62,6 +63,7 @@ private:
|
|||||||
QMutex mutex;
|
QMutex mutex;
|
||||||
bool interpretFrames; //should we use the dbcHandler?
|
bool interpretFrames; //should we use the dbcHandler?
|
||||||
bool overwriteDups; //should we display all frames or only the newest for each ID?
|
bool overwriteDups; //should we display all frames or only the newest for each ID?
|
||||||
|
QString timeFormat;
|
||||||
bool useHexMode;
|
bool useHexMode;
|
||||||
bool timeSeconds;
|
bool timeSeconds;
|
||||||
bool useSystemTime;
|
bool useSystemTime;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
|
|||||||
ui->cbRestorePositions->setChecked(settings->value("Main/SaveRestorePositions", true).toBool());
|
ui->cbRestorePositions->setChecked(settings->value("Main/SaveRestorePositions", true).toBool());
|
||||||
ui->cbValidate->setChecked(settings->value("Main/ValidateComm", true).toBool());
|
ui->cbValidate->setChecked(settings->value("Main/ValidateComm", true).toBool());
|
||||||
ui->spinPlaybackSpeed->setValue(settings->value("Playback/DefSpeed", 5).toInt());
|
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 secondsMode = settings->value("Main/TimeSeconds", false).toBool();
|
||||||
bool clockMode = settings->value("Main/TimeClock", 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->rbSysClock, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
|
||||||
connect(ui->comboSendingBus, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSettings()));
|
connect(ui->comboSendingBus, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSettings()));
|
||||||
connect(ui->cbUseFiltered, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
|
connect(ui->cbUseFiltered, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
|
||||||
|
connect(ui->lineClockFormat, SIGNAL(editingFinished()), this, SLOT(updateSettings()));
|
||||||
}
|
}
|
||||||
|
|
||||||
MainSettingsDialog::~MainSettingsDialog()
|
MainSettingsDialog::~MainSettingsDialog()
|
||||||
@@ -98,6 +100,8 @@ void MainSettingsDialog::updateSettings()
|
|||||||
settings->setValue("Main/TimeClock", ui->rbSysClock->isChecked());
|
settings->setValue("Main/TimeClock", ui->rbSysClock->isChecked());
|
||||||
settings->setValue("Playback/SendingBus", ui->comboSendingBus->currentIndex());
|
settings->setValue("Playback/SendingBus", ui->comboSendingBus->currentIndex());
|
||||||
settings->setValue("Main/UseFiltered", ui->cbUseFiltered->isChecked());
|
settings->setValue("Main/UseFiltered", ui->cbUseFiltered->isChecked());
|
||||||
|
settings->setValue("Main/TimeFormat", ui->lineClockFormat->text());
|
||||||
|
|
||||||
settings->sync();
|
settings->sync();
|
||||||
|
emit updatedSettings();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ public:
|
|||||||
explicit MainSettingsDialog(QWidget *parent = 0);
|
explicit MainSettingsDialog(QWidget *parent = 0);
|
||||||
~MainSettingsDialog();
|
~MainSettingsDialog();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void updatedSettings();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateSettings();
|
void updateSettings();
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -270,6 +270,8 @@ void MainWindow::readUpdateableSettings()
|
|||||||
useSystemClock = settings.value("Main/TimeClock", false).toBool();
|
useSystemClock = settings.value("Main/TimeClock", false).toBool();
|
||||||
model->setSysTimeMode(useSystemClock);
|
model->setSysTimeMode(useSystemClock);
|
||||||
useFiltered = settings.value("Main/UseFiltered", false).toBool();
|
useFiltered = settings.value("Main/UseFiltered", false).toBool();
|
||||||
|
model->setTimeFormat(settings.value("Main/TimeFormat", "MMM-dd HH:mm:ss.zzz").toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::writeSettings()
|
void MainWindow::writeSettings()
|
||||||
@@ -673,7 +675,7 @@ void MainWindow::showSettingsDialog()
|
|||||||
if (!settingsDialog)
|
if (!settingsDialog)
|
||||||
{
|
{
|
||||||
settingsDialog = new MainSettingsDialog();
|
settingsDialog = new MainSettingsDialog();
|
||||||
connect(settingsDialog, SIGNAL(finished(int)), this, SLOT(updateSettings()));
|
connect (settingsDialog, SIGNAL(updatedSettings()), this, SLOT(readUpdateableSettings()));
|
||||||
}
|
}
|
||||||
settingsDialog->show();
|
settingsDialog->show();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -97,6 +97,7 @@ private slots:
|
|||||||
public slots:
|
public slots:
|
||||||
void gotFrames(int);
|
void gotFrames(int);
|
||||||
void updateSettings();
|
void updateSettings();
|
||||||
|
void readUpdateableSettings();
|
||||||
void gotCenterTimeID(int32_t ID, double timestamp);
|
void gotCenterTimeID(int32_t ID, double timestamp);
|
||||||
void updateConnectionSettings(QString connectionType, QString port, int speed0, int speed1);
|
void updateConnectionSettings(QString connectionType, QString port, int speed0, int speed1);
|
||||||
|
|
||||||
@@ -168,7 +169,6 @@ private:
|
|||||||
void killEmAll();
|
void killEmAll();
|
||||||
void killWindow(QDialog *win);
|
void killWindow(QDialog *win);
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void readUpdateableSettings();
|
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>400</width>
|
||||||
<height>687</height>
|
<height>691</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -92,6 +92,20 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user