Notices


Reply
Thread Tools
Markkyboy's Avatar
Posts: 234 | Thanked: 275 times | Joined on Oct 2012 @ Planet Thanet
#1
Hey all,

I have a Page in my app, the page is a search page. I have included an editable 'TextArea', basically an area at the bottom of the screen where the user can add notes on planning his/her journey.

Ultimately, saving the notes to Documents is the aim, but for now, is it possible to preserve the text input even if the app is closed?, or even if the user navigates the rest of the app, comes back to search page and notes are preserved..?

I've tried taking samples from jolla-notes and tinyedit but have achieved nothing so far or have found convoluted methods on StackExchange that don't work with Sailfish......I'm stuck!, any help appreciated.

Regards,
__________________
moderator@openrepos
___________________

T.J.C.

Omelettes - You can't make one without breaking an egg.
 
Posts: 1,387 | Thanked: 6,342 times | Joined on Apr 2010 @ Czech Republic
#2
Looks like QtQuick LocalStorage might work for you to persistently store user data.

Alternatively you can also use PyOtherSide to use Python to store your files to a file on the local filesystem:

PyOtherSide @ Sailfish OS docs
General PyOtherSide docs

The "notes" PyOtherSide example in particular seems to be pretty close to what you are trying to achieve - storing some string from an application persistently to a file and the loading them from the file again:

notes_example.qml
notes_example.py
__________________
modRana: a flexible GPS navigation system
Mieru: a flexible manga and comic book reader

Thanks to everyone who voted for modRana & Mieru in the Maemo.org coding competition !
 

The Following 3 Users Say Thank You to MartinK For This Useful Post:
Posts: 303 | Thanked: 1,346 times | Joined on Aug 2016 @ Estonia
#3
As MartinK explained, you can use PyOtherSide to do the magic. If you prefer to do so in C++, you could save the notes together with the other app settings using QSettings. Since you can convert between JSON and strings at your will, any complicated structure can be saved / restored from settings.

For QSettings, you probably would have to write a small wrapper that would allow to call it from QML (Q_INVOKABLE methods).

But if you use Python, its better to go with MartinK solution. Seems to be simple enough and flexible as well - you'll be able to save the notes later where you want them to be saved.
 

The Following 2 Users Say Thank You to rinigus For This Useful Post:
Markkyboy's Avatar
Posts: 234 | Thanked: 275 times | Joined on Oct 2012 @ Planet Thanet
#4
Thanks guys (rinigus & MartinK),

I will have a go with QtQuick LocalStorage to start with, thanks

Regards,
__________________
moderator@openrepos
___________________

T.J.C.

Omelettes - You can't make one without breaking an egg.
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 04:51.