Changeset 191 in ntrip for trunk/BNC/bnctabledlg.cpp
- Timestamp:
- Sep 24, 2006, 6:49:47 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bnctabledlg.cpp
r136 r191 84 84 } 85 85 86 // Read Table from Caster 87 //////////////////////////////////////////////////////////////////////////// 88 void bncTableDlg::slotGetTable() { 86 // Read Table the caster (static) 87 //////////////////////////////////////////////////////////////////////////// 88 t_irc bncTableDlg::getFullTable(const QString& casterHost, 89 int casterPort, QStringList& allLines) { 90 91 allLines.clear(); 89 92 90 93 QUrl url; 91 url.setHost( _casterHostLineEdit->text());92 url.setPort( _casterPortLineEdit->text().toInt());94 url.setHost(casterHost); 95 url.setPort(casterPort); 93 96 94 97 // Send the Request … … 99 102 100 103 if (!socket) { 101 QMessageBox::warning(0, "BNC", msg); 102 return; 104 return failure; 103 105 } 104 106 105 107 // Read Caster Response 106 108 // -------------------- 107 QStringList allLines;108 109 bool first = true; 109 110 while (true) { 110 111 if (socket->canReadLine()) { 111 112 QString line = socket->readLine(); 113 allLines.push_back(line); 112 114 if (first) { 113 115 first = false; 114 116 if (line.indexOf("SOURCETABLE 200 OK") != 0) { 115 QMessageBox::warning(0, "BNC", "Wrong Caster Response:\n" + line);116 117 break; 117 118 } … … 121 122 break; 122 123 } 123 if (line.indexOf("STR") == 0) {124 allLines.push_back(line);125 }126 124 } 127 125 } … … 132 130 } 133 131 else { 134 QMessageBox::warning(0, "BNC", "Data Timeout");135 132 break; 136 133 } … … 138 135 } 139 136 delete socket; 137 138 return success; 139 } 140 141 // Read Table from Caster 142 //////////////////////////////////////////////////////////////////////////// 143 void bncTableDlg::slotGetTable() { 144 145 QStringList allLines; 146 147 if ( getFullTable(_casterHostLineEdit->text(), 148 _casterPortLineEdit->text().toInt(), 149 allLines) != success ) { 150 QMessageBox::warning(0, "BNC", "Cannot retrieve table of data"); 151 return; 152 } 153 154 QStringList lines; 155 QStringListIterator it(allLines); 156 while (it.hasNext()) { 157 QString line = it.next(); 158 if (line.indexOf("STR") == 0) { 159 lines.push_back(line); 160 } 161 } 140 162 141 163 static const QStringList labels = QString("mountpoint,identifier,format," … … 144 166 "misc").split(","); 145 167 146 if ( allLines.size() > 0) {168 if (lines.size() > 0) { 147 169 _table->setSelectionMode(QAbstractItemView::ExtendedSelection); 148 170 _table->setSelectionBehavior(QAbstractItemView::SelectRows); 149 171 150 QStringList hlp = allLines[0].split(";");172 QStringList hlp = lines[0].split(";"); 151 173 _table->setColumnCount(hlp.size()-1); 152 _table->setRowCount( allLines.size());153 154 QListIterator<QString> it( allLines);174 _table->setRowCount(lines.size()); 175 176 QListIterator<QString> it(lines); 155 177 int nRow = -1; 156 178 while (it.hasNext()) {
Note:
See TracChangeset
for help on using the changeset viewer.