Changeset 1494 in ntrip


Ignore:
Timestamp:
Jan 18, 2009, 11:14:24 AM (15 years ago)
Author:
mervart
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bnctabledlg.cpp

    r1493 r1494  
    436436  static const QStringList labels = QString("host,port,identifier,operator,nmea,country,lat,long,link").split(",");
    437437
    438   QStringList lines;
    439   lines.clear();
    440438  _casterTable = new QTableWidget(this);
    441439
     
    449447  QByteArray outData;
    450448  query.waitForRequestResult(url, outData);
    451   int endSourceTable = 1;
     449
     450  QStringList lines;
    452451  if (query.status() == bncNetQuery::finished) {
    453452    QTextStream in(outData);
     
    455454    while ( !line.isNull() ) {
    456455      line = in.readLine();
    457       if ((endSourceTable == 1 ) && line.indexOf("ENDSOURCETABLE") == 0) {
    458         endSourceTable = 0;
    459       }
    460456      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
    465465  if (lines.size() > 0) {
    466466    _casterTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
     
    468468
    469469    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);
    483486      }
    484487    }
    485488  }
    486   _casterTable->sortItems(0);
    487489  _casterTable->setHorizontalHeaderLabels(labels);
    488490  _casterTable->setSortingEnabled(true);
    489 
     491  _casterTable->sortItems(0);
    490492   int ww = QFontMetrics(this->font()).width('w');
    491493  _casterTable->horizontalHeader()->resizeSection(0,15*ww);
    492   _casterTable->horizontalHeader()->resizeSection(1,5*ww);
     494  _casterTable->horizontalHeader()->resizeSection(1, 5*ww);
    493495  _casterTable->horizontalHeader()->resizeSection(2,15*ww);
    494496  _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);
    499501  _casterTable->horizontalHeader()->resizeSection(8,15*ww);
    500 
    501   ww = QFontMetrics(font()).width('w');
    502502
    503503  _closeButton = new QPushButton("Cancel");
Note: See TracChangeset for help on using the changeset viewer.