Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <qt_gui_cpp/plugin_bridge.h>
00034
00035 #include <qt_gui_cpp/plugin.h>
00036 #include <qt_gui_cpp/plugin_context.h>
00037 #include <qt_gui_cpp/plugin_provider.h>
00038
00039 #include <QEvent>
00040
00041 namespace qt_gui_cpp {
00042
00043 PluginBridge::PluginBridge()
00044 : QObject()
00045 , provider_(0)
00046 , plugin_(0)
00047 {
00048 setObjectName("PluginBridge");
00049 }
00050
00051 bool PluginBridge::load_plugin(PluginProvider* provider, const QString& plugin_id, PluginContext* plugin_context)
00052 {
00053 qDebug("PluginBridge::load_plugin() %s", plugin_id.toStdString().c_str());
00054 provider_ = provider;
00055 plugin_ = provider_->load_plugin(plugin_id, plugin_context);
00056 if (plugin_)
00057 {
00058 plugin_->installEventFilter(this);
00059 }
00060 return plugin_ != 0;
00061 }
00062
00063 void PluginBridge::unload_plugin()
00064 {
00065 qDebug("PluginBridge::unload_plugin()");
00066 provider_->unload_plugin(plugin_);
00067 plugin_ = 0;
00068 }
00069
00070 bool PluginBridge::has_configuration() const
00071 {
00072 if (plugin_)
00073 {
00074 return plugin_->hasConfiguration();
00075 }
00076 return false;
00077 }
00078
00079 void PluginBridge::trigger_configuration()
00080 {
00081 if (plugin_)
00082 {
00083 plugin_->triggerConfiguration();
00084 }
00085 }
00086
00087 void PluginBridge::shutdown_plugin()
00088 {
00089 if (plugin_)
00090 {
00091 plugin_->removeEventFilter(this);
00092 plugin_->shutdownPlugin();
00093 }
00094 }
00095
00096 void PluginBridge::save_settings(QObject* plugin_settings, QObject* instance_settings)
00097 {
00098 if (plugin_)
00099 {
00100 Settings plugin(plugin_settings);
00101 Settings instance(instance_settings);
00102 plugin_->saveSettings(plugin, instance);
00103 }
00104 }
00105
00106 void PluginBridge::restore_settings(QObject* plugin_settings, QObject* instance_settings)
00107 {
00108 if (plugin_)
00109 {
00110 Settings plugin(plugin_settings);
00111 Settings instance(instance_settings);
00112 plugin_->restoreSettings(plugin, instance);
00113 }
00114 }
00115
00116 }