MCPcopy Create free account
hub / github.com/KDE/labplot / processExampleProjects

Method processExampleProjects

src/frontend/welcomescreen/WelcomeScreenHelper.cpp:238–272  ·  view source on GitHub ↗

* @brief Processes metadata file containing example projects. */

Source from the content-addressed store, hash-verified

236 * @brief Processes metadata file containing example projects.
237 */
238void WelcomeScreenHelper::processExampleProjects() {
239 const QString filePath = QStandardPaths::locate(QStandardPaths::AppDataLocation, "example_projects/example_projects.json");
240 QFile file(filePath);
241
242 if (file.open(QIODevice::ReadOnly)) {
243 QJsonDocument document = QJsonDocument::fromJson(file.readAll());
244 QJsonArray exampleArray = document.array();
245
246 // processing examples
247 for (int i = 0; i < exampleArray.size(); ++i) {
248 const QJsonObject currentExample = exampleArray[i].toObject();
249
250 const QString exampleName = currentExample.value("name").toString();
251 if (m_projectNameList.contains(exampleName)) {
252 qDebug() << "There is already an example file with this name";
253 } else {
254 m_projectNameList.append(exampleName);
255 const QString exampleFile = currentExample.value("fileName").toString();
256 m_pathMap[exampleName] = exampleFile;
257
258 // processing tags
259 const QJsonArray tags = currentExample.value("tags").toArray();
260 for (int j = 0; j < tags.size(); ++j) {
261 QString tagName = tags[j].toString();
262 m_tagMap[tagName].append(exampleName);
263 m_datasetTag[exampleName].append(tagName);
264 }
265 }
266 }
267
268 file.close();
269 } else {
270 qDebug("Couldn't open dataset category file");
271 }
272}
273
274/**
275 * @brief Returns in string format the thumbnail for the given example file

Callers

nothing calls this directly

Calls 7

appendMethod · 0.80
openMethod · 0.45
sizeMethod · 0.45
toStringMethod · 0.45
valueMethod · 0.45
containsMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected