BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ProjectUtils.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/mainwindow/ProjectUtils.h
6 //! @brief Defines 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 
15 #ifndef BORNAGAIN_GUI_COREGUI_MAINWINDOW_PROJECTUTILS_H
16 #define BORNAGAIN_GUI_COREGUI_MAINWINDOW_PROJECTUTILS_H
17 
18 #include <QString>
19 
20 //! Defines convenience function for project manager and document.
21 
22 namespace ProjectUtils {
23 
24 //! Returns project name deduced from project file name.
25 QString projectName(const QString& projectFileName);
26 
27 //! Returns project directory deduced from project file name.
28 QString projectDir(const QString& projectFileName);
29 
30 //! Returns fixed name for autosave sub-directory.
31 QString autosaveSubdir();
32 
33 //! Returns name of autosave directory for project with given project file name.
34 QString autosaveDir(const QString& projectFileName);
35 
36 //! Returns name of project for autoSave from given project file name.
37 QString autosaveName(const QString& projectFileName);
38 
39 //! Returns true if file exists.
40 bool exists(const QString& fileName);
41 
42 //! Returns true if project with given projectFileName contains autosaved data.
43 bool hasAutosavedData(const QString& projectFileName);
44 
45 //! Returns a string representing modification time of given file
46 QString lastModified(const QString& fileName);
47 
48 //! Returns list of files on disk representing nonXML data.
49 QStringList nonXMLDataInDir(const QString& dirname);
50 
51 //! Removes recursively directory with given name. Directory name is relative
52 //! to the parent (working directory of the executable).
53 bool removeRecursively(const QString& dirname);
54 
55 //! Remove file from given directory.
56 bool removeFile(const QString& dirname, const QString& filename);
57 bool removeFiles(const QString& dirname, const QStringList& filenames);
58 
59 //! Returns list of string from lhs, which are not in rhs.
60 QStringList substract(const QStringList& lhs, const QStringList& rhs);
61 
62 //! Returns multi-lione string representing content of text file.
63 QString readTextFile(const QString& fileName);
64 
65 //! Returns directory which user is normally using to export files.
66 QString userExportDir();
67 
68 } // namespace ProjectUtils
69 
70 #endif // BORNAGAIN_GUI_COREGUI_MAINWINDOW_PROJECTUTILS_H
std::string filename(const std::string &path)
Returns path without directory part ("Foo/Bar/Doz.int.gz" -> "Doz.int.gz")
Defines convenience function for project manager and document.
Definition: ProjectUtils.h:22
QStringList substract(const QStringList &lhs, const QStringList &rhs)
Returns list of string from lhs, which are not in rhs.
QStringList nonXMLDataInDir(const QString &dirname)
Returns list of files on disk representing nonXML data.
bool exists(const QString &fileName)
Returns true if file exists.
bool removeRecursively(const QString &dirname)
Removes recursively directory with given name.
bool removeFiles(const QString &dirname, const QStringList &filenames)
QString lastModified(const QString &fileName)
Returns a string representing modification time of given file.
QString autosaveName(const QString &projectFileName)
Returns name of project for autoSave from given project file name.
bool removeFile(const QString &dirname, const QString &filename)
Remove file from given directory.
QString projectName(const QString &projectFileName)
Returns project name deduced from project file name.
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 autosaveDir(const QString &projectFileName)
Returns name of autosave directory for project with given project file name.
QString userExportDir()
Returns directory which user is normally using to export files.
QString readTextFile(const QString &fileName)
Returns multi-lione string representing content of text file.
QString autosaveSubdir()
Returns fixed name for autosave sub-directory.