Commit 7f83bd3d authored by Bernhard Beschow's avatar Bernhard Beschow
Browse files

RenderPlugin: merge setMarbleModel() into newInstance()

parent 23a17e53
......@@ -45,8 +45,8 @@ class AbstractDataPluginPrivate
quint32 m_numberOfItems;
};
AbstractDataPlugin::AbstractDataPlugin()
: RenderPlugin(),
AbstractDataPlugin::AbstractDataPlugin( const MarbleModel *marbleModel )
: RenderPlugin( marbleModel ),
d( new AbstractDataPluginPrivate )
{
}
......
......@@ -42,7 +42,7 @@ class MARBLE_EXPORT AbstractDataPlugin : public RenderPlugin
Q_OBJECT
public:
AbstractDataPlugin();
AbstractDataPlugin( const MarbleModel *marbleModel );
virtual ~AbstractDataPlugin();
/**
......
......@@ -49,8 +49,8 @@ QPen AbstractFloatItemPrivate::s_pen = QPen( Qt::black );
QFont AbstractFloatItemPrivate::s_font = QFont( "Sans Serif", 8 );
#endif
AbstractFloatItem::AbstractFloatItem( const QPointF &point, const QSizeF &size )
: RenderPlugin(),
AbstractFloatItem::AbstractFloatItem( const MarbleModel *marbleModel, const QPointF &point, const QSizeF &size )
: RenderPlugin( marbleModel ),
FrameGraphicsItem(),
d( new AbstractFloatItemPrivate() )
{
......
......@@ -44,7 +44,8 @@ class MARBLE_EXPORT AbstractFloatItem : public RenderPlugin, public FrameGraphic
Q_OBJECT
public:
explicit AbstractFloatItem( const QPointF &point = QPointF( 10.0, 10.0 ),
explicit AbstractFloatItem( const MarbleModel *marbleModel,
const QPointF &point = QPointF( 10.0, 10.0 ),
const QSizeF &size = QSizeF( 150.0, 50.0 ) );
virtual ~AbstractFloatItem();
......
......@@ -65,7 +65,7 @@ LayerManagerPrivate::LayerManagerPrivate( const MarbleModel* model )
: m_mapTheme( 0 ),
m_marbleModel( model ),
m_pluginManager( model->pluginManager() ),
m_renderPlugins( m_pluginManager->createRenderPlugins() ),
m_renderPlugins( m_pluginManager->createRenderPlugins( model ) ),
m_showBackground( true )
{
}
......@@ -100,10 +100,6 @@ LayerManager::LayerManager( const MarbleModel* model, QObject *parent )
if( dataPlugin )
d->m_dataPlugins.append( dataPlugin );
}
foreach( RenderPlugin * renderPlugin, d->m_renderPlugins ) {
renderPlugin->setMarbleModel( d->m_marbleModel );
}
}
LayerManager::~LayerManager()
......
......@@ -78,10 +78,19 @@ QList<T*> createPlugins( const QList<const T*> &factories )
return result;
}
QList<RenderPlugin *> PluginManager::createRenderPlugins() const
QList<RenderPlugin *> PluginManager::createRenderPlugins( const MarbleModel *marbleModel ) const
{
d->loadPlugins();
return createPlugins( d->m_renderPluginTemplates );
QList<RenderPlugin *> result;
foreach ( const RenderPlugin *factory, d->m_renderPluginTemplates ) {
RenderPlugin *instance = factory->newInstance( marbleModel );
Q_ASSERT( instance && "Plugin returned null when requesting a new instance." );
result.append( instance );
}
return result;
}
QList<NetworkPlugin *> PluginManager::createNetworkPlugins() const
......
......@@ -20,6 +20,7 @@ namespace Marble
{
class RenderPlugin;
class MarbleModel;
class NetworkPlugin;
class PositionProviderPlugin;
class AbstractFloatItem;
......@@ -50,7 +51,7 @@ class MARBLE_EXPORT PluginManager
* This methods creates a new set of plugins and transfers ownership
* of them to the client.
*/
QList<RenderPlugin *> createRenderPlugins() const;
QList<RenderPlugin *> createRenderPlugins( const MarbleModel *marbleModel ) const;
/**
* This methods creates a new set of plugins and transfers ownership
......
......@@ -28,8 +28,8 @@ namespace Marble
class RenderPluginPrivate
{
public:
RenderPluginPrivate()
: m_marbleModel(0),
RenderPluginPrivate( const MarbleModel *marbleModel )
: m_marbleModel( marbleModel ),
m_action(0),
m_item(0),
m_enabled(true),
......@@ -42,7 +42,7 @@ class RenderPluginPrivate
}
// const: RenderPlugins should only read the model, not modify it
const MarbleModel *m_marbleModel;
const MarbleModel *const m_marbleModel;
QAction *m_action;
QStandardItem *m_item;
......@@ -51,8 +51,8 @@ class RenderPluginPrivate
};
RenderPlugin::RenderPlugin()
: d( new RenderPluginPrivate() )
RenderPlugin::RenderPlugin( const MarbleModel *marbleModel )
: d( new RenderPluginPrivate( marbleModel ) )
{
d->m_action = new QAction( this );
connect( d->m_action, SIGNAL( toggled( bool ) ),
......@@ -73,11 +73,6 @@ const MarbleModel* RenderPlugin::marbleModel() const
return d->m_marbleModel;
}
void RenderPlugin::setMarbleModel( const MarbleModel* marbleModel )
{
d->m_marbleModel = marbleModel;
}
QAction* RenderPlugin::action() const
{
d->m_action->setCheckable( true );
......
......@@ -56,20 +56,19 @@ class MARBLE_EXPORT RenderPlugin : public QObject, public RenderPluginInterface
Online
};
RenderPlugin();
RenderPlugin( const MarbleModel *marbleModel );
virtual ~RenderPlugin();
/**
* @brief Returns a new object of the plugin
*/
virtual RenderPlugin *newInstance() const = 0;
virtual RenderPlugin *newInstance( const MarbleModel *marbleModel ) const = 0;
virtual void initialize() = 0;
virtual bool isInitialized() const = 0;
const MarbleModel* marbleModel() const;
void setMarbleModel( const MarbleModel* );
QAction *action() const;
/**
......@@ -156,7 +155,7 @@ class MARBLE_EXPORT RenderPlugin : public QObject, public RenderPluginInterface
};
#define MARBLE_PLUGIN(T) public:\
virtual RenderPlugin* newInstance() const { return new T(); }
virtual RenderPlugin* newInstance( const MarbleModel *marbleModel ) const { return new T( marbleModel ); }
}
#endif
......@@ -37,7 +37,16 @@ using namespace Marble;
/* TRANSLATOR Marble::AprsPlugin */
AprsPlugin::AprsPlugin()
: m_mutex( new QMutex ),
: RenderPlugin( 0 ),
m_mutex( 0 ),
m_configDialog( 0 ),
ui_configWidget( 0 )
{
}
AprsPlugin::AprsPlugin( const MarbleModel *marbleModel )
: RenderPlugin( marbleModel ),
m_mutex( new QMutex ),
m_initialized( false ),
m_tcpipGatherer( 0 ),
m_ttyGatherer( 0 ),
......
......@@ -44,6 +44,7 @@ namespace Marble
public:
AprsPlugin();
explicit AprsPlugin( const MarbleModel *marbleModel );
~AprsPlugin();
QStringList backendTypes() const;
QString renderPolicy() const;
......
......@@ -27,7 +27,13 @@ namespace Marble
{
CompassFloatItem::CompassFloatItem()
: AbstractFloatItem( QPointF( -1.0, 10.0 ), QSizeF( 75.0, 75.0 ) ),
: AbstractFloatItem( 0 ),
m_svgobj( 0 )
{
}
CompassFloatItem::CompassFloatItem( const MarbleModel *marbleModel )
: AbstractFloatItem( marbleModel, QPointF( -1.0, 10.0 ), QSizeF( 75.0, 75.0 ) ),
m_isInitialized( false ),
m_svgobj( 0 ),
m_compass(),
......
......@@ -38,6 +38,7 @@ class CompassFloatItem : public AbstractFloatItem, public DialogConfigurationIn
MARBLE_PLUGIN( CompassFloatItem )
public:
CompassFloatItem();
explicit CompassFloatItem( const MarbleModel *marbleModel );
~CompassFloatItem ();
QStringList backendTypes() const;
......
......@@ -27,8 +27,15 @@
namespace Marble
{
CrosshairsPlugin::CrosshairsPlugin ( )
: m_isInitialized( false ),
CrosshairsPlugin::CrosshairsPlugin()
: RenderPlugin( 0 ),
m_svgobj( 0 )
{
}
CrosshairsPlugin::CrosshairsPlugin( const MarbleModel *marbleModel )
: RenderPlugin( marbleModel ),
m_isInitialized( false ),
m_svgobj( 0 ),
m_configDialog( 0 ),
m_uiConfigWidget( 0 )
......
......@@ -46,6 +46,8 @@ class CrosshairsPlugin : public RenderPlugin, public DialogConfigurationInterfac
public:
CrosshairsPlugin();
CrosshairsPlugin( const MarbleModel *marbleModel );
~CrosshairsPlugin();
QStringList backendTypes() const;
......
......@@ -18,7 +18,16 @@
namespace Marble {
EarthquakePlugin::EarthquakePlugin()
: m_isInitialized( false ),
: AbstractDataPlugin( 0 ),
m_ui( 0 ),
m_configDialog( 0 )
{
}
EarthquakePlugin::EarthquakePlugin( const MarbleModel *marbleModel )
: AbstractDataPlugin( marbleModel ),
m_isInitialized( false ),
m_ui( 0 ),
m_configDialog( 0 )
{
setEnabled( true ); // Plugin is enabled by default
......
......@@ -39,6 +39,8 @@ class EarthquakePlugin : public AbstractDataPlugin, public DialogConfigurationIn
public:
EarthquakePlugin();
explicit EarthquakePlugin( const MarbleModel *marbleModel );
virtual void initialize();
virtual bool isInitialized() const;
......
......@@ -31,8 +31,16 @@ namespace Marble
{
ElevationProfileFloatItem::ElevationProfileFloatItem()
: AbstractFloatItem( QPointF( 220, 10.5 ), QSizeF( 0.0, 50.0 ) ),
: AbstractFloatItem( 0 ),
m_configDialog( 0 ),
ui_configWidget( 0 )
{
}
ElevationProfileFloatItem::ElevationProfileFloatItem( const MarbleModel *marbleModel )
: AbstractFloatItem( marbleModel, QPointF( 220, 10.5 ), QSizeF( 0.0, 50.0 ) ),
m_configDialog( 0 ),
ui_configWidget( 0 ),
m_leftGraphMargin( 0 ),
m_eleGraphWidth( 0 ),
m_viewportWidth( 0 ),
......
......@@ -49,6 +49,7 @@ class ElevationProfileFloatItem : public AbstractFloatItem, public DialogConfigu
public:
ElevationProfileFloatItem();
explicit ElevationProfileFloatItem( const MarbleModel *marbleModel );
~ElevationProfileFloatItem();
virtual QStringList backendTypes() const;
......
......@@ -24,7 +24,13 @@ namespace Marble
{
GpsInfo::GpsInfo()
: AbstractFloatItem( QPointF( 10.5, 110 ), QSizeF( 135.0, 80.0 ) ),
: AbstractFloatItem( 0 ),
m_widgetItem( 0 )
{
}
GpsInfo::GpsInfo( const MarbleModel *marbleModel )
: AbstractFloatItem( marbleModel, QPointF( 10.5, 110 ), QSizeF( 135.0, 80.0 ) ),
m_widgetItem( 0 )
{
setVisible( false );
......
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