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

Method fileNew

app/src/API/Handlers/ProjectHandler.cpp:1482–1515  ·  view source on GitHub ↗

* @brief Reset the active project to a blank slate. */

Source from the content-addressed store, hash-verified

1480 * @brief Reset the active project to a blank slate.
1481 */
1482API::CommandResponse API::Handlers::ProjectHandler::fileNew(const QString& id,
1483 const QJsonObject& params)
1484{
1485 const bool isDryRun = params.value(QStringLiteral("dryRun")).toBool(false);
1486
1487 if (isDryRun) {
1488 QJsonObject wouldCreate;
1489 wouldCreate[QStringLiteral("title")] = QStringLiteral("Untitled Project");
1490 wouldCreate[QStringLiteral("groupCount")] = 0;
1491 wouldCreate[QStringLiteral("datasetCount")] = 0;
1492 wouldCreate[QStringLiteral("sourceCount")] = 1;
1493
1494 QJsonObject result;
1495 result[QStringLiteral("dryRun")] = true;
1496 result[QStringLiteral("wouldDiscard")] = summarizeCurrentProject();
1497 result[QStringLiteral("wouldCreate")] = wouldCreate;
1498 result[QStringLiteral("warning")] =
1499 QStringLiteral("DRY RUN: no project was reset. The current project (wouldDiscard) "
1500 "would be replaced by a blank one. Confirm before re-issuing without "
1501 "dryRun:true.");
1502 return CommandResponse::makeSuccess(id, result);
1503 }
1504
1505 DataModel::ProjectModel::instance().setSuppressMessageBoxes(true);
1506 DataModel::ProjectModel::instance().newJsonFile();
1507 DataModel::ProjectModel::instance().setSuppressMessageBoxes(false);
1508
1509 AppState::instance().setOperationMode(SerialStudio::ProjectFile);
1510
1511 QJsonObject result;
1512 result[QStringLiteral("created")] = true;
1513 result[QStringLiteral("title")] = DataModel::ProjectModel::instance().title();
1514 return CommandResponse::makeSuccess(id, result);
1515}
1516
1517/**
1518 * @brief Set project title

Callers

nothing calls this directly

Calls 6

summarizeCurrentProjectFunction · 0.85
newJsonFileMethod · 0.80
titleMethod · 0.80
valueMethod · 0.45
setOperationModeMethod · 0.45

Tested by

no test coverage detected