source: ntrip/trunk/GnssCenter/src/inpedit/inpedit.cpp@ 5017

Last change on this file since 5017 was 5017, checked in by mervart, 9 years ago
File size: 2.2 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
[5017]25Q_EXPORT_PLUGIN2(GnssCenter_inpEdit, GnssCenter::t_inpEdit)
26
[4823]27// Constructor
28////////////////////////////////////////////////////////////////////////////
[5015]29t_inpEdit::t_inpEdit() : QTabWidget(), t_pluginInterface() {
[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////////////////////////////////////////////////////////////////////////////
[5015]44void t_inpEdit::setInputFile(const QString& fileName) {
45 _fileName = fileName;
46 readFile();
47}
[4823]48
[5015]49//
50////////////////////////////////////////////////////////////////////////////
51void t_inpEdit::readFile() {
52
[4823]53 QFile file(_fileName);
54 file.open(QIODevice::ReadOnly | QIODevice::Text);
55 QTextStream inStream(&file);
56
[4835]57 int iPanel = 0;
58
[4823]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) {
[4872]71 t_panel* panel = new t_panel(line, inStream, &_keywords);
[4823]72 if (panel->ok()) {
[4835]73 ++iPanel;
74 addTab(panel, QString("Panel %1").arg(iPanel));
[4823]75 }
76 else {
77 delete panel;
78 }
79 }
80
[4855]81 // Read Keywords
82 // -------------
[4823]83 else {
[4855]84 t_keyword* keyword = new t_keyword(line, inStream);
85 if (keyword->ok()) {
[4871]86 _keywords[keyword->name()] = keyword;
[4823]87 }
88 else {
[4855]89 delete keyword;
[4823]90 }
91 }
92 }
93}
Note: See TracBrowser for help on using the repository browser.