Commit a23b3498 authored by Daniel Teske's avatar Daniel Teske

ProjectExplorer: Make "Add New File" work on FolderNodes

The ResoureceNode will be a folder node, this enables that to work for
add new file.

Change-Id: Ifb4827d0900ce550be164c44979c5b72ab947c42
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent fba7dcdb
......@@ -2782,7 +2782,7 @@ void ProjectExplorerPlugin::addNewFile()
QString location = directoryFor(d->m_currentNode);
QVariantMap map;
map.insert(QLatin1String(Constants::PREFERED_PROJECT_NODE), d->m_currentNode->projectNode()->path());
map.insert(QLatin1String(Constants::PREFERED_PROJECT_NODE), QVariant::fromValue(d->m_currentNode));
if (d->m_currentProject) {
QList<Id> profileIds;
foreach (Target *target, d->m_currentProject->targets())
......@@ -2804,7 +2804,7 @@ void ProjectExplorerPlugin::addNewSubproject()
&& d->m_currentNode->supportedActions(
d->m_currentNode).contains(ProjectExplorer::AddSubProject)) {
QVariantMap map;
map.insert(QLatin1String(Constants::PREFERED_PROJECT_NODE), d->m_currentNode->projectNode()->path());
map.insert(QLatin1String(Constants::PREFERED_PROJECT_NODE), QVariant::fromValue(d->m_currentNode));
if (d->m_currentProject) {
QList<Id> profileIds;
foreach (Target *target, d->m_currentProject->targets())
......
......@@ -61,7 +61,7 @@ public slots:
void initializeVersionControlChoices();
private:
void initProjectChoices(const QString &generatedProjectFilePath);
void initProjectChoices(const QList<Core::GeneratedFile> generatedFiles);
bool processProject(const QList<Core::GeneratedFile> &files,
bool *removeOpenProjectAttribute, QString *errorMessage);
bool processVersionControl(const QList<Core::GeneratedFile> &files, QString *errorMessage);
......
......@@ -180,7 +180,9 @@ bool Node::isEnabled() const
QList<ProjectAction> Node::supportedActions(Node *node) const
{
return parentFolderNode()->supportedActions(node);
QList<ProjectAction> list = parentFolderNode()->supportedActions(node);
list.append(ProjectExplorer::InheritedFromParent);
return list;
}
void Node::setNodeType(NodeType type)
......@@ -357,6 +359,12 @@ bool FolderNode::renameFile(const QString &filePath, const QString &newFilePath)
return false;
}
FolderNode::AddNewInformation FolderNode::addNewInformation(const QStringList &files) const
{
Q_UNUSED(files);
return AddNewInformation(QFileInfo(path()).fileName(), 100);
}
/*!
Adds file nodes specified by \a files to the internal list of the folder
and emits the corresponding signals from the projectNode.
......
......@@ -68,6 +68,8 @@ enum FileType {
};
enum ProjectAction {
// Special value to indicate that the actions are handled by the parent
InheritedFromParent,
AddSubProject,
RemoveSubProject,
// Let's the user select to which project file
......@@ -180,6 +182,18 @@ public:
virtual bool deleteFiles(const QStringList &filePaths);
virtual bool renameFile(const QString &filePath, const QString &newFilePath);
class AddNewInformation
{
public:
AddNewInformation(const QString &name, int p)
:displayName(name), priority(p)
{}
QString displayName;
int priority;
};
virtual AddNewInformation addNewInformation(const QStringList &files) const;
void addFileNodes(const QList<FileNode*> &files);
void removeFileNodes(const QList<FileNode*> &files);
......@@ -442,4 +456,6 @@ T1 subtractSortedList(T1 list1, T1 list2, T3 sorter)
} // namespace ProjectExplorer
Q_DECLARE_METATYPE(ProjectExplorer::Node *)
#endif // PROJECTNODES_H
......@@ -1040,6 +1040,12 @@ bool QmakePriFileNode::renameFile(const QString &filePath, const QString &newFil
return true;
}
ProjectExplorer::FolderNode::AddNewInformation QmakePriFileNode::addNewInformation(const QStringList &files) const
{
Q_UNUSED(files)
return ProjectExplorer::FolderNode::AddNewInformation(QFileInfo(path()).fileName(), 90);
}
bool QmakePriFileNode::priFileWritable(const QString &path)
{
Core::Internal::ReadOnlyFilesDialog roDialog(path, Core::ICore::mainWindow());
......@@ -1540,6 +1546,12 @@ bool QmakeProFileNode::hasBuildTargets() const
return hasBuildTargets(projectType());
}
ProjectExplorer::FolderNode::AddNewInformation QmakeProFileNode::addNewInformation(const QStringList &files) const
{
Q_UNUSED(files)
return AddNewInformation(QFileInfo(path()).fileName(), 100);
}
bool QmakeProFileNode::hasBuildTargets(QmakeProjectType projectType) const
{
return (projectType == ApplicationTemplate || projectType == LibraryTemplate);
......
......@@ -158,6 +158,7 @@ public:
bool removeFiles(const QStringList &filePaths, QStringList *notRemoved = 0);
bool deleteFiles(const QStringList &filePaths);
bool renameFile(const QString &filePath, const QString &newFilePath);
AddNewInformation addNewInformation(const QStringList &files) const;
bool setProVariable(const QString &var, const QString &value);
......@@ -367,6 +368,8 @@ public:
bool hasBuildTargets() const;
AddNewInformation addNewInformation(const QStringList &files) const;
QmakeProjectType projectType() const;
QStringList variableValue(const QmakeVariable var) const;
......
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