[4823] | 1 |
|
---|
| 2 | /* -------------------------------------------------------------------------
|
---|
| 3 | * RTNet GUI
|
---|
| 4 | * -------------------------------------------------------------------------
|
---|
| 5 | *
|
---|
[5015] | 6 | * Class: t_inpEdit
|
---|
[4823] | 7 | *
|
---|
| 8 | * Purpose: RTNet Input File
|
---|
| 9 | *
|
---|
| 10 | * Author: L. Mervart
|
---|
| 11 | *
|
---|
| 12 | * Created: 05-Jan-2013
|
---|
| 13 | *
|
---|
| 14 | * Changes:
|
---|
| 15 | *
|
---|
| 16 | * -----------------------------------------------------------------------*/
|
---|
| 17 |
|
---|
[5015] | 18 | #include "inpedit.h"
|
---|
[4855] | 19 | #include "keyword.h"
|
---|
| 20 | #include "panel.h"
|
---|
[4823] | 21 |
|
---|
| 22 | using namespace std;
|
---|
[5000] | 23 | using namespace GnssCenter;
|
---|
[4823] | 24 |
|
---|
| 25 | // Constructor
|
---|
| 26 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5015] | 27 | t_inpEdit::t_inpEdit() : QTabWidget(), t_pluginInterface() {
|
---|
[4823] | 28 | }
|
---|
| 29 |
|
---|
| 30 | // Destructor
|
---|
| 31 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5015] | 32 | t_inpEdit::~t_inpEdit() {
|
---|
[4871] | 33 | QMapIterator<QString, t_keyword*> it(_keywords);
|
---|
| 34 | while (it.hasNext()) {
|
---|
| 35 | it.next();
|
---|
| 36 | delete it.value();
|
---|
[4823] | 37 | }
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | //
|
---|
| 41 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5015] | 42 | void t_inpEdit::setInputFile(const QString& fileName) {
|
---|
| 43 | _fileName = fileName;
|
---|
| 44 | readFile();
|
---|
| 45 | }
|
---|
[4823] | 46 |
|
---|
[5015] | 47 | //
|
---|
| 48 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 49 | void t_inpEdit::readFile() {
|
---|
| 50 |
|
---|
[4823] | 51 | QFile file(_fileName);
|
---|
| 52 | file.open(QIODevice::ReadOnly | QIODevice::Text);
|
---|
| 53 | QTextStream inStream(&file);
|
---|
| 54 |
|
---|
[4835] | 55 | int iPanel = 0;
|
---|
| 56 |
|
---|
[4823] | 57 | while (inStream.status() == QTextStream::Ok && !inStream.atEnd()) {
|
---|
| 58 | QString line = inStream.readLine().trimmed();
|
---|
| 59 |
|
---|
| 60 | // Skip Comments and empty Lines
|
---|
| 61 | // -----------------------------
|
---|
| 62 | if (line.isEmpty() || line[0] == '!') {
|
---|
| 63 | continue;
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | // Read Panels
|
---|
| 67 | // -----------
|
---|
| 68 | else if (line[0] == '#' && line.indexOf("BEGIN_PANEL") != -1) {
|
---|
[4872] | 69 | t_panel* panel = new t_panel(line, inStream, &_keywords);
|
---|
[4823] | 70 | if (panel->ok()) {
|
---|
[4835] | 71 | ++iPanel;
|
---|
| 72 | addTab(panel, QString("Panel %1").arg(iPanel));
|
---|
[4823] | 73 | }
|
---|
| 74 | else {
|
---|
| 75 | delete panel;
|
---|
| 76 | }
|
---|
| 77 | }
|
---|
| 78 |
|
---|
[4855] | 79 | // Read Keywords
|
---|
| 80 | // -------------
|
---|
[4823] | 81 | else {
|
---|
[4855] | 82 | t_keyword* keyword = new t_keyword(line, inStream);
|
---|
| 83 | if (keyword->ok()) {
|
---|
[4871] | 84 | _keywords[keyword->name()] = keyword;
|
---|
[4823] | 85 | }
|
---|
| 86 | else {
|
---|
[4855] | 87 | delete keyword;
|
---|
[4823] | 88 | }
|
---|
| 89 | }
|
---|
| 90 | }
|
---|
| 91 | }
|
---|