|
|
|
@ -14,7 +14,9 @@
@@ -14,7 +14,9 @@
|
|
|
|
|
#include "AppSettings.h" |
|
|
|
|
#include "JsonHelper.h" |
|
|
|
|
#include "MissionManager.h" |
|
|
|
|
#include "KML.h" |
|
|
|
|
|
|
|
|
|
#include <QDomDocument> |
|
|
|
|
#include <QJsonDocument> |
|
|
|
|
#include <QFileInfo> |
|
|
|
|
|
|
|
|
@ -372,6 +374,30 @@ void PlanMasterController::saveToFile(const QString& filename)
@@ -372,6 +374,30 @@ void PlanMasterController::saveToFile(const QString& filename)
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PlanMasterController::saveToKml(const QString& filename) |
|
|
|
|
{ |
|
|
|
|
if (filename.isEmpty()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString kmlFilename = filename; |
|
|
|
|
if (!QFileInfo(filename).fileName().contains(".")) { |
|
|
|
|
kmlFilename += QString(".%1").arg(kmlFileExtension()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QFile file(kmlFilename); |
|
|
|
|
|
|
|
|
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { |
|
|
|
|
qgcApp()->showMessage(tr("KML save error %1 : %2").arg(filename).arg(file.errorString())); |
|
|
|
|
} else { |
|
|
|
|
QDomDocument domDocument; |
|
|
|
|
_missionController.convertToKMLDocument(domDocument); |
|
|
|
|
QTextStream stream(&file); |
|
|
|
|
stream << domDocument.toString(); |
|
|
|
|
file.close(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PlanMasterController::removeAll(void) |
|
|
|
|
{ |
|
|
|
|
_missionController.removeAll(); |
|
|
|
@ -417,6 +443,11 @@ QString PlanMasterController::fileExtension(void) const
@@ -417,6 +443,11 @@ QString PlanMasterController::fileExtension(void) const
|
|
|
|
|
return AppSettings::planFileExtension; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString PlanMasterController::kmlFileExtension(void) const |
|
|
|
|
{ |
|
|
|
|
return AppSettings::kmlFileExtension; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QStringList PlanMasterController::loadNameFilters(void) const |
|
|
|
|
{ |
|
|
|
|
QStringList filters; |
|
|
|
@ -435,6 +466,14 @@ QStringList PlanMasterController::saveNameFilters(void) const
@@ -435,6 +466,14 @@ QStringList PlanMasterController::saveNameFilters(void) const
|
|
|
|
|
return filters; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QStringList PlanMasterController::saveKmlFilters(void) const |
|
|
|
|
{ |
|
|
|
|
QStringList filters; |
|
|
|
|
|
|
|
|
|
filters << tr("KML Files (*.%1)").arg(kmlFileExtension()) << tr("All Files (*.*)"); |
|
|
|
|
return filters; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PlanMasterController::sendPlanToVehicle(Vehicle* vehicle, const QString& filename) |
|
|
|
|
{ |
|
|
|
|
// Use a transient PlanMasterController to accomplish this
|
|
|
|
|