source: ntrip/trunk/GnssCenter/inpedit/inpedit.cpp@ 5060

Last change on this file since 5060 was 5060, checked in by mervart, 11 years ago
File size: 2.4 KB
RevLine 
[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
22using namespace std;
[5000]23using namespace GnssCenter;
[4823]24
[5051]25Q_EXPORT_PLUGIN2(gnsscenter_inpedit, GnssCenter::t_inpEditFactory)
[5017]26
[4823]27// Constructor
28////////////////////////////////////////////////////////////////////////////
[5059]29t_inpEdit::t_inpEdit() : QTabWidget() {
[4823]30}
31
32// Destructor
33////////////////////////////////////////////////////////////////////////////
[5015]34t_inpEdit::~t_inpEdit() {
[4871]35 QMapIterator<QString, t_keyword*> it(_keywords);
36 while (it.hasNext()) {
37 it.next();
38 delete it.value();
[4823]39 }
40}
41
42//
43////////////////////////////////////////////////////////////////////////////
[5060]44void t_inpEdit::setVisible(bool visible) {
45 if (visible) {
46 setInputFile("RTNET.INP");
47 }
48 QTabWidget::setVisible(visible);
49}
50
51//
52////////////////////////////////////////////////////////////////////////////
[5015]53void t_inpEdit::setInputFile(const QString& fileName) {
54 _fileName = fileName;
55 readFile();
56}
[4823]57
[5015]58//
59////////////////////////////////////////////////////////////////////////////
60void t_inpEdit::readFile() {
61
[4823]62 QFile file(_fileName);
63 file.open(QIODevice::ReadOnly | QIODevice::Text);
64 QTextStream inStream(&file);
65
[4835]66 int iPanel = 0;
67
[4823]68 while (inStream.status() == QTextStream::Ok && !inStream.atEnd()) {
69 QString line = inStream.readLine().trimmed();
70
71 // Skip Comments and empty Lines
72 // -----------------------------
73 if (line.isEmpty() || line[0] == '!') {
74 continue;
75 }
76
77 // Read Panels
78 // -----------
79 else if (line[0] == '#' && line.indexOf("BEGIN_PANEL") != -1) {
[4872]80 t_panel* panel = new t_panel(line, inStream, &_keywords);
[4823]81 if (panel->ok()) {
[4835]82 ++iPanel;
83 addTab(panel, QString("Panel %1").arg(iPanel));
[4823]84 }
85 else {
86 delete panel;
87 }
88 }
89
[4855]90 // Read Keywords
91 // -------------
[4823]92 else {
[4855]93 t_keyword* keyword = new t_keyword(line, inStream);
94 if (keyword->ok()) {
[4871]95 _keywords[keyword->name()] = keyword;
[4823]96 }
97 else {
[4855]98 delete keyword;
[4823]99 }
100 }
101 }
102}
Note: See TracBrowser for help on using the repository browser.