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

Last change on this file since 1471 was 1471, checked in by weber, 15 years ago

* empty log message *

File size: 21.8 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 <iostream>
42
43#include "bnctabledlg.h"
44#include "bncgetthread.h"
45#include "bncnetqueryv2.h"
46
47using namespace std;
48
49// Constructor
50////////////////////////////////////////////////////////////////////////////
51bncTableDlg::bncTableDlg(QWidget* parent) : QDialog(parent) {
52
53 setMinimumSize(600,400);
54 setWindowTitle(tr("Add Streams"));
55
56 QVBoxLayout* mainLayout = new QVBoxLayout(this);
57
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);
64 QStringList casterHostList = settings.value("casterHostList").toStringList();
65 _casterHostLineEdit->addItem(settings.value("casterHost").toString());
66 for (int ii = 0; ii < casterHostList.count(); ii++) {
67 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);
79
80 _ntripVersionComboBox = new QComboBox();
81 _ntripVersionComboBox->addItems(QString("1,2,R").split(","));
82 int kk = _ntripVersionComboBox->findText(settings.value("ntripVersion").toString());
83 if (kk != -1) {
84 _ntripVersionComboBox->setCurrentIndex(kk);
85 }
86 _ntripVersionComboBox->setMaximumWidth(5*ww);
87
88 _buttonCasterTable = new QPushButton(tr("Show"), this);
89 connect(_buttonCasterTable, SIGNAL(clicked()), this, SLOT(slotCasterTable()));
90 _buttonCasterTable->setMaximumWidth(5*ww);
91
92 // WhatsThis
93 // ---------
94 _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>"));
96 _casterPortLineEdit->setWhatsThis(tr("Enter the NTRIP broadcaster port number."));
97 _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."));
98
99 QGridLayout* editLayout = new QGridLayout;
100 editLayout->addWidget(new QLabel(tr("Caster host")), 0, 0);
101 editLayout->addWidget(_casterHostLineEdit, 0, 1);
102 editLayout->addWidget(new QLabel(tr(" Caster port")), 0, 2, Qt::AlignRight);
103 editLayout->addWidget(_casterPortLineEdit, 0, 3);
104 editLayout->addWidget(new QLabel(tr("Caster table")), 0, 4, Qt::AlignRight);
105 editLayout->addWidget(_buttonCasterTable, 0, 5);
106 editLayout->addWidget(new QLabel(tr("User")), 1, 0, Qt::AlignRight);
107 editLayout->addWidget(_casterUserLineEdit, 1, 1);
108 editLayout->addWidget(new QLabel(tr("Password")), 1, 2, Qt::AlignRight);
109 editLayout->addWidget(_casterPasswordLineEdit, 1, 3);
110 editLayout->addWidget(new QLabel(tr(" NTRIP Version")),1, 4, Qt::AlignRight);
111 editLayout->addWidget(_ntripVersionComboBox, 1, 5);
112
113 mainLayout->addLayout(editLayout);
114
115 _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>"));
116 _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>"));
117
118 _table = new QTableWidget(this);
119 _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>"));
120 connect(_table, SIGNAL(itemSelectionChanged()),
121 this, SLOT(slotSelectionChanged()));
122 mainLayout->addWidget(_table);
123
124 _buttonWhatsThis = new QPushButton(tr("Help=Shift+F1"), this);
125 connect(_buttonWhatsThis, SIGNAL(clicked()), this, SLOT(slotWhatsThis()));
126
127 _buttonGet = new QPushButton(tr("Get table"), this);
128 _buttonGet->setDefault(true);
129 connect(_buttonGet, SIGNAL(clicked()), this, SLOT(slotGetTable()));
130
131 _buttonCancel = new QPushButton(tr("Cancel"), this);
132 connect(_buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
133
134 _buttonOK = new QPushButton(tr("OK"), this);
135 connect(_buttonOK, SIGNAL(clicked()), this, SLOT(accept()));
136
137 QHBoxLayout* buttonLayout = new QHBoxLayout;
138 buttonLayout->addWidget(_buttonWhatsThis);
139 buttonLayout->addStretch(1);
140 buttonLayout->addWidget(_buttonGet);
141 buttonLayout->addWidget(_buttonCancel);
142 buttonLayout->addWidget(_buttonOK);
143
144 mainLayout->addLayout(buttonLayout);
145}
146
147// Destructor
148////////////////////////////////////////////////////////////////////////////
149bncTableDlg::~bncTableDlg() {
150 if (_table) {
151 for (int ir = 0; ir < _table->rowCount(); ir++) {
152 for (int ic = 0; ic < _table->columnCount(); ic++) {
153 delete _table->item(ir,ic);
154 }
155 }
156 }
157}
158
159// Read Table the caster (static)
160////////////////////////////////////////////////////////////////////////////
161t_irc bncTableDlg::getFullTable(const QString& casterHost,
162 int casterPort, QStringList& allLines,
163 bool alwaysRead) {
164
165 static QMutex mutex;
166 static QMap<QString, QStringList> allTables;
167
168 QMutexLocker locker(&mutex);
169
170 if (!alwaysRead && allTables.find(casterHost) != allTables.end()) {
171 allLines = allTables.find(casterHost).value();
172 return success;
173 }
174
175 allLines.clear();
176
177 QUrl url;
178 url.setHost(casterHost);
179 url.setPort(casterPort);
180 url.setScheme("http");
181 url.setPath("/");
182
183 bncNetQueryV2 query;
184 QByteArray outData;
185 query.waitForRequestResult(url, outData);
186 if (query.status() == bncNetQuery::finished) {
187 QTextStream in(outData);
188 QString line = in.readLine();
189 while ( !line.isNull() ) {
190 allLines.append(line);
191 line = in.readLine();
192 }
193 allTables.insert(casterHost, allLines);
194 return success;
195 }
196 else {
197 return failure;
198 }
199}
200
201// Read Table from Caster
202////////////////////////////////////////////////////////////////////////////
203void bncTableDlg::slotGetTable() {
204
205 _buttonGet->setEnabled(false);
206 _buttonCasterTable->setEnabled(false);
207
208 _allLines.clear();
209
210 if ( getFullTable(_casterHostLineEdit->currentText(),
211 _casterPortLineEdit->text().toInt(),
212 _allLines) != success ) {
213 QMessageBox::warning(0, "BNC", "Cannot retrieve table of data");
214 _buttonGet->setEnabled(true);
215 return;
216 }
217
218 QStringList lines;
219 QStringListIterator it(_allLines);
220 int endSourceTable = 1;
221 while (it.hasNext()) {
222 QString line = it.next();
223 if ((endSourceTable == 1 ) && line.indexOf("ENDSOURCETABLE") == 0) {
224 endSourceTable = 0;
225 }
226 if (line.indexOf("STR") == 0) {
227 lines.push_back(line);
228 }
229 }
230 if (endSourceTable == 1) { printf("ENDSOURCETABLE missing\n");}
231
232 static const QStringList labels = QString("mountpoint,identifier,format,"
233 "format-details,carrier,system,network,country,lat,long,"
234 "nmea,solution,generator,compress.,auth.,fee,bitrate,"
235 "misc").split(",");
236
237 if (lines.size() > 0) {
238 _table->setSelectionMode(QAbstractItemView::ExtendedSelection);
239 _table->setSelectionBehavior(QAbstractItemView::SelectRows);
240
241 QStringList hlp = lines[0].split(";");
242 _table->setColumnCount(hlp.size()-1);
243 _table->setRowCount(lines.size() - endSourceTable);
244
245 QListIterator<QString> it(lines);
246 int nRow = -1;
247 while (it.hasNext()) {
248 QStringList columns = it.next().split(";");
249 ++nRow;
250 for (int ic = 0; ic < columns.size()-1; ic++) {
251
252 if (ic+1 == 11) { if (columns[ic+1] == "0") { columns[ic+1] = "no"; } else { columns[ic+1] = "yes"; }}
253
254 QTableWidgetItem* it = new QTableWidgetItem(columns[ic+1]);
255 it->setFlags(it->flags() & ~Qt::ItemIsEditable);
256 _table->setItem(nRow, ic, it);
257 }
258 }
259 _table->sortItems(0);
260 _table->setHorizontalHeaderLabels(labels);
261 _table->setSortingEnabled(true);
262
263 int ww = QFontMetrics(this->font()).width('w');
264 _table->horizontalHeader()->resizeSection(0,10*ww);
265 _table->horizontalHeader()->resizeSection(1,10*ww);
266 _table->horizontalHeader()->resizeSection(2,8*ww);
267 _table->horizontalHeader()->resizeSection(3,22*ww);
268 _table->horizontalHeader()->resizeSection(4,5*ww);
269 _table->horizontalHeader()->resizeSection(5,8*ww);
270 _table->horizontalHeader()->resizeSection(6,8*ww);
271 _table->horizontalHeader()->resizeSection(7,7*ww);
272 _table->horizontalHeader()->resizeSection(8,6*ww);
273 _table->horizontalHeader()->resizeSection(9,6*ww);
274 _table->horizontalHeader()->resizeSection(10,6*ww);
275 _table->horizontalHeader()->resizeSection(11,6*ww);
276 _table->horizontalHeader()->resizeSection(12,15*ww);
277 _table->horizontalHeader()->resizeSection(13,8*ww);
278 _table->horizontalHeader()->resizeSection(14,5*ww);
279 _table->horizontalHeader()->resizeSection(15,5*ww);
280 _table->horizontalHeader()->resizeSection(16,7*ww);
281 _table->horizontalHeader()->resizeSection(17,15*ww);
282 }
283}
284
285// Accept slot
286////////////////////////////////////////////////////////////////////////////
287void bncTableDlg::accept() {
288
289 QSettings settings;
290 settings.setValue("casterHost", _casterHostLineEdit->currentText());
291 QStringList casterHostList;
292 for (int ii = 0; ii < _casterHostLineEdit->count(); ii++) {
293 casterHostList.push_back(_casterHostLineEdit->itemText(ii));
294 }
295 settings.setValue("casterHostList", casterHostList);
296 settings.setValue("casterPort", _casterPortLineEdit->text());
297 settings.setValue("ntripVersion", _ntripVersionComboBox->currentText());
298 settings.setValue("casterUser", _casterUserLineEdit->text());
299 settings.setValue("casterPassword", _casterPasswordLineEdit->text());
300
301 QStringList* mountPoints = new QStringList;
302
303 if (_table) {
304 for (int ir = 0; ir < _table->rowCount(); ir++) {
305 QTableWidgetItem* item = _table->item(ir,0);
306 QString format = _table->item(ir,2)->text();
307 QString latitude = _table->item(ir,8)->text();
308 QString longitude = _table->item(ir,9)->text();
309 QString nmea = _table->item(ir,10)->text();
310 QString ntripVersion = _ntripVersionComboBox->currentText();
311 format.replace(" ", "_");
312 if (_table->isItemSelected(item)) {
313 QUrl url;
314 url.setUserName(QUrl::toPercentEncoding(_casterUserLineEdit->text()));
315 url.setPassword(QUrl::toPercentEncoding(_casterPasswordLineEdit->text()));
316 url.setHost(_casterHostLineEdit->currentText());
317 url.setPort(_casterPortLineEdit->text().toInt());
318 url.setPath(item->text());
319
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 _casterHostLineEdit->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 _casterHostLineEdit->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() {
516QWhatsThis::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
535 QSettings settings;
536 QString* newCasterHost = new QString;
537 QString* newCasterPort = new QString;
538
539 if (_casterTable) {
540 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);
555QDialog::accept();
556}
557
558// New caster selected
559////////////////////////////////////////////////////////////////////////////
560void 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
Note: See TracBrowser for help on using the repository browser.