forked from qt-creator/qt-creator
Fix File/New in the deployment folders.
That is tell the user that those files need not be added to any project, and show "<Implicitly Add>" for them on the last wizard page. This fixes Add/New for the QML/OTHER_FILES folder structure, except for the virtual folder itself. Reviewed-By: Jarek Kobus <jaroslaw.kobus@nokia.com>
This commit is contained in:
@@ -174,7 +174,8 @@ QList<ProjectExplorer::ProjectNode::ProjectAction> GenericProjectNode::supported
|
|||||||
{
|
{
|
||||||
Q_UNUSED(node);
|
Q_UNUSED(node);
|
||||||
return QList<ProjectAction>()
|
return QList<ProjectAction>()
|
||||||
<< AddFile
|
<< AddNewFile
|
||||||
|
<< AddExistingFile
|
||||||
<< RemoveFile;
|
<< RemoveFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -162,12 +162,12 @@ struct ProjectExplorerPluginPrivate {
|
|||||||
QAction *m_debugAction;
|
QAction *m_debugAction;
|
||||||
QAction *m_addNewFileAction;
|
QAction *m_addNewFileAction;
|
||||||
QAction *m_addExistingFilesAction;
|
QAction *m_addExistingFilesAction;
|
||||||
QAction *m_openFileAction;
|
|
||||||
QAction *m_showInGraphicalShell;
|
|
||||||
QAction *m_openTerminalHere;
|
|
||||||
QAction *m_removeFileAction;
|
QAction *m_removeFileAction;
|
||||||
QAction *m_deleteFileAction;
|
QAction *m_deleteFileAction;
|
||||||
QAction *m_renameFileAction;
|
QAction *m_renameFileAction;
|
||||||
|
QAction *m_openFileAction;
|
||||||
|
QAction *m_showInGraphicalShell;
|
||||||
|
QAction *m_openTerminalHere;
|
||||||
QAction *m_projectSelectorAction;
|
QAction *m_projectSelectorAction;
|
||||||
QAction *m_projectSelectorActionMenu;
|
QAction *m_projectSelectorActionMenu;
|
||||||
|
|
||||||
@@ -724,6 +724,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
|||||||
globalcontext);
|
globalcontext);
|
||||||
mfilec->addAction(cmd, Constants::G_FILE_OTHER);
|
mfilec->addAction(cmd, Constants::G_FILE_OTHER);
|
||||||
|
|
||||||
|
// delete file action
|
||||||
d->m_deleteFileAction = new QAction(tr("Delete File..."), this);
|
d->m_deleteFileAction = new QAction(tr("Delete File..."), this);
|
||||||
cmd = am->registerAction(d->m_deleteFileAction, ProjectExplorer::Constants::DELETEFILE,
|
cmd = am->registerAction(d->m_deleteFileAction, ProjectExplorer::Constants::DELETEFILE,
|
||||||
globalcontext);
|
globalcontext);
|
||||||
@@ -1968,6 +1969,7 @@ void ProjectExplorerPlugin::updateContextMenuActions(Node *node)
|
|||||||
d->m_removeFileAction->setEnabled(false);
|
d->m_removeFileAction->setEnabled(false);
|
||||||
d->m_deleteFileAction->setEnabled(false);
|
d->m_deleteFileAction->setEnabled(false);
|
||||||
|
|
||||||
|
d->m_addExistingFilesAction->setVisible(true);
|
||||||
d->m_removeFileAction->setVisible(true);
|
d->m_removeFileAction->setVisible(true);
|
||||||
d->m_deleteFileAction->setVisible(true);
|
d->m_deleteFileAction->setVisible(true);
|
||||||
|
|
||||||
@@ -1976,9 +1978,8 @@ void ProjectExplorerPlugin::updateContextMenuActions(Node *node)
|
|||||||
d->m_currentNode->projectNode()->supportedActions(node);
|
d->m_currentNode->projectNode()->supportedActions(node);
|
||||||
|
|
||||||
if (qobject_cast<FolderNode*>(d->m_currentNode)) {
|
if (qobject_cast<FolderNode*>(d->m_currentNode)) {
|
||||||
bool addFilesEnabled = actions.contains(ProjectNode::AddFile);
|
d->m_addNewFileAction->setEnabled(actions.contains(ProjectNode::AddNewFile));
|
||||||
d->m_addExistingFilesAction->setEnabled(addFilesEnabled);
|
d->m_addExistingFilesAction->setEnabled(actions.contains(ProjectNode::AddExistingFile));
|
||||||
d->m_addNewFileAction->setEnabled(addFilesEnabled);
|
|
||||||
d->m_renameFileAction->setEnabled(actions.contains(ProjectNode::Rename));
|
d->m_renameFileAction->setEnabled(actions.contains(ProjectNode::Rename));
|
||||||
} else if (qobject_cast<FileNode*>(d->m_currentNode)) {
|
} else if (qobject_cast<FileNode*>(d->m_currentNode)) {
|
||||||
// Enable and show remove / delete in magic ways:
|
// Enable and show remove / delete in magic ways:
|
||||||
|
@@ -65,24 +65,29 @@ namespace Internal {
|
|||||||
class AllProjectNodesVisitor : public NodesVisitor
|
class AllProjectNodesVisitor : public NodesVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static ProjectNodeList allProjects();
|
AllProjectNodesVisitor(ProjectNode::ProjectAction action)
|
||||||
|
: m_action(action)
|
||||||
|
{}
|
||||||
|
|
||||||
|
static ProjectNodeList allProjects(ProjectNode::ProjectAction action);
|
||||||
|
|
||||||
virtual void visitProjectNode(ProjectNode *node);
|
virtual void visitProjectNode(ProjectNode *node);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProjectNodeList m_projectNodes;
|
ProjectNodeList m_projectNodes;
|
||||||
|
ProjectNode::ProjectAction m_action;
|
||||||
};
|
};
|
||||||
|
|
||||||
ProjectNodeList AllProjectNodesVisitor::allProjects()
|
ProjectNodeList AllProjectNodesVisitor::allProjects(ProjectNode::ProjectAction action)
|
||||||
{
|
{
|
||||||
AllProjectNodesVisitor visitor;
|
AllProjectNodesVisitor visitor(action);
|
||||||
ProjectExplorerPlugin::instance()->session()->sessionNode()->accept(&visitor);
|
ProjectExplorerPlugin::instance()->session()->sessionNode()->accept(&visitor);
|
||||||
return visitor.m_projectNodes;
|
return visitor.m_projectNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AllProjectNodesVisitor::visitProjectNode(ProjectNode *node)
|
void AllProjectNodesVisitor::visitProjectNode(ProjectNode *node)
|
||||||
{
|
{
|
||||||
if (node->supportedActions(node).contains(ProjectNode::AddFile))
|
if (node->supportedActions(node).contains(m_action))
|
||||||
m_projectNodes.push_back(node);
|
m_projectNodes.push_back(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,6 +184,16 @@ ProjectFileWizardExtension::~ProjectFileWizardExtension()
|
|||||||
delete m_context;
|
delete m_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QList<ProjectEntry> findDeployProject(const QList<ProjectEntry> &projects,
|
||||||
|
QString &commonPath)
|
||||||
|
{
|
||||||
|
QList<ProjectEntry> filtered;
|
||||||
|
foreach (const ProjectEntry &project, projects)
|
||||||
|
if (project.node->deploysFolder(commonPath))
|
||||||
|
filtered << project;
|
||||||
|
return filtered;
|
||||||
|
}
|
||||||
|
|
||||||
// Find the project the new files should be added to given their common
|
// Find the project the new files should be added to given their common
|
||||||
// path. Either a direct match on the directory or the directory with
|
// path. Either a direct match on the directory or the directory with
|
||||||
// the longest matching path (list containing"/project/subproject1" matching
|
// the longest matching path (list containing"/project/subproject1" matching
|
||||||
@@ -219,7 +234,28 @@ void ProjectFileWizardExtension::firstExtensionPageShown(const QList<Core::Gener
|
|||||||
m_context->commonDirectory = Utils::commonPath(fileNames);
|
m_context->commonDirectory = Utils::commonPath(fileNames);
|
||||||
m_context->page->setFilesDisplay(m_context->commonDirectory, fileNames);
|
m_context->page->setFilesDisplay(m_context->commonDirectory, fileNames);
|
||||||
// Find best project (Entry at 0 is 'None').
|
// Find best project (Entry at 0 is 'None').
|
||||||
const int bestProjectIndex = findMatchingProject(m_context->projects, m_context->commonDirectory);
|
|
||||||
|
int bestProjectIndex = -1;
|
||||||
|
|
||||||
|
QList<ProjectEntry> deployingProjects = findDeployProject(m_context->projects, m_context->commonDirectory);
|
||||||
|
if (!deployingProjects.isEmpty()) {
|
||||||
|
// Oh we do have someone that deploys it
|
||||||
|
// then the best match is NONE
|
||||||
|
// We display a label explaining that and rename <None> to
|
||||||
|
// <Implictly Add>
|
||||||
|
m_context->page->setNoneLabel(tr("<Implictly Add>"));
|
||||||
|
|
||||||
|
QString text = tr("The files are implicitly added to the projects:\n");
|
||||||
|
foreach (ProjectEntry project, deployingProjects)
|
||||||
|
text += project.fileName + "\n";
|
||||||
|
|
||||||
|
m_context->page->setAdditionalInfo(text);
|
||||||
|
bestProjectIndex = -1;
|
||||||
|
} else {
|
||||||
|
bestProjectIndex = findMatchingProject(m_context->projects, m_context->commonDirectory);
|
||||||
|
m_context->page->setNoneLabel(tr("<None>"));
|
||||||
|
}
|
||||||
|
|
||||||
if (bestProjectIndex == -1) {
|
if (bestProjectIndex == -1) {
|
||||||
m_context->page->setCurrentProjectIndex(0);
|
m_context->page->setCurrentProjectIndex(0);
|
||||||
} else {
|
} else {
|
||||||
@@ -290,7 +326,8 @@ void ProjectFileWizardExtension::initProjectChoices(bool enabled)
|
|||||||
// Sort by base name and purge duplicated entries (resulting from dependencies)
|
// Sort by base name and purge duplicated entries (resulting from dependencies)
|
||||||
// via Map.
|
// via Map.
|
||||||
ProjectEntryMap entryMap;
|
ProjectEntryMap entryMap;
|
||||||
foreach(ProjectNode *n, AllProjectNodesVisitor::allProjects())
|
|
||||||
|
foreach(ProjectNode *n, AllProjectNodesVisitor::allProjects(ProjectNode::AddNewFile))
|
||||||
entryMap.insert(ProjectEntry(n), true);
|
entryMap.insert(ProjectEntry(n), true);
|
||||||
// Collect names
|
// Collect names
|
||||||
const ProjectEntryMap::const_iterator cend = entryMap.constEnd();
|
const ProjectEntryMap::const_iterator cend = entryMap.constEnd();
|
||||||
|
@@ -261,6 +261,12 @@ QList<ProjectNode*> ProjectNode::subProjectNodes() const
|
|||||||
\function bool ProjectNode::renameFile(const FileType, const QString &, const QString &)
|
\function bool ProjectNode::renameFile(const FileType, const QString &, const QString &)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
bool ProjectNode::deploysFolder(const QString &folder) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(folder);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QList<NodesWatcher*> ProjectNode::watchers() const
|
QList<NodesWatcher*> ProjectNode::watchers() const
|
||||||
{
|
{
|
||||||
return m_watchers;
|
return m_watchers;
|
||||||
|
@@ -159,8 +159,15 @@ public:
|
|||||||
enum ProjectAction {
|
enum ProjectAction {
|
||||||
AddSubProject,
|
AddSubProject,
|
||||||
RemoveSubProject,
|
RemoveSubProject,
|
||||||
AddFile,
|
// Let's the user select to which project file
|
||||||
|
// the file is added
|
||||||
|
AddNewFile,
|
||||||
|
AddExistingFile,
|
||||||
|
// Removes a file from the project, optionally also
|
||||||
|
// delete it on disc
|
||||||
RemoveFile,
|
RemoveFile,
|
||||||
|
// Deletes a file from the file system, informs the project
|
||||||
|
// that a file was deleted
|
||||||
// DeleteFile is a define on windows...
|
// DeleteFile is a define on windows...
|
||||||
EraseFile,
|
EraseFile,
|
||||||
Rename
|
Rename
|
||||||
@@ -191,6 +198,8 @@ public:
|
|||||||
virtual bool renameFile(const FileType fileType,
|
virtual bool renameFile(const FileType fileType,
|
||||||
const QString &filePath,
|
const QString &filePath,
|
||||||
const QString &newFilePath) = 0;
|
const QString &newFilePath) = 0;
|
||||||
|
// by default returns false
|
||||||
|
virtual bool deploysFolder(const QString &folder) const;
|
||||||
|
|
||||||
|
|
||||||
QList<NodesWatcher*> watchers() const;
|
QList<NodesWatcher*> watchers() const;
|
||||||
|
@@ -74,6 +74,17 @@ void ProjectWizardPage::setCurrentProjectIndex(int idx)
|
|||||||
m_ui->projectComboBox->setCurrentIndex(idx);
|
m_ui->projectComboBox->setCurrentIndex(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProjectWizardPage::setNoneLabel(const QString &label)
|
||||||
|
{
|
||||||
|
m_ui->projectComboBox->setItemText(0, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectWizardPage::setAdditionalInfo(const QString &text)
|
||||||
|
{
|
||||||
|
m_ui->additionalInfo->setText(text);
|
||||||
|
m_ui->additionalInfo->setVisible(!text.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
void ProjectWizardPage::setVersionControls(const QStringList &vcs)
|
void ProjectWizardPage::setVersionControls(const QStringList &vcs)
|
||||||
{
|
{
|
||||||
m_ui->addToVersionControlComboBox->clear();
|
m_ui->addToVersionControlComboBox->clear();
|
||||||
|
@@ -52,6 +52,9 @@ public:
|
|||||||
int currentProjectIndex() const;
|
int currentProjectIndex() const;
|
||||||
void setCurrentProjectIndex(int);
|
void setCurrentProjectIndex(int);
|
||||||
|
|
||||||
|
void setNoneLabel(const QString &label);
|
||||||
|
void setAdditionalInfo(const QString &text);
|
||||||
|
|
||||||
void setVersionControls(const QStringList &);
|
void setVersionControls(const QStringList &);
|
||||||
|
|
||||||
int versionControlIndex() const;
|
int versionControlIndex() const;
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>619</width>
|
<width>226</width>
|
||||||
<height>414</height>
|
<height>184</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@@ -37,9 +37,12 @@
|
|||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizeAdjustPolicy">
|
||||||
|
<enum>QComboBox::AdjustToContents</enum>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="addToVersionControlLabel">
|
<widget class="QLabel" name="addToVersionControlLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add to &version control:</string>
|
<string>Add to &version control:</string>
|
||||||
@@ -49,9 +52,19 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QComboBox" name="addToVersionControlComboBox"/>
|
<widget class="QComboBox" name="addToVersionControlComboBox"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLabel" name="additionalInfo">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -89,8 +102,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>611</width>
|
<width>218</width>
|
||||||
<height>328</height>
|
<height>83</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
@@ -176,7 +176,7 @@ QList<ProjectExplorer::ProjectNode::ProjectAction> QmlProjectNode::supportedActi
|
|||||||
{
|
{
|
||||||
Q_UNUSED(node);
|
Q_UNUSED(node);
|
||||||
QList<ProjectAction> actions;
|
QList<ProjectAction> actions;
|
||||||
actions.append(AddFile);
|
actions.append(AddNewFile);
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -702,6 +702,20 @@ void Qt4PriFileNode::folderChanged(const QString &)
|
|||||||
contents.updateSubFolders(this, this);
|
contents.updateSubFolders(this, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Qt4PriFileNode::deploysFolder(const QString &folder) const
|
||||||
|
{
|
||||||
|
QString f = folder;
|
||||||
|
if (!f.endsWith('/'))
|
||||||
|
f.append('/');
|
||||||
|
foreach (const QString &wf, m_watchedFolders) {
|
||||||
|
if (f.startsWith(wf)
|
||||||
|
&& (wf.endsWith('/')
|
||||||
|
|| (wf.length() < f.length() && f.at(wf.length()) == '/')))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QList<ProjectNode::ProjectAction> Qt4PriFileNode::supportedActions(Node *node) const
|
QList<ProjectNode::ProjectAction> Qt4PriFileNode::supportedActions(Node *node) const
|
||||||
{
|
{
|
||||||
QList<ProjectAction> actions;
|
QList<ProjectAction> actions;
|
||||||
@@ -715,11 +729,17 @@ QList<ProjectNode::ProjectAction> Qt4PriFileNode::supportedActions(Node *node) c
|
|||||||
switch (proFileNode->projectType()) {
|
switch (proFileNode->projectType()) {
|
||||||
case ApplicationTemplate:
|
case ApplicationTemplate:
|
||||||
case LibraryTemplate:
|
case LibraryTemplate:
|
||||||
actions << AddFile;
|
actions << AddNewFile;
|
||||||
if (m_recursiveEnumerateFiles.contains(node->path()))
|
if (m_recursiveEnumerateFiles.contains(node->path())) {
|
||||||
actions << EraseFile;
|
actions << EraseFile;
|
||||||
else
|
} else {
|
||||||
actions << RemoveFile;
|
actions << RemoveFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only enable 'add existing file' if we don't deploy the folder
|
||||||
|
if (!deploysFolder(node->path()))
|
||||||
|
actions << AddExistingFile;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case SubDirsTemplate:
|
case SubDirsTemplate:
|
||||||
actions << AddSubProject << RemoveSubProject;
|
actions << AddSubProject << RemoveSubProject;
|
||||||
|
@@ -154,6 +154,8 @@ public:
|
|||||||
|
|
||||||
void folderChanged(const QString &folder);
|
void folderChanged(const QString &folder);
|
||||||
|
|
||||||
|
bool deploysFolder(const QString &folder) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void clear();
|
void clear();
|
||||||
static QStringList varNames(FileType type);
|
static QStringList varNames(FileType type);
|
||||||
|
@@ -100,7 +100,6 @@ bool QtSingleApplication::isRunning()
|
|||||||
return peer->isClient();
|
return peer->isClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool QtSingleApplication::sendMessage(const QString &message, int timeout)
|
bool QtSingleApplication::sendMessage(const QString &message, int timeout)
|
||||||
{
|
{
|
||||||
return peer->sendMessage(message, timeout);
|
return peer->sendMessage(message, timeout);
|
||||||
|
Reference in New Issue
Block a user