Serialising an array

Hi all,

I have an app with 8 buttons for controlling lights and plugs. Of the 8 items, 2 are plugs. I would like to rename the plug when required and the new name to stick.

Example: PLUG1 is statically named ‘FAN’, but the ‘FAN’ broke and now I have my ‘BIKE’ charger plugged into it, so I would like to rename the button to ‘BIKE’ ~ I have already worked out how to change the name using TextField, but when the app is closed and opened again, the plug name has defaulted back to ‘FAN’ (clearly this is expected, the app does not know about the renaming of the indexed button).

I was shown how to serialise/deserialise data using QtCreator for Windows for a desktop application, but the same code does not apply/or work with SailfishOS. I cannot seem to adapt it, at all.

I know I have to use ConfigurationGroup (or possibly ConfigurationValue), which is fine for a single Item, this I know how to do, but not for multiple items in an Array.

So, my question is this; how do I serialise/deserialise my button names with SFOS.

My item ARRAY;

    Item {
        id: tasmota
        property var switchName:  ["POWER", "FAN", "DESK", "BED", "PATIO", "OFFICE", "KITCHEN", "CLOSET"]
    }
}

For SeaPrint i just use JSON.stringify(MyStuff) on job settings when i save them as defaults into a database.
That’s for an object, but arrays should work just fine too. It could also be that you should rethink how you model your stuff if the data is too hard to work with, but i don’t have enough insight to tell.

ConfigurationValue can be used to store an array. This is from a patch:

 ConfigurationValue {
         id: showLocationName
         key: "/apps/patchmanager/show-event-location/name"
         defaultValue: ["maps.google.com", "copy to clipboard"]
     }

To modify a single item in the array, a new array must be created and then showLocationName.value = array. So, a single item in configurationValue.value can’t be changed, the whole array must be reset.

I don’t remember using ConfigurationGroup, but I remember reading that the values in a ConfigurationGroup can’t be arrays. But, using confGroup.setKey(“length”, N) - if N is not a constant - and confGroup.setKey(“plugName1”, some text), …, confGroup.setKey(“plugNameN”, some text) should work as a kind of array.