MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / exportSessionToCsv

Method exportSessionToCsv

app/src/Sessions/DatabaseManager.cpp:765–792  ·  view source on GitHub ↗

* @brief Picks an output path and dispatches a streaming CSV export to the worker. */

Source from the content-addressed store, hash-verified

763 * @brief Picks an output path and dispatches a streaming CSV export to the worker.
764 */
765void 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

Callers 1

exportToCsvMethod · 0.80

Calls 4

sanitiseTitleForPathFunction · 0.85
isEmptyMethod · 0.80
valueMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected