| openPilotLog

astandardpaths.h
1 /*
2 *openPilotLog - A FOSS Pilot Logbook Application
3 *Copyright (C) 2020-2021 Felix Turowsky
4 *
5 *This program is free software: you can redistribute it and/or modify
6 *it under the terms of the GNU General Public License as published by
7 *the Free Software Foundation, either version 3 of the License, or
8 *(at your option) any later version.
9 *
10 *This program is distributed in the hope that it will be useful,
11 *but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *GNU General Public License for more details.
14 *
15 *You should have received a copy of the GNU General Public License
16 *along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18 #ifndef ASTANDARDPATHS_H
19 #define ASTANDARDPATHS_H
20
21 #include <QStandardPaths>
22 #include <QString>
23 #include <QHash>
24 #include <QDir>
25
30 class AStandardPaths{
31 public:
32 enum Directories {
33 Database,
34 Templates,
35 Backup,
36 Log,
37 JSON
38 };
39 private:
40 static QHash<Directories, QDir> directories;
41
46 static bool scan_directories();
47
48 public:
52 static bool setup();
53
58 static const QDir &directory(Directories location);
59
63 static const QString asChildOfDir(Directories location, const QString& filename);
68 static const QHash<Directories, QDir> &allDirectories();
69 };
70
71
72 #endif // ASTANDARDPATHS_H
AStandardPaths
The AStandardAppPaths class encapsulates a static QHash holding the standard paths of the application...
Definition: astandardpaths.h:30
AStandardPaths::directory
static const QDir & directory(Directories location)
Returns the QDir for the standard directory referenced by the Directories enum 'loc'.
Definition: astandardpaths.cpp:43
AStandardPaths::setup
static bool setup()
Creates and verifies a static map of the standard paths used in the app.
Definition: astandardpaths.cpp:23
AStandardPaths::asChildOfDir
static const QString asChildOfDir(Directories location, const QString &filename)
Returns a string of the absolute path to directory location concatenated with filename.
Definition: astandardpaths.cpp:48
AStandardPaths::allDirectories
static const QHash< Directories, QDir > & allDirectories()
returns the static map of all standard directories
Definition: astandardpaths.cpp:53