source: ntrip/trunk/BNC/src/bnctabledlg.cpp@ 7523

Last change on this file since 7523 was 7222, checked in by weber, 9 years ago

Documentation completed

File size: 24.0 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 "bncnetqueryv2.h"
47#include "bncsettings.h"
48#include "bncmap.h"
49
50using namespace std;
51
52// Constructor
53////////////////////////////////////////////////////////////////////////////
54bncTableDlg::bncTableDlg(QWidget* parent) : QDialog(parent) {
55
56 setMinimumSize(600,400);
57 setWindowTitle(tr("Add Streams from Caster"));
58
59 QVBoxLayout* mainLayout = new QVBoxLayout(this);
60
61 int ww = QFontMetrics(font()).width('w');
62
63 _casterPortLineEdit = new QLineEdit();
64 _casterPortLineEdit->setMaximumWidth(9*ww);
65
66 _casterUserLineEdit = new QLineEdit();
67 _casterUserLineEdit->setMaximumWidth(9*ww);
68
69 _casterPasswordLineEdit = new QLineEdit();
70 _casterPasswordLineEdit->setMaximumWidth(9*ww);
71 _casterPasswordLineEdit->setEchoMode(QLineEdit::PasswordEchoOnEdit);
72
73 _casterHostComboBox = new QComboBox();
74 _casterHostComboBox->setMaxCount(10);
75 _casterHostComboBox->setDuplicatesEnabled(false);
76 _casterHostComboBox->setEditable(true);
77 _casterHostComboBox->setMinimumWidth(20*ww);
78 _casterHostComboBox->setMaximumWidth(20*ww);
79 connect(_casterHostComboBox, SIGNAL(currentIndexChanged(const QString&)),
80 this, SLOT(slotCasterHostChanged(const QString&)));
81 bncSettings settings;
82 settings.remove("casterHostList");
83 settings.remove("casterHost");
84 settings.remove("casterPort");
85 settings.remove("casterUser");
86 settings.remove("casterPassword");
87 QStringList casterUrlList = settings.value("casterUrlList").toStringList();
88 for (int ii = 0; ii < casterUrlList.count(); ii++) {
89 QUrl url(casterUrlList[ii]);
90 _casterHostComboBox->addItem(url.host());
91 }
92
93 _ntripVersionComboBox = new QComboBox();
94 _ntripVersionComboBox->addItems(QString("1,2,2s,R,U").split(","));
95 int kk = _ntripVersionComboBox->findText(settings.value("ntripVersion").toString());
96 if (kk != -1) {
97 _ntripVersionComboBox->setCurrentIndex(kk);
98 }
99 _ntripVersionComboBox->setMaximumWidth(5*ww);
100
101 _buttonCasterTable = new QPushButton(tr("Show"), this);
102 connect(_buttonCasterTable, SIGNAL(clicked()), this, SLOT(slotCasterTable()));
103 _buttonCasterTable->setMaximumWidth(6*ww);
104
105 // WhatsThis
106 // ---------
107 _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>"));
108 _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>"));
109 _casterPortLineEdit->setWhatsThis(tr("<p>Enter the Ntrip broadcaster port number.</p></p>Note that Ntrip Version 2 via SSL usually requires specifying port 443.</p>"));
110 _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."));
111
112 QGridLayout* editLayout = new QGridLayout;
113 editLayout->addWidget(new QLabel(tr("Caster host")), 0, 0);
114 editLayout->addWidget(_casterHostComboBox, 0, 1);
115 editLayout->addWidget(new QLabel(tr(" Caster port")), 0, 2, Qt::AlignRight);
116 editLayout->addWidget(_casterPortLineEdit, 0, 3);
117 editLayout->addWidget(new QLabel(tr("Casters table")), 0, 4, Qt::AlignRight);
118 editLayout->addWidget(_buttonCasterTable, 0, 5);
119 editLayout->addWidget(new QLabel(tr("User")), 1, 0, Qt::AlignRight);
120 editLayout->addWidget(_casterUserLineEdit, 1, 1);
121 editLayout->addWidget(new QLabel(tr("Password")), 1, 2, Qt::AlignRight);
122 editLayout->addWidget(_casterPasswordLineEdit, 1, 3);
123 editLayout->addWidget(new QLabel(tr(" Ntrip Version")),1, 4, Qt::AlignRight);
124 editLayout->addWidget(_ntripVersionComboBox, 1, 5);
125
126 mainLayout->addLayout(editLayout);
127
128 _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>"));
129 _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; 2s:&nbsp; Ntrip version 2 TCP/IP mode via SSL (usually port 443)<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>"));
130
131 _table = new QTableWidget(this);
132 _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, or RTCM Version 3.x 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>"));
133 connect(_table, SIGNAL(itemSelectionChanged()),
134 this, SLOT(slotSelectionChanged()));
135 mainLayout->addWidget(_table);
136
137 _buttonWhatsThis = new QPushButton(tr("Help=Shift+F1"), this);
138 connect(_buttonWhatsThis, SIGNAL(clicked()), this, SLOT(slotWhatsThis()));
139
140 _buttonGet = new QPushButton(tr("Get table"), this);
141 _buttonGet->setDefault(true);
142 connect(_buttonGet, SIGNAL(clicked()), this, SLOT(slotGetTable()));
143
144 _buttonMap = new QPushButton(tr("Map"), this);
145 _buttonMap->setEnabled(false);
146 connect(_buttonMap, SIGNAL(clicked()), this, SLOT(slotShowMap()));
147
148 _buttonClose = new QPushButton(tr("Close"), this);
149 connect(_buttonClose, SIGNAL(clicked()), this, SLOT(close()));
150
151 _buttonSelect = new QPushButton(tr("Select"), this);
152 connect(_buttonSelect, SIGNAL(clicked()), this, SLOT(select()));
153
154 // WhatsThis
155 // ---------
156 _buttonMap->setWhatsThis(tr("<p>Draw distribution map of streams in downloaded caster source-table.</p>"));
157 _buttonGet->setWhatsThis(tr("<p>Download source-table from specified caster.</p>"));
158 _buttonClose->setWhatsThis(tr("<p>Close window.</p>"));
159 _buttonSelect->setWhatsThis(tr("<p>Select streams highlighted in downloaded source-table for processing.</p>"));
160
161 QHBoxLayout* buttonLayout = new QHBoxLayout;
162 buttonLayout->addWidget(_buttonWhatsThis);
163 buttonLayout->addStretch(1);
164 buttonLayout->addWidget(_buttonMap);
165 buttonLayout->addWidget(_buttonGet);
166 buttonLayout->addWidget(_buttonSelect);
167 buttonLayout->addWidget(_buttonClose);
168
169 mainLayout->addLayout(buttonLayout);
170}
171
172// Destructor
173////////////////////////////////////////////////////////////////////////////
174bncTableDlg::~bncTableDlg() {
175 delete _casterHostComboBox;
176 delete _casterPortLineEdit;
177 delete _casterUserLineEdit;
178 delete _casterPasswordLineEdit;
179 bncSettings settings;
180 settings.setValue("ntripVersion", _ntripVersionComboBox->currentText());
181 delete _ntripVersionComboBox;
182 delete _buttonMap;
183 delete _buttonGet;
184 delete _buttonClose;
185 delete _buttonSelect;
186 delete _buttonWhatsThis;
187 delete _buttonCasterTable;
188 delete _table;
189}
190
191// Read full caster table (static)
192////////////////////////////////////////////////////////////////////////////
193t_irc bncTableDlg::getFullTable(const QString& ntripVersion,
194 const QString& casterHost,
195 int casterPort, QStringList& allLines,
196 bool alwaysRead) {
197
198 static QMutex mutex;
199 static QMap<QString, QStringList> allTables;
200
201 QMutexLocker locker(&mutex);
202
203 if (!alwaysRead && allTables.find(casterHost) != allTables.end()) {
204 allLines = allTables.find(casterHost).value();
205 return success;
206 }
207
208 allLines.clear();
209
210 bncNetQuery* query = 0;
211 if (ntripVersion == "2") {
212 query = new bncNetQueryV2(false);
213 }
214 else if (ntripVersion == "2s") {
215 query = new bncNetQueryV2(true);
216 }
217 else {
218 query = new bncNetQueryV1();
219 }
220
221 QUrl url;
222 url.setHost(casterHost);
223 url.setPort(casterPort);
224 url.setPath("/");
225 if (ntripVersion == "2s") {
226 url.setScheme("https");
227 }
228 else {
229 url.setScheme("http");
230 }
231
232 QByteArray outData;
233 query->waitForRequestResult(url, outData);
234 if (query->status() == bncNetQuery::finished) {
235 QTextStream in(outData);
236 QString line = in.readLine();
237 while ( !line.isNull() ) {
238 allLines.append(line);
239 line = in.readLine();
240 }
241 allTables.insert(casterHost, allLines);
242 delete query;
243 return success;
244 }
245 else {
246 delete query;
247 return failure;
248 }
249}
250
251// Read Table from Caster
252////////////////////////////////////////////////////////////////////////////
253void bncTableDlg::slotGetTable() {
254
255 _buttonGet->setEnabled(false);
256 _buttonMap->setEnabled(true);
257 _buttonCasterTable->setEnabled(false);
258
259 if ( getFullTable(_ntripVersionComboBox->currentText(),
260 _casterHostComboBox->currentText(),
261 _casterPortLineEdit->text().toInt(),
262 _allLines, true) != success ) {
263 QMessageBox::warning(0, "BNC", "Cannot retrieve table of data");
264 _buttonGet->setEnabled(true);
265 return;
266 }
267
268 static const QStringList labels = QString("mountpoint,identifier,format,"
269 "format-details,carrier,system,network,country,lat,long,"
270 "nmea,solution,generator,compress.,auth.,fee,bitrate,"
271 "misc").split(",");
272
273 QStringList lines;
274 QStringListIterator it(_allLines);
275 while (it.hasNext()) {
276 QString line = it.next();
277 if (line.indexOf("STR") == 0) {
278 QStringList hlp = line.split(";");
279 if (hlp.size() > labels.size()) {
280 lines.push_back(line);
281 }
282 }
283 }
284
285 if (lines.size() > 0) {
286 _table->setSelectionMode(QAbstractItemView::ExtendedSelection);
287 _table->setSelectionBehavior(QAbstractItemView::SelectRows);
288 _table->setColumnCount(labels.size());
289 _table->setRowCount(lines.size());
290 for (int nRow = 0; nRow < lines.size(); nRow++) {
291 QStringList columns = lines[nRow].split(";");
292 for (int ic = 1; ic < columns.size(); ic++) {
293 if (ic == 11) {
294 if (columns[ic] == "0") {
295 columns[ic] = "no";
296 } else {
297 columns[ic] = "yes";
298 }
299 }
300 QTableWidgetItem* item = new QTableWidgetItem(columns[ic]);
301 item->setFlags(item->flags() & ~Qt::ItemIsEditable);
302 _table->setItem(nRow, ic-1, item);
303 }
304 }
305 _table->setHorizontalHeaderLabels(labels);
306 _table->setSortingEnabled(true);
307 int ww = QFontMetrics(this->font()).width('w');
308 _table->horizontalHeader()->resizeSection( 0,10*ww);
309 _table->horizontalHeader()->resizeSection( 1,10*ww);
310 _table->horizontalHeader()->resizeSection( 2, 8*ww);
311 _table->horizontalHeader()->resizeSection( 3,22*ww);
312 _table->horizontalHeader()->resizeSection( 4, 5*ww);
313 _table->horizontalHeader()->resizeSection( 5, 8*ww);
314 _table->horizontalHeader()->resizeSection( 6, 8*ww);
315 _table->horizontalHeader()->resizeSection( 7, 7*ww);
316 _table->horizontalHeader()->resizeSection( 8, 6*ww);
317 _table->horizontalHeader()->resizeSection( 9, 6*ww);
318 _table->horizontalHeader()->resizeSection(10, 6*ww);
319 _table->horizontalHeader()->resizeSection(11, 6*ww);
320 _table->horizontalHeader()->resizeSection(12,15*ww);
321 _table->horizontalHeader()->resizeSection(13, 8*ww);
322 _table->horizontalHeader()->resizeSection(14, 5*ww);
323 _table->horizontalHeader()->resizeSection(15, 5*ww);
324 _table->horizontalHeader()->resizeSection(16, 7*ww);
325 _table->horizontalHeader()->resizeSection(17,15*ww);
326 _table->sortItems(0);
327 }
328}
329
330// Show world map
331////////////////////////////////////////////////////////////////////////////
332void bncTableDlg::slotShowMap() {
333
334 t_bncMap* bncMap = new t_bncMap(this);
335
336 bncMap->setMinimumSize(800, 600);
337
338 for (int ii = 0; ii < _allLines.size(); ii++) {
339 if (_allLines.at(ii).startsWith("STR") == true) {
340 QStringList tmp = _allLines.at(ii).split(';');
341 if (tmp.size() > 10) {
342 double latDeg = tmp.at(9).toDouble();
343 double lonDeg = tmp.at(10).toDouble();
344 QString name = tmp.at(1);
345 bncMap->slotNewPoint(name, latDeg, lonDeg);
346 }
347 }
348 }
349
350 bncMap->show();
351}
352
353// Select slot
354////////////////////////////////////////////////////////////////////////////
355void bncTableDlg::select() {
356
357 QString ntripVersion = _ntripVersionComboBox->currentText();
358
359 QUrl url;
360 if (ntripVersion == "2s") {
361 url.setScheme("https");
362 }
363 else {
364 url.setScheme("http");
365 }
366 url.setHost(_casterHostComboBox->currentText());
367 url.setPort(_casterPortLineEdit->text().toInt());
368 url.setUserName(QUrl::toPercentEncoding(_casterUserLineEdit->text()));
369 url.setPassword(QUrl::toPercentEncoding(_casterPasswordLineEdit->text()));
370 addUrl(url);
371
372 QStringList* mountPoints = new QStringList;
373 if (_table) {
374 for (int ir = 0; ir < _table->rowCount(); ir++) {
375 QTableWidgetItem* item = _table->item(ir,0);
376 QString site = _table->item(ir,0)->text();
377 QString format = _table->item(ir,2)->text();
378 QString country = _table->item(ir,7)->text();
379 QString latitude = _table->item(ir,8)->text();
380 QString longitude = _table->item(ir,9)->text();
381 QString nmea = _table->item(ir,10)->text();
382 format.replace(" ", "_");
383 if (_table->isItemSelected(item)) {
384 url.setPath(item->text());
385 mountPoints->push_back(url.toString() + " " + format + " " + country + " " + latitude
386 + " " + longitude + " " + nmea + " " + ntripVersion);
387
388 site.resize(4);
389 }
390 }
391 }
392 emit newMountPoints(mountPoints);
393}
394
395// User changed the selection of mountPoints
396////////////////////////////////////////////////////////////////////////////
397void bncTableDlg::slotSelectionChanged() {
398 if (_table->selectedItems().isEmpty()) {
399 }
400}
401
402// Whats This Help
403void bncTableDlg::slotWhatsThis() {
404QWhatsThis::enterWhatsThisMode();
405}
406
407// Slot caster table
408////////////////////////////////////////////////////////////////////////////
409void bncTableDlg::slotCasterTable() {
410
411 _buttonCasterTable->setEnabled(false);
412 _casterHostComboBox->setEnabled(false);
413 _casterPortLineEdit->setEnabled(false);
414 _casterUserLineEdit->setEnabled(false);
415 _casterPasswordLineEdit->setEnabled(false);
416 _ntripVersionComboBox->setEnabled(false);
417 _buttonWhatsThis->setEnabled(false);
418 _buttonGet->setEnabled(false);
419 _buttonClose->setEnabled(false);
420 _buttonSelect->setEnabled(false);
421
422 bncCasterTableDlg* dlg =
423 new bncCasterTableDlg(_ntripVersionComboBox->currentText(), this);
424 dlg->move(this->pos().x()+50, this->pos().y()+50);
425 connect(dlg, SIGNAL(newCaster(QString, QString)),
426 this, SLOT(slotNewCaster(QString, QString)));
427 dlg->exec();
428 delete dlg;
429
430 _buttonCasterTable->setEnabled(true);
431 _casterHostComboBox->setEnabled(true);
432 _casterPortLineEdit->setEnabled(true);
433 _casterUserLineEdit->setEnabled(true);
434 _casterPasswordLineEdit->setEnabled(true);
435 _ntripVersionComboBox->setEnabled(true);
436 _buttonWhatsThis->setEnabled(true);
437 _buttonGet->setEnabled(true);
438 _buttonClose->setEnabled(true);
439 _buttonSelect->setEnabled(true);
440
441}
442
443// New caster selected
444////////////////////////////////////////////////////////////////////////////
445void bncTableDlg::slotNewCaster(QString newCasterHost, QString newCasterPort) {
446
447 _casterHostComboBox->insertItem(0, newCasterHost);
448 _casterHostComboBox->setCurrentIndex(0);
449 _casterUserLineEdit->setText("");
450 _casterPasswordLineEdit->setText("");
451 _casterPortLineEdit->setText(newCasterPort);
452
453 QString ntripVersion = _ntripVersionComboBox->currentText();
454
455 QUrl url;
456 if (ntripVersion == "2s") {
457 url.setScheme("https");
458 }
459 else {
460 url.setScheme("http");
461 }
462 url.setHost(newCasterHost);
463 url.setPort(newCasterPort.toInt());
464 addUrl(url);
465
466 _casterHostComboBox->setCurrentIndex(0);
467}
468
469// New caster selected
470////////////////////////////////////////////////////////////////////////////
471void bncTableDlg::addUrl(const QUrl& url) {
472 bncSettings settings;
473 QStringList oldUrlList = settings.value("casterUrlList").toStringList();
474 QStringList newUrlList;
475 newUrlList << url.toString();
476 for (int ii = 0; ii < oldUrlList.count(); ii++) {
477 QUrl oldUrl(oldUrlList[ii]);
478 if (url.host() != oldUrl.host()) {
479 newUrlList << oldUrl.toString();
480 }
481 }
482 settings.setValue("casterUrlList", newUrlList);
483}
484
485// New caster selected in combobox
486////////////////////////////////////////////////////////////////////////////
487void bncTableDlg::slotCasterHostChanged(const QString& newHost) {
488 bncSettings settings;
489 QStringList casterUrlList = settings.value("casterUrlList").toStringList();
490 for (int ii = 0; ii < casterUrlList.count(); ii++) {
491 QUrl url(casterUrlList[ii]);
492 if (url.host() == newHost) {
493 _casterUserLineEdit->setText(
494 QUrl::fromPercentEncoding(url.userName().toAscii()));
495 _casterPasswordLineEdit->setText(
496 QUrl::fromPercentEncoding(url.password().toAscii()));
497 if (url.port() > 0) {
498 _casterPortLineEdit->setText(QString("%1").arg(url.port()));
499 }
500 else {
501 _casterPortLineEdit->setText("");
502 }
503 }
504 }
505}
506
507// Caster table
508////////////////////////////////////////////////////////////////////////////
509bncCasterTableDlg::bncCasterTableDlg(const QString& ntripVersion,
510 QWidget* parent) :
511 QDialog(parent) {
512
513 static const QStringList labels = QString("host,port,identifier,operator,nmea,country,lat,long,link").split(",");
514
515 _casterTable = new QTableWidget(this);
516
517 QUrl url;
518 url.setHost("www.rtcm-ntrip.org");
519 url.setPath("/");
520 if (ntripVersion == "2s") {
521 url.setPort(443);
522 url.setScheme("https");
523 }
524 else {
525 url.setPort(2101);
526 url.setScheme("http");
527 }
528
529 bncNetQuery* query = 0;
530 if (ntripVersion == "2") {
531 query = new bncNetQueryV2(false);
532 }
533 else if (ntripVersion == "2s") {
534 query = new bncNetQueryV2(true);
535 }
536 else {
537 query = new bncNetQueryV1();
538 }
539
540 QByteArray outData;
541 query->waitForRequestResult(url, outData);
542
543 QStringList lines;
544 if (query->status() == bncNetQuery::finished) {
545 QTextStream in(outData);
546 QString line = in.readLine();
547 while ( !line.isNull() ) {
548 line = in.readLine();
549 if (line.indexOf("CAS") == 0) {
550 QStringList hlp = line.split(";");
551 if (hlp.size() > labels.size()) {
552 lines.push_back(line);
553 }
554 }
555 }
556 }
557
558 delete query;
559
560 if (lines.size() > 0) {
561 _casterTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
562 _casterTable->setSelectionBehavior(QAbstractItemView::SelectRows);
563
564 QStringList hlp = lines[0].split(";");
565 _casterTable->setColumnCount(labels.size());
566 _casterTable->setRowCount(lines.size());
567
568 for (int nRow = 0; nRow < lines.size(); nRow++) {
569 QStringList columns = lines[nRow].split(";");
570 for (int ic = 1; ic < columns.size(); ic++) {
571 if (ic == 5) {
572 if (columns[ic] == "0") {
573 columns[ic] = "no";
574 } else {
575 columns[ic] = "yes";
576 }
577 }
578 QTableWidgetItem* item = new QTableWidgetItem(columns[ic]);
579 item->setFlags(item->flags() & ~Qt::ItemIsEditable);
580 _casterTable->setItem(nRow, ic-1, item);
581 }
582 }
583 }
584 _casterTable->setHorizontalHeaderLabels(labels);
585 _casterTable->setSortingEnabled(true);
586 _casterTable->sortItems(0);
587 int ww = QFontMetrics(this->font()).width('w');
588 _casterTable->horizontalHeader()->resizeSection(0,15*ww);
589 _casterTable->horizontalHeader()->resizeSection(1, 5*ww);
590 _casterTable->horizontalHeader()->resizeSection(2,15*ww);
591 _casterTable->horizontalHeader()->resizeSection(3,15*ww);
592 _casterTable->horizontalHeader()->resizeSection(4, 5*ww);
593 _casterTable->horizontalHeader()->resizeSection(5, 7*ww);
594 _casterTable->horizontalHeader()->resizeSection(6, 7*ww);
595 _casterTable->horizontalHeader()->resizeSection(7, 7*ww);
596 _casterTable->horizontalHeader()->resizeSection(8,15*ww);
597
598 _closeButton = new QPushButton("Cancel");
599 connect(_closeButton, SIGNAL(clicked()), this, SLOT(close()));
600 _closeButton->setMinimumWidth(8*ww);
601 _closeButton->setMaximumWidth(8*ww);
602
603 _okButton = new QPushButton(tr("OK"), this);
604 connect(_okButton, SIGNAL(clicked()), this, SLOT(slotAcceptCasterTable()));
605 _okButton->setMinimumWidth(8*ww);
606 _okButton->setMaximumWidth(8*ww);
607
608 _whatsThisButton = new QPushButton(tr("Help=Shift+F1"), this);
609 connect(_whatsThisButton, SIGNAL(clicked()), this, SLOT(slotWhatsThis()));
610 _whatsThisButton->setMinimumWidth(12*ww);
611 _whatsThisButton->setMaximumWidth(12*ww);
612
613 _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>."));
614
615 QGridLayout* dlgLayout = new QGridLayout();
616 dlgLayout->addWidget(new QLabel(" List of Ntrip Broadcasters from www.rtcm-ntrip.org"), 0,0,1,3,Qt::AlignLeft);
617 dlgLayout->addWidget(_casterTable, 1, 0, 1, 3);
618 dlgLayout->addWidget(_whatsThisButton, 2, 0);
619 dlgLayout->addWidget(_closeButton, 2, 1, Qt::AlignRight);
620 dlgLayout->addWidget(_okButton, 2, 2);
621
622 setMinimumSize(600,400);
623 setWindowTitle(tr("Select Broadcaster"));
624 setLayout(dlgLayout);
625 resize(68*ww, 50*ww);
626 show();
627}
628
629// Caster table destructor
630////////////////////////////////////////////////////////////////////////////
631bncCasterTableDlg::~bncCasterTableDlg() {
632 delete _casterTable;
633 delete _okButton;
634 delete _closeButton;
635 delete _whatsThisButton;
636}
637
638// Caster table what's this
639////////////////////////////////////////////////////////////////////////////
640void bncCasterTableDlg:: slotWhatsThis() {
641 QWhatsThis::enterWhatsThisMode();
642}
643
644// Accept caster table
645////////////////////////////////////////////////////////////////////////////
646void bncCasterTableDlg::slotAcceptCasterTable() {
647 if (_casterTable) {
648 for (int ir = _casterTable->rowCount() - 1; ir >= 0 ; ir--) {
649 if (_casterTable->isItemSelected(_casterTable->item(ir,0))) {
650 emit newCaster(_casterTable->item(ir,0)->text(),
651 _casterTable->item(ir,1)->text());
652 }
653 }
654 }
655 QDialog::accept();
656}
Note: See TracBrowser for help on using the repository browser.