forked from qt-creator/qt-creator
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.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
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::removeFiles(const ProjectExplorer::FileType /*fileType*/,
|
||||
const QStringList & /*filePaths*/, QStringList * /*notRemoved*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QmlProjectNode::renameFile(const ProjectExplorer::FileType /*fileType*/,
|
||||
const QString & /*filePath*/, const QString & /*newFilePath*/)
|
||||
{
|
||||
Q_UNUSED(fileType)
|
||||
Q_UNUSED(filePath)
|
||||
Q_UNUSED(newFilePath)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user