Get help

Embedded Components Tutorial - Page 5

Making the Component Functional

The Plan

You're on the home stretch now. You have a fully working embedded
component -- you just need to make it do something!

This step is one of the shortest ones in this tutorial but will likely
be the hardest in real use. This is where you need to connect your
applications functionality to the KParts interface.

In the case of aKtion, nearly all of the actual "playing" code is
encapsulated in the KXAnim class. This made it very easy to use in a
KParts interface. All that was needed was to replace the QLabel
example with KXAnim and everything worked (mostly).

And this actually plays the file. Some hackery needed to be done to
get it to play due to some timing problems with KXAnim.
And that's pretty much it!

Visible Result

Practical Matters

As said earlier, this is one of the shorted and simplest steps in this
example.. but could easily be the hardest in your own application. It
all depends on how much functionality is encapsulated in your "main"
view object.

The key to this step is to have one view object already in your
application in which all processing of the file takes place. If you
have several classes that all depend on each other with no central
"viewing" object, then you will have problems.

As a case study, KGhostView was one of the hardest programs to port to
the KParts system. The reason for this was that all of the UI
elements were scattered all over the application. There was no one
coherent interface to the UI aspects -- essentially no way for a third
party app to "view" the same thing that KGhostView was.

The solution to this was to create a view class that combined most of
the required UI elements in one place. After this was done, it was
trivial to plug this view into the KParts system.

Things To Remember:
The ease of integrating your application into the KParts
architecture depends almost entirely on how encapsulated your UI
elements are into one coherent interface. The less coherent, the more
problems you will have.