This repository was archived by the owner on Sep 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVariablesManager.h
More file actions
98 lines (70 loc) · 2.33 KB
/
Copy pathVariablesManager.h
File metadata and controls
98 lines (70 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#ifndef VARIABLESMANAGER_H
#define VARIABLESMANAGER_H
/*
* This is a part of EnvironmentExplorer program
* which is licensed under LGPLv2.
*
* Github: https://github.com/PeterBocan/EnvironmentExplorer
* Author: https://twitter.com/PeterBocan
*/
//
// VariablesManager class handles a variable management.
//
#include <QSettings>
#include <QVariant>
#include <QObject>
#include <QList>
#include <QHash>
class QSettings;
namespace EnvironmentExplorer
{
struct Variable
{
// Represents the name of env. var.
QString name;
// Stores the default name
QString defaultName;
// Represents the current value.
QVariant value;
// Represents the default value
// (only if it from the environment)
QVariant defaultValue;
enum Type { Global, User };
Type type;
};
class VariablesManager : public QObject
{
Q_OBJECT
public:
VariablesManager(QObject* parent = 0);
void addUserVariable(const QString &name,
const QVariant &val);
void addGlobalVariable(const QString &name,
const QVariant &val);
void loadVariables();
void saveVariables();
bool contains(const QString &name) const;
bool replaceVariable(const QString &name,
const Variable &var);
void removeVariable(const QString &name);
void removeVariable(const QString &name,
Variable::Type type);
QList<Variable> userEnvironment() const;
QList<Variable> systemEnvironment() const;
Variable variable(const QString& name) const;
void dumpVariables(Variable::Type t);
void addVariable(const Variable &var);
protected:
void addVariable(const QString &name,
const QVariant &val,
Variable::Type type = Variable::User);
private:
QHash<QString, Variable> parseEnvironment(const QSettings &set,
Variable::Type t);
QSettings* machineSettings,
* userSettings;
QList<QString> variables;
QHash<QString, Variable> globals, locals;
};
}
#endif // VARIABLESMANAGER_H