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