From ba9a197e5ef6ecc4a676bf2d0a5b936d388f680a Mon Sep 17 00:00:00 2001
From: Kai Koehne <kai.koehne@nokia.com>
Date: Wed, 17 Feb 2010 10:19:17 +0100
Subject: [PATCH] Disable adding of files to a .qmlproject

The old code still assumed the old, plain text format, and just added
the file path to the end of the file. This broke the new .qmlproject
file format.

Ideally QmlProject should be clever enough to check whether the file
will be automatically picked up in the monitored directories, and if
not added explicitly e.g. to QmlFiles { paths: ... }. Anyhow, this
quick fix just shows every time an error message instead of destroying
the .qmlproject file.
---
 .../qmlprojectmanager/qmlprojectnodes.cpp     | 51 +++----------------
 1 file changed, 7 insertions(+), 44 deletions(-)

diff --git a/src/plugins/qmlprojectmanager/qmlprojectnodes.cpp b/src/plugins/qmlprojectmanager/qmlprojectnodes.cpp
index 163e2e7b543..63b4f813ade 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectnodes.cpp
+++ b/src/plugins/qmlprojectmanager/qmlprojectnodes.cpp
@@ -182,58 +182,21 @@ bool QmlProjectNode::removeSubProjects(const QStringList &proFilePaths)
     return false;
 }
 
-bool QmlProjectNode::addFiles(const ProjectExplorer::FileType,
-                              const QStringList &filePaths, QStringList *notAdded)
+bool QmlProjectNode::addFiles(const ProjectExplorer::FileType /*fileType*/,
+                              const QStringList & /*filePaths*/, QStringList * /*notAdded*/)
 {
-    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();
+    return false;
 }
 
-bool QmlProjectNode::removeFiles(const ProjectExplorer::FileType fileType,
-                                 const QStringList &filePaths, QStringList *notRemoved)
+bool QmlProjectNode::removeFiles(const ProjectExplorer::FileType /*fileType*/,
+                                 const QStringList & /*filePaths*/, QStringList * /*notRemoved*/)
 {
-    Q_UNUSED(fileType)
-    Q_UNUSED(filePaths)
-    Q_UNUSED(notRemoved)
     return false;
 }
 
-bool QmlProjectNode::renameFile(const ProjectExplorer::FileType fileType,
-                                    const QString &filePath, const QString &newFilePath)
+bool QmlProjectNode::renameFile(const ProjectExplorer::FileType /*fileType*/,
+                                    const QString & /*filePath*/, const QString & /*newFilePath*/)
 {
-    Q_UNUSED(fileType)
-    Q_UNUSED(filePath)
-    Q_UNUSED(newFilePath)
     return false;
 }
 
-- 
GitLab