Skip to content

Commit c4275f2

Browse files
author
Mich
committed
Code refactoring, button label's corrections
1 parent 62814a9 commit c4275f2

18 files changed

+314
-532
lines changed

src/LICENSE renamed to LICENSE

File renamed without changes.

src/QtSerialMonitor.pro

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ DEFINES += QT_DEPRECATED_WARNINGS
3030
CONFIG += c++11
3131

3232
SOURCES += \
33-
dataratechart.cpp \
3433
filereader.cpp \
3534
logger.cpp \
3635
main.cpp \
@@ -43,7 +42,6 @@ SOURCES += \
4342
HEADERS += \
4443
../../../../../../Downloads/QCustomPlot.tar/qcustomplot/qcustomplot.h \
4544
config.h \
46-
dataratechart.h \
4745
filereader.h \
4846
logger.h \
4947
mainwindow.h \

src/advancedgraphmenu.cpp

Lines changed: 0 additions & 92 deletions
This file was deleted.

src/dataratechart.cpp

Lines changed: 0 additions & 92 deletions
This file was deleted.

src/dataratechart.h

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/filereader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ FileReader::FileReader(QObject *parent) : QObject(parent)
77

88
void FileReader::readLineSendLine()
99
{
10-
int progressPercent = lineReadIterator * 100 / readFileSplitLines.count() ;
10+
int progressPercent = lineReadIterator * 100 / readFileSplitLines.count();
1111
emit lineReady(&readFileSplitLines[lineReadIterator], &progressPercent);
1212
lineReadIterator++;
1313

@@ -21,7 +21,7 @@ void FileReader::readLineSendLine()
2121
}
2222

2323
bool FileReader::startRead(QFile *fileToRead)
24-
{
24+
{
2525
if (fileToRead->open(QIODevice::ReadOnly))
2626
{
2727
QTextStream stream(fileToRead);

src/filereader.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
#ifndef FILEREADER_H
22
#define FILEREADER_H
33

4-
#include <QObject>
5-
#include <QTimer>
64
#include <QFile>
5+
#include <QObject>
76
#include <QTextStream>
7+
#include <QTimer>
88

99
class FileReader : public QObject
1010
{
1111
Q_OBJECT
1212
public:
1313
explicit FileReader(QObject *parent = nullptr);
14+
bool readAllAtOnce(QFile *fileToRead);
1415
bool startRead(QFile *fileToRead);
15-
void setReadInterval(int newVal);
1616
void abortRead();
17-
bool readAllAtOnce(QFile *fileToRead);
17+
void setReadInterval(int newVal);
1818
signals:
19-
void lineReady(QString*, int*);
2019
void fileReadFinished();
21-
void textReady(QString*);
20+
void lineReady(QString *, int *);
21+
void textReady(QString *);
2222
public slots:
23-
2423
private slots:
2524
void readLineSendLine();
25+
2626
private:
27-
QTimer fileReadTimer;
27+
int lineReadIterator = 0;
2828
int readInterval = 1; // ms
2929
QStringList readFileSplitLines;
30-
int lineReadIterator = 0;
30+
QTimer fileReadTimer;
3131
};
3232

3333
#endif // FILEREADER_H

src/logger.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
Logger::Logger(QObject *parent) : QObject(parent)
44
{
5-
65
}
76

87
void Logger::openFile(QString fileName)
@@ -36,7 +35,7 @@ bool Logger::beginLog(QString path, bool autoLogging, QString fileName)
3635
if (autoLogging)
3736
openFile(path + "/" + QDateTime::currentDateTime().toString("dd.MM.yyyy_hh.mm.ss.zzz_") + "Log.txt");
3837
else
39-
openFile(path +"/" + fileName);
38+
openFile(path + "/" + fileName);
4039

4140
return true;
4241
}
@@ -74,7 +73,7 @@ void Logger::writeLogParsedData(QStringList labelList, QList<double> dataList, b
7473
{
7574
QString text;
7675

77-
for (auto i = 0; i< labelList.count(); ++i)
76+
for (auto i = 0; i < labelList.count(); ++i)
7877
{
7978
text.append(labelList[i] + " " + QString::number(dataList[i], 'f') + " :: ");
8079
}
@@ -94,4 +93,3 @@ void Logger::writeLogParsedData(QStringList labelList, QList<double> dataList, b
9493
out << text + "\r";
9594
}
9695
}
97-

src/logger.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
#ifndef LOGGER_H
22
#define LOGGER_H
33

4-
#include <QObject>
54
#include <QDateTime>
5+
#include <QDir>
66
#include <QFile>
7-
#include <QTextStream>
7+
#include <QObject>
88
#include <QtDebug>
9-
#include <QDir>
9+
#include <QTextStream>
1010

1111
class Logger : public QObject
1212
{
1313
Q_OBJECT
1414
public:
1515
explicit Logger(QObject *parent = nullptr);
16-
17-
void openFile(QString fileName);
18-
void closeFile();
1916
bool beginLog(QString path, bool autoLogging, QString fileName);
2017
bool isOpen();
18+
void closeFile();
19+
void openFile(QString fileName);
2120
void writeLogLine(QString lineToAppend, bool simplifyText, bool appendDate);
2221
void writeLogParsedData(QStringList labelList, QList<double> dataList, bool appendDate = false);
2322
signals:
@@ -26,7 +25,6 @@ public slots:
2625

2726
private:
2827
QFile *logFile = nullptr;
29-
3028
};
3129

3230
#endif // LOGGER_H

0 commit comments

Comments
 (0)