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