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

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