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