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 |
|
---|
22 | using namespace std;
|
---|
23 | using namespace GnssCenter;
|
---|
24 |
|
---|
25 | Q_EXPORT_PLUGIN2(gnsscenter_inpedit, GnssCenter::t_inpEdit)
|
---|
26 |
|
---|
27 | // Constructor
|
---|
28 | ////////////////////////////////////////////////////////////////////////////
|
---|
29 | t_inpEdit::t_inpEdit() : QTabWidget(), t_pluginInterface() {
|
---|
30 | }
|
---|
31 |
|
---|
32 | // Destructor
|
---|
33 | ////////////////////////////////////////////////////////////////////////////
|
---|
34 | t_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 | ////////////////////////////////////////////////////////////////////////////
|
---|
44 | void t_inpEdit::setInputFile(const QString& fileName) {
|
---|
45 | _fileName = fileName;
|
---|
46 | readFile();
|
---|
47 | }
|
---|
48 |
|
---|
49 | //
|
---|
50 | ////////////////////////////////////////////////////////////////////////////
|
---|
51 | void t_inpEdit::readFile() {
|
---|
52 |
|
---|
53 | QFile file(_fileName);
|
---|
54 | file.open(QIODevice::ReadOnly | QIODevice::Text);
|
---|
55 | QTextStream inStream(&file);
|
---|
56 |
|
---|
57 | int iPanel = 0;
|
---|
58 |
|
---|
59 | while (inStream.status() == QTextStream::Ok && !inStream.atEnd()) {
|
---|
60 | QString line = inStream.readLine().trimmed();
|
---|
61 |
|
---|
62 | // Skip Comments and empty Lines
|
---|
63 | // -----------------------------
|
---|
64 | if (line.isEmpty() || line[0] == '!') {
|
---|
65 | continue;
|
---|
66 | }
|
---|
67 |
|
---|
68 | // Read Panels
|
---|
69 | // -----------
|
---|
70 | else if (line[0] == '#' && line.indexOf("BEGIN_PANEL") != -1) {
|
---|
71 | t_panel* panel = new t_panel(line, inStream, &_keywords);
|
---|
72 | if (panel->ok()) {
|
---|
73 | ++iPanel;
|
---|
74 | addTab(panel, QString("Panel %1").arg(iPanel));
|
---|
75 | }
|
---|
76 | else {
|
---|
77 | delete panel;
|
---|
78 | }
|
---|
79 | }
|
---|
80 |
|
---|
81 | // Read Keywords
|
---|
82 | // -------------
|
---|
83 | else {
|
---|
84 | t_keyword* keyword = new t_keyword(line, inStream);
|
---|
85 | if (keyword->ok()) {
|
---|
86 | _keywords[keyword->name()] = keyword;
|
---|
87 | }
|
---|
88 | else {
|
---|
89 | delete keyword;
|
---|
90 | }
|
---|
91 | }
|
---|
92 | }
|
---|
93 | }
|
---|