summaryrefslogtreecommitdiff
path: root/src/plugins/projectexplorer
diff options
context:
space:
mode:
authorDaniel Teske <daniel.teske@digia.com>2013-07-01 16:13:48 +0200
committerDaniel Teske <daniel.teske@digia.com>2013-07-08 17:05:04 +0200
commitcc7fe5eac6ea6125b063ee36d0763d5cb230e26f (patch)
tree59a9750b5ce40148764526171fb807bab0aaaa68 /src/plugins/projectexplorer
parenta98fe15fe51a87e2943623caf2a8ea072cfc5919 (diff)
downloadqt-creator-cc7fe5eac6ea6125b063ee36d0763d5cb230e26f.tar.gz
Project: Simplfy file adding/removing interface
The filetype is only relevant for Qt4 projects. But even for Qt4 projects the file type is insufficient to decide where the file should be added. So remove the file type from the interface and let the projectmanagers themselves figure out what they want to do. Also fix Task-number: QTCREATORBUG-9688 Change-Id: I02f7b1cd2e05efaf76e36fb9af34b109d4482f88 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Diffstat (limited to 'src/plugins/projectexplorer')
-rw-r--r--src/plugins/projectexplorer/projectexplorer.cpp17
-rw-r--r--src/plugins/projectexplorer/projectfilewizardextension.cpp23
-rw-r--r--src/plugins/projectexplorer/projectnodes.cpp24
-rw-r--r--src/plugins/projectexplorer/projectnodes.h19
4 files changed, 16 insertions, 67 deletions
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index d9ce009784..374e705077 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -2844,16 +2844,9 @@ void ProjectExplorerPlugin::addExistingFiles(ProjectNode *projectNode, const QSt
const QString dir = directoryFor(projectNode);
QStringList fileNames = filePaths;
- QHash<FileType, QString> fileTypeToFiles;
- foreach (const QString &fileName, fileNames) {
- FileType fileType = typeForFileName(Core::ICore::mimeDatabase(), QFileInfo(fileName));
- fileTypeToFiles.insertMulti(fileType, fileName);
- }
-
QStringList notAdded;
- foreach (const FileType type, fileTypeToFiles.uniqueKeys()) {
- projectNode->addFiles(type, fileTypeToFiles.values(type), &notAdded);
- }
+ projectNode->addFiles(fileNames, &notAdded);
+
if (!notAdded.isEmpty()) {
QString message = tr("Could not add following files to project %1:\n").arg(projectNode->displayName());
QString files = notAdded.join(QString(QLatin1Char('\n')));
@@ -2919,7 +2912,7 @@ void ProjectExplorerPlugin::removeFile()
ProjectNode *projectNode = fileNode->projectNode();
Q_ASSERT(projectNode);
- if (!projectNode->removeFiles(fileNode->fileType(), QStringList(filePath))) {
+ if (!projectNode->removeFiles(QStringList(filePath))) {
QMessageBox::warning(Core::ICore::mainWindow(), tr("Removing File Failed"),
tr("Could not remove file %1 from project %2.").arg(filePath).arg(projectNode->displayName()));
return;
@@ -2947,7 +2940,7 @@ void ProjectExplorerPlugin::deleteFile()
ProjectNode *projectNode = fileNode->projectNode();
QTC_ASSERT(projectNode, return);
- projectNode->deleteFiles(fileNode->fileType(), QStringList(filePath));
+ projectNode->deleteFiles(QStringList(filePath));
Core::DocumentManager::expectFileChange(filePath);
if (Core::IVersionControl *vc =
@@ -2988,7 +2981,7 @@ 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(fileNode->fileType(), orgFilePath, newFilePath)) {
+ if (!projectNode->renameFile(orgFilePath, newFilePath)) {
QMessageBox::warning(Core::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)
diff --git a/src/plugins/projectexplorer/projectfilewizardextension.cpp b/src/plugins/projectexplorer/projectfilewizardextension.cpp
index dca5a2c688..9db36e72ba 100644
--- a/src/plugins/projectexplorer/projectfilewizardextension.cpp
+++ b/src/plugins/projectexplorer/projectfilewizardextension.cpp
@@ -472,8 +472,6 @@ bool ProjectFileWizardExtension::processProject(
const QList<Core::GeneratedFile> &files,
bool *removeOpenProjectAttribute, QString *errorMessage)
{
- typedef QMultiMap<FileType, QString> TypeFileMap;
-
*removeOpenProjectAttribute = false;
QString generatedProject = generatedProjectFilePath(files);
@@ -491,20 +489,13 @@ bool ProjectFileWizardExtension::processProject(
}
*removeOpenProjectAttribute = true;
} else {
- // Split into lists by file type and bulk-add them.
- TypeFileMap typeFileMap;
- const Core::MimeDatabase *mdb = Core::ICore::mimeDatabase();
- foreach (const Core::GeneratedFile &generatedFile, files) {
- const QString path = generatedFile.path();
- typeFileMap.insert(typeForFileName(mdb, path), path);
- }
- foreach (FileType type, typeFileMap.uniqueKeys()) {
- const QStringList typeFiles = typeFileMap.values(type);
- if (!project->addFiles(type, typeFiles)) {
- *errorMessage = tr("Failed to add one or more files to project\n'%1' (%2).").
- arg(project->path(), typeFiles.join(QString(QLatin1Char(','))));
- return false;
- }
+ QStringList filePaths;
+ foreach (const Core::GeneratedFile &generatedFile, files)
+ filePaths << generatedFile.path();
+ if (!project->addFiles(filePaths)) {
+ *errorMessage = tr("Failed to add one or more files to project\n'%1' (%2).").
+ arg(project->path(), filePaths.join(QString(QLatin1Char(','))));
+ return false;
}
}
return true;
diff --git a/src/plugins/projectexplorer/projectnodes.cpp b/src/plugins/projectexplorer/projectnodes.cpp
index 3b81a0b498..a84c21e715 100644
--- a/src/plugins/projectexplorer/projectnodes.cpp
+++ b/src/plugins/projectexplorer/projectnodes.cpp
@@ -837,27 +837,3 @@ NodesWatcher::NodesWatcher(QObject *parent)
: QObject(parent)
{
}
-
-// TODO Maybe put this in core, so that all can benefit
-FileType typeForFileName(const Core::MimeDatabase *db, const QFileInfo &file)
-{
- const Core::MimeType mt = db->findByFile(file);
- if (!mt)
- return UnknownFileType;
-
- const QString typeName = mt.type();
- if (typeName == QLatin1String(Constants::CPP_SOURCE_MIMETYPE)
- || typeName == QLatin1String(Constants::C_SOURCE_MIMETYPE))
- return SourceType;
- if (typeName == QLatin1String(Constants::CPP_HEADER_MIMETYPE)
- || typeName == QLatin1String(Constants::C_HEADER_MIMETYPE))
- return HeaderType;
- if (typeName == QLatin1String(Constants::RESOURCE_MIMETYPE))
- return ResourceType;
- if (typeName == QLatin1String(Constants::FORM_MIMETYPE))
- return FormType;
- if (mt.subClassesOf().contains(QLatin1String(Constants::QML_MIMETYPE))
- || typeName == QLatin1String(Constants::QML_MIMETYPE))
- return QMLType;
- return UnknownFileType;
-}
diff --git a/src/plugins/projectexplorer/projectnodes.h b/src/plugins/projectexplorer/projectnodes.h
index 90e965ee33..b324dff4ec 100644
--- a/src/plugins/projectexplorer/projectnodes.h
+++ b/src/plugins/projectexplorer/projectnodes.h
@@ -214,18 +214,10 @@ public:
virtual bool removeSubProjects(const QStringList &proFilePaths) = 0;
- virtual bool addFiles(const FileType fileType,
- const QStringList &filePaths,
- QStringList *notAdded = 0) = 0;
- // TODO: Maybe remove fileType, can be detected by project
- virtual bool removeFiles(const FileType fileType,
- const QStringList &filePaths,
- QStringList *notRemoved = 0) = 0;
- virtual bool deleteFiles(const FileType fileType,
- const QStringList &filePaths) = 0;
- virtual bool renameFile(const FileType fileType,
- const QString &filePath,
- const QString &newFilePath) = 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;
@@ -343,7 +335,4 @@ private:
} // namespace ProjectExplorer
-// HACK: THERE SHOULD BE ONE PLACE TO MAKE THE FILE ENDING->FILE TYPE ASSOCIATION
-ProjectExplorer::FileType typeForFileName(const Core::MimeDatabase *db, const QFileInfo &file);
-
#endif // PROJECTNODES_H