source: ntrip/trunk/GnssCenter/inpedit/tabwidget.cpp@ 5088

Last change on this file since 5088 was 5087, checked in by mervart, 11 years ago
File size: 2.3 KB
Line 
1
2/* -------------------------------------------------------------------------
3 * RTNet GUI
4 * -------------------------------------------------------------------------
5 *
6 * Class: t_tabWidget
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 "tabwidget.h"
19#include "keyword.h"
20#include "panel.h"
21
22using namespace std;
23using namespace GnssCenter;
24
25// Constructor
26////////////////////////////////////////////////////////////////////////////
27t_tabWidget::t_tabWidget() : QTabWidget() {
28}
29
30// Destructor
31////////////////////////////////////////////////////////////////////////////
32t_tabWidget::~t_tabWidget() {
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_tabWidget::setVisible(bool visible) {
43 if (visible) {
44 setInputFile("RTNET.INP");
45 }
46 QTabWidget::setVisible(visible);
47}
48
49//
50////////////////////////////////////////////////////////////////////////////
51void t_tabWidget::setInputFile(const QString& fileName) {
52 _fileName = fileName;
53 readFile();
54}
55
56//
57////////////////////////////////////////////////////////////////////////////
58void t_tabWidget::readFile() {
59
60 QFile file(_fileName);
61 file.open(QIODevice::ReadOnly | QIODevice::Text);
62 QTextStream inStream(&file);
63
64 int iPanel = 0;
65
66 while (inStream.status() == QTextStream::Ok && !inStream.atEnd()) {
67 QString line = inStream.readLine().trimmed();
68
69 // Skip Comments and empty Lines
70 // -----------------------------
71 if (line.isEmpty() || line[0] == '!') {
72 continue;
73 }
74
75 // Read Panels
76 // -----------
77 else if (line[0] == '#' && line.indexOf("BEGIN_PANEL") != -1) {
78 t_panel* panel = new t_panel(line, inStream, &_keywords);
79 if (panel->ok()) {
80 ++iPanel;
81 addTab(panel, QString("Panel %1").arg(iPanel));
82 }
83 else {
84 delete panel;
85 }
86 }
87
88 // Read Keywords
89 // -------------
90 else {
91 t_keyword* keyword = new t_keyword(line, inStream);
92 if (keyword->ok()) {
93 _keywords[keyword->name()] = keyword;
94 }
95 else {
96 delete keyword;
97 }
98 }
99 }
100}
Note: See TracBrowser for help on using the repository browser.