diff options
author | Daniel Teske <daniel.teske@digia.com> | 2014-04-11 15:49:59 +0200 |
---|---|---|
committer | Daniel Teske <daniel.teske@digia.com> | 2014-04-29 11:47:07 +0200 |
commit | f0a8f4d9185a9d7dc37a9d204e2e2ab36a6f4284 (patch) | |
tree | e5b2caf0fcb40b3a94b25ff3e03b7f126e9bfac0 | |
parent | 3434420cdea7f3fe6a342a5779987a6be7f82470 (diff) | |
download | qt-creator-f0a8f4d9185a9d7dc37a9d204e2e2ab36a6f4284.tar.gz |
New File Wizard: Pay more attention to common path length
For qmake project some projects use .pri files in subdirectotires to
structure their project files. Those should be preferred to .pro files
higher up in the tree. While there are also .pri files that set common
variables between multiple .pro files, those are unlikely to be in the
leafs.
Change-Id: Ida6b4fc887fd8c273988ca71f2ead9d4e5929ae5
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
-rw-r--r-- | src/plugins/projectexplorer/projectfilewizardextension.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/plugins/projectexplorer/projectfilewizardextension.cpp b/src/plugins/projectexplorer/projectfilewizardextension.cpp index 9c4cd70caa..4c9f540740 100644 --- a/src/plugins/projectexplorer/projectfilewizardextension.cpp +++ b/src/plugins/projectexplorer/projectfilewizardextension.cpp @@ -288,19 +288,16 @@ static int findMatchingProject(const QList<FolderEntry> &projects, const FolderEntry &entry = projects.at(p); const QString &projectDirectory = entry.directory; const int projectDirectorySize = projectDirectory.size(); - if (entry.priority > bestMatchPriority) { - if (commonPath.startsWith(projectDirectory)) { - bestMatchPriority = entry.priority; - bestMatchLength = projectDirectory.size(); - bestMatch = p; - } - } else if (entry.priority == bestMatchPriority) { - if (projectDirectorySize > bestMatchLength - && commonPath.startsWith(projectDirectory)) { - bestMatchPriority = entry.priority; - bestMatchLength = projectDirectory.size(); - bestMatch = p; - } + if (!commonPath.startsWith(projectDirectory)) + continue; + + bool betterMatch = projectDirectorySize > bestMatchLength + || (projectDirectorySize == bestMatchLength && entry.priority > bestMatchPriority); + + if (betterMatch) { + bestMatchPriority = entry.priority; + bestMatchLength = projectDirectory.size(); + bestMatch = p; } } return bestMatch; |