12-10-2012 02:33 PM
Hello everyone,
I have here a small problem. I started building a small app with the Grid List Template in Momentics IDE. It has a grid list and when you click on a grid item, a second page gets opened. Here you can edit the data of the grid item.
This change has to be saved in the json-file back, but I am having some troubles at this point:
#include "Plan.h"
#include <qdebug.h>
#include <bb/cascades/GroupDataModel>
#include <bb/data/JsonDataAccess>
Plan::Plan() {}
void Plan::savePlan(QString id, QString tag, QString newFach, QString newRaum) {
bb::data::JsonDataAccess jda;
QVariantList lst = jda.load("app/native/assets/mydata.json").toList() ;
if (jda.hasError()) {
//bb::data::DataAccessError error = jda.error();
//qDebug() << "JSON2 loading error: " << error.errorType() << ": " << error.errorMessage();
} else {
qDebug() << "JSON2 data loaded OK!";
GroupDataModel *m = new GroupDataModel();
// insert the JSON data to model
m->insertList(lst);
// make the model flat
m->setGrouping(ItemGrouping::None);
QVariantMap newEntry;
newEntry["id"] = id;
newEntry["tag"] = tag;
newEntry["fach"] = newFach;
newEntry["raum"] = newRaum;
m->updateItem(1, newEntry);
QVariant newData = QVariant(QVariantList() << QVariant(m->data(0)) << QVariant(m->data(1)) << QVariant(m->data(2)) << QVariant(m->data(3)));
QDir home = QDir::home();
QTemporaryFile file(home.absoluteFilePath("app/native/assets/myda ta.json"));
// Open the file that was created
if (file.open()) {
// Create a JsonDataAccess object and save the data to the file
//JsonDataAccess jda;
jda.save(newData, &file);
}
}
}The basic problem is that this code does not get compiled
It gives me the following error:
../src/Plan.cpp:16:6: error: 'GroupDataModel' was not declared in this scope ../src/Plan.cpp:16:6: note: suggested alternative: C:/bbndk/target_10_0_9_1101/qnx6/usr/include/bb/cascades/databinding/groupdatamodel.h:241:29: note: 'bb::cascades::GroupDataModel' ../src/Plan.cpp:16:22: error: 'm' was not declared in this scope ../src/Plan.cpp:16:30: error: expected type-specifier before 'GroupDataModel' ../src/Plan.cpp:16:30: error: expected ';' before 'GroupDataModel' ../src/Plan.cpp:20:21: error: 'ItemGrouping' has not been declared
But I really do not know anymore, what this means. If it may help: Since Beta 4 update (+ complete reinstall of SDK) I have problems with using Qt at all in the IDE, as I'm getting for example "Unresolved inclusion: <"qdebug.h">.
EDIT: I could solve this problem with adding "bb::cascades::" before like in the suggested alternative. But I am still not sure if this is the right way to load and save data in Cascades.
Best Regards,
Sebastian
01-24-2013 02:43 AM
I think this is a namespace problem. In one of your header files or at the top of this file, you need:
using namepsace bb:cascades;
I hope that helps,
Nick