From 02cd2c71038a9a241b1d3b1901ca3f31a29debf5 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Wed, 20 Jul 2011 11:42:52 +0200 Subject: 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 Reviewed-by: Daniel Teske --- src/plugins/projectexplorer/projectexplorer.cpp | 16 +++++++++------- 1 file 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(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) { -- cgit v1.2.1