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