# HG changeset patch # User Heiko Schlittermann (JUMPER) # Date 1327246280 -3600 # Node ID e1abdc4804853155a4f204e41f57f8ce41b32159 # Parent d9d5b83c15347b766589a86b4192c5cbc682bf6c simple parsing of the igc file added diff -r d9d5b83c1534 -r e1abdc480485 igc.cc --- /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; + } + } +} diff -r d9d5b83c1534 -r e1abdc480485 igc.h --- /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 diff -r d9d5b83c1534 -r e1abdc480485 igc.pro --- 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 diff -r d9d5b83c1534 -r e1abdc480485 mainwindow.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); + } diff -r d9d5b83c1534 -r e1abdc480485 mainwindow.h --- 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