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