16,202
社区成员
发帖
与我相关
我的任务
分享
void MainWindow::GoToCell()
{
if ( !dialog_) {
dialog_ = new GoToCellDialog(this);
} else {
dialog_->SetText("");
}
if (dialog_->exec()) {
}
}
void MainWindow::LoadUi()
{
QFile file(":/ui/gotocelldialog.ui");
if ( !file.open(QFile::ReadOnly)) {
return;
}
QUiLoader loader;
GoToCellDialog* dialog = (GoToCellDialog*) loader.load(&file, this);
if (dialog->exec()) {
}
delete dialog;
}
void Spreadsheet::Paste()
{
QTableWidgetSelectionRange range = SelectedRange();
QString content = QApplication::clipboard()->text();
QStringList rows_content = content.split('\n');
const int number_rows(rows_content.count());
const int number_columns(rows_content.first().count('\t') + 1);
if ((1 != (range.rowCount() * range.columnCount())) &&
(range.rowCount() != number_rows || range.columnCount() != number_columns)) {
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 row=0; number_rows != row; ++row) {
QStringList columns_content = rows_content[row].split('\t');
for (int column=0; number_columns != column; ++column) {
int i = range.topRow() + row;
int j = range.leftColumn() + column;
if (ROW_COUNT_ > i && COLUMN_COUNT_ > j) {
SetFormula(i, j, columns_content[j]);
}
}
}
SomethingChanged();
}
void MainWindow::LoadUi()
{
QFile file(":/ui/gotocelldialog.ui");
if ( !file.open(QFile::ReadOnly)) {
return;
}
QUiLoader loader;
GoToCellDialog* dialog = (GoToCellDialog*) loader.load(&file, this);
if (dialog->exec()) {
dialog->SetText("Ok");
}
delete dialog;
}