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

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