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 |
|
---|
23 | using namespace std;
|
---|
24 | using namespace GnssCenter;
|
---|
25 |
|
---|
26 | // Constructor
|
---|
27 | ////////////////////////////////////////////////////////////////////////////
|
---|
28 | t_tabWidget::t_tabWidget() : QTabWidget() {
|
---|
29 | }
|
---|
30 |
|
---|
31 | // Destructor
|
---|
32 | ////////////////////////////////////////////////////////////////////////////
|
---|
33 | t_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 | ////////////////////////////////////////////////////////////////////////////
|
---|
43 | void 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 | ////////////////////////////////////////////////////////////////////////////
|
---|
94 | void t_tabWidget::writeInputFile(const QString& fileName) {
|
---|
95 | for (int ii = 0; ii < _staticLines.size(); ii++) {
|
---|
96 | cout << _staticLines[ii].toAscii().data() << endl;
|
---|
97 | }
|
---|
98 | }
|
---|