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