forked from qt-creator/qt-creator
ProjectNodes: Move (add|remove|delete|rename)Files to FolderNode
Change-Id: I464a4c1da299d61accba7abf928464ea6ad2ba4c Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -2842,21 +2842,22 @@ void ProjectExplorerPlugin::addExistingDirectory()
|
||||
|
||||
void ProjectExplorerPlugin::addExistingFiles(const QStringList &filePaths)
|
||||
{
|
||||
addExistingFiles(d->m_currentNode->projectNode(), filePaths);
|
||||
FolderNode *folderNode = qobject_cast<FolderNode *>(d->m_currentNode);
|
||||
addExistingFiles(folderNode, filePaths);
|
||||
}
|
||||
|
||||
void ProjectExplorerPlugin::addExistingFiles(ProjectNode *projectNode, const QStringList &filePaths)
|
||||
void ProjectExplorerPlugin::addExistingFiles(FolderNode *folderNode, const QStringList &filePaths)
|
||||
{
|
||||
if (!projectNode) // can happen when project is not yet parsed
|
||||
if (!folderNode) // can happen when project is not yet parsed
|
||||
return;
|
||||
|
||||
const QString dir = directoryFor(projectNode);
|
||||
const QString dir = directoryFor(folderNode);
|
||||
QStringList fileNames = filePaths;
|
||||
QStringList notAdded;
|
||||
projectNode->addFiles(fileNames, ¬Added);
|
||||
folderNode->addFiles(fileNames, ¬Added);
|
||||
|
||||
if (!notAdded.isEmpty()) {
|
||||
QString message = tr("Could not add following files to project %1:").arg(projectNode->displayName());
|
||||
QString message = tr("Could not add following files to project %1:").arg(folderNode->projectNode()->displayName());
|
||||
message += QLatin1Char('\n');
|
||||
QString files = notAdded.join(QString(QLatin1Char('\n')));
|
||||
QMessageBox::warning(ICore::mainWindow(), tr("Adding Files to Project Failed"),
|
||||
@@ -2918,12 +2919,12 @@ void ProjectExplorerPlugin::removeFile()
|
||||
const bool deleteFile = removeFileDialog.isDeleteFileChecked();
|
||||
|
||||
// remove from project
|
||||
ProjectNode *projectNode = fileNode->projectNode();
|
||||
Q_ASSERT(projectNode);
|
||||
FolderNode *folderNode = fileNode->parentFolderNode();
|
||||
Q_ASSERT(folderNode);
|
||||
|
||||
if (!projectNode->removeFiles(QStringList(filePath))) {
|
||||
if (!folderNode->removeFiles(QStringList(filePath))) {
|
||||
QMessageBox::warning(ICore::mainWindow(), tr("Removing File Failed"),
|
||||
tr("Could not remove file %1 from project %2.").arg(filePath).arg(projectNode->displayName()));
|
||||
tr("Could not remove file %1 from project %2.").arg(filePath).arg(folderNode->projectNode()->displayName()));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2946,10 +2947,10 @@ void ProjectExplorerPlugin::deleteFile()
|
||||
if (button != QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
ProjectNode *projectNode = fileNode->projectNode();
|
||||
QTC_ASSERT(projectNode, return);
|
||||
FolderNode *folderNode = fileNode->parentFolderNode();
|
||||
QTC_ASSERT(folderNode, return);
|
||||
|
||||
projectNode->deleteFiles(QStringList(filePath));
|
||||
folderNode->deleteFiles(QStringList(filePath));
|
||||
|
||||
DocumentManager::expectFileChange(filePath);
|
||||
if (IVersionControl *vc =
|
||||
@@ -2989,13 +2990,13 @@ void ProjectExplorerPlugin::renameFile(Node *node, const QString &to)
|
||||
|
||||
if (Core::FileUtils::renameFile(orgFilePath, newFilePath)) {
|
||||
// Tell the project plugin about rename
|
||||
ProjectNode *projectNode = fileNode->projectNode();
|
||||
if (!projectNode->renameFile(orgFilePath, newFilePath)) {
|
||||
FolderNode *folderNode = fileNode->parentFolderNode();
|
||||
if (!folderNode->renameFile(orgFilePath, newFilePath)) {
|
||||
QMessageBox::warning(ICore::mainWindow(), tr("Project Editing Failed"),
|
||||
tr("The file %1 was renamed to %2, but the project file %3 could not be automatically changed.")
|
||||
.arg(orgFilePath)
|
||||
.arg(newFilePath)
|
||||
.arg(projectNode->displayName()));
|
||||
.arg(folderNode->projectNode()->displayName()));
|
||||
} else {
|
||||
setCurrent(SessionManager::projectForFile(newFilePath), newFilePath, 0);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class IRunControlFactory;
|
||||
class Project;
|
||||
class Node;
|
||||
class BuildConfiguration;
|
||||
class ProjectNode;
|
||||
class FolderNode;
|
||||
class TaskHub;
|
||||
|
||||
namespace Internal { class ProjectExplorerSettings; }
|
||||
@@ -112,7 +112,7 @@ public:
|
||||
void runRunConfiguration(ProjectExplorer::RunConfiguration *rc, RunMode runMode,
|
||||
const bool forceSkipDeploy = false);
|
||||
|
||||
void addExistingFiles(ProjectExplorer::ProjectNode *projectNode, const QStringList &filePaths);
|
||||
void addExistingFiles(ProjectExplorer::FolderNode *projectNode, const QStringList &filePaths);
|
||||
void addExistingFiles(const QStringList &filePaths);
|
||||
|
||||
void buildProject(ProjectExplorer::Project *p);
|
||||
|
||||
@@ -329,6 +329,34 @@ FolderNode *FolderNode::findSubFolder(const QString &path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool FolderNode::addFiles(const QStringList &filePaths, QStringList *notAdded)
|
||||
{
|
||||
if (projectNode())
|
||||
return projectNode()->addFiles(filePaths, notAdded);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FolderNode::removeFiles(const QStringList &filePaths, QStringList *notRemoved)
|
||||
{
|
||||
if (projectNode())
|
||||
return projectNode()->removeFiles(filePaths, notRemoved);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FolderNode::deleteFiles(const QStringList &filePaths)
|
||||
{
|
||||
if (projectNode())
|
||||
return projectNode()->deleteFiles(filePaths);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FolderNode::renameFile(const QString &filePath, const QString &newFilePath)
|
||||
{
|
||||
if (projectNode())
|
||||
return projectNode()->renameFile(filePath, newFilePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\class ProjectExplorer::VirtualFolderNode
|
||||
|
||||
|
||||
@@ -173,6 +173,11 @@ public:
|
||||
FileNode *findFile(const QString &path);
|
||||
FolderNode *findSubFolder(const QString &path);
|
||||
|
||||
virtual bool addFiles(const QStringList &filePaths, QStringList *notAdded = 0);
|
||||
virtual bool removeFiles(const QStringList &filePaths, QStringList *notRemoved = 0);
|
||||
virtual bool deleteFiles(const QStringList &filePaths);
|
||||
virtual bool renameFile(const QString &filePath, const QString &newFilePath);
|
||||
|
||||
protected:
|
||||
QList<FolderNode*> m_subFolderNodes;
|
||||
QList<FileNode*> m_fileNodes;
|
||||
@@ -219,10 +224,6 @@ public:
|
||||
|
||||
virtual bool removeSubProjects(const QStringList &proFilePaths) = 0;
|
||||
|
||||
virtual bool addFiles(const QStringList &filePaths, QStringList *notAdded = 0) = 0;
|
||||
virtual bool removeFiles(const QStringList &filePaths, QStringList *notRemoved = 0) = 0;
|
||||
virtual bool deleteFiles(const QStringList &filePaths) = 0;
|
||||
virtual bool renameFile(const QString &filePath, const QString &newFilePath) = 0;
|
||||
// by default returns false
|
||||
virtual bool deploysFolder(const QString &folder) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user