summaryrefslogtreecommitdiffstats
path: root/Profile.h
blob: b31d9fe0feca0beb2bd3810349ba241e020845a6 (plain)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*
 * Copyright 2008 Ben Boeckel <MathStuf@gmail.com>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * \file Profile.h
 */

#ifndef PROFILE_H
#define PROFILE_H

// Qt includes
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>

// Forward declarations
class KConfigGroup;

/**
 * \class Profile
 * \brief Gives an evironment for an emulator.
 */
class Profile : public QObject
{
    Q_OBJECT
    /**
     * \var workingPath
     * \brief The working path when executed.
     * 
     * \sa workingPath
     * \sa setWorkingPath
     */
    Q_PROPERTY(QString workingPath READ workingPath WRITE setWorkingPath)
    /**
     * \var options
     * \brief The options for the emulator.
     * 
     * \sa options
     * \sa addOption
     * \sa removeOption
     */
    Q_PROPERTY(QStringList options READ options)
    /**
     * \var environment
     * \brief The environment for the emulator
     * 
     * \sa environment
     * \sa environmentValue
     * \sa environmentList
     */
    Q_PROPERTY(Environment environment READ environment)
    
    public:
        /**
         * \typedef Environment
         * \brief Type of the environment.
         */
        typedef QMap<QString, QString> Environment;
        
        /**
         * \brief Default constructor.
         */
        Profile();
        
        /**
         * \brief Configuration constructor.
         */
        Profile(const KConfigGroup& config);
        
        /**
         * \brief Copy constructor.
         * 
         * \param rhs The profile to copy.
         */
        Profile(const Profile& rhs);
        
        /**
         * \brief Create a KConfigGroup for saving.
         * 
         * \param name The name of the group.
         * \param parent The parent group.
         */
        void makeGroup(const QString& name, const KConfigGroup& parent) const;
        
        /**
         * \return The working path for the profile.
         */
        QString workingPath() const;
        
        /**
         * \return A list of options for the profile.
         */
        QStringList options() const;
        
        /**
         * \return A mapping of the environment.
         */
        Environment environment() const;
        
        /**
         * \param variable The variable to get.
         * \return The value of the variable.
         */
        QString environmentValue(const QString& variable) const;
        
        /**
         * \return The environment in assignment form.
         */
        QStringList environmentList() const;
        
        /**
         * \brief Assignment method.
         * \param rhs Profile to copy.
         */
        Profile& operator=(const Profile& rhs);
    public slots:
        /**
         * \brief Sets the path to run the command from.
         * 
         * \param workingPath 
         */
        void setWorkingPath(const QString& workingPath);
        
        /**
         * \brief Add an option when executed.
         * 
         * \param option 
         */
        void addOption(const QString& option);
        
        /**
         * \brief Remove an option from the profile.
         * 
         * \param option 
         */
        void removeOption(const QString& option);
        
        /**
         * \brief Add an environment expression to the profile.
         * 
         * \param expression Expression for the environment.
         */
        void addEnvironment(const QString& value);
        
        /**
         * \brief Add an environment variable to the profile.
         * 
         * \param variable The variable to set.
         * \param value The value to set it to.
         */
        void addEnvironment(const QString& variable, const QString& value);
        
        /**
         * \brief Unset an environment variable.
         * 
         * \param variable The variable to remove.
         */
        void removeEnvironment(const QString& variable);
    private:
        QString m_workingPath;
        QStringList m_options;
        Environment m_enviroment;
};

#endif