MCPcopy Create free account
hub / github.com/KDE/labplot / closeProject

Method closeProject

src/frontend/MainWin.cpp:1666–1717  ·  view source on GitHub ↗

! Closes the current project, if available. Return \c true, if the project was closed. */

Source from the content-addressed store, hash-verified

1664 Closes the current project, if available. Return \c true, if the project was closed.
1665*/
1666bool MainWin::closeProject() {
1667 if (m_project == nullptr)
1668 return true; // nothing to close
1669
1670 if (warnModified())
1671 return false;
1672
1673 // clear the worksheet preview before deleting the project and before deleting the dock widgets
1674 // so we don't need to react on current aspect changes
1675 if (m_worksheetPreviewWidget)
1676 m_worksheetPreviewWidget->setProject(nullptr);
1677
1678 if (!m_closing) {
1679 // if (dynamic_cast<QQuickWidget*>(centralWidget()) && m_showWelcomeScreen) {
1680 // m_welcomeWidget = createWelcomeScreen();
1681 // setCentralWidget(m_welcomeWidget);
1682 // }
1683 }
1684
1685 for (auto dock : m_dockManagerContent->dockWidgetsMap())
1686 m_dockManagerContent->removeDockWidget(dock);
1687
1688 m_projectClosing = true;
1689 statusBar()->clearMessage();
1690 delete m_guiObserver;
1691 m_guiObserver = nullptr;
1692 delete m_aspectTreeModel;
1693 m_aspectTreeModel = nullptr;
1694 delete m_project;
1695 m_project = nullptr;
1696 m_projectClosing = false;
1697
1698 // update the UI if we're just closing a project
1699 // and not closing(quitting) the application
1700 if (!m_closing) {
1701 m_currentAspect = nullptr;
1702 m_currentFolder = nullptr;
1703 updateGUIOnProjectChanges();
1704 m_newProjectAction->setEnabled(true);
1705
1706 if (m_autoSaveActive)
1707 m_autoSaveTimer.stop();
1708 }
1709
1710 if (cursorDock) {
1711 delete cursorDock;
1712 cursorDock = nullptr;
1713 cursorWidget = nullptr; // is deleted, because it's the child of cursorDock
1714 }
1715
1716 return true;
1717}
1718
1719bool MainWin::saveProject() {
1720 QString fileName = m_project->fileName();

Callers 1

closeEventMethod · 0.95

Calls 4

dockWidgetsMapMethod · 0.80
setProjectMethod · 0.45
removeDockWidgetMethod · 0.45
setEnabledMethod · 0.45

Tested by

no test coverage detected