|
Canorus
0.7
|
#include <pluginmanager.h>

Public Member Functions | |
| CAPluginManager (CAMainWin *mainWin, CAPlugin *plugin) | |
| ~CAPluginManager () | |
| bool | startElement (const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &attributes) |
| bool | endElement (const QString &namespaceURI, const QString &localName, const QString &qName) |
| bool | fatalError (const QXmlParseException &exception) |
| bool | characters (const QString &ch) |
Static Public Member Functions | |
| static void | readPlugins () |
| static bool | enablePlugin (CAPlugin *plugin, CAMainWin *mainWin) |
| static bool | enablePlugins (CAMainWin *mainWin) |
| static bool | disablePlugin (CAPlugin *plugin) |
| static bool | disablePlugins () |
| static void | action (QString onAction, CADocument *document, QEvent *evt, QPoint *coords, CAMainWin *mainWin) |
| static bool | exportFilterExists (const QString filter) |
| static void | exportAction (QString filter, CADocument *document, QString filename) |
| static bool | importFilterExists (const QString filter) |
| static void | importAction (QString filter, CADocument *document, QString filename) |
| static bool | installPlugin (QString path) |
| static bool | removePlugin (CAPlugin *plugin) |
| static const QList< CAPlugin * > | pluginList () |
Private Attributes | |
| CAMainWin * | _mainWin |
| QString | _curChars |
| QStack< QString > | _tree |
| CAPlugin * | _curPlugin |
| QString | _curPluginCanorusVersion |
| QString | _curPluginLocale |
| QHash< QString, QString > | _curActionText |
| QString | _curActionName |
| QString | _curActionLocale |
| QString | _curActionOnAction |
| QHash< QString, QString > | _curActionExportFilter |
| QHash< QString, QString > | _curActionImportFilter |
| QString | _curActionParentMenu |
| QString | _curActionParentToolbar |
| bool | _curActionRefresh |
| QString | _curActionLang |
| QString | _curActionFunction |
| QString | _curActionFilename |
| QList< QString > | _curActionArgs |
| QString | _curMenuName |
| QHash< QString, QString > | _curMenuTitle |
| QString | _curMenuLocale |
| QString | _curMenuParentMenu |
Static Private Attributes | |
| static QList< CAPlugin * > | _pluginList |
| static QMultiHash< QString, CAPlugin * > | _actionMap |
| static QHash< QString, CAPluginAction * > | _exportFilterMap |
| static QHash< QString, CAPluginAction * > | _importFilterMap |
This class is the backend for loading, unloading, installing, removing and executing plugins.
It's consists of two parts:
- Static members
Used globally to read, install/remove and enable/disable plugins.
- Non-static members
Inherits the QXml facilities and is used for parsing the plugin's descriptor file.
A plugin is installed or uninstalled using installPlugin() or removePlugin() methods. installMethod()
unpacks the compressed plugin into default user's plugins directory. removePlugin() deletes the plugin
directory from the disk.
After plugins are installed readPlugins() method should be called. This creates a list of available plugin
objects and stores their location paths.
To parse plugins descriptor files and enable plugins, call enablePlugins() to enable plugins marked as
auto-load in Canorus config file or enablePlugin() to load a specific plugin. These methods use Qt's XML
facilities to parse plugins descriptor files and use the non-static part of the class. They also require
an already created main window as the parser creates menu structures, toolbars and other elements
the plugin might offer.
An action (eg. when a user moves mouse in score viewport) is triggered by calling action() method and
pass the action type (eg. "onMouseMove") and other parameters. actionExport() and actionImport() are
separated and are called when Canorus user wants to export/import a document.\sa CAPlugin, CAPluginManagerWin
| CAPluginManager::CAPluginManager | ( | CAMainWin * | mainWin, |
| CAPlugin * | plugin | ||
| ) |
Used if parsing plugin's descriptor file. It uses the given mainWin in order to create new menus and toolbars the plugin might include. If the plugin has already been created (eg. using the same plugin in multiple main windows) plugin is the existing plugin.
References _curPlugin, _curPluginCanorusVersion, and _mainWin.
Referenced by enablePlugin().

| void CAPluginManager::action | ( | QString | val, |
| CADocument * | document, | ||
| QEvent * | evt, | ||
| QPoint * | coords, | ||
| CAMainWin * | mainWin | ||
| ) | [static] |
Gathers all the plugins actions having the given val <action> <name> tag in its descriptor file and calls them. This method is usually triggered automatically by Canorus signals (like mouseClick on score viewport or a menu action).
References _actionMap.
Referenced by endElement(), CAMainWin::onScoreViewPortSelectionChanged(), and CAMainWin::scoreViewPortMousePress().

