Changeset 1474 in ntrip


Ignore:
Timestamp:
Jan 17, 2009, 4:01:33 PM (15 years ago)
Author:
mervart
Message:

* empty log message *

Location:
trunk/BNC
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bnctabledlg.cpp

    r1471 r1474  
    5757
    5858  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&)));
    6477  QStringList casterHostList = settings.value("casterHostList").toStringList();
    65   _casterHostLineEdit->addItem(settings.value("casterHost").toString());
    6678  for (int ii = 0; ii < casterHostList.count(); ii++) {
    6779    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  }
    7986
    8087  _ntripVersionComboBox = new QComboBox();
     
    93100  // ---------
    94101  _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   _casterHostLineEdit->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>"));
    96103  _casterPortLineEdit->setWhatsThis(tr("Enter the NTRIP broadcaster port number."));
    97104  _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."));
     
    99106  QGridLayout* editLayout = new QGridLayout;
    100107  editLayout->addWidget(new QLabel(tr("Caster host")),    0, 0);
    101   editLayout->addWidget(_casterHostLineEdit,              0, 1);
     108  editLayout->addWidget(_casterHostComboBox,              0, 1);
    102109  editLayout->addWidget(new QLabel(tr("  Caster port")),  0, 2, Qt::AlignRight);
    103110  editLayout->addWidget(_casterPortLineEdit,              0, 3);
     
    208215  _allLines.clear();
    209216
    210   if ( getFullTable(_casterHostLineEdit->currentText(),
     217  if ( getFullTable(_casterHostComboBox->currentText(),
    211218                    _casterPortLineEdit->text().toInt(),
    212219                    _allLines) != success ) {
     
    288295
    289296  QSettings settings;
    290   settings.setValue("casterHost", _casterHostLineEdit->currentText());
     297  settings.setValue("casterHost", _casterHostComboBox->currentText());
    291298  QStringList casterHostList;
    292   for (int ii = 0; ii < _casterHostLineEdit->count(); ii++) {
    293     casterHostList.push_back(_casterHostLineEdit->itemText(ii));
     299  for (int ii = 0; ii < _casterHostComboBox->count(); ii++) {
     300    casterHostList.push_back(_casterHostComboBox->itemText(ii));
    294301  }
    295302  settings.setValue("casterHostList", casterHostList);
     
    314321        url.setUserName(QUrl::toPercentEncoding(_casterUserLineEdit->text()));
    315322        url.setPassword(QUrl::toPercentEncoding(_casterPasswordLineEdit->text()));
    316         url.setHost(_casterHostLineEdit->currentText());
     323        url.setHost(_casterHostComboBox->currentText());
    317324        url.setPort(_casterPortLineEdit->text().toInt());
    318325        url.setPath(item->text());
     
    377384       
    378385  _buttonCasterTable->setEnabled(false);
    379   _casterHostLineEdit->setEnabled(false);
     386  _casterHostComboBox->setEnabled(false);
    380387  _casterPortLineEdit->setEnabled(false);
    381388  _casterUserLineEdit->setEnabled(false);
     
    389396  bncCasterTableDlg* dlg = new bncCasterTableDlg(this);
    390397  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)));
    393400  dlg->exec();
    394401  delete dlg;
    395402
    396403  _buttonCasterTable->setEnabled(true);
    397   _casterHostLineEdit->setEnabled(true);
     404  _casterHostComboBox->setEnabled(true);
    398405  _casterPortLineEdit->setEnabled(true);
    399406  _casterUserLineEdit->setEnabled(true);
     
    532539////////////////////////////////////////////////////////////////////////////
    533540void bncCasterTableDlg::slotAcceptCasterTable() {
    534 
    535   QSettings settings;
    536   QString* newCasterHost = new QString;
    537   QString* newCasterPort = new QString;
    538 
    539541  if (_casterTable) {
    540542    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();
    556550}
    557551
    558552// New caster selected
    559553////////////////////////////////////////////////////////////////////////////
    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 
     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}
  • trunk/BNC/bnctabledlg.h

    r1459 r1474  
    4040
    4141  signals:
    42     void newCaster(QString* newCasterHost, QString* newCasterPort);
     42    void newCaster(QString newCasterHost, QString newCasterPort);
    4343
    4444  private slots:
     
    6969    void slotWhatsThis();
    7070    void slotCasterTable();
    71     void slotNewCaster(QString* newCasterHost, QString* newCasterPort);
     71    void slotNewCaster(QString newCasterHost, QString newCasterPort);
     72    void slotCasterHostChanged(const QString&);
    7273
    7374  private:
    74     QComboBox*   _casterHostLineEdit;
     75    QComboBox*   _casterHostComboBox;
    7576    QLineEdit*   _casterPortLineEdit;
    7677    QLineEdit*   _casterUserLineEdit;
Note: See TracChangeset for help on using the changeset viewer.