[Digikam-devel] state saving and restoring for GUI elements

Johannes Wienke languitar at semipol.de
Fri Dec 11 16:49:21 GMT 2009


Am 11.12.2009 17:40 schrieb Marcel Wiesweg:
>> So, any more thoughts on how to do this the best way?
> 
> I have the feeling that it's good to give KConfigGroups and do it outside of 
> the constructor/destructor, though the latter will create a bit of extra work.

Ok.

> A common base class can be difficult because there may be widgets not 
> inheriting from QWidget but a specialized subclass, and then you can't use 
> this code. Not sure about this. Is there really so much code to share for 
> generic QWidgets? Maybe it's easier to collect utility code in common place 
> for reuse. You will see that better when starting to work on it.

My idea was mainly about having a unique interface for all classes that 
allow state saving. We could use a base class as mixin via multiple 
inheritance:

class MySavingGuiObject: public QWidget, public StateSavingObject
{...}

class StateSavingObject
{
public:
     StateSavingObject();
     StateSavingObject(KConfigGroup &configGroup);
     virtual void restoreState() = 0;
     virtual void saveState() = 0;
     void setConfigGroup(KConfigGroup &newGroup);
protected:
     virtual KConfigGroup getConfigGroup() const;
}

Something like this. StateSavingObject could then also handle some 
default group handling code if necessary, eg. using a config group 
determined by the object name or what ever...

Johannes

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
URL: <http://mail.kde.org/pipermail/digikam-devel/attachments/20091211/6ef82dc4/attachment.sig>


More information about the Digikam-devel mailing list