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