| bool CAPluginManager::characters | ( | const QString & | ch | ) |
References _curChars.
| bool CAPluginManager::disablePlugin | ( | CAPlugin * | plugin | ) | [static] |
Deinitializes the given plugin and remove any menus, toolbars and other GUI elements the plugin might have created from all the main windows. Plugin is unloaded, but still remains on the list - it's only disabled.
Returns True, if plugin was unloaded successfully, otherwise False.
References _actionMap, CAPlugin::action(), CAPlugin::actionList(), CAPlugin::isEnabled(), CACanorus::mainWinAt(), CACanorus::mainWinCount(), and CAPlugin::setEnabled().
Referenced by disablePlugins(), and removePlugin().


| bool CAPluginManager::disablePlugins | ( | ) | [static] |
Disable and deinitializes all plugins.
Return True, if all the plugins were successfully loaded, otherwise False.
References _pluginList, and disablePlugin().

| bool CAPluginManager::enablePlugin | ( | CAPlugin * | plugin, |
| CAMainWin * | mainWin | ||
| ) | [static] |
Enables the plugin plugin and initializes it (action "onInit").
Returns True, if the plugin was loaded successfully, otherwise False.
References _actionMap, CAPlugin::action(), CAPlugin::actionList(), CAPluginManager(), CAPlugin::dirName(), CAPlugin::isEnabled(), and CAPlugin::setEnabled().
Referenced by enablePlugins().


| bool CAPluginManager::enablePlugins | ( | CAMainWin * | mainWin | ) | [static] |
Enables and initializes all plugins, which are marked as auto-load in Canorus config file.
Returns true if all the plugins were successfully loaded, otherwise False.
\sa enablePlugin(), disablePlugins()
References _pluginList, and enablePlugin().
Referenced by CAMainWin::CAMainWin().


| bool CAPluginManager::endElement | ( | const QString & | namespaceURI, |
| const QString & | localName, | ||
| const QString & | qName | ||
| ) |
References _curActionArgs, _curActionExportFilter, _curActionFilename, _curActionFunction, _curActionImportFilter, _curActionLang, _curActionLocale, _curActionName, _curActionOnAction, _curActionParentMenu, _curActionParentToolbar, _curActionRefresh, _curActionText, _curChars, _curMenuLocale, _curMenuName, _curMenuParentMenu, _curMenuTitle, _curPlugin, _curPluginCanorusVersion, _curPluginLocale, _exportFilterMap, _importFilterMap, _mainWin, _tree, action(), CAPlugin::addAction(), CAPlugin::addMenu(), CAMainWin::exportDialog(), CAMainWin::importDialog(), CAPlugin::menu(), CAPlugin::setAuthor(), CAPlugin::setDescription(), CAPluginAction::setExportFilters(), CAPlugin::setHomeUrl(), CAPluginAction::setImportFilters(), CAPlugin::setName(), CAPluginAction::setOnAction(), CAPluginAction::setRefresh(), CAPluginAction::setTexts(), CAPlugin::setUpdateUrl(), and CAPlugin::setVersion().

| void CAPluginManager::exportAction | ( | QString | filter, |
| CADocument * | document, | ||
| QString | filename | ||
| ) | [static] |
Finds the appropriate action having the given export filter and calls it using the given document and fileName.
References _exportFilterMap.
Referenced by CAMainWin::on_uiExportDocument_triggered().

| static bool CAPluginManager::exportFilterExists | ( | const QString | filter | ) | [inline, static] |
References _exportFilterMap.
Referenced by CAMainWin::on_uiExportDocument_triggered().

| bool CAPluginManager::fatalError | ( | const QXmlParseException & | exception | ) |
| void CAPluginManager::importAction | ( | QString | filter, |
| CADocument * | document, | ||
| QString | filename | ||
| ) | [static] |
Finds the appropriate action having the given import filter and calls it using the given document and fileName. The given document should already be created before calling this method.
References _importFilterMap.
Referenced by CAMainWin::on_uiImportDocument_triggered().

| static bool CAPluginManager::importFilterExists | ( | const QString | filter | ) | [inline, static] |
References _importFilterMap.
Referenced by CAMainWin::on_uiImportDocument_triggered().

| bool CAPluginManager::installPlugin | ( | QString | path | ) | [static] |
Extracts the plugin package at path to user's plugins directory.
Returns True, if plugin was installed and loaded successfully, otherwise False.
| static const QList<CAPlugin*> CAPluginManager::pluginList | ( | ) | [inline, static] |
References _pluginList.
| void CAPluginManager::readPlugins | ( | ) | [static] |
Reads the system and user's plugins directories and adds all the plugins to the internal plugins list.
\warning This function doesn't enable or initialize any of the plugins - use enablePlugins() for this.\sa enablePlugin(), enablePlugins()
References _pluginList, and CAPlugin::setDirName().
Referenced by main().


| bool CAPluginManager::removePlugin | ( | CAPlugin * | plugin | ) | [static] |
Disables and deletes the directory containing the given plugin.
References CAPlugin::dirName(), and disablePlugin().

| bool CAPluginManager::startElement | ( | const QString & | namespaceURI, |
| const QString & | localName, | ||
| const QString & | qName, | ||
| const QXmlAttributes & | attributes | ||
| ) |
References _curActionArgs, _curActionExportFilter, _curActionFilename, _curActionFunction, _curActionImportFilter, _curActionLang, _curActionLocale, _curActionName, _curActionOnAction, _curActionParentMenu, _curActionParentToolbar, _curActionRefresh, _curActionText, _curMenuLocale, _curMenuName, _curMenuParentMenu, _curMenuTitle, _curPlugin, _curPluginLocale, and _tree.
QMultiHash< QString, CAPlugin * > CAPluginManager::_actionMap [static, private] |
Referenced by action(), disablePlugin(), and enablePlugin().
QList<QString> CAPluginManager::_curActionArgs [private] |
Referenced by endElement(), and startElement().
QHash<QString,QString> CAPluginManager::_curActionExportFilter [private] |
Referenced by endElement(), and startElement().
QString CAPluginManager::_curActionFilename [private] |
Referenced by endElement(), and startElement().
QString CAPluginManager::_curActionFunction [private] |
Referenced by endElement(), and startElement().
QHash<QString,QString> CAPluginManager::_curActionImportFilter [private] |
Referenced by endElement(), and startElement().
QString CAPluginManager::_curActionLang [private] |
Referenced by endElement(), and startElement().
QString CAPluginManager::_curActionLocale [private] |
Referenced by endElement(), and startElement().
QString CAPluginManager::_curActionName [private] |
Referenced by endElement(), and startElement().
QString CAPluginManager::_curActionOnAction [private] |
Referenced by endElement(), and startElement().
QString CAPluginManager::_curActionParentMenu [private] |
Referenced by endElement(), and startElement().
QString CAPluginManager::_curActionParentToolbar [private] |
Referenced by endElement(), and startElement().
bool CAPluginManager::_curActionRefresh [private] |
Referenced by endElement(), and startElement().
QHash<QString, QString> CAPluginManager::_curActionText [private] |
Referenced by endElement(), and startElement().
QString CAPluginManager::_curChars [private] |
Referenced by characters(), and endElement().
QString CAPluginManager::_curMenuLocale [private] |
Referenced by endElement(), and startElement().
QString CAPluginManager::_curMenuName [private] |
Referenced by endElement(), and startElement().
QString CAPluginManager::_curMenuParentMenu [private] |
Referenced by endElement(), and startElement().
QHash<QString, QString> CAPluginManager::_curMenuTitle [private] |
Referenced by endElement(), and startElement().
CAPlugin* CAPluginManager::_curPlugin [private] |
Referenced by CAPluginManager(), endElement(), and startElement().
QString CAPluginManager::_curPluginCanorusVersion [private] |
Referenced by CAPluginManager(), and endElement().
QString CAPluginManager::_curPluginLocale [private] |
Referenced by endElement(), and startElement().
QHash< QString, CAPluginAction * > CAPluginManager::_exportFilterMap [static, private] |
Referenced by endElement(), exportAction(), and exportFilterExists().
QHash< QString, CAPluginAction * > CAPluginManager::_importFilterMap [static, private] |
Referenced by endElement(), importAction(), and importFilterExists().
CAMainWin* CAPluginManager::_mainWin [private] |
Referenced by CAPluginManager(), and endElement().
QList< CAPlugin * > CAPluginManager::_pluginList [static, private] |
Referenced by disablePlugins(), enablePlugins(), pluginList(), and readPlugins().
QStack<QString> CAPluginManager::_tree [private] |
Referenced by endElement(), and startElement().
1.8.0