[Development] QSettings refactor updates

Tomaz Canabrava tcanabrava at kde.org
Fri Oct 10 00:53:44 CEST 2014


On Thu, Oct 9, 2014 at 7:48 PM, Thiago Macieira <thiago.macieira at intel.com>
wrote:

> On Thursday 09 October 2014 19:43:08 Tomaz Canabrava wrote:
> > Please be kind, this is the first step to contributing to qt that I'm
> > trying. :)
> >
> > First, I'v implemented the rationale that thiago asked me to do on the
> > other thread:
> >
> > Settings format: .ini ( current settings uses native format, should I
> > implement that too or the reasoning here is 'be simple'? )
>
> I think we should stick to .ini only. Access to the Windows registry
> should be
> done via QSettings or via a dedicated class.
>
> Mac people: do we need access to plist files?
>
> > Usage on code:
> >
> > Open a QConfig, get the root() group, fill some values,
> > if a value is changed a 'dirty' flag will be set on that particular
> group.
> > upon destruction it will generate a binary json representation to be kept
> > in memory
> > when .sync() it will forcefully sync on disk
> > when the QConfigCore object is destroyed, it will also flush on disk.
> >
> > Working code example of usage:
> >
> > int main(int argc, char *argv[])
> > {
> >     QConfig config;
> >
> >     QConfigGroup& root = config.root();
>
> Make sure a reference is not needed.
>

I can change the reference to a pointer - but the way I tougth of it
working, a reference or a pointer is needed: ( I may be wrong, of course );

QConfig config;
QConfigGroup *myGroup = config.root()->group("main")->group("secondary");
myGroup->setValue("testValue", 1);

should set the config.root() to dirty so I know that I need to update
something on the json.


> >
> >     QConfigGroup& window = root.group("window");
> >     window.setValue("width", 800);
> >     window.setValue("height", 600);
> >     window.setValue("x", 100);
> >     window.setValue("y",100);
> >     window.setValue("opacity", 55);
> >
> >     QConfigGroup& font = root.group("fonts");
> >     font.setValue("family", "san-serif");
> >     font.setValue("pointSize", 9);
> >     font.setValue("bold", true);
> >     font.setValue("italic", true);
> >
> >     QConfigGroup& plasmoids = root.group("plasmoids");
> >     for(int i = 0; i < 5; i++){
> >         QConfigGroup& plasmoid = plasmoids.group(QString::number(i));
> >         plasmoid.setValue("name", "name_" + QString::number(i));
> >         plasmoid.setValue("width", rand() % 100 + 100);
> >         plasmoid.setValue("value", rand() % 100 + 100);
> >     }
> > }
> >
> > Any tougths?
>
> Looks good!
>

I'll organize the code and the repository with meaningfull commits so you
guys can take a look and point me to the right direction.


>
> --
> Thiago Macieira - thiago.macieira (AT) intel.com
>   Software Architect - Intel Open Source Technology Center
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20141009/60f8813e/attachment.html>


More information about the Development mailing list