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

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

* empty log message *

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