@@ -1,1 +1,1 | |||||
1 |
|
|
1 | e3a98a04d9ec8685bf222f8d687a614a71927549 src/SocExplorerEngine/PeripheralWidget |
@@ -1,224 +1,224 | |||||
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) 2012, Laboratory of Plasmas Physic - CNRS |
|
3 | -- Copyright (C) 2012, Laboratory of Plasmas Physic - 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 "socexplorerengine.h" |
|
22 | #include "socexplorerengine.h" | |
23 | #include <proxy/socexplorerproxy.h> |
|
23 | #include <proxy/socexplorerproxy.h> | |
24 |
|
24 | |||
25 | SocExplorerEngine* SocExplorerEngine::_self = NULL; |
|
25 | SocExplorerEngine* SocExplorerEngine::_self = NULL; | |
26 | socExplorerXmlModel* SocExplorerEngine::p_xmlmodel=NULL; |
|
26 | socExplorerXmlModel* SocExplorerEngine::p_xmlmodel=NULL; | |
27 | QMainWindow* SocExplorerEngine::mainWindow=NULL; |
|
27 | QMainWindow* SocExplorerEngine::mainWindow=NULL; | |
28 | QList<SOCModel*>* SocExplorerEngine::SOCs=NULL; |
|
28 | QList<SOCModel*>* SocExplorerEngine::SOCs=NULL; | |
29 | int SocExplorerEngine::loglvl=1; |
|
29 | int SocExplorerEngine::loglvl=1; | |
30 |
|
30 | |||
31 | SocExplorerEngine::SocExplorerEngine(QObject *parent) : |
|
31 | SocExplorerEngine::SocExplorerEngine(QObject *parent) : | |
32 | QObject(parent) |
|
32 | QObject(parent) | |
33 | { |
|
33 | { | |
34 | if(SOCs==NULL) |
|
34 | if(SOCs==NULL) | |
35 | { |
|
35 | { | |
36 | SOCs = new QList<SOCModel*>; |
|
36 | SOCs = new QList<SOCModel*>; | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 |
|
41 | |||
42 | void SocExplorerEngine::init() |
|
42 | void SocExplorerEngine::init() | |
43 | { |
|
43 | { | |
44 | QDir dir; |
|
44 | QDir dir; | |
45 | if(!_self) |
|
45 | if(!_self) | |
46 | { |
|
46 | { | |
47 | _self= new SocExplorerEngine; |
|
47 | _self= new SocExplorerEngine; | |
48 | } |
|
48 | } | |
49 | if(!dir.exists(configFolder())) |
|
49 | if(!dir.exists(configFolder())) | |
50 | dir.mkdir(configFolder()); |
|
50 | dir.mkdir(configFolder()); | |
51 | p_xmlmodel = new socExplorerXmlModel(_self); |
|
51 | p_xmlmodel = new socExplorerXmlModel(_self); | |
52 | p_xmlmodel->updateSOClist(); |
|
52 | p_xmlmodel->updateSOClist(); | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | QString SocExplorerEngine::configFolder() |
|
55 | QString SocExplorerEngine::configFolder() | |
56 | { |
|
56 | { | |
57 | return QString(SOCEXPLORER_CONFIG_PATH); |
|
57 | return QString(SOCEXPLORER_CONFIG_PATH); | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
60 | SOCModel *SocExplorerEngine::plugin2Soc(socexplorerplugin *plugin) |
|
60 | SOCModel *SocExplorerEngine::plugin2Soc(socexplorerplugin *plugin) | |
61 | { |
|
61 | { | |
62 | if(!_self) |
|
62 | if(!_self) | |
63 | init(); |
|
63 | init(); | |
64 | if(plugin) |
|
64 | if(plugin) | |
65 | { |
|
65 | { | |
66 | while (plugin->parent!=NULL) { |
|
66 | while (plugin->parent!=NULL) { | |
67 | plugin = plugin->parent; |
|
67 | plugin = plugin->parent; | |
68 | } |
|
68 | } | |
69 | for(int i=0;i<SOCs->count();i++) |
|
69 | for(int i=0;i<SOCs->count();i++) | |
70 | { |
|
70 | { | |
71 | if(SOCs->at(i)->isRootDev(plugin)) |
|
71 | if(SOCs->at(i)->isRootDev(plugin)) | |
72 | return SOCs->at(i); |
|
72 | return SOCs->at(i); | |
73 | } |
|
73 | } | |
74 | //no soc found so create a new one |
|
74 | //no soc found so create a new one | |
75 | SOCModel* soc=new SOCModel(plugin); |
|
75 | SOCModel* soc=new SOCModel(plugin); | |
76 | SOCs->append(soc); |
|
76 | SOCs->append(soc); | |
77 | return soc; |
|
77 | return soc; | |
78 | } |
|
78 | } | |
79 | return NULL; |
|
79 | return NULL; | |
80 | } |
|
80 | } | |
81 |
|
81 | |||
82 |
|
82 | |||
83 | int SocExplorerEngine::addEnumDevice(socexplorerplugin* rootPlugin,int VID, int PID, qint32 baseAddress, const QString &name) |
|
83 | int SocExplorerEngine::addEnumDevice(socexplorerplugin* rootPlugin,int VID, int PID, qint32 baseAddress, const QString &name) | |
84 | { |
|
84 | { | |
85 | if(!_self) |
|
85 | if(!_self) | |
86 | init(); |
|
86 | init(); | |
87 | SOCModel* soc = plugin2Soc(rootPlugin); |
|
87 | SOCModel* soc = plugin2Soc(rootPlugin); | |
88 | if(soc && !soc->enumDeviceExists(baseAddress)) |
|
88 | if(soc && !soc->enumDeviceExists(baseAddress)) | |
89 | { |
|
89 | { | |
90 | emit _self->enumDeviceAdded(soc->addEnumDevice(VID,PID,baseAddress,name)); |
|
90 | emit _self->enumDeviceAdded(soc->addEnumDevice(VID,PID,baseAddress,name)); | |
91 | return 1; |
|
91 | return 1; | |
92 | } |
|
92 | } | |
93 | return 0; |
|
93 | return 0; | |
94 | } |
|
94 | } | |
95 |
|
95 | |||
96 | QList<SOCModel *> *SocExplorerEngine::getSOCs() |
|
96 | QList<SOCModel *> *SocExplorerEngine::getSOCs() | |
97 | { |
|
97 | { | |
98 | if(!_self) |
|
98 | if(!_self) | |
99 | init(); |
|
99 | init(); | |
100 | return SOCs; |
|
100 | return SOCs; | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | qint32 SocExplorerEngine::getEnumDeviceBaseAddress(const QString& rootPlugin,int VID, int PID, int count) |
|
103 | qint32 SocExplorerEngine::getEnumDeviceBaseAddress(const QString& rootPlugin,int VID, int PID, int count) | |
104 | { |
|
104 | { | |
105 | socexplorerplugin* plugin = socexplorerproxy::findPlugin(rootPlugin); |
|
105 | socexplorerplugin* plugin = socexplorerproxy::findPlugin(rootPlugin); | |
106 | if(plugin==NULL)return -1; |
|
106 | if(plugin==NULL)return -1; | |
107 | SOCModel* soc = plugin2Soc(plugin); |
|
107 | SOCModel* soc = plugin2Soc(plugin); | |
108 | if(soc==NULL) |
|
108 | if(soc==NULL) | |
109 | return -1; |
|
109 | return -1; | |
110 | return soc->getEnumDeviceBaseAddress(VID,PID,count); |
|
110 | return soc->getEnumDeviceBaseAddress(VID,PID,count); | |
111 | } |
|
111 | } | |
112 |
|
112 | |||
113 | qint32 SocExplorerEngine::getEnumDeviceBaseAddress(socexplorerplugin *plugin, int VID, int PID, int count) |
|
113 | qint32 SocExplorerEngine::getEnumDeviceBaseAddress(socexplorerplugin *plugin, int VID, int PID, int count) | |
114 | { |
|
114 | { | |
115 | if(plugin==NULL)return -1; |
|
115 | if(plugin==NULL)return -1; | |
116 | SOCModel* soc = plugin2Soc(plugin); |
|
116 | SOCModel* soc = plugin2Soc(plugin); | |
117 | if(soc==NULL) |
|
117 | if(soc==NULL) | |
118 | return -1; |
|
118 | return -1; | |
119 | return soc->getEnumDeviceBaseAddress(VID,PID,count); |
|
119 | return soc->getEnumDeviceBaseAddress(VID,PID,count); | |
120 | } |
|
120 | } | |
121 |
|
121 | |||
122 | int SocExplorerEngine::addEnumDevice(const QString &rootPlugin, int VID, int PID, qint32 baseAddress, const QString &name) |
|
122 | int SocExplorerEngine::addEnumDevice(const QString &rootPlugin, int VID, int PID, qint32 baseAddress, const QString &name) | |
123 | { |
|
123 | { | |
124 | socexplorerplugin* plugin = socexplorerproxy::findPlugin(rootPlugin); |
|
124 | socexplorerplugin* plugin = socexplorerproxy::findPlugin(rootPlugin); | |
125 | if(plugin==NULL)return -1; |
|
125 | if(plugin==NULL)return -1; | |
126 | SOCModel* soc = plugin2Soc(plugin); |
|
126 | SOCModel* soc = plugin2Soc(plugin); | |
127 | if(soc==NULL) |
|
127 | if(soc==NULL) | |
128 | return -1; |
|
128 | return -1; | |
129 | soc->addEnumDevice(VID,PID,baseAddress,name); |
|
129 | soc->addEnumDevice(VID,PID,baseAddress,name); | |
130 | return 1; |
|
130 | return 1; | |
131 | } |
|
131 | } | |
132 |
|
132 | |||
133 |
|
133 | |||
134 | QString SocExplorerEngine::getDevName(int VID, int PID) |
|
134 | QString SocExplorerEngine::getDevName(int VID, int PID) | |
135 | { |
|
135 | { | |
136 | QList<QDomNodeList> list=p_xmlmodel->getAllNodes("peripheral"); |
|
136 | QList<QDomNodeList> list=p_xmlmodel->getAllNodes("peripheral"); | |
137 | for(int i=0;i<list.count();i++) |
|
137 | for(int i=0;i<list.count();i++) | |
138 | { |
|
138 | { | |
139 | QDomNodeList nodes=list.at(i); |
|
139 | QDomNodeList nodes=list.at(i); | |
140 | for(int l=0;l<nodes.count();l++) |
|
140 | for(int l=0;l<nodes.count();l++) | |
141 | { |
|
141 | { | |
142 | QDomElement node=nodes.at(l).toElement(); |
|
142 | QDomElement node=nodes.at(l).toElement(); | |
143 | int nodeVID=node.attribute("vid","0").toInt(); |
|
143 | int nodeVID=node.attribute("vid","0").toInt(); | |
144 | int nodePID=node.attribute("pid","0").toInt(); |
|
144 | int nodePID=node.attribute("pid","0").toInt(); | |
145 | if((nodeVID==VID)&&(nodePID==PID)) |
|
145 | if((nodeVID==VID)&&(nodePID==PID)) | |
146 | { |
|
146 | { | |
147 | return node.attribute("name","Unknow device"); |
|
147 | return node.attribute("name","Unknow device"); | |
148 | } |
|
148 | } | |
149 | } |
|
149 | } | |
150 | } |
|
150 | } | |
151 | return QString("Unknow device"); |
|
151 | return QString("Unknow device"); | |
152 | } |
|
152 | } | |
153 |
|
153 | |||
154 | QString SocExplorerEngine::SocExplorerVersion(){return QString(SOCEXPLORER_VERSION);} |
|
154 | QString SocExplorerEngine::SocExplorerVersion(){return QString(SOCEXPLORER_VERSION);} | |
155 |
|
155 | |||
156 | QString SocExplorerEngine::SocExplorerChangeset(){return QString(SOCEXPLORER_CHAGESET).split(" ").at(0);} |
|
156 | QString SocExplorerEngine::SocExplorerChangeset(){return QString(SOCEXPLORER_CHAGESET).split(" ").at(0);} | |
157 |
|
157 | |||
158 | QString SocExplorerEngine::SocExplorerBranch(){return QString(SOCEXPLORER_BRANCH);} |
|
158 | QString SocExplorerEngine::SocExplorerBranch(){return QString(SOCEXPLORER_BRANCH);} | |
159 |
|
159 | |||
160 | socExplorerXmlModel *SocExplorerEngine::xmlModel() |
|
160 | socExplorerXmlModel *SocExplorerEngine::xmlModel() | |
161 | { |
|
161 | { | |
162 | if(!_self) |
|
162 | if(!_self) | |
163 | init(); |
|
163 | init(); | |
164 | return p_xmlmodel; |
|
164 | return p_xmlmodel; | |
165 | } |
|
165 | } | |
166 |
|
166 | |||
167 | void SocExplorerEngine::setMainWindow(QMainWindow *Mainwindow) |
|
167 | void SocExplorerEngine::setMainWindow(QMainWindow *Mainwindow) | |
168 | { |
|
168 | { | |
169 | if(!_self) |
|
169 | if(!_self) | |
170 | init(); |
|
170 | init(); | |
171 | mainWindow=Mainwindow; |
|
171 | mainWindow=Mainwindow; | |
172 | } |
|
172 | } | |
173 |
|
173 | |||
174 | QProgressBar *SocExplorerEngine::getProgressBar(const QString& format, int max) |
|
174 | QProgressBar *SocExplorerEngine::getProgressBar(const QString& format, int max) | |
175 | { |
|
175 | { | |
176 | if(!_self) |
|
176 | if(!_self) | |
177 | init(); |
|
177 | init(); | |
178 | QProgressBar* progressBar; |
|
178 | QProgressBar* progressBar; | |
179 | if(mainWindow!=NULL) |
|
179 | if(mainWindow!=NULL) | |
180 | { |
|
180 | { | |
181 | progressBar = new QProgressBar(mainWindow); |
|
181 | progressBar = new QProgressBar(mainWindow); | |
182 | mainWindow->statusBar()->addWidget(progressBar); |
|
182 | mainWindow->statusBar()->addWidget(progressBar); | |
183 | } |
|
183 | } | |
184 | else |
|
184 | else | |
185 | { |
|
185 | { | |
186 | progressBar = new QProgressBar(); |
|
186 | progressBar = new QProgressBar(); | |
187 | } |
|
187 | } | |
188 | progressBar->setMaximum(max); |
|
188 | progressBar->setMaximum(max); | |
189 | progressBar->setFormat(format); |
|
189 | progressBar->setFormat(format); | |
190 | return progressBar; |
|
190 | return progressBar; | |
191 | } |
|
191 | } | |
192 |
|
192 | |||
193 | void SocExplorerEngine::deleteProgressBar(QProgressBar *progressBar) |
|
193 | void SocExplorerEngine::deleteProgressBar(QProgressBar *progressBar) | |
194 | { |
|
194 | { | |
195 | if(mainWindow!=NULL) |
|
195 | if(mainWindow!=NULL) | |
196 | { |
|
196 | { | |
197 | mainWindow->statusBar()->removeWidget(progressBar); |
|
197 | mainWindow->statusBar()->removeWidget(progressBar); | |
198 | } |
|
198 | } | |
199 | delete progressBar; |
|
199 | delete progressBar; | |
200 | } |
|
200 | } | |
201 |
|
201 | |||
202 | void SocExplorerEngine::addSOC(socexplorerplugin *rootPlugin) |
|
202 | void SocExplorerEngine::addSOC(socexplorerplugin *rootPlugin) | |
203 | { |
|
203 | { | |
204 | plugin2Soc(rootPlugin); |
|
204 | plugin2Soc(rootPlugin); | |
205 | } |
|
205 | } | |
206 |
|
206 | |||
207 | void SocExplorerEngine::removeSOC(socexplorerplugin *rootPlugin) |
|
207 | void SocExplorerEngine::removeSOC(socexplorerplugin *rootPlugin) | |
208 | { |
|
208 | { | |
209 | SOCModel* soc=plugin2Soc(rootPlugin); |
|
209 | SOCModel* soc=plugin2Soc(rootPlugin); | |
210 | SOCs->removeAll(soc); |
|
210 | SOCs->removeAll(soc); | |
211 | delete soc; |
|
211 | delete soc; | |
212 | } |
|
212 | } | |
213 |
|
213 | |||
214 | void SocExplorerEngine::message(socexplorerplugin *sender, const QString &message, int debugLevel) |
|
214 | void SocExplorerEngine::message(socexplorerplugin *sender, const QString &message, int debugLevel) | |
215 | { |
|
215 | { | |
216 | // TODO add multi output message manager IE also log in files |
|
216 | // TODO add multi output message manager IE also log in files | |
217 | if(!_self) |
|
217 | if(!_self) | |
218 | init(); |
|
218 | init(); | |
219 | if(loglvl>=debugLevel) |
|
219 | if(loglvl>=debugLevel) | |
220 | qDebug()<< QTime::currentTime().toString()+" " + sender->instanceName+":"+message; |
|
220 | qDebug()<< QTime::currentTime().toString()+" " + sender->instanceName()+":"+message; | |
221 | } |
|
221 | } | |
222 |
|
222 | |||
223 |
|
223 | |||
224 |
|
224 |
@@ -1,141 +1,142 | |||||
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, Laboratory of Plasmas Physic - CNRS |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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 "pluginmanagerWDGT.h" |
|
22 | #include "pluginmanagerWDGT.h" | |
23 | #include "pluginloader.h" |
|
23 | #include "pluginloader.h" | |
24 | #include <QFileDialog> |
|
24 | #include <QFileDialog> | |
25 | #include <unistd.h> |
|
25 | #include <unistd.h> | |
26 | #include <qsvgicon.h> |
|
26 | #include <qsvgicon.h> | |
27 | #include <socexplorerengine.h> |
|
27 | #include <socexplorerengine.h> | |
28 |
|
28 | |||
29 | #define mkbutton(button,text,image)button = new QPushButton();\ |
|
29 | #define mkbutton(button,text,image)button = new QPushButton();\ | |
30 | button->setIcon(QSvgIcon(image));\ |
|
30 | button->setIcon(QSvgIcon(image));\ | |
31 | button->setIconSize(QSize(16,16));\ |
|
31 | button->setIconSize(QSize(16,16));\ | |
32 | button->setToolTip(text) |
|
32 | button->setToolTip(text) | |
33 |
|
33 | |||
34 |
|
34 | |||
35 |
|
35 | |||
36 | pluginmanagerWDGT::pluginmanagerWDGT(QWidget *parent) : |
|
36 | pluginmanagerWDGT::pluginmanagerWDGT(QWidget *parent) : | |
37 | QSplitter(parent) |
|
37 | QSplitter(parent) | |
38 | { |
|
38 | { | |
39 | this->setWindowTitle("Plugin Manager"); |
|
39 | this->setWindowTitle("Plugin Manager"); | |
40 | this->setOrientation(Qt::Vertical); |
|
40 | this->setOrientation(Qt::Vertical); | |
41 | this->pluginListWidgetContainer = new QWidget(); |
|
41 | this->pluginListWidgetContainer = new QWidget(); | |
42 | this->mainlayoutSpliter = new QSplitter; |
|
42 | this->mainlayoutSpliter = new QSplitter; | |
43 | this->pluginListLayout = new QVBoxLayout(); |
|
43 | this->pluginListLayout = new QVBoxLayout(); | |
44 | this->mainlayoutSpliter->setOrientation(Qt::Vertical); |
|
44 | this->mainlayoutSpliter->setOrientation(Qt::Vertical); | |
45 | this->treeview = new plugintree(); |
|
45 | this->treeview = new plugintree(); | |
46 | this->pluginTable = new PluginList; |
|
46 | this->pluginTable = new PluginList; | |
47 | this->ButtonsLayout = new QHBoxLayout(); |
|
47 | this->ButtonsLayout = new QHBoxLayout(); | |
48 | this->ButtonsLayout->addStretch(); |
|
48 | this->ButtonsLayout->addStretch(); | |
49 | this->pluginListLayout->addLayout(this->ButtonsLayout); |
|
49 | this->pluginListLayout->addLayout(this->ButtonsLayout); | |
50 | this->addWidget(this->treeview); |
|
50 | this->addWidget(this->treeview); | |
51 | this->pluginListWidgetContainer->setLayout(this->pluginListLayout); |
|
51 | this->pluginListWidgetContainer->setLayout(this->pluginListLayout); | |
52 | this->addWidget(this->pluginListWidgetContainer); |
|
52 | this->addWidget(this->pluginListWidgetContainer); | |
53 | this->pluginListLayout->addWidget(this->pluginTable); |
|
53 | this->pluginListLayout->addWidget(this->pluginTable); | |
54 | this->pluginInfos = new pluginInfosWdgt; |
|
54 | this->pluginInfos = new pluginInfosWdgt; | |
55 |
|
55 | |||
56 | mkbutton(this->addPluginBt,tr("add plugin"),":/images/open.svg"); |
|
56 | mkbutton(this->addPluginBt,tr("add plugin"),":/images/open.svg"); | |
57 | mkbutton(this->removePluginBt,tr("remove plugin(s)"),":/images/trash.svg"); |
|
57 | mkbutton(this->removePluginBt,tr("remove plugin(s)"),":/images/trash.svg"); | |
58 | mkbutton(this->refreshPluginListBt,tr("Refresh Plugin(s) list"),":/images/refresh.svg"); |
|
58 | mkbutton(this->refreshPluginListBt,tr("Refresh Plugin(s) list"),":/images/refresh.svg"); | |
59 |
|
59 | |||
60 | this->ButtonsLayout->addWidget(this->addPluginBt); |
|
60 | this->ButtonsLayout->addWidget(this->addPluginBt); | |
61 | this->ButtonsLayout->addWidget(this->refreshPluginListBt); |
|
61 | this->ButtonsLayout->addWidget(this->refreshPluginListBt); | |
62 | this->ButtonsLayout->addWidget(this->removePluginBt); |
|
62 | this->ButtonsLayout->addWidget(this->removePluginBt); | |
63 |
|
63 | |||
64 | this->addWidget(this->pluginInfos); |
|
64 | this->addWidget(this->pluginInfos); | |
65 |
|
65 | |||
66 | connect(this->treeview,SIGNAL(geteplugintree()),this,SIGNAL(geteplugintree())); |
|
66 | connect(this->treeview,SIGNAL(geteplugintree()),this,SIGNAL(geteplugintree())); | |
67 | connect(this,SIGNAL(treeChanged(QList<socexplorerplugin*>)),this->treeview,SLOT(treeChanged(QList<socexplorerplugin*>))); |
|
67 | connect(this,SIGNAL(treeChanged(QList<socexplorerplugin*>)),this->treeview,SLOT(treeChanged(QList<socexplorerplugin*>))); | |
68 | connect(this->pluginTable,SIGNAL(currentRowChanged(int)),this,SLOT(libselected(int))); |
|
68 | connect(this->pluginTable,SIGNAL(currentRowChanged(int)),this,SLOT(libselected(int))); | |
69 | connect(this->pluginTable,SIGNAL(itemSelectionChanged(QStringList)),this->pluginInfos,SLOT(updateInfos(QStringList))); |
|
69 | connect(this->pluginTable,SIGNAL(itemSelectionChanged(QStringList)),this->pluginInfos,SLOT(updateInfos(QStringList))); | |
70 | connect(this->addPluginBt,SIGNAL(clicked()),this,SLOT(addPlugin())); |
|
70 | connect(this->addPluginBt,SIGNAL(clicked()),this,SLOT(addPlugin())); | |
71 | connect(this->removePluginBt,SIGNAL(clicked()),this,SLOT(removePlugin())); |
|
71 | connect(this->removePluginBt,SIGNAL(clicked()),this,SLOT(removePlugin())); | |
72 | connect(this->pluginTable,SIGNAL(itemDoubleClicked(QListWidgetItem*)),this,SLOT(loadplugin(QListWidgetItem*))); |
|
72 | connect(this->pluginTable,SIGNAL(itemDoubleClicked(QListWidgetItem*)),this,SLOT(loadplugin(QListWidgetItem*))); | |
73 | connect(this->refreshPluginListBt,SIGNAL(clicked()),this->pluginTable,SLOT(refreshPluginList())); |
|
73 | connect(this->refreshPluginListBt,SIGNAL(clicked()),this->pluginTable,SLOT(refreshPluginList())); | |
74 | connect(this->treeview,SIGNAL(loadSysDriver(QString)),this,SIGNAL(loadSysDrviver(QString))); |
|
74 | connect(this->treeview,SIGNAL(loadSysDriver(QString)),this,SIGNAL(loadSysDrviver(QString))); | |
75 | connect(this->treeview,SIGNAL(loadSysDriverToParent(QString,QString)),this,SIGNAL(loadSysDriverToParent(QString,QString))); |
|
75 | connect(this->treeview,SIGNAL(loadSysDriverToParent(QString,QString)),this,SIGNAL(loadSysDriverToParent(QString,QString))); | |
76 | connect(this->treeview,SIGNAL(changeSysDriverInstName(QString,QString)),this,SIGNAL(changeSysDriverInstName(QString,QString))); |
|
76 | connect(this->treeview,SIGNAL(changeSysDriverInstName(QString,QString)),this,SIGNAL(changeSysDriverInstName(QString,QString))); | |
77 | connect(this->treeview,SIGNAL(closeSysDriver(QString)),this,SIGNAL(closeSysDriver(QString))); |
|
77 | connect(this->treeview,SIGNAL(closeSysDriver(QString)),this,SIGNAL(closeSysDriver(QString))); | |
|
78 | connect(this->treeview,SIGNAL(pluginselected(QString)),this,SIGNAL(pluginselected(QString))); | |||
78 | this->rootLoadable = false; |
|
79 | this->rootLoadable = false; | |
79 | this->childLoadable = false; |
|
80 | this->childLoadable = false; | |
80 | this->pluginTable->refreshPluginList(); |
|
81 | this->pluginTable->refreshPluginList(); | |
81 | this->pluginTable->refreshPluginList(); |
|
82 | this->pluginTable->refreshPluginList(); | |
82 | } |
|
83 | } | |
83 |
|
84 | |||
84 |
|
85 | |||
85 | void pluginmanagerWDGT::setRootLoadable(bool flag) |
|
86 | void pluginmanagerWDGT::setRootLoadable(bool flag) | |
86 | { |
|
87 | { | |
87 | this->rootLoadable = flag; |
|
88 | this->rootLoadable = flag; | |
88 | } |
|
89 | } | |
89 |
|
90 | |||
90 |
|
91 | |||
91 | void pluginmanagerWDGT::setChildLoadable(bool flag) |
|
92 | void pluginmanagerWDGT::setChildLoadable(bool flag) | |
92 | { |
|
93 | { | |
93 | this->childLoadable = flag; |
|
94 | this->childLoadable = flag; | |
94 | } |
|
95 | } | |
95 |
|
96 | |||
96 |
|
97 | |||
97 |
|
98 | |||
98 |
|
99 | |||
99 | void pluginmanagerWDGT::addPlugin() |
|
100 | void pluginmanagerWDGT::addPlugin() | |
100 | { |
|
101 | { | |
101 | QString fileName = QFileDialog::getOpenFileName(this,tr("Open Plugin"), QDir::homePath(), tr("Plugin Files Files (*.dll *.so *.so.*)")); |
|
102 | QString fileName = QFileDialog::getOpenFileName(this,tr("Open Plugin"), QDir::homePath(), tr("Plugin Files Files (*.dll *.so *.so.*)")); | |
102 | if(pluginloader::checklibrary(fileName)) |
|
103 | if(pluginloader::checklibrary(fileName)) | |
103 | { |
|
104 | { | |
104 | QFile::copy(fileName,QString(SocExplorerEngine::pluginFolder())+"/"+ fileName.section('/',-1)); |
|
105 | QFile::copy(fileName,QString(SocExplorerEngine::pluginFolder())+"/"+ fileName.section('/',-1)); | |
105 | } |
|
106 | } | |
106 | this->pluginTable->refreshPluginList(); |
|
107 | this->pluginTable->refreshPluginList(); | |
107 | } |
|
108 | } | |
108 |
|
109 | |||
109 |
|
110 | |||
110 | void pluginmanagerWDGT::removePlugin() |
|
111 | void pluginmanagerWDGT::removePlugin() | |
111 | { |
|
112 | { | |
112 | for(int i=0;i<this->pluginTable->selectedItems().count();i++) |
|
113 | for(int i=0;i<this->pluginTable->selectedItems().count();i++) | |
113 | { |
|
114 | { | |
114 | QListWidgetItem* item = this->pluginTable->selectedItems().at(i); |
|
115 | QListWidgetItem* item = this->pluginTable->selectedItems().at(i); | |
115 | if(item!=NULL) |
|
116 | if(item!=NULL) | |
116 | { |
|
117 | { | |
117 | QFile::remove(QString(SocExplorerEngine::pluginFolder())+"/"+item->text()); |
|
118 | QFile::remove(QString(SocExplorerEngine::pluginFolder())+"/"+item->text()); | |
118 | } |
|
119 | } | |
119 | } |
|
120 | } | |
120 | this->pluginTable->refreshPluginList(); |
|
121 | this->pluginTable->refreshPluginList(); | |
121 | } |
|
122 | } | |
122 |
|
123 | |||
123 |
|
124 | |||
124 |
|
125 | |||
125 | void pluginmanagerWDGT::loadplugin() |
|
126 | void pluginmanagerWDGT::loadplugin() | |
126 | { |
|
127 | { | |
127 | for(int i=0;i<this->pluginTable->selectedItems().count();i++) |
|
128 | for(int i=0;i<this->pluginTable->selectedItems().count();i++) | |
128 | { |
|
129 | { | |
129 | QListWidgetItem* item = this->pluginTable->selectedItems().at(i); |
|
130 | QListWidgetItem* item = this->pluginTable->selectedItems().at(i); | |
130 | if(item!=NULL) |
|
131 | if(item!=NULL) | |
131 | { |
|
132 | { | |
132 | QString plugin = QString(SocExplorerEngine::pluginFolder())+"/"+item->text(); |
|
133 | QString plugin = QString(SocExplorerEngine::pluginFolder())+"/"+item->text(); | |
133 | emit this->loadSysDrviver(plugin); |
|
134 | emit this->loadSysDrviver(plugin); | |
134 | } |
|
135 | } | |
135 | } |
|
136 | } | |
136 | this->pluginTable->refreshPluginList(); |
|
137 | this->pluginTable->refreshPluginList(); | |
137 | } |
|
138 | } | |
138 |
|
139 | |||
139 |
|
140 | |||
140 |
|
141 | |||
141 |
|
142 |
@@ -1,92 +1,94 | |||||
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, Laboratory of Plasmas Physic - CNRS |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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 | #ifndef PLUGINMANAGERWDGT_H |
|
22 | #ifndef PLUGINMANAGERWDGT_H | |
23 | #define PLUGINMANAGERWDGT_H |
|
23 | #define PLUGINMANAGERWDGT_H | |
24 |
|
24 | |||
25 | #include <QApplication> |
|
25 | #include <QApplication> | |
26 | #include <QWidget> |
|
26 | #include <QWidget> | |
27 | #include <QDockWidget> |
|
27 | #include <QDockWidget> | |
28 | #include <QVBoxLayout> |
|
28 | #include <QVBoxLayout> | |
29 | #include <QHBoxLayout> |
|
29 | #include <QHBoxLayout> | |
30 | #include <QTableWidget> |
|
30 | #include <QTableWidget> | |
31 | #include <QDir> |
|
31 | #include <QDir> | |
32 | #include <QStringList> |
|
32 | #include <QStringList> | |
33 | #include <QFileInfoList> |
|
33 | #include <QFileInfoList> | |
34 | #include <QFileInfo> |
|
34 | #include <QFileInfo> | |
35 | #include <QTextEdit> |
|
35 | #include <QTextEdit> | |
36 | #include <QPushButton> |
|
36 | #include <QPushButton> | |
37 | #include <QSplitter> |
|
37 | #include <QSplitter> | |
38 | #include "plugininfoswdgt.h" |
|
38 | #include "plugininfoswdgt.h" | |
39 | #include "pluginlist.h" |
|
39 | #include "pluginlist.h" | |
40 | #include <socexplorerplugin.h> |
|
40 | #include <socexplorerplugin.h> | |
41 | #include <QList> |
|
41 | #include <QList> | |
42 | #include "plugintree.h" |
|
42 | #include "plugintree.h" | |
43 |
|
43 | |||
44 | #if defined(SOCEXPLORER_SDK_BUILD) |
|
44 | #if defined(SOCEXPLORER_SDK_BUILD) | |
45 | # define SOCEXPLORER_SDK_EXPORT Q_DECL_EXPORT |
|
45 | # define SOCEXPLORER_SDK_EXPORT Q_DECL_EXPORT | |
46 | #else |
|
46 | #else | |
47 | # define SOCEXPLORER_SDK_EXPORT Q_DECL_IMPORT |
|
47 | # define SOCEXPLORER_SDK_EXPORT Q_DECL_IMPORT | |
48 | #endif |
|
48 | #endif | |
49 |
|
49 | |||
50 | class pluginmanagerWDGT : public QSplitter |
|
50 | class pluginmanagerWDGT : public QSplitter | |
51 | { |
|
51 | { | |
52 | Q_OBJECT |
|
52 | Q_OBJECT | |
53 | public: |
|
53 | public: | |
54 | SOCEXPLORER_SDK_EXPORT explicit pluginmanagerWDGT(QWidget *parent = 0); |
|
54 | SOCEXPLORER_SDK_EXPORT explicit pluginmanagerWDGT(QWidget *parent = 0); | |
55 | SOCEXPLORER_SDK_EXPORT void setRootLoadable(bool flag); |
|
55 | SOCEXPLORER_SDK_EXPORT void setRootLoadable(bool flag); | |
56 | SOCEXPLORER_SDK_EXPORT void setChildLoadable(bool flag); |
|
56 | SOCEXPLORER_SDK_EXPORT void setChildLoadable(bool flag); | |
57 |
|
57 | |||
58 | signals: |
|
58 | signals: | |
59 | void updatepluginInfo(const QString libname); |
|
59 | void updatepluginInfo(const QString libname); | |
60 | void loadSysDrviver(const QString name); |
|
60 | void loadSysDrviver(const QString name); | |
61 | void loadSysDriverToParent(const QString name, const QString instanceName); |
|
61 | void loadSysDriverToParent(const QString name, const QString instanceName); | |
62 | void geteplugintree(void); |
|
62 | void geteplugintree(void); | |
63 | void treeChanged(const QList<socexplorerplugin*>& drivers); |
|
63 | void treeChanged(const QList<socexplorerplugin*>& drivers); | |
64 | void changeSysDriverInstName(const QString newinstanceName,const QString previnstanceName); |
|
64 | void changeSysDriverInstName(const QString newinstanceName,const QString previnstanceName); | |
65 | void closeSysDriver(const QString instanceName); |
|
65 | void closeSysDriver(const QString instanceName); | |
|
66 | void pluginselected(const QString& instanceName); | |||
|
67 | ||||
66 | public slots: |
|
68 | public slots: | |
67 | //void libselected(int row); |
|
69 | //void libselected(int row); | |
68 | void addPlugin(); |
|
70 | void addPlugin(); | |
69 | void removePlugin(); |
|
71 | void removePlugin(); | |
70 | void loadplugin(); |
|
72 | void loadplugin(); | |
71 | //void loadplugin(QListWidgetItem*); |
|
73 | //void loadplugin(QListWidgetItem*); | |
72 |
|
74 | |||
73 | private: |
|
75 | private: | |
74 |
|
76 | |||
75 | bool rootLoadable; |
|
77 | bool rootLoadable; | |
76 | bool childLoadable; |
|
78 | bool childLoadable; | |
77 | QWidget* pluginListWidgetContainer; |
|
79 | QWidget* pluginListWidgetContainer; | |
78 | QVBoxLayout* pluginListLayout; |
|
80 | QVBoxLayout* pluginListLayout; | |
79 | QHBoxLayout* ButtonsLayout; |
|
81 | QHBoxLayout* ButtonsLayout; | |
80 | QSplitter* mainlayoutSpliter; |
|
82 | QSplitter* mainlayoutSpliter; | |
81 | PluginList* pluginTable; |
|
83 | PluginList* pluginTable; | |
82 | pluginInfosWdgt* pluginInfos; |
|
84 | pluginInfosWdgt* pluginInfos; | |
83 | plugintree* treeview; |
|
85 | plugintree* treeview; | |
84 | QPushButton* addPluginBt; |
|
86 | QPushButton* addPluginBt; | |
85 | QPushButton* removePluginBt; |
|
87 | QPushButton* removePluginBt; | |
86 | QPushButton* loadPluginBt; |
|
88 | QPushButton* loadPluginBt; | |
87 | QPushButton* refreshPluginListBt; |
|
89 | QPushButton* refreshPluginListBt; | |
88 |
|
90 | |||
89 |
|
91 | |||
90 | }; |
|
92 | }; | |
91 |
|
93 | |||
92 | #endif // PLUGINMANAGERWDGT_H |
|
94 | #endif // PLUGINMANAGERWDGT_H |
@@ -1,210 +1,219 | |||||
1 | #include "plugintree.h" |
|
1 | #include "plugintree.h" | |
2 | #include "pluginloader.h" |
|
2 | #include "pluginloader.h" | |
3 | #include <QApplication> |
|
3 | #include <QApplication> | |
4 | #include "qsvgicon.h" |
|
4 | #include "qsvgicon.h" | |
5 | #include <QHeaderView> |
|
5 | #include <QHeaderView> | |
6 | #include <QString> |
|
6 | #include <QString> | |
7 |
|
7 | |||
8 | plugintree::plugintree(QWidget *parent) : |
|
8 | plugintree::plugintree(QWidget *parent) : | |
9 | QTreeWidget(parent) |
|
9 | QTreeWidget(parent) | |
10 | { |
|
10 | { | |
11 | this->editingItem=false; |
|
11 | this->editingItem=false; | |
12 | this->editeditemprev=new QString; |
|
12 | this->editeditemprev=new QString; | |
13 | this->setAcceptDrops(true); |
|
13 | this->setAcceptDrops(true); | |
14 | this->setDragDropMode(QAbstractItemView::DropOnly); |
|
14 | this->setDragDropMode(QAbstractItemView::DropOnly); | |
15 | connect(this,SIGNAL(itemChanged(QTreeWidgetItem*,int)),this,SLOT(pluginselectedslt(QTreeWidgetItem*,int))); |
|
15 | connect(this,SIGNAL(itemChanged(QTreeWidgetItem*,int)),this,SLOT(pluginselectedslt(QTreeWidgetItem*,int))); | |
|
16 | connect(this,SIGNAL(itemSelectionChanged()),this,SLOT(itemSelectionChangedslt())); | |||
16 | this->setHeaderLabels(QStringList()<<"Loaded plugins"); |
|
17 | this->setHeaderLabels(QStringList()<<"Loaded plugins"); | |
17 | emit this->geteplugintree(); |
|
18 | emit this->geteplugintree(); | |
18 | } |
|
19 | } | |
19 |
|
20 | |||
20 |
|
21 | |||
21 | void plugintree::pluginselectedslt(QTreeWidgetItem *item, int column) |
|
22 | void plugintree::pluginselectedslt(QTreeWidgetItem *item, int column) | |
22 | { |
|
23 | { | |
23 | Q_UNUSED(column) |
|
24 | Q_UNUSED(column) | |
24 | emit this->pluginselected(item->text(0)); |
|
25 | emit this->pluginselected(item->text(0)); | |
25 | } |
|
26 | } | |
26 |
|
27 | |||
|
28 | void plugintree::itemSelectionChangedslt() | |||
|
29 | { | |||
|
30 | if(this->selectedItems().count()==1) | |||
|
31 | { | |||
|
32 | emit this->pluginselected(this->selectedItems().first()->text(0)); | |||
|
33 | } | |||
|
34 | } | |||
|
35 | ||||
27 | void plugintree::treeChanged(const QList<socexplorerplugin*>& drivers) |
|
36 | void plugintree::treeChanged(const QList<socexplorerplugin*>& drivers) | |
28 | { |
|
37 | { | |
29 | this->clear(); |
|
38 | this->clear(); | |
30 | for(int i=0;i<drivers.count();i++) |
|
39 | for(int i=0;i<drivers.count();i++) | |
31 | { |
|
40 | { | |
32 | QTreeWidgetItem* currentItem=new QTreeWidgetItem; |
|
41 | QTreeWidgetItem* currentItem=new QTreeWidgetItem; | |
33 | currentItem->setIcon(0,QSvgIcon(":/images/server.svg")); |
|
42 | currentItem->setIcon(0,QSvgIcon(":/images/server.svg")); | |
34 | currentItem->setText(0,drivers.at(i)->instanceName); |
|
43 | currentItem->setText(0,drivers.at(i)->instanceName()); | |
35 | this->addTopLevelItem(currentItem); |
|
44 | this->addTopLevelItem(currentItem); | |
36 | if(drivers.at(i)->childs.count()!=0) |
|
45 | if(drivers.at(i)->childs.count()!=0) | |
37 | { |
|
46 | { | |
38 | this->addplugin(drivers.at(i),currentItem); |
|
47 | this->addplugin(drivers.at(i),currentItem); | |
39 | } |
|
48 | } | |
40 | currentItem->setExpanded(true); |
|
49 | currentItem->setExpanded(true); | |
41 | } |
|
50 | } | |
42 | } |
|
51 | } | |
43 |
|
52 | |||
44 | void plugintree::addplugin(socexplorerplugin *driver, QTreeWidgetItem *item) |
|
53 | void plugintree::addplugin(socexplorerplugin *driver, QTreeWidgetItem *item) | |
45 | { |
|
54 | { | |
46 |
|
55 | |||
47 | for(int i=0;i<driver->childs.count();i++) |
|
56 | for(int i=0;i<driver->childs.count();i++) | |
48 | { |
|
57 | { | |
49 | QTreeWidgetItem* currentItem=new QTreeWidgetItem; |
|
58 | QTreeWidgetItem* currentItem=new QTreeWidgetItem; | |
50 | currentItem->setIcon(0,QSvgIcon(":/images/server.svg")); |
|
59 | currentItem->setIcon(0,QSvgIcon(":/images/server.svg")); | |
51 | currentItem->setText(0,driver->childs.at(i)->instanceName); |
|
60 | currentItem->setText(0,driver->childs.at(i)->instanceName()); | |
52 | item->addChild(currentItem); |
|
61 | item->addChild(currentItem); | |
53 | if(driver->childs.at(i)->childs.count()!=0) |
|
62 | if(driver->childs.at(i)->childs.count()!=0) | |
54 | { |
|
63 | { | |
55 | this->addplugin(driver->childs.at(i),currentItem); |
|
64 | this->addplugin(driver->childs.at(i),currentItem); | |
56 | } |
|
65 | } | |
57 | currentItem->setExpanded(true); |
|
66 | currentItem->setExpanded(true); | |
58 | } |
|
67 | } | |
59 |
|
68 | |||
60 | } |
|
69 | } | |
61 |
|
70 | |||
62 |
|
71 | |||
63 |
|
72 | |||
64 |
|
73 | |||
65 | void plugintree::dragEnterEvent(QDragEnterEvent *event) |
|
74 | void plugintree::dragEnterEvent(QDragEnterEvent *event) | |
66 | { |
|
75 | { | |
67 | if (event->mimeData()->hasFormat("socexplorer/pluginName")) |
|
76 | if (event->mimeData()->hasFormat("socexplorer/pluginName")) | |
68 | { |
|
77 | { | |
69 |
|
78 | |||
70 | if(pluginloader::isvalid(event->mimeData()->text())) |
|
79 | if(pluginloader::isvalid(event->mimeData()->text())) | |
71 | { |
|
80 | { | |
72 | event->acceptProposedAction(); |
|
81 | event->acceptProposedAction(); | |
73 | }else |
|
82 | }else | |
74 | { |
|
83 | { | |
75 | event->ignore(); |
|
84 | event->ignore(); | |
76 | } |
|
85 | } | |
77 |
|
86 | |||
78 | } else |
|
87 | } else | |
79 | { |
|
88 | { | |
80 | event->ignore(); |
|
89 | event->ignore(); | |
81 | } |
|
90 | } | |
82 | } |
|
91 | } | |
83 |
|
92 | |||
84 | void plugintree::dragMoveEvent(QDragMoveEvent *event) |
|
93 | void plugintree::dragMoveEvent(QDragMoveEvent *event) | |
85 | { |
|
94 | { | |
86 | if (event->mimeData()->hasFormat("socexplorer/pluginName")) |
|
95 | if (event->mimeData()->hasFormat("socexplorer/pluginName")) | |
87 | { |
|
96 | { | |
88 |
|
97 | |||
89 | if(pluginloader::isvalid(event->mimeData()->text())) |
|
98 | if(pluginloader::isvalid(event->mimeData()->text())) | |
90 | { |
|
99 | { | |
91 | this->clearSelection(); |
|
100 | this->clearSelection(); | |
92 | if(this->itemAt(event->pos())!=NULL) |
|
101 | if(this->itemAt(event->pos())!=NULL) | |
93 | { |
|
102 | { | |
94 | this->itemAt(event->pos())->setSelected(true); |
|
103 | this->itemAt(event->pos())->setSelected(true); | |
95 | event->acceptProposedAction(); |
|
104 | event->acceptProposedAction(); | |
96 | } |
|
105 | } | |
97 | else |
|
106 | else | |
98 | if(pluginloader::libcanberoot(event->mimeData()->text())) |
|
107 | if(pluginloader::libcanberoot(event->mimeData()->text())) | |
99 | { |
|
108 | { | |
100 | event->acceptProposedAction(); |
|
109 | event->acceptProposedAction(); | |
101 | } |
|
110 | } | |
102 | else |
|
111 | else | |
103 | { |
|
112 | { | |
104 | event->ignore(); |
|
113 | event->ignore(); | |
105 | } |
|
114 | } | |
106 | }else |
|
115 | }else | |
107 | { |
|
116 | { | |
108 | event->ignore(); |
|
117 | event->ignore(); | |
109 | } |
|
118 | } | |
110 |
|
119 | |||
111 | } else |
|
120 | } else | |
112 | { |
|
121 | { | |
113 | event->ignore(); |
|
122 | event->ignore(); | |
114 | } |
|
123 | } | |
115 | } |
|
124 | } | |
116 |
|
125 | |||
117 |
|
126 | |||
118 | void plugintree::mouseDoubleClickEvent(QMouseEvent *event) |
|
127 | void plugintree::mouseDoubleClickEvent(QMouseEvent *event) | |
119 | { |
|
128 | { | |
120 | this->clearSelection(); |
|
129 | this->clearSelection(); | |
121 | this->editeditem=this->itemAt(event->pos()); |
|
130 | this->editeditem=this->itemAt(event->pos()); | |
122 | if(this->editeditem!=NULL && this->editingItem==false) |
|
131 | if(this->editeditem!=NULL && this->editingItem==false) | |
123 | { |
|
132 | { | |
124 | *this->editeditemprev=this->editeditem->text(0); |
|
133 | *this->editeditemprev=this->editeditem->text(0); | |
125 | this->openPersistentEditor(this->editeditem); |
|
134 | this->openPersistentEditor(this->editeditem); | |
126 | this->editingItem=true; |
|
135 | this->editingItem=true; | |
127 | } |
|
136 | } | |
128 | QTreeWidget::mouseDoubleClickEvent(event); |
|
137 | QTreeWidget::mouseDoubleClickEvent(event); | |
129 | } |
|
138 | } | |
130 |
|
139 | |||
131 | void plugintree::mousePressEvent(QMouseEvent *event) |
|
140 | void plugintree::mousePressEvent(QMouseEvent *event) | |
132 | { |
|
141 | { | |
133 | QTreeWidget::mousePressEvent(event); |
|
142 | QTreeWidget::mousePressEvent(event); | |
134 | if(this->editingItem==true && this->editeditem!=this->itemAt(event->pos())) |
|
143 | if(this->editingItem==true && this->editeditem!=this->itemAt(event->pos())) | |
135 | { |
|
144 | { | |
136 | this->closePersistentEditor(this->editeditem); |
|
145 | this->closePersistentEditor(this->editeditem); | |
137 | if(QString::compare(this->editeditem->text(0),this->editeditemprev)) |
|
146 | if(QString::compare(this->editeditem->text(0),this->editeditemprev)) | |
138 | { |
|
147 | { | |
139 | emit this->changeSysDriverInstName(this->editeditem->text(0),QString(*this->editeditemprev)); |
|
148 | emit this->changeSysDriverInstName(this->editeditem->text(0),QString(*this->editeditemprev)); | |
140 | } |
|
149 | } | |
141 | this->editingItem=false; |
|
150 | this->editingItem=false; | |
142 | } |
|
151 | } | |
143 | } |
|
152 | } | |
144 |
|
153 | |||
145 |
|
154 | |||
146 | void plugintree::keyPressEvent(QKeyEvent *event) |
|
155 | void plugintree::keyPressEvent(QKeyEvent *event) | |
147 | { |
|
156 | { | |
148 |
|
157 | |||
149 | { |
|
158 | { | |
150 | switch(event->key()) |
|
159 | switch(event->key()) | |
151 | { |
|
160 | { | |
152 | case Qt::Key_Return: |
|
161 | case Qt::Key_Return: | |
153 | if(this->editingItem==true) |
|
162 | if(this->editingItem==true) | |
154 | { |
|
163 | { | |
155 | this->closePersistentEditor(this->editeditem); |
|
164 | this->closePersistentEditor(this->editeditem); | |
156 | if(QString::compare(this->editeditem->text(0),this->editeditemprev)) |
|
165 | if(QString::compare(this->editeditem->text(0),this->editeditemprev)) | |
157 | { |
|
166 | { | |
158 | emit this->changeSysDriverInstName(this->editeditem->text(0),QString(*this->editeditemprev)); |
|
167 | emit this->changeSysDriverInstName(this->editeditem->text(0),QString(*this->editeditemprev)); | |
159 | } |
|
168 | } | |
160 | this->editingItem=false; |
|
169 | this->editingItem=false; | |
161 | } |
|
170 | } | |
162 |
|
171 | |||
163 | break; |
|
172 | break; | |
164 | case Qt::Key_Delete: |
|
173 | case Qt::Key_Delete: | |
165 | if(this->selectedItems().count()==1) |
|
174 | if(this->selectedItems().count()==1) | |
166 | { |
|
175 | { | |
167 | emit this->closeSysDriver(this->selectedItems().first()->text(0)); |
|
176 | emit this->closeSysDriver(this->selectedItems().first()->text(0)); | |
168 | } |
|
177 | } | |
169 | break; |
|
178 | break; | |
170 | default: |
|
179 | default: | |
171 | break; |
|
180 | break; | |
172 | } |
|
181 | } | |
173 | } |
|
182 | } | |
174 | } |
|
183 | } | |
175 |
|
184 | |||
176 |
|
185 | |||
177 | void plugintree::dropEvent(QDropEvent *event) |
|
186 | void plugintree::dropEvent(QDropEvent *event) | |
178 | { |
|
187 | { | |
179 | if (event->mimeData()->hasFormat("socexplorer/pluginName")) |
|
188 | if (event->mimeData()->hasFormat("socexplorer/pluginName")) | |
180 | { |
|
189 | { | |
181 | QTreeWidgetItem* item=this->itemAt(event->pos()); |
|
190 | QTreeWidgetItem* item=this->itemAt(event->pos()); | |
182 | if(item!=NULL) |
|
191 | if(item!=NULL) | |
183 | { |
|
192 | { | |
184 | emit this->loadSysDriverToParent(event->mimeData()->text(),item->text(0)); |
|
193 | emit this->loadSysDriverToParent(event->mimeData()->text(),item->text(0)); | |
185 | event->acceptProposedAction(); |
|
194 | event->acceptProposedAction(); | |
186 | } |
|
195 | } | |
187 | else if(pluginloader::libcanberoot(event->mimeData()->text())) |
|
196 | else if(pluginloader::libcanberoot(event->mimeData()->text())) | |
188 | { |
|
197 | { | |
189 | QString test(event->mimeData()->text()); |
|
198 | QString test(event->mimeData()->text()); | |
190 | emit this->loadSysDriver(event->mimeData()->text()); |
|
199 | emit this->loadSysDriver(event->mimeData()->text()); | |
191 | } |
|
200 | } | |
192 | if (event->source() == this) |
|
201 | if (event->source() == this) | |
193 | { |
|
202 | { | |
194 | event->setDropAction(Qt::MoveAction); |
|
203 | event->setDropAction(Qt::MoveAction); | |
195 | event->accept(); |
|
204 | event->accept(); | |
196 | } else { |
|
205 | } else { | |
197 | if(pluginloader::checklibrary(event->mimeData()->text())!=0) //lib ok |
|
206 | if(pluginloader::checklibrary(event->mimeData()->text())!=0) //lib ok | |
198 | { |
|
207 | { | |
199 | if(pluginloader::libcanberoot(event->mimeData()->text())) |
|
208 | if(pluginloader::libcanberoot(event->mimeData()->text())) | |
200 | event->acceptProposedAction(); |
|
209 | event->acceptProposedAction(); | |
201 | } |
|
210 | } | |
202 | } |
|
211 | } | |
203 | } else |
|
212 | } else | |
204 | { |
|
213 | { | |
205 | event->ignore(); |
|
214 | event->ignore(); | |
206 | } |
|
215 | } | |
207 | } |
|
216 | } | |
208 |
|
217 | |||
209 |
|
218 | |||
210 |
|
219 |
@@ -1,73 +1,73 | |||||
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, Laboratory of Plasmas Physic - CNRS |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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 | #ifndef PLUGINTREE_H |
|
22 | #ifndef PLUGINTREE_H | |
23 | #define PLUGINTREE_H |
|
23 | #define PLUGINTREE_H | |
24 |
|
24 | |||
25 | #include <QWidget> |
|
25 | #include <QWidget> | |
26 | #include <QTreeWidget> |
|
26 | #include <QTreeWidget> | |
27 | #include <socexplorerplugin.h> |
|
27 | #include <socexplorerplugin.h> | |
28 | #include <QList> |
|
28 | #include <QList> | |
29 | #include <QtGui/QDragEnterEvent> |
|
29 | #include <QtGui/QDragEnterEvent> | |
30 | #include <QtGui/QDragLeaveEvent> |
|
30 | #include <QtGui/QDragLeaveEvent> | |
31 | #include <QtGui/QDragMoveEvent> |
|
31 | #include <QtGui/QDragMoveEvent> | |
32 | #include <QtGui/QDropEvent> |
|
32 | #include <QtGui/QDropEvent> | |
33 | #include <QtCore/QMimeData> |
|
33 | #include <QtCore/QMimeData> | |
34 | #include <QtCore/QUrl> |
|
34 | #include <QtCore/QUrl> | |
35 | #include <QtCore/QList> |
|
35 | #include <QtCore/QList> | |
36 | #include <QPoint> |
|
36 | #include <QPoint> | |
37 | #include <QLabel> |
|
37 | #include <QLabel> | |
38 |
|
38 | |||
39 | class plugintree : public QTreeWidget |
|
39 | class plugintree : public QTreeWidget | |
40 | { |
|
40 | { | |
41 | Q_OBJECT |
|
41 | Q_OBJECT | |
42 | public: |
|
42 | public: | |
43 | explicit plugintree(QWidget *parent = 0); |
|
43 | explicit plugintree(QWidget *parent = 0); | |
44 |
|
44 | |||
45 | protected: |
|
45 | protected: | |
46 | void dragEnterEvent(QDragEnterEvent *event); |
|
46 | void dragEnterEvent(QDragEnterEvent *event); | |
47 | void dragMoveEvent(QDragMoveEvent *event); |
|
47 | void dragMoveEvent(QDragMoveEvent *event); | |
48 | void dropEvent(QDropEvent *event); |
|
48 | void dropEvent(QDropEvent *event); | |
49 | void mousePressEvent(QMouseEvent *event); |
|
49 | void mousePressEvent(QMouseEvent *event); | |
50 | void mouseDoubleClickEvent(QMouseEvent *event); |
|
50 | void mouseDoubleClickEvent(QMouseEvent *event); | |
51 | void keyPressEvent(QKeyEvent *event); |
|
51 | void keyPressEvent(QKeyEvent *event); | |
52 |
|
52 | |||
53 | signals: |
|
53 | signals: | |
54 | void geteplugintree(void); |
|
54 | void geteplugintree(void); | |
55 | void pluginselected(const QString& Name); |
|
55 | void pluginselected(const QString& Name); | |
56 | void loadSysDriverToParent(const QString name, const QString instanceName); |
|
56 | void loadSysDriverToParent(const QString name, const QString instanceName); | |
57 | void loadSysDriver(const QString name); |
|
57 | void loadSysDriver(const QString name); | |
58 | void closeSysDriver(const QString instanceName); |
|
58 | void closeSysDriver(const QString instanceName); | |
59 | void changeSysDriverInstName(const QString instanceName); |
|
59 | void changeSysDriverInstName(const QString instanceName); | |
60 | void changeSysDriverInstName(const QString newinstanceName,const QString previnstanceName); |
|
60 | void changeSysDriverInstName(const QString newinstanceName,const QString previnstanceName); | |
61 | public slots: |
|
61 | public slots: | |
62 | void treeChanged(const QList<socexplorerplugin*>& drivers); |
|
62 | void treeChanged(const QList<socexplorerplugin*>& drivers); | |
63 | void pluginselectedslt( QTreeWidgetItem * item, int column); |
|
63 | void pluginselectedslt( QTreeWidgetItem * item, int column); | |
64 |
|
64 | void itemSelectionChangedslt(); | ||
65 |
|
65 | |||
66 | private: |
|
66 | private: | |
67 | void addplugin(socexplorerplugin* driver,QTreeWidgetItem* item); |
|
67 | void addplugin(socexplorerplugin* driver,QTreeWidgetItem* item); | |
68 | QTreeWidgetItem* editeditem; |
|
68 | QTreeWidgetItem* editeditem; | |
69 | QString* editeditemprev; |
|
69 | QString* editeditemprev; | |
70 | bool editingItem; |
|
70 | bool editingItem; | |
71 | }; |
|
71 | }; | |
72 |
|
72 | |||
73 | #endif // PLUGINTREE_H |
|
73 | #endif // PLUGINTREE_H |
@@ -1,103 +1,103 | |||||
1 |
|
1 | |||
2 | #include <genericPySysdriver.h> |
|
2 | #include <genericPySysdriver.h> | |
3 | #include <socexplorerplugin.h> |
|
3 | #include <socexplorerplugin.h> | |
4 | #ifdef WIN32 |
|
4 | #ifdef WIN32 | |
5 | #include <stdlib.h> |
|
5 | #include <stdlib.h> | |
6 | #define socexplorerBswap32(X) _byteswap_ulong(X) |
|
6 | #define socexplorerBswap32(X) _byteswap_ulong(X) | |
7 | #else |
|
7 | #else | |
8 | #ifdef UNIX |
|
8 | #ifdef UNIX | |
9 | #include <byteswap.h> |
|
9 | #include <byteswap.h> | |
10 | #define socexplorerBswap32(X) bswap_32(X) |
|
10 | #define socexplorerBswap32(X) bswap_32(X) | |
11 | #endif |
|
11 | #endif | |
12 | #endif |
|
12 | #endif | |
13 |
|
13 | |||
14 |
|
14 | |||
15 |
|
15 | |||
16 |
|
16 | |||
17 | genericPySysdriver::genericPySysdriver(socexplorerplugin* plugin,QObject* parent): |
|
17 | genericPySysdriver::genericPySysdriver(socexplorerplugin* plugin,QObject* parent): | |
18 | QObject(parent) |
|
18 | QObject(parent) | |
19 | { |
|
19 | { | |
20 | Q_UNUSED(parent) |
|
20 | Q_UNUSED(parent) | |
21 | this->plugin = plugin; |
|
21 | this->plugin = plugin; | |
22 | } |
|
22 | } | |
23 |
|
23 | |||
24 | QVariantList genericPySysdriver::Read(unsigned int address,unsigned int count) |
|
24 | QVariantList genericPySysdriver::Read(unsigned int address,unsigned int count) | |
25 | { |
|
25 | { | |
26 | unsigned int data[count]; |
|
26 | unsigned int data[count]; | |
27 | QVariantList result; |
|
27 | QVariantList result; | |
28 | this->plugin->Read(data,count,address); |
|
28 | this->plugin->Read(data,count,address); | |
29 | for(unsigned int i = 0;i<count;i++) |
|
29 | for(unsigned int i = 0;i<count;i++) | |
30 | { |
|
30 | { | |
31 | result.append(QVariant((int)data[i])); |
|
31 | result.append(QVariant((int)data[i])); | |
32 | } |
|
32 | } | |
33 | return result; |
|
33 | return result; | |
34 | } |
|
34 | } | |
35 | void genericPySysdriver::Write(unsigned int address,QList<QVariant> dataList) |
|
35 | void genericPySysdriver::Write(unsigned int address,QList<QVariant> dataList) | |
36 | { |
|
36 | { | |
37 | unsigned int data[dataList.count()]; |
|
37 | unsigned int data[dataList.count()]; | |
38 | for(int i = 0;i<dataList.count();i++) |
|
38 | for(int i = 0;i<dataList.count();i++) | |
39 | { |
|
39 | { | |
40 | data[i] = (unsigned int)dataList.at(i).toUInt(); |
|
40 | data[i] = (unsigned int)dataList.at(i).toUInt(); | |
41 | } |
|
41 | } | |
42 | this->plugin->Write(data,dataList.count(),address); |
|
42 | this->plugin->Write(data,dataList.count(),address); | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | bool genericPySysdriver::dumpMemory(unsigned int address,unsigned int count,QString file) |
|
45 | bool genericPySysdriver::dumpMemory(unsigned int address,unsigned int count,QString file) | |
46 | { |
|
46 | { | |
47 | unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int)); |
|
47 | unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int)); | |
48 | if(buffer!=NULL) |
|
48 | if(buffer!=NULL) | |
49 | { |
|
49 | { | |
50 | this->plugin->Read(buffer,count,address); |
|
50 | this->plugin->Read(buffer,count,address); | |
51 | QFile outfile(file); |
|
51 | QFile outfile(file); | |
52 | if (!outfile.open(QIODevice::ReadWrite | QIODevice::Text)) |
|
52 | if (!outfile.open(QIODevice::ReadWrite | QIODevice::Text)) | |
53 | return false; |
|
53 | return false; | |
54 | QTextStream out(&outfile); |
|
54 | QTextStream out(&outfile); | |
55 | for(int i=0;(unsigned int)i<count;i++) |
|
55 | for(int i=0;(unsigned int)i<count;i++) | |
56 | out << "0x"+QString::number(address+(i*4),16) + ": 0x" + QString::number(buffer[i],16) + "\n"; |
|
56 | out << "0x"+QString::number(address+(i*4),16) + ": 0x" + QString::number(buffer[i],16) + "\n"; | |
57 | free(buffer); |
|
57 | free(buffer); | |
58 | out.flush(); |
|
58 | out.flush(); | |
59 | outfile.close(); |
|
59 | outfile.close(); | |
60 | return true; |
|
60 | return true; | |
61 | } |
|
61 | } | |
62 | return false; |
|
62 | return false; | |
63 | } |
|
63 | } | |
64 |
|
64 | |||
65 | bool genericPySysdriver::memSet(unsigned int address,int value, unsigned int count) |
|
65 | bool genericPySysdriver::memSet(unsigned int address,int value, unsigned int count) | |
66 | { |
|
66 | { | |
67 | unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int)); |
|
67 | unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int)); | |
68 | if(buffer!=NULL) |
|
68 | if(buffer!=NULL) | |
69 | { |
|
69 | { | |
70 | memset((void*)buffer,value,count*sizeof(unsigned int)); |
|
70 | memset((void*)buffer,value,count*sizeof(unsigned int)); | |
71 | this->plugin->Write(buffer,count,address); |
|
71 | this->plugin->Write(buffer,count,address); | |
72 | free(buffer ); |
|
72 | free(buffer ); | |
73 | return true; |
|
73 | return true; | |
74 | } |
|
74 | } | |
75 | return false; |
|
75 | return false; | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 | bool genericPySysdriver::loadbin(unsigned int address,QString file) |
|
78 | bool genericPySysdriver::loadbin(unsigned int address,QString file) | |
79 | { |
|
79 | { | |
80 | QFile infile(file); |
|
80 | QFile infile(file); | |
81 | if (!infile.open(QIODevice::ReadOnly)) |
|
81 | if (!infile.open(QIODevice::ReadOnly)) | |
82 | return false; |
|
82 | return false; | |
83 | uint32_t* buffer = (uint32_t*)malloc(infile.size()); |
|
83 | uint32_t* buffer = (uint32_t*)malloc(infile.size()); | |
84 | if(buffer!=NULL) |
|
84 | if(buffer!=NULL) | |
85 | { |
|
85 | { | |
86 | infile.read((char*)buffer,infile.size()); |
|
86 | infile.read((char*)buffer,infile.size()); | |
87 | for(int i=0;i<(infile.size()/4);i++) |
|
87 | for(int i=0;i<(infile.size()/4);i++) | |
88 | { |
|
88 | { | |
89 | buffer[i] = socexplorerBswap32(buffer[i]); |
|
89 | buffer[i] = socexplorerBswap32(buffer[i]); | |
90 | } |
|
90 | } | |
91 | this->plugin->Write(buffer,infile.size()/4,address); |
|
91 | this->plugin->Write(buffer,infile.size()/4,address); | |
92 | free(buffer); |
|
92 | free(buffer); | |
93 | return true; |
|
93 | return true; | |
94 | } |
|
94 | } | |
95 | return false; |
|
95 | return false; | |
96 |
|
96 | |||
97 | } |
|
97 | } | |
98 |
|
98 | |||
99 | QString genericPySysdriver::instance() |
|
99 | QString genericPySysdriver::instance() | |
100 | { |
|
100 | { | |
101 | return plugin->instanceName; |
|
101 | return plugin->instanceName(); | |
102 | } |
|
102 | } | |
103 |
|
103 |
@@ -1,84 +1,91 | |||||
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) 2014, Laboratory of Plasmas Physic - CNRS |
|
3 | -- Copyright (C) 2014, Laboratory of Plasmas Physic - 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 |
|
22 | |||
23 | #include <socexplorerplugin.h> |
|
23 | #include <socexplorerplugin.h> | |
24 |
|
24 | |||
25 |
|
25 | |||
26 | int socexplorerplugin::isConnected(){return this->Connected;} |
|
26 | int socexplorerplugin::isConnected(){return this->Connected;} | |
27 |
|
27 | |||
28 | QString socexplorerplugin::baseName(){return *_Name;} |
|
28 | QString socexplorerplugin::baseName(){return *_Name;} | |
29 |
|
29 | |||
30 | int socexplorerplugin::baseAddress(){return this->BaseAddress;} |
|
30 | int socexplorerplugin::baseAddress(){return this->BaseAddress;} | |
31 |
|
31 | |||
32 | void socexplorerplugin::setBaseAddress(unsigned int baseAddress){this->BaseAddress = baseAddress;} |
|
32 | void socexplorerplugin::setBaseAddress(unsigned int baseAddress){this->BaseAddress = baseAddress;} | |
33 |
|
33 | |||
|
34 | QString socexplorerplugin::instanceName() | |||
|
35 | { | |||
|
36 | return this->_instanceName; | |||
|
37 | } | |||
|
38 | ||||
34 | int socexplorerplugin::registermenu(QMenu *menu) |
|
39 | int socexplorerplugin::registermenu(QMenu *menu) | |
35 | { |
|
40 | { | |
36 | this->menu = menu->addMenu(this->instanceName); |
|
41 | this->menu = menu->addMenu(this->_instanceName); | |
37 | this->closeAction = this->menu->addAction(tr("Close plugin")); |
|
42 | this->closeAction = this->menu->addAction(tr("Close plugin")); | |
38 | QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe())); |
|
43 | QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe())); | |
39 | this->ChildsMenu = this->menu->addMenu(QString("Childs")); |
|
44 | this->ChildsMenu = this->menu->addMenu(QString("Childs")); | |
40 | for(int i=0;i<this->childs.count();i++) |
|
45 | for(int i=0;i<this->childs.count();i++) | |
41 | { |
|
46 | { | |
42 | this->childs.at(i)->registermenu(this->ChildsMenu); |
|
47 | this->childs.at(i)->registermenu(this->ChildsMenu); | |
43 | } |
|
48 | } | |
44 | if(this->pyObject!=NULL)emit this->registerObject((QObject*)this->pyObject,this->instanceName); |
|
49 | if(this->pyObject!=NULL)emit this->registerObject((QObject*)this->pyObject,this->instanceName()); | |
45 | return 0; |
|
50 | return 0; | |
46 | } |
|
51 | } | |
47 |
|
52 | |||
48 | void socexplorerplugin::postInstantiationTrigger() |
|
53 | void socexplorerplugin::postInstantiationTrigger() | |
49 | { |
|
54 | { | |
50 | return; |
|
55 | return; | |
51 | } |
|
56 | } | |
52 |
|
57 | |||
53 | unsigned int socexplorerplugin::Write(unsigned int *Value, unsigned int count, unsigned int address) |
|
58 | unsigned int socexplorerplugin::Write(unsigned int *Value, unsigned int count, unsigned int address) | |
54 | { |
|
59 | { | |
55 | if(parent!=NULL) |
|
60 | if(parent!=NULL) | |
56 | { |
|
61 | { | |
57 | return parent->Write(Value,count,address); |
|
62 | return parent->Write(Value,count,address); | |
58 | } |
|
63 | } | |
59 | return 0; |
|
64 | return 0; | |
60 | } |
|
65 | } | |
61 |
|
66 | |||
62 | unsigned int socexplorerplugin::Read(unsigned int *Value, unsigned int count, unsigned int address) |
|
67 | unsigned int socexplorerplugin::Read(unsigned int *Value, unsigned int count, unsigned int address) | |
63 | { |
|
68 | { | |
64 | if(parent!=NULL) |
|
69 | if(parent!=NULL) | |
65 | { |
|
70 | { | |
66 | return parent->Read(Value,count,address); |
|
71 | return parent->Read(Value,count,address); | |
67 | } |
|
72 | } | |
68 | return 0; |
|
73 | return 0; | |
69 | } |
|
74 | } | |
70 |
|
75 | |||
71 | void socexplorerplugin::closeMe(){emit this->closePlugin(this);} |
|
76 | void socexplorerplugin::closeMe(){emit this->closePlugin(this);} | |
72 |
|
77 | |||
73 | void socexplorerplugin::activate(bool flag){this->setEnabled(flag);emit this->activateSig(flag);} |
|
78 | void socexplorerplugin::activate(bool flag){this->setEnabled(flag);emit this->activateSig(flag);} | |
74 |
|
79 | |||
75 | void socexplorerplugin::setInstanceName(const QString &newName) |
|
80 | void socexplorerplugin::setInstanceName(const QString &newName) | |
76 | { |
|
81 | { | |
77 | this->instanceName = newName; |
|
82 | this->_instanceName = newName; | |
78 | this->menu->setTitle(this->instanceName); |
|
83 | if(this->menu) | |
|
84 | this->menu->setTitle(this->_instanceName); | |||
|
85 | this->setWindowTitle(newName); | |||
79 | } |
|
86 | } | |
80 |
|
87 | |||
81 | void socexplorerplugin::makeGenericPyWrapper() |
|
88 | void socexplorerplugin::makeGenericPyWrapper() | |
82 | { |
|
89 | { | |
83 | this->pyObject = new genericPySysdriver(this); |
|
90 | this->pyObject = new genericPySysdriver(this); | |
84 | } |
|
91 | } |
@@ -1,176 +1,180 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | ββββββββ βββββββ βββββββ βββββββββββ ββββββββββ βββ βββββββ βββββββ βββββββββββββββ |
|
2 | ββββββββ βββββββ βββββββ βββββββββββ ββββββββββ βββ βββββββ βββββββ βββββββββββββββ | |
3 | βββββββββββββββββββββββββ βββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββ |
|
3 | βββββββββββββββββββββββββ βββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββ | |
4 | βββββββββββ ββββββ ββββββ ββββββ βββββββββββ βββ βββββββββββββββββ ββββββββ |
|
4 | βββββββββββ ββββββ ββββββ ββββββ βββββββββββ βββ βββββββββββββββββ ββββββββ | |
5 | βββββββββββ ββββββ ββββββ ββββββ βββββββ βββ βββ βββββββββββββββββ ββββββββ |
|
5 | βββββββββββ ββββββ ββββββ ββββββ βββββββ βββ βββ βββββββββββββββββ ββββββββ | |
6 | βββββββββββββββββββββββββ ββββββββββββ ββββββ ββββββββββββββββββββ ββββββββββββββ βββ |
|
6 | βββββββββββββββββββββββββ ββββββββββββ ββββββ ββββββββββββββββββββ ββββββββββββββ βββ | |
7 | ββββββββ βββββββ βββββββ βββββββββββ ββββββ ββββββββ βββββββ βββ ββββββββββββββ βββ |
|
7 | ββββββββ βββββββ βββββββ βββββββββββ ββββββ ββββββββ βββββββ βββ ββββββββββββββ βββ | |
8 |
|
8 | |||
9 | -- This file is a part of the SOC Explorer Software |
|
9 | -- This file is a part of the SOC Explorer Software | |
10 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS |
|
10 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS | |
11 | -- |
|
11 | -- | |
12 | -- This program is free software; you can redistribute it and/or modify |
|
12 | -- This program is free software; you can redistribute it and/or modify | |
13 | -- it under the terms of the GNU General Public License as published by |
|
13 | -- it under the terms of the GNU General Public License as published by | |
14 | -- the Free Software Foundation; either version 2 of the License, or |
|
14 | -- the Free Software Foundation; either version 2 of the License, or | |
15 | -- (at your option) any later version. |
|
15 | -- (at your option) any later version. | |
16 | -- |
|
16 | -- | |
17 | -- This program is distributed in the hope that it will be useful, |
|
17 | -- This program is distributed in the hope that it will be useful, | |
18 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | -- GNU General Public License for more details. |
|
20 | -- GNU General Public License for more details. | |
21 | -- |
|
21 | -- | |
22 | -- You should have received a copy of the GNU General Public License |
|
22 | -- You should have received a copy of the GNU General Public License | |
23 | -- along with this program; if not, write to the Free Software |
|
23 | -- along with this program; if not, write to the Free Software | |
24 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
24 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
25 | -------------------------------------------------------------------------------*/ |
|
25 | -------------------------------------------------------------------------------*/ | |
26 | /*-- Author : Alexis Jeandet |
|
26 | /*-- Author : Alexis Jeandet | |
27 | -- Mail : alexis.jeandet@lpp.polytechnique.fr |
|
27 | -- Mail : alexis.jeandet@lpp.polytechnique.fr | |
28 | ----------------------------------------------------------------------------*/ |
|
28 | ----------------------------------------------------------------------------*/ | |
29 | #ifndef SOCEXPLORERPLUGIN_H |
|
29 | #ifndef SOCEXPLORERPLUGIN_H | |
30 | #define SOCEXPLORERPLUGIN_H |
|
30 | #define SOCEXPLORERPLUGIN_H | |
31 | #include <QWidget> |
|
31 | #include <QWidget> | |
32 | #include <QAction> |
|
32 | #include <QAction> | |
33 | #include <QDockWidget> |
|
33 | #include <QDockWidget> | |
34 | #include <QMainWindow> |
|
34 | #include <QMainWindow> | |
35 | #include <QList> |
|
35 | #include <QList> | |
36 | #include <QMenu> |
|
36 | #include <QMenu> | |
37 | #include <socexplorer.h> |
|
37 | #include <socexplorer.h> | |
38 | #include <QObject> |
|
38 | #include <QObject> | |
39 | #include <QVariant> |
|
39 | #include <QVariant> | |
40 | #include <QVariantList> |
|
40 | #include <QVariantList> | |
41 | #include <malloc.h> |
|
41 | #include <malloc.h> | |
42 | #include <QFile> |
|
42 | #include <QFile> | |
43 | #include <stdint.h> |
|
43 | #include <stdint.h> | |
44 | #include <QTextStream> |
|
44 | #include <QTextStream> | |
45 | #include <genericPySysdriver.h> |
|
45 | #include <genericPySysdriver.h> | |
46 | #ifndef driver_Name |
|
46 | #ifndef driver_Name | |
47 | #define driver_Name "Plugin" |
|
47 | #define driver_Name "Plugin" | |
48 | #endif |
|
48 | #endif | |
49 | #ifndef driver_Author |
|
49 | #ifndef driver_Author | |
50 | #define driver_Author "No Author" |
|
50 | #define driver_Author "No Author" | |
51 | #endif |
|
51 | #endif | |
52 | #ifndef driver_Version |
|
52 | #ifndef driver_Version | |
53 | #define driver_Version "0.0.0" |
|
53 | #define driver_Version "0.0.0" | |
54 | #endif |
|
54 | #endif | |
55 | #ifndef driver_Description |
|
55 | #ifndef driver_Description | |
56 | #define driver_Description "No description." |
|
56 | #define driver_Description "No description." | |
57 | #endif |
|
57 | #endif | |
58 | #ifndef driver_can_be_root |
|
58 | #ifndef driver_can_be_root | |
59 | #define driver_can_be_root 0 |
|
59 | #define driver_can_be_root 0 | |
60 | #endif |
|
60 | #endif | |
61 | #ifndef driver_can_be_child |
|
61 | #ifndef driver_can_be_child | |
62 | #define driver_can_be_child 0 |
|
62 | #define driver_can_be_child 0 | |
63 | #endif |
|
63 | #endif | |
64 | #ifndef driver_VID |
|
64 | #ifndef driver_VID | |
65 | #define driver_VID 0 |
|
65 | #define driver_VID 0 | |
66 | #endif |
|
66 | #endif | |
67 | #ifndef driver_PID |
|
67 | #ifndef driver_PID | |
68 | #define driver_PID 0 |
|
68 | #define driver_PID 0 | |
69 | #endif |
|
69 | #endif | |
70 |
|
70 | |||
71 | #if defined(SOCEXPLORER_SDK_BUILD) |
|
71 | #if defined(SOCEXPLORER_SDK_BUILD) | |
72 | # define SOCEXPLORER_SDK_EXPORT Q_DECL_EXPORT |
|
72 | # define SOCEXPLORER_SDK_EXPORT Q_DECL_EXPORT | |
73 | #else |
|
73 | #else | |
74 | # define SOCEXPLORER_SDK_EXPORT Q_DECL_IMPORT |
|
74 | # define SOCEXPLORER_SDK_EXPORT Q_DECL_IMPORT | |
75 | #endif |
|
75 | #endif | |
76 |
|
76 | |||
77 | class genericPySysdriver; |
|
77 | class genericPySysdriver; | |
78 |
|
78 | |||
79 | //! socexplorerplugin is the base class for any SocExplorer plugin, it gives a standard interface to communicate |
|
79 | //! socexplorerplugin is the base class for any SocExplorer plugin, it gives a standard interface to communicate | |
80 | //! between each plugins and to interact with SocExplorer software. |
|
80 | //! between each plugins and to interact with SocExplorer software. | |
81 |
|
81 | |||
82 | class SOCEXPLORER_SDK_EXPORT socexplorerplugin : public QDockWidget |
|
82 | class SOCEXPLORER_SDK_EXPORT socexplorerplugin : public QDockWidget | |
83 | { |
|
83 | { | |
84 | Q_OBJECT |
|
84 | Q_OBJECT | |
85 | public: |
|
85 | public: | |
86 | //! Default plugin constructor, any plugin should call this constructor. This constructor creates a |
|
86 | //! Default plugin constructor, any plugin should call this constructor. This constructor creates a | |
87 | //! default python wrapper instance. If you want to connect your own python wrapper, you have to clear |
|
87 | //! default python wrapper instance. If you want to connect your own python wrapper, you have to clear | |
88 | //! createPyObject option and instanciate your own genericPySysdriver derivated object. |
|
88 | //! createPyObject option and instanciate your own genericPySysdriver derivated object. | |
89 | socexplorerplugin(QWidget *parent = 0,bool createPyObject=true) |
|
89 | socexplorerplugin(QWidget *parent = 0,bool createPyObject=true):QDockWidget(parent) | |
90 | { |
|
90 | { | |
|
91 | closeAction=NULL; | |||
|
92 | menu=NULL; | |||
|
93 | ChildsMenu=NULL; | |||
91 | this->Connected = false; |
|
94 | this->Connected = false; | |
92 | this->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetVerticalTitleBar); |
|
95 | this->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetVerticalTitleBar); | |
93 | _Name = new QString(driver_Name); |
|
96 | _Name = new QString(driver_Name); | |
94 | _Author = new QString(driver_Author); |
|
97 | _Author = new QString(driver_Author); | |
95 | _Version = new QString(driver_Version); |
|
98 | _Version = new QString(driver_Version); | |
96 | _Description = new QString(driver_Description); |
|
99 | _Description = new QString(driver_Description); | |
97 | _canBeChild = driver_can_be_child; |
|
100 | _canBeChild = driver_can_be_child; | |
98 | _canBeRoot = driver_can_be_root; |
|
101 | _canBeRoot = driver_can_be_root; | |
99 | _VID = driver_VID; |
|
102 | _VID = driver_VID; | |
100 | _PID = driver_PID; |
|
103 | _PID = driver_PID; | |
101 | if(createPyObject) |
|
104 | if(createPyObject) | |
102 | { |
|
105 | { | |
103 | this->makeGenericPyWrapper(); |
|
106 | this->makeGenericPyWrapper(); | |
104 | } |
|
107 | } | |
105 | } |
|
108 | } | |
106 | //! Tells if the plugin is connected, it is used to enable or disable all childrens interfaces. |
|
109 | //! Tells if the plugin is connected, it is used to enable or disable all childrens interfaces. | |
107 | virtual int isConnected(); |
|
110 | virtual int isConnected(); | |
108 | //! Gives the associated Vendor IDentifier, usefull to automatically associate plugins with found |
|
111 | //! Gives the associated Vendor IDentifier, usefull to automatically associate plugins with found | |
109 | //! hardware while board enumeration. |
|
112 | //! hardware while board enumeration. | |
110 | virtual int VID(){return _PID;} |
|
113 | virtual int VID(){return _PID;} | |
111 | //! Gives the associated Product IDentifier, usefull to automatically associate plugins with found |
|
114 | //! Gives the associated Product IDentifier, usefull to automatically associate plugins with found | |
112 | //! hardware while board enumeration. |
|
115 | //! hardware while board enumeration. | |
113 | virtual int PID(){return _VID;} |
|
116 | virtual int PID(){return _VID;} | |
114 | //! Gives the plugin's base name, usefull to automatically generate instance name. |
|
117 | //! Gives the plugin's base name, usefull to automatically generate instance name. | |
115 | virtual QString baseName(); |
|
118 | virtual QString baseName(); | |
116 | //! Gives the base address of the current instance, for example if your plugin is supposed to drive |
|
119 | //! Gives the base address of the current instance, for example if your plugin is supposed to drive | |
117 | //! an UART it will correspond to the address of it's first register. This address have at least to |
|
120 | //! an UART it will correspond to the address of it's first register. This address have at least to | |
118 | //! be set by SocExplorer and it can be user accessible if you want. |
|
121 | //! be set by SocExplorer and it can be user accessible if you want. | |
119 | virtual int baseAddress(); |
|
122 | virtual int baseAddress(); | |
120 | //! Sets the base address of the current instance, for example if your plugin is supposed to drive |
|
123 | //! Sets the base address of the current instance, for example if your plugin is supposed to drive | |
121 | //! an UART it will correspond to the address of it's first register. This address have at least to |
|
124 | //! an UART it will correspond to the address of it's first register. This address have at least to | |
122 | //! be set by lppSocExplorer and it can be user accessible if you want. |
|
125 | //! be set by lppSocExplorer and it can be user accessible if you want. | |
123 | virtual void setBaseAddress(unsigned int baseAddress); |
|
126 | virtual void setBaseAddress(unsigned int baseAddress); | |
124 |
|
127 | |||
125 | genericPySysdriver* getPyObjectWrapper(){return this->pyObject;} |
|
128 | genericPySysdriver* getPyObjectWrapper(){return this->pyObject;} | |
126 | QList<socexplorerplugin*> childs; |
|
129 | QList<socexplorerplugin*> childs; | |
127 | socexplorerplugin* parent; |
|
130 | socexplorerplugin* parent; | |
128 | QAction* closeAction; |
|
131 | QAction* closeAction; | |
129 | QString instanceName; |
|
132 | QString instanceName(); | |
130 | QMenu* menu; |
|
133 | QMenu* menu; | |
131 | QMenu* ChildsMenu; |
|
134 | QMenu* ChildsMenu; | |
132 |
|
135 | |||
133 | signals: |
|
136 | signals: | |
134 | //! Signal emited each time the plugin is about to be closed. |
|
137 | //! Signal emited each time the plugin is about to be closed. | |
135 | void closePlugin(socexplorerplugin* driver); |
|
138 | void closePlugin(socexplorerplugin* driver); | |
136 | void activateSig(bool flag); |
|
139 | void activateSig(bool flag); | |
137 | void registerObject(QObject* object,const QString& instanceName); |
|
140 | void registerObject(QObject* object,const QString& instanceName); | |
138 |
|
141 | |||
139 | public slots: |
|
142 | public slots: | |
140 | virtual int registermenu(QMenu* menu); |
|
143 | virtual int registermenu(QMenu* menu); | |
141 | virtual void postInstantiationTrigger(); |
|
144 | virtual void postInstantiationTrigger(); | |
142 | //! Write slot this is the way your children plugins ask you for writing data. |
|
145 | //! Write slot this is the way your children plugins ask you for writing data. | |
143 | //! If your plugin is supposed to have childern drivers you should implement this methode. |
|
146 | //! If your plugin is supposed to have childern drivers you should implement this methode. | |
144 | //! By default this methode forward the write request to the parent plugin. |
|
147 | //! By default this methode forward the write request to the parent plugin. | |
145 | //! \param Value Pointer the data buffer. |
|
148 | //! \param Value Pointer the data buffer. | |
146 | //! \param count Number of 32 bits words you should to write. |
|
149 | //! \param count Number of 32 bits words you should to write. | |
147 | //! \param address Address from where you should to start to write. |
|
150 | //! \param address Address from where you should to start to write. | |
148 | //! \return Quantity of 32 bits words writtens. |
|
151 | //! \return Quantity of 32 bits words writtens. | |
149 | virtual unsigned int Write(unsigned int* Value, unsigned int count,unsigned int address); |
|
152 | virtual unsigned int Write(unsigned int* Value, unsigned int count,unsigned int address); | |
150 | //! Read slot this is the way your children plugins ask you for reading data. |
|
153 | //! Read slot this is the way your children plugins ask you for reading data. | |
151 | //! If your plugin is supposed to have childern drivers you should implement this methode. |
|
154 | //! If your plugin is supposed to have childern drivers you should implement this methode. | |
152 | //! By default this methode forward the write request to the parent plugin. |
|
155 | //! By default this methode forward the write request to the parent plugin. | |
153 | //! \param Value Pointer the data buffer. |
|
156 | //! \param Value Pointer the data buffer. | |
154 | //! \param count Number of 32 bits words you should to read. |
|
157 | //! \param count Number of 32 bits words you should to read. | |
155 | //! \param address Address from where you should to start to read. |
|
158 | //! \param address Address from where you should to start to read. | |
156 | //! \return Quantity of 32 bits words read. |
|
159 | //! \return Quantity of 32 bits words read. | |
157 | virtual unsigned int Read(unsigned int* Value, unsigned int count,unsigned int address); |
|
160 | virtual unsigned int Read(unsigned int* Value, unsigned int count,unsigned int address); | |
158 | virtual void closeMe(); |
|
161 | virtual void closeMe(); | |
159 | virtual void activate(bool flag); |
|
162 | virtual void activate(bool flag); | |
160 | virtual void setInstanceName(const QString& newName); |
|
163 | virtual void setInstanceName(const QString& newName); | |
161 | protected: |
|
164 | protected: | |
162 | void makeGenericPyWrapper(); |
|
165 | void makeGenericPyWrapper(); | |
163 | int BaseAddress; |
|
166 | int BaseAddress; | |
164 | bool Connected; |
|
167 | bool Connected; | |
165 | genericPySysdriver* pyObject; |
|
168 | genericPySysdriver* pyObject; | |
166 | QString* _Name; |
|
169 | QString* _Name; | |
167 | QString* _Author; |
|
170 | QString* _Author; | |
168 | QString* _Version; |
|
171 | QString* _Version; | |
169 | QString* _Description; |
|
172 | QString* _Description; | |
|
173 | QString _instanceName; | |||
170 | int _canBeChild; |
|
174 | int _canBeChild; | |
171 | int _canBeRoot; |
|
175 | int _canBeRoot; | |
172 | int _VID; |
|
176 | int _VID; | |
173 | int _PID; |
|
177 | int _PID; | |
174 | }; |
|
178 | }; | |
175 |
|
179 | |||
176 | #endif // SOCEXPLORERPLUGIN_H |
|
180 | #endif // SOCEXPLORERPLUGIN_H |
@@ -1,383 +1,379 | |||||
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, Laboratory of Plasmas Physic - CNRS |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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-> |
|
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-> |
|
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) |
|
193 | void socexplorerproxy::loadChild(socexplorerplugin *parent) | |
194 | { |
|
194 | { | |
195 | if(!_self)init(); |
|
195 | if(!_self)init(); | |
196 | parent = parent; |
|
196 | parent = parent; | |
197 | pluginmanagerWDGT* pluginmanager0 = new pluginmanagerWDGT; |
|
197 | pluginmanagerWDGT* pluginmanager0 = new pluginmanagerWDGT; | |
198 | pluginmanager0->setChildLoadable(true); |
|
198 | pluginmanager0->setChildLoadable(true); | |
199 | pluginmanager0->connect(pluginmanager0,SIGNAL(loadSysDrviver(QString)),_self,SLOT(loadSysDriverToParent(QString))); |
|
199 | pluginmanager0->connect(pluginmanager0,SIGNAL(loadSysDrviver(QString)),_self,SLOT(loadSysDriverToParent(QString))); | |
200 | pluginmanager0->show(); |
|
200 | pluginmanager0->show(); | |
201 | } |
|
201 | } | |
202 |
|
202 | |||
203 |
|
203 | |||
204 | void socexplorerproxy::connectChildToParent(socexplorerplugin *parent, socexplorerplugin *child) |
|
204 | void socexplorerproxy::connectChildToParent(socexplorerplugin *parent, socexplorerplugin *child) | |
205 | { |
|
205 | { | |
206 | if(!_self)init(); |
|
206 | if(!_self)init(); | |
207 | //connect(child,SIGNAL(WriteSig(uint*,uint,uint)),parent,SLOT(Write(uint*,uint,uint))); |
|
207 | connect(parent,SIGNAL(activateSig(bool)),child,SLOT(activate(bool))); | |
208 | //connect(child,SIGNAL(ReadSig(uint*,uint,uint)),parent,SLOT(Read(uint*,uint,uint))); |
|
|||
209 | connect(parent,SIGNAL(activateSig(bool)),child,SLOT(activate(bool)));//,Qt::DirectConnection); |
|
|||
210 | child->activate(parent->isConnected()); |
|
208 | child->activate(parent->isConnected()); | |
211 | } |
|
209 | } | |
212 |
|
210 | |||
213 | void socexplorerproxy::disconnectChildToParent(socexplorerplugin *child) |
|
211 | void socexplorerproxy::disconnectChildToParent(socexplorerplugin *child) | |
214 | { |
|
212 | { | |
215 | if(!_self)init(); |
|
213 | if(!_self)init(); | |
216 | //disconnect(child,SIGNAL(WriteSig(uint*,uint,uint)),child->parent,SLOT(Write(uint*,uint,uint))); |
|
214 | disconnect(child->parent,SIGNAL(activateSig(bool)),child,SLOT(activate(bool))); | |
217 | // disconnect(child,SIGNAL(ReadSig(uint*,uint,uint)),child->parent,SLOT(Read(uint*,uint,uint))); |
|
|||
218 | disconnect(child->parent,SIGNAL(activateSig(bool)),child,SLOT(activate(bool)));//,Qt::DirectConnection); |
|
|||
219 | } |
|
215 | } | |
220 |
|
216 | |||
221 |
|
217 | |||
222 | void socexplorerproxy::connectChildToProxy(socexplorerplugin *child) |
|
218 | void socexplorerproxy::connectChildToProxy(socexplorerplugin *child) | |
223 | { |
|
219 | { | |
224 | if(!_self)init(); |
|
220 | if(!_self)init(); | |
225 | connect(child,SIGNAL(registerObject(QObject*,QString)),_self,SIGNAL(registerObject(QObject*,QString))); |
|
221 | connect(child,SIGNAL(registerObject(QObject*,QString)),_self,SIGNAL(registerObject(QObject*,QString))); | |
226 | connect(child,SIGNAL(closePlugin(socexplorerplugin*)),_self,SLOT(closeSysDriver(socexplorerplugin*))); |
|
222 | connect(child,SIGNAL(closePlugin(socexplorerplugin*)),_self,SLOT(closeSysDriver(socexplorerplugin*))); | |
227 | } |
|
223 | } | |
228 |
|
224 | |||
229 | void socexplorerproxy::disconnectChildToProxy(socexplorerplugin *child) |
|
225 | void socexplorerproxy::disconnectChildToProxy(socexplorerplugin *child) | |
230 | { |
|
226 | { | |
231 | if(!_self)init(); |
|
227 | if(!_self)init(); | |
232 | disconnect(child,SIGNAL(registerObject(QObject*,QString)),_self,SIGNAL(registerObject(QObject*,QString))); |
|
228 | disconnect(child,SIGNAL(registerObject(QObject*,QString)),_self,SIGNAL(registerObject(QObject*,QString))); | |
233 | disconnect(child,SIGNAL(closePlugin(socexplorerplugin*)),_self,SLOT(closeSysDriverFromDriver(socexplorerplugin*))); |
|
229 | disconnect(child,SIGNAL(closePlugin(socexplorerplugin*)),_self,SLOT(closeSysDriverFromDriver(socexplorerplugin*))); | |
234 | } |
|
230 | } | |
235 |
|
231 | |||
236 | QString socexplorerproxy::getinstanceName(const QString& baseName) |
|
232 | QString socexplorerproxy::getinstanceName(const QString& baseName) | |
237 | { |
|
233 | { | |
238 | if(!_self)init(); |
|
234 | if(!_self)init(); | |
239 | int i=0; |
|
235 | int i=0; | |
240 | QString name; |
|
236 | QString name; | |
241 | bool validName = false; |
|
237 | bool validName = false; | |
242 | while(!validName) |
|
238 | while(!validName) | |
243 | { |
|
239 | { | |
244 | name.clear(); |
|
240 | name.clear(); | |
245 | name.append(baseName+QString::number(i)); |
|
241 | name.append(baseName+QString::number(i)); | |
246 | validName = instanceNameIsValid(name); |
|
242 | validName = instanceNameIsValid(name); | |
247 | i++; |
|
243 | i++; | |
248 | } |
|
244 | } | |
249 | return name; |
|
245 | return name; | |
250 | } |
|
246 | } | |
251 |
|
247 | |||
252 | void socexplorerproxy::changeSysDriverInstName(socexplorerplugin* driver) |
|
248 | void socexplorerproxy::changeSysDriverInstName(socexplorerplugin* driver) | |
253 | { |
|
249 | { | |
254 | if(!_self)init(); |
|
250 | if(!_self)init(); | |
255 | QString prevName(driver->instanceName); |
|
251 | QString prevName(driver->instanceName()); | |
256 | } |
|
252 | } | |
257 |
|
253 | |||
258 | bool socexplorerproxy::instanceNameIsValid(const QString& instanceName) |
|
254 | bool socexplorerproxy::instanceNameIsValid(const QString& instanceName) | |
259 | { |
|
255 | { | |
260 | if(!_self)init(); |
|
256 | if(!_self)init(); | |
261 | for(int k=0;k<linearDriverList->count();k++) |
|
257 | for(int k=0;k<linearDriverList->count();k++) | |
262 | { |
|
258 | { | |
263 | if(!linearDriverList->at(k)->instanceName.compare(instanceName)) |
|
259 | if(!linearDriverList->at(k)->instanceName().compare(instanceName)) | |
264 | return false; |
|
260 | return false; | |
265 | } |
|
261 | } | |
266 | return true; |
|
262 | return true; | |
267 | } |
|
263 | } | |
268 |
|
264 | |||
269 | socexplorerplugin *socexplorerproxy::findPlugin(const QString &instanceName) |
|
265 | socexplorerplugin *socexplorerproxy::findPlugin(const QString &instanceName) | |
270 | { |
|
266 | { | |
271 | if(!_self)init(); |
|
267 | if(!_self)init(); | |
272 | for(int k=0;k<linearDriverList->count();k++) |
|
268 | for(int k=0;k<linearDriverList->count();k++) | |
273 | { |
|
269 | { | |
274 | if(linearDriverList->at(k)->instanceName.compare(instanceName)) |
|
270 | if(linearDriverList->at(k)->instanceName().compare(instanceName)) | |
275 | return linearDriverList->at(k); |
|
271 | return linearDriverList->at(k); | |
276 | } |
|
272 | } | |
277 | return NULL; |
|
273 | return NULL; | |
278 | } |
|
274 | } | |
279 |
|
275 | |||
280 | bool socexplorerproxy::instanceExists(const QString &instanceName) |
|
276 | bool socexplorerproxy::instanceExists(const QString &instanceName) | |
281 | { |
|
277 | { | |
282 | return !socexplorerproxy::instanceNameIsValid(instanceName); |
|
278 | return !socexplorerproxy::instanceNameIsValid(instanceName); | |
283 | } |
|
279 | } | |
284 |
|
280 | |||
285 | void socexplorerproxy::close() |
|
281 | void socexplorerproxy::close() | |
286 | { |
|
282 | { | |
287 | if(!_self)init(); |
|
283 | if(!_self)init(); | |
288 | socexplorerplugin* tmpPtr; |
|
284 | socexplorerplugin* tmpPtr; | |
289 | while(drivers->count()>0) |
|
285 | while(drivers->count()>0) | |
290 | { |
|
286 | { | |
291 | tmpPtr = drivers->last(); |
|
287 | tmpPtr = drivers->last(); | |
292 | drivers->removeLast(); |
|
288 | drivers->removeLast(); | |
293 | _self->closeSysDriver(tmpPtr); |
|
289 | _self->closeSysDriver(tmpPtr); | |
294 | } |
|
290 | } | |
295 | if(root!=NULL) |
|
291 | if(root!=NULL) | |
296 | { |
|
292 | { | |
297 | _self->closeSysDriver(root); |
|
293 | _self->closeSysDriver(root); | |
298 | } |
|
294 | } | |
299 |
|
295 | |||
300 | } |
|
296 | } | |
301 |
|
297 | |||
302 | socexplorerplugin* socexplorerproxy::getSysDriver(const QString instanceName) |
|
298 | socexplorerplugin* socexplorerproxy::getSysDriver(const QString instanceName) | |
303 | { |
|
299 | { | |
304 | if(!_self)init(); |
|
300 | if(!_self)init(); | |
305 | for(int i=0;i<linearDriverList->count();i++) |
|
301 | for(int i=0;i<linearDriverList->count();i++) | |
306 | { |
|
302 | { | |
307 | if(!linearDriverList->at(i)->instanceName.compare(instanceName)) |
|
303 | if(!linearDriverList->at(i)->instanceName().compare(instanceName)) | |
308 | return linearDriverList->at(i); |
|
304 | return linearDriverList->at(i); | |
309 | } |
|
305 | } | |
310 | return NULL; |
|
306 | return NULL; | |
311 | } |
|
307 | } | |
312 |
|
308 | |||
313 |
|
309 | |||
314 | void socexplorerproxy::closeSysDriver(const QString instanceName) |
|
310 | void socexplorerproxy::closeSysDriver(const QString instanceName) | |
315 | { |
|
311 | { | |
316 | if(!_self)init(); |
|
312 | if(!_self)init(); | |
317 | closeSysDriver(getSysDriver(instanceName),false); |
|
313 | closeSysDriver(getSysDriver(instanceName),false); | |
318 | } |
|
314 | } | |
319 |
|
315 | |||
320 | void socexplorerproxy::closeSysDriver(socexplorerplugin *driver, bool recursive) |
|
316 | void socexplorerproxy::closeSysDriver(socexplorerplugin *driver, bool recursive) | |
321 | { |
|
317 | { | |
322 | if(!_self)init(); |
|
318 | if(!_self)init(); | |
323 | if(driver!=NULL) |
|
319 | if(driver!=NULL) | |
324 | { |
|
320 | { | |
325 | if(driver->parent==NULL)SocExplorerEngine::removeSOC(driver); |
|
321 | if(driver->parent==NULL)SocExplorerEngine::removeSOC(driver); | |
326 | while(driver->childs.count()!=0)closeSysDriver(driver->childs.first()); |
|
322 | while(driver->childs.count()!=0)closeSysDriver(driver->childs.first()); | |
327 | linearDriverList->removeOne(driver); |
|
323 | linearDriverList->removeOne(driver); | |
328 | if(driver->parent!= NULL) |
|
324 | if(driver->parent!= NULL) | |
329 | { |
|
325 | { | |
330 | driver->parent->childs.removeOne(driver); //Have parent so it's a child |
|
326 | driver->parent->childs.removeOne(driver); //Have parent so it's a child | |
331 | disconnectChildToParent(driver); |
|
327 | disconnectChildToParent(driver); | |
332 | disconnectChildToProxy(driver); |
|
328 | disconnectChildToProxy(driver); | |
333 | delete driver; |
|
329 | delete driver; | |
334 | } |
|
330 | } | |
335 | else |
|
331 | else | |
336 | { |
|
332 | { | |
337 | drivers->removeOne(driver); |
|
333 | drivers->removeOne(driver); | |
338 | disconnectChildToProxy(driver); |
|
334 | disconnectChildToProxy(driver); | |
339 | delete driver; |
|
335 | delete driver; | |
340 | } |
|
336 | } | |
341 | if(!recursive) |
|
337 | if(!recursive) | |
342 | { |
|
338 | { | |
343 | emit _self->clearMenu(); |
|
339 | emit _self->clearMenu(); | |
344 | emit _self->registermenu(mainWindow); |
|
340 | emit _self->registermenu(mainWindow); | |
345 | emit _self->treeChanged(QList<socexplorerplugin*>(*drivers)); |
|
341 | emit _self->treeChanged(QList<socexplorerplugin*>(*drivers)); | |
346 | } |
|
342 | } | |
347 | } |
|
343 | } | |
348 |
|
344 | |||
349 | } |
|
345 | } | |
350 |
|
346 | |||
351 | void socexplorerproxy::geteplugintree() |
|
347 | void socexplorerproxy::geteplugintree() | |
352 | { |
|
348 | { | |
353 | if(!_self)init(); |
|
349 | if(!_self)init(); | |
354 | emit _self->treeChanged(QList<socexplorerplugin*>(*drivers)); |
|
350 | emit _self->treeChanged(QList<socexplorerplugin*>(*drivers)); | |
355 | } |
|
351 | } | |
356 |
|
352 | |||
357 | void socexplorerproxy::closeSysDriverFromDriver(socexplorerplugin *driver) |
|
353 | void socexplorerproxy::closeSysDriverFromDriver(socexplorerplugin *driver) | |
358 | { |
|
354 | { | |
359 | if(!_self)init(); |
|
355 | if(!_self)init(); | |
360 | emit _self->closeSysDriverSig(driver); |
|
356 | emit _self->closeSysDriverSig(driver); | |
361 | } |
|
357 | } | |
362 |
|
358 | |||
363 | void socexplorerproxy::updateText() |
|
359 | void socexplorerproxy::updateText() | |
364 | { |
|
360 | { | |
365 | if(!_self)init(); |
|
361 | if(!_self)init(); | |
366 | emit _self->clearMenu(); |
|
362 | emit _self->clearMenu(); | |
367 | emit _self->registermenu(mainWindow); |
|
363 | emit _self->registermenu(mainWindow); | |
368 | } |
|
364 | } | |
369 |
|
365 | |||
370 |
|
366 | |||
371 |
|
367 | |||
372 |
|
368 | |||
373 |
|
369 | |||
374 | void socexplorerproxy::makeMenu(QMenu* menu) |
|
370 | void socexplorerproxy::makeMenu(QMenu* menu) | |
375 | { |
|
371 | { | |
376 | if(!_self)init(); |
|
372 | if(!_self)init(); | |
377 | for(int i=0;i<drivers->count();i++) |
|
373 | for(int i=0;i<drivers->count();i++) | |
378 | { |
|
374 | { | |
379 | drivers->at(i)->registermenu(menu); |
|
375 | drivers->at(i)->registermenu(menu); | |
380 | } |
|
376 | } | |
381 | } |
|
377 | } | |
382 |
|
378 | |||
383 |
|
379 |
@@ -1,22 +1,23 | |||||
1 | #include "dockablepluginmanager.h" |
|
1 | #include "dockablepluginmanager.h" | |
2 |
|
2 | |||
3 | dockablePluginManager::dockablePluginManager(QWidget *parent) : |
|
3 | dockablePluginManager::dockablePluginManager(QWidget *parent) : | |
4 | QDockWidget(parent) |
|
4 | QDockWidget(parent) | |
5 | { |
|
5 | { | |
6 | this->managerGui = new pluginmanagerWDGT; |
|
6 | this->managerGui = new pluginmanagerWDGT; | |
7 | connect(this->managerGui,SIGNAL(loadSysDrviver(QString)),this,SIGNAL(loadSysDrviver(QString))); |
|
7 | connect(this->managerGui,SIGNAL(loadSysDrviver(QString)),this,SIGNAL(loadSysDrviver(QString))); | |
8 | connect(this->managerGui,SIGNAL(loadSysDriverToParent(QString,QString)),this,SIGNAL(loadSysDriverToParent(QString,QString))); |
|
8 | connect(this->managerGui,SIGNAL(loadSysDriverToParent(QString,QString)),this,SIGNAL(loadSysDriverToParent(QString,QString))); | |
9 | connect(this->managerGui,SIGNAL(geteplugintree()),this,SIGNAL(geteplugintree())); |
|
9 | connect(this->managerGui,SIGNAL(geteplugintree()),this,SIGNAL(geteplugintree())); | |
10 | connect(this,SIGNAL(treeChanged(QList<socexplorerplugin*>)),this->managerGui,SIGNAL(treeChanged(QList<socexplorerplugin*>))); |
|
10 | connect(this,SIGNAL(treeChanged(QList<socexplorerplugin*>)),this->managerGui,SIGNAL(treeChanged(QList<socexplorerplugin*>))); | |
11 | connect(this->managerGui,SIGNAL(changeSysDriverInstName(QString,QString)),this,SIGNAL(changeSysDriverInstName(QString,QString))); |
|
11 | connect(this->managerGui,SIGNAL(changeSysDriverInstName(QString,QString)),this,SIGNAL(changeSysDriverInstName(QString,QString))); | |
12 | connect(this->managerGui,SIGNAL(closeSysDriver(QString)),this,SIGNAL(closeSysDriver(QString))); |
|
12 | connect(this->managerGui,SIGNAL(closeSysDriver(QString)),this,SIGNAL(closeSysDriver(QString))); | |
|
13 | connect(this->managerGui,SIGNAL(pluginselected(QString)),this,SIGNAL(pluginselected(QString))); | |||
13 | this->setWidget(this->managerGui); |
|
14 | this->setWidget(this->managerGui); | |
14 | this->setWindowTitle(this->managerGui->windowTitle()); |
|
15 | this->setWindowTitle(this->managerGui->windowTitle()); | |
15 | } |
|
16 | } | |
16 |
|
17 | |||
17 |
|
18 | |||
18 |
|
19 | |||
19 | void dockablePluginManager::setRootLoadable(bool flag) |
|
20 | void dockablePluginManager::setRootLoadable(bool flag) | |
20 | { |
|
21 | { | |
21 | this->managerGui->setRootLoadable(flag); |
|
22 | this->managerGui->setRootLoadable(flag); | |
22 | } |
|
23 | } |
@@ -1,49 +1,50 | |||||
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, Laboratory of Plasmas Physic - CNRS |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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 | #ifndef DOCKABLEPLUGINMANAGER_H |
|
22 | #ifndef DOCKABLEPLUGINMANAGER_H | |
23 | #define DOCKABLEPLUGINMANAGER_H |
|
23 | #define DOCKABLEPLUGINMANAGER_H | |
24 |
|
24 | |||
25 | #include <QDockWidget> |
|
25 | #include <QDockWidget> | |
26 | #include "pluginmanagerWDGT.h" |
|
26 | #include "pluginmanagerWDGT.h" | |
27 |
|
27 | |||
28 | class dockablePluginManager : public QDockWidget |
|
28 | class dockablePluginManager : public QDockWidget | |
29 | { |
|
29 | { | |
30 | Q_OBJECT |
|
30 | Q_OBJECT | |
31 | public: |
|
31 | public: | |
32 | explicit dockablePluginManager(QWidget *parent = 0); |
|
32 | explicit dockablePluginManager(QWidget *parent = 0); | |
33 | void setRootLoadable(bool flag); |
|
33 | void setRootLoadable(bool flag); | |
34 |
|
34 | |||
35 | signals: |
|
35 | signals: | |
36 | void loadSysDrviver(const QString name); |
|
36 | void loadSysDrviver(const QString name); | |
37 | void loadSysDriverToParent(const QString name, const QString instanceName); |
|
37 | void loadSysDriverToParent(const QString name, const QString instanceName); | |
38 | void geteplugintree(void); |
|
38 | void geteplugintree(void); | |
39 | void treeChanged(const QList<socexplorerplugin*>& drivers); |
|
39 | void treeChanged(const QList<socexplorerplugin*>& drivers); | |
40 | void changeSysDriverInstName(const QString newinstanceName,const QString previnstanceName); |
|
40 | void changeSysDriverInstName(const QString newinstanceName,const QString previnstanceName); | |
41 | void closeSysDriver(const QString instanceName); |
|
41 | void closeSysDriver(const QString instanceName); | |
|
42 | void pluginselected(const QString& instanceName); | |||
42 | public slots: |
|
43 | public slots: | |
43 |
|
44 | |||
44 | private: |
|
45 | private: | |
45 | pluginmanagerWDGT* managerGui; |
|
46 | pluginmanagerWDGT* managerGui; | |
46 |
|
47 | |||
47 | }; |
|
48 | }; | |
48 |
|
49 | |||
49 | #endif // DOCKABLEPLUGINMANAGER_H |
|
50 | #endif // DOCKABLEPLUGINMANAGER_H |
@@ -1,223 +1,234 | |||||
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, Laboratory of Plasmas Physic - CNRS |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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 "mainwindow.h" |
|
22 | #include "mainwindow.h" | |
23 | #include <QDockWidget> |
|
23 | #include <QDockWidget> | |
24 |
|
24 | |||
25 | LPMONMainWindow::LPMONMainWindow(QString ScriptToEval, QWidget *parent) |
|
25 | LPMONMainWindow::LPMONMainWindow(QString ScriptToEval, QWidget *parent) | |
26 | : QMainWindow(parent) |
|
26 | : QMainWindow(parent) | |
27 | { |
|
27 | { | |
28 | QCoreApplication::setApplicationName("SocExplorer"); |
|
28 | QCoreApplication::setApplicationName("SocExplorer"); | |
29 | QCoreApplication::setOrganizationName("LPP"); |
|
29 | QCoreApplication::setOrganizationName("LPP"); | |
30 | QCoreApplication::setOrganizationDomain("lpp.fr"); |
|
30 | QCoreApplication::setOrganizationDomain("lpp.fr"); | |
31 | this->makeObjects(ScriptToEval); |
|
31 | this->makeObjects(ScriptToEval); | |
32 | this->makeLayout(); |
|
32 | this->makeLayout(); | |
33 | this->makeMenu(); |
|
33 | this->makeMenu(); | |
34 | this->makeConnections(); |
|
34 | this->makeConnections(); | |
35 | this->setWindowIcon(QIcon(tr(":/images/logolppcutted.png"))); |
|
35 | this->setWindowIcon(QIcon(tr(":/images/logolppcutted.png"))); | |
36 | this->setAcceptDrops(true); |
|
36 | this->setAcceptDrops(true); | |
37 | this->pluginManager->setRootLoadable(true); |
|
37 | this->pluginManager->setRootLoadable(true); | |
38 | this->PythonConsoleInst->pyConsoleRunFile(ScriptToEval); |
|
38 | this->PythonConsoleInst->pyConsoleRunFile(ScriptToEval); | |
39 | QProgressBar* test = SocExplorerEngine::getProgressBar("test",10); |
|
39 | // QProgressBar* test = SocExplorerEngine::getProgressBar("test",10); | |
40 | statusBar()->setFixedHeight(statusBar()->height()); |
|
40 | // statusBar()->setFixedHeight(statusBar()->height()); | |
41 | SocExplorerEngine::deleteProgressBar(test); |
|
41 | // SocExplorerEngine::deleteProgressBar(test); | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 |
|
44 | |||
45 | void LPMONMainWindow::makeObjects(QString ScriptToEval) |
|
45 | void LPMONMainWindow::makeObjects(QString ScriptToEval) | |
46 | { |
|
46 | { | |
47 | Q_UNUSED(ScriptToEval) |
|
47 | Q_UNUSED(ScriptToEval) | |
48 | pluginsDockContainer = new QMainWindow; |
|
48 | pluginsDockContainer = new QMainWindow; | |
49 | pluginsDockContainer->setWindowFlags(Qt::Widget); |
|
49 | pluginsDockContainer->setWindowFlags(Qt::Widget); | |
50 | pluginsDockContainer->setDockNestingEnabled(true); |
|
50 | pluginsDockContainer->setDockNestingEnabled(true); | |
51 | this->mainWidget = new QSplitter(Qt::Vertical); |
|
51 | this->mainWidget = new QSplitter(Qt::Vertical); | |
52 | this->appTranslator = new QTranslator; |
|
52 | this->appTranslator = new QTranslator; | |
53 | this->Quit = new QAction(tr("&Quit"),this); |
|
53 | this->Quit = new QAction(tr("&Quit"),this); | |
54 | this->Quit->setShortcut(tr("CTRL+Q")); |
|
54 | this->Quit->setShortcut(tr("CTRL+Q")); | |
55 | this->ManagePlugins = new QAction(tr("&Manage Plugins"),this); |
|
55 | this->ManagePlugins = new QAction(tr("&Manage Plugins"),this); | |
56 | this->ManagePlugins->setShortcut(tr("CTRL+P")); |
|
56 | this->ManagePlugins->setShortcut(tr("CTRL+P")); | |
57 | this->regsManager = new QAction(tr("&Manage registers"),this); |
|
57 | this->regsManager = new QAction(tr("&Manage registers"),this); | |
58 | this->exploreRegs = new QAction(tr("&Explore registers"),this); |
|
58 | this->exploreRegs = new QAction(tr("&Explore registers"),this); | |
59 | this->help = new QAction(tr("&Help"),this); |
|
59 | this->help = new QAction(tr("&Help"),this); | |
60 | this->help->setShortcut(tr("CTRL+H")); |
|
60 | this->help->setShortcut(tr("CTRL+H")); | |
61 | this->about = new QAction(tr("&About"),this); |
|
61 | this->about = new QAction(tr("&About"),this); | |
62 | socexplorerproxy::setMainWindow(this); |
|
62 | socexplorerproxy::setMainWindow(this); | |
63 | SocExplorerEngine::setMainWindow(this); |
|
63 | SocExplorerEngine::setMainWindow(this); | |
64 | SocExplorerEngine::xmlModel()->scanXmlFiles(); |
|
64 | SocExplorerEngine::xmlModel()->scanXmlFiles(); | |
65 | this->regExplorer = new regsExplorer(); |
|
65 | this->regExplorer = new regsExplorer(); | |
66 | this->regExplorer->setAllowedAreas(Qt::AllDockWidgetAreas); |
|
66 | this->regExplorer->setAllowedAreas(Qt::AllDockWidgetAreas); | |
67 | this->pluginsDockContainer->addDockWidget(Qt::TopDockWidgetArea,this->regExplorer); |
|
67 | // this->pluginsDockContainer->addDockWidget(Qt::TopDockWidgetArea,this->regExplorer); | |
|
68 | this->addPluginInterface(this->regExplorer); | |||
68 | this->PythonConsoleInst = new PythonConsole(socexplorerproxy::self()); |
|
69 | this->PythonConsoleInst = new PythonConsole(socexplorerproxy::self()); | |
69 | this->PythonConsoleInst->addObject("SocExplorerEngine",SocExplorerEngine::self()); |
|
70 | this->PythonConsoleInst->addObject("SocExplorerEngine",SocExplorerEngine::self()); | |
70 | this->pluginManager = new dockablePluginManager(); |
|
71 | this->pluginManager = new dockablePluginManager(); | |
71 | this->toolpane = new toolBar; |
|
72 | this->toolpane = new toolBar; | |
72 | this->p_about = new aboutsocexplorer(); |
|
73 | this->p_about = new aboutsocexplorer(); | |
73 | } |
|
74 | } | |
74 |
|
75 | |||
75 | void LPMONMainWindow::makeLayout() |
|
76 | void LPMONMainWindow::makeLayout() | |
76 | { |
|
77 | { | |
77 | this->mainWidget->addWidget(pluginsDockContainer); |
|
78 | this->mainWidget->addWidget(pluginsDockContainer); | |
78 | this->mainWidget->addWidget(this->PythonConsoleInst); |
|
79 | this->mainWidget->addWidget(this->PythonConsoleInst); | |
79 | this->toolpane->setAllowedAreas(Qt::RightDockWidgetArea|Qt::LeftDockWidgetArea); |
|
80 | this->toolpane->setAllowedAreas(Qt::RightDockWidgetArea|Qt::LeftDockWidgetArea); | |
80 | this->addDockWidget(Qt::LeftDockWidgetArea,this->toolpane); |
|
81 | this->addDockWidget(Qt::LeftDockWidgetArea,this->toolpane); | |
81 | this->toolpane->addTool(this->pluginManager); |
|
82 | this->toolpane->addTool(this->pluginManager); | |
82 | this->setCentralWidget(this->mainWidget); |
|
83 | this->setCentralWidget(this->mainWidget); | |
83 | } |
|
84 | } | |
84 |
|
85 | |||
85 |
|
86 | |||
86 | void LPMONMainWindow::makeConnections() |
|
87 | void LPMONMainWindow::makeConnections() | |
87 | { |
|
88 | { | |
88 | connect(socexplorerproxy::self(),SIGNAL(clearMenu()),this,SLOT(clearMenu())); |
|
89 | connect(socexplorerproxy::self(),SIGNAL(clearMenu()),this,SLOT(clearMenu())); | |
89 | connect(this,SIGNAL(translateSig()),socexplorerproxy::self(),SLOT(updateText())); |
|
90 | connect(this,SIGNAL(translateSig()),socexplorerproxy::self(),SLOT(updateText())); | |
90 | connect(socexplorerproxy::self(),SIGNAL(addPluginGUI(QDockWidget*)),this,SLOT(addPluginInterface(QDockWidget*))); |
|
91 | connect(socexplorerproxy::self(),SIGNAL(addPluginGUI(QDockWidget*)),this,SLOT(addPluginInterface(QDockWidget*))); | |
91 | connect(this->ManagePlugins,SIGNAL(triggered()),this,SLOT(launchPluginManager())); |
|
92 | connect(this->ManagePlugins,SIGNAL(triggered()),this,SLOT(launchPluginManager())); | |
92 | connect(this->Quit,SIGNAL(triggered()),qApp,SLOT(quit())); |
|
93 | connect(this->Quit,SIGNAL(triggered()),qApp,SLOT(quit())); | |
93 | connect(this,SIGNAL(registerObject(QObject*,QString)),this->PythonConsoleInst,SLOT(registerObject(QObject*,QString))); |
|
94 | connect(this,SIGNAL(registerObject(QObject*,QString)),this->PythonConsoleInst,SLOT(registerObject(QObject*,QString))); | |
94 | connect(socexplorerproxy::self(),SIGNAL(registerObject(QObject*,QString)),this,SIGNAL(registerObject(QObject*,QString))); |
|
95 | connect(socexplorerproxy::self(),SIGNAL(registerObject(QObject*,QString)),this,SIGNAL(registerObject(QObject*,QString))); | |
95 | connect(this->pluginManager,SIGNAL(geteplugintree()),socexplorerproxy::self(),SLOT(geteplugintree())); |
|
96 | connect(this->pluginManager,SIGNAL(geteplugintree()),socexplorerproxy::self(),SLOT(geteplugintree())); | |
96 | connect(socexplorerproxy::self(),SIGNAL(treeChanged(QList<socexplorerplugin*>)),this->pluginManager,SIGNAL(treeChanged(QList<socexplorerplugin*>))); |
|
97 | connect(socexplorerproxy::self(),SIGNAL(treeChanged(QList<socexplorerplugin*>)),this->pluginManager,SIGNAL(treeChanged(QList<socexplorerplugin*>))); | |
97 | connect(this->pluginManager,SIGNAL(changeSysDriverInstName(QString,QString)),socexplorerproxy::self(),SLOT(changeSysDriverInstName(QString,QString))); |
|
98 | connect(this->pluginManager,SIGNAL(changeSysDriverInstName(QString,QString)),socexplorerproxy::self(),SLOT(changeSysDriverInstName(QString,QString))); | |
98 | connect(this->pluginManager,SIGNAL(changeSysDriverInstName(QString,QString)),this->PythonConsoleInst,SLOT(changeSysDriverInstName(QString,QString))); |
|
99 | connect(this->pluginManager,SIGNAL(changeSysDriverInstName(QString,QString)),this->PythonConsoleInst,SLOT(changeSysDriverInstName(QString,QString))); | |
99 | connect(this->pluginManager,SIGNAL(closeSysDriver(QString)),socexplorerproxy::self(),SLOT(closeSysDriver(QString))); |
|
100 | connect(this->pluginManager,SIGNAL(closeSysDriver(QString)),socexplorerproxy::self(),SLOT(closeSysDriver(QString))); | |
100 | connect(this->pluginManager,SIGNAL(closeSysDriver(QString)),this->PythonConsoleInst,SLOT(removeDriver(QString))); |
|
101 | connect(this->pluginManager,SIGNAL(closeSysDriver(QString)),this->PythonConsoleInst,SLOT(removeDriver(QString))); | |
|
102 | connect(this->pluginManager,SIGNAL(pluginselected(QString)),this,SLOT(pluginselected(QString))); | |||
101 | connect(this->about,SIGNAL(triggered()),this,SLOT(showAboutBox())); |
|
103 | connect(this->about,SIGNAL(triggered()),this,SLOT(showAboutBox())); | |
102 | connect(this->exploreRegs,SIGNAL(triggered()),this->regExplorer,SLOT(show())); |
|
104 | connect(this->exploreRegs,SIGNAL(triggered()),this->regExplorer,SLOT(show())); | |
|
105 | ||||
103 | this->pluginManager->connect(this->pluginManager,SIGNAL(loadSysDrviver(QString)),socexplorerproxy::self(),SLOT(loadSysDriver(QString))); |
|
106 | this->pluginManager->connect(this->pluginManager,SIGNAL(loadSysDrviver(QString)),socexplorerproxy::self(),SLOT(loadSysDriver(QString))); | |
104 | this->pluginManager->connect(this->pluginManager,SIGNAL(loadSysDriverToParent(QString,QString)),socexplorerproxy::self(),SLOT(loadSysDriverToParent(QString,QString))); |
|
107 | this->pluginManager->connect(this->pluginManager,SIGNAL(loadSysDriverToParent(QString,QString)),socexplorerproxy::self(),SLOT(loadSysDriverToParent(QString,QString))); | |
105 |
|
108 | |||
106 | } |
|
109 | } | |
107 |
|
110 | |||
108 |
|
111 | |||
109 | void LPMONMainWindow::launchPluginManager() |
|
112 | void LPMONMainWindow::launchPluginManager() | |
110 | { |
|
113 | { | |
111 |
|
114 | |||
112 | if(this->pluginManager->isHidden()) |
|
115 | if(this->pluginManager->isHidden()) | |
113 | { |
|
116 | { | |
114 | this->pluginManager->setHidden(false); |
|
117 | this->pluginManager->setHidden(false); | |
115 | } |
|
118 | } | |
116 |
|
119 | |||
117 | } |
|
120 | } | |
118 |
|
121 | |||
119 |
|
122 | |||
120 | void LPMONMainWindow::addPluginInterface(QDockWidget *plugin) |
|
123 | void LPMONMainWindow::addPluginInterface(QDockWidget *plugin) | |
121 | { |
|
124 | { | |
122 | static QDockWidget* last=NULL; |
|
125 | static QDockWidget* last=NULL; | |
123 | plugin->setAllowedAreas(Qt::AllDockWidgetAreas); |
|
126 | plugin->setAllowedAreas(Qt::AllDockWidgetAreas); | |
124 | this->pluginsDockContainer->addDockWidget(Qt::TopDockWidgetArea,plugin); |
|
127 | this->pluginsDockContainer->addDockWidget(Qt::TopDockWidgetArea,plugin); | |
125 | if(last!=NULL) |
|
128 | if(last!=NULL) | |
126 | this->pluginsDockContainer->tabifyDockWidget(last,plugin); |
|
129 | this->pluginsDockContainer->tabifyDockWidget(last,plugin); | |
127 | last = plugin; |
|
130 | last = plugin; | |
128 |
|
131 | |||
129 | } |
|
132 | } | |
130 |
|
133 | |||
131 |
|
134 | |||
132 | void LPMONMainWindow::clearMenu() |
|
135 | void LPMONMainWindow::clearMenu() | |
133 | { |
|
136 | { | |
134 | this->menuBar()->clear(); |
|
137 | this->menuBar()->clear(); | |
135 | this->makeMenu(); |
|
138 | this->makeMenu(); | |
136 | } |
|
139 | } | |
137 |
|
140 | |||
138 |
|
141 | |||
139 | void LPMONMainWindow::makeMenu() |
|
142 | void LPMONMainWindow::makeMenu() | |
140 | { |
|
143 | { | |
141 | this->FileMenu = menuBar()->addMenu(tr("&File")); |
|
144 | this->FileMenu = menuBar()->addMenu(tr("&File")); | |
142 | this->PluginsMenu = menuBar()->addMenu(tr("&Plugins")); |
|
145 | this->PluginsMenu = menuBar()->addMenu(tr("&Plugins")); | |
143 | this->ToolsMenu = menuBar()->addMenu(tr("&Tools")); |
|
146 | this->ToolsMenu = menuBar()->addMenu(tr("&Tools")); | |
144 | this->ToolsMenu->addAction(this->exploreRegs); |
|
147 | this->ToolsMenu->addAction(this->exploreRegs); | |
145 | this->FileMenu->addAction(this->Quit); |
|
148 | this->FileMenu->addAction(this->Quit); | |
146 | socexplorerproxy::self()->makeMenu(this->PluginsMenu); |
|
149 | socexplorerproxy::self()->makeMenu(this->PluginsMenu); | |
147 | this->PluginsMenu->addAction(this->ManagePlugins); |
|
150 | this->PluginsMenu->addAction(this->ManagePlugins); | |
148 |
|
151 | |||
149 | this->helpMenu = menuBar()->addMenu(tr("Help")); |
|
152 | this->helpMenu = menuBar()->addMenu(tr("Help")); | |
150 | this->helpMenu->addAction(this->help); |
|
153 | this->helpMenu->addAction(this->help); | |
151 | this->helpMenu->addAction(this->about); |
|
154 | this->helpMenu->addAction(this->about); | |
152 |
|
155 | |||
153 | } |
|
156 | } | |
154 |
|
157 | |||
155 |
|
158 | |||
156 | LPMONMainWindow::~LPMONMainWindow() |
|
159 | LPMONMainWindow::~LPMONMainWindow() | |
157 | { |
|
160 | { | |
158 | delete this->p_about; |
|
161 | delete this->p_about; | |
159 | } |
|
162 | } | |
160 |
|
163 | |||
161 |
|
164 | |||
162 | void LPMONMainWindow::setLangage(QAction *action) |
|
165 | void LPMONMainWindow::setLangage(QAction *action) | |
163 | { |
|
166 | { | |
164 | QString local = action->data().toString(); |
|
167 | QString local = action->data().toString(); | |
165 | QString qmPath = QDir(QString("translations")).absolutePath(); |
|
168 | QString qmPath = QDir(QString("translations")).absolutePath(); | |
166 | appTranslator->load(qmPath+"/socexplorer_"+local+".qm"); |
|
169 | appTranslator->load(qmPath+"/socexplorer_"+local+".qm"); | |
167 | qApp->installTranslator(appTranslator); |
|
170 | qApp->installTranslator(appTranslator); | |
168 | emit this->translateSig(); |
|
171 | emit this->translateSig(); | |
169 | } |
|
172 | } | |
170 |
|
173 | |||
171 |
|
174 | |||
172 | void LPMONMainWindow::createLangMenu() |
|
175 | void LPMONMainWindow::createLangMenu() | |
173 | { |
|
176 | { | |
174 | this->langMenu = menuBar()->addMenu(tr("&Langue")); |
|
177 | this->langMenu = menuBar()->addMenu(tr("&Langue")); | |
175 | this->langActionGrp = new QActionGroup(this); |
|
178 | this->langActionGrp = new QActionGroup(this); | |
176 | connect(this->langActionGrp,SIGNAL(triggered(QAction*)),this,SLOT(setLangage(QAction*))); |
|
179 | connect(this->langActionGrp,SIGNAL(triggered(QAction*)),this,SLOT(setLangage(QAction*))); | |
177 | QDir* qmDir = new QDir(QString("translations")); |
|
180 | QDir* qmDir = new QDir(QString("translations")); | |
178 | QStringList LangFiles = qmDir->entryList(QStringList("socexplorer_*.qm")); |
|
181 | QStringList LangFiles = qmDir->entryList(QStringList("socexplorer_*.qm")); | |
179 | for(int i=0;i<LangFiles.size();++i) |
|
182 | for(int i=0;i<LangFiles.size();++i) | |
180 | { |
|
183 | { | |
181 | QString Local = LangFiles[i]; |
|
184 | QString Local = LangFiles[i]; | |
182 | Local.remove(0,Local.indexOf('_')+1); |
|
185 | Local.remove(0,Local.indexOf('_')+1); | |
183 | Local.chop(3); |
|
186 | Local.chop(3); | |
184 | QTranslator translator; |
|
187 | QTranslator translator; | |
185 | translator.load(LangFiles[i],qmDir->absolutePath()); |
|
188 | translator.load(LangFiles[i],qmDir->absolutePath()); | |
186 | QString langage = translator.translate("MainWindow","English"); |
|
189 | QString langage = translator.translate("MainWindow","English"); | |
187 | QAction *action = new QAction(tr("&%1 %2").arg(i+1).arg(langage),this); |
|
190 | QAction *action = new QAction(tr("&%1 %2").arg(i+1).arg(langage),this); | |
188 | action->setCheckable(true); |
|
191 | action->setCheckable(true); | |
189 | action->setData(Local); |
|
192 | action->setData(Local); | |
190 | langMenu->addAction(action); |
|
193 | langMenu->addAction(action); | |
191 | langActionGrp->addAction(action); |
|
194 | langActionGrp->addAction(action); | |
192 | if(langage==tr("English")) |
|
195 | if(langage==tr("English")) | |
193 | action->setChecked(true); |
|
196 | action->setChecked(true); | |
194 | } |
|
197 | } | |
195 | } |
|
198 | } | |
196 |
|
199 | |||
197 |
|
200 | |||
198 | void LPMONMainWindow::updateText() |
|
201 | void LPMONMainWindow::updateText() | |
199 | { |
|
202 | { | |
200 | emit this->translateSig(); |
|
203 | emit this->translateSig(); | |
201 | } |
|
204 | } | |
202 |
|
205 | |||
203 |
|
206 | |||
204 |
|
207 | |||
205 | void LPMONMainWindow::showAboutBox() |
|
208 | void LPMONMainWindow::showAboutBox() | |
206 | { |
|
209 | { | |
207 | p_about->show(); |
|
210 | p_about->show(); | |
208 | } |
|
211 | } | |
209 |
|
212 | |||
|
213 | void LPMONMainWindow::pluginselected(const QString &instanceName) | |||
|
214 | { | |||
|
215 | socexplorerplugin* drv=socexplorerproxy::self()->getSysDriver(instanceName); | |||
|
216 | // if(drv) | |||
|
217 | // drv->activate(true); | |||
|
218 | // TODO add plugin widget auto focus | |||
|
219 | } | |||
|
220 | ||||
210 |
|
221 | |||
211 |
|
222 | |||
212 | void LPMONMainWindow::closeEvent(QCloseEvent *event) |
|
223 | void LPMONMainWindow::closeEvent(QCloseEvent *event) | |
213 | { |
|
224 | { | |
214 | socexplorerproxy::self()->close(); |
|
225 | socexplorerproxy::self()->close(); | |
215 | qApp->closeAllWindows(); |
|
226 | qApp->closeAllWindows(); | |
216 | event->accept(); |
|
227 | event->accept(); | |
217 | } |
|
228 | } | |
218 |
|
229 | |||
219 |
|
230 | |||
220 |
|
231 | |||
221 |
|
232 | |||
222 |
|
233 | |||
223 |
|
234 |
@@ -1,85 +1,85 | |||||
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, Laboratory of Plasmas Physic - CNRS |
|
3 | -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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 | #ifndef MAINWINDOW_H |
|
22 | #ifndef MAINWINDOW_H | |
23 | #define MAINWINDOW_H |
|
23 | #define MAINWINDOW_H | |
24 |
|
24 | |||
25 | #include <QMainWindow> |
|
25 | #include <QMainWindow> | |
26 | #include <QApplication> |
|
26 | #include <QApplication> | |
27 | #include <QVBoxLayout> |
|
27 | #include <QVBoxLayout> | |
28 | #include <QIcon> |
|
28 | #include <QIcon> | |
29 | #include <QMenuBar> |
|
29 | #include <QMenuBar> | |
30 | #include <QMenu> |
|
30 | #include <QMenu> | |
31 | #include <QAction> |
|
31 | #include <QAction> | |
32 | #include <QDockWidget> |
|
32 | #include <QDockWidget> | |
33 | #include <QTranslator> |
|
33 | #include <QTranslator> | |
34 | #include <QSplitter> |
|
34 | #include <QSplitter> | |
35 | #include "dockablepluginmanager.h" |
|
35 | #include "dockablepluginmanager.h" | |
36 | #include <socexplorerproxy.h> |
|
36 | #include <socexplorerproxy.h> | |
37 | #include "PyWdgt/pythonconsole.h" |
|
37 | #include "PyWdgt/pythonconsole.h" | |
38 | #include "aboutsocexplorer.h" |
|
38 | #include "aboutsocexplorer.h" | |
39 | #include "toolbar.h" |
|
39 | #include "toolbar.h" | |
40 | #include "regsExplorer/regsexplorer.h" |
|
40 | #include "regsExplorer/regsexplorer.h" | |
41 |
|
41 | |||
42 | class LPMONMainWindow : public QMainWindow |
|
42 | class LPMONMainWindow : public QMainWindow | |
43 | { |
|
43 | { | |
44 | Q_OBJECT |
|
44 | Q_OBJECT | |
45 |
|
45 | |||
46 | public: |
|
46 | public: | |
47 | LPMONMainWindow(QString ScriptToEval,QWidget *parent = 0); |
|
47 | LPMONMainWindow(QString ScriptToEval,QWidget *parent = 0); | |
48 | ~LPMONMainWindow(); |
|
48 | ~LPMONMainWindow(); | |
49 | QAction* Quit,*LoadPlugin,*ManagePlugins,*help,*regsManager,*exploreRegs,*about,*translateAction; |
|
49 | QAction* Quit,*LoadPlugin,*ManagePlugins,*help,*regsManager,*exploreRegs,*about,*translateAction; | |
50 | QActionGroup*langActionGrp; |
|
50 | QActionGroup*langActionGrp; | |
51 | QMenu* FileMenu,*PluginsMenu,*ToolsMenu,*langMenu,*helpMenu; |
|
51 | QMenu* FileMenu,*PluginsMenu,*ToolsMenu,*langMenu,*helpMenu; | |
52 | QTranslator* appTranslator; |
|
52 | QTranslator* appTranslator; | |
53 | void createLangMenu(); |
|
53 | void createLangMenu(); | |
54 | void closeEvent(QCloseEvent *event); |
|
54 | void closeEvent(QCloseEvent *event); | |
55 | toolBar* toolpane; |
|
55 | toolBar* toolpane; | |
56 |
|
56 | |||
57 |
|
57 | |||
58 | public slots: |
|
58 | public slots: | |
59 | void launchPluginManager(); |
|
59 | void launchPluginManager(); | |
60 | void addPluginInterface(QDockWidget* plugin); |
|
60 | void addPluginInterface(QDockWidget* plugin); | |
61 | void clearMenu(); |
|
61 | void clearMenu(); | |
62 | void updateText(); |
|
62 | void updateText(); | |
63 | void setLangage(QAction* action); |
|
63 | void setLangage(QAction* action); | |
64 | void showAboutBox(); |
|
64 | void showAboutBox(); | |
65 |
|
65 | void pluginselected(const QString& instanceName); | ||
66 |
|
66 | |||
67 | signals: |
|
67 | signals: | |
68 | void translateSig(); |
|
68 | void translateSig(); | |
69 | void registerObject(QObject* object,const QString& instanceName); |
|
69 | void registerObject(QObject* object,const QString& instanceName); | |
70 |
|
70 | |||
71 | private: |
|
71 | private: | |
72 | void makeObjects(QString ScriptToEval); |
|
72 | void makeObjects(QString ScriptToEval); | |
73 | void makeLayout(); |
|
73 | void makeLayout(); | |
74 | void makeConnections(); |
|
74 | void makeConnections(); | |
75 | void makeMenu(); |
|
75 | void makeMenu(); | |
76 | QMainWindow* pluginsDockContainer; |
|
76 | QMainWindow* pluginsDockContainer; | |
77 | QSplitter* mainWidget; |
|
77 | QSplitter* mainWidget; | |
78 | PythonConsole* PythonConsoleInst; |
|
78 | PythonConsole* PythonConsoleInst; | |
79 | dockablePluginManager* pluginManager; |
|
79 | dockablePluginManager* pluginManager; | |
80 | regsExplorer* regExplorer; |
|
80 | regsExplorer* regExplorer; | |
81 | aboutsocexplorer* p_about; |
|
81 | aboutsocexplorer* p_about; | |
82 |
|
82 | |||
83 | }; |
|
83 | }; | |
84 |
|
84 | |||
85 | #endif // MAINWINDOW_H |
|
85 | #endif // MAINWINDOW_H |
General Comments 0
You need to be logged in to leave comments.
Login now