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