Changeset 3335 in ntrip for trunk/BNC/bnctabledlg.cpp
- Timestamp:
- Jul 19, 2011, 4:23:19 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bnctabledlg.cpp
r3294 r3335 44 44 #include "bncgetthread.h" 45 45 #include "bncnetqueryv1.h" 46 #include "bncnetqueryv2.h" 46 47 #include "bncsettings.h" 47 48 #include "bncmap.h" … … 91 92 92 93 _ntripVersionComboBox = new QComboBox(); 93 _ntripVersionComboBox->addItems(QString("1,2, R,U").split(","));94 _ntripVersionComboBox->addItems(QString("1,2,2s,R,U").split(",")); 94 95 int kk = _ntripVersionComboBox->findText(settings.value("ntripVersion").toString()); 95 96 if (kk != -1) { … … 180 181 // Read full caster table (static) 181 182 //////////////////////////////////////////////////////////////////////////// 182 t_irc bncTableDlg::getFullTable(const QString& casterHost, 183 t_irc bncTableDlg::getFullTable(const QString& ntripVersion, 184 const QString& casterHost, 183 185 int casterPort, QStringList& allLines, 184 186 bool alwaysRead) { … … 196 198 allLines.clear(); 197 199 200 bncNetQuery* query = 0; 201 if (ntripVersion == "2" || ntripVersion == "2s") { 202 query = new bncNetQueryV2(); 203 } 204 else { 205 query = new bncNetQueryV1(); 206 } 207 198 208 QUrl url; 199 209 url.setHost(casterHost); 200 210 url.setPort(casterPort); 201 url.setScheme("http");202 211 url.setPath("/"); 203 204 bncNetQueryV1 query; 212 if (ntripVersion == "2s") { 213 url.setScheme("https"); 214 } 215 else { 216 url.setScheme("http"); 217 } 218 205 219 QByteArray outData; 206 query .waitForRequestResult(url, outData);207 if (query .status() == bncNetQuery::finished) {220 query->waitForRequestResult(url, outData); 221 if (query->status() == bncNetQuery::finished) { 208 222 QTextStream in(outData); 209 223 QString line = in.readLine(); … … 213 227 } 214 228 allTables.insert(casterHost, allLines); 229 delete query; 215 230 return success; 216 231 } 217 232 else { 233 delete query; 218 234 return failure; 219 235 } … … 228 244 _buttonCasterTable->setEnabled(false); 229 245 230 if ( getFullTable(_casterHostComboBox->currentText(), 246 if ( getFullTable(_ntripVersionComboBox->currentText(), 247 _casterHostComboBox->currentText(), 231 248 _casterPortLineEdit->text().toInt(), 232 249 _allLines, true) != success ) { … … 362 379 363 380 bncSettings settings; 364 settings.setValue("ntripVersion", _ntripVersionComboBox->currentText()); 381 QString ntripVersion = _ntripVersionComboBox->currentText(); 382 settings.setValue("ntripVersion", ntripVersion); 365 383 QUrl url; 366 url.setScheme("http"); 384 if (ntripVersion == "2s") { 385 url.setScheme("https"); 386 } 387 else { 388 url.setScheme("http"); 389 } 367 390 url.setHost(_casterHostComboBox->currentText()); 368 391 url.setPort(_casterPortLineEdit->text().toInt()); … … 380 403 QString longitude = _table->item(ir,9)->text(); 381 404 QString nmea = _table->item(ir,10)->text(); 382 QString ntripVersion = _ntripVersionComboBox->currentText();383 405 format.replace(" ", "_"); 384 406 if (_table->isItemSelected(item)) { … … 424 446 _buttonSelect->setEnabled(false); 425 447 426 bncCasterTableDlg* dlg = new bncCasterTableDlg(this); 448 bncCasterTableDlg* dlg = 449 new bncCasterTableDlg(_ntripVersionComboBox->currentText(), this); 427 450 dlg->move(this->pos().x()+50, this->pos().y()+50); 428 451 connect(dlg, SIGNAL(newCaster(QString, QString)), … … 504 527 // Caster table 505 528 //////////////////////////////////////////////////////////////////////////// 506 bncCasterTableDlg::bncCasterTableDlg(QWidget* parent) : 529 bncCasterTableDlg::bncCasterTableDlg(const QString& ntripVersion, 530 QWidget* parent) : 507 531 QDialog(parent) { 508 532 … … 517 541 url.setPath("/"); 518 542 519 bncNetQueryV1 query; 543 bncNetQuery* query = 0; 544 if (ntripVersion == "2" || ntripVersion == "2s") { 545 query = new bncNetQueryV2(); 546 } 547 else { 548 query = new bncNetQueryV1(); 549 } 550 520 551 QByteArray outData; 521 query .waitForRequestResult(url, outData);552 query->waitForRequestResult(url, outData); 522 553 523 554 QStringList lines; 524 if (query .status() == bncNetQuery::finished) {555 if (query->status() == bncNetQuery::finished) { 525 556 QTextStream in(outData); 526 557 QString line = in.readLine(); … … 535 566 } 536 567 } 568 569 delete query; 537 570 538 571 if (lines.size() > 0) {
Note:
See TracChangeset
for help on using the changeset viewer.