! automatically detect the proper format for the datetime columns having the format "yyyy-MM-dd hh:mm:ss" */
| 275 | automatically detect the proper format for the datetime columns having the format "yyyy-MM-dd hh:mm:ss" |
| 276 | */ |
| 277 | void SpreadsheetTest::testCopyPasteColumnMode06() { |
| 278 | Spreadsheet sheet(QStringLiteral("test"), false); |
| 279 | sheet.setColumnCount(2); |
| 280 | sheet.setRowCount(100); |
| 281 | |
| 282 | const QString str = QStringLiteral( |
| 283 | "2018-03-21 10:00:00 1\n" |
| 284 | "2018-03-21 10:30:00 2"); |
| 285 | |
| 286 | QApplication::clipboard()->setText(str); |
| 287 | |
| 288 | SpreadsheetView view(&sheet, false); |
| 289 | view.pasteIntoSelection(); |
| 290 | |
| 291 | // spreadsheet size |
| 292 | QCOMPARE(sheet.columnCount(), 2); |
| 293 | QCOMPARE(sheet.rowCount(), 100); |
| 294 | |
| 295 | // column modes |
| 296 | QCOMPARE(sheet.column(0)->columnMode(), AbstractColumn::ColumnMode::DateTime); |
| 297 | QCOMPARE(sheet.column(1)->columnMode(), AbstractColumn::ColumnMode::Integer); |
| 298 | |
| 299 | // values |
| 300 | auto* filter = static_cast<DateTime2StringFilter*>(sheet.column(0)->outputFilter()); |
| 301 | const QString& format = filter->format(); |
| 302 | |
| 303 | QCOMPARE(sheet.column(0)->dateTimeAt(0).toString(format), QLatin1String("2018-03-21 10:00:00")); |
| 304 | QCOMPARE(sheet.column(1)->integerAt(0), 1); |
| 305 | |
| 306 | QCOMPARE(sheet.column(0)->dateTimeAt(1).toString(format), QLatin1String("2018-03-21 10:30:00")); |
| 307 | QCOMPARE(sheet.column(1)->integerAt(1), 2); |
| 308 | } |
| 309 | |
| 310 | /*! |
| 311 | insert one column with whitespaces surrounding the actual values. |
nothing calls this directly
no test coverage detected