source: ntrip/trunk/GnssCenter/src/inpedit/inpedit.cpp@ 5015

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