Commit cba0b221 authored by Dennis Nienhüser's avatar Dennis Nienhüser
Browse files

Support adding plugins manually.

parent 99990613
......@@ -60,8 +60,8 @@ PluginManagerPrivate::~PluginManagerPrivate()
// nothing to do
}
PluginManager::PluginManager()
: d( new PluginManagerPrivate() )
PluginManager::PluginManager( QObject *parent ) : QObject( parent ),
d( new PluginManagerPrivate() )
{
}
......@@ -76,42 +76,91 @@ QList<const RenderPlugin *> PluginManager::renderPlugins() const
return d->m_renderPluginTemplates;
}
void PluginManager::addRenderPlugin( RenderPlugin *plugin )
{
d->loadPlugins();
d->m_renderPluginTemplates << plugin;
emit renderPluginsChanged();
}
QList<const NetworkPlugin *> PluginManager::networkPlugins() const
{
d->loadPlugins();
return d->m_networkPluginTemplates;
}
void PluginManager::addNetworkPlugin( NetworkPlugin *plugin )
{
d->loadPlugins();
d->m_networkPluginTemplates << plugin;
emit networkPluginsChanged();
}
QList<const PositionProviderPlugin *> PluginManager::positionProviderPlugins() const
{
d->loadPlugins();
return d->m_positionProviderPluginTemplates;
}
void PluginManager::addPositionProviderPlugin( PositionProviderPlugin *plugin )
{
d->loadPlugins();
d->m_positionProviderPluginTemplates << plugin;
emit positionProviderPluginsChanged();
}
QList<const SearchRunnerPlugin *> PluginManager::searchRunnerPlugins() const
{
d->loadPlugins();
return d->m_searchRunnerPlugins;
}
void PluginManager::addSearchRunnerPlugin( SearchRunnerPlugin *plugin )
{
d->loadPlugins();
d->m_searchRunnerPlugins << plugin;
emit searchRunnerPluginsChanged();
}
QList<const ReverseGeocodingRunnerPlugin *> PluginManager::reverseGeocodingRunnerPlugins() const
{
d->loadPlugins();
return d->m_reverseGeocodingRunnerPlugins;
}
void PluginManager::addReverseGeocodingRunnerPlugin( ReverseGeocodingRunnerPlugin *plugin )
{
d->loadPlugins();
d->m_reverseGeocodingRunnerPlugins << plugin;
emit reverseGeocodingRunnerPluginsChanged();
}
QList<RoutingRunnerPlugin *> PluginManager::routingRunnerPlugins() const
{
d->loadPlugins();
return d->m_routingRunnerPlugins;
}
void PluginManager::addRoutingRunnerPlugin( RoutingRunnerPlugin *plugin )
{
d->loadPlugins();
d->m_routingRunnerPlugins << plugin;
emit routingRunnerPluginsChanged();
}
QList<const ParseRunnerPlugin *> PluginManager::parsingRunnerPlugins() const
{
d->loadPlugins();
return d->m_parsingRunnerPlugins;
}
void PluginManager::addParseRunnerPlugin( ParseRunnerPlugin *plugin )
{
d->loadPlugins();
d->m_parsingRunnerPlugins << plugin;
emit parseRunnerPluginsChanged();
}
/** Append obj to the given plugins list if it inherits both T and U */
template<class T, class U>
bool appendPlugin( QObject * obj, QPluginLoader* &loader, QList<T*> &plugins )
......@@ -210,3 +259,5 @@ void PluginManagerPrivate::loadPlugins()
}
}
#include "PluginManager.moc"
......@@ -12,6 +12,7 @@
#ifndef MARBLE_PLUGINMANAGER_H
#define MARBLE_PLUGINMANAGER_H
#include <QtCore/QObject>
#include <QtCore/QList>
#include "marble_export.h"
......@@ -42,10 +43,12 @@ class ParseRunnerPlugin;
*
*/
class MARBLE_EXPORT PluginManager
class MARBLE_EXPORT PluginManager : public QObject
{
Q_OBJECT
public:
explicit PluginManager();
explicit PluginManager( QObject* parent = 0 );
~PluginManager();
......@@ -58,6 +61,13 @@ class MARBLE_EXPORT PluginManager
*/
QList<const RenderPlugin *> renderPlugins() const;
/**
* @brief Add a RenderPlugin manually to the list of known plugins. Normally you
* don't need to call this method since all plugins are loaded automatically.
* @param plugin The plugin to add. Ownership retains with the caller.
*/
void addRenderPlugin( RenderPlugin * plugin );
/**
* @brief Returns all available NetworkPlugins.
*
......@@ -67,6 +77,13 @@ class MARBLE_EXPORT PluginManager
*/
QList<const NetworkPlugin *> networkPlugins() const;
/**
* @brief Add a NetworkPlugin manually to the list of known plugins. Normally you
* don't need to call this method since all plugins are loaded automatically.
* @param plugin The plugin to add. Ownership retains with the caller.
*/
void addNetworkPlugin( NetworkPlugin * plugin );
/**
* @brief Returns all available PositionProviderPlugins.
*
......@@ -76,30 +93,80 @@ class MARBLE_EXPORT PluginManager
*/
QList<const PositionProviderPlugin *> positionProviderPlugins() const;
/**
* @brief Add a PositionProviderPlugin manually to the list of known plugins. Normally you
* don't need to call this method since all plugins are loaded automatically.
* @param plugin The plugin to add. Ownership retains with the caller.
*/
void addPositionProviderPlugin( PositionProviderPlugin * plugin );
/**
* Returns all search runner plugins.
* @note: Runner plugins are owned by the PluginManager, do not delete them.
*/
QList<const SearchRunnerPlugin *> searchRunnerPlugins() const;
/**
* @brief Add a SearchRunnerPlugin manually to the list of known plugins. Normally you
* don't need to call this method since all plugins are loaded automatically.
* @param plugin The plugin to add. Ownership retains with the caller.
*/
void addSearchRunnerPlugin( SearchRunnerPlugin * plugin );
/**
* Returns all reverse geocoding runner plugins.
* @note: The runner plugins are owned by the PluginManager, do not delete them.
*/
QList<const ReverseGeocodingRunnerPlugin *> reverseGeocodingRunnerPlugins() const;
/**
* @brief Add a ReverseGeocodingRunnerPlugin manually to the list of known plugins. Normally you
* don't need to call this method since all plugins are loaded automatically.
* @param plugin The plugin to add. Ownership retains with the caller.
*/
void addReverseGeocodingRunnerPlugin( ReverseGeocodingRunnerPlugin * plugin );
/**
* Returns all routing runner plugins.
* @note: The runner plugins are owned by the PluginManager, do not delete them.
*/
QList<RoutingRunnerPlugin *> routingRunnerPlugins() const;
/**
* @brief Add a RoutingRunnerPlugin manually to the list of known plugins. Normally you
* don't need to call this method since all plugins are loaded automatically.
* @param plugin The plugin to add. Ownership retains with the caller.
*/
void addRoutingRunnerPlugin( RoutingRunnerPlugin * plugin );
/**
* Returns all parse runner plugins.
* @note: The runner plugins are owned by the PluginManager, do not delete them.
*/
QList<const ParseRunnerPlugin *> parsingRunnerPlugins() const;
/**
* @brief Add a ParseRunnerPlugin manually to the list of known plugins. Normally you
* don't need to call this method since all plugins are loaded automatically.
* @param plugin The plugin to add. Ownership retains with the caller.
*/
void addParseRunnerPlugin( ParseRunnerPlugin * plugin );
Q_SIGNALS:
void renderPluginsChanged();
void networkPluginsChanged();
void positionProviderPluginsChanged();
void searchRunnerPluginsChanged();
void reverseGeocodingRunnerPluginsChanged();
void routingRunnerPluginsChanged();
void parseRunnerPluginsChanged();
private:
Q_DISABLE_COPY( PluginManager )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment