Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool KhipuData::saveData(QList<KhipuSpace*> spaceList, QString fileName)
- {
- fileName = fileName + ".json";
- QFile file(fileName);
- if (!file.open(QIODevice::WriteOnly)) {
- qDebug() << "Não deu pra salvar o arquivo";
- return false;
- }
- QJsonObject spaces;
- for (int i = 0; i < spaceList.size(); i++){
- QJsonObject space;
- space["name"] = spaceList[i]->name();
- space["id"] = spaceList[i]->id();
- space["type"] = spaceList[i]->type();
- qDebug() << spaceList[i]->model()->rowCount();
- QJsonObject plots;
- QModelIndex model;
- auto *plotsModel = spaceList[i]->model();
- for (int j = 0; j < spaceList[i]->model()->rowCount(); j++){
- QJsonObject plot;
- auto plotIndex = plotsModel->index(j, 0);
- auto data = plotsModel->data(plotIndex, Analitza::PlotsModel::DescriptionRole);
- plot["expression"] = data.toString();
- //qDebug() << spaceList[i]->plots().at(j)->strExpression();*/
- plots.insert(QString::number(j),plot);
- }
- space["plots"] = plots;
- spaces.insert(QString::number(i),space);
- }
- QJsonDocument doc(spaces);
- file.write(doc.toJson());
- file.close();
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement