- Timestamp:
- Jan 18, 2009, 11:14:24 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bnctabledlg.cpp
r1493 r1494 436 436 static const QStringList labels = QString("host,port,identifier,operator,nmea,country,lat,long,link").split(","); 437 437 438 QStringList lines;439 lines.clear();440 438 _casterTable = new QTableWidget(this); 441 439 … … 449 447 QByteArray outData; 450 448 query.waitForRequestResult(url, outData); 451 int endSourceTable = 1; 449 450 QStringList lines; 452 451 if (query.status() == bncNetQuery::finished) { 453 452 QTextStream in(outData); … … 455 454 while ( !line.isNull() ) { 456 455 line = in.readLine(); 457 if ((endSourceTable == 1 ) && line.indexOf("ENDSOURCETABLE") == 0) {458 endSourceTable = 0;459 }460 456 if (line.indexOf("CAS") == 0) { 461 lines.append(line); 462 } 463 } 464 } 457 QStringList hlp = line.split(";"); 458 if (hlp.size() > labels.size()) { 459 lines.push_back(line); 460 } 461 } 462 } 463 } 464 465 465 if (lines.size() > 0) { 466 466 _casterTable->setSelectionMode(QAbstractItemView::ExtendedSelection); … … 468 468 469 469 QStringList hlp = lines[0].split(";"); 470 _casterTable->setColumnCount(hlp.size()-1); 471 _casterTable->setRowCount(lines.size() - endSourceTable); 472 473 QListIterator<QString> it(lines); 474 int nRow = -1; 475 while (it.hasNext()) { 476 QStringList columns = it.next().split(";"); 477 ++nRow; 478 for (int ic = 0; ic < columns.size()-1; ic++) { 479 if (ic+1 == 5) { if (columns[ic+1] == "0") { columns[ic+1] = "no"; } else { columns[ic+1] = "yes"; }} 480 QTableWidgetItem* it = new QTableWidgetItem(columns[ic+1]); 481 it->setFlags(it->flags() & ~Qt::ItemIsEditable); 482 _casterTable->setItem(nRow, ic, it); 470 _casterTable->setColumnCount(labels.size()); 471 _casterTable->setRowCount(lines.size()); 472 473 for (int nRow = 0; nRow < lines.size(); nRow++) { 474 QStringList columns = lines[nRow].split(";"); 475 for (int ic = 1; ic < columns.size(); ic++) { 476 if (ic == 5) { 477 if (columns[ic] == "0") { 478 columns[ic] = "no"; 479 } else { 480 columns[ic] = "yes"; 481 } 482 } 483 QTableWidgetItem* item = new QTableWidgetItem(columns[ic]); 484 item->setFlags(item->flags() & ~Qt::ItemIsEditable); 485 _casterTable->setItem(nRow, ic-1, item); 483 486 } 484 487 } 485 488 } 486 _casterTable->sortItems(0);487 489 _casterTable->setHorizontalHeaderLabels(labels); 488 490 _casterTable->setSortingEnabled(true); 489 491 _casterTable->sortItems(0); 490 492 int ww = QFontMetrics(this->font()).width('w'); 491 493 _casterTable->horizontalHeader()->resizeSection(0,15*ww); 492 _casterTable->horizontalHeader()->resizeSection(1, 5*ww);494 _casterTable->horizontalHeader()->resizeSection(1, 5*ww); 493 495 _casterTable->horizontalHeader()->resizeSection(2,15*ww); 494 496 _casterTable->horizontalHeader()->resizeSection(3,15*ww); 495 _casterTable->horizontalHeader()->resizeSection(4, 5*ww);496 _casterTable->horizontalHeader()->resizeSection(5, 7*ww);497 _casterTable->horizontalHeader()->resizeSection(6, 7*ww);498 _casterTable->horizontalHeader()->resizeSection(7, 7*ww);497 _casterTable->horizontalHeader()->resizeSection(4, 5*ww); 498 _casterTable->horizontalHeader()->resizeSection(5, 7*ww); 499 _casterTable->horizontalHeader()->resizeSection(6, 7*ww); 500 _casterTable->horizontalHeader()->resizeSection(7, 7*ww); 499 501 _casterTable->horizontalHeader()->resizeSection(8,15*ww); 500 501 ww = QFontMetrics(font()).width('w');502 502 503 503 _closeButton = new QPushButton("Cancel");
Note:
See TracChangeset
for help on using the changeset viewer.