diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 227d20e0ed423185da62bf52343c9717c849fc35..b69649ab313da842be62f9ef0e5c9b4f180a9312 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -2002,8 +2002,23 @@ void ProjectExplorerPlugin::updateContextMenuActions(Node *node) void ProjectExplorerPlugin::addNewFile() { QTC_ASSERT(d->m_currentNode, return) - QFileInfo fi(d->m_currentNode->path()); - const QString location = (fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath()); + QString path = d->m_currentNode->path(); + QString location; + FolderNode *folder = qobject_cast<FolderNode *>(d->m_currentNode); + 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() + "/"; + if (list.isEmpty()) + location = path.left(path.indexOf('#')); + else + location = Utils::commonPath(list); + } else { + QFileInfo fi(path); + location = (fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath()); + } Core::ICore::instance()->showNewItemDialog(tr("New File", "Title of dialog"), Core::IWizard::wizardsOfKind(Core::IWizard::FileWizard) + Core::IWizard::wizardsOfKind(Core::IWizard::ClassWizard), diff --git a/src/plugins/qt4projectmanager/qt4nodes.cpp b/src/plugins/qt4projectmanager/qt4nodes.cpp index 9f3087634b2f725b66da442f80f7591220a625d8..343a44a74836fda47e52f971c74c43a31b54f2f9 100644 --- a/src/plugins/qt4projectmanager/qt4nodes.cpp +++ b/src/plugins/qt4projectmanager/qt4nodes.cpp @@ -53,6 +53,7 @@ #include <projectexplorer/buildmanager.h> #include <utils/qtcassert.h> +#include <utils/stringutils.h> #include <algorithm> #include <QtCore/QDebug> @@ -728,7 +729,7 @@ QList<ProjectNode::ProjectAction> Qt4PriFileNode::supportedActions(Node *node) c switch (proFileNode->projectType()) { case ApplicationTemplate: - case LibraryTemplate: + case LibraryTemplate: { actions << AddNewFile; if (m_recursiveEnumerateFiles.contains(node->path())) { actions << EraseFile; @@ -736,11 +737,26 @@ QList<ProjectNode::ProjectAction> Qt4PriFileNode::supportedActions(Node *node) c actions << RemoveFile; } - // Only enable 'add existing file' if we don't deploy the folder - if (!deploysFolder(node->path())) + bool addExistingFiles = true; + if (node->path().contains('#')) { + // A virtual folder, we do what the projectexplorer does + FolderNode *folder = qobject_cast<FolderNode *>(node); + if (folder) { + QStringList list; + foreach (FolderNode *f, folder->subFolderNodes()) + list << f->path() + '/'; + if (deploysFolder(Utils::commonPath(list))) + addExistingFiles = false; + } + } + + addExistingFiles = addExistingFiles && deploysFolder(node->path()); + + if (addExistingFiles) actions << AddExistingFile; break; + } case SubDirsTemplate: actions << AddSubProject << RemoveSubProject; break;