[280] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
| 2 | // converting GNSS data streams from NTRIP broadcasters,
|
---|
| 3 | // written by Leos Mervart.
|
---|
| 4 | //
|
---|
| 5 | // Copyright (C) 2006
|
---|
| 6 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 7 | // http://www.bkg.bund.de
|
---|
| 8 | // Czech Technical University Prague, Department of Advanced Geodesy
|
---|
| 9 | // http://www.fsv.cvut.cz
|
---|
| 10 | //
|
---|
| 11 | // Email: euref-ip@bkg.bund.de
|
---|
| 12 | //
|
---|
| 13 | // This program is free software; you can redistribute it and/or
|
---|
| 14 | // modify it under the terms of the GNU General Public License
|
---|
| 15 | // as published by the Free Software Foundation, version 2.
|
---|
| 16 | //
|
---|
| 17 | // This program is distributed in the hope that it will be useful,
|
---|
| 18 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 20 | // GNU General Public License for more details.
|
---|
| 21 | //
|
---|
| 22 | // You should have received a copy of the GNU General Public License
|
---|
| 23 | // along with this program; if not, write to the Free Software
|
---|
| 24 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
[35] | 25 |
|
---|
| 26 | /* -------------------------------------------------------------------------
|
---|
[93] | 27 | * BKG NTRIP Client
|
---|
[35] | 28 | * -------------------------------------------------------------------------
|
---|
| 29 | *
|
---|
| 30 | * Class: bncWindow
|
---|
| 31 | *
|
---|
| 32 | * Purpose: This class implements the main application window.
|
---|
| 33 | *
|
---|
| 34 | * Author: L. Mervart
|
---|
| 35 | *
|
---|
| 36 | * Created: 24-Dec-2005
|
---|
| 37 | *
|
---|
| 38 | * Changes:
|
---|
| 39 | *
|
---|
| 40 | * -----------------------------------------------------------------------*/
|
---|
| 41 |
|
---|
[274] | 42 | #include <unistd.h>
|
---|
[35] | 43 | #include "bncwindow.h"
|
---|
[149] | 44 | #include "bncapp.h"
|
---|
[35] | 45 | #include "bncgetthread.h"
|
---|
| 46 | #include "bnctabledlg.h"
|
---|
[177] | 47 | #include "bnchlpdlg.h"
|
---|
[168] | 48 | #include "bnchtml.h"
|
---|
[184] | 49 | #include "bnctableitem.h"
|
---|
[35] | 50 |
|
---|
| 51 | using namespace std;
|
---|
| 52 |
|
---|
| 53 | // Constructor
|
---|
| 54 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 55 | bncWindow::bncWindow() {
|
---|
| 56 |
|
---|
[91] | 57 | int ww = QFontMetrics(this->font()).width('w');
|
---|
[199] | 58 |
|
---|
| 59 | static const QStringList labels = QString("account,mountpoint,"
|
---|
| 60 | "decoder,bytes").split(",");
|
---|
[35] | 61 |
|
---|
[143] | 62 | setMinimumSize(60*ww, 80*ww);
|
---|
[237] | 63 | setWindowTitle(tr("BKG Ntrip Client (BNC), Version 1.0b"));
|
---|
[91] | 64 |
|
---|
[35] | 65 | // Create Actions
|
---|
| 66 | // --------------
|
---|
[108] | 67 | _actHelp = new QAction(tr("&Help Contents"),this);
|
---|
| 68 | connect(_actHelp, SIGNAL(triggered()), SLOT(slotHelp()));
|
---|
[35] | 69 |
|
---|
[108] | 70 | _actAbout = new QAction(tr("&About BNC"),this);
|
---|
| 71 | connect(_actAbout, SIGNAL(triggered()), SLOT(slotAbout()));
|
---|
| 72 |
|
---|
[261] | 73 | _actFontSel = new QAction(tr("Select &Font"),this);
|
---|
[110] | 74 | connect(_actFontSel, SIGNAL(triggered()), SLOT(slotFontSel()));
|
---|
| 75 |
|
---|
[35] | 76 | _actSaveOpt = new QAction(tr("&Save Options"),this);
|
---|
| 77 | connect(_actSaveOpt, SIGNAL(triggered()), SLOT(slotSaveOptions()));
|
---|
| 78 |
|
---|
| 79 | _actQuit = new QAction(tr("&Quit"),this);
|
---|
| 80 | connect(_actQuit, SIGNAL(triggered()), SLOT(close()));
|
---|
| 81 |
|
---|
[182] | 82 | _actAddMountPoints = new QAction(tr("Add &Mountpoints"),this);
|
---|
[35] | 83 | connect(_actAddMountPoints, SIGNAL(triggered()), SLOT(slotAddMountPoints()));
|
---|
| 84 |
|
---|
[105] | 85 | _actDeleteMountPoints = new QAction(tr("&Delete Mountpoints"),this);
|
---|
[35] | 86 | connect(_actDeleteMountPoints, SIGNAL(triggered()), SLOT(slotDeleteMountPoints()));
|
---|
[83] | 87 | _actDeleteMountPoints->setEnabled(false);
|
---|
[35] | 88 |
|
---|
[182] | 89 | _actGetData = new QAction(tr("Sta&rt"),this);
|
---|
[35] | 90 | connect(_actGetData, SIGNAL(triggered()), SLOT(slotGetData()));
|
---|
| 91 |
|
---|
[182] | 92 | _actStop = new QAction(tr("Sto&p"),this);
|
---|
| 93 | connect(_actStop, SIGNAL(triggered()), SLOT(slotStop()));
|
---|
| 94 | _actStop->setEnabled(false);
|
---|
| 95 |
|
---|
[35] | 96 | // Create Menus
|
---|
| 97 | // ------------
|
---|
| 98 | _menuFile = menuBar()->addMenu(tr("&File"));
|
---|
[110] | 99 | _menuFile->addAction(_actFontSel);
|
---|
| 100 | _menuFile->addSeparator();
|
---|
[35] | 101 | _menuFile->addAction(_actSaveOpt);
|
---|
| 102 | _menuFile->addSeparator();
|
---|
| 103 | _menuFile->addAction(_actQuit);
|
---|
| 104 |
|
---|
| 105 | _menuHlp = menuBar()->addMenu(tr("&Help"));
|
---|
[108] | 106 | _menuHlp->addAction(_actHelp);
|
---|
[35] | 107 | _menuHlp->addAction(_actAbout);
|
---|
| 108 |
|
---|
| 109 | // Tool (Command) Bar
|
---|
| 110 | // ------------------
|
---|
| 111 | QToolBar* toolBar = new QToolBar;
|
---|
| 112 | addToolBar(Qt::BottomToolBarArea, toolBar);
|
---|
| 113 | toolBar->setMovable(false);
|
---|
| 114 | toolBar->addAction(_actAddMountPoints);
|
---|
| 115 | toolBar->addAction(_actDeleteMountPoints);
|
---|
| 116 | toolBar->addAction(_actGetData);
|
---|
[182] | 117 | toolBar->addAction(_actStop);
|
---|
[35] | 118 |
|
---|
| 119 | // Canvas with Editable Fields
|
---|
| 120 | // ---------------------------
|
---|
| 121 | _canvas = new QWidget;
|
---|
| 122 | setCentralWidget(_canvas);
|
---|
| 123 |
|
---|
| 124 | QGridLayout* layout = new QGridLayout;
|
---|
| 125 | _canvas->setLayout(layout);
|
---|
| 126 |
|
---|
| 127 | QSettings settings;
|
---|
| 128 | _proxyHostLineEdit = new QLineEdit(settings.value("proxyHost").toString());
|
---|
[83] | 129 | _proxyHostLineEdit->setMaximumWidth(12*ww);
|
---|
[35] | 130 | _proxyPortLineEdit = new QLineEdit(settings.value("proxyPort").toString());
|
---|
[83] | 131 | _proxyPortLineEdit->setMaximumWidth(9*ww);
|
---|
[135] | 132 | _waitTimeSpinBox = new QSpinBox();
|
---|
[139] | 133 | _waitTimeSpinBox->setMinimum(1);
|
---|
[135] | 134 | _waitTimeSpinBox->setMaximum(30);
|
---|
| 135 | _waitTimeSpinBox->setSingleStep(1);
|
---|
| 136 | _waitTimeSpinBox->setSuffix(" sec");
|
---|
| 137 | _waitTimeSpinBox->setMaximumWidth(9*ww);
|
---|
| 138 | _waitTimeSpinBox->setValue(settings.value("waitTime").toInt());
|
---|
[35] | 139 | _outFileLineEdit = new QLineEdit(settings.value("outFile").toString());
|
---|
| 140 | _outPortLineEdit = new QLineEdit(settings.value("outPort").toString());
|
---|
[83] | 141 | _outPortLineEdit->setMaximumWidth(9*ww);
|
---|
| 142 | _rnxPathLineEdit = new QLineEdit(settings.value("rnxPath").toString());
|
---|
[106] | 143 | _rnxScrpLineEdit = new QLineEdit(settings.value("rnxScript").toString());
|
---|
[83] | 144 | _rnxSkelLineEdit = new QLineEdit(settings.value("rnxSkel").toString());
|
---|
| 145 | _rnxSkelLineEdit->setMaximumWidth(5*ww);
|
---|
[259] | 146 | _rnxAppendCheckBox = new QCheckBox();
|
---|
| 147 | _rnxAppendCheckBox->setCheckState(Qt::CheckState(
|
---|
| 148 | settings.value("rnxAppend").toInt()));
|
---|
[106] | 149 | _rnxIntrComboBox = new QComboBox();
|
---|
| 150 | _rnxIntrComboBox->setMaximumWidth(9*ww);
|
---|
| 151 | _rnxIntrComboBox->setEditable(false);
|
---|
[199] | 152 | _rnxIntrComboBox->addItems(QString("5 min,10 min,15 min,30 min,1 hour,1 day").split(","));
|
---|
[106] | 153 | int ii = _rnxIntrComboBox->findText(settings.value("rnxIntr").toString());
|
---|
| 154 | if (ii != -1) {
|
---|
| 155 | _rnxIntrComboBox->setCurrentIndex(ii);
|
---|
| 156 | }
|
---|
| 157 | _rnxSamplSpinBox = new QSpinBox();
|
---|
| 158 | _rnxSamplSpinBox->setMinimum(0);
|
---|
| 159 | _rnxSamplSpinBox->setMaximum(60);
|
---|
| 160 | _rnxSamplSpinBox->setSingleStep(5);
|
---|
[107] | 161 | _rnxSamplSpinBox->setMaximumWidth(9*ww);
|
---|
[106] | 162 | _rnxSamplSpinBox->setValue(settings.value("rnxSampl").toInt());
|
---|
[135] | 163 | _rnxSamplSpinBox->setSuffix(" sec");
|
---|
[143] | 164 | _logFileLineEdit = new QLineEdit(settings.value("logFile").toString());
|
---|
[184] | 165 | _mountPointsTable = new QTableWidget(0,4);
|
---|
[233] | 166 | _mountPointsTable->horizontalHeader()->resizeSection(1,25*ww);
|
---|
[199] | 167 | _mountPointsTable->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
|
---|
[203] | 168 | _mountPointsTable->horizontalHeader()->setStretchLastSection(true);
|
---|
[199] | 169 | _mountPointsTable->setHorizontalHeaderLabels(labels);
|
---|
| 170 | // _mountPointsTable->horizontalHeader()->hide();
|
---|
[239] | 171 | // _mountPointsTable->verticalHeader()->hide();
|
---|
[115] | 172 | _mountPointsTable->setGridStyle(Qt::NoPen);
|
---|
| 173 | _mountPointsTable->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
---|
[35] | 174 | _mountPointsTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
---|
| 175 | _mountPointsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
---|
| 176 | QListIterator<QString> it(settings.value("mountPoints").toStringList());
|
---|
| 177 | if (!it.hasNext()) {
|
---|
| 178 | _actGetData->setEnabled(false);
|
---|
| 179 | }
|
---|
| 180 | int iRow = 0;
|
---|
| 181 | while (it.hasNext()) {
|
---|
[59] | 182 | QStringList hlp = it.next().split(" ");
|
---|
[83] | 183 | if (hlp.size() <= 1) continue;
|
---|
[35] | 184 | _mountPointsTable->insertRow(iRow);
|
---|
[110] | 185 |
|
---|
| 186 | QUrl url(hlp[0]);
|
---|
| 187 |
|
---|
| 188 | QString fullPath = url.host() + QString(":%1").arg(url.port()) + url.path();
|
---|
| 189 | QString format(hlp[1]);
|
---|
| 190 |
|
---|
| 191 | QTableWidgetItem* it;
|
---|
| 192 | it = new QTableWidgetItem(url.userInfo());
|
---|
[115] | 193 | it->setFlags(it->flags() & ~Qt::ItemIsEditable);
|
---|
[110] | 194 | _mountPointsTable->setItem(iRow, 0, it);
|
---|
| 195 |
|
---|
| 196 | it = new QTableWidgetItem(fullPath);
|
---|
[115] | 197 | it->setFlags(it->flags() & ~Qt::ItemIsEditable);
|
---|
[110] | 198 | _mountPointsTable->setItem(iRow, 1, it);
|
---|
| 199 |
|
---|
| 200 | it = new QTableWidgetItem(format);
|
---|
| 201 | _mountPointsTable->setItem(iRow, 2, it);
|
---|
[184] | 202 |
|
---|
| 203 | bncTableItem* bncIt = new bncTableItem();
|
---|
[276] | 204 | bncIt->setFlags(bncIt->flags() & ~Qt::ItemIsEditable);
|
---|
[184] | 205 | _mountPointsTable->setItem(iRow, 3, bncIt);
|
---|
| 206 |
|
---|
[35] | 207 | iRow++;
|
---|
| 208 | }
|
---|
[111] | 209 | _mountPointsTable->hideColumn(0);
|
---|
[110] | 210 | _mountPointsTable->sortItems(1);
|
---|
[35] | 211 |
|
---|
[83] | 212 | connect(_mountPointsTable, SIGNAL(itemSelectionChanged()),
|
---|
| 213 | SLOT(slotSelectionChanged()));
|
---|
[35] | 214 |
|
---|
[83] | 215 | _log = new QTextEdit();
|
---|
| 216 | _log->setReadOnly(true);
|
---|
[35] | 217 |
|
---|
[199] | 218 | layout->addWidget(new QLabel("Proxy host"), 0, 0, 1, 2);
|
---|
| 219 | layout->addWidget(_proxyHostLineEdit, 0, 2);
|
---|
| 220 | layout->addWidget(new QLabel("Proxy port"), 0, 3);
|
---|
| 221 | layout->addWidget(_proxyPortLineEdit, 0, 4);
|
---|
[143] | 222 |
|
---|
| 223 | layout->addWidget(new QLabel("Wait for full epoch"), 1, 0, 1, 2);
|
---|
[135] | 224 | layout->addWidget(_waitTimeSpinBox, 1, 2);
|
---|
[143] | 225 |
|
---|
| 226 | layout->addWidget(new QLabel("ASCII output file (full path)"), 2, 0, 1, 2);
|
---|
[106] | 227 | layout->addWidget(_outFileLineEdit, 2, 2, 1, 3);
|
---|
[143] | 228 |
|
---|
| 229 | layout->addWidget(new QLabel("Port for binary output"), 3, 0, 1, 2);
|
---|
[106] | 230 | layout->addWidget(_outPortLineEdit, 3, 2);
|
---|
[143] | 231 |
|
---|
[240] | 232 | layout->addWidget(new QLabel("RINEX directory"), 4, 0, 1, 2);
|
---|
[106] | 233 | layout->addWidget(_rnxPathLineEdit, 4, 2, 1, 3);
|
---|
[143] | 234 |
|
---|
| 235 | layout->addWidget(new QLabel("RINEX script (full path)"), 5, 0, 1, 2);
|
---|
[106] | 236 | layout->addWidget(_rnxScrpLineEdit, 5, 2, 1, 3);
|
---|
[143] | 237 |
|
---|
| 238 | layout->addWidget(new QLabel("RINEX file interval"), 6, 0, 1, 2);
|
---|
[106] | 239 | layout->addWidget(_rnxIntrComboBox, 6, 2);
|
---|
[143] | 240 | layout->addWidget(new QLabel("Sampling"), 6, 3);
|
---|
[106] | 241 | layout->addWidget(_rnxSamplSpinBox, 6, 4);
|
---|
| 242 |
|
---|
[143] | 243 | layout->addWidget(new QLabel("RINEX skeleton extension"), 7, 0, 1, 2);
|
---|
[106] | 244 | layout->addWidget(_rnxSkelLineEdit, 7, 2);
|
---|
| 245 |
|
---|
[259] | 246 | layout->addWidget(new QLabel("Append files"), 7, 3);
|
---|
| 247 | layout->addWidget(_rnxAppendCheckBox, 7, 4);
|
---|
| 248 |
|
---|
[143] | 249 | layout->addWidget(new QLabel("Mountpoints"), 8, 0, 1, 2);
|
---|
| 250 | layout->addWidget(_mountPointsTable, 9, 0, 1, 5);
|
---|
| 251 |
|
---|
[240] | 252 | layout->addWidget(new QLabel("Log (full path)"), 10, 0, 1, 2);
|
---|
[143] | 253 | layout->addWidget(_logFileLineEdit, 10, 2, 1, 3);
|
---|
| 254 | layout->addWidget(_log, 11, 0, 1, 5);
|
---|
[35] | 255 | }
|
---|
| 256 |
|
---|
| 257 | // Destructor
|
---|
| 258 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 259 | bncWindow::~bncWindow() {
|
---|
| 260 | }
|
---|
| 261 |
|
---|
| 262 | // Retrieve Table
|
---|
| 263 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 264 | void bncWindow::slotAddMountPoints() {
|
---|
[101] | 265 |
|
---|
| 266 | QSettings settings;
|
---|
| 267 | QString proxyHost = settings.value("proxyHost").toString();
|
---|
| 268 | int proxyPort = settings.value("proxyPort").toInt();
|
---|
| 269 | if (proxyHost != _proxyHostLineEdit->text() ||
|
---|
| 270 | proxyPort != _proxyPortLineEdit->text().toInt()) {
|
---|
[102] | 271 | int iRet = QMessageBox::question(this, "Question", "Proxy options "
|
---|
[101] | 272 | "changed. Use the new ones?",
|
---|
| 273 | QMessageBox::Yes, QMessageBox::No,
|
---|
| 274 | QMessageBox::NoButton);
|
---|
| 275 | if (iRet == QMessageBox::Yes) {
|
---|
| 276 | settings.setValue("proxyHost", _proxyHostLineEdit->text());
|
---|
| 277 | settings.setValue("proxyPort", _proxyPortLineEdit->text());
|
---|
| 278 | }
|
---|
| 279 | }
|
---|
| 280 |
|
---|
[90] | 281 | bncTableDlg* dlg = new bncTableDlg(this);
|
---|
[83] | 282 | dlg->move(this->pos().x()+50, this->pos().y()+50);
|
---|
[35] | 283 | connect(dlg, SIGNAL(newMountPoints(QStringList*)),
|
---|
| 284 | this, SLOT(slotNewMountPoints(QStringList*)));
|
---|
| 285 | dlg->exec();
|
---|
| 286 | delete dlg;
|
---|
| 287 |
|
---|
| 288 | }
|
---|
| 289 |
|
---|
| 290 | // Delete Selected Mount Points
|
---|
| 291 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 292 | void bncWindow::slotDeleteMountPoints() {
|
---|
[117] | 293 |
|
---|
| 294 | int nRows = _mountPointsTable->rowCount();
|
---|
| 295 | bool flg[nRows];
|
---|
| 296 | for (int iRow = 0; iRow < nRows; iRow++) {
|
---|
[116] | 297 | if (_mountPointsTable->isItemSelected(_mountPointsTable->item(iRow,1))) {
|
---|
[117] | 298 | flg[iRow] = true;
|
---|
| 299 | }
|
---|
| 300 | else {
|
---|
| 301 | flg[iRow] = false;
|
---|
| 302 | }
|
---|
| 303 | }
|
---|
| 304 | for (int iRow = nRows-1; iRow >= 0; iRow--) {
|
---|
| 305 | if (flg[iRow]) {
|
---|
[116] | 306 | _mountPointsTable->removeRow(iRow);
|
---|
[83] | 307 | }
|
---|
| 308 | }
|
---|
| 309 | _actDeleteMountPoints->setEnabled(false);
|
---|
[183] | 310 |
|
---|
| 311 | if (_mountPointsTable->rowCount() == 0) {
|
---|
| 312 | _actGetData->setEnabled(false);
|
---|
| 313 | }
|
---|
[35] | 314 | }
|
---|
| 315 |
|
---|
| 316 | // New Mount Points Selected
|
---|
| 317 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 318 | void bncWindow::slotNewMountPoints(QStringList* mountPoints) {
|
---|
| 319 | int iRow = 0;
|
---|
| 320 | QListIterator<QString> it(*mountPoints);
|
---|
| 321 | while (it.hasNext()) {
|
---|
[59] | 322 | QStringList hlp = it.next().split(" ");
|
---|
[110] | 323 | QUrl url(hlp[0]);
|
---|
| 324 | QString fullPath = url.host() + QString(":%1").arg(url.port()) + url.path();
|
---|
| 325 | QString format(hlp[1]);
|
---|
| 326 |
|
---|
[35] | 327 | _mountPointsTable->insertRow(iRow);
|
---|
[110] | 328 |
|
---|
| 329 | QTableWidgetItem* it;
|
---|
| 330 | it = new QTableWidgetItem(url.userInfo());
|
---|
[115] | 331 | it->setFlags(it->flags() & ~Qt::ItemIsEditable);
|
---|
[110] | 332 | _mountPointsTable->setItem(iRow, 0, it);
|
---|
| 333 |
|
---|
| 334 | it = new QTableWidgetItem(fullPath);
|
---|
[115] | 335 | it->setFlags(it->flags() & ~Qt::ItemIsEditable);
|
---|
[110] | 336 | _mountPointsTable->setItem(iRow, 1, it);
|
---|
| 337 |
|
---|
| 338 | it = new QTableWidgetItem(format);
|
---|
| 339 | _mountPointsTable->setItem(iRow, 2, it);
|
---|
[184] | 340 |
|
---|
| 341 | bncTableItem* bncIt = new bncTableItem();
|
---|
| 342 | _mountPointsTable->setItem(iRow, 3, bncIt);
|
---|
| 343 |
|
---|
[35] | 344 | iRow++;
|
---|
| 345 | }
|
---|
[111] | 346 | _mountPointsTable->hideColumn(0);
|
---|
[110] | 347 | _mountPointsTable->sortItems(1);
|
---|
[35] | 348 | if (mountPoints->count() > 0) {
|
---|
| 349 | _actGetData->setEnabled(true);
|
---|
| 350 | }
|
---|
| 351 | delete mountPoints;
|
---|
| 352 | }
|
---|
| 353 |
|
---|
| 354 | // Save Options
|
---|
| 355 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 356 | void bncWindow::slotSaveOptions() {
|
---|
| 357 | QSettings settings;
|
---|
| 358 | settings.setValue("proxyHost", _proxyHostLineEdit->text());
|
---|
| 359 | settings.setValue("proxyPort", _proxyPortLineEdit->text());
|
---|
[135] | 360 | settings.setValue("waitTime", _waitTimeSpinBox->value());
|
---|
[35] | 361 | settings.setValue("outFile", _outFileLineEdit->text());
|
---|
| 362 | settings.setValue("outPort", _outPortLineEdit->text());
|
---|
[83] | 363 | settings.setValue("rnxPath", _rnxPathLineEdit->text());
|
---|
[106] | 364 | settings.setValue("rnxScript", _rnxScrpLineEdit->text());
|
---|
| 365 | settings.setValue("rnxIntr", _rnxIntrComboBox->currentText());
|
---|
| 366 | settings.setValue("rnxSampl", _rnxSamplSpinBox->value());
|
---|
[83] | 367 | settings.setValue("rnxSkel", _rnxSkelLineEdit->text());
|
---|
[259] | 368 | settings.setValue("rnxAppend", _rnxAppendCheckBox->checkState());
|
---|
[143] | 369 | settings.setValue("logFile", _logFileLineEdit->text());
|
---|
[110] | 370 |
|
---|
[35] | 371 | QStringList mountPoints;
|
---|
[110] | 372 |
|
---|
[35] | 373 | for (int iRow = 0; iRow < _mountPointsTable->rowCount(); iRow++) {
|
---|
[112] | 374 | QUrl url( "//" + _mountPointsTable->item(iRow, 0)->text() +
|
---|
| 375 | "@" + _mountPointsTable->item(iRow, 1)->text() );
|
---|
[110] | 376 |
|
---|
| 377 | mountPoints.append(url.toString() + " " +
|
---|
| 378 | _mountPointsTable->item(iRow, 2)->text());
|
---|
[35] | 379 | }
|
---|
| 380 | settings.setValue("mountPoints", mountPoints);
|
---|
| 381 | }
|
---|
| 382 |
|
---|
| 383 | // All get slots terminated
|
---|
| 384 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 385 | void bncWindow::slotGetThreadErrors() {
|
---|
[83] | 386 | slotMessage("All Get Threads Terminated");
|
---|
[149] | 387 | ((bncApp*)qApp)->slotMessage("All Get Threads Terminated");
|
---|
[35] | 388 | _actAddMountPoints->setEnabled(true);
|
---|
| 389 | _actGetData->setEnabled(true);
|
---|
| 390 | }
|
---|
| 391 |
|
---|
| 392 | // Retrieve Data
|
---|
| 393 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 394 | void bncWindow::slotGetData() {
|
---|
[128] | 395 | slotSaveOptions();
|
---|
| 396 |
|
---|
[35] | 397 | _actAddMountPoints->setEnabled(false);
|
---|
| 398 | _actDeleteMountPoints->setEnabled(false);
|
---|
| 399 | _actGetData->setEnabled(false);
|
---|
[182] | 400 | _actStop->setEnabled(true);
|
---|
[35] | 401 |
|
---|
[243] | 402 | _global_caster = new bncCaster(_outFileLineEdit->text(),
|
---|
[35] | 403 | _outPortLineEdit->text().toInt());
|
---|
| 404 |
|
---|
[243] | 405 | connect(_global_caster, SIGNAL(getThreadErrors()),
|
---|
[35] | 406 | this, SLOT(slotGetThreadErrors()));
|
---|
| 407 |
|
---|
[243] | 408 | connect(_global_caster, SIGNAL(newMessage(const QByteArray&)),
|
---|
[83] | 409 | this, SLOT(slotMessage(const QByteArray&)));
|
---|
[243] | 410 | connect(_global_caster, SIGNAL(newMessage(const QByteArray&)),
|
---|
[149] | 411 | (bncApp*)qApp, SLOT(slotMessage(const QByteArray&)));
|
---|
[83] | 412 |
|
---|
[35] | 413 | for (int iRow = 0; iRow < _mountPointsTable->rowCount(); iRow++) {
|
---|
[112] | 414 | QUrl url( "//" + _mountPointsTable->item(iRow, 0)->text() +
|
---|
| 415 | "@" + _mountPointsTable->item(iRow, 1)->text() );
|
---|
[110] | 416 |
|
---|
[111] | 417 | QByteArray format = _mountPointsTable->item(iRow, 2)->text().toAscii();
|
---|
[35] | 418 |
|
---|
[278] | 419 | bncGetThread* getThread = new bncGetThread(url, format, iRow);
|
---|
[83] | 420 |
|
---|
| 421 | connect(getThread, SIGNAL(newMessage(const QByteArray&)),
|
---|
| 422 | this, SLOT(slotMessage(const QByteArray&)));
|
---|
[149] | 423 | connect(getThread, SIGNAL(newMessage(const QByteArray&)),
|
---|
| 424 | (bncApp*)qApp, SLOT(slotMessage(const QByteArray&)));
|
---|
[83] | 425 |
|
---|
[184] | 426 | connect(getThread, SIGNAL(newObs(const QByteArray&, Observation*)),
|
---|
| 427 | (bncTableItem*) _mountPointsTable->item(iRow, 3),
|
---|
| 428 | SLOT(slotNewObs(const QByteArray&, Observation*)));
|
---|
| 429 |
|
---|
[243] | 430 | _global_caster->addGetThread(getThread);
|
---|
[35] | 431 |
|
---|
| 432 | getThread->start();
|
---|
[285] | 433 | #ifndef WIN32
|
---|
[274] | 434 | usleep(100000); // sleep 0.1 sec
|
---|
[285] | 435 | #endif
|
---|
[35] | 436 | }
|
---|
| 437 | }
|
---|
[83] | 438 |
|
---|
[182] | 439 | // Retrieve Data
|
---|
| 440 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 441 | void bncWindow::slotStop() {
|
---|
| 442 | int iRet = QMessageBox::question(this, "Stop", "Stop retrieving data?",
|
---|
| 443 | QMessageBox::Yes, QMessageBox::No,
|
---|
| 444 | QMessageBox::NoButton);
|
---|
| 445 | if (iRet == QMessageBox::Yes) {
|
---|
[243] | 446 | delete _global_caster; _global_caster = 0;
|
---|
[182] | 447 | _actGetData->setEnabled(true);
|
---|
| 448 | _actStop->setEnabled(false);
|
---|
[183] | 449 | _actAddMountPoints->setEnabled(true);
|
---|
[182] | 450 | }
|
---|
| 451 | }
|
---|
| 452 |
|
---|
[83] | 453 | // Close Application gracefully
|
---|
| 454 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 455 | void bncWindow::closeEvent(QCloseEvent* event) {
|
---|
| 456 |
|
---|
| 457 | int iRet = QMessageBox::question(this, "Close", "Save Options?",
|
---|
| 458 | QMessageBox::Yes, QMessageBox::No,
|
---|
| 459 | QMessageBox::Cancel);
|
---|
| 460 |
|
---|
| 461 | if (iRet == QMessageBox::Cancel) {
|
---|
| 462 | event->ignore();
|
---|
| 463 | return;
|
---|
| 464 | }
|
---|
| 465 | else if (iRet == QMessageBox::Yes) {
|
---|
| 466 | slotSaveOptions();
|
---|
| 467 | }
|
---|
| 468 |
|
---|
| 469 | return QMainWindow::closeEvent(event);
|
---|
| 470 | }
|
---|
| 471 |
|
---|
| 472 | // User changed the selection of mountPoints
|
---|
| 473 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 474 | void bncWindow::slotSelectionChanged() {
|
---|
| 475 | if (_mountPointsTable->selectedItems().isEmpty()) {
|
---|
| 476 | _actDeleteMountPoints->setEnabled(false);
|
---|
| 477 | }
|
---|
| 478 | else {
|
---|
| 479 | _actDeleteMountPoints->setEnabled(true);
|
---|
| 480 | }
|
---|
| 481 | }
|
---|
| 482 |
|
---|
| 483 | // Display Program Messages
|
---|
| 484 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 485 | void bncWindow::slotMessage(const QByteArray& msg) {
|
---|
| 486 |
|
---|
| 487 | const int maxBufferSize = 10000;
|
---|
| 488 |
|
---|
[189] | 489 | QString txt = _log->toPlainText() + "\n" +
|
---|
| 490 | QTime::currentTime().toString("hh:mm:ss ") + msg;
|
---|
[83] | 491 | _log->clear();
|
---|
| 492 | _log->append(txt.right(maxBufferSize));
|
---|
| 493 | }
|
---|
| 494 |
|
---|
[108] | 495 | // About Message
|
---|
| 496 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 497 | void bncWindow::slotAbout() {
|
---|
| 498 |
|
---|
[161] | 499 | QTextBrowser* tb = new QTextBrowser;
|
---|
[169] | 500 | QUrl url; url.setPath(":bncabout.html");
|
---|
| 501 | tb->setSource(url);
|
---|
[161] | 502 | tb->setReadOnly(true);
|
---|
[142] | 503 |
|
---|
[161] | 504 | QDialog dlg(this);
|
---|
[142] | 505 |
|
---|
[164] | 506 | QGridLayout* dlgLayout = new QGridLayout();
|
---|
| 507 | QLabel* img = new QLabel();
|
---|
[173] | 508 | img->setPixmap(QPixmap(":ntrip-logo.png"));
|
---|
[164] | 509 | dlgLayout->addWidget(img, 0,0);
|
---|
[231] | 510 | dlgLayout->addWidget(new QLabel("BKG NTRIP Client (BNC), Version 1.0b"), 0,1);
|
---|
[164] | 511 | dlgLayout->addWidget(tb,1,0,1,2);
|
---|
[161] | 512 |
|
---|
| 513 | dlg.setLayout(dlgLayout);
|
---|
| 514 | int ww = QFontMetrics(font()).width('w');
|
---|
| 515 | dlg.resize(60*ww, 60*ww);
|
---|
| 516 | dlg.exec();
|
---|
[108] | 517 | }
|
---|
| 518 |
|
---|
| 519 | // Help Window
|
---|
| 520 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 521 | void bncWindow::slotHelp() {
|
---|
[177] | 522 | QUrl url;
|
---|
| 523 | url.setPath(":bnchelp.html");
|
---|
| 524 | new bncHlpDlg(this, url);
|
---|
[108] | 525 | }
|
---|
[110] | 526 |
|
---|
| 527 | // Select Fonts
|
---|
| 528 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 529 | void bncWindow::slotFontSel() {
|
---|
| 530 | bool ok;
|
---|
| 531 | QFont newFont = QFontDialog::getFont(&ok, this->font(), this);
|
---|
| 532 | if (ok) {
|
---|
[113] | 533 | QSettings settings;
|
---|
| 534 | settings.setValue("font", newFont.toString());
|
---|
[110] | 535 | QApplication::setFont(newFont);
|
---|
[113] | 536 | int ww = QFontMetrics(newFont).width('w');
|
---|
[152] | 537 | setMinimumSize(60*ww, 80*ww);
|
---|
| 538 | resize(60*ww, 80*ww);
|
---|
[110] | 539 | }
|
---|
| 540 | }
|
---|