* @brief Picks an output path and dispatches a streaming CSV export to the worker. */
| 763 | * @brief Picks an output path and dispatches a streaming CSV export to the worker. |
| 764 | */ |
| 765 | void Sessions::DatabaseManager::exportSessionToCsv(int sessionId) |
| 766 | { |
| 767 | if (!isOpen() || m_csvExportBusy) |
| 768 | return; |
| 769 | |
| 770 | const auto meta = sessionMetadata(sessionId); |
| 771 | const QString projTitle = meta.value("project_title").toString(); |
| 772 | const QString safeProj = sanitiseTitleForPath(projTitle); |
| 773 | const QString dir = |
| 774 | QStringLiteral("%1/%2").arg(Misc::WorkspaceManager::instance().path("CSV"), safeProj); |
| 775 | QDir().mkpath(dir); |
| 776 | |
| 777 | const QString suggested = |
| 778 | QStringLiteral("%1/session_%2.csv").arg(dir, QString::number(sessionId)); |
| 779 | const auto path = QFileDialog::getSaveFileName( |
| 780 | nullptr, tr("Export Session to CSV"), suggested, tr("CSV files (*.csv)")); |
| 781 | if (path.isEmpty()) |
| 782 | return; |
| 783 | |
| 784 | m_csvExportBusy = true; |
| 785 | m_csvExportProgress = 0.0; |
| 786 | m_pendingCsvPath = path; |
| 787 | Q_EMIT csvExportBusyChanged(); |
| 788 | Q_EMIT csvExportProgressChanged(); |
| 789 | |
| 790 | QMetaObject::invokeMethod( |
| 791 | m_worker, "runCsvExport", Qt::QueuedConnection, Q_ARG(int, sessionId), Q_ARG(QString, path)); |
| 792 | } |
| 793 | |
| 794 | //-------------------------------------------------------------------------------------------------- |
| 795 | // PDF / HTML report export |
no test coverage detected