BornAgain
1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
|
Handles activity related to opening/save projects.
Definition at line 28 of file ProjectManager.h.
Public Slots | |
void | clearRecentProjects () |
Clears list of recent projects. More... | |
bool | closeCurrentProject () |
Processes close current project request. Call save/discard/cancel dialog, if necessary. Returns false if saving was canceled. More... | |
void | newProject () |
Processes new project request (close old project, rise dialog for project name, create project). 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 | aboutToCloseDocument () |
void | documentModified () |
void | documentOpenedOrClosed (bool opened) |
void | recentListModified () |
Public Member Functions | |
ProjectManager (QObject *parent) | |
~ProjectManager () override | |
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 | 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... | |
Static Public Member Functions | |
static ProjectManager * | instance () |
Private Member Functions | |
QString | acquireProjectFileName () |
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 () |
ProjectDocument::ReadResult | loadProject (const QString &projectFileName, MessageService &messageService) |
Load project data from file name. If autosave info exists, opens dialog for project restore. More... | |
bool | restoreProjectDialog (const QString &projectFileName, QString autosaveName) |
Name of directory where project directory was created. More... | |
void | riseProjectLoadFailedDialog (const MessageService &messageService) |
void | riseProjectLoadProblemDialog (const MessageService &messageService) |
QString | untitledProjectName () |
Will return 'Untitled' if the directory with such name doesn't exist in project path. Otherwise will return Untitled1, Untitled2 etc. 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... | |
QStringList | m_recentProjects |
SaveService * | m_saveService |
QString | m_workingDirectory |
Name of directory from there user prefer to import files. More... | |
Static Private Attributes | |
static ProjectManager * | s_instance = nullptr |
ProjectManager::ProjectManager | ( | QObject * | parent | ) |
|
override |
Definition at line 61 of file ProjectManager.cpp.
References gSessionData, SessionData::projectDocument, and s_instance.
|
signal |
Referenced by MainWindow::MainWindow(), and deleteCurrentProject().
|
private |
Returns project file name from dialog. Returns empty string if dialog was canceled.
Definition at line 389 of file ProjectManager.cpp.
References NewProjectDialog::getProjectFileName(), NewProjectDialog::getWorkingDirectory(), m_workingDirectory, GUI::Global::mainWindow, untitledProjectName(), and workingDirectory().
Referenced by saveProject(), and saveProjectAs().
|
private |
Add name of the current project to the name of recent projects.
Definition at line 403 of file ProjectManager.cpp.
References gSessionData, m_recentProjects, GUI::Constants::MAX_RECENT_PROJECTS, SessionData::projectDocument, and recentListModified().
Referenced by openProject(), and saveProject().
|
slot |
Clears list of recent projects.
Definition at line 201 of file ProjectManager.cpp.
References m_recentProjects, and recentListModified().
Referenced by ActionManager::onAboutToShowFileMenu().
|
slot |
Processes close current project request. Call save/discard/cancel dialog, if necessary. Returns false if saving was canceled.
Definition at line 220 of file ProjectManager.cpp.
References deleteCurrentProject(), documentOpenedOrClosed(), gSessionData, SessionData::projectDocument, and saveProject().
Referenced by MainWindow::closeEvent(), ActionManager::createActions(), newProject(), and openProject().
|
private |
Calls dialog window to define project path and name.
Definition at line 329 of file ProjectManager.cpp.
References ProjectDocument::All, appSettings, ApplicationSettings::defaultFunctionalities(), ApplicationSettings::defaultIsSingleInstrumentMode(), ApplicationSettings::defaultIsSingleSampleMode(), documentModified(), Error, gSessionData, m_saveService, ProjectDocument::modified(), SessionData::projectDocument, SaveService::setDocument(), toFunctionalities(), and toVariant().
Referenced by newProject(), and openProject().
|
private |
Definition at line 354 of file ProjectManager.cpp.
References aboutToCloseDocument(), gSessionData, m_saveService, SessionData::projectDocument, and SaveService::stopService().
Referenced by closeCurrentProject(), and openProject().
|
signal |
Referenced by MainWindow::MainWindow(), and createNewProject().
|
signal |
Referenced by ActionManager::ActionManager(), MainWindow::MainWindow(), closeCurrentProject(), newProject(), and openProject().
|
static |
Definition at line 67 of file ProjectManager.cpp.
References Error, and s_instance.
Referenced by ActionManager::ActionManager(), SimulationView::exportPythonScript(), RealDataSelectorWidget::importData1D(), RealDataSelectorWidget::importData2D(), and WelcomeView::projectManager().
bool ProjectManager::isAutosaveEnabled | ( | ) | const |
Definition at line 187 of file ProjectManager.cpp.
References SaveService::isAutosaveEnabled(), and m_saveService.
Referenced by ActionManager::onAboutToShowSettingsMenu().
|
private |
Load project data from file name. If autosave info exists, opens dialog for project restore.
Definition at line 364 of file ProjectManager.cpp.
References GUI::Project::Utils::autosaveName(), gSessionData, GUI::Project::Utils::hasAutosavedData(), m_saveService, ProjectDocument::ok, SessionData::projectDocument, and restoreProjectDialog().
Referenced by openProject().
|
slot |
Processes new project request (close old project, rise dialog for project name, create project).
Definition at line 209 of file ProjectManager.cpp.
References closeCurrentProject(), createNewProject(), and documentOpenedOrClosed().
Referenced by MainWindow::MainWindow(), WelcomeView::WelcomeView(), and ActionManager::createActions().
|
slot |
Opens existing project. If fileName is empty, will popup file selection dialog.
Definition at line 295 of file ProjectManager.cpp.
References addToRecentProjects(), appSettings, closeCurrentProject(), createNewProject(), deleteCurrentProject(), documentOpenedOrClosed(), ProjectDocument::error, gSessionData, loadProject(), GUI::Global::mainWindow, ProjectDocument::ok, SessionData::projectDocument, riseProjectLoadFailedDialog(), riseProjectLoadProblemDialog(), ApplicationSettings::useNativeFileDialog(), ProjectDocument::warning, and workingDirectory().
Referenced by ActionManager::createActions(), MainWindow::openRecentProject(), and WelcomeView::updateRecentProjectPanel().
QString ProjectManager::projectDir | ( | ) | const |
Returns name of the current project directory.
Definition at line 134 of file ProjectManager.cpp.
References gSessionData, and SessionData::projectDocument.
Referenced by untitledProjectName().
void ProjectManager::readSettings | ( | ) |
Reads settings of ProjectManager from global settings.
Definition at line 78 of file ProjectManager.cpp.
References m_importDirectory, m_importFilter1D, m_importFilter2D, m_recentProjects, m_workingDirectory, and setAutosaveEnabled().
Referenced by MainWindow::readSettings().
|
signal |
Referenced by WelcomeView::WelcomeView(), addToRecentProjects(), and clearRecentProjects().
QString ProjectManager::recentlyUsedImportFilter1D | ( | ) | const |
Definition at line 153 of file ProjectManager.cpp.
References m_importFilter1D.
Referenced by RealDataSelectorWidget::importData1D().
QString ProjectManager::recentlyUsedImportFilter2D | ( | ) | const |
Definition at line 158 of file ProjectManager.cpp.
References m_importFilter2D.
Referenced by RealDataSelectorWidget::importData2D().
QStringList ProjectManager::recentProjects | ( | ) |
Returns list of recent projects, validates if projects still exists on disk.
Definition at line 122 of file ProjectManager.cpp.
References m_recentProjects.
Referenced by ActionManager::onAboutToShowFileMenu().
|
private |
Name of directory where project directory was created.
Rises dialog if the project should be restored from autosave. Returns true, if yes.
Definition at line 467 of file ProjectManager.cpp.
References GUI::Project::Utils::autosaveName(), GUI::Global::mainWindow, GUI::Project::Utils::projectName(), and GUI::View::Helpers::question().
Referenced by loadProject().
|
private |
Definition at line 443 of file ProjectManager.cpp.
References MessageService::errors(), gSessionData, GUI::Global::mainWindow, SessionData::projectDocument, and GUI::View::Helpers::warning().
Referenced by openProject().
|
private |
Definition at line 454 of file ProjectManager.cpp.
References gSessionData, GUI::Global::mainWindow, SessionData::projectDocument, and MessageService::warnings().
Referenced by openProject().
|
slot |
Processes save project request.
Definition at line 253 of file ProjectManager.cpp.
References acquireProjectFileName(), addToRecentProjects(), gSessionData, m_saveService, GUI::Global::mainWindow, SessionData::projectDocument, SaveService::save(), and GUI::View::Helpers::warning().
Referenced by closeCurrentProject(), ActionManager::createActions(), and saveProjectAs().
|
slot |
Processes 'save project as' request.
Definition at line 283 of file ProjectManager.cpp.
References acquireProjectFileName(), and saveProject().
Referenced by ActionManager::createActions().
|
slot |
Definition at line 192 of file ProjectManager.cpp.
References m_saveService, and SaveService::setAutosaveEnabled().
Referenced by ActionManager::onAboutToShowSettingsMenu(), and readSettings().
void ProjectManager::setImportDir | ( | const QString & | dirname | ) |
Sets user import directory in system settings.
Definition at line 165 of file ProjectManager.cpp.
References m_importDirectory.
void ProjectManager::setImportDirFromFilePath | ( | const QString & | filePath | ) |
Sets user import directory in system settings.
Definition at line 172 of file ProjectManager.cpp.
References m_importDirectory.
Referenced by RealDataSelectorWidget::importData1D(), and RealDataSelectorWidget::importData2D().
void ProjectManager::setRecentlyUsedImportFilter1D | ( | const QString & | filter | ) |
Definition at line 177 of file ProjectManager.cpp.
References m_importFilter1D.
Referenced by RealDataSelectorWidget::importData1D().
void ProjectManager::setRecentlyUsedImportFilter2D | ( | const QString & | filter | ) |
Definition at line 182 of file ProjectManager.cpp.
References m_importFilter2D.
Referenced by RealDataSelectorWidget::importData2D().
|
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 424 of file ProjectManager.cpp.
References projectDir(), and workingDirectory().
Referenced by acquireProjectFileName().
QString ProjectManager::userImportDir | ( | ) | const |
Returns directory name which was used by the user to import files.
Definition at line 143 of file ProjectManager.cpp.
References gSessionData, m_importDirectory, and SessionData::projectDocument.
Referenced by RealDataSelectorWidget::importData1D(), and RealDataSelectorWidget::importData2D().
|
private |
Returns default project path.
Definition at line 416 of file ProjectManager.cpp.
References m_workingDirectory.
Referenced by acquireProjectFileName(), openProject(), and untitledProjectName().
void ProjectManager::writeSettings | ( | ) |
Saves settings of ProjectManager in global settings.
Definition at line 105 of file ProjectManager.cpp.
References m_importDirectory, m_importFilter1D, m_importFilter2D, m_recentProjects, and m_workingDirectory.
Referenced by MainWindow::writeSettings().
|
private |
Definition at line 85 of file ProjectManager.h.
Referenced by readSettings(), setImportDir(), setImportDirFromFilePath(), userImportDir(), and writeSettings().
|
private |
Recently used import filter for 1D files.
Definition at line 88 of file ProjectManager.h.
Referenced by readSettings(), recentlyUsedImportFilter1D(), setRecentlyUsedImportFilter1D(), and writeSettings().
|
private |
Recently used import filter for 2D files.
Definition at line 91 of file ProjectManager.h.
Referenced by readSettings(), recentlyUsedImportFilter2D(), setRecentlyUsedImportFilter2D(), and writeSettings().
|
private |
Definition at line 93 of file ProjectManager.h.
Referenced by addToRecentProjects(), clearRecentProjects(), readSettings(), recentProjects(), and writeSettings().
|
private |
Definition at line 94 of file ProjectManager.h.
Referenced by createNewProject(), deleteCurrentProject(), isAutosaveEnabled(), loadProject(), saveProject(), and setAutosaveEnabled().
|
private |
Name of directory from there user prefer to import files.
Definition at line 82 of file ProjectManager.h.
Referenced by acquireProjectFileName(), readSettings(), workingDirectory(), and writeSettings().
|
staticprivate |
Definition at line 96 of file ProjectManager.h.
Referenced by ProjectManager(), ~ProjectManager(), and instance().