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

List:       koffice-devel
Subject:    Re: Specific API questions
From:       Thomas Zander <zander () kde ! org>
Date:       2010-01-23 11:58:47
Message-ID: 201001231258.48260.zander () kde ! org
[Download RAW message or body]

On Saturday 23. January 2010 04.53.25 Dr. Robert Marmorstein wrote:
> On Thursday 21 January 2010 09:50:36 Dmitry Kazakov wrote:
> > Hi, All!
> >
> > Where these questions answered? They were asked 10 days ago, but still
> > don't have the answer.
> > If i knew KoLibs, i would answer them...
> 
> Nope.  No one responded.  

:-(

> I've been trying to figure them out all on my
>  own, but I think I'm going about this the wrong way.  So far I haven't
>  been able to find any way to do these things from a docker.
> 
> I tried using the KoCanvasBase and KoCanvasObserver to get a
>  shapeController object and then using the dataCenterMap in the
>  shapeController to get a KoInlineTextManager (from which I could get to
>  the variable manager).

Note that I just committed a change that the dataCenterMap is removed and 
replaced by a resourceManager (formerly KoCanvasResourceProvider)
 
> But:
> 
> A.  The canvas pointer is always NULL when the user clicks the button (i.e.
> setCanvas is never called).  (Do I have to use "connect" to connect it to
> something?)

When the canvasController gets focus it is supposed to iterate over all the 
dockers added to the mainwindow and dynamic cast it to a 
KoCanvasObserver(Base), if it works then it will call setCanvas on it.

See the code in the KoCanvasController line 166

> Questions from the Old Post:
> 
> 1.  My docker currently attaches ALL opened documents which have been
> saved to disk and have valid filenames.  It would be really nice to be able
>  to only attach the "current" document.  Is there a way to get that
>  "current" document? (I need a KoDocument pointer).

Yes, this is useful; added API for this on the KoResourceManager in commit 
r1079019
Note that a KoDocument inherits from a KoOdfDocument, so if the latter is not 
enough you can just cast.
 
> 2.  I would like to extend this so that the configuration elements
> (title, start date, and so forth) are saved as NamedVariables and can be
> used in the document (and so that they can be saved with the document and
> don't have to be typed in every time).  However, I can't figure out how to
>  do this.  What class do I need to use for creating these?

For an example see  KWDocument::firePageSetupChanged
where the page number is updated.
I guess that somewhere in the libs/main/ there is code that alters the 
properties and it should use a similar mechanism to put those properties in 
the inlineTextObjectManager() (if it exists)

> 3.  Is there a way to get a "KoView" or "KoMainWindow" pointer from the
> docker?  This would enable me to call "save" or "saveAs" before
> publishing so
> that the document exists on the disk.  I think it would probably also
> help with question 2...

You likely want to get the KAction for that, which indeed requires a KoView 
instance.
Not sure what the proper solution is, but you should use 
 KoCanvasBase::canvasWidget()
and then repeatedly call parentWidget() on that to get to the top.
One of those in the stack will likely correctly
  qobject_cast<KoView*>(widget);
so you can use that.
 
> I have tried lots of things to make these work unsuccessfully.  My gut
> feeling is that there is some API missing for these to be possible.  A
>  single static function that returns a pointer to the parent KoView of the
>  docker might solve most of these. (Does that even make sense?  Does a
>  docker have a parent KoView? Maybe I want a "parent KoMainWindow"?)

Hope my additions help.
Apologies for the heavy refactoring in trunk that will likely mean you need to 
change some of your code to compile again. The class renames I did yesterday 
(KoDockFactory -> KoDockFactoryBase etc) come to mind.
-- 
Thomas Zander
_______________________________________________
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