-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'faketrello' example feature req -- persist model to file, Board::load() recreates model #2
Comments
In fact, It is not difficult. You just need a JSON parsing code to load as QVariantMap/ QVariantList then convert to your own data structure. Example code of JSON parsing (QVariantMap)
stringify
|
Thanks for the hint! I added to appdelegatge.cpp:
And then call in main.qml:
Which, on application close, outputs the initial board layout from both the model and the board (which are the same).
TODO: onClosing, save to a file in ~/.local/share/ and on initialization read JSON from that file to recreate model. QUESTION: In AppDelegate::stringifyModel() is there a simpler way of getting the toplevel model from cardListStore as a QVariantMap or do I need to create a toplevel map of "lists" , and then convert that to JSON (as done in code example above). Probably makes sense to add such code to QSListsModel, to provide a QVariantMap version of the model, rather than do it in appdelegate.cpp ... |
See #3 for an implementation of this feature. |
In faketrello example, Board::load() currently loads board statically from code. It would be a more complete example app if it showed "end to end" usage of the model, from initial creation, modification, and persistence on application close.
What's the simplest implementation of a "print method" for the model so that it can be persisted to a file? For example a method to output the current model as JSON?
How could Board::load() read such a file, and then reconstruct the model from the JSON-persisted file?
The text was updated successfully, but these errors were encountered: