Commit bf249dc6 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

JsonWizard: Add option to only scan for the first project



Make that option the default. This matches what the earlier
checkout wizards used to do.

Change-Id: I935c45b213bc3b688e964340ebebf74c597b3896
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent 3c9efc3e
......@@ -40,6 +40,7 @@
#include <extensionsystem/pluginmanager.h>
#include <utils/algorithm.h>
#include <utils/fileutils.h>
#include <utils/qtcassert.h>
#include <utils/macroexpander.h>
......@@ -77,6 +78,8 @@ bool JsonWizardScannerGenerator::setup(const QVariant &data, QString *errorMessa
m_subDirectoryExpressions << regexp;
}
m_firstProjectOnly = gen.value(QLatin1String("firstProjectOnly"), QLatin1String("true")).toString();
return true;
}
......@@ -103,25 +106,24 @@ Core::GeneratedFiles JsonWizardScannerGenerator::fileList(Utils::MacroExpander *
}
}
bool onlyFirst = JsonWizard::boolFromVariant(m_firstProjectOnly, expander);
result = scan(project.absolutePath(), project);
QList<IProjectManager *> projectManagers
= ExtensionSystem::PluginManager::getObjects<IProjectManager>();
int projectCount = 0;
for (auto it = result.begin(); it != result.end(); ++it) {
const QString relPath = project.relativeFilePath(it->path());
it->setBinary(binaryPattern.match(relPath).hasMatch());
Utils::MimeType mt = mdb.mimeTypeForFile(relPath);
if (mt.isValid()) {
bool foundProjectManager = false;
foreach (IProjectManager *manager, projectManagers) {
if (mt.matchesName(manager->mimeType())) {
foundProjectManager = true;
break;
}
}
if (foundProjectManager)
bool found = Utils::anyOf(projectManagers, [mt](IProjectManager *m) {
return mt.matchesName(m->mimeType());
});
if (found && !(onlyFirst && projectCount++))
it->setAttributes(it->attributes() | Core::GeneratedFile::OpenProjectAttribute);
}
}
......
......@@ -55,6 +55,7 @@ private:
bool matchesSubdirectoryPattern(const QString &path);
QString m_binaryPattern;
QString m_firstProjectOnly;
QList<QRegularExpression> m_subDirectoryExpressions;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment