mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-06 21:54:15 +01:00
OP-1244 Added basic support for multiple export format.
This commit is contained in:
parent
14f2894464
commit
905e6a8eda
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QXmlStreamWriter>
|
||||||
|
|
||||||
#include "debuglogcontrol.h"
|
#include "debuglogcontrol.h"
|
||||||
#include "uavobjecthelper.h"
|
#include "uavobjecthelper.h"
|
||||||
@ -193,21 +194,12 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve)
|
|||||||
setDisableControls(false);
|
setDisableControls(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlightLogManager::exportLogs()
|
void FlightLogManager::exportToOPL(QString fileName)
|
||||||
{
|
{
|
||||||
if (m_logEntries.isEmpty()) {
|
// Fix the file name
|
||||||
return;
|
fileName.replace(QString(".opl"), QString("%1.opl"));
|
||||||
}
|
|
||||||
|
|
||||||
setDisableControls(true);
|
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
|
||||||
|
|
||||||
QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save Log"),
|
|
||||||
tr("OP-%0.opl").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss")),
|
|
||||||
tr("OpenPilot Log (*.opl)"));
|
|
||||||
if (!fileName.isEmpty()) {
|
|
||||||
// Loop and create a new file for each flight.
|
// Loop and create a new file for each flight.
|
||||||
fileName = fileName.replace(QString(".opl"), QString("%1.opl"));
|
|
||||||
int currentEntry = 0;
|
int currentEntry = 0;
|
||||||
int currentFlight = 0;
|
int currentFlight = 0;
|
||||||
quint32 adjustedBaseTime = 0;
|
quint32 adjustedBaseTime = 0;
|
||||||
@ -246,6 +238,51 @@ void FlightLogManager::exportLogs()
|
|||||||
|
|
||||||
logFile.close();
|
logFile.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlightLogManager::exportToCSV(QString fileName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlightLogManager::exportToXML(QString fileName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlightLogManager::exportLogs()
|
||||||
|
{
|
||||||
|
if (m_logEntries.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setDisableControls(true);
|
||||||
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
|
||||||
|
QString oplFilter = tr("OpenPilot Log file %1").arg("(*.opl)");
|
||||||
|
QString csvFilter = tr("Text file %1").arg("(*.csv)");
|
||||||
|
QString xmlFilter = tr("XML file %1").arg("(*.xml)");
|
||||||
|
|
||||||
|
QString selectedFilter = csvFilter;
|
||||||
|
|
||||||
|
QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save Log Entries"),
|
||||||
|
QString("OP-%1").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss")),
|
||||||
|
QString("%1;;%2;;%3").arg(oplFilter, csvFilter, xmlFilter), &selectedFilter);
|
||||||
|
if (!fileName.isEmpty()) {
|
||||||
|
if (selectedFilter == oplFilter) {
|
||||||
|
if (!fileName.endsWith(".opl")) {
|
||||||
|
fileName.append(".opl");
|
||||||
|
}
|
||||||
|
exportToOPL(fileName);
|
||||||
|
} else if (selectedFilter == csvFilter) {
|
||||||
|
if (!fileName.endsWith(".csv")) {
|
||||||
|
fileName.append(".csv");
|
||||||
|
}
|
||||||
|
exportToCSV(fileName);
|
||||||
|
} else if (selectedFilter == xmlFilter) {
|
||||||
|
if (!fileName.endsWith(".xml")) {
|
||||||
|
fileName.append(".xml");
|
||||||
|
}
|
||||||
|
exportToXML(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
|
@ -157,6 +157,11 @@ private:
|
|||||||
bool m_disableExport;
|
bool m_disableExport;
|
||||||
bool m_cancelDownload;
|
bool m_cancelDownload;
|
||||||
bool m_adjustExportedTimestamps;
|
bool m_adjustExportedTimestamps;
|
||||||
|
|
||||||
|
void exportToOPL(QString fileName);
|
||||||
|
void exportToCSV(QString fileName);
|
||||||
|
void exportToXML(QString fileName);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FLIGHTLOGMANAGER_H
|
#endif // FLIGHTLOGMANAGER_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user