void AccountsPage::done(int retval)
{
    QTableWidget *tableW = ui->tableWidget;
    if(!tableW->selectionModel())
        return;

    // Figure out which address was selected, and return it
    QModelIndexList indexes = tableW->selectionModel()->selectedRows(2);

    foreach (QModelIndex index, indexes)
    {
        QVariant address = tableW->model()->data(index);
        returnValue = address.toString();
    }
void AccountsPage::selectionChanged()
{
    // Set button states based on selected tab and selection
    QTableWidget *tableW = ui->tableWidget;
    if(!tableW->selectionModel())
        return;

    if(tableW->selectionModel()->hasSelection())
    {
        ui->copyAddress->setEnabled(true);
    }
    else
    {
        ui->copyAddress->setEnabled(false);
    }
}
Example #3
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;
        }
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;
      }