[280] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
[464] | 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
[280] | 3 | //
|
---|
[464] | 4 | // Copyright (C) 2007
|
---|
[280] | 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
[464] | 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
[280] | 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.
|
---|
[35] | 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
[93] | 26 | * BKG NTRIP Client
|
---|
[35] | 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 |
|
---|
[1493] | 41 | #include <iostream>
|
---|
| 42 |
|
---|
[35] | 43 | #include "bnctabledlg.h"
|
---|
| 44 | #include "bncgetthread.h"
|
---|
[1848] | 45 | #include "bncnetqueryv1.h"
|
---|
[1535] | 46 | #include "bncsettings.h"
|
---|
[2753] | 47 | #include "bncmap.h"
|
---|
[35] | 48 |
|
---|
[1373] | 49 | using namespace std;
|
---|
| 50 |
|
---|
[35] | 51 | // Constructor
|
---|
| 52 | ////////////////////////////////////////////////////////////////////////////
|
---|
[90] | 53 | bncTableDlg::bncTableDlg(QWidget* parent) : QDialog(parent) {
|
---|
[35] | 54 |
|
---|
| 55 | setMinimumSize(600,400);
|
---|
[1611] | 56 | setWindowTitle(tr("Add Streams from Caster"));
|
---|
[35] | 57 |
|
---|
| 58 | QVBoxLayout* mainLayout = new QVBoxLayout(this);
|
---|
| 59 |
|
---|
[1474] | 60 | int ww = QFontMetrics(font()).width('w');
|
---|
| 61 |
|
---|
| 62 | _casterPortLineEdit = new QLineEdit();
|
---|
| 63 | _casterPortLineEdit->setMaximumWidth(9*ww);
|
---|
| 64 |
|
---|
| 65 | _casterUserLineEdit = new QLineEdit();
|
---|
| 66 | _casterUserLineEdit->setMaximumWidth(9*ww);
|
---|
| 67 |
|
---|
| 68 | _casterPasswordLineEdit = new QLineEdit();
|
---|
| 69 | _casterPasswordLineEdit->setMaximumWidth(9*ww);
|
---|
[3294] | 70 | _casterPasswordLineEdit->setEchoMode(QLineEdit::PasswordEchoOnEdit);
|
---|
[1474] | 71 |
|
---|
| 72 | _casterHostComboBox = new QComboBox();
|
---|
[1482] | 73 | _casterHostComboBox->setMaxCount(10);
|
---|
[1474] | 74 | _casterHostComboBox->setDuplicatesEnabled(false);
|
---|
| 75 | _casterHostComboBox->setEditable(true);
|
---|
[1477] | 76 | _casterHostComboBox->setMinimumWidth(20*ww);
|
---|
[1474] | 77 | _casterHostComboBox->setMaximumWidth(20*ww);
|
---|
| 78 | connect(_casterHostComboBox, SIGNAL(currentIndexChanged(const QString&)),
|
---|
| 79 | this, SLOT(slotCasterHostChanged(const QString&)));
|
---|
[1535] | 80 | bncSettings settings;
|
---|
[1481] | 81 | settings.remove("casterHostList");
|
---|
| 82 | settings.remove("casterHost");
|
---|
| 83 | settings.remove("casterPort");
|
---|
| 84 | settings.remove("casterUser");
|
---|
| 85 | settings.remove("casterPassword");
|
---|
[1476] | 86 | QStringList casterUrlList = settings.value("casterUrlList").toStringList();
|
---|
| 87 | for (int ii = 0; ii < casterUrlList.count(); ii++) {
|
---|
| 88 | QUrl url(casterUrlList[ii]);
|
---|
[1474] | 89 | _casterHostComboBox->addItem(url.host());
|
---|
[1274] | 90 | }
|
---|
[683] | 91 |
|
---|
[1350] | 92 | _ntripVersionComboBox = new QComboBox();
|
---|
[1721] | 93 | _ntripVersionComboBox->addItems(QString("1,2,R,U").split(","));
|
---|
[1350] | 94 | int kk = _ntripVersionComboBox->findText(settings.value("ntripVersion").toString());
|
---|
| 95 | if (kk != -1) {
|
---|
| 96 | _ntripVersionComboBox->setCurrentIndex(kk);
|
---|
| 97 | }
|
---|
[1459] | 98 | _ntripVersionComboBox->setMaximumWidth(5*ww);
|
---|
[1350] | 99 |
|
---|
[1459] | 100 | _buttonCasterTable = new QPushButton(tr("Show"), this);
|
---|
| 101 | connect(_buttonCasterTable, SIGNAL(clicked()), this, SLOT(slotCasterTable()));
|
---|
| 102 | _buttonCasterTable->setMaximumWidth(5*ww);
|
---|
| 103 |
|
---|
[683] | 104 | // WhatsThis
|
---|
| 105 | // ---------
|
---|
[1459] | 106 | _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>"));
|
---|
[1474] | 107 | _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>"));
|
---|
[1459] | 108 | _casterPortLineEdit->setWhatsThis(tr("Enter the NTRIP broadcaster port number."));
|
---|
| 109 | _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."));
|
---|
[35] | 110 |
|
---|
[88] | 111 | QGridLayout* editLayout = new QGridLayout;
|
---|
[1459] | 112 | editLayout->addWidget(new QLabel(tr("Caster host")), 0, 0);
|
---|
[1474] | 113 | editLayout->addWidget(_casterHostComboBox, 0, 1);
|
---|
[1459] | 114 | editLayout->addWidget(new QLabel(tr(" Caster port")), 0, 2, Qt::AlignRight);
|
---|
| 115 | editLayout->addWidget(_casterPortLineEdit, 0, 3);
|
---|
[1598] | 116 | editLayout->addWidget(new QLabel(tr("Casters table")), 0, 4, Qt::AlignRight);
|
---|
[1459] | 117 | editLayout->addWidget(_buttonCasterTable, 0, 5);
|
---|
| 118 | editLayout->addWidget(new QLabel(tr("User")), 1, 0, Qt::AlignRight);
|
---|
| 119 | editLayout->addWidget(_casterUserLineEdit, 1, 1);
|
---|
| 120 | editLayout->addWidget(new QLabel(tr("Password")), 1, 2, Qt::AlignRight);
|
---|
| 121 | editLayout->addWidget(_casterPasswordLineEdit, 1, 3);
|
---|
| 122 | editLayout->addWidget(new QLabel(tr(" NTRIP Version")),1, 4, Qt::AlignRight);
|
---|
| 123 | editLayout->addWidget(_ntripVersionComboBox, 1, 5);
|
---|
[88] | 124 |
|
---|
[35] | 125 | mainLayout->addLayout(editLayout);
|
---|
| 126 |
|
---|
[1471] | 127 | _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>"));
|
---|
[1766] | 128 | _ntripVersionComboBox->setWhatsThis(tr("<p>Select the NTRIP transport protocol version you want to use. Implemented options are:<br> 1: NTRIP version 1, TCP/IP<br> 2: NTRIP version 2, TCP/IP mode<br> R: NTRIP Version 2, RTSP/RTP mode<br> U: NTRIP Version 2, UDP 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') and UDP (option 'U') are not accepted by proxies and sometimes not supported by mobile Internet Service Providers.</p>"));
|
---|
[1409] | 129 |
|
---|
[35] | 130 | _table = new QTableWidget(this);
|
---|
[1459] | 131 | _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>"));
|
---|
[195] | 132 | connect(_table, SIGNAL(itemSelectionChanged()),
|
---|
| 133 | this, SLOT(slotSelectionChanged()));
|
---|
[35] | 134 | mainLayout->addWidget(_table);
|
---|
| 135 |
|
---|
[402] | 136 | _buttonWhatsThis = new QPushButton(tr("Help=Shift+F1"), this);
|
---|
[399] | 137 | connect(_buttonWhatsThis, SIGNAL(clicked()), this, SLOT(slotWhatsThis()));
|
---|
| 138 |
|
---|
[195] | 139 | _buttonGet = new QPushButton(tr("Get table"), this);
|
---|
[399] | 140 | _buttonGet->setDefault(true);
|
---|
[35] | 141 | connect(_buttonGet, SIGNAL(clicked()), this, SLOT(slotGetTable()));
|
---|
[366] | 142 |
|
---|
[2753] | 143 | _buttonMap = new QPushButton(tr("Map"), this);
|
---|
| 144 | _buttonMap->setEnabled(false);
|
---|
| 145 | connect(_buttonMap, SIGNAL(clicked()), this, SLOT(slotShowMap()));
|
---|
| 146 |
|
---|
[2796] | 147 | _buttonClose = new QPushButton(tr("Close"), this);
|
---|
| 148 | connect(_buttonClose, SIGNAL(clicked()), this, SLOT(close()));
|
---|
[35] | 149 |
|
---|
[2796] | 150 | _buttonSelect = new QPushButton(tr("Select"), this);
|
---|
| 151 | connect(_buttonSelect, SIGNAL(clicked()), this, SLOT(select()));
|
---|
[35] | 152 |
|
---|
| 153 | QHBoxLayout* buttonLayout = new QHBoxLayout;
|
---|
[399] | 154 | buttonLayout->addWidget(_buttonWhatsThis);
|
---|
[35] | 155 | buttonLayout->addStretch(1);
|
---|
[2753] | 156 | buttonLayout->addWidget(_buttonMap);
|
---|
[35] | 157 | buttonLayout->addWidget(_buttonGet);
|
---|
[2796] | 158 | buttonLayout->addWidget(_buttonSelect);
|
---|
| 159 | buttonLayout->addWidget(_buttonClose);
|
---|
[35] | 160 |
|
---|
| 161 | mainLayout->addLayout(buttonLayout);
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | // Destructor
|
---|
| 165 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 166 | bncTableDlg::~bncTableDlg() {
|
---|
[1490] | 167 | delete _casterHostComboBox;
|
---|
| 168 | delete _casterPortLineEdit;
|
---|
| 169 | delete _casterUserLineEdit;
|
---|
| 170 | delete _casterPasswordLineEdit;
|
---|
| 171 | delete _ntripVersionComboBox;
|
---|
| 172 | delete _buttonGet;
|
---|
[2796] | 173 | delete _buttonClose;
|
---|
| 174 | delete _buttonSelect;
|
---|
[1490] | 175 | delete _buttonWhatsThis;
|
---|
| 176 | delete _buttonCasterTable;
|
---|
| 177 | delete _table;
|
---|
[35] | 178 | }
|
---|
| 179 |
|
---|
[1493] | 180 | // Read full caster table (static)
|
---|
[35] | 181 | ////////////////////////////////////////////////////////////////////////////
|
---|
[191] | 182 | t_irc bncTableDlg::getFullTable(const QString& casterHost,
|
---|
[1376] | 183 | int casterPort, QStringList& allLines,
|
---|
| 184 | bool alwaysRead) {
|
---|
[35] | 185 |
|
---|
[299] | 186 | static QMutex mutex;
|
---|
[298] | 187 | static QMap<QString, QStringList> allTables;
|
---|
| 188 |
|
---|
[299] | 189 | QMutexLocker locker(&mutex);
|
---|
| 190 |
|
---|
[298] | 191 | if (!alwaysRead && allTables.find(casterHost) != allTables.end()) {
|
---|
| 192 | allLines = allTables.find(casterHost).value();
|
---|
| 193 | return success;
|
---|
| 194 | }
|
---|
| 195 |
|
---|
[191] | 196 | allLines.clear();
|
---|
| 197 |
|
---|
[88] | 198 | QUrl url;
|
---|
[191] | 199 | url.setHost(casterHost);
|
---|
| 200 | url.setPort(casterPort);
|
---|
[1375] | 201 | url.setScheme("http");
|
---|
| 202 | url.setPath("/");
|
---|
[35] | 203 |
|
---|
[1848] | 204 | bncNetQueryV1 query;
|
---|
[1373] | 205 | QByteArray outData;
|
---|
[1375] | 206 | query.waitForRequestResult(url, outData);
|
---|
| 207 | if (query.status() == bncNetQuery::finished) {
|
---|
| 208 | QTextStream in(outData);
|
---|
| 209 | QString line = in.readLine();
|
---|
| 210 | while ( !line.isNull() ) {
|
---|
| 211 | allLines.append(line);
|
---|
| 212 | line = in.readLine();
|
---|
| 213 | }
|
---|
| 214 | allTables.insert(casterHost, allLines);
|
---|
| 215 | return success;
|
---|
| 216 | }
|
---|
| 217 | else {
|
---|
[191] | 218 | return failure;
|
---|
[35] | 219 | }
|
---|
[191] | 220 | }
|
---|
| 221 |
|
---|
| 222 | // Read Table from Caster
|
---|
| 223 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 224 | void bncTableDlg::slotGetTable() {
|
---|
| 225 |
|
---|
[555] | 226 | _buttonGet->setEnabled(false);
|
---|
[2753] | 227 | _buttonMap->setEnabled(true);
|
---|
[1459] | 228 | _buttonCasterTable->setEnabled(false);
|
---|
[555] | 229 |
|
---|
[1474] | 230 | if ( getFullTable(_casterHostComboBox->currentText(),
|
---|
[191] | 231 | _casterPortLineEdit->text().toInt(),
|
---|
[1493] | 232 | _allLines, true) != success ) {
|
---|
[191] | 233 | QMessageBox::warning(0, "BNC", "Cannot retrieve table of data");
|
---|
[645] | 234 | _buttonGet->setEnabled(true);
|
---|
[191] | 235 | return;
|
---|
| 236 | }
|
---|
[2753] | 237 |
|
---|
[1493] | 238 | static const QStringList labels = QString("mountpoint,identifier,format,"
|
---|
| 239 | "format-details,carrier,system,network,country,lat,long,"
|
---|
| 240 | "nmea,solution,generator,compress.,auth.,fee,bitrate,"
|
---|
| 241 | "misc").split(",");
|
---|
| 242 |
|
---|
[191] | 243 | QStringList lines;
|
---|
[196] | 244 | QStringListIterator it(_allLines);
|
---|
[191] | 245 | while (it.hasNext()) {
|
---|
| 246 | QString line = it.next();
|
---|
| 247 | if (line.indexOf("STR") == 0) {
|
---|
[1493] | 248 | QStringList hlp = line.split(";");
|
---|
| 249 | if (hlp.size() > labels.size()) {
|
---|
| 250 | lines.push_back(line);
|
---|
| 251 | }
|
---|
[191] | 252 | }
|
---|
| 253 | }
|
---|
| 254 |
|
---|
| 255 | if (lines.size() > 0) {
|
---|
[35] | 256 | _table->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
---|
| 257 | _table->setSelectionBehavior(QAbstractItemView::SelectRows);
|
---|
[1493] | 258 | _table->setColumnCount(labels.size());
|
---|
| 259 | _table->setRowCount(lines.size());
|
---|
| 260 | for (int nRow = 0; nRow < lines.size(); nRow++) {
|
---|
| 261 | QStringList columns = lines[nRow].split(";");
|
---|
| 262 | for (int ic = 1; ic < columns.size(); ic++) {
|
---|
| 263 | if (ic == 11) {
|
---|
| 264 | if (columns[ic] == "0") {
|
---|
| 265 | columns[ic] = "no";
|
---|
| 266 | } else {
|
---|
| 267 | columns[ic] = "yes";
|
---|
| 268 | }
|
---|
| 269 | }
|
---|
| 270 | QTableWidgetItem* item = new QTableWidgetItem(columns[ic]);
|
---|
| 271 | item->setFlags(item->flags() & ~Qt::ItemIsEditable);
|
---|
| 272 | _table->setItem(nRow, ic-1, item);
|
---|
[35] | 273 | }
|
---|
| 274 | }
|
---|
[103] | 275 | _table->setHorizontalHeaderLabels(labels);
|
---|
[104] | 276 | _table->setSortingEnabled(true);
|
---|
[371] | 277 | int ww = QFontMetrics(this->font()).width('w');
|
---|
[1493] | 278 | _table->horizontalHeader()->resizeSection( 0,10*ww);
|
---|
| 279 | _table->horizontalHeader()->resizeSection( 1,10*ww);
|
---|
| 280 | _table->horizontalHeader()->resizeSection( 2, 8*ww);
|
---|
| 281 | _table->horizontalHeader()->resizeSection( 3,22*ww);
|
---|
| 282 | _table->horizontalHeader()->resizeSection( 4, 5*ww);
|
---|
| 283 | _table->horizontalHeader()->resizeSection( 5, 8*ww);
|
---|
| 284 | _table->horizontalHeader()->resizeSection( 6, 8*ww);
|
---|
| 285 | _table->horizontalHeader()->resizeSection( 7, 7*ww);
|
---|
| 286 | _table->horizontalHeader()->resizeSection( 8, 6*ww);
|
---|
| 287 | _table->horizontalHeader()->resizeSection( 9, 6*ww);
|
---|
| 288 | _table->horizontalHeader()->resizeSection(10, 6*ww);
|
---|
| 289 | _table->horizontalHeader()->resizeSection(11, 6*ww);
|
---|
[371] | 290 | _table->horizontalHeader()->resizeSection(12,15*ww);
|
---|
[1493] | 291 | _table->horizontalHeader()->resizeSection(13, 8*ww);
|
---|
| 292 | _table->horizontalHeader()->resizeSection(14, 5*ww);
|
---|
| 293 | _table->horizontalHeader()->resizeSection(15, 5*ww);
|
---|
| 294 | _table->horizontalHeader()->resizeSection(16, 7*ww);
|
---|
[371] | 295 | _table->horizontalHeader()->resizeSection(17,15*ww);
|
---|
[1493] | 296 | _table->sortItems(0);
|
---|
[35] | 297 | }
|
---|
| 298 | }
|
---|
| 299 |
|
---|
[2753] | 300 | // Show world map
|
---|
| 301 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 302 | void bncTableDlg::slotShowMap() {
|
---|
| 303 |
|
---|
| 304 | bncMap* winMap = new bncMap(this);
|
---|
[2796] | 305 | winMap->setGeometry( x(), int(y()+height()*1.3), 880, 440 );
|
---|
[2753] | 306 |
|
---|
[3292] | 307 | connect(this, SIGNAL(newPoint(QPointF, QString, QPen, double)),
|
---|
| 308 | winMap, SLOT(slotNewPoint(QPointF, QString, QPen, double)));
|
---|
[2753] | 309 |
|
---|
[2796] | 310 | connect(this, SIGNAL(fitMap()),
|
---|
| 311 | winMap, SLOT(slotFitMap() ));
|
---|
[3292] | 312 |
|
---|
| 313 | connect(this, SIGNAL(fitFont()),
|
---|
| 314 | winMap, SLOT(slotFitFont() ));
|
---|
[2796] | 315 |
|
---|
[2753] | 316 | _buttonMap->setEnabled(false);
|
---|
| 317 | showSourceTable();
|
---|
| 318 | winMap->exec();
|
---|
| 319 | _buttonMap->setEnabled(true);
|
---|
| 320 |
|
---|
[3292] | 321 | disconnect(this, SIGNAL(newPoint(QPointF, QString, QPen, double)),
|
---|
| 322 | winMap, SLOT(slotNewPoint(QPointF, QString, QPen, double)));
|
---|
[2753] | 323 |
|
---|
[2796] | 324 | disconnect(this, SIGNAL(fitMap()),
|
---|
| 325 | winMap, SLOT(slotFitMap() ));
|
---|
| 326 |
|
---|
[3292] | 327 | disconnect(this, SIGNAL(fitFont()),
|
---|
| 328 | winMap, SLOT(slotFitFont() ));
|
---|
| 329 |
|
---|
[2753] | 330 | delete winMap;
|
---|
| 331 | }
|
---|
| 332 |
|
---|
| 333 | // Show world map
|
---|
| 334 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 335 | void bncTableDlg::showSourceTable() {
|
---|
| 336 |
|
---|
| 337 | for( int i = 0; i < _allLines.size(); i++ ){
|
---|
| 338 |
|
---|
| 339 | if( _allLines.at(i).startsWith("STR") == true ){
|
---|
| 340 |
|
---|
| 341 | QStringList tmp = _allLines.at(i).split(';');
|
---|
| 342 | if( tmp.size() > 0 ){
|
---|
| 343 |
|
---|
| 344 | QPointF point;
|
---|
| 345 | point.setY( tmp.at(9).toDouble() );
|
---|
| 346 | point.setX( tmp.at(10).toDouble() );
|
---|
[2796] | 347 |
|
---|
[2753] | 348 | QString site = tmp.at(1);
|
---|
| 349 | site.resize(4);
|
---|
| 350 |
|
---|
[3292] | 351 | emit newPoint(point, site, QPen(QBrush(QColor(0,0,255,200)), 1.5), 1.5 );
|
---|
[2796] | 352 | }
|
---|
[2753] | 353 | }
|
---|
| 354 | }
|
---|
[2796] | 355 | emit fitMap();
|
---|
[2753] | 356 | }
|
---|
| 357 |
|
---|
| 358 |
|
---|
[2796] | 359 | // Select slot
|
---|
[35] | 360 | ////////////////////////////////////////////////////////////////////////////
|
---|
[2796] | 361 | void bncTableDlg::select() {
|
---|
[35] | 362 |
|
---|
[1535] | 363 | bncSettings settings;
|
---|
[1477] | 364 | settings.setValue("ntripVersion", _ntripVersionComboBox->currentText());
|
---|
[1476] | 365 | QUrl url;
|
---|
[1478] | 366 | url.setScheme("http");
|
---|
[1476] | 367 | url.setHost(_casterHostComboBox->currentText());
|
---|
| 368 | url.setPort(_casterPortLineEdit->text().toInt());
|
---|
[1508] | 369 | url.setUserName(QUrl::toPercentEncoding(_casterUserLineEdit->text()));
|
---|
| 370 | url.setPassword(QUrl::toPercentEncoding(_casterPasswordLineEdit->text()));
|
---|
[1477] | 371 | addUrl(url);
|
---|
[1476] | 372 |
|
---|
[35] | 373 | QStringList* mountPoints = new QStringList;
|
---|
| 374 | if (_table) {
|
---|
| 375 | for (int ir = 0; ir < _table->rowCount(); ir++) {
|
---|
[59] | 376 | QTableWidgetItem* item = _table->item(ir,0);
|
---|
[2753] | 377 | QString site = _table->item(ir,0)->text();
|
---|
[59] | 378 | QString format = _table->item(ir,2)->text();
|
---|
[366] | 379 | QString latitude = _table->item(ir,8)->text();
|
---|
| 380 | QString longitude = _table->item(ir,9)->text();
|
---|
| 381 | QString nmea = _table->item(ir,10)->text();
|
---|
[1351] | 382 | QString ntripVersion = _ntripVersionComboBox->currentText();
|
---|
[59] | 383 | format.replace(" ", "_");
|
---|
[35] | 384 | if (_table->isItemSelected(item)) {
|
---|
| 385 | url.setPath(item->text());
|
---|
[2796] | 386 | mountPoints->push_back(url.toString() + " " + format + " " + latitude
|
---|
[1351] | 387 | + " " + longitude + " " + nmea + " " + ntripVersion);
|
---|
[2753] | 388 |
|
---|
[2796] | 389 | site.resize(4);
|
---|
[2753] | 390 | emit newPoint(QPointF(longitude.toDouble(),latitude.toDouble()), site,
|
---|
[3292] | 391 | QPen(QBrush(QColor(255,0,0,200)), 3.0), 3.0 );
|
---|
[35] | 392 | }
|
---|
| 393 | }
|
---|
| 394 | }
|
---|
| 395 | emit newMountPoints(mountPoints);
|
---|
[3292] | 396 | emit fitFont();
|
---|
[35] | 397 | }
|
---|
[195] | 398 |
|
---|
| 399 | // User changed the selection of mountPoints
|
---|
| 400 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 401 | void bncTableDlg::slotSelectionChanged() {
|
---|
| 402 | if (_table->selectedItems().isEmpty()) {
|
---|
| 403 | }
|
---|
| 404 | }
|
---|
| 405 |
|
---|
[399] | 406 | // Whats This Help
|
---|
| 407 | void bncTableDlg::slotWhatsThis() {
|
---|
| 408 | QWhatsThis::enterWhatsThisMode();
|
---|
| 409 | }
|
---|
| 410 |
|
---|
[1459] | 411 | // Slot caster table
|
---|
| 412 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 413 | void bncTableDlg::slotCasterTable() {
|
---|
| 414 |
|
---|
| 415 | _buttonCasterTable->setEnabled(false);
|
---|
[1474] | 416 | _casterHostComboBox->setEnabled(false);
|
---|
[1461] | 417 | _casterPortLineEdit->setEnabled(false);
|
---|
| 418 | _casterUserLineEdit->setEnabled(false);
|
---|
| 419 | _casterPasswordLineEdit->setEnabled(false);
|
---|
| 420 | _ntripVersionComboBox->setEnabled(false);
|
---|
| 421 | _buttonWhatsThis->setEnabled(false);
|
---|
| 422 | _buttonGet->setEnabled(false);
|
---|
[2796] | 423 | _buttonClose->setEnabled(false);
|
---|
| 424 | _buttonSelect->setEnabled(false);
|
---|
[1461] | 425 |
|
---|
[1459] | 426 | bncCasterTableDlg* dlg = new bncCasterTableDlg(this);
|
---|
| 427 | dlg->move(this->pos().x()+50, this->pos().y()+50);
|
---|
[1474] | 428 | connect(dlg, SIGNAL(newCaster(QString, QString)),
|
---|
| 429 | this, SLOT(slotNewCaster(QString, QString)));
|
---|
[1459] | 430 | dlg->exec();
|
---|
| 431 | delete dlg;
|
---|
[1461] | 432 |
|
---|
[1459] | 433 | _buttonCasterTable->setEnabled(true);
|
---|
[1474] | 434 | _casterHostComboBox->setEnabled(true);
|
---|
[1461] | 435 | _casterPortLineEdit->setEnabled(true);
|
---|
| 436 | _casterUserLineEdit->setEnabled(true);
|
---|
| 437 | _casterPasswordLineEdit->setEnabled(true);
|
---|
| 438 | _ntripVersionComboBox->setEnabled(true);
|
---|
| 439 | _buttonWhatsThis->setEnabled(true);
|
---|
| 440 | _buttonGet->setEnabled(true);
|
---|
[2796] | 441 | _buttonClose->setEnabled(true);
|
---|
| 442 | _buttonSelect->setEnabled(true);
|
---|
[399] | 443 |
|
---|
[1459] | 444 | }
|
---|
| 445 |
|
---|
[1492] | 446 | // New caster selected
|
---|
| 447 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 448 | void bncTableDlg::slotNewCaster(QString newCasterHost, QString newCasterPort) {
|
---|
| 449 |
|
---|
| 450 | _casterHostComboBox->insertItem(0, newCasterHost);
|
---|
| 451 | _casterHostComboBox->setCurrentIndex(0);
|
---|
| 452 | _casterUserLineEdit->setText("");
|
---|
[1497] | 453 | _casterPasswordLineEdit->setText("");
|
---|
[1492] | 454 | _casterPortLineEdit->setText(newCasterPort);
|
---|
| 455 |
|
---|
| 456 | QUrl url;
|
---|
| 457 | url.setScheme("http");
|
---|
| 458 | url.setHost(newCasterHost);
|
---|
| 459 | url.setPort(newCasterPort.toInt());
|
---|
| 460 | addUrl(url);
|
---|
| 461 |
|
---|
| 462 | _casterHostComboBox->setCurrentIndex(0);
|
---|
| 463 | }
|
---|
| 464 |
|
---|
| 465 | // New caster selected
|
---|
| 466 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 467 | void bncTableDlg::addUrl(const QUrl& url) {
|
---|
[1535] | 468 | bncSettings settings;
|
---|
[1492] | 469 | QStringList oldUrlList = settings.value("casterUrlList").toStringList();
|
---|
| 470 | QStringList newUrlList;
|
---|
| 471 | newUrlList << url.toString();
|
---|
| 472 | for (int ii = 0; ii < oldUrlList.count(); ii++) {
|
---|
| 473 | QUrl oldUrl(oldUrlList[ii]);
|
---|
| 474 | if (url.host() != oldUrl.host()) {
|
---|
| 475 | newUrlList << oldUrl.toString();
|
---|
| 476 | }
|
---|
| 477 | }
|
---|
| 478 | settings.setValue("casterUrlList", newUrlList);
|
---|
| 479 | settings.sync();
|
---|
| 480 | }
|
---|
| 481 |
|
---|
| 482 | // New caster selected in combobox
|
---|
| 483 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 484 | void bncTableDlg::slotCasterHostChanged(const QString& newHost) {
|
---|
[1535] | 485 | bncSettings settings;
|
---|
[1492] | 486 | QStringList casterUrlList = settings.value("casterUrlList").toStringList();
|
---|
| 487 | for (int ii = 0; ii < casterUrlList.count(); ii++) {
|
---|
| 488 | QUrl url(casterUrlList[ii]);
|
---|
| 489 | if (url.host() == newHost) {
|
---|
[1508] | 490 | _casterUserLineEdit->setText(
|
---|
| 491 | QUrl::fromPercentEncoding(url.userName().toAscii()));
|
---|
| 492 | _casterPasswordLineEdit->setText(
|
---|
| 493 | QUrl::fromPercentEncoding(url.password().toAscii()));
|
---|
[1492] | 494 | if (url.port() > 0) {
|
---|
| 495 | _casterPortLineEdit->setText(QString("%1").arg(url.port()));
|
---|
| 496 | }
|
---|
| 497 | else {
|
---|
| 498 | _casterPortLineEdit->setText("");
|
---|
| 499 | }
|
---|
| 500 | }
|
---|
| 501 | }
|
---|
| 502 | }
|
---|
| 503 |
|
---|
[1459] | 504 | // Caster table
|
---|
| 505 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 506 | bncCasterTableDlg::bncCasterTableDlg(QWidget* parent) :
|
---|
| 507 | QDialog(parent) {
|
---|
| 508 |
|
---|
[1461] | 509 | static const QStringList labels = QString("host,port,identifier,operator,nmea,country,lat,long,link").split(",");
|
---|
[1459] | 510 |
|
---|
| 511 | _casterTable = new QTableWidget(this);
|
---|
| 512 |
|
---|
| 513 | QUrl url;
|
---|
| 514 | url.setHost("www.rtcm-ntrip.org");
|
---|
| 515 | url.setPort(2101);
|
---|
| 516 | url.setScheme("http");
|
---|
| 517 | url.setPath("/");
|
---|
| 518 |
|
---|
[1848] | 519 | bncNetQueryV1 query;
|
---|
[1459] | 520 | QByteArray outData;
|
---|
| 521 | query.waitForRequestResult(url, outData);
|
---|
[1494] | 522 |
|
---|
| 523 | QStringList lines;
|
---|
[1459] | 524 | if (query.status() == bncNetQuery::finished) {
|
---|
| 525 | QTextStream in(outData);
|
---|
| 526 | QString line = in.readLine();
|
---|
| 527 | while ( !line.isNull() ) {
|
---|
| 528 | line = in.readLine();
|
---|
| 529 | if (line.indexOf("CAS") == 0) {
|
---|
[1494] | 530 | QStringList hlp = line.split(";");
|
---|
| 531 | if (hlp.size() > labels.size()) {
|
---|
| 532 | lines.push_back(line);
|
---|
| 533 | }
|
---|
[1459] | 534 | }
|
---|
| 535 | }
|
---|
| 536 | }
|
---|
[1494] | 537 |
|
---|
[1459] | 538 | if (lines.size() > 0) {
|
---|
| 539 | _casterTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
---|
| 540 | _casterTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
---|
| 541 |
|
---|
| 542 | QStringList hlp = lines[0].split(";");
|
---|
[1494] | 543 | _casterTable->setColumnCount(labels.size());
|
---|
| 544 | _casterTable->setRowCount(lines.size());
|
---|
[1459] | 545 |
|
---|
[1494] | 546 | for (int nRow = 0; nRow < lines.size(); nRow++) {
|
---|
| 547 | QStringList columns = lines[nRow].split(";");
|
---|
| 548 | for (int ic = 1; ic < columns.size(); ic++) {
|
---|
| 549 | if (ic == 5) {
|
---|
| 550 | if (columns[ic] == "0") {
|
---|
| 551 | columns[ic] = "no";
|
---|
| 552 | } else {
|
---|
| 553 | columns[ic] = "yes";
|
---|
| 554 | }
|
---|
| 555 | }
|
---|
| 556 | QTableWidgetItem* item = new QTableWidgetItem(columns[ic]);
|
---|
| 557 | item->setFlags(item->flags() & ~Qt::ItemIsEditable);
|
---|
| 558 | _casterTable->setItem(nRow, ic-1, item);
|
---|
[1459] | 559 | }
|
---|
| 560 | }
|
---|
| 561 | }
|
---|
| 562 | _casterTable->setHorizontalHeaderLabels(labels);
|
---|
| 563 | _casterTable->setSortingEnabled(true);
|
---|
[1494] | 564 | _casterTable->sortItems(0);
|
---|
[1459] | 565 | int ww = QFontMetrics(this->font()).width('w');
|
---|
| 566 | _casterTable->horizontalHeader()->resizeSection(0,15*ww);
|
---|
[1494] | 567 | _casterTable->horizontalHeader()->resizeSection(1, 5*ww);
|
---|
[1459] | 568 | _casterTable->horizontalHeader()->resizeSection(2,15*ww);
|
---|
| 569 | _casterTable->horizontalHeader()->resizeSection(3,15*ww);
|
---|
[1494] | 570 | _casterTable->horizontalHeader()->resizeSection(4, 5*ww);
|
---|
| 571 | _casterTable->horizontalHeader()->resizeSection(5, 7*ww);
|
---|
| 572 | _casterTable->horizontalHeader()->resizeSection(6, 7*ww);
|
---|
| 573 | _casterTable->horizontalHeader()->resizeSection(7, 7*ww);
|
---|
[1459] | 574 | _casterTable->horizontalHeader()->resizeSection(8,15*ww);
|
---|
| 575 |
|
---|
[1488] | 576 | _closeButton = new QPushButton("Cancel");
|
---|
[1459] | 577 | connect(_closeButton, SIGNAL(clicked()), this, SLOT(close()));
|
---|
| 578 | _closeButton->setMinimumWidth(8*ww);
|
---|
| 579 | _closeButton->setMaximumWidth(8*ww);
|
---|
| 580 |
|
---|
[1488] | 581 | _okButton = new QPushButton(tr("OK"), this);
|
---|
[1459] | 582 | connect(_okButton, SIGNAL(clicked()), this, SLOT(slotAcceptCasterTable()));
|
---|
| 583 | _okButton->setMinimumWidth(8*ww);
|
---|
| 584 | _okButton->setMaximumWidth(8*ww);
|
---|
| 585 |
|
---|
[1488] | 586 | _whatsThisButton = new QPushButton(tr("Help=Shift+F1"), this);
|
---|
| 587 | connect(_whatsThisButton, SIGNAL(clicked()), this, SLOT(slotWhatsThis()));
|
---|
| 588 | _whatsThisButton->setMinimumWidth(12*ww);
|
---|
| 589 | _whatsThisButton->setMaximumWidth(12*ww);
|
---|
[1459] | 590 |
|
---|
[1471] | 591 | _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>."));
|
---|
[1459] | 592 |
|
---|
| 593 | QGridLayout* dlgLayout = new QGridLayout();
|
---|
| 594 | dlgLayout->addWidget(new QLabel(" List of NTRIP Broadcasters from www.rtcm-ntrip.org"), 0,0,1,3,Qt::AlignLeft);
|
---|
[1488] | 595 | dlgLayout->addWidget(_casterTable, 1, 0, 1, 3);
|
---|
| 596 | dlgLayout->addWidget(_whatsThisButton, 2, 0);
|
---|
| 597 | dlgLayout->addWidget(_closeButton, 2, 1, Qt::AlignRight);
|
---|
| 598 | dlgLayout->addWidget(_okButton, 2, 2);
|
---|
[1459] | 599 |
|
---|
| 600 | setMinimumSize(600,400);
|
---|
| 601 | setWindowTitle(tr("Select Broadcaster"));
|
---|
| 602 | setLayout(dlgLayout);
|
---|
[1504] | 603 | resize(68*ww, 50*ww);
|
---|
[1459] | 604 | show();
|
---|
| 605 | }
|
---|
| 606 |
|
---|
[1488] | 607 | // Caster table destructor
|
---|
[1459] | 608 | ////////////////////////////////////////////////////////////////////////////
|
---|
[1488] | 609 | bncCasterTableDlg::~bncCasterTableDlg() {
|
---|
| 610 | delete _casterTable;
|
---|
| 611 | delete _okButton;
|
---|
| 612 | delete _closeButton;
|
---|
| 613 | delete _whatsThisButton;
|
---|
[1459] | 614 | }
|
---|
| 615 |
|
---|
[1488] | 616 | // Caster table what's this
|
---|
[1459] | 617 | ////////////////////////////////////////////////////////////////////////////
|
---|
[1488] | 618 | void bncCasterTableDlg:: slotWhatsThis() {
|
---|
| 619 | QWhatsThis::enterWhatsThisMode();
|
---|
[1459] | 620 | }
|
---|
| 621 |
|
---|
| 622 | // Accept caster table
|
---|
| 623 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 624 | void bncCasterTableDlg::slotAcceptCasterTable() {
|
---|
| 625 | if (_casterTable) {
|
---|
[1489] | 626 | for (int ir = _casterTable->rowCount() - 1; ir >= 0 ; ir--) {
|
---|
[1474] | 627 | if (_casterTable->isItemSelected(_casterTable->item(ir,0))) {
|
---|
| 628 | emit newCaster(_casterTable->item(ir,0)->text(),
|
---|
| 629 | _casterTable->item(ir,1)->text());
|
---|
[1459] | 630 | }
|
---|
| 631 | }
|
---|
| 632 | }
|
---|
[1474] | 633 | QDialog::accept();
|
---|
[1459] | 634 | }
|
---|