source: ntrip/trunk/GnssCenter/inpedit/inpedit.cpp@ 5060

Last change on this file since 5060 was 5060, checked in by mervart, 11 years ago
File size: 2.4 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
25Q_EXPORT_PLUGIN2(gnsscenter_inpedit, GnssCenter::t_inpEditFactory)
26
27// Constructor
28////////////////////////////////////////////////////////////////////////////
29t_inpEdit::t_inpEdit() : QTabWidget() {
30}
31
32// Destructor
33////////////////////////////////////////////////////////////////////////////
34t_inpEdit::~t_inpEdit() {
35 QMapIterator<QString, t_keyword*> it(_keywords);
36 while (it.hasNext()) {
37 it.next();
38 delete it.value();
39 }
40}
41
42//
43////////////////////////////////////////////////////////////////////////////
44void t_inpEdit::setVisible(bool visible) {
45 if (visible) {
46 setInputFile("RTNET.INP");
47 }
48 QTabWidget::setVisible(visible);
49}
50
51//
52////////////////////////////////////////////////////////////////////////////
53void t_inpEdit::setInputFile(const QString& fileName) {
54 _fileName = fileName;
55 readFile();
56}
57
58//
59////////////////////////////////////////////////////////////////////////////
60void t_inpEdit::readFile() {
61
62 QFile file(_fileName);
63 file.open(QIODevice::ReadOnly | QIODevice::Text);
64 QTextStream inStream(&file);
65
66 int iPanel = 0;
67
68 while (inStream.status() == QTextStream::Ok && !inStream.atEnd()) {
69 QString line = inStream.readLine().trimmed();
70
71 // Skip Comments and empty Lines
72 // -----------------------------
73 if (line.isEmpty() || line[0] == '!') {
74 continue;
75 }
76
77 // Read Panels
78 // -----------
79 else if (line[0] == '#' && line.indexOf("BEGIN_PANEL") != -1) {
80 t_panel* panel = new t_panel(line, inStream, &_keywords);
81 if (panel->ok()) {
82 ++iPanel;
83 addTab(panel, QString("Panel %1").arg(iPanel));
84 }
85 else {
86 delete panel;
87 }
88 }
89
90 // Read Keywords
91 // -------------
92 else {
93 t_keyword* keyword = new t_keyword(line, inStream);
94 if (keyword->ok()) {
95 _keywords[keyword->name()] = keyword;
96 }
97 else {
98 delete keyword;
99 }
100 }
101 }
102}
Note: See TracBrowser for help on using the repository browser.