Ownership of a widget.

Inge Wallin, Lysator inge at lysator.liu.se
Sat Feb 9 17:02:50 GMT 2013


Most of you probably know the statistics docker in Words and Author. It keeps 
track of the number of words/characters/... in the document. 

Architecturally, the docker owns a QWidget which it also embeds inside itself. 
The widget has a configuration widget, which is activated (opened) through a 
menu button. By using the configuration widget the user can define which values 
should be displayed in the widget and therefore also the docker. The widget 
can also adapt itself to the position of the docker by using a vertical or 
horizontal layout. This is controlled by calling into the widget from the 
docker when it changes position.

Now, one goal for Calligra 2.7 is that the user should be able to show the 
statistics in the status bar. In principle this is simple. There is a call in 
KoView to embed a QWidget in the status bar so that part is trivial. However, 
suddenly the ownership of the widget gets interesting.

I have put the option to be in the docker or the statusbar in the configuration 
dialog in the widget. This means that the docker may suddenly get the 
information from the widget that "I don't want to be yours anymore. Now I 
belong to the statusbar." and vice versa. In this case the docker should close 
itself and when the widget wants to be back in the docker it should reopen 
itself when unless the docker is disabled in the Settings menu.

But who should own the widget? Can the docker continue to own the widget even 
though it physically resides inside the statusbar? somebody must control the 
widget when it moves from one location to the other and I don't think it's 
obvious who that somebody is. 

Does anybody have an idea?  I can give more details but my train leaves now so 
I need to go now.

	-Inge




More information about the calligra-devel mailing list