Skip to content

Commit

Permalink
Feature/logfile UI (#389)
Browse files Browse the repository at this point in the history
* Support directory navigation in filesystem browser

* Directories are shown in list and can be opened
* Up button navigates up
* Open CSV button moved into filesystem tab

* Add display of opened log

To make room for the filename and make the UI less busy

* Browse renamed to Source
* Export buttons moved to export page
* RtPage moved under Source

* Better layout for Export tab
  • Loading branch information
cortex authored Nov 1, 2024
1 parent 9ee74f5 commit 85f5a58
Show file tree
Hide file tree
Showing 3 changed files with 336 additions and 186 deletions.
42 changes: 35 additions & 7 deletions pages/pageloganalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ void PageLogAnalysis::loadVescLog(QVector<LOG_DATA> log)
mVesc->emitMessageDialog("Load Log", "No data", false);
return;
}

ui->currentLog->setText("Realtime");
storeSelection();

resetInds();
Expand Down Expand Up @@ -682,7 +682,7 @@ void PageLogAnalysis::on_openCsvButton_clicked()

QFile inFile(fileName);
if (inFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
openLog(inFile.readAll());
openLog("Local: " + fileName, inFile.readAll());
}
}
}
Expand Down Expand Up @@ -1181,6 +1181,14 @@ void PageLogAnalysis::logListRefresh()
QString dirPath = set.value("pageloganalysis/lastdir").toString();
QDir dir(dirPath);
if (dir.exists()) {
for (QFileInfo d: dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot , QDir::Name)) {
QTableWidgetItem *itName = new QTableWidgetItem(d.fileName());
itName->setData(Qt::UserRole, d.absoluteFilePath());
ui->logTable->setRowCount(ui->logTable->rowCount() + 1);
ui->logTable->setItem(ui->logTable->rowCount() - 1, 0, itName);
ui->logTable->setItem(ui->logTable->rowCount() - 1, 1,
new QTableWidgetItem("Folder"));
}
for (QFileInfo f: dir.entryInfoList(QStringList() << "*.csv" << "*.Csv" << "*.CSV",
QDir::Files, QDir::Name)) {
QTableWidgetItem *itName = new QTableWidgetItem(f.fileName());
Expand All @@ -1197,6 +1205,18 @@ void PageLogAnalysis::logListRefresh()
}
}

void PageLogAnalysis::on_logListUpButton_clicked()
{
QSettings set;
if (set.contains("pageloganalysis/lastdir")) {
QString dirPath = set.value("pageloganalysis/lastdir").toString();
QDir dir(dirPath);
dir.cdUp();
set.setValue("pageloganalysis/lastdir", dir.absolutePath());
logListRefresh();
}
}

void PageLogAnalysis::addDataItem(QString name, bool hasScale, double scaleStep, double scaleMax)
{
ui->dataTable->setRowCount(ui->dataTable->rowCount() + 1);
Expand Down Expand Up @@ -1236,10 +1256,11 @@ void PageLogAnalysis::addDataItem(QString name, bool hasScale, double scaleStep,
}
}

void PageLogAnalysis::openLog(QByteArray data)
void PageLogAnalysis::openLog(QString name, QByteArray data)
{
storeSelection();

// get label for current open file
ui->currentLog->setText(name);
QTextStream in(&data);
auto tokensLine1 = in.readLine().split(";");
if (tokensLine1.size() < 1) {
Expand Down Expand Up @@ -1601,11 +1622,18 @@ void PageLogAnalysis::on_logListOpenButton_clicked()
if (items.size() > 0) {
QString fileName = items.
first()->data(Qt::UserRole).toString();

if (QDir(fileName).exists()) {
QSettings set;
set.setValue("pageloganalysis/lastdir", fileName);
logListRefresh();
return;
}

QFile inFile(fileName);
if (inFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
openLog(inFile.readAll());
}
openLog("Local: " + fileName, inFile.readAll());
}
} else {
mVesc->emitMessageDialog("Open Log", "No Log Selected", false);
}
Expand Down Expand Up @@ -1696,7 +1724,7 @@ void PageLogAnalysis::on_vescLogListOpenButton_clicked()
auto data = mVesc->commands()->fileBlockRead(mVescLastPath + "/" + fe.name);
setFileButtonsEnabled(true);
if (!data.isEmpty()) {
openLog(data);
openLog("Device: " + fe.name, data);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion pages/pageloganalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ private slots:
void on_centerButton_clicked();
void on_logListOpenButton_clicked();
void on_logListRefreshButton_clicked();
void on_logListUpButton_clicked();
void on_logTable_cellDoubleClicked(int row, int column);
void on_vescLogListRefreshButton_clicked();
void on_vescLogListOpenButton_clicked();
Expand Down Expand Up @@ -176,7 +177,7 @@ private slots:
void logListRefresh();
void addDataItem(QString name, bool hasScale = true,
double scaleStep = 0.1, double scaleMax = 99.99);
void openLog(QByteArray data);
void openLog(QString name, QByteArray data);
void generateMissingEntries();

void storeSelection();
Expand Down
Loading

0 comments on commit 85f5a58

Please sign in to comment.