! automatically detect the proper format for the datetime columns, time part only */
| 238 | automatically detect the proper format for the datetime columns, time part only |
| 239 | */ |
| 240 | void SpreadsheetTest::testCopyPasteColumnMode05() { |
| 241 | QLocale::setDefault(QLocale::C); // . as decimal separator |
| 242 | Spreadsheet sheet(QStringLiteral("test"), false); |
| 243 | sheet.setColumnCount(2); |
| 244 | sheet.setRowCount(100); |
| 245 | |
| 246 | const QString str = QStringLiteral( |
| 247 | "11:21:40 7.7\n" |
| 248 | "11:21:41 4.2"); |
| 249 | |
| 250 | QApplication::clipboard()->setText(str); |
| 251 | |
| 252 | SpreadsheetView view(&sheet, false); |
| 253 | view.pasteIntoSelection(); |
| 254 | |
| 255 | // spreadsheet size |
| 256 | QCOMPARE(sheet.columnCount(), 2); |
| 257 | QCOMPARE(sheet.rowCount(), 100); |
| 258 | |
| 259 | // column modes |
| 260 | QCOMPARE(sheet.column(0)->columnMode(), AbstractColumn::ColumnMode::DateTime); |
| 261 | QCOMPARE(sheet.column(1)->columnMode(), AbstractColumn::ColumnMode::Double); |
| 262 | |
| 263 | // values |
| 264 | auto* filter = static_cast<DateTime2StringFilter*>(sheet.column(0)->outputFilter()); |
| 265 | const QString& format = filter->format(); |
| 266 | |
| 267 | QCOMPARE(sheet.column(0)->dateTimeAt(0).toString(format), QLatin1String("11:21:40")); |
| 268 | QCOMPARE(sheet.column(1)->valueAt(0), 7.7); |
| 269 | |
| 270 | QCOMPARE(sheet.column(0)->dateTimeAt(1).toString(format), QLatin1String("11:21:41")); |
| 271 | QCOMPARE(sheet.column(1)->valueAt(1), 4.2); |
| 272 | } |
| 273 | |
| 274 | /*! |
| 275 | automatically detect the proper format for the datetime columns having the format "yyyy-MM-dd hh:mm:ss" |
nothing calls this directly
no test coverage detected