From 39ea1eb759075af3bad3654f1a42025919510a4e Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Wed, 5 Oct 2022 09:41:38 -0500 Subject: [PATCH] basic saving of servicelist as json file --- src/filemanager.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/filemanager.cpp b/src/filemanager.cpp index 5e8f22a..b10b307 100644 --- a/src/filemanager.cpp +++ b/src/filemanager.cpp @@ -1,6 +1,10 @@ #include "filemanager.h" #include #include +#include +#include +#include +#include File::File(QObject *parent) : QObject{parent} @@ -48,5 +52,20 @@ bool File::save(QUrl file, QVariantList serviceList) { qDebug() << "File path is: " << file; qDebug() << "serviceList is: " << serviceList; qDebug() << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"; + QJsonArray jsonData = QJsonArray::fromVariantList(serviceList); + qDebug() << jsonData; + + QJsonDocument jsonText(jsonData); + + QDir dir; + dir.mkpath("/tmp/presenter"); + QFile jsonFile("/tmp/presenter/json"); + if (!jsonFile.exists()) + qDebug() << "NOT EXISTS!"; + if (!jsonFile.open(QIODevice::WriteOnly | QIODevice::Text)) + return false; + + jsonFile.write(jsonText.toJson()); + return true; }