MCPcopy Create free account
hub / github.com/GENIVI/CANdevStudio / handleLoadAction

Method handleLoadAction

src/gui/mainwindow.cpp:335–373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

333}
334
335void MainWindow::handleLoadAction()
336{
337 QString fileName = QFileDialog::getOpenFileName(nullptr, "Open project", QDir::homePath(), "CANdevStudio (*.cds)");
338
339 if (fileName.isEmpty()) {
340 cds_debug("Load action cancelled by the user");
341 return;
342 }
343
344 QFile file(fileName);
345
346 if (!file.open(QIODevice::ReadOnly)) {
347 cds_error("Could not open file");
348 return;
349 }
350
351 QByteArray wholeFile = file.readAll();
352
353 // TODO nodeeditor is not validating data. Improve schema file (using required fields) to be safe.
354 if (!ProjectConfigValidator::validateConfiguration(wholeFile)) {
355 QMessageBox::warning(nullptr, "File corrupted", "Invalid file. Project loading aborted");
356 return;
357 }
358
359 QFileInfo fInfo(fileName);
360
361 if (createProjectConfig(fInfo.completeBaseName())) {
362 if (_projectConfig) {
363 _projectConfig->load(wholeFile); // FIXME
364 _projectFile = fileName;
365
366 addRecentProject(_projectName, _projectFile);
367 } else {
368 cds_error("Project config does not exist");
369 }
370 }
371
372 refreshRecentProjects();
373}
374
375void MainWindow::handleAboutAction()
376{

Callers

nothing calls this directly

Calls 1

loadMethod · 0.45

Tested by

no test coverage detected