##// END OF EJS Templates
Session manager almost complete.
Jeandet Alexis -
r94:9652b437323f default
parent child
Show More
@@ -197,6 +197,59 bool SocExplorerSettings::loadSession(co
197 return false;
197 return false;
198 }
198 }
199
199
200 bool SocExplorerSettings::deleteSession()
201 {
202 INIT();
203 if(m_sessionSettings)
204 {
205 m_sessionSettings->clear();
206 QString filename= m_sessionSettings->fileName();
207 if(QFile::exists(filename))
208 {
209 delete m_sessionSettings;
210 QFile::remove(filename);
211 }
212 else
213 delete m_sessionSettings;
214 m_sessionSettings = NULL;
215 return true;
216 }
217 return false;
218 }
219
220 bool SocExplorerSettings::deleteSession(const QString &session)
221 {
222 QFileInfo sessionInfo(m_settings->fileName());
223 QString fullpath=sessionInfo.absoluteDir().absolutePath() +"/"+session+".conf";
224 if(m_sessionSettings)
225 {
226 if(m_sessionSettings->fileName()==fullpath)
227 {
228 deleteSession();
229 return true;
230 }
231 }
232 QSettings* sessionSettings = new QSettings(fullpath,QSettings::NativeFormat,self());
233 if(sessionSettings)
234 {
235 if(sessionSettings->status()==QSettings::NoError)
236 {
237 sessionSettings->clear();
238 QString filename= m_sessionSettings->fileName();
239 if(QFile::exists(filename))
240 {
241 delete sessionSettings;
242 QFile::remove(filename);
243 }
244 else
245 delete sessionSettings;
246 return true;
247 }
248 delete sessionSettings;
249 }
250 return false;
251 }
252
200 void SocExplorerSettings::popConfigDialog()
253 void SocExplorerSettings::popConfigDialog()
201 {
254 {
202 m_configDialog->popConfigDialog(NULL);
255 m_configDialog->popConfigDialog(NULL);
@@ -56,6 +56,8 public:
56 //! \param session Session name.
56 //! \param session Session name.
57 //! \return true if success or false if fails to create session config file.
57 //! \return true if success or false if fails to create session config file.
58 static bool loadSession(const QString& session);
58 static bool loadSession(const QString& session);
59 static bool deleteSession();
60 static bool deleteSession(const QString& session);
59 signals:
61 signals:
60
62
61 public slots:
63 public slots:
@@ -85,6 +85,7 public:
85 //! Default plugin constructor, any plugin should call this constructor.
85 //! Default plugin constructor, any plugin should call this constructor.
86 socexplorerplugin(QWidget *parent = 0,bool createPyObject=true):QDockWidget(parent)
86 socexplorerplugin(QWidget *parent = 0,bool createPyObject=true):QDockWidget(parent)
87 {
87 {
88 Q_UNUSED(createPyObject)
88 closeAction=NULL;
89 closeAction=NULL;
89 menu=NULL;
90 menu=NULL;
90 ChildsMenu=NULL;
91 ChildsMenu=NULL;
@@ -32,6 +32,7 QList<socexplorerplugin*>* socexplorerpr
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 QStringList* socexplorerproxy::linearDriverPathList=NULL;
35
36
36 socexplorerproxy::socexplorerproxy(QObject *parent) :
37 socexplorerproxy::socexplorerproxy(QObject *parent) :
37 QObject(parent)
38 QObject(parent)
@@ -39,6 +40,7 socexplorerproxy::socexplorerproxy(QObje
39 cache = new PluginsCache;
40 cache = new PluginsCache;
40 drivers = new QList<socexplorerplugin*>;
41 drivers = new QList<socexplorerplugin*>;
41 linearDriverList=new QList<socexplorerplugin*>;
42 linearDriverList=new QList<socexplorerplugin*>;
43 linearDriverPathList=new QStringList;
42 root = NULL;
44 root = NULL;
43 }
45 }
44
46
@@ -50,6 +52,7 socexplorerproxy::socexplorerproxy(QMain
50 cache = new PluginsCache;
52 cache = new PluginsCache;
51 drivers = new QList<socexplorerplugin*>;
53 drivers = new QList<socexplorerplugin*>;
52 linearDriverList=new QList<socexplorerplugin*>;
54 linearDriverList=new QList<socexplorerplugin*>;
55 linearDriverPathList=new QStringList;
53 root = NULL;
56 root = NULL;
54 }
57 }
55
58
@@ -77,7 +80,7 void socexplorerproxy::loadSysDriver(con
77 {
80 {
78 socexplorerplugin* driver = pluginloader::newsocexplorerplugin(name);
81 socexplorerplugin* driver = pluginloader::newsocexplorerplugin(name);
79 QString driverName = _self->getinstanceName(driver->baseName());
82 QString driverName = _self->getinstanceName(driver->baseName());
80 loadSysDriver(driver,driverName);
83 loadSysDriver(driver,driverName,name);
81 }
84 }
82 }
85 }
83
86
@@ -87,18 +90,22 void socexplorerproxy::loadSysDriver(con
87 if(pluginloader::libcanberoot(name) && !_self->instanceExists(instanceName))
90 if(pluginloader::libcanberoot(name) && !_self->instanceExists(instanceName))
88 {
91 {
89 socexplorerplugin* driver = pluginloader::newsocexplorerplugin(name);
92 socexplorerplugin* driver = pluginloader::newsocexplorerplugin(name);
90 loadSysDriver(driver,instanceName);
93 loadSysDriver(driver,instanceName,name);
91 }
94 }
92 }
95 }
93
96
94
97
95 void socexplorerproxy::loadSysDriver(socexplorerplugin *driver, const QString instanceName)
98 void socexplorerproxy::loadSysDriver(socexplorerplugin *driver, const QString instanceName, const QString path)
96 {
99 {
97 if(!_self)init();
100 if(!_self)init();
98 driver->setInstanceName(instanceName);
101 driver->setInstanceName(instanceName);
99 driver->parent = NULL;
102 driver->parent = NULL;
100 drivers->append(driver);
103 drivers->append(driver);
101 linearDriverList->append(driver);
104 linearDriverList->append(driver);
105 if(path.isEmpty())
106 linearDriverPathList->append(driver->baseName());
107 else
108 linearDriverPathList->append(path);
102 connectChildToProxy(driver);
109 connectChildToProxy(driver);
103 emit _self->addPluginGUI(driver);
110 emit _self->addPluginGUI(driver);
104 emit _self->clearMenu();
111 emit _self->clearMenu();
@@ -117,7 +124,7 void socexplorerproxy::loadChildSysDrive
117 bool ok=true;
124 bool ok=true;
118 if(ok)
125 if(ok)
119 {
126 {
120 if(parent!=NULL)_self->loadSysDriverToParent(driver,parent,driverName);
127 if(parent!=NULL)_self->loadSysDriverToParent(driver,parent,driverName,child);
121 }
128 }
122 }
129 }
123 }
130 }
@@ -133,7 +140,7 void socexplorerproxy::loadSysDriverToPa
133 if(ok)
140 if(ok)
134 {
141 {
135 socexplorerplugin* parent=_self->getSysDriver(ParentInst);
142 socexplorerplugin* parent=_self->getSysDriver(ParentInst);
136 if(parent!=NULL)loadSysDriverToParent(driver,parent,driverName);
143 if(parent!=NULL)loadSysDriverToParent(driver,parent,driverName,name);
137 }
144 }
138 }
145 }
139 }
146 }
@@ -149,15 +156,19 void socexplorerproxy::loadSysDriverToPa
149 if(ok)
156 if(ok)
150 {
157 {
151 socexplorerplugin* parent=_self->getSysDriver(ParentInst);
158 socexplorerplugin* parent=_self->getSysDriver(ParentInst);
152 if(parent!=NULL)loadSysDriverToParent(driver,parent,instanceName);
159 if(parent!=NULL)loadSysDriverToParent(driver,parent,instanceName,name);
153 }
160 }
154 }
161 }
155 }
162 }
156
163
157 void socexplorerproxy::loadSysDriverToParent(socexplorerplugin *driver,socexplorerplugin *parent, const QString instanceName)
164 void socexplorerproxy::loadSysDriverToParent(socexplorerplugin *driver,socexplorerplugin *parent, const QString instanceName,const QString path)
158 {
165 {
159 if(!_self)init();
166 if(!_self)init();
160 linearDriverList->append(driver);
167 linearDriverList->append(driver);
168 if(path.isEmpty())
169 linearDriverPathList->append(driver->baseName());
170 else
171 linearDriverPathList->append(path);
161 driver->parent = parent;
172 driver->parent = parent;
162 driver->setInstanceName(instanceName);
173 driver->setInstanceName(instanceName);
163 parent->childs.append(driver);
174 parent->childs.append(driver);
@@ -264,6 +275,57 socexplorerplugin *socexplorerproxy::fin
264 return NULL;
275 return NULL;
265 }
276 }
266
277
278 QStringList socexplorerproxy::getPluginsList()
279 {
280 if(!_self)init();
281 QStringList result;
282 socexplorerplugin* plugin;
283 for(int i=0; i<linearDriverList->count();i++)
284 {
285 QString parent="";
286 plugin=linearDriverList->at(i);
287 if(plugin->parent)parent=plugin->parent->instanceName();
288 result.append(linearDriverList->at(i)->instanceName()+":"+parent+":"+linearDriverPathList->at(i));
289 }
290 return result;
291 }
292
293 bool socexplorerproxy::loadPluginsList(QStringList plugins)
294 {
295 if(!_self)init();
296 QString plugin;
297 int lastLoadedPlugins=-1;
298 QStringList loadedPlugins;
299 while(plugins.count() && lastLoadedPlugins!=loadedPlugins.count())
300 {
301 lastLoadedPlugins=loadedPlugins.count();
302 for (int i = 0; i < plugins.count(); i++)
303 {
304 plugin=plugins[i];
305 QStringList args=plugin.split(':',QString::KeepEmptyParts);
306 if(args.count()==3)
307 {
308 if(args[1].isEmpty())
309 {
310 _self->loadSysDriver(args[2],args[0]);
311 loadedPlugins.append(args[0]);
312 plugins.removeAt(i);
313 }
314 else if(loadedPlugins.contains(args[1]))
315 {
316 _self->loadSysDriverToParent(args[2],args[0],args[1]);
317 loadedPlugins.append(args[0]);
318 plugins.removeAt(i);
319 }
320 }
321 else
322 {
323 plugins.removeAt(i);
324 }
325 }
326 }
327 }
328
267 bool socexplorerproxy::instanceExists(const QString &instanceName)
329 bool socexplorerproxy::instanceExists(const QString &instanceName)
268 {
330 {
269 return !socexplorerproxy::instanceNameIsValid(instanceName);
331 return !socexplorerproxy::instanceNameIsValid(instanceName);
@@ -312,6 +374,7 void socexplorerproxy::closeSysDriver(so
312 emit _self->removePluginGUI(driver);
374 emit _self->removePluginGUI(driver);
313 if(driver->parent==NULL)SocExplorerEngine::removeSOC(driver);
375 if(driver->parent==NULL)SocExplorerEngine::removeSOC(driver);
314 while(driver->childs.count()!=0)closeSysDriver(driver->childs.first());
376 while(driver->childs.count()!=0)closeSysDriver(driver->childs.first());
377 linearDriverPathList->removeAt(linearDriverList->indexOf(driver));
315 linearDriverList->removeOne(driver);
378 linearDriverList->removeOne(driver);
316 if(driver->parent!= NULL)
379 if(driver->parent!= NULL)
317 {
380 {
@@ -54,6 +54,8 public:
54 static void disconnectChildToProxy(socexplorerplugin* child);
54 static void disconnectChildToProxy(socexplorerplugin* child);
55 static bool instanceNameIsValid(const QString& instanceName);
55 static bool instanceNameIsValid(const QString& instanceName);
56 static socexplorerplugin* findPlugin(const QString &instanceName);
56 static socexplorerplugin* findPlugin(const QString &instanceName);
57 static QStringList getPluginsList();
58 static bool loadPluginsList( QStringList plugins);
57
59
58 QT_ENSURE_STACK_ALIGNED_FOR_SSE static void loadChildSysDriver(socexplorerplugin* parent,const QString child);
60 QT_ENSURE_STACK_ALIGNED_FOR_SSE static void loadChildSysDriver(socexplorerplugin* parent,const QString child);
59
61
@@ -72,10 +74,10 signals:
72 public slots:
74 public slots:
73 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadSysDriver(const QString name);
75 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadSysDriver(const QString name);
74 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadSysDriver(const QString name,const QString instanceName);
76 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadSysDriver(const QString name,const QString instanceName);
75 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadSysDriver(socexplorerplugin* driver,const QString instanceName);
77 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadSysDriver(socexplorerplugin* driver,const QString instanceName,const QString path="");
76 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadSysDriverToParent(const QString name,const QString ParentInst);
78 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadSysDriverToParent(const QString name,const QString ParentInst);
77 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadSysDriverToParent(const QString name,const QString instanceName,const QString ParentInst);
79 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadSysDriverToParent(const QString name,const QString instanceName,const QString ParentInst);
78 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadSysDriverToParent(socexplorerplugin *driver,socexplorerplugin *parent, const QString instanceName);
80 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadSysDriverToParent(socexplorerplugin *driver,socexplorerplugin *parent, const QString instanceName,const QString path="");
79 QT_ENSURE_STACK_ALIGNED_FOR_SSE void changeSysDriverInstName(const QString instanceName);
81 QT_ENSURE_STACK_ALIGNED_FOR_SSE void changeSysDriverInstName(const QString instanceName);
80 QT_ENSURE_STACK_ALIGNED_FOR_SSE void changeSysDriverInstName(const QString newinstanceName,const QString previnstanceName);
82 QT_ENSURE_STACK_ALIGNED_FOR_SSE void changeSysDriverInstName(const QString newinstanceName,const QString previnstanceName);
81 // QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadChild(socexplorerplugin* parent);
83 // QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadChild(socexplorerplugin* parent);
@@ -95,6 +97,7 private:
95 static QMainWindow* mainWindow;
97 static QMainWindow* mainWindow;
96 static QList<socexplorerplugin*>* drivers;
98 static QList<socexplorerplugin*>* drivers;
97 static QList<socexplorerplugin*>* linearDriverList;
99 static QList<socexplorerplugin*>* linearDriverList;
100 static QStringList* linearDriverPathList;
98 static socexplorerplugin* root;
101 static socexplorerplugin* root;
99 static socexplorerplugin* parent;
102 static socexplorerplugin* parent;
100 static PluginsCache* cache;
103 static PluginsCache* cache;
@@ -34,7 +34,6 SocExplorerMainWindow::SocExplorerMainWi
34 this->makeLayout();
34 this->makeLayout();
35 this->makeMenu();
35 this->makeMenu();
36 SocExplorerSettings::init();
36 SocExplorerSettings::init();
37 SocExplorerSettings::loadSession("Session1");
38 this->makeConnections();
37 this->makeConnections();
39 this->setWindowIcon(QIcon(":/images/icon.png"));
38 this->setWindowIcon(QIcon(":/images/icon.png"));
40 this->setAcceptDrops(true);
39 this->setAcceptDrops(true);
@@ -54,6 +53,7 void SocExplorerMainWindow::makeObjects(
54 Q_UNUSED(ScriptToEval)
53 Q_UNUSED(ScriptToEval)
55 this->p_pluginGUIlist = new QList<QDockWidget*>();
54 this->p_pluginGUIlist = new QList<QDockWidget*>();
56 pluginsDockContainer = new QMainWindow;
55 pluginsDockContainer = new QMainWindow;
56 pluginsDockContainer->setObjectName("pluginsDockContainer");
57 pluginsDockContainer->setWindowFlags(Qt::Widget);
57 pluginsDockContainer->setWindowFlags(Qt::Widget);
58 pluginsDockContainer->setDockNestingEnabled(true);
58 pluginsDockContainer->setDockNestingEnabled(true);
59 this->mainWidget = new QSplitter(Qt::Vertical);
59 this->mainWidget = new QSplitter(Qt::Vertical);
@@ -73,11 +73,13 void SocExplorerMainWindow::makeObjects(
73 SocExplorerEngine::xmlModel()->scanXmlFiles();
73 SocExplorerEngine::xmlModel()->scanXmlFiles();
74 this->regExplorer = new RegsExplorer();
74 this->regExplorer = new RegsExplorer();
75 this->regExplorer->setAllowedAreas(Qt::AllDockWidgetAreas);
75 this->regExplorer->setAllowedAreas(Qt::AllDockWidgetAreas);
76 this->regExplorer->setObjectName("regExplorer");
76 this->addPluginInterface(this->regExplorer);
77 this->addPluginInterface(this->regExplorer);
77 this->PythonConsoleInst = new PythonConsole(socexplorerproxy::self());
78 this->PythonConsoleInst = new PythonConsole(socexplorerproxy::self());
78 this->PythonConsoleInst->addObject("SocExplorerEngine",SocExplorerEngine::self());
79 this->PythonConsoleInst->addObject("SocExplorerEngine",SocExplorerEngine::self());
79 this->pluginManager = new dockablePluginManager();
80 this->pluginManager = new dockablePluginManager();
80 this->toolpane = new toolBar;
81 this->toolpane = new toolBar;
82 this->toolpane->setObjectName("toolpane");
81 this->p_about = new aboutsocexplorer();
83 this->p_about = new aboutsocexplorer();
82 }
84 }
83
85
@@ -112,7 +114,8 void SocExplorerMainWindow::makeConnecti
112 connect(this->about,SIGNAL(triggered()),this,SLOT(showAboutBox()));
114 connect(this->about,SIGNAL(triggered()),this,SLOT(showAboutBox()));
113 connect(this->exploreRegs,SIGNAL(triggered()),this->regExplorer,SLOT(show()));
115 connect(this->exploreRegs,SIGNAL(triggered()),this->regExplorer,SLOT(show()));
114
116
115 connect(this->sessionManagerAction, SIGNAL(triggered(bool)),this->p_SessionManagerDialog,SLOT(show()));
117 connect(this->sessionManagerAction, SIGNAL(triggered(bool)),this,SLOT(showSessionManager(bool)));
118 connect(this->p_SessionManagerDialog, SIGNAL(switchSession(QString)),this,SLOT(setActiveSession(QString)));
116
119
117 this->pluginManager->connect(this->pluginManager,SIGNAL(loadSysDrviver(QString)),socexplorerproxy::self(),SLOT(loadSysDriver(QString)));
120 this->pluginManager->connect(this->pluginManager,SIGNAL(loadSysDrviver(QString)),socexplorerproxy::self(),SLOT(loadSysDriver(QString)));
118 this->pluginManager->connect(this->pluginManager,SIGNAL(loadSysDriverToParent(QString,QString)),socexplorerproxy::self(),SLOT(loadSysDriverToParent(QString,QString)));
121 this->pluginManager->connect(this->pluginManager,SIGNAL(loadSysDriverToParent(QString,QString)),socexplorerproxy::self(),SLOT(loadSysDriverToParent(QString,QString)));
@@ -122,12 +125,10 void SocExplorerMainWindow::makeConnecti
122
125
123 void SocExplorerMainWindow::launchPluginManager()
126 void SocExplorerMainWindow::launchPluginManager()
124 {
127 {
125
126 if(this->pluginManager->isHidden())
128 if(this->pluginManager->isHidden())
127 {
129 {
128 this->pluginManager->setHidden(false);
130 this->pluginManager->setHidden(false);
129 }
131 }
130
131 }
132 }
132
133
133
134
@@ -158,6 +159,7 void SocExplorerMainWindow::makeMenu()
158 {
159 {
159 this->FileMenu = menuBar()->addMenu(tr("&File"));
160 this->FileMenu = menuBar()->addMenu(tr("&File"));
160 this->SessionsMenu = this->FileMenu->addMenu(tr("&Sessions"));
161 this->SessionsMenu = this->FileMenu->addMenu(tr("&Sessions"));
162 this->loadSessions();
161 this->sessionManagerAction = this->FileMenu->addAction(tr("&Session manager..."));
163 this->sessionManagerAction = this->FileMenu->addAction(tr("&Session manager..."));
162 this->SettingsMenu = menuBar()->addMenu(tr("&Settings"));
164 this->SettingsMenu = menuBar()->addMenu(tr("&Settings"));
163 SocExplorerGUI::registerMenuBar(menuBar(),this->FileMenu,this->SettingsMenu);
165 SocExplorerGUI::registerMenuBar(menuBar(),this->FileMenu,this->SettingsMenu);
@@ -177,13 +179,57 void SocExplorerMainWindow::makeMenu()
177 void SocExplorerMainWindow::loadSessions()
179 void SocExplorerMainWindow::loadSessions()
178 {
180 {
179 p_Sessions=this->p_SessionManagerDialog->getSessionsList();
181 p_Sessions=this->p_SessionManagerDialog->getSessionsList();
182 sessionsActions_t* sact;
183 QString stext;
184 foreach (sact, sessionsActions)
185 {
186 sessionsActions.removeAll(sact);
187 SessionsMenu->removeAction(sact);
188 disconnect(sact);
189 delete sact;
190 }
191 foreach (stext, p_Sessions)
192 {
193 sact = new sessionsActions_t(stext,this);
194 sact->setCheckable(true);
195 connect(sact,SIGNAL(triggered(QString)),this,SLOT(setActiveSession(QString)));
196 sessionsActions.append(sact);
197 SessionsMenu->addAction(sact);
198 }
199 }
200
201 void SocExplorerMainWindow::savePlugins()
202 {
203
204 }
205
206 void SocExplorerMainWindow::saveCurrentSession()
207 {
208 if(p_currentSession.isEmpty())
209 {
210 SocExplorerSettings::loadSession("default");
211 }
212 SocExplorerSettings::setValue("GLOBAL","LastModified",QDate::currentDate().toString(),SocExplorerSettings::Session);
213 SocExplorerSettings::setValue(this,"DOCK_LOCATIONS",this->saveState(0),SocExplorerSettings::Session);
214 SocExplorerSettings::setValue(this,"MAIN_WINDOW_GEOMETRY",this->saveGeometry(),SocExplorerSettings::Session);
215 QStringList plugins = socexplorerproxy::getPluginsList();
216 SocExplorerSettings::setValue(this,"LOADED_PLUGINS",QVariant(plugins),SocExplorerSettings::Session);
217 SocExplorerSettings::sync();
218 }
219
220 void SocExplorerMainWindow::loadCurrentSession()
221 {
222
223 QStringList plugins = SocExplorerSettings::value(this,"LOADED_PLUGINS",QVariant(),SocExplorerSettings::Session).toStringList();
224 socexplorerproxy::loadPluginsList(plugins);
225 this->restoreGeometry(SocExplorerSettings::value(this,"MAIN_WINDOW_GEOMETRY",QVariant(),SocExplorerSettings::Session).toByteArray());
226 this->restoreState(SocExplorerSettings::value(this,"DOCK_LOCATIONS",QVariant(),SocExplorerSettings::Session).toByteArray());
180 }
227 }
181
228
182
229
183 SocExplorerMainWindow::~SocExplorerMainWindow()
230 SocExplorerMainWindow::~SocExplorerMainWindow()
184 {
231 {
185 SocExplorerSettings::setValue("GLOBAL","LastModified",QDate::currentDate().toString(),SocExplorerSettings::Session);
232
186 SocExplorerSettings::sync();
187 }
233 }
188
234
189
235
@@ -242,10 +288,34 void SocExplorerMainWindow::pluginselect
242 drv->raise();
288 drv->raise();
243 }
289 }
244
290
291 void SocExplorerMainWindow::setActiveSession(const QString &session)
292 {
293 if(!(p_currentSession.isNull() && session=="default"))
294 saveCurrentSession();
295 socexplorerproxy::self()->close();
296 this->p_currentSession = session;
297 sessionsActions_t* sact;
298 SocExplorerSettings::loadSession(session);
299 loadCurrentSession();
300 foreach (sact, sessionsActions)
301 {
302 if(sact->text().compare(session))
303 sact->setChecked(false);
304 else
305 sact->setChecked(true);
306 }
307 }
308
309 void SocExplorerMainWindow::showSessionManager(bool)
310 {
311 this->p_SessionManagerDialog->show();
312 }
313
245
314
246
315
247 void SocExplorerMainWindow::closeEvent(QCloseEvent *event)
316 void SocExplorerMainWindow::closeEvent(QCloseEvent *event)
248 {
317 {
318 saveCurrentSession();
249 socexplorerproxy::self()->close();
319 socexplorerproxy::self()->close();
250 qApp->closeAllWindows();
320 qApp->closeAllWindows();
251 event->accept();
321 event->accept();
@@ -40,15 +40,35
40 #include "regsExplorer/regsexplorer.h"
40 #include "regsExplorer/regsexplorer.h"
41 #include "socexplorergui.h"
41 #include "socexplorergui.h"
42 #include "sessionmanagerdialog.h"
42 #include "sessionmanagerdialog.h"
43 class sessionsActions_t: public QAction
44 {
45 Q_OBJECT
46 public:
47 sessionsActions_t(const QString &text, QObject* parent)
48 : QAction(text,parent)
49 {
50 connect(this,SIGNAL(triggered(bool)),this,SLOT(p_triggered(bool)));
51 }
52 signals:
53 void triggered(const QString & session);
54 private slots:
55 void p_triggered(bool checked = false)
56 {
57 Q_UNUSED(checked)
58 emit triggered(this->text());
59 }
60 };
43
61
44 class SocExplorerMainWindow : public QMainWindow
62 class SocExplorerMainWindow : public QMainWindow
45 {
63 {
46 Q_OBJECT
64 Q_OBJECT
47
65
66
48 public:
67 public:
49 SocExplorerMainWindow(QString ScriptToEval,QWidget *parent = 0);
68 SocExplorerMainWindow(QString ScriptToEval,QWidget *parent = 0);
50 ~SocExplorerMainWindow();
69 ~SocExplorerMainWindow();
51 QAction* Quit,*LoadPlugin,*ManagePlugins,*help,*regsManager,*exploreRegs,*about,*translateAction,*sessionManagerAction;
70 QAction* Quit,*LoadPlugin,*ManagePlugins,*help,*regsManager,*exploreRegs,*about,*translateAction,*sessionManagerAction;
71 QList<sessionsActions_t*> sessionsActions;
52 QActionGroup*langActionGrp;
72 QActionGroup*langActionGrp;
53 QMenu* FileMenu,*SettingsMenu,*PluginsMenu,*ToolsMenu,*langMenu,*helpMenu,*SessionsMenu;
73 QMenu* FileMenu,*SettingsMenu,*PluginsMenu,*ToolsMenu,*langMenu,*helpMenu,*SessionsMenu;
54 QTranslator* appTranslator;
74 QTranslator* appTranslator;
@@ -66,7 +86,8 public slots:
66 void setLangage(QAction* action);
86 void setLangage(QAction* action);
67 void showAboutBox();
87 void showAboutBox();
68 void pluginselected(const QString& instanceName);
88 void pluginselected(const QString& instanceName);
69
89 void setActiveSession(const QString & session);
90 void showSessionManager(bool);
70 signals:
91 signals:
71 void translateSig();
92 void translateSig();
72 void registerObject(QObject* object,const QString& instanceName);
93 void registerObject(QObject* object,const QString& instanceName);
@@ -77,6 +98,9 private:
77 void makeConnections();
98 void makeConnections();
78 void makeMenu();
99 void makeMenu();
79 void loadSessions();
100 void loadSessions();
101 void savePlugins();
102 void saveCurrentSession();
103 void loadCurrentSession();
80 QMainWindow* pluginsDockContainer;
104 QMainWindow* pluginsDockContainer;
81 QSplitter* mainWidget;
105 QSplitter* mainWidget;
82 PythonConsole* PythonConsoleInst;
106 PythonConsole* PythonConsoleInst;
@@ -85,6 +109,7 private:
85 aboutsocexplorer* p_about;
109 aboutsocexplorer* p_about;
86 QList<QDockWidget*>* p_pluginGUIlist;
110 QList<QDockWidget*>* p_pluginGUIlist;
87 QStringList p_Sessions;
111 QStringList p_Sessions;
112 QString p_currentSession;
88 SessionManagerDialog* p_SessionManagerDialog;
113 SessionManagerDialog* p_SessionManagerDialog;
89 };
114 };
90
115
@@ -33,6 +33,8 SessionManagerDialog::SessionManagerDial
33 ui->setupUi(this);
33 ui->setupUi(this);
34 connect(this->ui->NewQPB,SIGNAL(clicked(bool)),this,SLOT(newSession()));
34 connect(this->ui->NewQPB,SIGNAL(clicked(bool)),this,SLOT(newSession()));
35 connect(this->ui->DeleteQPB,SIGNAL(clicked(bool)),this,SLOT(deleteSession()));
35 connect(this->ui->DeleteQPB,SIGNAL(clicked(bool)),this,SLOT(deleteSession()));
36 connect(this->ui->RenameQPB,SIGNAL(clicked(bool)),this,SLOT(renameSession()));
37 connect(this->ui->SwitchToQPB,SIGNAL(clicked(bool)),this,SLOT(switchSession()));
36 }
38 }
37
39
38 SessionManagerDialog::~SessionManagerDialog()
40 SessionManagerDialog::~SessionManagerDialog()
@@ -63,6 +65,7 QStringList SessionManagerDialog::getSes
63 void SessionManagerDialog::show()
65 void SessionManagerDialog::show()
64 {
66 {
65 QStringList sessions = getSessionsList();
67 QStringList sessions = getSessionsList();
68 this->ui->listWidget->clear();
66 this->ui->listWidget->addItems(sessions);
69 this->ui->listWidget->addItems(sessions);
67 QDialog::show();
70 QDialog::show();
68 }
71 }
@@ -73,7 +76,7 void SessionManagerDialog::newSession()
73 QString text;
76 QString text;
74 do
77 do
75 {
78 {
76 text = QInputDialog::getText(this, tr("QInputDialog::getText()"),
79 text = QInputDialog::getText(this, tr("SocExplorer Session Manager"),
77 tr("Session name:"), QLineEdit::Normal,
80 tr("Session name:"), QLineEdit::Normal,
78 "New Session", &ok);
81 "New Session", &ok);
79 exists = sessionExists(text);
82 exists = sessionExists(text);
@@ -83,7 +86,7 void SessionManagerDialog::newSession()
83 tr("The session ")+text+tr(" already exists."),
86 tr("The session ")+text+tr(" already exists."),
84 QMessageBox::Ok);
87 QMessageBox::Ok);
85 }
88 }
86 }while(ok && !text.isEmpty() && exists);
89 }while(ok && (text.isEmpty() || exists));
87
90
88 if (ok && !text.isEmpty())
91 if (ok && !text.isEmpty())
89 {
92 {
@@ -102,7 +105,28 void SessionManagerDialog::newSession(QS
102
105
103 void SessionManagerDialog::renameSession()
106 void SessionManagerDialog::renameSession()
104 {
107 {
108 bool ok=true;
109 int exists=0;
110 QListWidgetItem* item = this->ui->listWidget->currentItem();
111 QString text= item->text();
112 do
113 {
114 text = QInputDialog::getText(this, tr("SocExplorer Session Manager"),
115 tr("New session name:"), QLineEdit::Normal,
116 text, &ok);
117 exists = sessionExists(text);
118 if(exists&& ok)
119 {
120 QMessageBox::warning(this, tr("SocExplorer Session Manager"),
121 tr("The session ")+text+tr(" already exists."),
122 QMessageBox::Ok);
123 }
124 }while(ok && text.isEmpty());
105
125
126 if (ok && !text.isEmpty())
127 {
128 item->setText(text);
129 }
106 }
130 }
107
131
108 void SessionManagerDialog::deleteSession()
132 void SessionManagerDialog::deleteSession()
@@ -113,21 +137,28 void SessionManagerDialog::deleteSession
113 if(item && item->text().compare("default"))
137 if(item && item->text().compare("default"))
114 {
138 {
115 this->ui->listWidget->removeItemWidget(item);
139 this->ui->listWidget->removeItemWidget(item);
116 //TODO delete session FILE!
140 SocExplorerSettings::deleteSession(item->text());
117 delete item;
141 delete item;
118 updateSessionList();
142 updateSessionList();
119 }
143 }
120 }
144 }
121 }
145 }
122
146
123 bool SessionManagerDialog::sessionExists(QString session)
147 void SessionManagerDialog::switchSession()
124 {
148 {
125 bool diff=true;
149 QListWidgetItem* item = this->ui->listWidget->currentItem();
150 if(item)
151 emit switchSession(item->text());
152 }
153
154 int SessionManagerDialog::sessionExists(QString session)
155 {
156 int exists=0;
126 for(int i=0;i< this->ui->listWidget->count();i++)
157 for(int i=0;i< this->ui->listWidget->count();i++)
127 {
158 {
128 diff &= (this->ui->listWidget->item(i)->text().compare(session)!=0);
159 exists += (this->ui->listWidget->item(i)->text().compare(session)==0);
129 }
160 }
130 return !diff;
161 return exists;
131 }
162 }
132
163
133 void SessionManagerDialog::updateSessionList()
164 void SessionManagerDialog::updateSessionList()
@@ -39,11 +39,15 public:
39 QStringList getSessionsList();
39 QStringList getSessionsList();
40 public slots:
40 public slots:
41 void show();
41 void show();
42 void newSession(QString session);
43 int sessionExists(QString session);
44 private slots:
42 void newSession();
45 void newSession();
43 void newSession(QString session);
44 void renameSession();
46 void renameSession();
45 void deleteSession();
47 void deleteSession();
46 bool sessionExists(QString session);
48 void switchSession();
49 signals:
50 void switchSession(QString session);
47
51
48 private:
52 private:
49 void updateSessionList();
53 void updateSessionList();
@@ -11,7 +11,7
11 </rect>
11 </rect>
12 </property>
12 </property>
13 <property name="windowTitle">
13 <property name="windowTitle">
14 <string>Dialog</string>
14 <string>SocExplorer Session Manager</string>
15 </property>
15 </property>
16 <layout class="QGridLayout" name="gridLayout">
16 <layout class="QGridLayout" name="gridLayout">
17 <item row="0" column="0">
17 <item row="0" column="0">
General Comments 0
You need to be logged in to leave comments. Login now