Commit 75ba8364 authored by Martin Schultz's avatar Martin Schultz

Added slot for CrossplatformConnectQueued to core.hh

And refactored ffunctionality to common function which uses a bool to
determine connection type
parent d10dbdc1
......@@ -636,6 +636,9 @@ signals:
/// Called to create inter plugin connections
void slotCrossPluginConnect( QString _pluginName1, const char* _signal, QString _pluginName2, const char* _slot);
/// Called to create inter plugin connections
void slotCrossPluginConnectQueued( QString _pluginName1, const char* _signal, QString _pluginName2, const char* _slot);
/// called to switch the renderer for a specific viewer
void slotSetRenderer(unsigned int _viewer, QString _rendererName);
......
......@@ -433,10 +433,13 @@ void Core::deletedObject(int /*_objectId*/) {
//========================================================================================
// === Cross Plugin connections ============================
//========================================================================================
void Core::slotCrossPluginConnect( QString _pluginName1, const char* _signal, QString _pluginName2, const char* _slot) {
/// Helper function to avoid code duplication
void connectPlugins( Core* c, const std::vector<PluginInfo>& plugins_, QString _pluginName1, const char* _signal, QString _pluginName2, const char* _slot, bool _queued)
{
QObject* plugin1 = 0;
QObject* plugin2 = 0;
for ( int i = 0 ; i < (int)plugins_.size(); ++i ) {
if ( plugins_[i].rpcName == _pluginName1 ) {
plugin1 = plugins_[i].plugin;
......@@ -447,17 +450,28 @@ void Core::slotCrossPluginConnect( QString _pluginName1, const char* _signal, QS
}
if ( plugin1 == 0 ) {
emit log(LOGERR,tr("Cross Plugin Interconnection failed because plugin %1 was not found!").arg(_pluginName1));
emit c->log(LOGERR,QObject::tr("Cross Plugin Interconnection failed because plugin %1 was not found!").arg(_pluginName1));
return;
}
if ( plugin2 == 0 ) {
emit log(LOGERR,tr("Cross Plugin Interconnection failed because plugin %1 was not found!").arg(_pluginName2));
emit c->log(LOGERR,QObject::tr("Cross Plugin Interconnection failed because plugin %1 was not found!").arg(_pluginName2));
return;
}
// now connect them
connect(plugin1,_signal,plugin2,_slot);
if(_queued)
QObject::connect(plugin1,_signal,plugin2,_slot, Qt::QueuedConnection);
else
QObject::connect(plugin1,_signal,plugin2,_slot);
}
void Core::slotCrossPluginConnect( QString _pluginName1, const char* _signal, QString _pluginName2, const char* _slot) {
connectPlugins(this, plugins_, _pluginName1, _signal, _pluginName2, _slot, false);
}
void Core::slotCrossPluginConnectQueued( QString _pluginName1, const char* _signal, QString _pluginName2, const char* _slot) {
connectPlugins(this, plugins_, _pluginName1, _signal, _pluginName2, _slot, true);
}
//========================================================================================
......
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