Ejemplo n.º 1
0
void BAMseek::copyCells(){
  QAbstractItemModel * model = tableview->model();
  QItemSelectionModel * selection = tableview->selectionModel();
  QModelIndexList indexes = selection->selectedIndexes();
  std::sort(indexes.begin(), indexes.end());

  QString selected_text;
  int row = 0;
  if(!indexes.empty()){
    row = indexes.first().row();
    selected_text.append(model->data(indexes.first()).toString());
    indexes.removeFirst();
  }
  QModelIndex current;
  foreach(current, indexes){
    QVariant data = model->data(current);
    QString text = data.toString();
    
    if(current.row() != row){
      selected_text.append('\n');
    }else{
      selected_text.append('\t');
    }
    row = current.row();

    selected_text.append(text);
  }
Ejemplo n.º 2
0
void ExtendedTableWidget::copy()
{
    // Get list of selected items
    QItemSelectionModel* selection = selectionModel();
    QModelIndexList indices = selection->selectedIndexes();

    // Abort if there's nothing to copy
    if(indices.size() == 0)
    {
        return;
    } else if(indices.size() == 1) {
        qApp->clipboard()->setText(indices.front().data().toString());
        return;
    }

    // Sort the items by row, then by column
    qSort(indices);

    // Go through all the items...
    QString result;
    QModelIndex prev = indices.front();
    indices.removeFirst();
    foreach(QModelIndex index, indices)
    {
        // Add the content of this cell to the clipboard string
        result.append(QString("\"%1\"").arg(prev.data().toString()));

        // If this is a new row add a line break, if not add a tab for cell separation
        if(index.row() != prev.row())
            result.append("\r\n");
        else
            result.append("\t");

        prev = index;
    }
Ejemplo n.º 3
0
void TimeWidget::copy()
{
  QApplication::clipboard()->clear();

  QItemSelectionModel* selected = table->selectionModel();
  QModelIndexList indices = selected->selectedIndexes();

  if(indices.size() < 1)
    return;
  qSort(indices);

  QModelIndex previous = indices.first();
  indices.removeFirst();
  QString selected_text;
  QModelIndex current;

  Q_FOREACH(current, indices)
  {
    QVariant data = table->model()->data(previous);
    QString text = data.toString();
    selected_text.append(text);

    // Add last character for this element based on row or element change
    if(current.row() != previous.row())
      selected_text.append(QLatin1Char('\n'));
    else
      selected_text.append(";");
    previous = current;
  }
Ejemplo n.º 4
0
void SessionAnalysisWidget::keyPressEvent(QKeyEvent *k)
{
    if (k->key() == Qt::Key_Escape)
        close();

    if (k->key() == Qt::Key_C && k->modifiers() == Qt::ControlModifier)
    {
        QTableWidget *table = ui.lapTimeTableWidget;
        if (EventData::getInstance().getEventType() == LTPackets::PRACTICE_EVENT)
            table = ui.lapTimeTableWidgetFP;

        if (EventData::getInstance().getEventType() == LTPackets::QUALI_EVENT)
        {
            switch (ui.qualiTabWidget->currentIndex())
            {
                case 0: table = ui.lapTimeTableWidgetQuali; break;
                case 1: table = ui.lapTimeTableWidgetQ1; break;
                case 2: table = ui.lapTimeTableWidgetQ2; break;
                case 3: table = ui.lapTimeTableWidgetQ3; break;
            }
        }
        QItemSelectionModel * selection = table->selectionModel();
        QModelIndexList indexes = selection->selectedIndexes();

        if(indexes.size() < 1)
            return;

        // QModelIndex::operator < sorts first by row, then by column.
        // this is what we need
        qSort(indexes.begin(), indexes.end());

        // You need a pair of indexes to find the row changes
        QModelIndex previous = indexes.first();
        indexes.removeFirst();
        QString selected_text;
        QModelIndex current;
        Q_FOREACH(current, indexes)
        {
            QVariant data = table->model()->data(previous);
            QString text = data.toString();

            selected_text.append(text);

            if (current.row() != previous.row())
            {
                selected_text.append(QLatin1Char('\n'));
            }
            else
            {
                selected_text.append(QLatin1Char('\t'));
            }
            previous = current;
        }
Ejemplo n.º 5
0
void    ClipProperty::removeTagsRequired()
{
    QItemSelectionModel*    selected = ui->metaTagsView->selectionModel();
    QModelIndexList         listSelected = selected->selectedIndexes();
    QStringList             list = m_model->stringList();
    while ( listSelected.empty() == false )
    {
        QVariant    elem = m_model->data( listSelected.first(), Qt::DisplayRole );
        list.removeOne( elem.toString() );
        listSelected.removeFirst();
    }
    m_model->setStringList( list );
}
Ejemplo n.º 6
0
QStringList FMListView::selectedFiles()
{
    QModelIndex index;
    QStringList slist;
    if( this->hasFocus() )
    {
        QModelIndexList list = selectedIndexes();
        if( list.at(0).data().toString().at(0)=='.' && list.at(0).data().toString().at(1)=='.' )
        {
            list.removeFirst();
        }
        foreach( index, list)
        {
            slist.append( index.data().toString() );
        }
Ejemplo n.º 7
0
void QTableViewCp::copySelected()
{
	QItemSelectionModel * selection = selectionModel();
	QModelIndexList indexes = selection->selectedIndexes();

	if(indexes.size() < 1)
		return;

	// QModelIndex::operator < sorts first by row, then by column.
	// this is what we need
	std::sort(indexes.begin(), indexes.end());

	// You need a pair of indexes to find the row changes
	QModelIndex previous = indexes.first();
	QModelIndex current;
	indexes.removeFirst();
	QString selected_text;

	if(indexes.isEmpty())
	{
		QVariant data = model()->data(previous);
		selected_text.append(data.toString());
	}
	else
	{
		Q_FOREACH(current, indexes)
		{
			QVariant data = model()->data(previous);
			selected_text.append(data.toString());
			if (current.row() != previous.row())
			{
				selected_text.append(QLatin1Char('\n'));
			}
			else
			{
				selected_text.append(QLatin1Char('\t'));
			}
			previous = current;
		}
	}
Ejemplo n.º 8
0
void LapTimeComparisonDialog::keyPressEvent(QKeyEvent *event)
{
    if (ui->tabWidget->currentIndex() == 0 && event->key() == Qt::Key_C && event->modifiers() == Qt::ControlModifier)
    {
            QItemSelectionModel * selection = ui->tableWidget->selectionModel();
            QModelIndexList indexes = selection->selectedIndexes();

            if(indexes.size() < 1)
                return;

            // QModelIndex::operator < sorts first by row, then by column.
            // this is what we need
            qSort(indexes.begin(), indexes.end());

            // You need a pair of indexes to find the row changes
            QModelIndex previous = indexes.first();
            indexes.removeFirst();
            QString selected_text;
            QModelIndex current;
            Q_FOREACH(current, indexes)
            {
                QVariant data = ui->tableWidget->model()->data(previous);
                QString text = data.toString();
                // At this point `text` contains the text in one cell
                selected_text.append(text);
                // If you are at the start of the row the row number of the previous index
                // isn't the same.  Text is followed by a row separator, which is a newline.
                if (current.row() != previous.row())
                {
                    selected_text.append(QLatin1Char('\n'));
                }
                // Otherwise it's the same row, so append a column separator, which is a tab.
                else
                {
                    selected_text.append(QLatin1Char('\t'));
                }
                previous = current;
            }
Ejemplo n.º 9
0
void WindingWizardWidget::export_table_to_clipboard(){

    QTableWidget * table = ui->tw_winding;

      QItemSelectionModel * selection = table->selectionModel();
      QModelIndexList indexes = selection->selectedIndexes();

      if(indexes.size() < 1)
        return;

      // QModelIndex::operator < sorts first by row, then by column.
      // this is what we need
      std::sort(indexes.begin(), indexes.end());

      // You need a pair of indexes to find the row changes
      QModelIndex previous = indexes.first();
      indexes.removeFirst();
      QString selected_text;
      QModelIndex current;
      Q_FOREACH(current, indexes)
      {
        QVariant data = table->model()->data(previous);
        QString text = data.toString();
        // At this point `text` contains the text in one cell
        selected_text.append(text);
        // If you are at the start of the row the row number of the previous index
        // isn't the same.  Text is followed by a row separator, which is a newline.
        if (current.row() != previous.row())
        {
          selected_text.append(QLatin1Char('\n'));
        }
        // Otherwise it's the same row, so append a column separator, which is a tab.
        else
        {
          selected_text.append(QLatin1Char('\t'));
        }
        previous = current;
      }
Ejemplo n.º 10
0
void QueryView::copyc()
{
    QItemSelectionModel *s = qview->selectionModel();
    QModelIndexList indices = s->selectedIndexes();
    if(indices.isEmpty()) {
        return;
    }
    qSort(indices);
    QModelIndex prev = indices.first();
    QModelIndex last = indices.last();
    indices.removeFirst();
    QModelIndex current;
    QString selectedText;

    foreach(current, indices) {
        QVariant data = qview->model()->data(prev);
        selectedText.append(data.toString());
        if(current.row() != prev.row())
            selectedText.append(QLatin1Char('\n'));
        else
            selectedText.append(QLatin1Char('\t'));
        prev = current;
    }