Commit ece749c3 authored by dt's avatar dt
Browse files

Fix context menu for the QML virtual folder.

That is: a) Figure out a suitable default location for Add New on a
virtual folder.
b) If that default location is deployed, don't show a Add Existing Files
option, since that is confusing.
parent e5f8a31b
......@@ -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),
......
......@@ -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;
......
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