17 #ifndef GEPETTO_GUI_PLUGINMANAGERDIALOG_HH 18 #define GEPETTO_GUI_PLUGINMANAGERDIALOG_HH 22 #include <QSignalMapper> 24 #include <QPluginLoader> 25 #include <QTableWidgetItem> 30 class PluginManagerDialog;
37 typedef QPair <QString, QPluginLoader*>
Pair;
38 typedef QMap <QString, QPluginLoader*>
Map;
39 typedef QPair <QString, QString>
PyPair;
40 typedef QMap <QString, QString>
PyMap;
43 qDeleteAll (plugins_);
46 const Map&
plugins ()
const {
return plugins_; }
48 const PyMap&
pyplugins ()
const {
return pyplugins_; }
50 template <
typename Interface> Interface* getFirstOf ();
52 template <
typename Interface> QList <Interface*>
get ();
54 static QIcon icon (
const QPluginLoader* pl);
56 static QString status (
const QPluginLoader* pl);
58 static void addPluginDir (
const QString& path);
60 void declareAllPlugins (QWidget* parent = NULL);
62 bool declarePlugin (
const QString& name, QWidget* parent = NULL);
64 bool loadPlugin (
const QString& name);
66 bool initPlugin (
const QString& name);
68 bool unloadPlugin (
const QString& name);
72 void declareAllPyPlugins ();
74 bool declarePyPlugin (
const QString& name);
76 bool loadPyPlugin (
const QString& name);
78 bool unloadPyPlugin (
const QString& name);
80 bool isPyPluginLoaded (
const QString& name);
82 void clearPyPlugins ();
85 template <
typename Interface>
86 static const Interface* const_instance_cast (
const QPluginLoader* pl);
88 QMap <QString, QPluginLoader*> plugins_;
89 static QList <QDir> pluginDirs_;
90 QMap <QString, QString> pyplugins_;
102 void onItemChanged (QTableWidgetItem* current, QTableWidgetItem* previous);
103 void contextMenu(
const QPoint& pos);
104 void load (
const QString& name);
105 void unload (
const QString& name);
108 void pyContextMenu(
const QPoint& pos);
109 void pyLoad (
const QString& name);
110 void pyUnload (
const QString& name);
116 static const int P_NAME;
117 static const int P_FILE;
118 static const int P_FULLPATH;
119 static const int P_VERSION;
123 ::Ui::PluginManagerDialog *ui_;
128 template <
typename Interface>
129 Interface* PluginManager::getFirstOf ()
131 foreach (QPluginLoader* p, plugins_) {
134 if (check && check->
isInit ()) {
135 Interface* pi = qobject_cast <Interface*> (p->instance());
143 template <
typename Interface>
144 QList <Interface*> PluginManager::get ()
146 QList <Interface*> list;
147 foreach (QPluginLoader* p, plugins_) {
150 if (check && check->
isInit ()) {
151 Interface* pi = qobject_cast <Interface*> (p->instance());
160 template <
typename Interface>
161 const Interface* PluginManager::const_instance_cast (
const QPluginLoader* pl)
163 return (
const Interface*) qobject_cast <Interface*> (const_cast <QPluginLoader*>(pl)->instance());
168 #endif // GEPETTO_GUI_PLUGINMANAGERDIALOG_HH Definition: pluginmanagerdialog.hh:93
QMap< QString, QPluginLoader * > Map
Definition: pluginmanagerdialog.hh:38
Definition: dialogloadenvironment.hh:23
bool isInit() const
Definition: plugin-interface.hh:54
Definition: plugin-interface.hh:33
Definition: action-search-bar.hh:27
QPair< QString, QString > PyPair
Definition: pluginmanagerdialog.hh:39
Definition: pluginmanagerdialog.hh:35
const Map & plugins() const
Definition: pluginmanagerdialog.hh:46
const PyMap & pyplugins() const
Definition: pluginmanagerdialog.hh:48
QPair< QString, QPluginLoader * > Pair
Definition: pluginmanagerdialog.hh:37
~PluginManager()
Definition: pluginmanagerdialog.hh:42
QMap< QString, QString > PyMap
Definition: pluginmanagerdialog.hh:40