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

Johannes Wienke languitar at semipol.de
Fri Dec 11 16:06:59 GMT 2009


Hi,

for the model view port branch most of the old functionality for saving 
and restoring is currently not re-implement or called and that's one of 
the tasks that I want to do next. For this purpose I stumbled across 
several different approaches how to save and restore the GUI states. 
Some classes do this in constructors and destructors, others have 
separate methods that need to be called externally. Sometimes these 
methods require a KConfig or KConfigGroup object and / or a prefix to 
prepend at the entry names, sometimes the object name is used, and so on...

I think this should be unified in some way but I'm not quiet sure how to 
do this the best way. Here are some thoughts I had about the problem.

1. We should always consider that one class can be used several times in 
the application. So always writing to the same config entries will 
result in some kind of race condition on which saving / restoring 
results will be used.

2. Always using the same config group for one class may not be desirable 
for the same reason as above. If I use a tree view for the left sidebar 
I want its state to be stored in the config group for the sidebar. If I 
use the same class in the settings for the advanced search, I want the 
state to be stored in a config group for these settings. So passing in 
the config group to use sounds reasonable.

3. Should state be always stored or only sometimes? In the first case 
using constructors / destructors sounds reasonable, else special methods 
should be used.

4. I think it would be a good idea to have a special interface (abstract 
base class) for all GUI clases, that provide mechanisms to save or 
restore state. Automatically using the constructor or destructor of this 
base class for saving / restoring will not work because of the 
restriction not to call virtual functions in these methods...

So, any more thoughts on how to do this the best way?

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/4302de9d/attachment.sig>


More information about the Digikam-devel mailing list