--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/igc.cc Sun Jan 22 16:31:20 2012 +0100
@@ -0,0 +1,22 @@
+#include "igc.h"
+
+void IGC::read(QTextStream &in)
+{
+ while (!in.atEnd()) {
+ char c;
+ in >> c;
+ switch (c) {
+ case 'A': theAuthor = in.readLine(); break;
+ case 'H': {
+ QString line = in.readLine();
+ QString key = line.section(':', 0, 0);
+ QString value = line.section(':', 1, 1).simplified();
+ qDebug() << key << "--" << value;
+ if (key == "FPLTPILOT") thePilot = value;
+ if (key == "FGTYGLIDERTYPE") theGlider = value;
+ }
+ break;
+ case 'B': points << in.readLine(); break;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/igc.h Sun Jan 22 16:31:20 2012 +0100
@@ -0,0 +1,16 @@
+#ifndef _igc_h_
+#define _igc_h_
+
+#include "pch.h"
+
+class IGC {
+ public:
+ void read(QTextStream&);
+ QString author() const { return theAuthor; }
+ QString pilot() const { return thePilot; }
+ private:
+ QString theAuthor, thePilot, theGlider;
+ QStringList points;
+
+};
+#endif
--- a/igc.pro Sun Jan 22 15:31:01 2012 +0100
+++ b/igc.pro Sun Jan 22 16:31:20 2012 +0100
@@ -15,6 +15,9 @@
# Input
PRECOMPILED_HEADER += pch.h
-HEADERS += mainwindow.h
FORMS += ui/*.ui
-SOURCES += main.cc mainwindow.cc
+
+HEADERS += mainwindow.h \
+ igc.h
+SOURCES += main.cc mainwindow.cc \
+ igc.cc
--- a/mainwindow.cc Sun Jan 22 15:31:01 2012 +0100
+++ b/mainwindow.cc Sun Jan 22 16:31:20 2012 +0100
@@ -22,6 +22,7 @@
this,
tr("Open IGC file"),
"flights", tr("IGC files (*.igc);; All files (*)"));
+ if (fileName.isEmpty()) return;
currentFile.setFileName(fileName);
@@ -32,6 +33,10 @@
return;
}
+ input.setDevice(¤tFile);
setWindowTitle(QFileInfo(fileName).baseName());
statusBar()->showMessage(tr("opening %1").arg(fileName), 5000);
+
+ igc.read(input);
+
}
--- a/mainwindow.h Sun Jan 22 15:31:01 2012 +0100
+++ b/mainwindow.h Sun Jan 22 16:31:20 2012 +0100
@@ -2,6 +2,7 @@
#define _mainwindow_h_
#include "pch.h"
+#include "igc.h"
namespace Ui { class MainWindow; }
@@ -14,8 +15,13 @@
protected slots:
void open();
private:
+
+ Ui::MainWindow *ui;
QFile currentFile;
- Ui::MainWindow *ui;
+ QTextStream input;
+
+ IGC igc;
+
};
#endif