Changeset View
Changeset View
Standalone View
Standalone View
shell/settings/environmentprofilemodel.h
- This file was added.
1 | /* This file is part of KDevelop | ||||
---|---|---|---|---|---|
2 | Copyright 2007 Andreas Pakulat <apaku@gmx.de> | ||||
3 | Copyright 2017 Friedrich W. H. Kossebau <kossebau@kde.org> | ||||
4 | | ||||
5 | This library is free software; you can redistribute it and/or | ||||
6 | modify it under the terms of the GNU Library General Public | ||||
7 | License as published by the Free Software Foundation; either | ||||
8 | version 2 of the License, or (at your option) any later version. | ||||
9 | | ||||
10 | This library 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 GNU | ||||
13 | Library General Public License for more details. | ||||
14 | | ||||
15 | You should have received a copy of the GNU Library General Public License | ||||
16 | along with this library; see the file COPYING.LIB. If not, write to | ||||
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
18 | Boston, MA 02110-1301, USA. | ||||
19 | */ | ||||
20 | | ||||
21 | #ifndef KDEVPLATFORM_ENVIRONMENTPROFILEMODEL_H | ||||
22 | #define KDEVPLATFORM_ENVIRONMENTPROFILEMODEL_H | ||||
23 | | ||||
24 | #include <QAbstractTableModel> | ||||
25 | #include <QStringList> | ||||
26 | #include "util/environmentgrouplist.h" | ||||
27 | | ||||
28 | namespace KDevelop | ||||
29 | { | ||||
30 | class EnvironmentProfileListModel; | ||||
31 | | ||||
32 | class EnvironmentProfileModel : public QAbstractTableModel | ||||
33 | { | ||||
34 | Q_OBJECT | ||||
35 | | ||||
36 | public: | ||||
37 | enum Role { | ||||
38 | VariableRole = Qt::UserRole + 1, | ||||
39 | ValueRole | ||||
40 | }; | ||||
41 | | ||||
42 | enum Column { | ||||
43 | VariableColumn = 0, | ||||
44 | ValueColumn = 1 | ||||
45 | }; | ||||
46 | | ||||
47 | EnvironmentProfileModel(EnvironmentProfileListModel* profileListModel, QObject* parent = nullptr); | ||||
48 | | ||||
49 | int rowCount(const QModelIndex& parent = {}) const override; | ||||
50 | int columnCount(const QModelIndex& parent = {}) const override; | ||||
51 | Qt::ItemFlags flags(const QModelIndex& index) const override; | ||||
52 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; | ||||
53 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; | ||||
54 | bool setData(const QModelIndex& index, const QVariant&, int role = Qt::EditRole) override; | ||||
55 | | ||||
56 | void setCurrentProfile(const QString& profileName); | ||||
57 | | ||||
58 | void addVariable(const QString& variableName, const QString& value); | ||||
59 | /** | ||||
60 | * Load a set of environment variables from a plaintext string. | ||||
61 | * | ||||
62 | * @p plainText In the form "FOO=1\nBAR=2" | ||||
63 | */ | ||||
64 | void setVariablesFromString(const QString& plainText); | ||||
65 | void removeVariable(const QString& variableName); | ||||
66 | void removeVariables(const QStringList& variableNames); | ||||
67 | | ||||
68 | private: | ||||
69 | void onProfileAboutToBeRemoved(const QString& profileName); | ||||
70 | | ||||
71 | private: | ||||
72 | QStringList m_varsByIndex; | ||||
73 | QString m_currentProfileName; | ||||
74 | EnvironmentProfileListModel* m_profileListModel; | ||||
75 | }; | ||||
76 | | ||||
77 | } | ||||
78 | | ||||
79 | #endif |