28 #include <QStringList>
30 #include <QFileDialog>
32 #include <QMessageBox>
33 #include <QWriteLocker>
36 #include <QKeySequence>
41 KmlExportPlugin::KmlExportPlugin() {}
46 bool KmlExportPlugin::initialize(
const QStringList &args, QString *errMsg)
56 exportToKmlCmd = am->
registerAction(
new QAction(
this),
"KmlExport.ExportToKML",
58 exportToKmlCmd->
action()->setText(
"Export logfile to KML");
60 ac->
menu()->addSeparator();
62 ac->
addAction(exportToKmlCmd,
"KML Export");
64 connect(exportToKmlCmd->
action(), SIGNAL(triggered(
bool)),
this, SLOT(exportToKML()));
73 void KmlExportPlugin::exportToKML()
77 QString inputFileName = QFileDialog::getOpenFileName(
79 tr(
"dRonin Log Files (*.drlog *.tll)"));
81 if (inputFileName.isEmpty())
85 QString filters = tr(
"Keyhole Markup Language (compressed) (*.kmz);; Keyhole Markup Language "
86 "(uncompressed) (*.kml)");
87 bool proceed_flag =
false;
88 QString outputFileName;
89 QString localizedOutputFileName;
92 while (proceed_flag ==
false) {
93 outputFileName = QFileDialog::getSaveFileName(
95 inputFileName.split(
".", QString::SkipEmptyParts).at(0), filters);
97 if (outputFileName.isEmpty()) {
98 qDebug() <<
"No KML file name given.";
100 }
else if (QFileInfo(outputFileName).suffix() == NULL) {
101 qDebug() <<
"No KML file extension: " << outputFileName;
102 QMessageBox::critical(
new QWidget(),
"No file extension",
103 "Filename must have .kml or .kmz extension.");
104 }
else if (QFileInfo(outputFileName).suffix().toLower() !=
"kml"
105 && QFileInfo(outputFileName).suffix().toLower() !=
"kmz") {
106 qDebug() <<
"Incorrect KML file extension: " << QFileInfo(outputFileName).suffix();
107 QMessageBox::critical(
new QWidget(),
"Incorrect file extension",
108 "Filename must have .kml or .kmz extension.");
109 }
else if (outputFileName.toLocal8Bit() == (QByteArray)NULL) {
110 qDebug() <<
"Unsupported characters in path: " << outputFileName;
111 QMessageBox::critical(
new QWidget(),
"Unsupported characters",
112 "Not all uni-code characters are supported. Please choose a path "
113 "and file name that uses only the standard latin alphabet.");
119 localizedOutputFileName = outputFileName.toLocal8Bit();
124 KmlExport kmlExport(inputFileName, localizedOutputFileName);
125 kmlExport.exportToKML();
130 void KmlExportPlugin::shutdown()
virtual void extensionsInitialized()=0
virtual QAction * action() const =0
virtual Command * registerAction(QAction *action, const QString &id, const QList< int > &context)=0
Makes an action known to the system under the specified string id.
const char *const M_TOOLS
virtual ActionContainer * actionContainer(const QString &id) const =0
Returns the IActionContainter object that is know to the system under the given string id...
virtual ActionManager * actionManager() const =0
Returns the application's action manager.
virtual QMenu * menu() const =0
static ICore * instance()
virtual void appendGroup(const QString &group)=0
virtual void addAction(Core::Command *action, const QString &group=QString())=0
The action manager is responsible for registration of menus and menu items and keyboard shortcuts...