MCPcopy Create free account
hub / github.com/KDE/kdevelop / createProject

Method createProject

plugins/appwizard/appwizardplugin.cpp:223–427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221} // end anonymous namespace
222
223QString AppWizardPlugin::createProject(const ApplicationInfo& info)
224{
225 QFileInfo templateInfo(info.appTemplate);
226 if (!templateInfo.exists()) {
227 qCWarning(PLUGIN_APPWIZARD) << "Project app template does not exist:" << info.appTemplate;
228 return QString();
229 }
230
231 QString templateName = templateInfo.baseName();
232 qCDebug(PLUGIN_APPWIZARD) << "Searching archive for template name:" << templateName;
233
234 QString templateArchive;
235 const QStringList filters = {templateName + QStringLiteral(".*")};
236 const QStringList matchesPaths = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("kdevappwizard/templates/"), QStandardPaths::LocateDirectory);
237 for (const QString& matchesPath : matchesPaths) {
238 const QStringList files = QDir(matchesPath).entryList(filters);
239 if(!files.isEmpty()) {
240 templateArchive = matchesPath + files.first();
241 }
242 }
243
244 if(templateArchive.isEmpty()) {
245 qCWarning(PLUGIN_APPWIZARD) << "Template name does not exist in the template list";
246 return QString();
247 }
248
249 qCDebug(PLUGIN_APPWIZARD) << "Using template archive:" << templateArchive;
250
251 QUrl dest = info.location;
252
253 //prepare variable substitution hash
254 m_variables.clear();
255 m_variables[QStringLiteral("APPNAME")] = info.name;
256 m_variables[QStringLiteral("APPNAMEUC")] = generateIdentifier(info.name.toUpper());
257 m_variables[QStringLiteral("APPNAMELC")] = info.name.toLower();
258 m_variables[QStringLiteral("APPNAMEID")] = generateIdentifier(info.name);
259 m_variables[QStringLiteral("PROJECTDIR")] = dest.toLocalFile();
260 // backwards compatibility
261 m_variables[QStringLiteral("dest")] = m_variables[QStringLiteral("PROJECTDIR")];
262 m_variables[QStringLiteral("PROJECTDIRNAME")] = dest.fileName();
263 m_variables[QStringLiteral("VERSIONCONTROLPLUGIN")] = info.vcsPluginName;
264
265 KArchive* arch = nullptr;
266 if( templateArchive.endsWith(QLatin1String(".zip")) )
267 {
268 arch = new KZip(templateArchive);
269 }
270 else
271 {
272 arch = new KTar(templateArchive, QStringLiteral("application/x-bzip"));
273 }
274 if (arch->open(QIODevice::ReadOnly))
275 {
276 QTemporaryDir tmpdir;
277 QString unpackDir = tmpdir.path(); //the default value for all Centralized VCS
278 IPlugin* plugin = core()->pluginController()->loadPlugin( info.vcsPluginName );
279 if( info.vcsPluginName.isEmpty() || ( plugin && plugin->extension<KDevelop::IDistributedVersionControl>() ) )
280 {

Callers

nothing calls this directly

Calls 15

generateIdentifierFunction · 0.85
rootFunction · 0.85
vcsErrorFunction · 0.85
toDVCSFunction · 0.85
toCVCSFunction · 0.85
initializeDVCSFunction · 0.85
initializeCVCSFunction · 0.85
cleanPathFunction · 0.85
QStringListClass · 0.85
existsMethod · 0.80
baseNameMethod · 0.80
toLocalFileMethod · 0.80

Tested by

no test coverage detected