Skip to content
Snippets Groups Projects
Commit 5b11a292 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Add files to the projects.

parent 8f9bc24d
No related branches found
No related tags found
No related merge requests found
......@@ -168,7 +168,7 @@ Core::IFile *QmlProject::file() const
return m_file;
}
ProjectExplorer::IProjectManager *QmlProject::projectManager() const
Manager *QmlProject::projectManager() const
{
return m_manager;
}
......
......@@ -59,7 +59,7 @@ public:
virtual QString name() const;
virtual Core::IFile *file() const;
virtual ProjectExplorer::IProjectManager *projectManager() const;
virtual Manager *projectManager() const;
virtual QList<ProjectExplorer::Project *> dependsOn();
......
......@@ -28,6 +28,7 @@
**************************************************************************/
#include "qmlprojectnodes.h"
#include "qmlprojectmanager.h"
#include "qmlproject.h"
#include <coreplugin/ifile.h>
......@@ -153,7 +154,9 @@ bool QmlProjectNode::hasTargets() const
QList<ProjectExplorer::ProjectNode::ProjectAction> QmlProjectNode::supportedActions() const
{
return QList<ProjectAction>();
QList<ProjectAction> actions;
actions.append(AddFile);
return actions;
}
bool QmlProjectNode::addSubProjects(const QStringList &proFilePaths)
......@@ -168,17 +171,45 @@ bool QmlProjectNode::removeSubProjects(const QStringList &proFilePaths)
return false;
}
bool QmlProjectNode::addFiles(const ProjectExplorer::FileType fileType,
const QStringList &filePaths, QStringList *notAdded)
bool QmlProjectNode::addFiles(const ProjectExplorer::FileType,
const QStringList &filePaths, QStringList *notAdded)
{
Q_UNUSED(fileType);
Q_UNUSED(filePaths);
Q_UNUSED(notAdded);
return false;
QDir projectDir(QFileInfo(projectFilePath()).dir());
QFile file(projectFilePath());
if (! file.open(QFile::WriteOnly | QFile::Append))
return false;
QTextStream stream(&file);
QStringList failedFiles;
bool first = true;
foreach (const QString &filePath, filePaths) {
const QString rel = projectDir.relativeFilePath(filePath);
if (rel.isEmpty() || rel.startsWith(QLatin1Char('.'))) {
failedFiles.append(rel);
} else {
if (first) {
stream << endl;
first = false;
}
stream << rel << endl;
}
}
if (notAdded)
*notAdded += failedFiles;
if (! first)
m_project->projectManager()->notifyChanged(projectFilePath());
return failedFiles.isEmpty();
}
bool QmlProjectNode::removeFiles(const ProjectExplorer::FileType fileType,
const QStringList &filePaths, QStringList *notRemoved)
const QStringList &filePaths, QStringList *notRemoved)
{
Q_UNUSED(fileType);
Q_UNUSED(filePaths);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment