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