Questions about TosContainer

Thorsten Zachmann t.zachmann at zagge.de
Thu Sep 1 07:18:19 BST 2011


Hello Yue,
> 
> Here is the patch. What I want to do is change defaultTool's
> double-click event so that when a pathshape without textbox is double
> clicked, a textShape is created for that pathshape and the appropriate
> tool is activated to let user edit the textbox.
> 
Move the discussion to the mailing list.

The adding of a text shape should be done in a command so that it can be 
undone again. The comand should be in flake where it can also be accessed from 
other parts.


+    foreach(KoShape *shape, shapes) {
+        if (shape->shapeId() == KoPathShapeId) {
+            KoTosContainer *container = dynamic_cast<KoTosContainer*>(shape)

Instead of the if  you should cast to a KoTosContainer and check if the result 
is a a container or not. With that it will work for all shapes that support 
tos.

+            if (!container->textShape()) {
+                KoShape *textShape = container->createTextShape(canvas()-
>resourceManager());

You need to pass the document resource manager and not the canvas resource 
manager here.

Also we need to make sure that double click does not create a tos in all 
applications e.g. in karbon as that is not what is wanted there. There double 
click should still activate the path shape.

If there are more open points feel free to ask.

Thorsten



More information about the calligra-devel mailing list