Commit 6186e130 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Only offer to import directories building the sources

Reviewed-by: dt
parent 86ca9f84
......@@ -94,11 +94,15 @@ void ProjectLoadWizard::setupTargetPage()
if (m_targetSetupPage)
return;
QList<TargetSetupPage::ImportInfo> importVersions = TargetSetupPage::recursivelyCheckDirectoryForBuild(m_project->projectDirectory());
importVersions.append(TargetSetupPage::recursivelyCheckDirectoryForBuild(m_project->defaultTopLevelBuildDirectory()));
QList<TargetSetupPage::ImportInfo> importVersions =
TargetSetupPage::recursivelyCheckDirectoryForBuild(m_project->projectDirectory(),
m_project->file()->fileName());
importVersions.append(TargetSetupPage::recursivelyCheckDirectoryForBuild(m_project->defaultTopLevelBuildDirectory(),
m_project->file()->fileName()));
importVersions.append(TargetSetupPage::importInfosForKnownQtVersions(m_project));
m_targetSetupPage = new TargetSetupPage(this);
m_targetSetupPage->setProFilePath(m_project->file()->fileName());
m_targetSetupPage->setImportInfos(importVersions);
m_targetSetupPage->setImportDirectoryBrowsingEnabled(true);
m_targetSetupPage->setImportDirectoryBrowsingLocation(m_project->projectDirectory());
......
......@@ -283,6 +283,11 @@ void TargetSetupPage::setPreferMobile(bool mobile)
m_preferMobile = mobile;
}
void TargetSetupPage::setProFilePath(const QString &path)
{
m_proFilePath = path;
}
QList<TargetSetupPage::ImportInfo>
TargetSetupPage::importInfosForKnownQtVersions(Qt4ProjectManager::Qt4Project *project)
{
......@@ -323,7 +328,7 @@ QList<TargetSetupPage::ImportInfo> TargetSetupPage::filterImportInfos(const QSet
}
QList<TargetSetupPage::ImportInfo>
TargetSetupPage::recursivelyCheckDirectoryForBuild(const QString &directory, int maxdepth)
TargetSetupPage::recursivelyCheckDirectoryForBuild(const QString &directory, const QString &proFile, int maxdepth)
{
QList<ImportInfo> results;
......@@ -334,10 +339,11 @@ TargetSetupPage::recursivelyCheckDirectoryForBuild(const QString &directory, int
QString qmakeBinary = QtVersionManager::findQMakeBinaryFromMakefile(directory);
// Recurse into subdirectories:
if (qmakeBinary.isNull()) {
if (qmakeBinary.isNull() || !QtVersionManager::makefileIsFor(directory, proFile)) {
QStringList subDirs = QDir(directory).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
foreach (QString subDir, subDirs)
results.append(recursivelyCheckDirectoryForBuild(directory + QChar('/') + subDir, maxdepth - 1));
results.append(recursivelyCheckDirectoryForBuild(QDir::cleanPath(directory + QChar('/') + subDir),
proFile, maxdepth - 1));
return results;
}
......@@ -385,7 +391,7 @@ void TargetSetupPage::importDirectoryAdded(const QString &directory)
m_directoryChooser->setPath(QString());
QList<ImportInfo> tmp = m_infos;
m_infos.clear(); // Clear m_infos without deleting temporary QtVersions!
tmp.append(recursivelyCheckDirectoryForBuild(directory));
tmp.append(recursivelyCheckDirectoryForBuild(directory, m_proFilePath));
setImportInfos(tmp);
}
......
......@@ -95,12 +95,14 @@ public:
void setImportDirectoryBrowsingLocation(const QString &directory);
void setShowLocationInformation(bool location);
void setPreferMobile(bool mobile);
void setProFilePath(const QString &dir);
static QList<ImportInfo> importInfosForKnownQtVersions(Qt4ProjectManager::Qt4Project *project);
static QList<ImportInfo> filterImportInfos(const QSet<QString> &validTargets,
const QList<ImportInfo> &infos);
static QList<ImportInfo> recursivelyCheckDirectoryForBuild(const QString &directory, int maxdepth = 3);
static QList<ImportInfo> recursivelyCheckDirectoryForBuild(const QString &directory,
const QString &proFile, int maxdepth = 3);
bool hasSelection() const;
bool isTargetSelected(const QString &targetid) const;
......@@ -120,6 +122,7 @@ private:
Utils::PathChooser *m_directoryChooser;
QLabel *m_directoryLabel;
bool m_preferMobile;
QString m_proFilePath;
};
} // namespace Internal
......
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