Skip to content

Commit a98a596

Browse files
author
Mich
committed
Added truncate mode to logger
1 parent 525a538 commit a98a596

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

src/logger.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ Logger::Logger(QObject *parent) : QObject(parent)
44
{
55
}
66

7-
void Logger::openFile(QString fileName)
7+
void Logger::openFile(QString fileName, bool truncateFile)
88
{
99
if (!fileName.isEmpty())
1010
{
1111
logFile = new QFile;
1212
logFile->setFileName(fileName);
13-
logFile->open(QIODevice::OpenModeFlag::ReadWrite | QIODevice::Text);
13+
14+
if (truncateFile)
15+
logFile->open(QIODevice::OpenModeFlag::ReadWrite | QIODevice::OpenModeFlag::Truncate | QIODevice::Text);
16+
else
17+
logFile->open(QIODevice::OpenModeFlag::ReadWrite | QIODevice::Text);
1418
}
1519
}
1620

@@ -137,7 +141,7 @@ void Logger::writeLogCSV(QStringList labelList, QList<double> dataList, bool app
137141

138142
for (auto i = 0; i < csvLabelsBuffer.count(); ++i)
139143
{
140-
out.atEnd();
144+
out.atEnd(); // ???
141145

142146
int index = labelList.indexOf(csvLabelsBuffer[i]);
143147
if (index >= 0 && index < dataList.count())

src/logger.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Logger : public QObject
1616
bool beginLog(QString path, bool autoLogging, QString fileName);
1717
bool isOpen();
1818
void closeFile();
19-
void openFile(QString fileName);
19+
void openFile(QString fileName, bool truncateFile = false);
2020
void writeLogLine(QString lineToAppend, bool simplifyText, bool appendDate);
2121
void writeLogParsedData(QStringList labelList, QList<double> dataList, bool appendDate = false);
2222
void writeLogCSV(QStringList labelList, QList<double> dataList, bool appendDate);

src/mainwindow.ui

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@
12001200
<item row="1" column="0">
12011201
<widget class="QLabel" name="label_22">
12021202
<property name="text">
1203-
<string>Mode:</string>
1203+
<string>Log mode:</string>
12041204
</property>
12051205
</widget>
12061206
</item>
@@ -1209,24 +1209,34 @@
12091209
<property name="enabled">
12101210
<bool>true</bool>
12111211
</property>
1212-
<property name="minimumSize">
1213-
<size>
1214-
<width>0</width>
1215-
<height>30</height>
1216-
</size>
1212+
<property name="sizePolicy">
1213+
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
1214+
<horstretch>0</horstretch>
1215+
<verstretch>0</verstretch>
1216+
</sizepolicy>
12171217
</property>
12181218
<property name="sizeAdjustPolicy">
12191219
<enum>QComboBox::AdjustToContents</enum>
12201220
</property>
1221+
<item>
1222+
<property name="text">
1223+
<string>Text</string>
1224+
</property>
1225+
</item>
1226+
<item>
1227+
<property name="text">
1228+
<string>Parsed data</string>
1229+
</property>
1230+
</item>
12211231
</widget>
12221232
</item>
12231233
<item row="0" column="1">
12241234
<widget class="QComboBox" name="comboBoxLogFormat">
1225-
<property name="minimumSize">
1226-
<size>
1227-
<width>0</width>
1228-
<height>30</height>
1229-
</size>
1235+
<property name="sizePolicy">
1236+
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
1237+
<horstretch>0</horstretch>
1238+
<verstretch>0</verstretch>
1239+
</sizepolicy>
12301240
</property>
12311241
<property name="sizeAdjustPolicy">
12321242
<enum>QComboBox::AdjustToContents</enum>
@@ -2627,7 +2637,7 @@ p, li { white-space: pre-wrap; }
26272637
<x>0</x>
26282638
<y>0</y>
26292639
<width>1801</width>
2630-
<height>27</height>
2640+
<height>22</height>
26312641
</rect>
26322642
</property>
26332643
<widget class="QMenu" name="menuFile">

0 commit comments

Comments
 (0)