[5087] | 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 |
|
---|
[5097] | 18 | #include <iostream>
|
---|
[5087] | 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::setInputFile(const QString& fileName) {
|
---|
| 44 | _fileName = fileName;
|
---|
| 45 | readFile();
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | //
|
---|
| 49 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 50 | void t_tabWidget::readFile() {
|
---|
| 51 |
|
---|
[5097] | 52 | _staticLines.clear();
|
---|
| 53 |
|
---|
[5087] | 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] == '!') {
|
---|
[5097] | 66 | _staticLines << line;
|
---|
[5087] | 67 | continue;
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | // Read Panels
|
---|
| 71 | // -----------
|
---|
| 72 | else if (line[0] == '#' && line.indexOf("BEGIN_PANEL") != -1) {
|
---|
[5097] | 73 | t_panel* panel = new t_panel(line, inStream, &_keywords, _staticLines);
|
---|
[5087] | 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 {
|
---|
[5097] | 86 | t_keyword* keyword = new t_keyword(line, inStream, _staticLines);
|
---|
[5087] | 87 | if (keyword->ok()) {
|
---|
| 88 | _keywords[keyword->name()] = keyword;
|
---|
| 89 | }
|
---|
| 90 | else {
|
---|
| 91 | delete keyword;
|
---|
| 92 | }
|
---|
| 93 | }
|
---|
| 94 | }
|
---|
[5097] | 95 |
|
---|
| 96 | //// beg test
|
---|
| 97 | for (int ii = 0; ii < _staticLines.size(); ii++) {
|
---|
| 98 | cout << _staticLines[ii].toAscii().data() << endl;
|
---|
| 99 | }
|
---|
| 100 | //// end test
|
---|
[5087] | 101 | }
|
---|