[Development] QSettings refactor updates
Koehne Kai
Kai.Koehne at theqtcompany.com
Fri Oct 10 08:48:55 CEST 2014
> -----Original Message-----
> From: development-bounces+kai.koehne=theqtcompany.com at qt-
> project.org [mailto:development-
> bounces+kai.koehne=theqtcompany.com at qt-project.org] On Behalf Of
> Tomaz Canabrava
> Sent: Friday, October 10, 2014 12:54 AM
> To: Thiago Macieira
> Cc: development at qt-project.org
> Subject: Re: [Development] QSettings refactor updates
>
>
>
> 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.
Well, QConfigGroup might be just the handle. Something like:
class QConfigGroup {
protected:
QConfigGroup(QConfig *config) : m_config(config) {}
public:
bool setValue(const QString &str, const QVariant &value) { m_config->setValue(str, value); }
private:
QConfig *m_config;
}
> [...]
> 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.
First of all, thumbs up for the effort :) If I may suggest something though: In addition to uploading the code, you might consider collecting the requirements and design rationales at a central point (e.g. in the wiki, or on bugreports). This might help to set the expectations & goals straight even before we discuss the details to death ;)
Regards
Kai
More information about the Development
mailing list