Commit 84d5e101 authored by Mark Nauwelaerts's avatar Mark Nauwelaerts

project: handle sparse project file

... by auto-generating some entries as in the auto-generated project case
parent 2ef84f78
......@@ -33,6 +33,8 @@
#include <QPlainTextDocumentLayout>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QJsonObject>
#include <QJsonArray>
#include <utility>
KateProject::KateProject(ThreadWeaver::Queue *weaver)
......@@ -103,6 +105,32 @@ QVariantMap KateProject::readProjectFile() const
return QVariantMap();
}
/**
* convenience; align with auto-generated projects
* generate 'name' and 'files' if not specified explicitly,
* so those parts need not be given if only wishes to specify additional
* project configuration (e.g. build, ctags)
*/
if (project.isObject()) {
auto dir = QFileInfo(m_fileName).dir();
auto object = project.object();
auto name = object[QStringLiteral("name")];
if (name.isUndefined() || name.isNull()) {
name = dir.dirName();
}
auto files = object[QStringLiteral("files")];
if (files.isUndefined() || files.isNull()) {
// support all we can, could try to detect,
// but it will be sorted out upon loading anyway
QJsonArray afiles;
for (const auto &t : {QStringLiteral("git"), QStringLiteral("hg"), QStringLiteral("svn"), QStringLiteral("darcs")}) {
afiles.push_back(QJsonObject {{t, true}});
}
files = afiles;
}
project.setObject(object);
}
return project.toVariant().toMap();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment