[35] | 1 |
|
---|
| 2 | /* -------------------------------------------------------------------------
|
---|
[93] | 3 | * BKG NTRIP Client
|
---|
[35] | 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"
|
---|
[149] | 19 | #include "bncapp.h"
|
---|
[35] | 20 | #include "bncgetthread.h"
|
---|
| 21 | #include "bnctabledlg.h"
|
---|
[177] | 22 | #include "bnchlpdlg.h"
|
---|
[168] | 23 | #include "bnchtml.h"
|
---|
[184] | 24 | #include "bnctableitem.h"
|
---|
[35] | 25 |
|
---|
| 26 | using namespace std;
|
---|
| 27 |
|
---|
| 28 | // Constructor
|
---|
| 29 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 30 | bncWindow::bncWindow() {
|
---|
| 31 |
|
---|
[91] | 32 | int ww = QFontMetrics(this->font()).width('w');
|
---|
[35] | 33 |
|
---|
[143] | 34 | setMinimumSize(60*ww, 80*ww);
|
---|
[91] | 35 |
|
---|
[35] | 36 | // Create Actions
|
---|
| 37 | // --------------
|
---|
[108] | 38 | _actHelp = new QAction(tr("&Help Contents"),this);
|
---|
| 39 | connect(_actHelp, SIGNAL(triggered()), SLOT(slotHelp()));
|
---|
[35] | 40 |
|
---|
[108] | 41 | _actAbout = new QAction(tr("&About BNC"),this);
|
---|
| 42 | connect(_actAbout, SIGNAL(triggered()), SLOT(slotAbout()));
|
---|
| 43 |
|
---|
[110] | 44 | _actFontSel = new QAction(tr("Select &Fonts"),this);
|
---|
| 45 | connect(_actFontSel, SIGNAL(triggered()), SLOT(slotFontSel()));
|
---|
| 46 |
|
---|
[35] | 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 |
|
---|
[182] | 53 | _actAddMountPoints = new QAction(tr("Add &Mountpoints"),this);
|
---|
[35] | 54 | connect(_actAddMountPoints, SIGNAL(triggered()), SLOT(slotAddMountPoints()));
|
---|
| 55 |
|
---|
[105] | 56 | _actDeleteMountPoints = new QAction(tr("&Delete Mountpoints"),this);
|
---|
[35] | 57 | connect(_actDeleteMountPoints, SIGNAL(triggered()), SLOT(slotDeleteMountPoints()));
|
---|
[83] | 58 | _actDeleteMountPoints->setEnabled(false);
|
---|
[35] | 59 |
|
---|
[182] | 60 | _actGetData = new QAction(tr("Sta&rt"),this);
|
---|
[35] | 61 | connect(_actGetData, SIGNAL(triggered()), SLOT(slotGetData()));
|
---|
| 62 |
|
---|
[182] | 63 | _actStop = new QAction(tr("Sto&p"),this);
|
---|
| 64 | connect(_actStop, SIGNAL(triggered()), SLOT(slotStop()));
|
---|
| 65 | _actStop->setEnabled(false);
|
---|
| 66 |
|
---|
[35] | 67 | // Create Menus
|
---|
| 68 | // ------------
|
---|
| 69 | _menuFile = menuBar()->addMenu(tr("&File"));
|
---|
[110] | 70 | _menuFile->addAction(_actFontSel);
|
---|
| 71 | _menuFile->addSeparator();
|
---|
[35] | 72 | _menuFile->addAction(_actSaveOpt);
|
---|
| 73 | _menuFile->addSeparator();
|
---|
| 74 | _menuFile->addAction(_actQuit);
|
---|
| 75 |
|
---|
| 76 | _menuHlp = menuBar()->addMenu(tr("&Help"));
|
---|
[108] | 77 | _menuHlp->addAction(_actHelp);
|
---|
[35] | 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);
|
---|
[182] | 88 | toolBar->addAction(_actStop);
|
---|
[35] | 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());
|
---|
[83] | 100 | _proxyHostLineEdit->setMaximumWidth(12*ww);
|
---|
[35] | 101 | _proxyPortLineEdit = new QLineEdit(settings.value("proxyPort").toString());
|
---|
[83] | 102 | _proxyPortLineEdit->setMaximumWidth(9*ww);
|
---|
[135] | 103 | _waitTimeSpinBox = new QSpinBox();
|
---|
[139] | 104 | _waitTimeSpinBox->setMinimum(1);
|
---|
[135] | 105 | _waitTimeSpinBox->setMaximum(30);
|
---|
| 106 | _waitTimeSpinBox->setSingleStep(1);
|
---|
| 107 | _waitTimeSpinBox->setSuffix(" sec");
|
---|
| 108 | _waitTimeSpinBox->setMaximumWidth(9*ww);
|
---|
| 109 | _waitTimeSpinBox->setValue(settings.value("waitTime").toInt());
|
---|
[35] | 110 | _outFileLineEdit = new QLineEdit(settings.value("outFile").toString());
|
---|
| 111 | _outPortLineEdit = new QLineEdit(settings.value("outPort").toString());
|
---|
[83] | 112 | _outPortLineEdit->setMaximumWidth(9*ww);
|
---|
| 113 | _rnxPathLineEdit = new QLineEdit(settings.value("rnxPath").toString());
|
---|
[106] | 114 | _rnxScrpLineEdit = new QLineEdit(settings.value("rnxScript").toString());
|
---|
[83] | 115 | _rnxSkelLineEdit = new QLineEdit(settings.value("rnxSkel").toString());
|
---|
| 116 | _rnxSkelLineEdit->setMaximumWidth(5*ww);
|
---|
[106] | 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);
|
---|
[107] | 129 | _rnxSamplSpinBox->setMaximumWidth(9*ww);
|
---|
[106] | 130 | _rnxSamplSpinBox->setValue(settings.value("rnxSampl").toInt());
|
---|
[135] | 131 | _rnxSamplSpinBox->setSuffix(" sec");
|
---|
[143] | 132 | _logFileLineEdit = new QLineEdit(settings.value("logFile").toString());
|
---|
[184] | 133 | _mountPointsTable = new QTableWidget(0,4);
|
---|
[83] | 134 | _mountPointsTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
|
---|
[35] | 135 | _mountPointsTable->horizontalHeader()->hide();
|
---|
| 136 | _mountPointsTable->verticalHeader()->hide();
|
---|
[115] | 137 | _mountPointsTable->setGridStyle(Qt::NoPen);
|
---|
| 138 | _mountPointsTable->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
---|
[35] | 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()) {
|
---|
[59] | 147 | QStringList hlp = it.next().split(" ");
|
---|
[83] | 148 | if (hlp.size() <= 1) continue;
|
---|
[35] | 149 | _mountPointsTable->insertRow(iRow);
|
---|
[110] | 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());
|
---|
[115] | 158 | it->setFlags(it->flags() & ~Qt::ItemIsEditable);
|
---|
[110] | 159 | _mountPointsTable->setItem(iRow, 0, it);
|
---|
| 160 |
|
---|
| 161 | it = new QTableWidgetItem(fullPath);
|
---|
[115] | 162 | it->setFlags(it->flags() & ~Qt::ItemIsEditable);
|
---|
[110] | 163 | _mountPointsTable->setItem(iRow, 1, it);
|
---|
| 164 |
|
---|
| 165 | it = new QTableWidgetItem(format);
|
---|
| 166 | _mountPointsTable->setItem(iRow, 2, it);
|
---|
[184] | 167 |
|
---|
| 168 | bncTableItem* bncIt = new bncTableItem();
|
---|
| 169 | _mountPointsTable->setItem(iRow, 3, bncIt);
|
---|
| 170 |
|
---|
[35] | 171 | iRow++;
|
---|
| 172 | }
|
---|
[111] | 173 | _mountPointsTable->hideColumn(0);
|
---|
[110] | 174 | _mountPointsTable->sortItems(1);
|
---|
[35] | 175 |
|
---|
[83] | 176 | connect(_mountPointsTable, SIGNAL(itemSelectionChanged()),
|
---|
| 177 | SLOT(slotSelectionChanged()));
|
---|
[35] | 178 |
|
---|
[83] | 179 | _log = new QTextEdit();
|
---|
| 180 | _log->setReadOnly(true);
|
---|
[35] | 181 |
|
---|
[105] | 182 | layout->addWidget(new QLabel("Proxy host"), 0, 0);
|
---|
[106] | 183 | layout->addWidget(_proxyHostLineEdit, 0, 1);
|
---|
| 184 | layout->addWidget(new QLabel("Proxy port"), 0, 2);
|
---|
| 185 | layout->addWidget(_proxyPortLineEdit, 0, 3);
|
---|
[143] | 186 |
|
---|
| 187 | layout->addWidget(new QLabel("Wait for full epoch"), 1, 0, 1, 2);
|
---|
[135] | 188 | layout->addWidget(_waitTimeSpinBox, 1, 2);
|
---|
[143] | 189 |
|
---|
| 190 | layout->addWidget(new QLabel("ASCII output file (full path)"), 2, 0, 1, 2);
|
---|
[106] | 191 | layout->addWidget(_outFileLineEdit, 2, 2, 1, 3);
|
---|
[143] | 192 |
|
---|
| 193 | layout->addWidget(new QLabel("Port for binary output"), 3, 0, 1, 2);
|
---|
[106] | 194 | layout->addWidget(_outPortLineEdit, 3, 2);
|
---|
[143] | 195 |
|
---|
| 196 | layout->addWidget(new QLabel("RINEX path"), 4, 0, 1, 2);
|
---|
[106] | 197 | layout->addWidget(_rnxPathLineEdit, 4, 2, 1, 3);
|
---|
[143] | 198 |
|
---|
| 199 | layout->addWidget(new QLabel("RINEX script (full path)"), 5, 0, 1, 2);
|
---|
[106] | 200 | layout->addWidget(_rnxScrpLineEdit, 5, 2, 1, 3);
|
---|
[143] | 201 |
|
---|
| 202 | layout->addWidget(new QLabel("RINEX file interval"), 6, 0, 1, 2);
|
---|
[106] | 203 | layout->addWidget(_rnxIntrComboBox, 6, 2);
|
---|
[143] | 204 | layout->addWidget(new QLabel("Sampling"), 6, 3);
|
---|
[106] | 205 | layout->addWidget(_rnxSamplSpinBox, 6, 4);
|
---|
| 206 |
|
---|
[143] | 207 | layout->addWidget(new QLabel("RINEX skeleton extension"), 7, 0, 1, 2);
|
---|
[106] | 208 | layout->addWidget(_rnxSkelLineEdit, 7, 2);
|
---|
| 209 |
|
---|
[143] | 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 |
|
---|
[35] | 217 | _bncCaster = 0;
|
---|
| 218 | }
|
---|
| 219 |
|
---|
| 220 | // Destructor
|
---|
| 221 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 222 | bncWindow::~bncWindow() {
|
---|
| 223 | }
|
---|
| 224 |
|
---|
| 225 | // Retrieve Table
|
---|
| 226 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 227 | void bncWindow::slotAddMountPoints() {
|
---|
[101] | 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()) {
|
---|
[102] | 234 | int iRet = QMessageBox::question(this, "Question", "Proxy options "
|
---|
[101] | 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 |
|
---|
[90] | 244 | bncTableDlg* dlg = new bncTableDlg(this);
|
---|
[83] | 245 | dlg->move(this->pos().x()+50, this->pos().y()+50);
|
---|
[35] | 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() {
|
---|
[117] | 256 |
|
---|
| 257 | int nRows = _mountPointsTable->rowCount();
|
---|
| 258 | bool flg[nRows];
|
---|
| 259 | for (int iRow = 0; iRow < nRows; iRow++) {
|
---|
[116] | 260 | if (_mountPointsTable->isItemSelected(_mountPointsTable->item(iRow,1))) {
|
---|
[117] | 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]) {
|
---|
[116] | 269 | _mountPointsTable->removeRow(iRow);
|
---|
[83] | 270 | }
|
---|
| 271 | }
|
---|
| 272 | _actDeleteMountPoints->setEnabled(false);
|
---|
[183] | 273 |
|
---|
| 274 | if (_mountPointsTable->rowCount() == 0) {
|
---|
| 275 | _actGetData->setEnabled(false);
|
---|
| 276 | }
|
---|
[35] | 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()) {
|
---|
[59] | 285 | QStringList hlp = it.next().split(" ");
|
---|
[110] | 286 | QUrl url(hlp[0]);
|
---|
| 287 | QString fullPath = url.host() + QString(":%1").arg(url.port()) + url.path();
|
---|
| 288 | QString format(hlp[1]);
|
---|
| 289 |
|
---|
[35] | 290 | _mountPointsTable->insertRow(iRow);
|
---|
[110] | 291 |
|
---|
| 292 | QTableWidgetItem* it;
|
---|
| 293 | it = new QTableWidgetItem(url.userInfo());
|
---|
[115] | 294 | it->setFlags(it->flags() & ~Qt::ItemIsEditable);
|
---|
[110] | 295 | _mountPointsTable->setItem(iRow, 0, it);
|
---|
| 296 |
|
---|
| 297 | it = new QTableWidgetItem(fullPath);
|
---|
[115] | 298 | it->setFlags(it->flags() & ~Qt::ItemIsEditable);
|
---|
[110] | 299 | _mountPointsTable->setItem(iRow, 1, it);
|
---|
| 300 |
|
---|
| 301 | it = new QTableWidgetItem(format);
|
---|
| 302 | _mountPointsTable->setItem(iRow, 2, it);
|
---|
[184] | 303 |
|
---|
| 304 | bncTableItem* bncIt = new bncTableItem();
|
---|
| 305 | _mountPointsTable->setItem(iRow, 3, bncIt);
|
---|
| 306 |
|
---|
[35] | 307 | iRow++;
|
---|
| 308 | }
|
---|
[111] | 309 | _mountPointsTable->hideColumn(0);
|
---|
[110] | 310 | _mountPointsTable->sortItems(1);
|
---|
[35] | 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());
|
---|
[135] | 323 | settings.setValue("waitTime", _waitTimeSpinBox->value());
|
---|
[35] | 324 | settings.setValue("outFile", _outFileLineEdit->text());
|
---|
| 325 | settings.setValue("outPort", _outPortLineEdit->text());
|
---|
[83] | 326 | settings.setValue("rnxPath", _rnxPathLineEdit->text());
|
---|
[106] | 327 | settings.setValue("rnxScript", _rnxScrpLineEdit->text());
|
---|
| 328 | settings.setValue("rnxIntr", _rnxIntrComboBox->currentText());
|
---|
| 329 | settings.setValue("rnxSampl", _rnxSamplSpinBox->value());
|
---|
[83] | 330 | settings.setValue("rnxSkel", _rnxSkelLineEdit->text());
|
---|
[143] | 331 | settings.setValue("logFile", _logFileLineEdit->text());
|
---|
[110] | 332 |
|
---|
[35] | 333 | QStringList mountPoints;
|
---|
[110] | 334 |
|
---|
[35] | 335 | for (int iRow = 0; iRow < _mountPointsTable->rowCount(); iRow++) {
|
---|
[112] | 336 | QUrl url( "//" + _mountPointsTable->item(iRow, 0)->text() +
|
---|
| 337 | "@" + _mountPointsTable->item(iRow, 1)->text() );
|
---|
[110] | 338 |
|
---|
| 339 | mountPoints.append(url.toString() + " " +
|
---|
| 340 | _mountPointsTable->item(iRow, 2)->text());
|
---|
[35] | 341 | }
|
---|
| 342 | settings.setValue("mountPoints", mountPoints);
|
---|
| 343 | }
|
---|
| 344 |
|
---|
| 345 | // All get slots terminated
|
---|
| 346 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 347 | void bncWindow::slotGetThreadErrors() {
|
---|
[83] | 348 | slotMessage("All Get Threads Terminated");
|
---|
[149] | 349 | ((bncApp*)qApp)->slotMessage("All Get Threads Terminated");
|
---|
[35] | 350 | _actAddMountPoints->setEnabled(true);
|
---|
| 351 | _actGetData->setEnabled(true);
|
---|
| 352 | }
|
---|
| 353 |
|
---|
| 354 | // Retrieve Data
|
---|
| 355 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 356 | void bncWindow::slotGetData() {
|
---|
[128] | 357 | slotSaveOptions();
|
---|
| 358 |
|
---|
[35] | 359 | _actAddMountPoints->setEnabled(false);
|
---|
| 360 | _actDeleteMountPoints->setEnabled(false);
|
---|
| 361 | _actGetData->setEnabled(false);
|
---|
[182] | 362 | _actStop->setEnabled(true);
|
---|
[35] | 363 |
|
---|
| 364 | _bncCaster = new bncCaster(_outFileLineEdit->text(),
|
---|
| 365 | _outPortLineEdit->text().toInt());
|
---|
| 366 |
|
---|
| 367 | connect(_bncCaster, SIGNAL(getThreadErrors()),
|
---|
| 368 | this, SLOT(slotGetThreadErrors()));
|
---|
| 369 |
|
---|
[83] | 370 | connect(_bncCaster, SIGNAL(newMessage(const QByteArray&)),
|
---|
| 371 | this, SLOT(slotMessage(const QByteArray&)));
|
---|
[149] | 372 | connect(_bncCaster, SIGNAL(newMessage(const QByteArray&)),
|
---|
| 373 | (bncApp*)qApp, SLOT(slotMessage(const QByteArray&)));
|
---|
[83] | 374 |
|
---|
[35] | 375 | _bncCaster->start();
|
---|
| 376 |
|
---|
| 377 | for (int iRow = 0; iRow < _mountPointsTable->rowCount(); iRow++) {
|
---|
[112] | 378 | QUrl url( "//" + _mountPointsTable->item(iRow, 0)->text() +
|
---|
| 379 | "@" + _mountPointsTable->item(iRow, 1)->text() );
|
---|
[110] | 380 |
|
---|
[111] | 381 | QByteArray format = _mountPointsTable->item(iRow, 2)->text().toAscii();
|
---|
[35] | 382 |
|
---|
[88] | 383 | bncGetThread* getThread = new bncGetThread(url, format);
|
---|
[83] | 384 |
|
---|
| 385 | connect(getThread, SIGNAL(newMessage(const QByteArray&)),
|
---|
| 386 | this, SLOT(slotMessage(const QByteArray&)));
|
---|
[149] | 387 | connect(getThread, SIGNAL(newMessage(const QByteArray&)),
|
---|
| 388 | (bncApp*)qApp, SLOT(slotMessage(const QByteArray&)));
|
---|
[83] | 389 |
|
---|
[184] | 390 | connect(getThread, SIGNAL(newObs(const QByteArray&, Observation*)),
|
---|
| 391 | (bncTableItem*) _mountPointsTable->item(iRow, 3),
|
---|
| 392 | SLOT(slotNewObs(const QByteArray&, Observation*)));
|
---|
| 393 |
|
---|
[35] | 394 | _bncCaster->addGetThread(getThread);
|
---|
| 395 |
|
---|
| 396 | getThread->start();
|
---|
| 397 | }
|
---|
| 398 | }
|
---|
[83] | 399 |
|
---|
[182] | 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();
|
---|
[188] | 408 | _bncCaster->wait();
|
---|
[182] | 409 | delete _bncCaster;
|
---|
| 410 | _bncCaster = 0;
|
---|
| 411 | _actGetData->setEnabled(true);
|
---|
| 412 | _actStop->setEnabled(false);
|
---|
[183] | 413 | _actAddMountPoints->setEnabled(true);
|
---|
[182] | 414 | }
|
---|
| 415 | }
|
---|
| 416 |
|
---|
[83] | 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 |
|
---|
[189] | 453 | QString txt = _log->toPlainText() + "\n" +
|
---|
| 454 | QTime::currentTime().toString("hh:mm:ss ") + msg;
|
---|
[83] | 455 | _log->clear();
|
---|
| 456 | _log->append(txt.right(maxBufferSize));
|
---|
| 457 | }
|
---|
| 458 |
|
---|
[108] | 459 | // About Message
|
---|
| 460 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 461 | void bncWindow::slotAbout() {
|
---|
| 462 |
|
---|
[161] | 463 | QTextBrowser* tb = new QTextBrowser;
|
---|
[169] | 464 | QUrl url; url.setPath(":bncabout.html");
|
---|
| 465 | tb->setSource(url);
|
---|
[161] | 466 | tb->setReadOnly(true);
|
---|
[142] | 467 |
|
---|
[161] | 468 | QDialog dlg(this);
|
---|
[142] | 469 |
|
---|
[164] | 470 | QGridLayout* dlgLayout = new QGridLayout();
|
---|
| 471 | QLabel* img = new QLabel();
|
---|
[173] | 472 | img->setPixmap(QPixmap(":ntrip-logo.png"));
|
---|
[164] | 473 | dlgLayout->addWidget(img, 0,0);
|
---|
| 474 | dlgLayout->addWidget(new QLabel("BKG NTRIP Client (BNC), Version 1.0"), 0,1);
|
---|
| 475 | dlgLayout->addWidget(tb,1,0,1,2);
|
---|
[161] | 476 |
|
---|
| 477 | dlg.setLayout(dlgLayout);
|
---|
| 478 | int ww = QFontMetrics(font()).width('w');
|
---|
| 479 | dlg.resize(60*ww, 60*ww);
|
---|
| 480 | dlg.exec();
|
---|
[108] | 481 | }
|
---|
| 482 |
|
---|
| 483 | // Help Window
|
---|
| 484 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 485 | void bncWindow::slotHelp() {
|
---|
[177] | 486 | QUrl url;
|
---|
| 487 | url.setPath(":bnchelp.html");
|
---|
| 488 | new bncHlpDlg(this, url);
|
---|
[108] | 489 | }
|
---|
[110] | 490 |
|
---|
| 491 | // Select Fonts
|
---|
| 492 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 493 | void bncWindow::slotFontSel() {
|
---|
| 494 | bool ok;
|
---|
| 495 | QFont newFont = QFontDialog::getFont(&ok, this->font(), this);
|
---|
| 496 | if (ok) {
|
---|
[113] | 497 | QSettings settings;
|
---|
| 498 | settings.setValue("font", newFont.toString());
|
---|
[110] | 499 | QApplication::setFont(newFont);
|
---|
[113] | 500 | int ww = QFontMetrics(newFont).width('w');
|
---|
[152] | 501 | setMinimumSize(60*ww, 80*ww);
|
---|
| 502 | resize(60*ww, 80*ww);
|
---|
[110] | 503 | }
|
---|
| 504 | }
|
---|