! automatically detect the proper format for the datetime columns */
| 201 | automatically detect the proper format for the datetime columns |
| 202 | */ |
| 203 | void SpreadsheetTest::testCopyPasteColumnMode04() { |
| 204 | QLocale::setDefault(QLocale::C); // . as decimal separator |
| 205 | Spreadsheet sheet(QStringLiteral("test"), false); |
| 206 | sheet.setColumnCount(2); |
| 207 | sheet.setRowCount(100); |
| 208 | |
| 209 | const QString str = QStringLiteral( |
| 210 | "2020-09-20 11:21:40:849 7.7\n" |
| 211 | "2020-09-20 11:21:41:830 4.2"); |
| 212 | |
| 213 | QApplication::clipboard()->setText(str); |
| 214 | |
| 215 | SpreadsheetView view(&sheet, false); |
| 216 | view.pasteIntoSelection(); |
| 217 | |
| 218 | // spreadsheet size |
| 219 | QCOMPARE(sheet.columnCount(), 2); |
| 220 | QCOMPARE(sheet.rowCount(), 100); |
| 221 | |
| 222 | // column modes |
| 223 | QCOMPARE(sheet.column(0)->columnMode(), AbstractColumn::ColumnMode::DateTime); |
| 224 | QCOMPARE(sheet.column(1)->columnMode(), AbstractColumn::ColumnMode::Double); |
| 225 | |
| 226 | // values |
| 227 | auto* filter = static_cast<DateTime2StringFilter*>(sheet.column(0)->outputFilter()); |
| 228 | const QString& format = filter->format(); |
| 229 | |
| 230 | QCOMPARE(sheet.column(0)->dateTimeAt(0).toString(format), QLatin1String("2020-09-20 11:21:40:849")); |
| 231 | QCOMPARE(sheet.column(1)->valueAt(0), 7.7); |
| 232 | |
| 233 | QCOMPARE(sheet.column(0)->dateTimeAt(1).toString(format), QLatin1String("2020-09-20 11:21:41:830")); |
| 234 | QCOMPARE(sheet.column(1)->valueAt(1), 4.2); |
| 235 | } |
| 236 | |
| 237 | /*! |
| 238 | automatically detect the proper format for the datetime columns, time part only |
nothing calls this directly
no test coverage detected