summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@nokia.com>2011-07-20 11:42:52 +0200
committerEike Ziller <eike.ziller@nokia.com>2011-07-20 13:27:49 +0200
commit02cd2c71038a9a241b1d3b1901ca3f31a29debf5 (patch)
treefe520392fb6e77d260389885cb7049cf059b9a40
parentedd8dac2651fa4a31e362344bbd82943b3545c2e (diff)
downloadqt-creator-02cd2c71038a9a241b1d3b1901ca3f31a29debf5.tar.gz
Fix suggested folder for New File from context menu on project tree.
If a virtual category folder had files directly below them and a single subdirectory, the suggestion was the subdirectory. Change-Id: I185c7e6e9f64764664f5858d95aea57082161b82 Reviewed-on: http://codereview.qt.nokia.com/1871 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
-rw-r--r--src/plugins/projectexplorer/projectexplorer.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index 0fe62c99b3..645cd4bcbf 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -2344,14 +2344,16 @@ QString pathOrDirectoryFor(Node *node, bool dir)
FolderNode *folder = qobject_cast<FolderNode *>(node);
if (path.contains("#") && folder) {
// Virtual Folder case
- // We figure out a commonPath from the subfolders
- QStringList list;
- foreach (FolderNode *f, folder->subFolderNodes())
- list << f->path() + QLatin1Char('/');
- if (list.isEmpty())
- location = path.left(path.indexOf('#'));
- else
+ // If there are files directly below or no subfolders, take the folder path
+ if (!folder->fileNodes().isEmpty() || folder->subFolderNodes().isEmpty()) {
+ location = path.left(path.indexOf('#'));;
+ } else {
+ // Otherwise we figure out a commonPath from the subfolders
+ QStringList list;
+ foreach (FolderNode *f, folder->subFolderNodes())
+ list << f->path() + QLatin1Char('/');
location = Utils::commonPath(list);
+ }
} else {
QFileInfo fi(path);
if (dir) {