source: ntrip/trunk/GnssCenter/src/inpedit/inpfile.cpp@ 5000

Last change on this file since 5000 was 5000, checked in by mervart, 11 years ago
File size: 2.0 KB
RevLine 
[4823]1
2/* -------------------------------------------------------------------------
3 * RTNet GUI
4 * -------------------------------------------------------------------------
5 *
[4855]6 * Class: t_inpFile
[4823]7 *
8 * Purpose: RTNet Input File
9 *
10 * Author: L. Mervart
11 *
12 * Created: 05-Jan-2013
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
[4855]18#include "inpfile.h"
19#include "keyword.h"
20#include "panel.h"
[4823]21
22using namespace std;
[5000]23using namespace GnssCenter;
[4823]24
25// Constructor
26////////////////////////////////////////////////////////////////////////////
[4855]27t_inpFile::t_inpFile(const QString& fileName) : QTabWidget(0) {
[4824]28 _fileName = fileName;
[4823]29 readFile();
30}
31
32// Destructor
33////////////////////////////////////////////////////////////////////////////
[4855]34t_inpFile::~t_inpFile() {
[4871]35 QMapIterator<QString, t_keyword*> it(_keywords);
36 while (it.hasNext()) {
37 it.next();
38 delete it.value();
[4823]39 }
40}
41
42//
43////////////////////////////////////////////////////////////////////////////
[4855]44void t_inpFile::readFile() {
[4823]45
46 QFile file(_fileName);
47 file.open(QIODevice::ReadOnly | QIODevice::Text);
48 QTextStream inStream(&file);
49
[4835]50 int iPanel = 0;
51
[4823]52 while (inStream.status() == QTextStream::Ok && !inStream.atEnd()) {
53 QString line = inStream.readLine().trimmed();
54
55 // Skip Comments and empty Lines
56 // -----------------------------
57 if (line.isEmpty() || line[0] == '!') {
58 continue;
59 }
60
61 // Read Panels
62 // -----------
63 else if (line[0] == '#' && line.indexOf("BEGIN_PANEL") != -1) {
[4872]64 t_panel* panel = new t_panel(line, inStream, &_keywords);
[4823]65 if (panel->ok()) {
[4835]66 ++iPanel;
67 addTab(panel, QString("Panel %1").arg(iPanel));
[4823]68 }
69 else {
70 delete panel;
71 }
72 }
73
[4855]74 // Read Keywords
75 // -------------
[4823]76 else {
[4855]77 t_keyword* keyword = new t_keyword(line, inStream);
78 if (keyword->ok()) {
[4871]79 _keywords[keyword->name()] = keyword;
[4823]80 }
81 else {
[4855]82 delete keyword;
[4823]83 }
84 }
85 }
86}
Note: See TracBrowser for help on using the repository browser.