[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 |
|
---|
| 18 | #include "tabwidget.h"
|
---|
| 19 | #include "keyword.h"
|
---|
| 20 | #include "panel.h"
|
---|
| 21 |
|
---|
| 22 | using namespace std;
|
---|
| 23 | using namespace GnssCenter;
|
---|
| 24 |
|
---|
| 25 | // Constructor
|
---|
| 26 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 27 | t_tabWidget::t_tabWidget() : QTabWidget() {
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | // Destructor
|
---|
| 31 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 32 | t_tabWidget::~t_tabWidget() {
|
---|
| 33 | QMapIterator<QString, t_keyword*> it(_keywords);
|
---|
| 34 | while (it.hasNext()) {
|
---|
| 35 | it.next();
|
---|
| 36 | delete it.value();
|
---|
| 37 | }
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | //
|
---|
| 41 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 42 | void t_tabWidget::setInputFile(const QString& fileName) {
|
---|
| 43 | _fileName = fileName;
|
---|
| 44 | readFile();
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | //
|
---|
| 48 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 49 | void t_tabWidget::readFile() {
|
---|
| 50 |
|
---|
| 51 | QFile file(_fileName);
|
---|
| 52 | file.open(QIODevice::ReadOnly | QIODevice::Text);
|
---|
| 53 | QTextStream inStream(&file);
|
---|
| 54 |
|
---|
| 55 | int iPanel = 0;
|
---|
| 56 |
|
---|
| 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) {
|
---|
| 69 | t_panel* panel = new t_panel(line, inStream, &_keywords);
|
---|
| 70 | if (panel->ok()) {
|
---|
| 71 | ++iPanel;
|
---|
| 72 | addTab(panel, QString("Panel %1").arg(iPanel));
|
---|
| 73 | }
|
---|
| 74 | else {
|
---|
| 75 | delete panel;
|
---|
| 76 | }
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | // Read Keywords
|
---|
| 80 | // -------------
|
---|
| 81 | else {
|
---|
| 82 | t_keyword* keyword = new t_keyword(line, inStream);
|
---|
| 83 | if (keyword->ok()) {
|
---|
| 84 | _keywords[keyword->name()] = keyword;
|
---|
| 85 | }
|
---|
| 86 | else {
|
---|
| 87 | delete keyword;
|
---|
| 88 | }
|
---|
| 89 | }
|
---|
| 90 | }
|
---|
| 91 | }
|
---|