source: ntrip/trunk/BNC/bnctabledlg.cpp@ 2796

Last change on this file since 2796 was 2796, checked in by mervart, 13 years ago
File size: 23.1 KB
Line 
1// Part of BNC, a utility for retrieving decoding and
2// converting GNSS data streams from NTRIP broadcasters.
3//
4// Copyright (C) 2007
5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
7// Czech Technical University Prague, Department of Geodesy
8// http://www.fsv.cvut.cz
9//
10// Email: euref-ip@bkg.bund.de
11//
12// This program is free software; you can redistribute it and/or
13// modify it under the terms of the GNU General Public License
14// as published by the Free Software Foundation, version 2.
15//
16// This program is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program; if not, write to the Free Software
23// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
25/* -------------------------------------------------------------------------
26 * BKG NTRIP Client
27 * -------------------------------------------------------------------------
28 *
29 * Class: bncTableDlg
30 *
31 * Purpose: Displays the source table, allows mountpoints selection
32 *
33 * Author: L. Mervart
34 *
35 * Created: 24-Dec-2005
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iostream>
42
43#include "bnctabledlg.h"
44#include "bncgetthread.h"
45#include "bncnetqueryv1.h"
46#include "bncsettings.h"
47#include "bncmap.h"
48
49using namespace std;
50
51// Constructor
52////////////////////////////////////////////////////////////////////////////
53bncTableDlg::bncTableDlg(QWidget* parent) : QDialog(parent) {
54
55 setMinimumSize(600,400);
56 setWindowTitle(tr("Add Streams from Caster"));
57
58 QVBoxLayout* mainLayout = new QVBoxLayout(this);
59
60 int ww = QFontMetrics(font()).width('w');
61
62 _casterPortLineEdit = new QLineEdit();
63 _casterPortLineEdit->setMaximumWidth(9*ww);
64
65 _casterUserLineEdit = new QLineEdit();
66 _casterUserLineEdit->setMaximumWidth(9*ww);
67
68 _casterPasswordLineEdit = new QLineEdit();
69 _casterPasswordLineEdit->setMaximumWidth(9*ww);
70 _casterPasswordLineEdit->setEchoMode(QLineEdit::Password);
71
72 _casterHostComboBox = new QComboBox();
73 _casterHostComboBox->setMaxCount(10);
74 _casterHostComboBox->setDuplicatesEnabled(false);
75 _casterHostComboBox->setEditable(true);
76 _casterHostComboBox->setMinimumWidth(20*ww);
77 _casterHostComboBox->setMaximumWidth(20*ww);
78 connect(_casterHostComboBox, SIGNAL(currentIndexChanged(const QString&)),
79 this, SLOT(slotCasterHostChanged(const QString&)));
80 bncSettings settings;
81 settings.remove("casterHostList");
82 settings.remove("casterHost");
83 settings.remove("casterPort");
84 settings.remove("casterUser");
85 settings.remove("casterPassword");
86 QStringList casterUrlList = settings.value("casterUrlList").toStringList();
87 for (int ii = 0; ii < casterUrlList.count(); ii++) {
88 QUrl url(casterUrlList[ii]);
89 _casterHostComboBox->addItem(url.host());
90 }
91
92 _ntripVersionComboBox = new QComboBox();
93 _ntripVersionComboBox->addItems(QString("1,2,R,U").split(","));
94 int kk = _ntripVersionComboBox->findText(settings.value("ntripVersion").toString());
95 if (kk != -1) {
96 _ntripVersionComboBox->setCurrentIndex(kk);
97 }
98 _ntripVersionComboBox->setMaximumWidth(5*ww);
99
100 _buttonCasterTable = new QPushButton(tr("Show"), this);
101 connect(_buttonCasterTable, SIGNAL(clicked()), this, SLOT(slotCasterTable()));
102 _buttonCasterTable->setMaximumWidth(5*ww);
103
104 // WhatsThis
105 // ---------
106 _casterUserLineEdit->setWhatsThis(tr("<p>Access to some streams on NTRIP broadcasters may be restricted. You'll need to enter a valid 'User ID' and 'Password' for access to these protected streams.</p><p>Accounts are usually provided per NTRIP broadcaster through a registration process. Register through <u>http://igs.bkg.bund.de/index_ntrip_reg.htm</u> for access to protected streams on <u>www.euref-ip.net</u> and <u>www.igs-ip.net</u>.</p>"));
107 _casterHostComboBox->setWhatsThis(tr("<p>Enter the NTRIP broadcaster hostname or IP number.</p><p>Note that EUREF and IGS operate NTRIP broadcasters at <u>http://www.euref-ip.net/home</u> and <u>http://www.igs-ip.net/home</u>.</p>"));
108 _casterPortLineEdit->setWhatsThis(tr("Enter the NTRIP broadcaster port number."));
109 _casterPasswordLineEdit->setWhatsThis(tr("Access to some streams on NTRIP broadcasters may be restricted. You'll need to enter a valid 'Password' for access to these protected streams."));
110
111 QGridLayout* editLayout = new QGridLayout;
112 editLayout->addWidget(new QLabel(tr("Caster host")), 0, 0);
113 editLayout->addWidget(_casterHostComboBox, 0, 1);
114 editLayout->addWidget(new QLabel(tr(" Caster port")), 0, 2, Qt::AlignRight);
115 editLayout->addWidget(_casterPortLineEdit, 0, 3);
116 editLayout->addWidget(new QLabel(tr("Casters table")), 0, 4, Qt::AlignRight);
117 editLayout->addWidget(_buttonCasterTable, 0, 5);
118 editLayout->addWidget(new QLabel(tr("User")), 1, 0, Qt::AlignRight);
119 editLayout->addWidget(_casterUserLineEdit, 1, 1);
120 editLayout->addWidget(new QLabel(tr("Password")), 1, 2, Qt::AlignRight);
121 editLayout->addWidget(_casterPasswordLineEdit, 1, 3);
122 editLayout->addWidget(new QLabel(tr(" NTRIP Version")),1, 4, Qt::AlignRight);
123 editLayout->addWidget(_ntripVersionComboBox, 1, 5);
124
125 mainLayout->addLayout(editLayout);
126
127 _buttonCasterTable->setWhatsThis(tr("<p>Hit 'Show' for a table of known NTRIP broadcaster installations as maintained at <u>www.rtcm-ntrip.org/home.</u></p><p>A window opens which allows to select a broadcaster for stream retrieval.</p>"));
128 _ntripVersionComboBox->setWhatsThis(tr("<p>Select the NTRIP transport protocol version you want to use. Implemented options are:<br>&nbsp; 1:&nbsp; NTRIP version 1, TCP/IP<br>&nbsp; 2:&nbsp; NTRIP version 2, TCP/IP mode<br>&nbsp; R:&nbsp; NTRIP Version 2, RTSP/RTP mode<br>&nbsp; U:&nbsp; NTRIP Version 2, UDP mode<br>Select option '1' if you are not sure whether the NTRIP broadcaster supports NTRIP version 2.</p><p>Note that RTSP/RTP (option 'R') and UDP (option 'U') are not accepted by proxies and sometimes not supported by mobile Internet Service Providers.</p>"));
129
130 _table = new QTableWidget(this);
131 _table->setWhatsThis(tr("<p>Use the 'Get Table' button to download the sourcetable from the selected NTRIP broadcaster. Select the desired streams line by line, using +Shift and +Ctrl when necessary. Hit 'OK' to return to the main window.</p><p>Pay attention to data field 'format'. Keep in mind that BNC can only decode and convert streams that come in RTCM Version 2.x, RTCM Version 3.x, or RTIGS format. See data field 'format-details' for available message types and their repetition rates in brackets.</p><p>The content of data field 'nmea' tells you whether a stream comes from a virtual reference station (VRS).</p>"));
132 connect(_table, SIGNAL(itemSelectionChanged()),
133 this, SLOT(slotSelectionChanged()));
134 mainLayout->addWidget(_table);
135
136 _buttonWhatsThis = new QPushButton(tr("Help=Shift+F1"), this);
137 connect(_buttonWhatsThis, SIGNAL(clicked()), this, SLOT(slotWhatsThis()));
138
139 _buttonGet = new QPushButton(tr("Get table"), this);
140 _buttonGet->setDefault(true);
141 connect(_buttonGet, SIGNAL(clicked()), this, SLOT(slotGetTable()));
142
143 _buttonMap = new QPushButton(tr("Map"), this);
144 _buttonMap->setEnabled(false);
145 connect(_buttonMap, SIGNAL(clicked()), this, SLOT(slotShowMap()));
146
147 _buttonClose = new QPushButton(tr("Close"), this);
148 connect(_buttonClose, SIGNAL(clicked()), this, SLOT(close()));
149
150 _buttonSelect = new QPushButton(tr("Select"), this);
151 connect(_buttonSelect, SIGNAL(clicked()), this, SLOT(select()));
152
153 QHBoxLayout* buttonLayout = new QHBoxLayout;
154 buttonLayout->addWidget(_buttonWhatsThis);
155 buttonLayout->addStretch(1);
156 buttonLayout->addWidget(_buttonMap);
157 buttonLayout->addWidget(_buttonGet);
158 buttonLayout->addWidget(_buttonSelect);
159 buttonLayout->addWidget(_buttonClose);
160
161 mainLayout->addLayout(buttonLayout);
162}
163
164// Destructor
165////////////////////////////////////////////////////////////////////////////
166bncTableDlg::~bncTableDlg() {
167 delete _casterHostComboBox;
168 delete _casterPortLineEdit;
169 delete _casterUserLineEdit;
170 delete _casterPasswordLineEdit;
171 delete _ntripVersionComboBox;
172 delete _buttonGet;
173 delete _buttonClose;
174 delete _buttonSelect;
175 delete _buttonWhatsThis;
176 delete _buttonCasterTable;
177 delete _table;
178}
179
180// Read full caster table (static)
181////////////////////////////////////////////////////////////////////////////
182t_irc bncTableDlg::getFullTable(const QString& casterHost,
183 int casterPort, QStringList& allLines,
184 bool alwaysRead) {
185
186 static QMutex mutex;
187 static QMap<QString, QStringList> allTables;
188
189 QMutexLocker locker(&mutex);
190
191 if (!alwaysRead && allTables.find(casterHost) != allTables.end()) {
192 allLines = allTables.find(casterHost).value();
193 return success;
194 }
195
196 allLines.clear();
197
198 QUrl url;
199 url.setHost(casterHost);
200 url.setPort(casterPort);
201 url.setScheme("http");
202 url.setPath("/");
203
204 bncNetQueryV1 query;
205 QByteArray outData;
206 query.waitForRequestResult(url, outData);
207 if (query.status() == bncNetQuery::finished) {
208 QTextStream in(outData);
209 QString line = in.readLine();
210 while ( !line.isNull() ) {
211 allLines.append(line);
212 line = in.readLine();
213 }
214 allTables.insert(casterHost, allLines);
215 return success;
216 }
217 else {
218 return failure;
219 }
220}
221
222// Read Table from Caster
223////////////////////////////////////////////////////////////////////////////
224void bncTableDlg::slotGetTable() {
225
226 _buttonGet->setEnabled(false);
227 _buttonMap->setEnabled(true);
228 _buttonCasterTable->setEnabled(false);
229
230 if ( getFullTable(_casterHostComboBox->currentText(),
231 _casterPortLineEdit->text().toInt(),
232 _allLines, true) != success ) {
233 QMessageBox::warning(0, "BNC", "Cannot retrieve table of data");
234 _buttonGet->setEnabled(true);
235 return;
236 }
237
238 static const QStringList labels = QString("mountpoint,identifier,format,"
239 "format-details,carrier,system,network,country,lat,long,"
240 "nmea,solution,generator,compress.,auth.,fee,bitrate,"
241 "misc").split(",");
242
243 QStringList lines;
244 QStringListIterator it(_allLines);
245 while (it.hasNext()) {
246 QString line = it.next();
247 if (line.indexOf("STR") == 0) {
248 QStringList hlp = line.split(";");
249 if (hlp.size() > labels.size()) {
250 lines.push_back(line);
251 }
252 }
253 }
254
255 if (lines.size() > 0) {
256 _table->setSelectionMode(QAbstractItemView::ExtendedSelection);
257 _table->setSelectionBehavior(QAbstractItemView::SelectRows);
258 _table->setColumnCount(labels.size());
259 _table->setRowCount(lines.size());
260 for (int nRow = 0; nRow < lines.size(); nRow++) {
261 QStringList columns = lines[nRow].split(";");
262 for (int ic = 1; ic < columns.size(); ic++) {
263 if (ic == 11) {
264 if (columns[ic] == "0") {
265 columns[ic] = "no";
266 } else {
267 columns[ic] = "yes";
268 }
269 }
270 QTableWidgetItem* item = new QTableWidgetItem(columns[ic]);
271 item->setFlags(item->flags() & ~Qt::ItemIsEditable);
272 _table->setItem(nRow, ic-1, item);
273 }
274 }
275 _table->setHorizontalHeaderLabels(labels);
276 _table->setSortingEnabled(true);
277 int ww = QFontMetrics(this->font()).width('w');
278 _table->horizontalHeader()->resizeSection( 0,10*ww);
279 _table->horizontalHeader()->resizeSection( 1,10*ww);
280 _table->horizontalHeader()->resizeSection( 2, 8*ww);
281 _table->horizontalHeader()->resizeSection( 3,22*ww);
282 _table->horizontalHeader()->resizeSection( 4, 5*ww);
283 _table->horizontalHeader()->resizeSection( 5, 8*ww);
284 _table->horizontalHeader()->resizeSection( 6, 8*ww);
285 _table->horizontalHeader()->resizeSection( 7, 7*ww);
286 _table->horizontalHeader()->resizeSection( 8, 6*ww);
287 _table->horizontalHeader()->resizeSection( 9, 6*ww);
288 _table->horizontalHeader()->resizeSection(10, 6*ww);
289 _table->horizontalHeader()->resizeSection(11, 6*ww);
290 _table->horizontalHeader()->resizeSection(12,15*ww);
291 _table->horizontalHeader()->resizeSection(13, 8*ww);
292 _table->horizontalHeader()->resizeSection(14, 5*ww);
293 _table->horizontalHeader()->resizeSection(15, 5*ww);
294 _table->horizontalHeader()->resizeSection(16, 7*ww);
295 _table->horizontalHeader()->resizeSection(17,15*ww);
296 _table->sortItems(0);
297 }
298}
299
300// Show world map
301////////////////////////////////////////////////////////////////////////////
302void bncTableDlg::slotShowMap() {
303
304 bncMap* winMap = new bncMap(this);
305 winMap->setGeometry( x(), int(y()+height()*1.3), 880, 440 );
306
307 connect(this, SIGNAL(newPoint(QPointF, QString, QPen)),
308 winMap, SLOT(slotNewPoint(QPointF, QString, QPen)));
309
310 connect(this, SIGNAL(fitMap()),
311 winMap, SLOT(slotFitMap() ));
312
313 _buttonMap->setEnabled(false);
314 showSourceTable();
315 winMap->exec();
316 _buttonMap->setEnabled(true);
317
318 disconnect(this, SIGNAL(newPoint(QPointF, QString, QPen)),
319 winMap, SLOT(slotNewPoint(QPointF, QString, QPen)));
320
321 disconnect(this, SIGNAL(fitMap()),
322 winMap, SLOT(slotFitMap() ));
323
324 delete winMap;
325}
326
327// Show world map
328////////////////////////////////////////////////////////////////////////////
329void bncTableDlg::showSourceTable() {
330
331 for( int i = 0; i < _allLines.size(); i++ ){
332
333 if( _allLines.at(i).startsWith("STR") == true ){
334
335 QStringList tmp = _allLines.at(i).split(';');
336 if( tmp.size() > 0 ){
337
338 QPointF point;
339 point.setY( tmp.at(9).toDouble() );
340 point.setX( tmp.at(10).toDouble() );
341
342 QString site = tmp.at(1);
343 site.resize(4);
344
345 emit newPoint(point, site, QPen(QBrush(QColor(0,0,255,200)), 1.5) );
346 }
347 }
348 }
349 emit fitMap();
350}
351
352
353// Select slot
354////////////////////////////////////////////////////////////////////////////
355void bncTableDlg::select() {
356
357 bncSettings settings;
358 settings.setValue("ntripVersion", _ntripVersionComboBox->currentText());
359 QUrl url;
360 url.setScheme("http");
361 url.setHost(_casterHostComboBox->currentText());
362 url.setPort(_casterPortLineEdit->text().toInt());
363 url.setUserName(QUrl::toPercentEncoding(_casterUserLineEdit->text()));
364 url.setPassword(QUrl::toPercentEncoding(_casterPasswordLineEdit->text()));
365 addUrl(url);
366
367 QStringList* mountPoints = new QStringList;
368 if (_table) {
369 for (int ir = 0; ir < _table->rowCount(); ir++) {
370 QTableWidgetItem* item = _table->item(ir,0);
371 QString site = _table->item(ir,0)->text();
372 QString format = _table->item(ir,2)->text();
373 QString latitude = _table->item(ir,8)->text();
374 QString longitude = _table->item(ir,9)->text();
375 QString nmea = _table->item(ir,10)->text();
376 QString ntripVersion = _ntripVersionComboBox->currentText();
377 format.replace(" ", "_");
378 if (_table->isItemSelected(item)) {
379 url.setPath(item->text());
380 mountPoints->push_back(url.toString() + " " + format + " " + latitude
381 + " " + longitude + " " + nmea + " " + ntripVersion);
382
383 site.resize(4);
384 emit newPoint(QPointF(longitude.toDouble(),latitude.toDouble()), site,
385 QPen(QBrush(QColor(255,0,0,200)), 3) );
386 }
387 }
388 }
389 emit newMountPoints(mountPoints);
390}
391
392// User changed the selection of mountPoints
393////////////////////////////////////////////////////////////////////////////
394void bncTableDlg::slotSelectionChanged() {
395 if (_table->selectedItems().isEmpty()) {
396 }
397}
398
399// Whats This Help
400void bncTableDlg::slotWhatsThis() {
401QWhatsThis::enterWhatsThisMode();
402}
403
404// Slot caster table
405////////////////////////////////////////////////////////////////////////////
406void bncTableDlg::slotCasterTable() {
407
408 _buttonCasterTable->setEnabled(false);
409 _casterHostComboBox->setEnabled(false);
410 _casterPortLineEdit->setEnabled(false);
411 _casterUserLineEdit->setEnabled(false);
412 _casterPasswordLineEdit->setEnabled(false);
413 _ntripVersionComboBox->setEnabled(false);
414 _buttonWhatsThis->setEnabled(false);
415 _buttonGet->setEnabled(false);
416 _buttonClose->setEnabled(false);
417 _buttonSelect->setEnabled(false);
418
419 bncCasterTableDlg* dlg = new bncCasterTableDlg(this);
420 dlg->move(this->pos().x()+50, this->pos().y()+50);
421 connect(dlg, SIGNAL(newCaster(QString, QString)),
422 this, SLOT(slotNewCaster(QString, QString)));
423 dlg->exec();
424 delete dlg;
425
426 _buttonCasterTable->setEnabled(true);
427 _casterHostComboBox->setEnabled(true);
428 _casterPortLineEdit->setEnabled(true);
429 _casterUserLineEdit->setEnabled(true);
430 _casterPasswordLineEdit->setEnabled(true);
431 _ntripVersionComboBox->setEnabled(true);
432 _buttonWhatsThis->setEnabled(true);
433 _buttonGet->setEnabled(true);
434 _buttonClose->setEnabled(true);
435 _buttonSelect->setEnabled(true);
436
437}
438
439// New caster selected
440////////////////////////////////////////////////////////////////////////////
441void bncTableDlg::slotNewCaster(QString newCasterHost, QString newCasterPort) {
442
443 _casterHostComboBox->insertItem(0, newCasterHost);
444 _casterHostComboBox->setCurrentIndex(0);
445 _casterUserLineEdit->setText("");
446 _casterPasswordLineEdit->setText("");
447 _casterPortLineEdit->setText(newCasterPort);
448
449 QUrl url;
450 url.setScheme("http");
451 url.setHost(newCasterHost);
452 url.setPort(newCasterPort.toInt());
453 addUrl(url);
454
455 _casterHostComboBox->setCurrentIndex(0);
456}
457
458// New caster selected
459////////////////////////////////////////////////////////////////////////////
460void bncTableDlg::addUrl(const QUrl& url) {
461 bncSettings settings;
462 QStringList oldUrlList = settings.value("casterUrlList").toStringList();
463 QStringList newUrlList;
464 newUrlList << url.toString();
465 for (int ii = 0; ii < oldUrlList.count(); ii++) {
466 QUrl oldUrl(oldUrlList[ii]);
467 if (url.host() != oldUrl.host()) {
468 newUrlList << oldUrl.toString();
469 }
470 }
471 settings.setValue("casterUrlList", newUrlList);
472 settings.sync();
473}
474
475// New caster selected in combobox
476////////////////////////////////////////////////////////////////////////////
477void bncTableDlg::slotCasterHostChanged(const QString& newHost) {
478 bncSettings settings;
479 QStringList casterUrlList = settings.value("casterUrlList").toStringList();
480 for (int ii = 0; ii < casterUrlList.count(); ii++) {
481 QUrl url(casterUrlList[ii]);
482 if (url.host() == newHost) {
483 _casterUserLineEdit->setText(
484 QUrl::fromPercentEncoding(url.userName().toAscii()));
485 _casterPasswordLineEdit->setText(
486 QUrl::fromPercentEncoding(url.password().toAscii()));
487 if (url.port() > 0) {
488 _casterPortLineEdit->setText(QString("%1").arg(url.port()));
489 }
490 else {
491 _casterPortLineEdit->setText("");
492 }
493 }
494 }
495}
496
497// Caster table
498////////////////////////////////////////////////////////////////////////////
499bncCasterTableDlg::bncCasterTableDlg(QWidget* parent) :
500 QDialog(parent) {
501
502 static const QStringList labels = QString("host,port,identifier,operator,nmea,country,lat,long,link").split(",");
503
504 _casterTable = new QTableWidget(this);
505
506 QUrl url;
507 url.setHost("www.rtcm-ntrip.org");
508 url.setPort(2101);
509 url.setScheme("http");
510 url.setPath("/");
511
512 bncNetQueryV1 query;
513 QByteArray outData;
514 query.waitForRequestResult(url, outData);
515
516 QStringList lines;
517 if (query.status() == bncNetQuery::finished) {
518 QTextStream in(outData);
519 QString line = in.readLine();
520 while ( !line.isNull() ) {
521 line = in.readLine();
522 if (line.indexOf("CAS") == 0) {
523 QStringList hlp = line.split(";");
524 if (hlp.size() > labels.size()) {
525 lines.push_back(line);
526 }
527 }
528 }
529 }
530
531 if (lines.size() > 0) {
532 _casterTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
533 _casterTable->setSelectionBehavior(QAbstractItemView::SelectRows);
534
535 QStringList hlp = lines[0].split(";");
536 _casterTable->setColumnCount(labels.size());
537 _casterTable->setRowCount(lines.size());
538
539 for (int nRow = 0; nRow < lines.size(); nRow++) {
540 QStringList columns = lines[nRow].split(";");
541 for (int ic = 1; ic < columns.size(); ic++) {
542 if (ic == 5) {
543 if (columns[ic] == "0") {
544 columns[ic] = "no";
545 } else {
546 columns[ic] = "yes";
547 }
548 }
549 QTableWidgetItem* item = new QTableWidgetItem(columns[ic]);
550 item->setFlags(item->flags() & ~Qt::ItemIsEditable);
551 _casterTable->setItem(nRow, ic-1, item);
552 }
553 }
554 }
555 _casterTable->setHorizontalHeaderLabels(labels);
556 _casterTable->setSortingEnabled(true);
557 _casterTable->sortItems(0);
558 int ww = QFontMetrics(this->font()).width('w');
559 _casterTable->horizontalHeader()->resizeSection(0,15*ww);
560 _casterTable->horizontalHeader()->resizeSection(1, 5*ww);
561 _casterTable->horizontalHeader()->resizeSection(2,15*ww);
562 _casterTable->horizontalHeader()->resizeSection(3,15*ww);
563 _casterTable->horizontalHeader()->resizeSection(4, 5*ww);
564 _casterTable->horizontalHeader()->resizeSection(5, 7*ww);
565 _casterTable->horizontalHeader()->resizeSection(6, 7*ww);
566 _casterTable->horizontalHeader()->resizeSection(7, 7*ww);
567 _casterTable->horizontalHeader()->resizeSection(8,15*ww);
568
569 _closeButton = new QPushButton("Cancel");
570 connect(_closeButton, SIGNAL(clicked()), this, SLOT(close()));
571 _closeButton->setMinimumWidth(8*ww);
572 _closeButton->setMaximumWidth(8*ww);
573
574 _okButton = new QPushButton(tr("OK"), this);
575 connect(_okButton, SIGNAL(clicked()), this, SLOT(slotAcceptCasterTable()));
576 _okButton->setMinimumWidth(8*ww);
577 _okButton->setMaximumWidth(8*ww);
578
579 _whatsThisButton = new QPushButton(tr("Help=Shift+F1"), this);
580 connect(_whatsThisButton, SIGNAL(clicked()), this, SLOT(slotWhatsThis()));
581 _whatsThisButton->setMinimumWidth(12*ww);
582 _whatsThisButton->setMaximumWidth(12*ww);
583
584 _casterTable->setWhatsThis(tr("<p>Select an NTRIP broadcaster and hit 'OK'.</p><p>See <u>http://www.rtcm-ntrip.org/home</u> for further details on known NTRIP broadcaster installations.</u>."));
585
586 QGridLayout* dlgLayout = new QGridLayout();
587 dlgLayout->addWidget(new QLabel(" List of NTRIP Broadcasters from www.rtcm-ntrip.org"), 0,0,1,3,Qt::AlignLeft);
588 dlgLayout->addWidget(_casterTable, 1, 0, 1, 3);
589 dlgLayout->addWidget(_whatsThisButton, 2, 0);
590 dlgLayout->addWidget(_closeButton, 2, 1, Qt::AlignRight);
591 dlgLayout->addWidget(_okButton, 2, 2);
592
593 setMinimumSize(600,400);
594 setWindowTitle(tr("Select Broadcaster"));
595 setLayout(dlgLayout);
596 resize(68*ww, 50*ww);
597 show();
598}
599
600// Caster table destructor
601////////////////////////////////////////////////////////////////////////////
602bncCasterTableDlg::~bncCasterTableDlg() {
603 delete _casterTable;
604 delete _okButton;
605 delete _closeButton;
606 delete _whatsThisButton;
607}
608
609// Caster table what's this
610////////////////////////////////////////////////////////////////////////////
611void bncCasterTableDlg:: slotWhatsThis() {
612 QWhatsThis::enterWhatsThisMode();
613}
614
615// Accept caster table
616////////////////////////////////////////////////////////////////////////////
617void bncCasterTableDlg::slotAcceptCasterTable() {
618 if (_casterTable) {
619 for (int ir = _casterTable->rowCount() - 1; ir >= 0 ; ir--) {
620 if (_casterTable->isItemSelected(_casterTable->item(ir,0))) {
621 emit newCaster(_casterTable->item(ir,0)->text(),
622 _casterTable->item(ir,1)->text());
623 }
624 }
625 }
626 QDialog::accept();
627}
Note: See TracBrowser for help on using the repository browser.