[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: Question about KoShape::notifyChanged();
From:       Thomas Zander <zander () kde ! org>
Date:       2009-05-23 19:34:47
Message-ID: 200905232134.47955.zander () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


On Saturday 23. May 2009 20.04.19 Cyrille Berger wrote:
> I was wondering how a shape is supposed to warn the UI about a change of
> parameter in a shape. Lets take the example of the web shape (I wrote in
> braindump), it has a URL parameter that can be changed through the "shape
> properties" docker, I was wondering what is the best way to say a
> parameter was changed ? I see there is KoShape::update to trigger a
> repaint, and there is KoShape::notifyChanged(), but the API for this say
> it's for position notification.

The API is indeed for position notification. The design is there to allow a 
shapeCollection to be notified of child shapes changing something and doing 
something.
Usecase example is to have a KoShapeContainer that is a multi-column text. 
So it creates text shapes based on the content amount and the size of the 
shapeContainer. If the text amount changes, the normal behavior is to make 
the frame longer. This container can detect that and properly resize the 
shapes to make them balanced again.

> So my question now is wether the API dox is wrong on notifyChanged() ? Is
> there an other solution ? Or is there something missing ?

The design is that shapes are supid objects. So I'd indeed think that 
changing the URL in your case is something that would ideally not be solved 
in libFlake itself.
The reason for that is that its quite easy to fall into the trap to make a 
shape a QObject and make it emit signals on property changes.  This would 
unfortunately not scale very well (making connections is slow, QObject is 
expensive).

So, I'd suggest you do something in your plugin; naturally you can just add 
the observer/listener pattern to your own shape.
Your docker (via the tool perhaps) should then be shipped in the same plugin 
so it can use the private API of your shape. This can then listen to the 
signal from the shape(s) as it changes.

> I also wonder what is the best solution to monitor a bunch of shapes ?
> Create a shapemanager, add them to the shape manager and then monitor
> selectionContentChanged() ?

Well, sure, you can do that :)
Are the shapes you want to watch not all in the selection?
And if they are not, then why would you want to monitor them? I'm trying to 
understand the usecase to see how this fits best. Or if its a good example of 
how we should indeed extend Flake ;)

ps. after writing this mail I'll turn off the laptop and then I'll be offline 
for 3 days.  Trekking through the woods.
-- 
Thomas Zander

["signature.asc" (application/pgp-signature)]

_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic