-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmsvcmodelitems.h
More file actions
181 lines (142 loc) · 4.97 KB
/
msvcmodelitems.h
File metadata and controls
181 lines (142 loc) · 4.97 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
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
180
181
/* KDevelop MSVC Support
*
* Copyright 2015 Ennio Barbaro <enniobarbaro@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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef MSVCMODELITEMS_H
#define MSVCMODELITEMS_H
#include <QUuid>
#include <project/projectmodel.h>
#include <kdevplatform/util/path.h>
#include "msvcprojectconfig.h"
class MsvcFilterItem : public KDevelop::ProjectBaseItem
{
public:
using KDevelop::ProjectBaseItem::ProjectBaseItem;
int type() const override { return Folder; }
bool lessThan( const KDevelop::ProjectBaseItem* item ) const override;
QString iconName() const override;
RenameStatus rename(const QString &) override
{
return ProjectManagerRenameFailed;
}
};
class MsvcExecutableTargetItem : public KDevelop::ProjectExecutableTargetItem
{
public:
using KDevelop::ProjectExecutableTargetItem::ProjectExecutableTargetItem;
QUrl builtUrl() const override;
QUrl installedUrl() const override { return QUrl(); }
private:
};
class MsvcProjectItem : public KDevelop::ProjectBuildFolderItem
{
public:
MsvcProjectItem( KDevelop::IProject* ,
const KDevelop::Path& path,
ProjectBaseItem* parent = nullptr );
bool lessThan( const KDevelop::ProjectBaseItem* item ) const override;
RenameStatus rename(const QString & newName) override
{
return KDevelop::ProjectBaseItem::rename(newName);
}
void addConfiguration( MsvcProjectConfig const & );
bool setCurrentConfiguration( QString const & fullname);
MsvcProjectConfig getCurrentConfig() const;
void setUuid(QUuid uuid)
{
uuid_ = uuid;
}
void setRootNamespace(QString const & ns )
{
root_namespace_ = ns;
}
QUuid uuid() const { return uuid_; }
QString rootNamespace() const { return root_namespace_; }
private:
QString current_config_;
QString root_namespace_;
QHash< QString, MsvcProjectConfig > configurations_;
QUuid uuid_;
};
class MsvcSolutionItem : public KDevelop::ProjectBuildFolderItem
{
public:
MsvcSolutionItem( KDevelop::IProject* ,
const KDevelop::Path& path,
ProjectBaseItem* parent = nullptr );
bool lessThan( const KDevelop::ProjectBaseItem* item ) const override;
RenameStatus rename(const QString & newName) override
{
return KDevelop::ProjectBaseItem::rename(newName);
}
void setCurrentConfig(QString const & name);
void addConfiguration(QString const & nameAndArch)
{
config_map_.insert( nameAndArch, {} );
}
void addProjectConfig(QString const & mainCfg,
QUuid const & project,
QString const & projectCfg)
{
auto it = config_map_.find( mainCfg );
if ( it != config_map_.end() )
{
(*it)[project] = projectCfg;
}
}
QList<QString> getConfigurations() const { return config_map_.keys(); }
private:
MsvcProjectItem* findProjectByUuid(const QUuid &) const;
QHash< QString, QHash<QUuid, QString> > config_map_;
};
class MsvcVariableReplacer
{
public:
QString replace( QString s, KDevelop::ProjectBaseItem const * item );
QStringList replace( QStringList s, KDevelop::ProjectBaseItem const * item )
{
for (QString & x : s)
x = replace(x, item);
return s;
}
QString getReplacement( QString const & key, KDevelop::ProjectBaseItem const * item );
private:
QString visit( QString const & key, KDevelop::ProjectBaseItem const * item );
QString visit( QString const & key, MsvcProjectItem const * item );
QString visit( QString const & key, MsvcSolutionItem const * item );
struct recursionChecker
{
explicit recursionChecker(bool & guard) :
guard_(guard),
stop_(guard)
{
guard_ = true;
}
~recursionChecker() { guard_ = false; }
bool stop() const { return stop_; }
private:
bool & guard_;
bool stop_;
};
bool replace_target_dir_guard_ = false,
replace_target_path_guard_ = false,
replace_target_name_guard_ = false,
replace_target_file_name_guard_ = false,
replace_target_ext_guard_ = false;
};
#endif //MSVCMODELITEMS_H