BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ProjectUtils.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Support/IO/ProjectUtils.cpp
6 //! @brief Implements ProjectUtils namespace
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 #include <QFileInfo>
17 
18 QString GUI::Project::Utils::projectName(const QString& projectFileName)
19 {
20  return QFileInfo(projectFileName).baseName();
21 }
22 
23 QString GUI::Project::Utils::projectDir(const QString& projectFileName)
24 {
25  return QFileInfo(projectFileName).path();
26 }
27 
29 {
30  return "autosave";
31 }
32 
33 QString GUI::Project::Utils::autosaveDir(const QString& projectFileName)
34 {
35  return projectDir(projectFileName) + "/" + autosaveSubdir();
36 }
37 
38 QString GUI::Project::Utils::autosaveName(const QString& projectFileName)
39 {
40  return autosaveDir(projectFileName) + "/" + projectName(projectFileName) + projectFileExtension;
41 }
42 
43 bool GUI::Project::Utils::hasAutosavedData(const QString& projectFileName)
44 {
45  return QFile::exists(projectFileName) && QFile::exists(autosaveName(projectFileName));
46 }
Defines namespace GUI::Project::Utils.
constexpr const char * projectFileExtension
Definition: ProjectUtils.h:24
QString autosaveSubdir()
Returns fixed name for autosave sub-directory.
QString autosaveDir(const QString &projectFileName)
Returns name of autosave directory for project with given project file name. E.g. from '/projects/Unt...
bool hasAutosavedData(const QString &projectFileName)
Returns true if project with given projectFileName contains autosaved data.
QString projectDir(const QString &projectFileName)
Returns project directory deduced from project file name.
QString projectName(const QString &projectFileName)
Returns project name deduced from project file name.
QString autosaveName(const QString &projectFileName)
Returns name of project for autoSave from given project file name. E.g. from '/projects/Untitled2/Unt...