void Spreadsheet::paste() { QTableWidgetSelectionRange range = selectedRange(); QString str = QApplication::clipboard()->text(); QStringList rows = str.split('\n'); int numRows = rows.count(); int numColumns = rows.first().count('\t') + 1; if( range.rowCount() * range.columnCount() != 1 && ( range.rowCount() != numRows || range.columnCount() != numColumns) ) { QMessageBox::information(this, tr("Spreadsheet") , tr("The information cannot be pasted because the copy" "and paste areas aren't the same size.")); return; } for(int i = 0; i < numRows; ++i) { QStringList columns = rows[i].split('\t'); for(int j = 0; j < numColumns; ++j) { int row = range.topRow() + i; int column = range.leftColumn() + j; if(row < RowCount && column < ColumnCount) setFormula(row, column, columns[j]); } } somethingChanged(); }
void Spreadsheet::sort(const SpreadsheetCompare &compare) { QList<QStringList> rows; QTableWidgetSelectionRange range = selectedRange(); int i; for(i = 0; i < range.rowCount(); ++i) { QStringList row; for(int j = 0; j < range.columnCount(); ++j) row.append(formula(range.topRow() + i, range.leftColumn() + j)); rows.append(row); } qStableSort(rows.begin(), rows.end(), compare); for(i = 0; i < range.rowCount(); ++i) { for(int j = 0; j < range.columnCount(); ++j) setFormula(range.topRow() + i, range.leftColumn() + j, rows[i][j]); } clearSelection(); somethingChanged(); }
void Editor::writeSelectionToPasteboard(Pasteboard& pasteboard) { PasteboardWebContent pasteboardContent; pasteboardContent.text = selectedTextForDataTransfer(); pasteboardContent.markup = createMarkup(*selectedRange(), nullptr, AnnotateForInterchange, false, ResolveNonLocalURLs); pasteboard.write(pasteboardContent); }
void Spreadsheet::paste() { QString str = QApplication::clipboard()->text(); QStringList rows = str.split('\n'); int numRows = rows.count(); int numCols = rows.first().count('\t') + 1; QTableWidgetSelectionRange selection = selectedRange(); if(selection.rowCount() * selection.columnCount() != 1 && (numRows != selection.rowCount() || numCols != selection.columnCount())){ QMessageBox::information(this, tr("Spreadsheet"), tr("The information cannot be paseted" "because the copy and the paste areas aren't the same size")); return; } int destRow = selection.topRow(); int destCol = selection.leftColumn(); for(int i=0; i<numRows; i++){ QStringList columns = rows[i].split('\t'); for(int j=0; j<numCols; j++){ if(i+destRow < RowCount && j+destCol < ColumnCount) setFormula(i+destRow, j+destCol, columns[j]); } } somethingChanged(); }
void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText, MailBlockquoteHandling mailBlockquoteHandling) { RefPtr<Range> range = selectedRange(); if (!range) return; bool chosePlainText; RefPtr<DocumentFragment> fragment = createFragmentFromPasteboardData(*pasteboard, m_frame, *range, allowPlainText, chosePlainText); if (fragment && shouldInsertFragment(fragment, range, EditorInsertActionPasted)) pasteAsFragment(fragment.releaseNonNull(), canSmartReplaceWithPasteboard(*pasteboard), chosePlainText, mailBlockquoteHandling); }
void Spreadsheet::copy() { QTableWidgetSelectionRange range = selectedRange(); QString str; for (int i = 0; i < range.rowCount(); ++i) { if (i > 0) str += "\n"; for (int j = 0; j < range.columnCount(); ++j) { if (j > 0) str += "\t"; str += formula(range.topRow() + i, range.leftColumn() + j); } } QApplication::clipboard()->setText(str); }
void Spreadsheet::copy() { QTableWidgetSelectionRange selection = selectedRange(); QString str; int numRows = selection.rowCount(); int numCols = selection.columnCount(); for(int i=0; i<numRows; i++){ for(int j=0; j<numCols; j++){ str += formula(selection.topRow()+i, selection.leftColumn()+j); if(j+1 != numCols) str += "\t"; } if(i+1 != numRows) str += "\n"; } QApplication::clipboard()->setText(str); }
void TrWidget::slotPaste() { QTableWidgetSelectionRange range = selectedRange(); QString str = QApplication::clipboard()->text(); qDebug() << str; QStringList rows = str.split('\n'); int nRows = rows.count(); int nCols = rows.first().count('\t') + 1; for(int i = 0; i < nRows; i++) { QStringList columns = rows.at(i).split('\t'); for(int j = 0; j < nCols; j++) { int row = range.topRow() + i; int col = range.leftColumn() + j; m_table->item(row, col)->setText(columns.at(j)); } } }
void TrWidget::slotCopy() { #if 0 QList<QTableWidgetSelectionRange> ranges = m_table->selectedRanges(); QString str; qDebug() << "slotCopy:" << ranges.size(); for(int i = 0; i < ranges.size(); i++) { if(i > 0) str += "\n"; str += copySelectedRange(ranges.at(i)); } qDebug() << str; QApplication::clipboard()->setText(str); #endif QString str; QTableWidgetItem *item; QTableWidgetSelectionRange range = selectedRange(); qDebug() << "rowCount:" << range.rowCount(); qDebug() << "columnCount:" << range.columnCount(); for(int row = 0; row < range.rowCount(); row++) { if(row > 0){ str += "\n"; } for(int col = 0; col < range.columnCount(); col++) { if(col > 0) str += "\t"; item = m_table->item(range.topRow() + row, range.leftColumn() + col); if(item->text().contains('\n')){ str += QString("\"%1\"").arg(item->text()); }else{ str += item->text(); } } } qDebug() << str; QApplication::clipboard()->setText(str); }
void OperationTable::copy() { QTableWidgetSelectionRange range = selectedRange(); QString str; for(int i = 0; i < range.rowCount(); i++) { for(int j = 0; j < range.columnCount(); j++) { if( isColumnHidden( range.leftColumn() + j ) ) continue; str += this->text( range.topRow() + i, range.leftColumn() + j ); if( j < range.columnCount()-1 ) str += "\t"; } if( i < range.rowCount() - 1 ) str += "\n"; } QApplication::clipboard()->setText(str); }
void UISpreadsheet::paste() { QTableWidgetSelectionRange range = selectedRange(); QString str = QApplication::clipboard()->text(); QStringList rows = str.split('\n'); int numRows = rows.count(); int numColumns = rows.first().count('\t') + 1; cout<<str.toStdString()<<" to paste "<<endl; if (range.rowCount() * range.columnCount() != 1 && (range.rowCount() != numRows || range.columnCount() != numColumns)) { QMessageBox::information(this, tr("Spreadsheet"), tr("The information cannot be pasted because the copy " "and paste areas aren't the same size.")); return; } cout<<"hola-------------------------------"<<endl; for (int i = 0; i < numRows; ++i) { QStringList columns = rows[i].split('\t'); // cout<<"---"<<columns[0].toStdString(); // cout<<" tmb "<<columns[1].toStdString()<<endl; cout<<numRows<<"filas to copy"<<endl; for (int j = 0; j < numColumns; ++j) { int row = range.topRow() + i; cout<<"row"<<row<<endl; int column = range.leftColumn() + j; if (row < RowCount && column < ColumnCount) setFormula(row, column, columns[j]); //somethingChanged(); //cout<<columns[j].toStdString()<<"should paste "<<row<<" "<<column<<endl; } } // somethingChanged(); }