QTableWidgetSelectionRange Spreadsheet::selectedRange() const
{
    QList<QTableWidgetSelectionRange> ranges = selectedRanges();
    if(ranges.empty())
        return QTableWidgetSelectionRange();
    return ranges.first();
}
Beispiel #2
0
QTableWidgetSelectionRange TrWidget::selectedRange() const
{
    QList<QTableWidgetSelectionRange>ranges = m_table->selectedRanges();
    if(ranges.isEmpty())
        return QTableWidgetSelectionRange();
    return ranges.first();
}
QTableWidgetSelectionRange OperationTable::selectedRange() const
{
	QList<QTableWidgetSelectionRange> ranges = selectedRanges();
	if( ranges.isEmpty() )
		return QTableWidgetSelectionRange();
	return ranges.first();
}
void CoreHighlightSettingsPage::selectIgnoredRow(QTableWidgetItem *item)
{
    int row = item->row();
    bool selected = item->isSelected();
    ui.ignoredTable
        ->setRangeSelected(QTableWidgetSelectionRange(row, 0, row, CoreHighlightSettingsPage::ColumnCount - 1),
                           selected);
}
void ViewTable::selectRow()
{
	int row = currentRow();
	if( row < 0 )
		return;

	clearSelection();
	setRangeSelected( QTableWidgetSelectionRange( row, 0, row, columnCount()-1 ), true );

	setRowTextBold( row );
	if( lastRow != row )
		setRowTextBold( lastRow, false );
	lastRow = row;
	
	emit rowSelected( row );
}
Beispiel #6
0
void SimDock::selectionChanged()
{
  if (m_ltsManager->simulation() && m_ltsManager->simulation()->isStarted())
  {
    m_ui.trigger->setEnabled(true);
    QList<Transition *> transitions = m_ltsManager->simulation()->availableTransitions();
    for (int i = 0; i < transitions.size(); i++)
    {
      if (transitions[i] == m_ltsManager->simulation()->currentTransition())
      {
        m_ui.transitionTable->setRangeSelected(QTableWidgetSelectionRange(i, 0, i, 1), true);
      }
    }
  }
  else
  {
    m_ui.trigger->setEnabled(false);
  }
}
void ViewTable::selectRow(int row, bool em)
{
	if( row < 0 || row >= rowCount() )
		return;

	setCurrentCell(row, 0);
	//selectRow();

	clearSelection();
	setRangeSelected( QTableWidgetSelectionRange( row, 0, row, columnCount()-1 ), true );

	setRowTextBold( row );
	if( lastRow != row )
		setRowTextBold( lastRow, false );
	lastRow = row;
	
	if( em )
		emit rowSelected( row );
}
Beispiel #8
0
void TreeSubWindow::duplicateDownSelection(unsigned int rep)
{
  QList<QTableWidgetSelectionRange> selection = nodeEditor_->selectedRanges();
  if (selection.size() == 0) {
    QMessageBox::critical(phyview_, QString("Oups..."), QString("No selection."));
    return;
  }
  //Perform some checking:
  int row = -1;
  for (int i = 0; i < selection.size(); ++i) {
    QTableWidgetSelectionRange range = selection[i];
    if (range.rowCount() != 1) {
      QMessageBox::critical(phyview_, QString("Oups..."), QString("Only one row can be selected."));
      return;
    }
    if (i == 0) {
      row = range.topRow();
    } else {
      if (range.topRow() != row) {
        QMessageBox::critical(phyview_, QString("Oups..."), QString("Only one row can be selected."));
        return;
      }
    }
  }
  //Ok, if we reach this stage, then everything is ok...
  int j;
  for (j = row + 1; j < nodeEditor_->rowCount() && j - row <= static_cast<int>(rep); ++j) {
    for (int i = 0; i < selection.size(); ++i) {
      QTableWidgetSelectionRange range = selection[i];
      for (int k = range.leftColumn(); k <= range.rightColumn(); ++k) {
        nodeEditor_->setItem(j, k, nodeEditor_->item(row, k)->clone());
      }
    }
  }
  //Shift selection:
  for (int i = 0; i < selection.size(); ++i) {
    QTableWidgetSelectionRange range = selection[i];
    nodeEditor_->setRangeSelected(range, false);
    nodeEditor_->setRangeSelected(QTableWidgetSelectionRange(j - 1, range.leftColumn(), j - 1, range.rightColumn()), true);
  }
}
Beispiel #9
0
bool TableEventHandler::eventFilter(QObject *o, QEvent *e) {
  if( !o ) qWarning("TableEventHandler::eventFilter called with 0 object?");
  if( QString(o->metaObject()->className()) != tr("QTableWidget") ) {
#ifdef EI_DEBUG
      qDebug("Only QTableWidget objects accepted! Returning!");
#endif
      return false;
  }
  QTableWidget *to = (QTableWidget *)o;
  if( e->type() == QEvent::KeyPress ) {
    QKeyEvent *ke = (QKeyEvent*)e;
    if(ke->matches(QKeySequence::Copy) ){
       QString cellText; itemCopy.clear(); copyRange.clear();
       QList<QTableWidgetSelectionRange> ts = to->selectedRanges();
       if(!ts.isEmpty()) {
          for ( int irow = ts.first().topRow(); irow <= ts.first().bottomRow(); irow++){
               for ( int icol = ts.first().leftColumn(); icol <= ts.first().rightColumn(); icol++){
                   QTableWidgetItem *w = to->item(irow,icol);
                   if(w) cellText = w->text();
                   if ( !cellText.isEmpty() ){
                      itemCopy << cellText;
                   }
                   else
                      itemCopy << " ";
               }
          }
          copyRange = ts;
          //cout << itemCopy.join(", ").toLatin1().data() << endl;
       }
       else {
            QTableWidgetItem *w = to->item(to->currentRow(), to->currentColumn());
            if (w) cellText = w->text();
            if ( !cellText.isEmpty() )
                 itemCopy << cellText;
            else itemCopy << "";
       }
       return true;
    }
    else if(ke->matches(QKeySequence::Paste) && !itemCopy.isEmpty() && !copyRange.isEmpty()){
       QList<QTableWidgetSelectionRange> cs = to->selectedRanges();
       int top = cs.first().topRow(), left = cs.first().leftColumn(), icount = 0;
       QTableWidgetSelectionRange ts = QTableWidgetSelectionRange(
                                       top , left,
                                       top  + copyRange.first().rowCount()-1,
                                       left + copyRange.first().columnCount()-1);
       for ( int irow = ts.topRow(); irow <= ts.bottomRow(); irow++){
         for ( int icol = ts.leftColumn(); icol <= ts.rightColumn(); icol++){
             if ( ++icount <= itemCopy.size() )
                to->setItem(irow, icol, new QTableWidgetItem(itemCopy[icount-1]));
         }
       }
       return true;
    }
    else if(ke->matches(QKeySequence::Cut) ){
       QString cellText; itemCopy.clear(); copyRange.clear();
       QList<QTableWidgetSelectionRange> ts = to->selectedRanges();
       if(!ts.isEmpty()) {
         for (int irow = ts.first().topRow(); irow <= ts.first().bottomRow(); irow++) {
           for(int icol = ts.first().leftColumn(); icol <= ts.first().rightColumn(); icol++) {
               QTableWidgetItem *w = to->item(irow,icol);
               if(w) cellText = w->text();
               if ( !cellText.isEmpty() ){
                  itemCopy << cellText;
               }
               else
                  itemCopy << "";
               to->setItem(irow,icol,0);
           }
         }
         copyRange = ts;
         //cout << itemCopy.join(", ").toLatin1().data() << endl;
       }
       return true;
    }
    else if(ke->matches(QKeySequence::Delete) ){
       QList<QTableWidgetSelectionRange> ts = to->selectedRanges();
       if(!ts.isEmpty()) {
         for (int irow = ts.first().topRow(); irow <= ts.first().bottomRow(); irow++) {
           for(int icol = ts.first().leftColumn(); icol <= ts.first().rightColumn(); icol++) {
               to->setItem(irow,icol,0);
           }
         }
       }
       return true;
    }
    else
        to->eventFilter(o, e);
  }
  return false;
}
Beispiel #10
0
void
TransferFunctionManager::removeTransferFunction()
{
  if (!m_tfContainer) return;

  //------------------------------------------------
  //temporarily diconnect the connections
  m_tableWidget->disconnect(this);
  //------------------------------------------------


  QList<QTableWidgetSelectionRange> sel = m_tableWidget->selectedRanges();

  for(int i=0; i<sel.count(); i++)
    {
      if (sel[i].leftColumn() == 0)
	{
	  for(int row=sel[i].topRow(); row<=sel[i].bottomRow(); row++)
	    {
	      QTableWidgetItem *wi;
	      wi = new QTableWidgetItem(QString("%~%*"));
	      m_tableWidget->setItem(row, 0, wi);	    
	    }
	}
    }
  
  bool done = false;
  while (!done)
    {
      done = true;
      for(int i=0; i<m_tableWidget->rowCount(); i++)
	{
	  QTableWidgetItem *wi;
	  wi = m_tableWidget->item(i, 0);
	  if (wi->text() == QString("%~%*"))
	    {
	      m_tableWidget->removeRow(i);
	      done = false;
	      
	      //------------------------------------------------
	      // remove TransferFunction
	      m_tfContainer->removeSplineTF(i);
	      //------------------------------------------------
	    }
	}
    }

  //------------------------------------------------
  //rewire the connections
  connect(m_tableWidget, SIGNAL(cellClicked(int, int)),
	  this, SLOT(cellClicked(int, int)));

  connect(m_tableWidget, SIGNAL(cellChanged(int, int)),
	  this, SLOT(cellChanged(int, int)));
  //------------------------------------------------

  int rows = m_tableWidget->rowCount();
  int cols = m_tableWidget->columnCount();

  QList<bool> on;

  if (rows > 0)
    {
      m_tableWidget->setRangeSelected(QTableWidgetSelectionRange(0, 0, rows, cols-1), false);
      m_tableWidget->setRangeSelected(QTableWidgetSelectionRange(0, 0, 0, cols-1), true);      

      for (int i=0; i<m_tfContainer->maxSets(); i++)
	{
	  QTableWidgetItem *wi;
	  wi = m_tableWidget->item(0, i+1);
	  bool flag = wi->checkState() == Qt::Checked;
	  on.append(flag);
	}
      emit changeTransferFunctionDisplay(0, on);
    }
  else
    emit changeTransferFunctionDisplay(-1, on);

  qApp->processEvents();
}
Beispiel #11
0
void
TransferFunctionManager::addNewTransferFunction()
{
  if (!m_tfContainer) return;

  //------------------------------------------------
  //temporarily diconnect the connections
  m_tableWidget->disconnect(this);
  //------------------------------------------------

  int rows = m_tableWidget->rowCount();
  int cols = m_tableWidget->columnCount();

  m_tableWidget->insertRow(rows);

  QTableWidgetItem *qtwi;
  qtwi = new QTableWidgetItem(QString("TF %1").arg(rows));
  qtwi->setFlags(qtwi->flags() & ~Qt::ItemIsUserCheckable);
  m_tableWidget->setItem(rows, 0, qtwi);

  if (cols > 1)
    {
      QTableWidgetItem *wi;
      wi = new QTableWidgetItem("");
      wi->setCheckState(Qt::Checked);
      wi->setFlags(wi->flags() & ~Qt::ItemIsEditable);
      m_tableWidget->setItem(rows, 1, wi);
    }
  for (int i=2; i<cols; i++)
    {
      QTableWidgetItem *wi;
      wi = new QTableWidgetItem("");
      wi->setCheckState(Qt::Unchecked);
      wi->setFlags(wi->flags() & ~Qt::ItemIsEditable);
      m_tableWidget->setItem(rows, i, wi);
    }


  for(int it=0; it<m_tableWidget->rowCount(); it++)
    m_tableWidget->setRowHeight(it, 20);


  //------------------------------------------------
  // add new TransferFunction
  m_tfContainer->addSplineTF();
  SplineTransferFunction *tf = m_tfContainer->transferFunctionPtr(rows);
  tf->setName(qtwi->text());
  //------------------------------------------------

  //------------------------------------------------
  //rewire the connections
  connect(m_tableWidget, SIGNAL(cellClicked(int, int)),
	  this, SLOT(cellClicked(int, int)));

  connect(m_tableWidget, SIGNAL(cellChanged(int, int)),
	  this, SLOT(cellChanged(int, int)));
  //------------------------------------------------

  m_tableWidget->setRangeSelected(QTableWidgetSelectionRange(0, 0, rows, cols-1), false);
  m_tableWidget->setRangeSelected(QTableWidgetSelectionRange(rows, 0, rows, cols-1), true);

  QList<bool> on;
  for (int i=0; i<m_tfContainer->maxSets(); i++)
    {
      QTableWidgetItem *wi;
      wi = m_tableWidget->item(rows, i+1);
      bool flag = wi->checkState() == Qt::Checked;
      on.append(flag);
    }
  emit changeTransferFunctionDisplay(rows, on);
  qApp->processEvents();
}