QList<double> Calculator::extractData(const QStringList &stringArgs, const QList<double> &doubleArgs) { QList<double> returnList; for (int i = 0; i < stringArgs.size(); i++) { int iterator = 0; if (isRange(stringArgs[i] + QChar(QChar::Null), iterator)) { if (iterator == stringArgs[i].size()) //if there is only a range in the argument { QTableWidgetSelectionRange range; Table::decodeRange(stringArgs[i], range); for (int row=range.topRow(); row<=range.bottomRow(); row++) { for (int column=range.leftColumn(); column<=range.rightColumn(); column++) { returnList.append(table -> getItemText(row, column).toDouble()); } } continue; } } returnList.append(doubleArgs[i]); } return returnList; }
void PreFlightCheckListPage::slotEdit() { QTableWidgetItem* item = m_list->currentItem(); if( item == static_cast<QTableWidgetItem *>(0) ) { // Item can be a Null pointer! return; } QList<QTableWidgetSelectionRange> selRangeList = m_list->selectedRanges(); if( selRangeList.size() == 0 ) { // Nothing seems to be selected return; } QTableWidgetSelectionRange sr = selRangeList.at(0); if( sr.rowCount() > 1 ) { // More than one row are selected return; } if( sr.rightColumn() == 1 ) { slotEditCell( m_list->currentRow(), 1 ); } }
void Matrix::copySelection() { QString the_text; QList<QTableWidgetSelectionRange> sel = d_table->selectedRanges(); if (sel.isEmpty()) the_text = text(d_table->currentRow(),d_table->currentColumn()); else { QListIterator<QTableWidgetSelectionRange> it(sel); QTableWidgetSelectionRange cur; if(!it.hasNext())return; cur = it.next(); int top = cur.topRow(); int bottom = cur.bottomRow(); int left = cur.leftColumn(); int right = cur.rightColumn(); for(int i=top; i<=bottom; i++) { for(int j=left; j<right; j++) the_text += text(i,j)+"\t"; the_text += text(i,right)+"\n"; } } // Copy text into the clipboard QApplication::clipboard()->setText(the_text); }
void QueryPathsDialog::tableSelectionChanged() { QList<QTableWidgetSelectionRange> selection = ui->tableWidget->selectedRanges(); int totalSelectedRows = 0; for (int i = 0; i < selection.size(); ++i) totalSelectedRows += selection[i].rowCount(); g_memory->queryPaths.clear(); QList<int> selectedRows; for (int i = 0; i < selection.size(); ++i) { QTableWidgetSelectionRange * selectionRange = &(selection[i]); int top = selectionRange->topRow(); int bottom = selectionRange->bottomRow(); for (int row = top; row <= bottom; ++row) { if (!selectedRows.contains(row)) selectedRows.push_back(row); } } for (int i = 0; i < selectedRows.size(); ++i) { int row = selectedRows[i]; QString pathString = ui->tableWidget->item(row, 0)->text(); QString pathStringFailure; g_memory->queryPaths.push_back(Path::makeFromString(pathString, false, &pathStringFailure)); } emit selectionChanged(); }
void MainWindow::on_actionCopy_triggered() { QString str; QString s; QTextStream ss(&s); QList<QTableWidgetSelectionRange> ranges = ui->tableWidget->selectedRanges(); if(ranges.isEmpty()) return; QTableWidgetSelectionRange range = ui->tableWidget->selectedRanges().first(); 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"; if(j==1 && range.columnCount() == 3){ ss << left << qSetFieldWidth(35) << ui->tableWidget->item(range.topRow()+i,range.leftColumn()+j)->text(); str+=ui->tableWidget->item(range.topRow()+i,range.leftColumn()+j)->text(); } else{ ss << left << qSetFieldWidth(55) << ui->tableWidget->item(range.topRow()+i,range.leftColumn()+j)->text() << qSetFieldWidth(0); str+=ui->tableWidget->item(range.topRow()+i,range.leftColumn()+j)->text();} } ss << endl; } QApplication::clipboard()->setText(s); // qDebug() << str; //qDebug() << s; }
void ViewTableListWidget::showRightMenu( const QPoint & pos) { //显示右键菜单 qDebug()<<tr("视图菜单")<<pos.x()<<" "<<pos.y(); QTableWidgetItem *curItem = this->itemAt(pos); if(curItem != NULL) { curindex = currentRow(); viewfilenames.clear(); QList<QTableWidgetSelectionRange> rangelist = this->selectedRanges(); QList<QTableWidgetSelectionRange>::iterator iter = rangelist.begin(); while(iter != rangelist.end()) { QTableWidgetSelectionRange range = *iter; for(int i =range.topRow(); i<=range.bottomRow(); i++ ) viewfilenames<<item(i,0)->text(); ++iter; } } qDebug()<<viewfilenames; this->createRightMenu((int *)curItem); }
void MainWindow::on_actionSort_triggered() { SortDialog dialog(this); QTableWidgetSelectionRange range = spreadsheet->selectedRange(); dialog.setColumnRange('A' + range.leftColumn(), 'A' + range.rightColumn()); if(dialog.exec()){ spreadsheet->sort(Compare(dialog)); } }
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 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); }
static QTableWidgetItem *getSelectedRow(QTableWidget *tbl) { QList<QTableWidgetSelectionRange> selections = tbl->selectedRanges(); if(selections.size() != 1) return 0; QTableWidgetSelectionRange selection = selections.first(); if(selection.rowCount() != 1) return 0; int row = selection.topRow(); return tbl->item(row, 0); }
void MainWindow::sort() { SortDialog dialog(this); QTableWidgetSelectionRange range = spreadsheet->selectedRange(); dialog.setColumnRange('A' + range.leftColumn(),'A'+range.rightColumn()); if(dialog.exec()) { SpreadsheetCompare compare; compare.keys[0]=dialog.primarycolumncombo->currentIndex(); compare.keys[1]=dialog.sencondarycolumncombo->currentIndex() - 1; compare.keys[2]=dialog.tertiarycolumncombo->currentIndex() - 1; compare.ascending[0] = (dialog.primaryordercombo->currentIndex() ==0); compare.ascending[1] = (dialog.secondaryordercombo->currentIndex() == 0); compare.ascending[2] = (dialog.tertiaryordercombo->currentIndex() == 0); spreadsheet->sort(compare); } }
bool Matrix::rowsSelected() { QList<QTableWidgetSelectionRange> sel = d_table->selectedRanges(); QListIterator<QTableWidgetSelectionRange> it(sel); QTableWidgetSelectionRange cur; if( it.hasNext() ) { cur = it.next(); for(int i=cur.topRow(); i<=cur.bottomRow(); i++) { if (!isRowSelected (i, true)) return false; } } return true; }
void TableWidget::copyCells(){ QList<QTableWidgetSelectionRange> ranges = selectedRanges(); if(ranges.size()==0){ return; } QTableWidgetSelectionRange range = ranges[0]; 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"; } if(!item(i,j)){ str += ""; }else{ str += item(range.topRow() +i, range.leftColumn()+j)->text(); qDebug()<<"adding to clipbard: "<<item(range.topRow() +i, range.leftColumn()+j)->text(); } } } QApplication::clipboard()->setText(str); }
bool Matrix::isRowSelected(int row, bool full) { QList<QTableWidgetSelectionRange> sel = d_table->selectedRanges(); QListIterator<QTableWidgetSelectionRange> it(sel); QTableWidgetSelectionRange cur; if ( !full ) { if( it.hasNext() ) { cur = it.next(); if ( (row >= cur.topRow()) && (row <= cur.bottomRow() ) ) return true; } } else { if( it.hasNext() ) { cur = it.next(); if ( row >= cur.topRow() && row <= cur.bottomRow() && cur.leftColumn() == 0 && cur.rightColumn() == numCols() - 1 ) return true; } } return false; }
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::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 Matrix::clearSelection() { allow_modification_signals = false; QList<QTableWidgetSelectionRange> sel = d_table->selectedRanges(); QListIterator<QTableWidgetSelectionRange> it(sel); QTableWidgetSelectionRange cur; if( it.hasNext() ) { cur = it.next(); for(int i = cur.topRow(); i <= cur.bottomRow(); i++) for(int j = cur.leftColumn(); j<= cur.rightColumn();j++) setText(i, j, ""); } allow_modification_signals = true; emit modifiedWindow(this); }
void PMeshViewer::deleteMesh() { QList<QTableWidgetSelectionRange> list = meshTable->selectedRanges(); if (list.isEmpty()) return; QTableWidgetSelectionRange range = list[0]; // Only 1 range. for (int i = range.bottomRow(); i >= range.topRow(); --i) { meshTable->removeRow(i); renderer->RemoveActor(meshList[i].actor); meshList[i].normals->Delete(); meshList[i].mapper->Delete(); meshList[i].actor->Delete(); meshList.removeAt(i); } renderWindow->Render(); }
void TableWidget::copy() { // Get a list of all selected ranges: QList<QTableWidgetSelectionRange> selectedRanges = this->selectedRanges(); if(selectedRanges.isEmpty()) return; // Establish the outer boundary of all selections: int leftColumn = this->columnCount() - 1; int rightColumn = 0; int topRow = this->rowCount() - 1; int bottomRow = 0; for(int i = 0; i < selectedRanges.size(); i++) { QTableWidgetSelectionRange range = selectedRanges.at(i); if(range.leftColumn() < leftColumn) leftColumn = range.leftColumn(); if(range.rightColumn() > rightColumn) rightColumn = range.rightColumn(); if(range.topRow() < topRow) topRow = range.topRow(); if(range.bottomRow() > bottomRow) bottomRow = range.bottomRow(); } if(bottomRow < topRow or rightColumn < leftColumn) return; // Loop through selection range and extract data: QString outputText; for(int i = topRow; i <= bottomRow; i++) { for(int j = leftColumn; j <= rightColumn; j++) { if(this->item(i, j)->isSelected()) { outputText += this->item(i, j)->text(); } if (j < rightColumn) outputText += "\t"; else outputText += "\n"; } } // Copy data to clipboard: QClipboard *clipboard = QApplication::clipboard(); clipboard->setText(outputText); return; }
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 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 TableWidget::checkRows(){ QAction *action = qobject_cast<QAction*>(sender()); bool checked = action->data().toBool(); QList<QTableWidgetSelectionRange> ranges = selectedRanges(); if(ranges.size()==0){ return; } QTableWidgetSelectionRange range = ranges[0]; for(int i=range.topRow(); i<=range.bottomRow(); ++i) { if(!item(i,0)){ continue; } if(checked){ item(i,0)->setCheckState(Qt::Checked); }else{ item(i,0)->setCheckState(Qt::Unchecked); } } }
void PhotoTexturingWidget::calculateTextures(){ bool calcZBuffer =ui.checkBoxzBuffer->isChecked(); bool selectedCamOnly = ui.selectedCameraOnlyCheckBox->isChecked(); if (!selectedCamOnly){ photoTexturer->calculateMeshTextureForAllCameras(mesh,calcZBuffer); }else{ QList<QTableWidgetSelectionRange> ranges = ui.cameraTableWidget->selectedRanges(); for (int i=0;i<ranges.size();i++){ QTableWidgetSelectionRange range = ranges.at(i); for(int j=range.topRow();j<=range.bottomRow();j++){ Camera *cam = photoTexturer->cameras.at(j); photoTexturer->calculateMeshTextureForCamera(mesh,cam,calcZBuffer); } } } glarea->update(); update(); updateGLAreaTextures(); updateMainWindowMenus(); }
void TableWidget::paste(){ QList<QTableWidgetSelectionRange> ranges = selectedRanges(); if(ranges.size()==0){ return; } QTableWidgetSelectionRange range = ranges[0]; if(range.leftColumn()<TITLE || range.rightColumn()<TITLE){ QMessageBox::information(this, tr("Discogs dialog"), tr("Pasting in the three first columns is not allowed") ); return; } QString str = QApplication::clipboard()->text(); qDebug()<<"clipboard: "; qDebug()<<str; 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("Discogs dialog"), tr("The information cannot be pasted because the copy " "and paste areas aren't the same size.")); return; } bool enabled = isSortingEnabled(); setSortingEnabled(false); 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()){ if(!item(row,column)){ TableWidgetItem *item = new TableWidgetItem; setItem(row,column,item); } item(row,column)->setText(columns[j]); } } } setSortingEnabled(enabled); }
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); } }
void TransactionWidget::copy() { QTableWidgetSelectionRange range = table->selectedRange(); QString str; QString t; bool ok = false; for(int i = 0; i < range.rowCount(); i++) { for(int j = 0; j < range.columnCount(); j++) { if( table->isColumnHidden( range.leftColumn() + j ) ) continue; t = table->text( range.topRow() + i, range.leftColumn() + j ); if( j >= 2 && j <= 4 ) { double d = t.toDouble(&ok); if( ok ) { int conv = 0; if( j == 3 ) conv = 3; else conv = 2; t = QString::number( d, 'f', conv ); } //text = convertSumForDouble( text ); } str += t; if( j < range.columnCount()-1 ) str += "\t"; } if( i < range.rowCount() - 1 ) str += "\n"; } 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 DatPanel::copy() { QTableWidgetSelectionRange ts = tab->selectedRanges().first(); register long i,j; QString res, s; for(j=ts.topRow();j<=ts.bottomRow();j++) { for(i=ts.leftColumn();i<=ts.rightColumn();i++) { res = res + tab->item(j,i)->text(); if(i<ts.rightColumn()) res = res + "\t"; } res = res + "\n"; } QApplication::clipboard()->setText(res, QClipboard::Clipboard); }
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 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(); }