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

Last change on this file since 1488 was 1488, checked in by mervart, 15 years ago

* empty log message *

File size: 21.9 KB
RevLine 
[280]1// Part of BNC, a utility for retrieving decoding and
[464]2// converting GNSS data streams from NTRIP broadcasters.
[280]3//
[464]4// Copyright (C) 2007
[280]5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
[464]7// Czech Technical University Prague, Department of Geodesy
[280]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.
[35]24
25/* -------------------------------------------------------------------------
[93]26 * BKG NTRIP Client
[35]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 "bnctabledlg.h"
42#include "bncgetthread.h"
[1387]43#include "bncnetqueryv2.h"
[35]44
[1373]45using namespace std;
46
[35]47// Constructor
48////////////////////////////////////////////////////////////////////////////
[90]49bncTableDlg::bncTableDlg(QWidget* parent) : QDialog(parent) {
[35]50
51 setMinimumSize(600,400);
[1409]52 setWindowTitle(tr("Add Streams"));
[35]53
54 QVBoxLayout* mainLayout = new QVBoxLayout(this);
55
[1474]56 int ww = QFontMetrics(font()).width('w');
57
58 _casterPortLineEdit = new QLineEdit();
59 _casterPortLineEdit->setMaximumWidth(9*ww);
60
61 _casterUserLineEdit = new QLineEdit();
62 _casterUserLineEdit->setMaximumWidth(9*ww);
63
64 _casterPasswordLineEdit = new QLineEdit();
65 _casterPasswordLineEdit->setMaximumWidth(9*ww);
66 _casterPasswordLineEdit->setEchoMode(QLineEdit::Password);
67
68 _casterHostComboBox = new QComboBox();
[1482]69 _casterHostComboBox->setMaxCount(10);
[1474]70 _casterHostComboBox->setDuplicatesEnabled(false);
71 _casterHostComboBox->setEditable(true);
[1477]72 _casterHostComboBox->setMinimumWidth(20*ww);
[1474]73 _casterHostComboBox->setMaximumWidth(20*ww);
74 connect(_casterHostComboBox, SIGNAL(currentIndexChanged(const QString&)),
75 this, SLOT(slotCasterHostChanged(const QString&)));
[1476]76 QSettings settings;
[1481]77 settings.remove("casterHostList");
78 settings.remove("casterHost");
79 settings.remove("casterPort");
80 settings.remove("casterUser");
81 settings.remove("casterPassword");
[1476]82 QStringList casterUrlList = settings.value("casterUrlList").toStringList();
83 for (int ii = 0; ii < casterUrlList.count(); ii++) {
84 QUrl url(casterUrlList[ii]);
[1474]85 _casterHostComboBox->addItem(url.host());
[1274]86 }
[683]87
[1350]88 _ntripVersionComboBox = new QComboBox();
[1410]89 _ntripVersionComboBox->addItems(QString("1,2,R").split(","));
[1350]90 int kk = _ntripVersionComboBox->findText(settings.value("ntripVersion").toString());
91 if (kk != -1) {
92 _ntripVersionComboBox->setCurrentIndex(kk);
93 }
[1459]94 _ntripVersionComboBox->setMaximumWidth(5*ww);
[1350]95
[1459]96 _buttonCasterTable = new QPushButton(tr("Show"), this);
97 connect(_buttonCasterTable, SIGNAL(clicked()), this, SLOT(slotCasterTable()));
98 _buttonCasterTable->setMaximumWidth(5*ww);
99
[683]100 // WhatsThis
101 // ---------
[1459]102 _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>"));
[1474]103 _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>"));
[1459]104 _casterPortLineEdit->setWhatsThis(tr("Enter the NTRIP broadcaster port number."));
105 _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."));
[35]106
[88]107 QGridLayout* editLayout = new QGridLayout;
[1459]108 editLayout->addWidget(new QLabel(tr("Caster host")), 0, 0);
[1474]109 editLayout->addWidget(_casterHostComboBox, 0, 1);
[1459]110 editLayout->addWidget(new QLabel(tr(" Caster port")), 0, 2, Qt::AlignRight);
111 editLayout->addWidget(_casterPortLineEdit, 0, 3);
112 editLayout->addWidget(new QLabel(tr("Caster table")), 0, 4, Qt::AlignRight);
113 editLayout->addWidget(_buttonCasterTable, 0, 5);
114 editLayout->addWidget(new QLabel(tr("User")), 1, 0, Qt::AlignRight);
115 editLayout->addWidget(_casterUserLineEdit, 1, 1);
116 editLayout->addWidget(new QLabel(tr("Password")), 1, 2, Qt::AlignRight);
117 editLayout->addWidget(_casterPasswordLineEdit, 1, 3);
118 editLayout->addWidget(new QLabel(tr(" NTRIP Version")),1, 4, Qt::AlignRight);
119 editLayout->addWidget(_ntripVersionComboBox, 1, 5);
[88]120
[35]121 mainLayout->addLayout(editLayout);
122
[1471]123 _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>"));
[1466]124 _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>Select option '1' if you are not sure whether the NTRIP broadcaster supports NTRIP version 2.</p><p>Note that RTSP/RTP (option 'R') is sometimes not supported by mobile Internet Service Providers.</p>"));
[1409]125
[35]126 _table = new QTableWidget(this);
[1459]127 _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>"));
[195]128 connect(_table, SIGNAL(itemSelectionChanged()),
129 this, SLOT(slotSelectionChanged()));
[35]130 mainLayout->addWidget(_table);
131
[402]132 _buttonWhatsThis = new QPushButton(tr("Help=Shift+F1"), this);
[399]133 connect(_buttonWhatsThis, SIGNAL(clicked()), this, SLOT(slotWhatsThis()));
134
[195]135 _buttonGet = new QPushButton(tr("Get table"), this);
[399]136 _buttonGet->setDefault(true);
[35]137 connect(_buttonGet, SIGNAL(clicked()), this, SLOT(slotGetTable()));
[366]138
[35]139 _buttonCancel = new QPushButton(tr("Cancel"), this);
140 connect(_buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
141
142 _buttonOK = new QPushButton(tr("OK"), this);
143 connect(_buttonOK, SIGNAL(clicked()), this, SLOT(accept()));
144
145 QHBoxLayout* buttonLayout = new QHBoxLayout;
[399]146 buttonLayout->addWidget(_buttonWhatsThis);
[35]147 buttonLayout->addStretch(1);
148 buttonLayout->addWidget(_buttonGet);
149 buttonLayout->addWidget(_buttonCancel);
150 buttonLayout->addWidget(_buttonOK);
151
152 mainLayout->addLayout(buttonLayout);
153}
154
155// Destructor
156////////////////////////////////////////////////////////////////////////////
157bncTableDlg::~bncTableDlg() {
158 if (_table) {
159 for (int ir = 0; ir < _table->rowCount(); ir++) {
160 for (int ic = 0; ic < _table->columnCount(); ic++) {
161 delete _table->item(ir,ic);
162 }
163 }
164 }
165}
166
[191]167// Read Table the caster (static)
[35]168////////////////////////////////////////////////////////////////////////////
[191]169t_irc bncTableDlg::getFullTable(const QString& casterHost,
[1376]170 int casterPort, QStringList& allLines,
171 bool alwaysRead) {
[35]172
[299]173 static QMutex mutex;
[298]174 static QMap<QString, QStringList> allTables;
175
[299]176 QMutexLocker locker(&mutex);
177
[298]178 if (!alwaysRead && allTables.find(casterHost) != allTables.end()) {
179 allLines = allTables.find(casterHost).value();
180 return success;
181 }
182
[191]183 allLines.clear();
184
[88]185 QUrl url;
[191]186 url.setHost(casterHost);
187 url.setPort(casterPort);
[1375]188 url.setScheme("http");
189 url.setPath("/");
[35]190
[1387]191 bncNetQueryV2 query;
[1373]192 QByteArray outData;
[1375]193 query.waitForRequestResult(url, outData);
194 if (query.status() == bncNetQuery::finished) {
195 QTextStream in(outData);
196 QString line = in.readLine();
197 while ( !line.isNull() ) {
198 allLines.append(line);
199 line = in.readLine();
200 }
201 allTables.insert(casterHost, allLines);
202 return success;
203 }
204 else {
[191]205 return failure;
[35]206 }
[191]207}
208
209// Read Table from Caster
210////////////////////////////////////////////////////////////////////////////
211void bncTableDlg::slotGetTable() {
212
[555]213 _buttonGet->setEnabled(false);
[1459]214 _buttonCasterTable->setEnabled(false);
[555]215
[196]216 _allLines.clear();
[191]217
[1474]218 if ( getFullTable(_casterHostComboBox->currentText(),
[191]219 _casterPortLineEdit->text().toInt(),
[196]220 _allLines) != success ) {
[191]221 QMessageBox::warning(0, "BNC", "Cannot retrieve table of data");
[645]222 _buttonGet->setEnabled(true);
[191]223 return;
224 }
225
226 QStringList lines;
[196]227 QStringListIterator it(_allLines);
[1470]228 int endSourceTable = 1;
[191]229 while (it.hasNext()) {
230 QString line = it.next();
[1470]231 if ((endSourceTable == 1 ) && line.indexOf("ENDSOURCETABLE") == 0) {
232 endSourceTable = 0;
233 }
[191]234 if (line.indexOf("STR") == 0) {
235 lines.push_back(line);
236 }
237 }
238
[103]239 static const QStringList labels = QString("mountpoint,identifier,format,"
[1465]240 "format-details,carrier,system,network,country,lat,long,"
241 "nmea,solution,generator,compress.,auth.,fee,bitrate,"
[103]242 "misc").split(",");
243
[191]244 if (lines.size() > 0) {
[35]245 _table->setSelectionMode(QAbstractItemView::ExtendedSelection);
246 _table->setSelectionBehavior(QAbstractItemView::SelectRows);
247
[191]248 QStringList hlp = lines[0].split(";");
[35]249 _table->setColumnCount(hlp.size()-1);
[1470]250 _table->setRowCount(lines.size() - endSourceTable);
[35]251
[191]252 QListIterator<QString> it(lines);
[35]253 int nRow = -1;
254 while (it.hasNext()) {
255 QStringList columns = it.next().split(";");
256 ++nRow;
257 for (int ic = 0; ic < columns.size()-1; ic++) {
[366]258
[410]259 if (ic+1 == 11) { if (columns[ic+1] == "0") { columns[ic+1] = "no"; } else { columns[ic+1] = "yes"; }}
[366]260
[107]261 QTableWidgetItem* it = new QTableWidgetItem(columns[ic+1]);
[115]262 it->setFlags(it->flags() & ~Qt::ItemIsEditable);
[107]263 _table->setItem(nRow, ic, it);
[35]264 }
265 }
[83]266 _table->sortItems(0);
[103]267 _table->setHorizontalHeaderLabels(labels);
[104]268 _table->setSortingEnabled(true);
[371]269
270 int ww = QFontMetrics(this->font()).width('w');
[375]271 _table->horizontalHeader()->resizeSection(0,10*ww);
[1465]272 _table->horizontalHeader()->resizeSection(1,10*ww);
[371]273 _table->horizontalHeader()->resizeSection(2,8*ww);
[1465]274 _table->horizontalHeader()->resizeSection(3,22*ww);
275 _table->horizontalHeader()->resizeSection(4,5*ww);
[371]276 _table->horizontalHeader()->resizeSection(5,8*ww);
277 _table->horizontalHeader()->resizeSection(6,8*ww);
[1465]278 _table->horizontalHeader()->resizeSection(7,7*ww);
279 _table->horizontalHeader()->resizeSection(8,6*ww);
280 _table->horizontalHeader()->resizeSection(9,6*ww);
281 _table->horizontalHeader()->resizeSection(10,6*ww);
282 _table->horizontalHeader()->resizeSection(11,6*ww);
[371]283 _table->horizontalHeader()->resizeSection(12,15*ww);
284 _table->horizontalHeader()->resizeSection(13,8*ww);
[1465]285 _table->horizontalHeader()->resizeSection(14,5*ww);
286 _table->horizontalHeader()->resizeSection(15,5*ww);
287 _table->horizontalHeader()->resizeSection(16,7*ww);
[371]288 _table->horizontalHeader()->resizeSection(17,15*ww);
[35]289 }
290}
291
292// Accept slot
293////////////////////////////////////////////////////////////////////////////
294void bncTableDlg::accept() {
295
[1477]296 QSettings settings;
297 settings.setValue("ntripVersion", _ntripVersionComboBox->currentText());
[1476]298 QUrl url;
[1478]299 url.setScheme("http");
[1476]300 url.setHost(_casterHostComboBox->currentText());
301 url.setPort(_casterPortLineEdit->text().toInt());
302 url.setUserName(_casterUserLineEdit->text());
303 url.setPassword(_casterPasswordLineEdit->text());
[1477]304 addUrl(url);
[1476]305
[35]306 QStringList* mountPoints = new QStringList;
307
308 if (_table) {
309 for (int ir = 0; ir < _table->rowCount(); ir++) {
[59]310 QTableWidgetItem* item = _table->item(ir,0);
311 QString format = _table->item(ir,2)->text();
[366]312 QString latitude = _table->item(ir,8)->text();
313 QString longitude = _table->item(ir,9)->text();
314 QString nmea = _table->item(ir,10)->text();
[1351]315 QString ntripVersion = _ntripVersionComboBox->currentText();
[59]316 format.replace(" ", "_");
[35]317 if (_table->isItemSelected(item)) {
318 url.setPath(item->text());
[1351]319 mountPoints->push_back(url.toString() + " " + format + " " + latitude
320 + " " + longitude + " " + nmea + " " + ntripVersion);
[35]321 }
322 }
323 }
324 emit newMountPoints(mountPoints);
325
326 QDialog::accept();
327}
[195]328
329// User changed the selection of mountPoints
330////////////////////////////////////////////////////////////////////////////
331void bncTableDlg::slotSelectionChanged() {
332 if (_table->selectedItems().isEmpty()) {
333 }
334}
335
[196]336// Create RINEX skeleton header
[195]337////////////////////////////////////////////////////////////////////////////
338void bncTableDlg::slotSkl() {
339
[196]340 int nRows = _table->rowCount();
341 for (int iRow = 0; iRow < nRows; iRow++) {
342 if (_table->isItemSelected(_table->item(iRow,1))) {
343 QString staID = _table->item(iRow,0)->text();
344 QString net = _table->item(iRow,6)->text();
[195]345
[196]346 QString ftpDir;
347 QStringListIterator it(_allLines);
348 while (it.hasNext()) {
349 QString line = it.next();
350 if (line.indexOf("NET") == 0) {
351 QStringList tags = line.split(';');
352 if (tags.at(1) == net) {
353 ftpDir = tags.at(6);
354 break;
355 }
356 }
357 }
358
[197]359 if (!ftpDir.isEmpty()) {
360 QUrl url(ftpDir);
361 QMessageBox::warning(0, "Warning", url.host() + "\n" + url.path() +
362 "\nnot yet implemented");
363 }
[196]364 }
365 }
[197]366}
[196]367
[399]368// Whats This Help
369void bncTableDlg::slotWhatsThis() {
370QWhatsThis::enterWhatsThisMode();
371}
372
[1459]373// Slot caster table
374////////////////////////////////////////////////////////////////////////////
375void bncTableDlg::slotCasterTable() {
376
377 _buttonCasterTable->setEnabled(false);
[1474]378 _casterHostComboBox->setEnabled(false);
[1461]379 _casterPortLineEdit->setEnabled(false);
380 _casterUserLineEdit->setEnabled(false);
381 _casterPasswordLineEdit->setEnabled(false);
382 _ntripVersionComboBox->setEnabled(false);
383 _buttonWhatsThis->setEnabled(false);
384 _buttonGet->setEnabled(false);
385 _buttonCancel->setEnabled(false);
386 _buttonOK->setEnabled(false);
387
[1459]388 bncCasterTableDlg* dlg = new bncCasterTableDlg(this);
389 dlg->move(this->pos().x()+50, this->pos().y()+50);
[1474]390 connect(dlg, SIGNAL(newCaster(QString, QString)),
391 this, SLOT(slotNewCaster(QString, QString)));
[1459]392 dlg->exec();
393 delete dlg;
[1461]394
[1459]395 _buttonCasterTable->setEnabled(true);
[1474]396 _casterHostComboBox->setEnabled(true);
[1461]397 _casterPortLineEdit->setEnabled(true);
398 _casterUserLineEdit->setEnabled(true);
399 _casterPasswordLineEdit->setEnabled(true);
400 _ntripVersionComboBox->setEnabled(true);
401 _buttonWhatsThis->setEnabled(true);
402 _buttonGet->setEnabled(true);
403 _buttonCancel->setEnabled(true);
404 _buttonOK->setEnabled(true);
[399]405
[1459]406}
407
408// Caster table
409////////////////////////////////////////////////////////////////////////////
410bncCasterTableDlg::bncCasterTableDlg(QWidget* parent) :
411 QDialog(parent) {
412
[1461]413 static const QStringList labels = QString("host,port,identifier,operator,nmea,country,lat,long,link").split(",");
[1459]414
415 QStringList lines;
416 lines.clear();
417 _casterTable = new QTableWidget(this);
418
419 QUrl url;
420 url.setHost("www.rtcm-ntrip.org");
421 url.setPort(2101);
422 url.setScheme("http");
423 url.setPath("/");
424
425 bncNetQueryV2 query;
426 QByteArray outData;
427 query.waitForRequestResult(url, outData);
[1470]428 int endSourceTable = 1;
[1459]429 if (query.status() == bncNetQuery::finished) {
430 QTextStream in(outData);
431 QString line = in.readLine();
432 while ( !line.isNull() ) {
433 line = in.readLine();
[1470]434 if ((endSourceTable == 1 ) && line.indexOf("ENDSOURCETABLE") == 0) {
435 endSourceTable = 0;
436 }
[1459]437 if (line.indexOf("CAS") == 0) {
438 lines.append(line);
439 }
440 }
441 }
442 if (lines.size() > 0) {
443 _casterTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
444 _casterTable->setSelectionBehavior(QAbstractItemView::SelectRows);
445
446 QStringList hlp = lines[0].split(";");
447 _casterTable->setColumnCount(hlp.size()-1);
[1470]448 _casterTable->setRowCount(lines.size() - endSourceTable);
[1459]449
450 QListIterator<QString> it(lines);
451 int nRow = -1;
452 while (it.hasNext()) {
453 QStringList columns = it.next().split(";");
454 ++nRow;
455 for (int ic = 0; ic < columns.size()-1; ic++) {
456 if (ic+1 == 5) { if (columns[ic+1] == "0") { columns[ic+1] = "no"; } else { columns[ic+1] = "yes"; }}
457 QTableWidgetItem* it = new QTableWidgetItem(columns[ic+1]);
458 it->setFlags(it->flags() & ~Qt::ItemIsEditable);
459 _casterTable->setItem(nRow, ic, it);
460 }
461 }
462 }
463 _casterTable->sortItems(0);
464 _casterTable->setHorizontalHeaderLabels(labels);
465 _casterTable->setSortingEnabled(true);
466
467 int ww = QFontMetrics(this->font()).width('w');
468 _casterTable->horizontalHeader()->resizeSection(0,15*ww);
469 _casterTable->horizontalHeader()->resizeSection(1,5*ww);
470 _casterTable->horizontalHeader()->resizeSection(2,15*ww);
471 _casterTable->horizontalHeader()->resizeSection(3,15*ww);
472 _casterTable->horizontalHeader()->resizeSection(4,5*ww);
473 _casterTable->horizontalHeader()->resizeSection(5,7*ww);
474 _casterTable->horizontalHeader()->resizeSection(6,7*ww);
475 _casterTable->horizontalHeader()->resizeSection(7,7*ww);
476 _casterTable->horizontalHeader()->resizeSection(8,15*ww);
477
478 ww = QFontMetrics(font()).width('w');
479
[1488]480 _closeButton = new QPushButton("Cancel");
[1459]481 connect(_closeButton, SIGNAL(clicked()), this, SLOT(close()));
482 _closeButton->setMinimumWidth(8*ww);
483 _closeButton->setMaximumWidth(8*ww);
484
[1488]485 _okButton = new QPushButton(tr("OK"), this);
[1459]486 connect(_okButton, SIGNAL(clicked()), this, SLOT(slotAcceptCasterTable()));
487 _okButton->setMinimumWidth(8*ww);
488 _okButton->setMaximumWidth(8*ww);
489
[1488]490 _whatsThisButton = new QPushButton(tr("Help=Shift+F1"), this);
491 connect(_whatsThisButton, SIGNAL(clicked()), this, SLOT(slotWhatsThis()));
492 _whatsThisButton->setMinimumWidth(12*ww);
493 _whatsThisButton->setMaximumWidth(12*ww);
[1459]494
[1471]495 _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>."));
[1459]496
497 QGridLayout* dlgLayout = new QGridLayout();
498 dlgLayout->addWidget(new QLabel(" List of NTRIP Broadcasters from www.rtcm-ntrip.org"), 0,0,1,3,Qt::AlignLeft);
[1488]499 dlgLayout->addWidget(_casterTable, 1, 0, 1, 3);
500 dlgLayout->addWidget(_whatsThisButton, 2, 0);
501 dlgLayout->addWidget(_closeButton, 2, 1, Qt::AlignRight);
502 dlgLayout->addWidget(_okButton, 2, 2);
[1459]503
504 setMinimumSize(600,400);
505 setWindowTitle(tr("Select Broadcaster"));
506 setLayout(dlgLayout);
507 resize(68*ww, 60*ww);
508 show();
509}
510
[1488]511// Caster table destructor
[1459]512////////////////////////////////////////////////////////////////////////////
[1488]513bncCasterTableDlg::~bncCasterTableDlg() {
514 delete _casterTable;
515 delete _okButton;
516 delete _closeButton;
517 delete _whatsThisButton;
[1459]518}
519
[1488]520// Caster table what's this
[1459]521////////////////////////////////////////////////////////////////////////////
[1488]522void bncCasterTableDlg:: slotWhatsThis() {
523 QWhatsThis::enterWhatsThisMode();
[1459]524}
525
526// Accept caster table
527////////////////////////////////////////////////////////////////////////////
528void bncCasterTableDlg::slotAcceptCasterTable() {
529 if (_casterTable) {
530 for (int ir = 0; ir < _casterTable->rowCount(); ir++) {
[1474]531 if (_casterTable->isItemSelected(_casterTable->item(ir,0))) {
532 emit newCaster(_casterTable->item(ir,0)->text(),
533 _casterTable->item(ir,1)->text());
[1459]534 }
535 }
536 }
[1474]537 QDialog::accept();
[1459]538}
539
540// New caster selected
541////////////////////////////////////////////////////////////////////////////
[1474]542void bncTableDlg::slotNewCaster(QString newCasterHost, QString newCasterPort) {
[1459]543
[1474]544 _casterHostComboBox->insertItem(0, newCasterHost);
[1479]545 _casterHostComboBox->setCurrentIndex(0);
[1474]546 _casterUserLineEdit->setText("");
547 _casterPortLineEdit->setText(newCasterPort);
[1475]548
[1476]549 QUrl url;
550 url.setScheme("http");
551 url.setHost(newCasterHost);
552 url.setPort(newCasterPort.toInt());
[1477]553 addUrl(url);
[1482]554
555 _casterHostComboBox->setCurrentIndex(0);
[1477]556}
[1476]557
[1477]558// New caster selected
559////////////////////////////////////////////////////////////////////////////
560void bncTableDlg::addUrl(const QUrl& url) {
[1475]561 QSettings settings;
[1477]562 QStringList oldUrlList = settings.value("casterUrlList").toStringList();
563 QStringList newUrlList;
[1483]564 newUrlList << url.toString();
[1477]565 for (int ii = 0; ii < oldUrlList.count(); ii++) {
566 QUrl oldUrl(oldUrlList[ii]);
[1483]567 if (url.host() != oldUrl.host()) {
[1477]568 newUrlList << oldUrl.toString();
569 }
570 }
571 settings.setValue("casterUrlList", newUrlList);
[1475]572 settings.sync();
[1474]573}
[1459]574
[1474]575// New caster selected in combobox
576////////////////////////////////////////////////////////////////////////////
577void bncTableDlg::slotCasterHostChanged(const QString& newHost) {
578 QSettings settings;
[1476]579 QStringList casterUrlList = settings.value("casterUrlList").toStringList();
580 for (int ii = 0; ii < casterUrlList.count(); ii++) {
581 QUrl url(casterUrlList[ii]);
[1474]582 if (url.host() == newHost) {
583 _casterUserLineEdit->setText(url.userName());
[1480]584 _casterPasswordLineEdit->setText(url.password());
[1474]585 if (url.port() > 0) {
586 _casterPortLineEdit->setText(QString("%1").arg(url.port()));
587 }
588 else {
589 _casterPortLineEdit->setText("");
590 }
591 }
592 }
[1459]593}
Note: See TracBrowser for help on using the repository browser.