KTextEditor
KTextEditor::MdiContainer Class Reference
#include <containerinterface.h>
Detailed Description
A container for MDI-capable kpart hosts.The kpart container for the KTextEditor interface may have different capabilities. For example, inside KDevelop or Kate, the container can manage multiple views and multiple documents. However, if the kpart text is used inside konqueror as a replacement of the text entry in html forms, the container will only support one view with one document.
This class allows the kpart component to create and delete views, create and delete documents, fetch and set the current view. Note that the ktexteditor framework already supports multiple document and views and that the kpart host can create them and delete them as it wishes. What this class provides is the ability for the kpart component being hosted to do the same.
An instance of this extension should be set with ContainerInterface::setContainerExtension().Check ContainerInterface() to see how to obtain an instance of ContainerInterface. The instance should inherit QObject, inherit MdiContainer, declare the Q_OBJECT macro and declare a Q_INTERFACES(KTextEditor::MdiContainer) .
Code example to support MdiContainer (in the kpart host):
class MyMdiContainer : public QObject, public MdiContainer { Q_OBJECT Q_INTERFACES( KTextEditor::MdiContainer ) public: // ... }
To check if the kpart hosts supports the MDI container:
Editor * editor = KTextEditor::EditorChooser::editor(); ContainerInterface * iface = qobject_cast<ContainerInterface *>( editor ); if (iface) { MdiContainer * mdiContainer = qobject_cast<MdiContainer *>( iface->container() ); if (MdiContainer != NULL ) { // great, I can create addtional views // ... } }
Definition at line 164 of file containerinterface.h.
Public Member Functions | |
| MdiContainer () | |
| virtual | ~MdiContainer () |
| virtual void | setActiveView (View *view)=0 |
| virtual View * | activeView ()=0 |
| virtual Document * | createDocument ()=0 |
| virtual bool | closeDocument (Document *doc)=0 |
| virtual View * | createView (Document *doc)=0 |
| virtual bool | closeView (View *view)=0 |
Constructor & Destructor Documentation
| MdiContainer::MdiContainer | ( | ) |
| MdiContainer::~MdiContainer | ( | ) | [virtual] |
Member Function Documentation
| virtual void KTextEditor::MdiContainer::setActiveView | ( | View * | view | ) | [pure virtual] |
| virtual View* KTextEditor::MdiContainer::activeView | ( | ) | [pure virtual] |
| virtual Document* KTextEditor::MdiContainer::createDocument | ( | ) | [pure virtual] |
Create a new Document and return it to the kpart.
Canonical implementation is:
Document * createDocument() { Document * doc; // set parentQObject to relevant value doc = editor->createDocument( parentQObject ); // integrate the new document in the document list of the // container, ... return doc; }
The signal documentCreated() will be emitted during the creation.
- Returns:
- a pointer to the new Document object.
Closes of document doc .
The document is about to be closed but is still valid when this call is made. The Document does not contain any view when this call is made (closeView() has been called on all the views of the document previously).
The signal aboutToClose() is emitted before this method is called.
- Returns:
- true if the removal is authorized and acted, or false if removing documents by the kpart is not supported by the container.
Creates a new View and return it to the kpart.
Canonical implementation is:
View * createView( Document * doc ) { // set parentWidget to relevant value return doc->createView( parentWidget ); }
The signal viewCreated() will be emitted during the createView() call.
- Returns:
- a pointer to the new View created.
Closes the View view .
The view is still valid when this call is made but will be deleted shortly after.
- Returns:
- true if the removal is authorized and acted, or false if the container does not support view removing from the kpart, or
The documentation for this class was generated from the following files:
KDE 4.0 API Reference