MCPcopy Create free account
hub / github.com/OpenBoard-org/OpenBoard / save

Method save

src/document/UBTocSerializer.cpp:104–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104bool UBTocJsonSerializer::save(const QVersionNumber& version, const QVector<QVariantMap>& toc)
105{
106 QJsonArray list;
107
108 for (const auto entry : toc)
109 {
110 list.append(QJsonObject::fromVariantMap(entry));
111 }
112
113 QJsonObject document;
114 document[VERSION] = version.toString();
115 document[PAGES] = list;
116
117 QJsonDocument doc{document};
118 auto json = doc.toJson(QJsonDocument::Indented);
119
120 // reduce indentation to one space
121 json.replace(" ", " ");
122
123 QFile file{mPath + "/toc.json"};
124
125 if (!file.open(QFile::WriteOnly))
126 {
127 qWarning() << "Cannot save TOC: Cannot open file" << file.fileName();
128 return false;
129 }
130
131 file.write(json);
132 file.close();
133 return true;
134}

Callers

nothing calls this directly

Calls 1

closeMethod · 0.45

Tested by

no test coverage detected