//test
@@ -1,380 +1,370 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SocExplorer Software |
|
2 | -- This file is a part of the SocExplorer Software | |
3 | -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 2 of the License, or |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr |
|
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 | #include "socexplorerproxy.h" |
|
22 | #include "socexplorerproxy.h" | |
23 | #include <pluginmanagerWDGT.h> |
|
23 | #include <pluginmanagerWDGT.h> | |
24 | #include <socexplorerengine.h> |
|
24 | #include <socexplorerengine.h> | |
25 | #include <pluginloader.h> |
|
25 | #include <pluginloader.h> | |
26 | #include <socexplorerplugin.h> |
|
26 | #include <socexplorerplugin.h> | |
27 |
|
27 | |||
28 | socexplorerproxy* socexplorerproxy::_self=NULL; |
|
28 | socexplorerproxy* socexplorerproxy::_self=NULL; | |
29 | QMainWindow* socexplorerproxy::mainWindow=NULL; |
|
29 | QMainWindow* socexplorerproxy::mainWindow=NULL; | |
30 | QList<socexplorerplugin*>* socexplorerproxy::drivers=NULL; |
|
30 | QList<socexplorerplugin*>* socexplorerproxy::drivers=NULL; | |
31 | QList<socexplorerplugin*>* socexplorerproxy::linearDriverList=NULL; |
|
31 | QList<socexplorerplugin*>* socexplorerproxy::linearDriverList=NULL; | |
32 | socexplorerplugin* socexplorerproxy::root=NULL; |
|
32 | socexplorerplugin* socexplorerproxy::root=NULL; | |
33 | socexplorerplugin* socexplorerproxy::parent=NULL; |
|
33 | socexplorerplugin* socexplorerproxy::parent=NULL; | |
34 | PluginsCache* socexplorerproxy::cache=NULL; |
|
34 | PluginsCache* socexplorerproxy::cache=NULL; | |
35 |
|
35 | |||
36 | socexplorerproxy::socexplorerproxy(QObject *parent) : |
|
36 | socexplorerproxy::socexplorerproxy(QObject *parent) : | |
37 | QObject(parent) |
|
37 | QObject(parent) | |
38 | { |
|
38 | { | |
39 | cache = new PluginsCache; |
|
39 | cache = new PluginsCache; | |
40 | drivers = new QList<socexplorerplugin*>; |
|
40 | drivers = new QList<socexplorerplugin*>; | |
41 | linearDriverList=new QList<socexplorerplugin*>; |
|
41 | linearDriverList=new QList<socexplorerplugin*>; | |
42 | root = NULL; |
|
42 | root = NULL; | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 |
|
45 | |||
46 | socexplorerproxy::socexplorerproxy(QMainWindow *Mainwindow, QObject *parent): |
|
46 | socexplorerproxy::socexplorerproxy(QMainWindow *Mainwindow, QObject *parent): | |
47 | QObject(parent) |
|
47 | QObject(parent) | |
48 | { |
|
48 | { | |
49 | mainWindow = Mainwindow; |
|
49 | mainWindow = Mainwindow; | |
50 | cache = new PluginsCache; |
|
50 | cache = new PluginsCache; | |
51 | drivers = new QList<socexplorerplugin*>; |
|
51 | drivers = new QList<socexplorerplugin*>; | |
52 | linearDriverList=new QList<socexplorerplugin*>; |
|
52 | linearDriverList=new QList<socexplorerplugin*>; | |
53 | root = NULL; |
|
53 | root = NULL; | |
54 | } |
|
54 | } | |
55 |
|
55 | |||
56 |
|
56 | |||
57 | void socexplorerproxy::init() |
|
57 | void socexplorerproxy::init() | |
58 | { |
|
58 | { | |
59 | if(!_self) |
|
59 | if(!_self) | |
60 | { |
|
60 | { | |
61 | _self = new socexplorerproxy(); |
|
61 | _self = new socexplorerproxy(); | |
62 | mainWindow = NULL; |
|
62 | mainWindow = NULL; | |
63 | } |
|
63 | } | |
64 |
|
64 | |||
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 | void socexplorerproxy::setMainWindow(QMainWindow *Mainwindow) |
|
67 | void socexplorerproxy::setMainWindow(QMainWindow *Mainwindow) | |
68 | { |
|
68 | { | |
69 | if(!_self)init(); |
|
69 | if(!_self)init(); | |
70 | mainWindow=Mainwindow; |
|
70 | mainWindow=Mainwindow; | |
71 | } |
|
71 | } | |
72 |
|
72 | |||
73 | void socexplorerproxy::loadSysDriver(const QString name) |
|
73 | void socexplorerproxy::loadSysDriver(const QString name) | |
74 | { |
|
74 | { | |
75 | if(!_self)init(); |
|
75 | if(!_self)init(); | |
76 | if(pluginloader::libcanberoot(name)) |
|
76 | if(pluginloader::libcanberoot(name)) | |
77 | { |
|
77 | { | |
78 | socexplorerplugin* driver = pluginloader::newsocexplorerplugin(name); |
|
78 | socexplorerplugin* driver = pluginloader::newsocexplorerplugin(name); | |
79 | QString driverName = _self->getinstanceName(driver->baseName()); |
|
79 | QString driverName = _self->getinstanceName(driver->baseName()); | |
80 | loadSysDriver(driver,driverName); |
|
80 | loadSysDriver(driver,driverName); | |
81 | } |
|
81 | } | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
84 | void socexplorerproxy::loadSysDriver(const QString name, const QString instanceName) |
|
84 | void socexplorerproxy::loadSysDriver(const QString name, const QString instanceName) | |
85 | { |
|
85 | { | |
86 | if(!_self)init(); |
|
86 | if(!_self)init(); | |
87 | if(pluginloader::libcanberoot(name) && !_self->instanceExists(instanceName)) |
|
87 | if(pluginloader::libcanberoot(name) && !_self->instanceExists(instanceName)) | |
88 | { |
|
88 | { | |
89 | socexplorerplugin* driver = pluginloader::newsocexplorerplugin(name); |
|
89 | socexplorerplugin* driver = pluginloader::newsocexplorerplugin(name); | |
90 | loadSysDriver(driver,instanceName); |
|
90 | loadSysDriver(driver,instanceName); | |
91 | } |
|
91 | } | |
92 | } |
|
92 | } | |
93 |
|
93 | |||
94 |
|
94 | |||
95 | void socexplorerproxy::loadSysDriver(socexplorerplugin *driver, const QString instanceName) |
|
95 | void socexplorerproxy::loadSysDriver(socexplorerplugin *driver, const QString instanceName) | |
96 | { |
|
96 | { | |
97 | if(!_self)init(); |
|
97 | if(!_self)init(); | |
98 | driver->setInstanceName(instanceName); |
|
98 | driver->setInstanceName(instanceName); | |
99 | driver->parent = NULL; |
|
99 | driver->parent = NULL; | |
100 | drivers->append(driver); |
|
100 | drivers->append(driver); | |
101 | linearDriverList->append(driver); |
|
101 | linearDriverList->append(driver); | |
102 | connectChildToProxy(driver); |
|
102 | connectChildToProxy(driver); | |
103 | emit _self->addPluginGUI(driver); |
|
103 | emit _self->addPluginGUI(driver); | |
104 | emit _self->clearMenu(); |
|
104 | emit _self->clearMenu(); | |
105 | emit _self->treeChanged(QList<socexplorerplugin*>(*drivers)); |
|
105 | emit _self->treeChanged(QList<socexplorerplugin*>(*drivers)); | |
106 | SocExplorerEngine::addSOC(driver); |
|
106 | SocExplorerEngine::addSOC(driver); | |
107 | } |
|
107 | } | |
108 |
|
108 | |||
109 | void socexplorerproxy::loadChildSysDriver(socexplorerplugin *parent, const QString child) |
|
109 | void socexplorerproxy::loadChildSysDriver(socexplorerplugin *parent, const QString child) | |
110 | { |
|
110 | { | |
111 | if(!_self)init(); |
|
111 | if(!_self)init(); | |
112 | if(pluginloader::libcanbechild(child)) |
|
112 | if(pluginloader::libcanbechild(child)) | |
113 | { |
|
113 | { | |
114 | socexplorerplugin* driver = pluginloader::newsocexplorerplugin(child); |
|
114 | socexplorerplugin* driver = pluginloader::newsocexplorerplugin(child); | |
115 | QString driverName = _self->getinstanceName(driver->baseName()); |
|
115 | QString driverName = _self->getinstanceName(driver->baseName()); | |
116 | bool ok=true; |
|
116 | bool ok=true; | |
117 | if(ok) |
|
117 | if(ok) | |
118 | { |
|
118 | { | |
119 | if(parent!=NULL)_self->loadSysDriverToParent(driver,parent,driverName); |
|
119 | if(parent!=NULL)_self->loadSysDriverToParent(driver,parent,driverName); | |
120 | } |
|
120 | } | |
121 | } |
|
121 | } | |
122 | } |
|
122 | } | |
123 |
|
123 | |||
124 | void socexplorerproxy::loadSysDriverToParent(const QString name,const QString ParentInst) |
|
124 | void socexplorerproxy::loadSysDriverToParent(const QString name,const QString ParentInst) | |
125 | { |
|
125 | { | |
126 | if(!_self)init(); |
|
126 | if(!_self)init(); | |
127 | if(pluginloader::libcanbechild(name)) |
|
127 | if(pluginloader::libcanbechild(name)) | |
128 | { |
|
128 | { | |
129 | socexplorerplugin* driver = pluginloader::newsocexplorerplugin(name); |
|
129 | socexplorerplugin* driver = pluginloader::newsocexplorerplugin(name); | |
130 | QString driverName = _self->getinstanceName(driver->baseName()); |
|
130 | QString driverName = _self->getinstanceName(driver->baseName()); | |
131 | bool ok=true; |
|
131 | bool ok=true; | |
132 | if(ok) |
|
132 | if(ok) | |
133 | { |
|
133 | { | |
134 | socexplorerplugin* parent=_self->getSysDriver(ParentInst); |
|
134 | socexplorerplugin* parent=_self->getSysDriver(ParentInst); | |
135 | if(parent!=NULL)loadSysDriverToParent(driver,parent,driverName); |
|
135 | if(parent!=NULL)loadSysDriverToParent(driver,parent,driverName); | |
136 | } |
|
136 | } | |
137 | } |
|
137 | } | |
138 | } |
|
138 | } | |
139 |
|
139 | |||
140 |
|
140 | |||
141 | void socexplorerproxy::loadSysDriverToParent(const QString name,const QString instanceName,const QString ParentInst) |
|
141 | void socexplorerproxy::loadSysDriverToParent(const QString name,const QString instanceName,const QString ParentInst) | |
142 | { |
|
142 | { | |
143 | if(!_self)init(); |
|
143 | if(!_self)init(); | |
144 | if(pluginloader::libcanbechild(name) && !_self->instanceExists(instanceName)) |
|
144 | if(pluginloader::libcanbechild(name) && !_self->instanceExists(instanceName)) | |
145 | { |
|
145 | { | |
146 | socexplorerplugin* driver = pluginloader::newsocexplorerplugin(name); |
|
146 | socexplorerplugin* driver = pluginloader::newsocexplorerplugin(name); | |
147 | bool ok=true; |
|
147 | bool ok=true; | |
148 | if(ok) |
|
148 | if(ok) | |
149 | { |
|
149 | { | |
150 | socexplorerplugin* parent=_self->getSysDriver(ParentInst); |
|
150 | socexplorerplugin* parent=_self->getSysDriver(ParentInst); | |
151 | if(parent!=NULL)loadSysDriverToParent(driver,parent,instanceName); |
|
151 | if(parent!=NULL)loadSysDriverToParent(driver,parent,instanceName); | |
152 | } |
|
152 | } | |
153 | } |
|
153 | } | |
154 | } |
|
154 | } | |
155 |
|
155 | |||
156 | void socexplorerproxy::loadSysDriverToParent(socexplorerplugin *driver,socexplorerplugin *parent, const QString instanceName) |
|
156 | void socexplorerproxy::loadSysDriverToParent(socexplorerplugin *driver,socexplorerplugin *parent, const QString instanceName) | |
157 | { |
|
157 | { | |
158 | if(!_self)init(); |
|
158 | if(!_self)init(); | |
159 | linearDriverList->append(driver); |
|
159 | linearDriverList->append(driver); | |
160 | driver->parent = parent; |
|
160 | driver->parent = parent; | |
161 | driver->setInstanceName(instanceName); |
|
161 | driver->setInstanceName(instanceName); | |
162 | parent->childs.append(driver); |
|
162 | parent->childs.append(driver); | |
163 | connectChildToProxy(driver); |
|
163 | connectChildToProxy(driver); | |
164 | connectChildToParent(parent,driver); |
|
164 | connectChildToParent(parent,driver); | |
165 | emit _self->clearMenu(); |
|
165 | emit _self->clearMenu(); | |
166 | emit _self->addPluginGUI(driver); |
|
166 | emit _self->addPluginGUI(driver); | |
167 | emit _self->treeChanged(QList<socexplorerplugin*>(*drivers)); |
|
167 | emit _self->treeChanged(QList<socexplorerplugin*>(*drivers)); | |
168 | driver->postInstantiationTrigger(); |
|
168 | driver->postInstantiationTrigger(); | |
169 | } |
|
169 | } | |
170 |
|
170 | |||
171 |
|
171 | |||
172 | void socexplorerproxy::changeSysDriverInstName(const QString instanceName) |
|
172 | void socexplorerproxy::changeSysDriverInstName(const QString instanceName) | |
173 | { |
|
173 | { | |
174 | Q_UNUSED(instanceName) |
|
174 | Q_UNUSED(instanceName) | |
175 | } |
|
175 | } | |
176 |
|
176 | |||
177 | void socexplorerproxy::changeSysDriverInstName(const QString newinstanceName, const QString previnstanceName) |
|
177 | void socexplorerproxy::changeSysDriverInstName(const QString newinstanceName, const QString previnstanceName) | |
178 | { |
|
178 | { | |
179 | if(!_self)init(); |
|
179 | if(!_self)init(); | |
180 | socexplorerplugin*temp=_self->getSysDriver(previnstanceName); |
|
180 | socexplorerplugin*temp=_self->getSysDriver(previnstanceName); | |
181 | if(temp!=NULL) |
|
181 | if(temp!=NULL) | |
182 | { |
|
182 | { | |
183 | if(NULL!=_self->getSysDriver(newinstanceName)) |
|
183 | if(NULL!=_self->getSysDriver(newinstanceName)) | |
184 | { |
|
184 | { | |
185 | emit _self->treeChanged(QList<socexplorerplugin*>(*drivers)); |
|
185 | emit _self->treeChanged(QList<socexplorerplugin*>(*drivers)); | |
186 | return; |
|
186 | return; | |
187 | } |
|
187 | } | |
188 | temp->setInstanceName(newinstanceName); |
|
188 | temp->setInstanceName(newinstanceName); | |
189 | } |
|
189 | } | |
190 | emit _self->treeChanged(QList<socexplorerplugin*>(*drivers)); |
|
190 | emit _self->treeChanged(QList<socexplorerplugin*>(*drivers)); | |
191 | } |
|
191 | } | |
192 |
|
192 | |||
193 | //void socexplorerproxy::loadChild(socexplorerplugin *parent) |
|
|||
194 | //{ |
|
|||
195 | // if(!_self)init(); |
|
|||
196 | // parent = parent; |
|
|||
197 | // pluginmanagerWDGT* pluginmanager0 = new pluginmanagerWDGT; |
|
|||
198 | // pluginmanager0->setChildLoadable(true); |
|
|||
199 | // pluginmanager0->connect(pluginmanager0,SIGNAL(loadSysDrviver(QString)),_self,SLOT(loadSysDriverToParent(QString))); |
|
|||
200 |
// pluginmanager0->show();
|
|
|||
201 | //} |
|
|||
202 |
|
||||
203 |
|
193 | |||
204 | void socexplorerproxy::connectChildToParent(socexplorerplugin *parent, socexplorerplugin *child) |
|
194 | void socexplorerproxy::connectChildToParent(socexplorerplugin *parent, socexplorerplugin *child) | |
205 | { |
|
195 | { | |
206 | if(!_self)init(); |
|
196 | if(!_self)init(); | |
207 | connect(parent,SIGNAL(activateSig(bool)),child,SLOT(activate(bool))); |
|
197 | connect(parent,SIGNAL(activateSig(bool)),child,SLOT(activate(bool))); | |
208 | child->activate(parent->isConnected()); |
|
198 | child->activate(parent->isConnected()); | |
209 | } |
|
199 | } | |
210 |
|
200 | |||
211 | void socexplorerproxy::disconnectChildToParent(socexplorerplugin *child) |
|
201 | void socexplorerproxy::disconnectChildToParent(socexplorerplugin *child) | |
212 | { |
|
202 | { | |
213 | if(!_self)init(); |
|
203 | if(!_self)init(); | |
214 | disconnect(child->parent,SIGNAL(activateSig(bool)),child,SLOT(activate(bool))); |
|
204 | disconnect(child->parent,SIGNAL(activateSig(bool)),child,SLOT(activate(bool))); | |
215 | } |
|
205 | } | |
216 |
|
206 | |||
217 |
|
207 | |||
218 | void socexplorerproxy::connectChildToProxy(socexplorerplugin *child) |
|
208 | void socexplorerproxy::connectChildToProxy(socexplorerplugin *child) | |
219 | { |
|
209 | { | |
220 | if(!_self)init(); |
|
210 | if(!_self)init(); | |
221 | connect(child,SIGNAL(registerObject(QObject*,QString)),_self,SIGNAL(registerObject(QObject*,QString))); |
|
211 | connect(child,SIGNAL(registerObject(QObject*,QString)),_self,SIGNAL(registerObject(QObject*,QString))); | |
222 | connect(child,SIGNAL(closePlugin(socexplorerplugin*)),_self,SLOT(closeSysDriver(socexplorerplugin*))); |
|
212 | connect(child,SIGNAL(closePlugin(socexplorerplugin*)),_self,SLOT(closeSysDriver(socexplorerplugin*))); | |
223 | } |
|
213 | } | |
224 |
|
214 | |||
225 | void socexplorerproxy::disconnectChildToProxy(socexplorerplugin *child) |
|
215 | void socexplorerproxy::disconnectChildToProxy(socexplorerplugin *child) | |
226 | { |
|
216 | { | |
227 | if(!_self)init(); |
|
217 | if(!_self)init(); | |
228 | disconnect(child,SIGNAL(registerObject(QObject*,QString)),_self,SIGNAL(registerObject(QObject*,QString))); |
|
218 | disconnect(child,SIGNAL(registerObject(QObject*,QString)),_self,SIGNAL(registerObject(QObject*,QString))); | |
229 | disconnect(child,SIGNAL(closePlugin(socexplorerplugin*)),_self,SLOT(closeSysDriverFromDriver(socexplorerplugin*))); |
|
219 | disconnect(child,SIGNAL(closePlugin(socexplorerplugin*)),_self,SLOT(closeSysDriverFromDriver(socexplorerplugin*))); | |
230 | } |
|
220 | } | |
231 |
|
221 | |||
232 | QString socexplorerproxy::getinstanceName(const QString& baseName) |
|
222 | QString socexplorerproxy::getinstanceName(const QString& baseName) | |
233 | { |
|
223 | { | |
234 | if(!_self)init(); |
|
224 | if(!_self)init(); | |
235 | int i=0; |
|
225 | int i=0; | |
236 | QString name; |
|
226 | QString name; | |
237 | bool validName = false; |
|
227 | bool validName = false; | |
238 | while(!validName) |
|
228 | while(!validName) | |
239 | { |
|
229 | { | |
240 | name.clear(); |
|
230 | name.clear(); | |
241 | name.append(baseName+QString::number(i)); |
|
231 | name.append(baseName+QString::number(i)); | |
242 | validName = instanceNameIsValid(name); |
|
232 | validName = instanceNameIsValid(name); | |
243 | i++; |
|
233 | i++; | |
244 | } |
|
234 | } | |
245 | return name; |
|
235 | return name; | |
246 | } |
|
236 | } | |
247 |
|
237 | |||
248 | void socexplorerproxy::changeSysDriverInstName(socexplorerplugin* driver) |
|
238 | void socexplorerproxy::changeSysDriverInstName(socexplorerplugin* driver) | |
249 | { |
|
239 | { | |
250 | if(!_self)init(); |
|
240 | if(!_self)init(); | |
251 | QString prevName(driver->instanceName()); |
|
241 | QString prevName(driver->instanceName()); | |
252 | } |
|
242 | } | |
253 |
|
243 | |||
254 | bool socexplorerproxy::instanceNameIsValid(const QString& instanceName) |
|
244 | bool socexplorerproxy::instanceNameIsValid(const QString& instanceName) | |
255 | { |
|
245 | { | |
256 | if(!_self)init(); |
|
246 | if(!_self)init(); | |
257 | for(int k=0;k<linearDriverList->count();k++) |
|
247 | for(int k=0;k<linearDriverList->count();k++) | |
258 | { |
|
248 | { | |
259 | if(!linearDriverList->at(k)->instanceName().compare(instanceName)) |
|
249 | if(!linearDriverList->at(k)->instanceName().compare(instanceName)) | |
260 | return false; |
|
250 | return false; | |
261 | } |
|
251 | } | |
262 | return true; |
|
252 | return true; | |
263 | } |
|
253 | } | |
264 |
|
254 | |||
265 | socexplorerplugin *socexplorerproxy::findPlugin(const QString &instanceName) |
|
255 | socexplorerplugin *socexplorerproxy::findPlugin(const QString &instanceName) | |
266 | { |
|
256 | { | |
267 | if(!_self)init(); |
|
257 | if(!_self)init(); | |
268 | for(int k=0;k<linearDriverList->count();k++) |
|
258 | for(int k=0;k<linearDriverList->count();k++) | |
269 | { |
|
259 | { | |
270 | if(linearDriverList->at(k)->instanceName().compare(instanceName)) |
|
260 | if(linearDriverList->at(k)->instanceName().compare(instanceName)) | |
271 | return linearDriverList->at(k); |
|
261 | return linearDriverList->at(k); | |
272 | } |
|
262 | } | |
273 | return NULL; |
|
263 | return NULL; | |
274 | } |
|
264 | } | |
275 |
|
265 | |||
276 | bool socexplorerproxy::instanceExists(const QString &instanceName) |
|
266 | bool socexplorerproxy::instanceExists(const QString &instanceName) | |
277 | { |
|
267 | { | |
278 | return !socexplorerproxy::instanceNameIsValid(instanceName); |
|
268 | return !socexplorerproxy::instanceNameIsValid(instanceName); | |
279 | } |
|
269 | } | |
280 |
|
270 | |||
281 | void socexplorerproxy::close() |
|
271 | void socexplorerproxy::close() | |
282 | { |
|
272 | { | |
283 | if(!_self)init(); |
|
273 | if(!_self)init(); | |
284 | socexplorerplugin* tmpPtr; |
|
274 | socexplorerplugin* tmpPtr; | |
285 | while(drivers->count()>0) |
|
275 | while(drivers->count()>0) | |
286 | { |
|
276 | { | |
287 | tmpPtr = drivers->last(); |
|
277 | tmpPtr = drivers->last(); | |
288 | drivers->removeLast(); |
|
278 | drivers->removeLast(); | |
289 | _self->closeSysDriver(tmpPtr); |
|
279 | _self->closeSysDriver(tmpPtr); | |
290 | } |
|
280 | } | |
291 | if(root!=NULL) |
|
281 | if(root!=NULL) | |
292 | { |
|
282 | { | |
293 | _self->closeSysDriver(root); |
|
283 | _self->closeSysDriver(root); | |
294 | } |
|
284 | } | |
295 |
|
285 | |||
296 | } |
|
286 | } | |
297 |
|
287 | |||
298 | socexplorerplugin* socexplorerproxy::getSysDriver(const QString instanceName) |
|
288 | socexplorerplugin* socexplorerproxy::getSysDriver(const QString instanceName) | |
299 | { |
|
289 | { | |
300 | if(!_self)init(); |
|
290 | if(!_self)init(); | |
301 | for(int i=0;i<linearDriverList->count();i++) |
|
291 | for(int i=0;i<linearDriverList->count();i++) | |
302 | { |
|
292 | { | |
303 | if(!linearDriverList->at(i)->instanceName().compare(instanceName)) |
|
293 | if(!linearDriverList->at(i)->instanceName().compare(instanceName)) | |
304 | return linearDriverList->at(i); |
|
294 | return linearDriverList->at(i); | |
305 | } |
|
295 | } | |
306 | return NULL; |
|
296 | return NULL; | |
307 | } |
|
297 | } | |
308 |
|
298 | |||
309 |
|
299 | |||
310 | void socexplorerproxy::closeSysDriver(const QString instanceName) |
|
300 | void socexplorerproxy::closeSysDriver(const QString instanceName) | |
311 | { |
|
301 | { | |
312 | if(!_self)init(); |
|
302 | if(!_self)init(); | |
313 | closeSysDriver(getSysDriver(instanceName),false); |
|
303 | closeSysDriver(getSysDriver(instanceName),false); | |
314 | } |
|
304 | } | |
315 |
|
305 | |||
316 | void socexplorerproxy::closeSysDriver(socexplorerplugin *driver, bool recursive) |
|
306 | void socexplorerproxy::closeSysDriver(socexplorerplugin *driver, bool recursive) | |
317 | { |
|
307 | { | |
318 | if(!_self)init(); |
|
308 | if(!_self)init(); | |
319 | if(driver!=NULL) |
|
309 | if(driver!=NULL) | |
320 | { |
|
310 | { | |
321 | emit _self->removePluginGUI(driver); |
|
311 | emit _self->removePluginGUI(driver); | |
322 | if(driver->parent==NULL)SocExplorerEngine::removeSOC(driver); |
|
312 | if(driver->parent==NULL)SocExplorerEngine::removeSOC(driver); | |
323 | while(driver->childs.count()!=0)closeSysDriver(driver->childs.first()); |
|
313 | while(driver->childs.count()!=0)closeSysDriver(driver->childs.first()); | |
324 | linearDriverList->removeOne(driver); |
|
314 | linearDriverList->removeOne(driver); | |
325 | if(driver->parent!= NULL) |
|
315 | if(driver->parent!= NULL) | |
326 | { |
|
316 | { | |
327 | driver->parent->childs.removeOne(driver); //Have parent so it's a child |
|
317 | driver->parent->childs.removeOne(driver); //Have parent so it's a child | |
328 | disconnectChildToParent(driver); |
|
318 | disconnectChildToParent(driver); | |
329 | disconnectChildToProxy(driver); |
|
319 | disconnectChildToProxy(driver); | |
330 | delete driver; |
|
320 | delete driver; | |
331 | } |
|
321 | } | |
332 | else |
|
322 | else | |
333 | { |
|
323 | { | |
334 | drivers->removeOne(driver); |
|
324 | drivers->removeOne(driver); | |
335 | disconnectChildToProxy(driver); |
|
325 | disconnectChildToProxy(driver); | |
336 | delete driver; |
|
326 | delete driver; | |
337 | } |
|
327 | } | |
338 | if(!recursive) |
|
328 | if(!recursive) | |
339 | { |
|
329 | { | |
340 | emit _self->clearMenu(); |
|
330 | emit _self->clearMenu(); | |
341 | emit _self->registermenu(mainWindow); |
|
331 | emit _self->registermenu(mainWindow); | |
342 | emit _self->treeChanged(QList<socexplorerplugin*>(*drivers)); |
|
332 | emit _self->treeChanged(QList<socexplorerplugin*>(*drivers)); | |
343 | } |
|
333 | } | |
344 | } |
|
334 | } | |
345 |
|
335 | |||
346 | } |
|
336 | } | |
347 |
|
337 | |||
348 | void socexplorerproxy::geteplugintree() |
|
338 | void socexplorerproxy::geteplugintree() | |
349 | { |
|
339 | { | |
350 | if(!_self)init(); |
|
340 | if(!_self)init(); | |
351 | emit _self->treeChanged(QList<socexplorerplugin*>(*drivers)); |
|
341 | emit _self->treeChanged(QList<socexplorerplugin*>(*drivers)); | |
352 | } |
|
342 | } | |
353 |
|
343 | |||
354 | void socexplorerproxy::closeSysDriverFromDriver(socexplorerplugin *driver) |
|
344 | void socexplorerproxy::closeSysDriverFromDriver(socexplorerplugin *driver) | |
355 | { |
|
345 | { | |
356 | if(!_self)init(); |
|
346 | if(!_self)init(); | |
357 | emit _self->closeSysDriverSig(driver); |
|
347 | emit _self->closeSysDriverSig(driver); | |
358 | } |
|
348 | } | |
359 |
|
349 | |||
360 | void socexplorerproxy::updateText() |
|
350 | void socexplorerproxy::updateText() | |
361 | { |
|
351 | { | |
362 | if(!_self)init(); |
|
352 | if(!_self)init(); | |
363 | emit _self->clearMenu(); |
|
353 | emit _self->clearMenu(); | |
364 | emit _self->registermenu(mainWindow); |
|
354 | emit _self->registermenu(mainWindow); | |
365 | } |
|
355 | } | |
366 |
|
356 | |||
367 |
|
357 | |||
368 |
|
358 | |||
369 |
|
359 | |||
370 |
|
360 | |||
371 | void socexplorerproxy::makeMenu(QMenu* menu) |
|
361 | void socexplorerproxy::makeMenu(QMenu* menu) | |
372 | { |
|
362 | { | |
373 | if(!_self)init(); |
|
363 | if(!_self)init(); | |
374 | for(int i=0;i<drivers->count();i++) |
|
364 | for(int i=0;i<drivers->count();i++) | |
375 | { |
|
365 | { | |
376 | drivers->at(i)->registermenu(menu); |
|
366 | drivers->at(i)->registermenu(menu); | |
377 | } |
|
367 | } | |
378 | } |
|
368 | } | |
379 |
|
369 | |||
380 |
|
370 |
General Comments 0
You need to be logged in to leave comments.
Login now