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

Method newProject

src/frontend/MainWin.cpp:1289–1368  ·  view source on GitHub ↗

! creates a new empty project. Returns \c true, if a new project was created. the parameter \c createInitialContent whether a default content (new worksheet, etc. ) has to be created automatically (it's \c false if a project is opened, \c true if a new project is created). */

Source from the content-addressed store, hash-verified

1287 has to be created automatically (it's \c false if a project is opened, \c true if a new project is created).
1288*/
1289bool MainWin::newProject(bool createInitialContent) {
1290 // close the current project, if available
1291 if (!closeProject())
1292 return false;
1293
1294 QApplication::processEvents(QEventLoop::AllEvents, 100);
1295
1296 m_project = new Project();
1297 undoStackIndexLastSave = 0;
1298 m_currentAspect = m_project;
1299 m_currentFolder = m_project;
1300
1301 KConfigGroup group = Settings::group(QStringLiteral("Settings_General"));
1302 auto vis = Project::DockVisibility(group.readEntry("DockVisibility", 0));
1303 m_project->setDockVisibility(vis);
1304 if (vis == Project::DockVisibility::folderOnly)
1305 m_visibilityFolderAction->setChecked(true);
1306 else if (vis == Project::DockVisibility::folderAndSubfolders)
1307 m_visibilitySubfolderAction->setChecked(true);
1308 else
1309 m_visibilityAllAction->setChecked(true);
1310
1311 m_aspectTreeModel = new AspectTreeModel(m_project, this);
1312 connect(m_aspectTreeModel, &AspectTreeModel::statusInfo, [=](const QString& text) {
1313 statusBar()->showMessage(text);
1314 });
1315
1316 m_newProjectAction->setEnabled(false);
1317#ifdef HAVE_PURPOSE
1318 m_shareAction->setEnabled(false); // sharing is only possible after the project was saved to a file
1319#endif
1320
1321 m_projectExplorer->setModel(m_aspectTreeModel);
1322 m_projectExplorer->setProject(m_project);
1323 m_projectExplorer->setCurrentAspect(m_project);
1324 m_worksheetPreviewWidget->setProject(m_project);
1325 m_guiObserver = new GuiObserver(this); // initialize after all docks were createad
1326
1327 connect(m_project, &Project::childAspectAdded, this, &MainWin::handleAspectAdded);
1328 connect(m_project, &Project::childAspectRemoved, this, &MainWin::handleAspectRemoved);
1329 connect(m_project, &Project::childAspectAboutToBeRemoved, this, &MainWin::handleAspectAboutToBeRemoved);
1330 connect(m_project, SIGNAL(statusInfo(QString)), statusBar(), SLOT(showMessage(QString)));
1331 connect(m_project, &Project::changed, this, &MainWin::projectChanged);
1332 connect(m_project, &Project::requestProjectContextMenu, this, &MainWin::createContextMenu);
1333 connect(m_project, &Project::requestFolderContextMenu, this, &MainWin::createFolderContextMenu);
1334 connect(m_project, &Project::mdiWindowVisibilityChanged, this, &MainWin::updateDockWindowVisibility);
1335 connect(m_project, &Project::closeRequested, this, &MainWin::closeProject);
1336
1337 // depending on the settings, create the default project content (add a worksheet, etc.)
1338 if (createInitialContent) {
1339 const auto newProject = (NewProject)group.readEntry(QStringLiteral("NewProject"), static_cast<int>(NewProject::WithSpreadsheet));
1340 switch (newProject) {
1341 case NewProject::WithWorksheet:
1342 newWorksheet();
1343 break;
1344 case NewProject::WithSpreadsheet:
1345 newSpreadsheet();
1346 break;

Callers

nothing calls this directly

Calls 11

groupFunction · 0.85
showMessageMethod · 0.80
setCurrentAspectMethod · 0.80
QStringClass · 0.50
setDockVisibilityMethod · 0.45
setEnabledMethod · 0.45
setModelMethod · 0.45
setProjectMethod · 0.45
indexOfMethod · 0.45
setChangedMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected