Changeset 1474 in ntrip
- Timestamp:
- Jan 17, 2009, 4:01:33 PM (16 years ago)
- Location:
- trunk/BNC
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bnctabledlg.cpp
r1471 r1474 57 57 58 58 QSettings settings; 59 _casterHostLineEdit = new QComboBox(); 60 _casterHostLineEdit->setDuplicatesEnabled(false); 61 _casterHostLineEdit->setEditable(true); 62 int ww = QFontMetrics(_casterHostLineEdit->font()).width('w'); 63 _casterHostLineEdit->setMaximumWidth(20*ww); 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&))); 64 77 QStringList casterHostList = settings.value("casterHostList").toStringList(); 65 _casterHostLineEdit->addItem(settings.value("casterHost").toString());66 78 for (int ii = 0; ii < casterHostList.count(); ii++) { 67 79 QString item = casterHostList[ii]; 68 if (_casterHostLineEdit->findText(item, Qt::MatchFixedString) < 0) { 69 _casterHostLineEdit->addItem(item); 70 } 71 } 72 _casterPortLineEdit = new QLineEdit(settings.value("casterPort").toString()); 73 _casterPortLineEdit->setMaximumWidth(9*ww); 74 _casterUserLineEdit = new QLineEdit(settings.value("casterUser").toString()); 75 _casterUserLineEdit->setMaximumWidth(9*ww); 76 _casterPasswordLineEdit = new QLineEdit(settings.value("casterPassword").toString()); 77 _casterPasswordLineEdit->setMaximumWidth(9*ww); 78 _casterPasswordLineEdit->setEchoMode(QLineEdit::Password); 80 if (item.indexOf("http://") != 0) { 81 item = "http://" + item; 82 } 83 QUrl url(item); 84 _casterHostComboBox->addItem(url.host()); 85 } 79 86 80 87 _ntripVersionComboBox = new QComboBox(); … … 93 100 // --------- 94 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>")); 95 _casterHost LineEdit->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>"));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>")); 96 103 _casterPortLineEdit->setWhatsThis(tr("Enter the NTRIP broadcaster port number.")); 97 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.")); … … 99 106 QGridLayout* editLayout = new QGridLayout; 100 107 editLayout->addWidget(new QLabel(tr("Caster host")), 0, 0); 101 editLayout->addWidget(_casterHost LineEdit, 0, 1);108 editLayout->addWidget(_casterHostComboBox, 0, 1); 102 109 editLayout->addWidget(new QLabel(tr(" Caster port")), 0, 2, Qt::AlignRight); 103 110 editLayout->addWidget(_casterPortLineEdit, 0, 3); … … 208 215 _allLines.clear(); 209 216 210 if ( getFullTable(_casterHost LineEdit->currentText(),217 if ( getFullTable(_casterHostComboBox->currentText(), 211 218 _casterPortLineEdit->text().toInt(), 212 219 _allLines) != success ) { … … 288 295 289 296 QSettings settings; 290 settings.setValue("casterHost", _casterHost LineEdit->currentText());297 settings.setValue("casterHost", _casterHostComboBox->currentText()); 291 298 QStringList casterHostList; 292 for (int ii = 0; ii < _casterHost LineEdit->count(); ii++) {293 casterHostList.push_back(_casterHost LineEdit->itemText(ii));299 for (int ii = 0; ii < _casterHostComboBox->count(); ii++) { 300 casterHostList.push_back(_casterHostComboBox->itemText(ii)); 294 301 } 295 302 settings.setValue("casterHostList", casterHostList); … … 314 321 url.setUserName(QUrl::toPercentEncoding(_casterUserLineEdit->text())); 315 322 url.setPassword(QUrl::toPercentEncoding(_casterPasswordLineEdit->text())); 316 url.setHost(_casterHost LineEdit->currentText());323 url.setHost(_casterHostComboBox->currentText()); 317 324 url.setPort(_casterPortLineEdit->text().toInt()); 318 325 url.setPath(item->text()); … … 377 384 378 385 _buttonCasterTable->setEnabled(false); 379 _casterHost LineEdit->setEnabled(false);386 _casterHostComboBox->setEnabled(false); 380 387 _casterPortLineEdit->setEnabled(false); 381 388 _casterUserLineEdit->setEnabled(false); … … 389 396 bncCasterTableDlg* dlg = new bncCasterTableDlg(this); 390 397 dlg->move(this->pos().x()+50, this->pos().y()+50); 391 connect(dlg, SIGNAL(newCaster(QString *, QString*)),392 this, SLOT(slotNewCaster(QString *, QString*)));398 connect(dlg, SIGNAL(newCaster(QString, QString)), 399 this, SLOT(slotNewCaster(QString, QString))); 393 400 dlg->exec(); 394 401 delete dlg; 395 402 396 403 _buttonCasterTable->setEnabled(true); 397 _casterHost LineEdit->setEnabled(true);404 _casterHostComboBox->setEnabled(true); 398 405 _casterPortLineEdit->setEnabled(true); 399 406 _casterUserLineEdit->setEnabled(true); … … 532 539 //////////////////////////////////////////////////////////////////////////// 533 540 void bncCasterTableDlg::slotAcceptCasterTable() { 534 535 QSettings settings;536 QString* newCasterHost = new QString;537 QString* newCasterPort = new QString;538 539 541 if (_casterTable) { 540 542 for (int ir = 0; ir < _casterTable->rowCount(); ir++) { 541 QTableWidgetItem* item = _casterTable->item(ir,0); 542 for (int ic = 0; ic < _casterTable->columnCount(); ic++) { 543 if (_casterTable->isItemSelected(item)) { 544 if (ic == 0) { 545 newCasterHost->push_back(_casterTable->item(ir,0)->text()); 546 } 547 if (ic == 1) { 548 newCasterPort->push_back(_casterTable->item(ir,1)->text()); 549 } 550 } 551 } 552 } 553 } 554 emit newCaster(newCasterHost, newCasterPort); 555 QDialog::accept(); 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(); 556 550 } 557 551 558 552 // New caster selected 559 553 //////////////////////////////////////////////////////////////////////////// 560 void bncTableDlg::slotNewCaster(QString* newCasterHost, QString* newCasterPort) { 561 562 const QString* newHost = new QString(*newCasterHost); 563 const QString* newPort = new QString(*newCasterPort); 564 565 _casterHostLineEdit->setItemText(0,newHost->toAscii().data()); 566 _casterPortLineEdit->clear(); 567 _casterPortLineEdit->insert(newPort->toAscii().data()); 568 } 569 554 void 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 //////////////////////////////////////////////////////////////////////////// 563 void 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 } -
trunk/BNC/bnctabledlg.h
r1459 r1474 40 40 41 41 signals: 42 void newCaster(QString * newCasterHost, QString*newCasterPort);42 void newCaster(QString newCasterHost, QString newCasterPort); 43 43 44 44 private slots: … … 69 69 void slotWhatsThis(); 70 70 void slotCasterTable(); 71 void slotNewCaster(QString* newCasterHost, QString* newCasterPort); 71 void slotNewCaster(QString newCasterHost, QString newCasterPort); 72 void slotCasterHostChanged(const QString&); 72 73 73 74 private: 74 QComboBox* _casterHost LineEdit;75 QComboBox* _casterHostComboBox; 75 76 QLineEdit* _casterPortLineEdit; 76 77 QLineEdit* _casterUserLineEdit;
Note:
See TracChangeset
for help on using the changeset viewer.