Commit 0c8ce343 authored by Felipe Borges's avatar Felipe Borges Committed by Christoph Cullmann
Browse files

Serializing a project QVariantList on KConfigGroup


Signed-off-by: Felipe Borges's avatarFelipe Borges <bumbleblo2013@gmail.com>
parent 98ec3fce
......@@ -592,35 +592,42 @@ void KateProjectPlugin::unregisterVariables()
void KateProjectPlugin::readSessionConfig(const KConfigGroup &config)
{
const QStringList projectList = config.readEntry("projects", QStringList());
const QVariantList projectMapList = config.readEntry("projectsMaps", QVariantList());
if (!projectMapList.isEmpty()){
int i = 0;
for (const QString &project : projectList) {
createProjectForDirectory(QDir(project), projectMapList.at(i).toMap());
i++;
}
} else {
for (const QString &project : projectList) {
createProjectForDirectory(QDir(project));
QByteArray buffer;
QVariantMap projectMap;
QVariantList projectList = config.readEntry("projects", QVariantList());
for (QVariant &project : projectList) {
buffer = project.toByteArray();
{
QDataStream stream(&buffer, QIODevice::ReadOnly);
stream >> projectMap;
}
}
createProjectForDirectory(QDir(projectMap[QStringLiteral("path")].toString()), projectMap[QStringLiteral("data")].toMap());
}
}
void KateProjectPlugin::writeSessionConfig(KConfigGroup &config)
{
QStringList projectList;
QVariantList projectMapList;
QVariantList projectList;
QByteArray buffer;
for (KateProject *project : projects()) {
if (project->fileName().isEmpty()) {
projectList.push_back(project->baseDir());
projectMapList.push_back(project->projectMap());
if (!project->isFileBacked()) {
QVariantMap sMap;
sMap[QStringLiteral("data")] = project->projectMap();
sMap[QStringLiteral("path")] = project->baseDir();
{
QDataStream stream(&buffer, QIODevice::WriteOnly);
stream << sMap;
}
projectList.push_back(buffer);
}
}
config.writeEntry("projects", projectList);
config.writeEntry("projectsMaps", projectMapList);
}
......@@ -200,6 +200,10 @@ private:
static void registerVariables();
static void unregisterVariables();
/***
* Serialize object into a QByteArray
*/
private:
/**
* open plugins, maps project base directory => project
......
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