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

Last change on this file since 5099 was 5099, checked in by mervart, 9 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::readInputFile(const QString& fileName) {
44
45 _fileName = fileName;
46
47 _staticLines.clear();
48
49 QFile file(_fileName);
50 file.open(QIODevice::ReadOnly | QIODevice::Text);
51 QTextStream inStream(&file);
52
53 int iPanel = 0;
54
55 while (inStream.status() == QTextStream::Ok && !inStream.atEnd()) {
56 QString line = inStream.readLine().trimmed();
57
58 // Skip Comments and empty Lines
59 // -----------------------------
60 if (line.isEmpty() || line[0] == '!') {
61 _staticLines << line;
62 continue;
63 }
64
65 // Read Panels
66 // -----------
67 else if (line[0] == '#' && line.indexOf("BEGIN_PANEL") != -1) {
68 t_panel* panel = new t_panel(line, inStream, &_keywords, _staticLines);
69 if (panel->ok()) {
70 ++iPanel;
71 addTab(panel, QString("Panel %1").arg(iPanel));
72 }
73 else {
74 delete panel;
75 }
76 }
77
78 // Read Keywords
79 // -------------
80 else {
81 t_keyword* keyword = new t_keyword(line, inStream, _staticLines);
82 if (keyword->ok()) {
83 _keywords[keyword->name()] = keyword;
84 }
85 else {
86 delete keyword;
87 }
88 }
89 }
90}
91
92//
93////////////////////////////////////////////////////////////////////////////
94void t_tabWidget::writeInputFile(const QString& fileName) {
95 for (int ii = 0; ii < _staticLines.size(); ii++) {
96 cout << _staticLines[ii].toAscii().data() << endl;
97 }
98}
Note: See TracBrowser for help on using the repository browser.