CopperSpice API
1.9.2
|
Plugins are used to extend the functionality provided by a given CopperSpice library or application.
CopperSpice will not find plugins unless they are located in the correct relative path. For example, all SQL drivers must be located in a sub-directory called sqldrivers. Typically this sub-directory will be relative to the application executable. However, the exact path for the sqldrivers directory can be modified using cs.conf or using QApplication::addLibraryPath().
Refer to Plugin Path Configuration for more information.
There are two APIs for creating plugins:
Writing a plugin that extends CopperSpice is achieved by subclassing the appropriate plugin base class, reimplementing a few methods and then exporting the class with the CS_PLUGIN_REGISTER() macro.
For a list of the interfaces and plugin base classes refer to List of Plugins.
To add a new style plugin called MyStyle, refer to the following example.
The QStylePlugin is case insensitive so the call to toLower() is required in the implementation of the create() method. Most of the other plugins are case sensitive.
For database drivers, image formats, text codecs, and other plugin types, no explicit object creation is required. Styles are an exception, since you might want to set a style explicitly in code. To apply a style, use the following type of code.
Some plugin classes require additional methods to be implemented. Refer to the class documentation for details of the virtual methods which must be reimplemented for each type of plugin.
Making an application extensible through plugins involves the following steps:
Writing a plugin involves these steps: