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

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

* empty log message *

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