summaryrefslogtreecommitdiffstats
path: root/smtk-import/smtk_standalone.cpp
diff options
context:
space:
mode:
authorGravatar Salvador Cuñat <salvador.cunat@gmail.com>2015-11-08 18:50:05 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-11-12 07:39:14 -0800
commitddc77845142c19097b5c8094d7601f78719d3e53 (patch)
treec144f5bd37c0cff89c498257f341ceac41907a3a /smtk-import/smtk_standalone.cpp
parentdc4d8f26ece3d11b0931e486c7190813afbfb6f3 (diff)
downloadsubsurface-ddc77845142c19097b5c8094d7601f78719d3e53.tar.gz
SmartTrak import - CLI parser and GUI files
The tool can be called from CLI with or without arguments, if called with a single argument (this is, no destination file specified) an usage message will be displayed on the terminal; if called with arguments, these should be the .slg file(s) to be imported and a single .xml file to store the resulting Subsurface formatted data; if called without arguments a GUI will display to select the file(s) to import and to store. WARNING, if destination file exists, its previous content will be erased. The GUI is pretty simple and don't think any more is needed but, as this is my first QT thing, I expect those with much better knowledge of QT/C++ will improve it as needed. Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'smtk-import/smtk_standalone.cpp')
-rw-r--r--smtk-import/smtk_standalone.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/smtk-import/smtk_standalone.cpp b/smtk-import/smtk_standalone.cpp
new file mode 100644
index 000000000..54d5b6a99
--- /dev/null
+++ b/smtk-import/smtk_standalone.cpp
@@ -0,0 +1,49 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include "dive.h"
+#include "smrtk2ssrfc_window.h"
+#include <QApplication>
+#include <QDebug>
+
+extern "C" void smartrak_import(const char *file, struct dive_table *table);
+
+/*
+ * Simple command line interface to call directly smartrak_import() or launch
+ * the GUI if called without arguments.
+ */
+
+int main(int argc, char *argv[])
+{
+ char *infile, *outfile;
+ int i;
+ QApplication a(argc, argv);
+ Smrtk2ssrfcWindow w;
+
+ switch (argc) {
+ case 1:
+ w.show();
+ return a.exec();
+ break;
+ case 2:
+ qDebug() << "\nUsage:\n";
+ qDebug() << "Smrtk2ssrfc importer can be used without arguments (in a graphical UI)";
+ qDebug() << "or with, at least, two arguments (in a CLI, the file to be imported and";
+ qDebug() << "the file to store the Subsurface formatted dives), so you have to use one";
+ qDebug() << "of these examples:\n";
+ qDebug() << "$smrtk2ssrfc";
+ qDebug() << "or";
+ qDebug() << "$smrtk2ssrfc /input/file.slg[ file_2[ file_n]] /output/file.xml\n\n";
+ break;
+ default:
+ outfile = argv[argc - 1];
+ qDebug() << "\n[Importing]\n";
+ for(i = 1; i < argc -1; i++) {
+ infile = argv[i];
+ qDebug() << "\t" << infile << "\n";
+ smartrak_import(infile, &dive_table);
+ }
+ qDebug() << "\n[Writing]\n\t" << outfile << "\n";
+ save_dives_logic(outfile, false);
+ break;
+ }
+}