Commit 53751dfe authored by dogmaphobic's avatar dogmaphobic

Adding some TODO items

Fixing braces
Changing data plot save files to csv only
Fixing LinechartWidget::startLogging() as it no longer needs to worry about a proper file name being set.
parent 18c2e01a
...@@ -157,6 +157,7 @@ void QGCDataPlot2D::savePlot() ...@@ -157,6 +157,7 @@ void QGCDataPlot2D::savePlot()
} else if (fileName.endsWith(".svg")) { } else if (fileName.endsWith(".svg")) {
exportSVG(fileName); exportSVG(fileName);
} }
// TODO Tell the user the name (type) was invalid (neither pdf nor svg) and nothing is being done.
} }
...@@ -272,7 +273,7 @@ void QGCDataPlot2D::selectFile() ...@@ -272,7 +273,7 @@ void QGCDataPlot2D::selectFile()
} }
else else
{ {
fileName = QGCFileDialog::getOpenFileName(this, tr("Load Log File"), QString(), "Log files (*.csv *.txt *.log)"); fileName = QGCFileDialog::getOpenFileName(this, tr("Load Log File"), QString(), "Log files (*.csv);;All Files (*)");
} }
// Check if the user hit cancel, which results in an empty string. // Check if the user hit cancel, which results in an empty string.
...@@ -698,11 +699,13 @@ void QGCDataPlot2D::saveCsvLog() ...@@ -698,11 +699,13 @@ void QGCDataPlot2D::saveCsvLog()
{ {
QString fileName = QGCFileDialog::getSaveFileName( QString fileName = QGCFileDialog::getSaveFileName(
this, "Save CSV Log File", QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), this, "Save CSV Log File", QStandardPaths::writableLocation(QStandardPaths::DesktopLocation),
"CSV file (*.csv);;Text file (*.txt)", "CSV file (*.csv)",
"csv"); "csv",
true);
if (fileName.isEmpty()) if (fileName.isEmpty()) {
return; //User cancelled return; //User cancelled
}
bool success = logFile->copy(fileName); bool success = logFile->copy(fileName);
......
...@@ -431,49 +431,29 @@ void LinechartWidget::refresh() ...@@ -431,49 +431,29 @@ void LinechartWidget::refresh()
setUpdatesEnabled(true); setUpdatesEnabled(true);
} }
QString LinechartWidget::getLogSaveFilename()
{
QString fileName = QGCFileDialog::getSaveFileName(this,
tr("Save Log File"),
QStandardPaths::writableLocation(QStandardPaths::DesktopLocation),
tr("Log file (*.log)"),
"log",
true);
return fileName;
}
void LinechartWidget::startLogging() void LinechartWidget::startLogging()
{ {
// Store reference to file
bool abort = false;
// Check if any curve is enabled // Check if any curve is enabled
if (!activePlot->anyCurveVisible()) { if (!activePlot->anyCurveVisible()) {
QGCMessageBox::critical(tr("No curves selected for logging."), tr("Please check all curves you want to log. Currently no data would be logged, aborting the logging.")); QGCMessageBox::critical(
tr("No curves selected for logging."),
tr("Please check all curves you want to log. Currently no data would be logged. Aborting the logging."));
return; return;
} }
// Let user select the log file name // Let user select the log file name
// QDate date(QDate::currentDate()); // QDate date(QDate::currentDate());
// QString("./pixhawk-log-" + date.toString("yyyy-MM-dd") + "-" + QString::number(logindex) + ".log") // QString("./pixhawk-log-" + date.toString("yyyy-MM-dd") + "-" + QString::number(logindex) + ".log")
QString fileName = getLogSaveFilename(); QString fileName = QGCFileDialog::getSaveFileName(this,
tr("Save Log File"),
while (!(fileName.endsWith(".log")) && !abort && fileName != "") { QStandardPaths::writableLocation(QStandardPaths::DesktopLocation),
QMessageBox::StandardButton button = QGCMessageBox::critical(tr("Unsuitable file extension for logfile"), tr("Log file (*.log)"),
tr("Please choose .log as file extension. Click OK to change the file extension, cancel to not start logging."), "log", // Default type
QMessageBox::Ok | QMessageBox::Cancel, true); // Enforce default type
QMessageBox::Ok);
if (button != QMessageBox::Ok) {
abort = true;
break;
}
fileName = getLogSaveFilename();
}
qDebug() << "SAVE FILE " << fileName; qDebug() << "SAVE FILE " << fileName;
// Check if the user did not abort the file save dialog if (!fileName.isEmpty()) {
if (!abort && fileName != "") {
logFile = new QFile(fileName); logFile = new QFile(fileName);
if (logFile->open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text)) { if (logFile->open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text)) {
logging = true; logging = true;
...@@ -498,10 +478,11 @@ void LinechartWidget::stopLogging() ...@@ -498,10 +478,11 @@ void LinechartWidget::stopLogging()
compressor = new LogCompressor(logFile->fileName(), logFile->fileName()); compressor = new LogCompressor(logFile->fileName(), logFile->fileName());
connect(compressor, SIGNAL(finishedFile(QString)), this, SIGNAL(logfileWritten(QString))); connect(compressor, SIGNAL(finishedFile(QString)), this, SIGNAL(logfileWritten(QString)));
QMessageBox::StandardButton button = QGCMessageBox::question(tr("Starting Log Compression"), QMessageBox::StandardButton button = QGCMessageBox::question(
tr("Should empty fields (e.g. due to packet drops) be filled with the previous value of the same variable (zero order hold)?"), tr("Starting Log Compression"),
QMessageBox::Yes | QMessageBox::No, tr("Should empty fields (e.g. due to packet drops) be filled with the previous value of the same variable (zero order hold)?"),
QMessageBox::No); QMessageBox::Yes | QMessageBox::No,
QMessageBox::No);
bool fill; bool fill;
if (button == QMessageBox::Yes) if (button == QMessageBox::Yes)
{ {
......
...@@ -123,7 +123,6 @@ protected: ...@@ -123,7 +123,6 @@ protected:
QToolButton* createButton(QWidget* parent); QToolButton* createButton(QWidget* parent);
void createCurveItem(QString curve); void createCurveItem(QString curve);
void createLayout(); void createLayout();
QString getLogSaveFilename();
/** @brief Get the name for a curve key */ /** @brief Get the name for a curve key */
QString getCurveName(const QString& key, bool shortEnabled); QString getCurveName(const QString& key, bool shortEnabled);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment