BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ProjectManager Class Reference

Handles activity related to opening/save projects. More...

Inheritance diagram for ProjectManager:
[legend]
Collaboration diagram for ProjectManager:
[legend]

Classes

struct  ProjectManagerImpl
 

Public Slots

void clearRecentProjects ()
 Clears list of recent projects. More...
 
bool closeCurrentProject ()
 Processes close current project request. More...
 
void newProject ()
 Processes new project request (close old project, rise dialog for project name, create project). More...
 
void onDocumentModified ()
 Updates title of main window when the project was modified. More...
 
void openProject (QString fileName="")
 Opens existing project. If fileName is empty, will popup file selection dialog. More...
 
bool saveProject (QString projectFileName="")
 Processes save project request. More...
 
bool saveProjectAs ()
 Processes 'save project as' request. More...
 
void setAutosaveEnabled (bool value)
 

Signals

void modified ()
 

Public Member Functions

 ProjectManager (MainWindow *parent)
 
virtual ~ProjectManager ()
 
ProjectDocumentdocument ()
 
bool isAutosaveEnabled () const
 
QString projectDir () const
 Returns name of the current project directory. More...
 
void readSettings ()
 Reads settings of ProjectManager from global settings. More...
 
QString recentlyUsedImportFilter1D () const
 
QString recentlyUsedImportFilter2D () const
 
QStringList recentProjects ()
 Returns list of recent projects, validates if projects still exists on disk. More...
 
void setImportDir (const QString &dirname)
 Sets user import directory in system settings. More...
 
void setImportDirFromFilePath (const QString &filePath)
 Sets user import directory in system settings. More...
 
void setRecentlyUsedImportFilter1D (const QString &filter)
 
void setRecentlyUsedImportFilter2D (const QString &filter)
 
QString userExportDir () const
 Returns directory name suitable for saving plots. More...
 
QString userImportDir () const
 Returns directory name which was used by the user to import files. More...
 
void writeSettings ()
 Saves settings of ProjectManager in global settings. More...
 

Private Member Functions

QString acquireProjectFileName (bool forSaveAs)
 Returns project file name from dialog. Returns empty string if dialog was canceled. More...
 
void addToRecentProjects ()
 Add name of the current project to the name of recent projects. More...
 
void createNewProject ()
 Calls dialog window to define project path and name. More...
 
void deleteCurrentProject ()
 
void loadProject (const QString &projectFileName)
 Load project data from file name. If autosave info exists, opens dialog for project restore. More...
 
bool restoreProjectDialog (const QString &projectFileName)
 Rises dialog if the project should be restored from autosave. Returns true, if yes. More...
 
void riseProjectLoadFailedDialog ()
 
void riseProjectLoadWarningDialog ()
 
QString untitledProjectName ()
 Will return 'Untitled' if the directory with such name doesn't exist in project path. More...
 
QString workingDirectory ()
 Returns default project path. More...
 

Private Attributes

QString m_importDirectory
 
QString m_importFilter1D
 Recently used import filter for 1D files. More...
 
QString m_importFilter2D
 Recently used import filter for 2D files. More...
 
MainWindowm_mainWindow
 
MessageServicem_messageService
 
ProjectDocumentm_project_document
 Name of directory where project directory was created. More...
 
QStringList m_recentProjects
 
SaveServicem_saveService
 
QString m_workingDirectory
 Name of directory from there user prefer to import files. More...
 

Detailed Description

Handles activity related to opening/save projects.

Definition at line 28 of file projectmanager.h.

Constructor & Destructor Documentation

◆ ProjectManager()

ProjectManager::ProjectManager ( MainWindow parent)

Definition at line 45 of file projectmanager.cpp.

46  : m_mainWindow(parent)
47  , m_project_document(nullptr)
49  , m_saveService(new SaveService(this))
50 
51 {
53  AppSvc::subscribe(this);
54 }
static void subscribe(ProjectManager *projectManager)
Definition: AppSvc.cpp:23
The service to collect messages from different senders.
MainWindow * m_mainWindow
void createNewProject()
Calls dialog window to define project path and name.
SaveService * m_saveService
ProjectDocument * m_project_document
Name of directory where project directory was created.
MessageService * m_messageService
Provides save/autosave of ProjectDocument in a thread.
Definition: SaveService.h:26

References createNewProject(), and AppSvc::subscribe().

Here is the call graph for this function:

◆ ~ProjectManager()

ProjectManager::~ProjectManager ( )
virtual

Definition at line 56 of file projectmanager.cpp.

57 {
58  AppSvc::unsubscribe(this);
59  delete m_project_document;
60  delete m_messageService;
61 }
static void unsubscribe(ProjectManager *projectManager)
Definition: AppSvc.cpp:28

References m_messageService, m_project_document, and AppSvc::unsubscribe().

Here is the call graph for this function:

Member Function Documentation

◆ acquireProjectFileName()

QString ProjectManager::acquireProjectFileName ( bool  forSaveAs)
private

Returns project file name from dialog. Returns empty string if dialog was canceled.

Definition at line 395 of file projectmanager.cpp.

396 {
400 
401  if (dialog.exec() != QDialog::Accepted)
402  return "";
403 
404  m_workingDirectory = dialog.getWorkingDirectory();
405 
406  return dialog.getProjectFileName();
407 }
new project dialog window
QString untitledProjectName()
Will return 'Untitled' if the directory with such name doesn't exist in project path.
QString m_workingDirectory
Name of directory from there user prefer to import files.
QString workingDirectory()
Returns default project path.

References NewProjectDialog::CREATE, NewProjectDialog::getProjectFileName(), NewProjectDialog::getWorkingDirectory(), m_mainWindow, m_workingDirectory, NewProjectDialog::SAVE, untitledProjectName(), and workingDirectory().

Referenced by newProject(), saveProject(), and saveProjectAs().

Here is the call graph for this function:

◆ addToRecentProjects()

void ProjectManager::addToRecentProjects ( )
private

Add name of the current project to the name of recent projects.

Definition at line 411 of file projectmanager.cpp.

412 {
413  QString fileName = m_project_document->projectFileName();
414  m_recentProjects.removeAll(fileName);
415  m_recentProjects.prepend(fileName);
417  m_recentProjects.removeLast();
418 }
QString projectFileName() const
QStringList m_recentProjects
const int MAX_RECENT_PROJECTS

References m_project_document, m_recentProjects, Constants::MAX_RECENT_PROJECTS, and ProjectDocument::projectFileName().

Referenced by openProject(), and saveProject().

Here is the call graph for this function:

◆ clearRecentProjects

void ProjectManager::clearRecentProjects ( )
slot

Clears list of recent projects.

Definition at line 213 of file projectmanager.cpp.

214 {
215  m_recentProjects.clear();
216  modified();
217 }

References m_recentProjects, and modified().

Referenced by ActionManager::onAboutToShowFileMenu().

◆ closeCurrentProject

bool ProjectManager::closeCurrentProject ( )
slot

Processes close current project request.

Call save/discard/cancel dialog, if necessary. Returns false if saving was canceled.

Definition at line 236 of file projectmanager.cpp.

237 {
238  if (!m_project_document)
239  return true;
240 
241  bool projectWasClosed(true);
242 
244  QMessageBox msgBox;
245  msgBox.setText("The project has been modified.");
246  msgBox.setInformativeText("Do you want to save your changes?");
247  msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
248  msgBox.setDefaultButton(QMessageBox::Save);
249  int ret = msgBox.exec();
250 
251  switch (ret) {
252  case QMessageBox::Save:
253  if (!saveProject())
254  projectWasClosed = false;
255  break;
256  case QMessageBox::Discard:
257  break;
258  case QMessageBox::Cancel:
259  projectWasClosed = false;
260  break;
261  default:
262  break;
263  }
264  }
265 
266  if (projectWasClosed)
268 
269  return projectWasClosed;
270 }
bool saveProject(QString projectFileName="")
Processes save project request.
void deleteCurrentProject()

References deleteCurrentProject(), ProjectDocument::isModified(), m_project_document, and saveProject().

Referenced by MainWindow::closeEvent(), newProject(), and openProject().

Here is the call graph for this function:

◆ createNewProject()

void ProjectManager::createNewProject ( )
private

Calls dialog window to define project path and name.

Definition at line 349 of file projectmanager.cpp.

350 {
351  if (m_project_document)
352  throw GUIHelpers::Error("ProjectManager::createNewProject() -> Project already exists");
353 
355 
359  m_project_document->setProjectName("Untitled");
362 
364 }
ApplicationModels * models()
Definition: mainwindow.cpp:159
Project document class handles all data related to the opened project (sample, jobModel,...
void setApplicationModels(ApplicationModels *applicationModels)
void setProjectName(const QString &text)
void setLogger(MessageService *messageService)
void onDocumentModified()
Updates title of main window when the project was modified.
void setDocument(ProjectDocument *document)
Definition: SaveService.cpp:46

References MessageService::clear(), m_mainWindow, m_messageService, m_project_document, m_saveService, MainWindow::models(), ProjectDocument::modified(), onDocumentModified(), ProjectDocument::setApplicationModels(), SaveService::setDocument(), ProjectDocument::setLogger(), and ProjectDocument::setProjectName().

Referenced by ProjectManager(), newProject(), and openProject().

Here is the call graph for this function:

◆ deleteCurrentProject()

void ProjectManager::deleteCurrentProject ( )
private

Definition at line 366 of file projectmanager.cpp.

367 {
369 
370  delete m_project_document;
371  m_project_document = 0;
373 }
void resetModels()
reset all models to initial state
void stopService()
Definition: SaveService.cpp:98

References m_mainWindow, m_project_document, m_saveService, MainWindow::models(), ApplicationModels::resetModels(), and SaveService::stopService().

Referenced by closeCurrentProject(), and openProject().

Here is the call graph for this function:

◆ document()

ProjectDocument * ProjectManager::document ( )

Definition at line 107 of file projectmanager.cpp.

108 {
109  return m_project_document;
110 }

References m_project_document.

◆ isAutosaveEnabled()

bool ProjectManager::isAutosaveEnabled ( ) const

Definition at line 188 of file projectmanager.cpp.

189 {
191 }
bool isAutosaveEnabled() const
Definition: SaveService.cpp:78

References SaveService::isAutosaveEnabled(), and m_saveService.

Referenced by ActionManager::onAboutToShowSettingsMenu().

Here is the call graph for this function:

◆ loadProject()

void ProjectManager::loadProject ( const QString &  projectFileName)
private

Load project data from file name. If autosave info exists, opens dialog for project restore.

Definition at line 377 of file projectmanager.cpp.

378 {
379  bool useAutosave = m_saveService && ProjectUtils::hasAutosavedData(projectFileName);
380 
381  if (useAutosave && restoreProjectDialog(projectFileName)) {
382  QApplication::setOverrideCursor(Qt::WaitCursor);
384  m_project_document->setProjectFileName(projectFileName);
386  } else {
387  QApplication::setOverrideCursor(Qt::WaitCursor);
388  m_project_document->load(projectFileName);
389  }
390  QApplication::restoreOverrideCursor();
391 }
void load(const QString &project_file_name)
void setProjectFileName(const QString &text)
void setModified(bool flag)
bool restoreProjectDialog(const QString &projectFileName)
Rises dialog if the project should be restored from autosave. Returns true, if yes.
QString autosaveName(const QString &projectFileName)
Returns name of project for autoSave from given project file name.
bool hasAutosavedData(const QString &projectFileName)
Returns true if project with given projectFileName contains autosaved data.

References ProjectUtils::autosaveName(), ProjectUtils::hasAutosavedData(), ProjectDocument::load(), m_project_document, m_saveService, restoreProjectDialog(), ProjectDocument::setModified(), and ProjectDocument::setProjectFileName().

Referenced by openProject().

Here is the call graph for this function:

◆ modified

void ProjectManager::modified ( )
signal

◆ newProject

void ProjectManager::newProject ( )
slot

Processes new project request (close old project, rise dialog for project name, create project).

Definition at line 221 of file projectmanager.cpp.

222 {
223  if (!closeCurrentProject())
224  return;
225 
227 
228  QString projectFileName = acquireProjectFileName(false);
229  if (!projectFileName.isEmpty())
230  saveProject(projectFileName);
231 }
QString acquireProjectFileName(bool forSaveAs)
Returns project file name from dialog. Returns empty string if dialog was canceled.
bool closeCurrentProject()
Processes close current project request.

References acquireProjectFileName(), closeCurrentProject(), createNewProject(), and saveProject().

Referenced by WelcomeView::WelcomeView(), and ActionManager::createActions().

Here is the call graph for this function:

◆ onDocumentModified

void ProjectManager::onDocumentModified ( )
slot

Updates title of main window when the project was modified.

Definition at line 202 of file projectmanager.cpp.

203 {
205  m_mainWindow->setWindowTitle("*" + m_project_document->projectName());
206  } else {
207  m_mainWindow->setWindowTitle(m_project_document->projectName());
208  }
209 }
QString projectName() const

References ProjectDocument::isModified(), m_mainWindow, m_project_document, and ProjectDocument::projectName().

Referenced by createNewProject().

Here is the call graph for this function:

◆ openProject

void ProjectManager::openProject ( QString  fileName = "")
slot

Opens existing project. If fileName is empty, will popup file selection dialog.

Definition at line 317 of file projectmanager.cpp.

318 {
319  if (!closeCurrentProject())
320  return;
321 
323 
324  if (fileName.isEmpty()) {
325  fileName =
326  QFileDialog::getOpenFileName(m_mainWindow, "Open project file", workingDirectory(),
327  "BornAgain project Files (*.pro)");
328  if (fileName.isEmpty())
329  return;
330  }
331 
332  loadProject(fileName);
333 
334  if (m_project_document->isReady()) {
336  } else if (m_project_document->hasErrors()) {
340  } else if (m_project_document->hasWarnings()) {
343  }
344  emit modified();
345 }
bool isReady() const
bool hasWarnings() const
bool hasErrors() const
void riseProjectLoadFailedDialog()
void loadProject(const QString &projectFileName)
Load project data from file name. If autosave info exists, opens dialog for project restore.
void addToRecentProjects()
Add name of the current project to the name of recent projects.
void riseProjectLoadWarningDialog()

References addToRecentProjects(), closeCurrentProject(), createNewProject(), deleteCurrentProject(), ProjectDocument::hasErrors(), ProjectDocument::hasWarnings(), ProjectDocument::isReady(), loadProject(), m_mainWindow, m_project_document, modified(), riseProjectLoadFailedDialog(), riseProjectLoadWarningDialog(), and workingDirectory().

Referenced by WelcomeView::WelcomeView(), ActionManager::createActions(), WelcomeView::generateRecentProjectList(), and MainWindow::openRecentProject().

Here is the call graph for this function:

◆ projectDir()

QString ProjectManager::projectDir ( ) const

Returns name of the current project directory.

Definition at line 128 of file projectmanager.cpp.

129 {
131  return m_project_document->projectDir();
132 
133  return "";
134 }
QString projectDir() const

References ProjectDocument::hasValidNameAndPath(), m_project_document, and ProjectDocument::projectDir().

Referenced by SimulationSetupWidget::onExportToPythonScript(), untitledProjectName(), and userExportDir().

Here is the call graph for this function:

◆ readSettings()

void ProjectManager::readSettings ( )

Reads settings of ProjectManager from global settings.

Definition at line 65 of file projectmanager.cpp.

66 {
67  QSettings settings;
68  m_workingDirectory = QDir::homePath();
69  if (settings.childGroups().contains(S_PROJECTMANAGER)) {
70  settings.beginGroup(S_PROJECTMANAGER);
71 
72  if (!settings.contains(S_AUTOSAVE))
73  settings.setValue(S_AUTOSAVE, true);
74 
75  m_workingDirectory = settings.value(S_DEFAULTPROJECTPATH).toString();
76  m_recentProjects = settings.value(S_RECENTPROJECTS).toStringList();
77 
78  if (settings.contains(S_LASTUSEDIMPORTDIR))
79  m_importDirectory = settings.value(S_LASTUSEDIMPORTDIR, QString()).toString();
80 
81  m_importFilter1D = settings.value(S_LASTUSEDIMPORFILTER1D, m_importFilter1D).toString();
82  m_importFilter2D = settings.value(S_LASTUSEDIMPORFILTER2D, m_importFilter2D).toString();
83 
84  setAutosaveEnabled(settings.value(S_AUTOSAVE).toBool());
85 
86  settings.endGroup();
87  }
88 }
QString m_importFilter2D
Recently used import filter for 2D files.
void setAutosaveEnabled(bool value)
QString m_importDirectory
QString m_importFilter1D
Recently used import filter for 1D files.

References m_importDirectory, m_importFilter1D, m_importFilter2D, m_recentProjects, m_workingDirectory, and setAutosaveEnabled().

Referenced by MainWindow::readSettings().

Here is the call graph for this function:

◆ recentlyUsedImportFilter1D()

QString ProjectManager::recentlyUsedImportFilter1D ( ) const

Definition at line 154 of file projectmanager.cpp.

155 {
156  return m_importFilter1D;
157 }

References m_importFilter1D.

Referenced by RealDataSelectorWidget::importData().

◆ recentlyUsedImportFilter2D()

QString ProjectManager::recentlyUsedImportFilter2D ( ) const

Definition at line 159 of file projectmanager.cpp.

160 {
161  return m_importFilter2D;
162 }

References m_importFilter2D.

Referenced by RealDataSelectorWidget::importData().

◆ recentProjects()

QStringList ProjectManager::recentProjects ( )

Returns list of recent projects, validates if projects still exists on disk.

Definition at line 114 of file projectmanager.cpp.

115 {
116  QStringList updatedList;
117  for (QString fileName : m_recentProjects) {
118  QFile fin(fileName);
119  if (fin.exists())
120  updatedList.append(fileName);
121  }
122  m_recentProjects = updatedList;
123  return m_recentProjects;
124 }

References m_recentProjects.

Referenced by ActionManager::onAboutToShowFileMenu().

◆ restoreProjectDialog()

bool ProjectManager::restoreProjectDialog ( const QString &  projectFileName)
private

Rises dialog if the project should be restored from autosave. Returns true, if yes.

Definition at line 472 of file projectmanager.cpp.

473 {
474  QString title("Recover project");
475 
476  QString message =
477  QString("Project '%1' contains autosaved data.\n\n"
478  "Project saved at %2\nAutosave from %3")
479  .arg(ProjectUtils::projectName(projectFileName))
480  .arg(ProjectUtils::lastModified(projectFileName))
482 
483  return GUIHelpers::question(m_mainWindow, title, message,
484  "\nDo you want to restore from autosave?\n", "Yes, please restore.",
485  "No, keep loading original");
486 }
bool question(QWidget *parent, const QString &title, const QString &text, const QString &detailedText, const QString &yesText, const QString &noText)
Definition: GUIHelpers.cpp:94
QString lastModified(const QString &fileName)
Returns a string representing modification time of given file.
QString projectName(const QString &projectFileName)
Returns project name deduced from project file name.

References ProjectUtils::autosaveName(), ProjectUtils::lastModified(), m_mainWindow, ProjectUtils::projectName(), and GUIHelpers::question().

Referenced by loadProject().

Here is the call graph for this function:

◆ riseProjectLoadFailedDialog()

void ProjectManager::riseProjectLoadFailedDialog ( )
private

Definition at line 449 of file projectmanager.cpp.

450 {
451  QString message =
452  QString("Failed to load the project '%1' \n\n").arg(m_project_document->projectFileName());
453 
455  message.append(details + "\n");
456 
457  QMessageBox::warning(m_mainWindow, "Error while opening project file", message);
458 }
QStringList errorDescriptionList(const QObject *sender=0) const
Returns multi-line string representing error messages of given sender.
void warning(QWidget *parent, const QString &title, const QString &text, const QString &detailedText)
Definition: GUIHelpers.cpp:74

References MessageService::errorDescriptionList(), m_mainWindow, m_messageService, m_project_document, ProjectDocument::projectFileName(), and GUIHelpers::warning().

Referenced by openProject().

Here is the call graph for this function:

◆ riseProjectLoadWarningDialog()

void ProjectManager::riseProjectLoadWarningDialog ( )
private

Definition at line 460 of file projectmanager.cpp.

461 {
465 
466  warningDialog->show();
467  warningDialog->raise();
468 }
#define ASSERT(condition)
Definition: Assert.h:31
QString documentVersion() const
The dialog to inform user about encountered problems during the loading of old project.

References ASSERT, ProjectDocument::documentVersion(), m_mainWindow, m_messageService, and m_project_document.

Referenced by openProject().

Here is the call graph for this function:

◆ saveProject

bool ProjectManager::saveProject ( QString  projectFileName = "")
slot

Processes save project request.

Definition at line 274 of file projectmanager.cpp.

275 {
276  if (projectFileName.isEmpty()) {
278  projectFileName = m_project_document->projectFileName();
279  else
280  projectFileName = acquireProjectFileName(true);
281  }
282 
283  if (projectFileName.isEmpty())
284  return false;
285 
286  try {
287  m_saveService->save(projectFileName);
288  } catch (const std::exception& ex) {
289  QString message = QString("Failed to save project under '%1'. \n\n").arg(projectFileName);
290  message.append("Exception was thrown.\n\n");
291  message.append(ex.what());
292 
293  QMessageBox::warning(m_mainWindow, "Error while saving project", message);
294  return false;
295  }
296 
298  modified();
299 
300  return true;
301 }
void save(const QString &project_file_name)
Definition: SaveService.cpp:56

References acquireProjectFileName(), addToRecentProjects(), ProjectDocument::hasValidNameAndPath(), m_mainWindow, m_project_document, m_saveService, modified(), ProjectDocument::projectFileName(), SaveService::save(), and GUIHelpers::warning().

Referenced by closeCurrentProject(), ActionManager::createActions(), newProject(), and saveProjectAs().

Here is the call graph for this function:

◆ saveProjectAs

bool ProjectManager::saveProjectAs ( )
slot

Processes 'save project as' request.

Definition at line 305 of file projectmanager.cpp.

306 {
307  QString projectFileName = acquireProjectFileName(true);
308 
309  if (projectFileName.isEmpty())
310  return false;
311 
312  return saveProject(projectFileName);
313 }

References acquireProjectFileName(), and saveProject().

Referenced by ActionManager::createActions().

Here is the call graph for this function:

◆ setAutosaveEnabled

void ProjectManager::setAutosaveEnabled ( bool  value)
slot

Definition at line 193 of file projectmanager.cpp.

194 {
196  QSettings settings;
197  settings.setValue(S_PROJECTMANAGER + "/" + S_AUTOSAVE, value);
198 }
void setAutosaveEnabled(bool value)
Definition: SaveService.cpp:64

References m_saveService, and SaveService::setAutosaveEnabled().

Referenced by ActionManager::onAboutToShowSettingsMenu(), and readSettings().

Here is the call graph for this function:

◆ setImportDir()

void ProjectManager::setImportDir ( const QString &  dirname)

Sets user import directory in system settings.

Definition at line 166 of file projectmanager.cpp.

167 {
168  m_importDirectory = dirname;
169 }

References m_importDirectory.

Referenced by RealDataSelectorWidget::importData(), and PyImportAssistant::saveImportDir().

◆ setImportDirFromFilePath()

void ProjectManager::setImportDirFromFilePath ( const QString &  filePath)

Sets user import directory in system settings.

Definition at line 173 of file projectmanager.cpp.

174 {
175  m_importDirectory = QFileInfo(filePath).absolutePath();
176 }

References m_importDirectory.

◆ setRecentlyUsedImportFilter1D()

void ProjectManager::setRecentlyUsedImportFilter1D ( const QString &  filter)

Definition at line 178 of file projectmanager.cpp.

179 {
180  m_importFilter1D = filter;
181 }

References m_importFilter1D.

Referenced by RealDataSelectorWidget::importData().

◆ setRecentlyUsedImportFilter2D()

void ProjectManager::setRecentlyUsedImportFilter2D ( const QString &  filter)

Definition at line 183 of file projectmanager.cpp.

184 {
185  m_importFilter2D = filter;
186 }

References m_importFilter2D.

Referenced by RealDataSelectorWidget::importData().

◆ untitledProjectName()

QString ProjectManager::untitledProjectName ( )
private

Will return 'Untitled' if the directory with such name doesn't exist in project path.

Otherwise will return Untitled1, Untitled2 etc.

Definition at line 430 of file projectmanager.cpp.

431 {
432  QString result = "Untitled";
433  QDir projectDir = workingDirectory() + "/" + result;
434  if (projectDir.exists()) {
435  for (size_t i = 1; i < 99; ++i) {
436  result = QString("Untitled") + QString::number(i);
437 #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
438  projectDir.setPath(workingDirectory() + "/" + result);
439 #else
440  projectDir = workingDirectory() + "/" + result;
441 #endif
442  if (!projectDir.exists())
443  break;
444  }
445  }
446  return result;
447 }
QString projectDir() const
Returns name of the current project directory.

References projectDir(), and workingDirectory().

Referenced by acquireProjectFileName().

Here is the call graph for this function:

◆ userExportDir()

QString ProjectManager::userExportDir ( ) const

Returns directory name suitable for saving plots.

Definition at line 138 of file projectmanager.cpp.

139 {
140  QString result = projectDir();
141  if (result.isEmpty())
142  result = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
143 
144  return result;
145 }

References projectDir().

Referenced by IntensityDataCanvas::onSavePlotAction(), SpecularDataCanvas::onSavePlotAction(), MaskEditorCanvas::onSavePlotRequest(), RealSpaceCanvas::savePicture(), ProjectUtils::userExportDir(), and userImportDir().

Here is the call graph for this function:

◆ userImportDir()

QString ProjectManager::userImportDir ( ) const

Returns directory name which was used by the user to import files.

Definition at line 149 of file projectmanager.cpp.

150 {
151  return m_importDirectory.isEmpty() ? userExportDir() : m_importDirectory;
152 }
QString userExportDir() const
Returns directory name suitable for saving plots.

References m_importDirectory, and userExportDir().

Referenced by PyImportAssistant::fileNameToOpen(), and RealDataSelectorWidget::importData().

Here is the call graph for this function:

◆ workingDirectory()

QString ProjectManager::workingDirectory ( )
private

Returns default project path.

Definition at line 422 of file projectmanager.cpp.

423 {
424  return m_workingDirectory;
425 }

References m_workingDirectory.

Referenced by acquireProjectFileName(), openProject(), and untitledProjectName().

◆ writeSettings()

void ProjectManager::writeSettings ( )

Saves settings of ProjectManager in global settings.

Definition at line 92 of file projectmanager.cpp.

93 {
94  QSettings settings;
95  settings.beginGroup(S_PROJECTMANAGER);
96  settings.setValue(S_DEFAULTPROJECTPATH, m_workingDirectory);
97  settings.setValue(S_RECENTPROJECTS, m_recentProjects);
98 
99  if (!m_importDirectory.isEmpty())
100  settings.setValue(S_LASTUSEDIMPORTDIR, m_importDirectory);
101  settings.setValue(S_LASTUSEDIMPORFILTER1D, m_importFilter1D);
102  settings.setValue(S_LASTUSEDIMPORFILTER2D, m_importFilter2D);
103 
104  settings.endGroup();
105 }

References m_importDirectory, m_importFilter1D, m_importFilter2D, m_recentProjects, and m_workingDirectory.

Referenced by MainWindow::writeSettings().

Member Data Documentation

◆ m_importDirectory

QString ProjectManager::m_importDirectory
private

◆ m_importFilter1D

QString ProjectManager::m_importFilter1D
private

Recently used import filter for 1D files.

Definition at line 89 of file projectmanager.h.

Referenced by readSettings(), recentlyUsedImportFilter1D(), setRecentlyUsedImportFilter1D(), and writeSettings().

◆ m_importFilter2D

QString ProjectManager::m_importFilter2D
private

Recently used import filter for 2D files.

Definition at line 92 of file projectmanager.h.

Referenced by readSettings(), recentlyUsedImportFilter2D(), setRecentlyUsedImportFilter2D(), and writeSettings().

◆ m_mainWindow

◆ m_messageService

MessageService* ProjectManager::m_messageService
private

◆ m_project_document

◆ m_recentProjects

QStringList ProjectManager::m_recentProjects
private

◆ m_saveService

SaveService* ProjectManager::m_saveService
private

◆ m_workingDirectory

QString ProjectManager::m_workingDirectory
private

Name of directory from there user prefer to import files.

Definition at line 83 of file projectmanager.h.

Referenced by acquireProjectFileName(), readSettings(), workingDirectory(), and writeSettings().


The documentation for this class was generated from the following files: