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->setHorizontalHeaderLabels(labels);
|
---|
139 | // _mountPointsTable->horizontalHeader()->hide();
|
---|
140 | _mountPointsTable->verticalHeader()->hide();
|
---|
141 | _mountPointsTable->setGridStyle(Qt::NoPen);
|
---|
142 | _mountPointsTable->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
---|
143 | _mountPointsTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
---|
144 | _mountPointsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
---|
145 | QListIterator<QString> it(settings.value("mountPoints").toStringList());
|
---|
146 | if (!it.hasNext()) {
|
---|
147 | _actGetData->setEnabled(false);
|
---|
148 | }
|
---|
149 | int iRow = 0;
|
---|
150 | while (it.hasNext()) {
|
---|
151 | QStringList hlp = it.next().split(" ");
|
---|
152 | if (hlp.size() <= 1) continue;
|
---|
153 | _mountPointsTable->insertRow(iRow);
|
---|
154 |
|
---|
155 | QUrl url(hlp[0]);
|
---|
156 |
|
---|
157 | QString fullPath = url.host() + QString(":%1").arg(url.port()) + url.path();
|
---|
158 | QString format(hlp[1]);
|
---|
159 |
|
---|
160 | QTableWidgetItem* it;
|
---|
161 | it = new QTableWidgetItem(url.userInfo());
|
---|
162 | it->setFlags(it->flags() & ~Qt::ItemIsEditable);
|
---|
163 | _mountPointsTable->setItem(iRow, 0, it);
|
---|
164 |
|
---|
165 | it = new QTableWidgetItem(fullPath);
|
---|
166 | it->setFlags(it->flags() & ~Qt::ItemIsEditable);
|
---|
167 | _mountPointsTable->setItem(iRow, 1, it);
|
---|
168 |
|
---|
169 | it = new QTableWidgetItem(format);
|
---|
170 | _mountPointsTable->setItem(iRow, 2, it);
|
---|
171 |
|
---|
172 | bncTableItem* bncIt = new bncTableItem();
|
---|
173 | _mountPointsTable->setItem(iRow, 3, bncIt);
|
---|
174 |
|
---|
175 | iRow++;
|
---|
176 | }
|
---|
177 | _mountPointsTable->hideColumn(0);
|
---|
178 | _mountPointsTable->sortItems(1);
|
---|
179 |
|
---|
180 | connect(_mountPointsTable, SIGNAL(itemSelectionChanged()),
|
---|
181 | SLOT(slotSelectionChanged()));
|
---|
182 |
|
---|
183 | _log = new QTextEdit();
|
---|
184 | _log->setReadOnly(true);
|
---|
185 |
|
---|
186 | layout->addWidget(new QLabel("Proxy host"), 0, 0, 1, 2);
|
---|
187 | layout->addWidget(_proxyHostLineEdit, 0, 2);
|
---|
188 | layout->addWidget(new QLabel("Proxy port"), 0, 3);
|
---|
189 | layout->addWidget(_proxyPortLineEdit, 0, 4);
|
---|
190 |
|
---|
191 | layout->addWidget(new QLabel("Wait for full epoch"), 1, 0, 1, 2);
|
---|
192 | layout->addWidget(_waitTimeSpinBox, 1, 2);
|
---|
193 |
|
---|
194 | layout->addWidget(new QLabel("ASCII output file (full path)"), 2, 0, 1, 2);
|
---|
195 | layout->addWidget(_outFileLineEdit, 2, 2, 1, 3);
|
---|
196 |
|
---|
197 | layout->addWidget(new QLabel("Port for binary output"), 3, 0, 1, 2);
|
---|
198 | layout->addWidget(_outPortLineEdit, 3, 2);
|
---|
199 |
|
---|
200 | layout->addWidget(new QLabel("RINEX directory path"), 4, 0, 1, 2);
|
---|
201 | layout->addWidget(_rnxPathLineEdit, 4, 2, 1, 3);
|
---|
202 |
|
---|
203 | layout->addWidget(new QLabel("RINEX script (full path)"), 5, 0, 1, 2);
|
---|
204 | layout->addWidget(_rnxScrpLineEdit, 5, 2, 1, 3);
|
---|
205 |
|
---|
206 | layout->addWidget(new QLabel("RINEX file interval"), 6, 0, 1, 2);
|
---|
207 | layout->addWidget(_rnxIntrComboBox, 6, 2);
|
---|
208 | layout->addWidget(new QLabel("Sampling"), 6, 3);
|
---|
209 | layout->addWidget(_rnxSamplSpinBox, 6, 4);
|
---|
210 |
|
---|
211 | layout->addWidget(new QLabel("RINEX skeleton extension"), 7, 0, 1, 2);
|
---|
212 | layout->addWidget(_rnxSkelLineEdit, 7, 2);
|
---|
213 |
|
---|
214 | layout->addWidget(new QLabel("Mountpoints"), 8, 0, 1, 2);
|
---|
215 | layout->addWidget(_mountPointsTable, 9, 0, 1, 5);
|
---|
216 |
|
---|
217 | layout->addWidget(new QLabel("Log file (full path)"), 10, 0, 1, 2);
|
---|
218 | layout->addWidget(_logFileLineEdit, 10, 2, 1, 3);
|
---|
219 | layout->addWidget(_log, 11, 0, 1, 5);
|
---|
220 |
|
---|
221 | _bncCaster = 0;
|
---|
222 | }
|
---|
223 |
|
---|
224 | // Destructor
|
---|
225 | ////////////////////////////////////////////////////////////////////////////
|
---|
226 | bncWindow::~bncWindow() {
|
---|
227 | }
|
---|
228 |
|
---|
229 | // Retrieve Table
|
---|
230 | ////////////////////////////////////////////////////////////////////////////
|
---|
231 | void bncWindow::slotAddMountPoints() {
|
---|
232 |
|
---|
233 | QSettings settings;
|
---|
234 | QString proxyHost = settings.value("proxyHost").toString();
|
---|
235 | int proxyPort = settings.value("proxyPort").toInt();
|
---|
236 | if (proxyHost != _proxyHostLineEdit->text() ||
|
---|
237 | proxyPort != _proxyPortLineEdit->text().toInt()) {
|
---|
238 | int iRet = QMessageBox::question(this, "Question", "Proxy options "
|
---|
239 | "changed. Use the new ones?",
|
---|
240 | QMessageBox::Yes, QMessageBox::No,
|
---|
241 | QMessageBox::NoButton);
|
---|
242 | if (iRet == QMessageBox::Yes) {
|
---|
243 | settings.setValue("proxyHost", _proxyHostLineEdit->text());
|
---|
244 | settings.setValue("proxyPort", _proxyPortLineEdit->text());
|
---|
245 | }
|
---|
246 | }
|
---|
247 |
|
---|
248 | bncTableDlg* dlg = new bncTableDlg(this);
|
---|
249 | dlg->move(this->pos().x()+50, this->pos().y()+50);
|
---|
250 | connect(dlg, SIGNAL(newMountPoints(QStringList*)),
|
---|
251 | this, SLOT(slotNewMountPoints(QStringList*)));
|
---|
252 | dlg->exec();
|
---|
253 | delete dlg;
|
---|
254 |
|
---|
255 | }
|
---|
256 |
|
---|
257 | // Delete Selected Mount Points
|
---|
258 | ////////////////////////////////////////////////////////////////////////////
|
---|
259 | void bncWindow::slotDeleteMountPoints() {
|
---|
260 |
|
---|
261 | int nRows = _mountPointsTable->rowCount();
|
---|
262 | bool flg[nRows];
|
---|
263 | for (int iRow = 0; iRow < nRows; iRow++) {
|
---|
264 | if (_mountPointsTable->isItemSelected(_mountPointsTable->item(iRow,1))) {
|
---|
265 | flg[iRow] = true;
|
---|
266 | }
|
---|
267 | else {
|
---|
268 | flg[iRow] = false;
|
---|
269 | }
|
---|
270 | }
|
---|
271 | for (int iRow = nRows-1; iRow >= 0; iRow--) {
|
---|
272 | if (flg[iRow]) {
|
---|
273 | _mountPointsTable->removeRow(iRow);
|
---|
274 | }
|
---|
275 | }
|
---|
276 | _actDeleteMountPoints->setEnabled(false);
|
---|
277 |
|
---|
278 | if (_mountPointsTable->rowCount() == 0) {
|
---|
279 | _actGetData->setEnabled(false);
|
---|
280 | }
|
---|
281 | }
|
---|
282 |
|
---|
283 | // New Mount Points Selected
|
---|
284 | ////////////////////////////////////////////////////////////////////////////
|
---|
285 | void bncWindow::slotNewMountPoints(QStringList* mountPoints) {
|
---|
286 | int iRow = 0;
|
---|
287 | QListIterator<QString> it(*mountPoints);
|
---|
288 | while (it.hasNext()) {
|
---|
289 | QStringList hlp = it.next().split(" ");
|
---|
290 | QUrl url(hlp[0]);
|
---|
291 | QString fullPath = url.host() + QString(":%1").arg(url.port()) + url.path();
|
---|
292 | QString format(hlp[1]);
|
---|
293 |
|
---|
294 | _mountPointsTable->insertRow(iRow);
|
---|
295 |
|
---|
296 | QTableWidgetItem* it;
|
---|
297 | it = new QTableWidgetItem(url.userInfo());
|
---|
298 | it->setFlags(it->flags() & ~Qt::ItemIsEditable);
|
---|
299 | _mountPointsTable->setItem(iRow, 0, it);
|
---|
300 |
|
---|
301 | it = new QTableWidgetItem(fullPath);
|
---|
302 | it->setFlags(it->flags() & ~Qt::ItemIsEditable);
|
---|
303 | _mountPointsTable->setItem(iRow, 1, it);
|
---|
304 |
|
---|
305 | it = new QTableWidgetItem(format);
|
---|
306 | _mountPointsTable->setItem(iRow, 2, it);
|
---|
307 |
|
---|
308 | bncTableItem* bncIt = new bncTableItem();
|
---|
309 | _mountPointsTable->setItem(iRow, 3, bncIt);
|
---|
310 |
|
---|
311 | iRow++;
|
---|
312 | }
|
---|
313 | _mountPointsTable->hideColumn(0);
|
---|
314 | _mountPointsTable->sortItems(1);
|
---|
315 | if (mountPoints->count() > 0) {
|
---|
316 | _actGetData->setEnabled(true);
|
---|
317 | }
|
---|
318 | delete mountPoints;
|
---|
319 | }
|
---|
320 |
|
---|
321 | // Save Options
|
---|
322 | ////////////////////////////////////////////////////////////////////////////
|
---|
323 | void bncWindow::slotSaveOptions() {
|
---|
324 | QSettings settings;
|
---|
325 | settings.setValue("proxyHost", _proxyHostLineEdit->text());
|
---|
326 | settings.setValue("proxyPort", _proxyPortLineEdit->text());
|
---|
327 | settings.setValue("waitTime", _waitTimeSpinBox->value());
|
---|
328 | settings.setValue("outFile", _outFileLineEdit->text());
|
---|
329 | settings.setValue("outPort", _outPortLineEdit->text());
|
---|
330 | settings.setValue("rnxPath", _rnxPathLineEdit->text());
|
---|
331 | settings.setValue("rnxScript", _rnxScrpLineEdit->text());
|
---|
332 | settings.setValue("rnxIntr", _rnxIntrComboBox->currentText());
|
---|
333 | settings.setValue("rnxSampl", _rnxSamplSpinBox->value());
|
---|
334 | settings.setValue("rnxSkel", _rnxSkelLineEdit->text());
|
---|
335 | settings.setValue("logFile", _logFileLineEdit->text());
|
---|
336 |
|
---|
337 | QStringList mountPoints;
|
---|
338 |
|
---|
339 | for (int iRow = 0; iRow < _mountPointsTable->rowCount(); iRow++) {
|
---|
340 | QUrl url( "//" + _mountPointsTable->item(iRow, 0)->text() +
|
---|
341 | "@" + _mountPointsTable->item(iRow, 1)->text() );
|
---|
342 |
|
---|
343 | mountPoints.append(url.toString() + " " +
|
---|
344 | _mountPointsTable->item(iRow, 2)->text());
|
---|
345 | }
|
---|
346 | settings.setValue("mountPoints", mountPoints);
|
---|
347 | }
|
---|
348 |
|
---|
349 | // All get slots terminated
|
---|
350 | ////////////////////////////////////////////////////////////////////////////
|
---|
351 | void bncWindow::slotGetThreadErrors() {
|
---|
352 | slotMessage("All Get Threads Terminated");
|
---|
353 | ((bncApp*)qApp)->slotMessage("All Get Threads Terminated");
|
---|
354 | _actAddMountPoints->setEnabled(true);
|
---|
355 | _actGetData->setEnabled(true);
|
---|
356 | }
|
---|
357 |
|
---|
358 | // Retrieve Data
|
---|
359 | ////////////////////////////////////////////////////////////////////////////
|
---|
360 | void bncWindow::slotGetData() {
|
---|
361 | slotSaveOptions();
|
---|
362 |
|
---|
363 | _actAddMountPoints->setEnabled(false);
|
---|
364 | _actDeleteMountPoints->setEnabled(false);
|
---|
365 | _actGetData->setEnabled(false);
|
---|
366 | _actStop->setEnabled(true);
|
---|
367 |
|
---|
368 | _bncCaster = new bncCaster(_outFileLineEdit->text(),
|
---|
369 | _outPortLineEdit->text().toInt());
|
---|
370 |
|
---|
371 | connect(_bncCaster, SIGNAL(getThreadErrors()),
|
---|
372 | this, SLOT(slotGetThreadErrors()));
|
---|
373 |
|
---|
374 | connect(_bncCaster, SIGNAL(newMessage(const QByteArray&)),
|
---|
375 | this, SLOT(slotMessage(const QByteArray&)));
|
---|
376 | connect(_bncCaster, SIGNAL(newMessage(const QByteArray&)),
|
---|
377 | (bncApp*)qApp, SLOT(slotMessage(const QByteArray&)));
|
---|
378 |
|
---|
379 | _bncCaster->start();
|
---|
380 |
|
---|
381 | for (int iRow = 0; iRow < _mountPointsTable->rowCount(); iRow++) {
|
---|
382 | QUrl url( "//" + _mountPointsTable->item(iRow, 0)->text() +
|
---|
383 | "@" + _mountPointsTable->item(iRow, 1)->text() );
|
---|
384 |
|
---|
385 | QByteArray format = _mountPointsTable->item(iRow, 2)->text().toAscii();
|
---|
386 |
|
---|
387 | bncGetThread* getThread = new bncGetThread(url, format);
|
---|
388 |
|
---|
389 | connect(getThread, SIGNAL(newMessage(const QByteArray&)),
|
---|
390 | this, SLOT(slotMessage(const QByteArray&)));
|
---|
391 | connect(getThread, SIGNAL(newMessage(const QByteArray&)),
|
---|
392 | (bncApp*)qApp, SLOT(slotMessage(const QByteArray&)));
|
---|
393 |
|
---|
394 | connect(getThread, SIGNAL(newObs(const QByteArray&, Observation*)),
|
---|
395 | (bncTableItem*) _mountPointsTable->item(iRow, 3),
|
---|
396 | SLOT(slotNewObs(const QByteArray&, Observation*)));
|
---|
397 |
|
---|
398 | _bncCaster->addGetThread(getThread);
|
---|
399 |
|
---|
400 | getThread->start();
|
---|
401 | }
|
---|
402 | }
|
---|
403 |
|
---|
404 | // Retrieve Data
|
---|
405 | ////////////////////////////////////////////////////////////////////////////
|
---|
406 | void bncWindow::slotStop() {
|
---|
407 | int iRet = QMessageBox::question(this, "Stop", "Stop retrieving data?",
|
---|
408 | QMessageBox::Yes, QMessageBox::No,
|
---|
409 | QMessageBox::NoButton);
|
---|
410 | if (iRet == QMessageBox::Yes) {
|
---|
411 | _bncCaster->terminate();
|
---|
412 | _bncCaster->wait();
|
---|
413 | delete _bncCaster;
|
---|
414 | _bncCaster = 0;
|
---|
415 | _actGetData->setEnabled(true);
|
---|
416 | _actStop->setEnabled(false);
|
---|
417 | _actAddMountPoints->setEnabled(true);
|
---|
418 | }
|
---|
419 | }
|
---|
420 |
|
---|
421 | // Close Application gracefully
|
---|
422 | ////////////////////////////////////////////////////////////////////////////
|
---|
423 | void bncWindow::closeEvent(QCloseEvent* event) {
|
---|
424 |
|
---|
425 | int iRet = QMessageBox::question(this, "Close", "Save Options?",
|
---|
426 | QMessageBox::Yes, QMessageBox::No,
|
---|
427 | QMessageBox::Cancel);
|
---|
428 |
|
---|
429 | if (iRet == QMessageBox::Cancel) {
|
---|
430 | event->ignore();
|
---|
431 | return;
|
---|
432 | }
|
---|
433 | else if (iRet == QMessageBox::Yes) {
|
---|
434 | slotSaveOptions();
|
---|
435 | }
|
---|
436 |
|
---|
437 | return QMainWindow::closeEvent(event);
|
---|
438 | }
|
---|
439 |
|
---|
440 | // User changed the selection of mountPoints
|
---|
441 | ////////////////////////////////////////////////////////////////////////////
|
---|
442 | void bncWindow::slotSelectionChanged() {
|
---|
443 | if (_mountPointsTable->selectedItems().isEmpty()) {
|
---|
444 | _actDeleteMountPoints->setEnabled(false);
|
---|
445 | }
|
---|
446 | else {
|
---|
447 | _actDeleteMountPoints->setEnabled(true);
|
---|
448 | }
|
---|
449 | }
|
---|
450 |
|
---|
451 | // Display Program Messages
|
---|
452 | ////////////////////////////////////////////////////////////////////////////
|
---|
453 | void bncWindow::slotMessage(const QByteArray& msg) {
|
---|
454 |
|
---|
455 | const int maxBufferSize = 10000;
|
---|
456 |
|
---|
457 | QString txt = _log->toPlainText() + "\n" +
|
---|
458 | QTime::currentTime().toString("hh:mm:ss ") + msg;
|
---|
459 | _log->clear();
|
---|
460 | _log->append(txt.right(maxBufferSize));
|
---|
461 | }
|
---|
462 |
|
---|
463 | // About Message
|
---|
464 | ////////////////////////////////////////////////////////////////////////////
|
---|
465 | void bncWindow::slotAbout() {
|
---|
466 |
|
---|
467 | QTextBrowser* tb = new QTextBrowser;
|
---|
468 | QUrl url; url.setPath(":bncabout.html");
|
---|
469 | tb->setSource(url);
|
---|
470 | tb->setReadOnly(true);
|
---|
471 |
|
---|
472 | QDialog dlg(this);
|
---|
473 |
|
---|
474 | QGridLayout* dlgLayout = new QGridLayout();
|
---|
475 | QLabel* img = new QLabel();
|
---|
476 | img->setPixmap(QPixmap(":ntrip-logo.png"));
|
---|
477 | dlgLayout->addWidget(img, 0,0);
|
---|
478 | dlgLayout->addWidget(new QLabel("BKG NTRIP Client (BNC), Version 1.0"), 0,1);
|
---|
479 | dlgLayout->addWidget(tb,1,0,1,2);
|
---|
480 |
|
---|
481 | dlg.setLayout(dlgLayout);
|
---|
482 | int ww = QFontMetrics(font()).width('w');
|
---|
483 | dlg.resize(60*ww, 60*ww);
|
---|
484 | dlg.exec();
|
---|
485 | }
|
---|
486 |
|
---|
487 | // Help Window
|
---|
488 | ////////////////////////////////////////////////////////////////////////////
|
---|
489 | void bncWindow::slotHelp() {
|
---|
490 | QUrl url;
|
---|
491 | url.setPath(":bnchelp.html");
|
---|
492 | new bncHlpDlg(this, url);
|
---|
493 | }
|
---|
494 |
|
---|
495 | // Select Fonts
|
---|
496 | ////////////////////////////////////////////////////////////////////////////
|
---|
497 | void bncWindow::slotFontSel() {
|
---|
498 | bool ok;
|
---|
499 | QFont newFont = QFontDialog::getFont(&ok, this->font(), this);
|
---|
500 | if (ok) {
|
---|
501 | QSettings settings;
|
---|
502 | settings.setValue("font", newFont.toString());
|
---|
503 | QApplication::setFont(newFont);
|
---|
504 | int ww = QFontMetrics(newFont).width('w');
|
---|
505 | setMinimumSize(60*ww, 80*ww);
|
---|
506 | resize(60*ww, 80*ww);
|
---|
507 | }
|
---|
508 | }
|
---|