Changeset 2869 in ntrip


Ignore:
Timestamp:
Jan 23, 2011, 4:26:10 PM (14 years ago)
Author:
mervart
Message:
 
Location:
trunk/BNC
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bncwindow.cpp

    r2868 r2869  
    807807
    808808  _cmbTable = new QTableWidget(0,3);
    809   _cmbTable->horizontalHeader()->setStretchLastSection(true);
     809  ////  _cmbTable->horizontalHeader()->setStretchLastSection(true);
    810810  _cmbTable->setHorizontalHeaderLabels(QString("Mountpoint, AC Name, Weight").split(","));
    811   cmbLayout->addWidget(_cmbTable,0,0,6,1);
    812 
    813   QPushButton* addRowButton = new QPushButton("Add Row");
    814   cmbLayout->addWidget(addRowButton,0,1);
    815   QPushButton* delRowButton = new QPushButton("Delete");
    816   cmbLayout->addWidget(delRowButton,1,1);
    817 
    818   cmbLayout->addWidget(new QLabel,0,2);
    819   cmbLayout->setColumnStretch(2,1);
     811  _cmbTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
     812  _cmbTable->setSelectionBehavior(QAbstractItemView::SelectRows);
     813  cmbLayout->addWidget(_cmbTable,0,0,6,2);
     814
     815  QPushButton* addCmbRowButton = new QPushButton("Add Row");
     816  cmbLayout->addWidget(addCmbRowButton,0,2);
     817  connect(addCmbRowButton, SIGNAL(clicked()), this, SLOT(slotAddCmbRow()));
     818  QPushButton* delCmbRowButton = new QPushButton("Delete");
     819  cmbLayout->addWidget(delCmbRowButton,1,2);
     820  connect(delCmbRowButton, SIGNAL(clicked()), this, SLOT(slotDelCmbRow()));
     821
     822  cmbLayout->addWidget(new QLabel,0,3);
     823  cmbLayout->setColumnStretch(3,1);
    820824
    821825  cmbgroup->setLayout(cmbLayout);
     
    18141818  }
    18151819}
     1820
     1821//
     1822////////////////////////////////////////////////////////////////////////////
     1823void bncWindow::slotAddCmbRow() {
     1824  int iRow = _cmbTable->rowCount();
     1825  _cmbTable->insertRow(iRow);
     1826  for (int iCol = 0; iCol < _cmbTable->columnCount(); iCol++) {
     1827    _cmbTable->setItem(iRow, iCol, new QTableWidgetItem(""));
     1828  }
     1829}
     1830
     1831//
     1832////////////////////////////////////////////////////////////////////////////
     1833void bncWindow::slotDelCmbRow() {
     1834  int nRows = _cmbTable->rowCount();
     1835  bool flg[nRows];
     1836  for (int iRow = 0; iRow < nRows; iRow++) {
     1837    if (_cmbTable->isItemSelected(_cmbTable->item(iRow,1))) {
     1838      flg[iRow] = true;
     1839    }
     1840    else {
     1841      flg[iRow] = false;
     1842    }
     1843  }
     1844  for (int iRow = nRows-1; iRow >= 0; iRow--) {
     1845    if (flg[iRow]) {
     1846      _cmbTable->removeRow(iRow);
     1847    }
     1848  }
     1849}
  • trunk/BNC/bncwindow.h

    r2868 r2869  
    7979    void slotSelectionChanged();
    8080    void slotWhatsThis();
     81    void slotAddCmbRow();
     82    void slotDelCmbRow();
    8183
    8284  protected:
Note: See TracChangeset for help on using the changeset viewer.