class KTextEditor.Plugin |
|
|
KTextEditor Plugin interface. Topics: - plugin_intro - plugin_config - plugin_sessions - plugin_arch Introduction The Plugin class provides methods to create loadable plugins for all KTextEditor implementations. A plugin can handle several documents and views. For every document the plugin should handle addDocument() is called and for every view addView(). Configuration Management If your plugin supports a config dialog overwrite configDialogSupported() and return true (The default implementation returns false and indicates that the plugin does not support a config dialog). The config dialog can be shown by calling configDialog(), it can also be called from a KTextEditor implementation (e.g. the KTextEditor implementation might have a listview that shows all available plugins along with a Configure... button). To save or load plugin settings writeConfig() and readConfig() is called by the Editor part. Usually you do not have to call readConfig() and writeConfig() yourself. Session Management As an extension a Plugin can implement the SessionConfigInterface. This interface provides functions to read and write session related settings. If you have session dependant data additionally derive your Plugin from this interface and implement the session related functions, for example: class MyPlugin : public KTextEditor.Plugin, public KTextEditor.SessionConfigInterface { Q_OBJECT Q_INTERFACES(KTextEditor.SessionConfigInterface) Plugin Architecture After the plugin is loaded the editor implementation should first call readConfig() with a given KConfig object. After this it will call addDocument() and addView() for all documents and views the plugin should handle. If your plugin has a GUI it is common to add an extra class, like: class PluginView : public QObject, public KXMLGUIClient { Q_OBJECT public: // Constructor and other methods PluginView( KTextEditor.View* view ) : QObject( view ), KXMLGUIClient( view ), m_view( view ) { ... } // ... private: KTextEditor.View* m_view; };Your KTextEditor.Plugin derived class then will create a new PluginView for every View, i.e. for every call of addView(). The method removeView() will be called whenever a View is removed/closed. If you have a PluginView for every view this is the place to remove it.
See also KTextEditor.Editor, KTextEditor.Document, KTextEditor.View,
KTextEditor.SessionConfigInterface
Author Christoph Cullmann \ |
|
Constructor. Create a new plugin. parent - parent object |
|
Add a new document to the plugin. This method is called whenever the plugin should handle another document. For every call of addDocument() will finally follow a call of removeDocument(), i.e. the number of calls are identic.
document - new document to handle See also removeDocument(), addView() |
|
This method is called whenever the plugin should add its GUI to view. The process for the Editor can be roughly described as follows: - add documents the plugin should handle via addDocument() - for every document doc call addView() for every view for doc. For every call of addView() will finally follow a call of removeView(), i.e. the number of calls are identic. As addView() is called for every view in which the plugin's GUI should be visible you must not add the the GUI by iterating over all Document.views() yourself neither use the signal Document.viewCreated().
view - view to hang the gui in See also removeView(), addDocument() |
|
Show the config dialog for the plugin. Changes should be applied to the plugin, but not saved to the disk immediately. writeConfig() is called by the Editor implementation to save the plugin's settings, e.g. when a plugin is unloaded.
parent - parent widget See also configDialogSupported() |
|
Check, whether the plugin has support for a config dialog. Returns true, if the plugin has a config dialog, otherwise false See also configDialog() |
|
Read the editor configuration from the KConfig config. If config is 0 you can KApplication.kApplication ()->config() as fallback solution. readConfig() is called from the Editor implementation, so you never have to call it yourself.
config - config object See also writeConfig() |
|
Remove the document from the plugin. This method is called whenever the plugin should stop handling the document. For every call of addDocument() will finally follow a call of removeDocument(), i.e. the number of calls are identic.
document - document to hang the gui out from See also addDocument(), removeView() |
|
This method is called whenever the plugin should remove its GUI from view. For every call of addView() will finally follow a call of removeView(), i.e. the number of calls are identic.
view - view to hang the gui out from See also addView(), removeDocument() |
|
Write the editor configuration to the KConfig config. If config is 0 you can KApplication.kApplication ()->config() as fallback solution. writeConfig() is called from the Editor implementation, so you never have to call it yourself.
config - config object See also readConfig() |