bool CascadesImportWizard::convertFilePath(Core::GeneratedFile &file, ConvertedProjectContext &projectContext, QString &errorMessage) const { Q_UNUSED(errorMessage); const QString destProjectPath = projectContext.destProjectPath(); file.setPath(destProjectPath % QLatin1Char('/') % file.path()); return true; }
Core::GeneratedFiles dryRunCustomWizardGeneratorScript(const QString &targetPath, const QStringList &script, const QList<GeneratorScriptArgument> &arguments, const QMap<QString, QString> &fieldMap, QString *errorMessage) { // Run in temporary directory as the target path may not exist yet. QString stdOut; if (!runGenerationScriptHelper(QDir::tempPath(), script, arguments, true, fieldMap, &stdOut, errorMessage)) return Core::GeneratedFiles(); Core::GeneratedFiles files; // Parse the output consisting of lines with ',' separated tokens. // (file name + attributes matching those of the <file> element) foreach (const QString &line, stdOut.split(QLatin1Char('\n'))) { const QString trimmed = line.trimmed(); if (!trimmed.isEmpty()) { Core::GeneratedFile file; Core::GeneratedFile::Attributes attributes = Core::GeneratedFile::CustomGeneratorAttribute; const QStringList tokens = line.split(QLatin1Char(',')); const int count = tokens.count(); for (int i = 0; i < count; i++) { const QString &token = tokens.at(i); if (i) { if (token == QLatin1String(customWizardFileOpenEditorAttributeC)) attributes |= Core::GeneratedFile::OpenEditorAttribute; else if (token == QLatin1String(customWizardFileOpenProjectAttributeC)) attributes |= Core::GeneratedFile::OpenProjectAttribute; } else { // Token 0 is file name. Wizard wants native names. // Expand to full path if relative const QFileInfo fileInfo(token); const QString fullPath = fileInfo.isAbsolute() ? token : (targetPath + QLatin1Char('/') + token); file.setPath(fullPath); } } file.setAttributes(attributes); files.push_back(file); } } if (CustomWizard::verbose()) { QDebug nospace = qDebug().nospace(); nospace << script << " generated:\n"; foreach (const Core::GeneratedFile &f, files) nospace << ' ' << f.path() << f.attributes() << '\n'; } return files; }