##// 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 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 253 void SocExplorerSettings::popConfigDialog()
201 254 {
202 255 m_configDialog->popConfigDialog(NULL);
@@ -56,6 +56,8 public:
56 56 //! \param session Session name.
57 57 //! \return true if success or false if fails to create session config file.
58 58 static bool loadSession(const QString& session);
59 static bool deleteSession();
60 static bool deleteSession(const QString& session);
59 61 signals:
60 62
61 63 public slots:
@@ -85,6 +85,7 public:
85 85 //! Default plugin constructor, any plugin should call this constructor.
86 86 socexplorerplugin(QWidget *parent = 0,bool createPyObject=true):QDockWidget(parent)
87 87 {
88 Q_UNUSED(createPyObject)
88 89 closeAction=NULL;
89 90 menu=NULL;
90 91 ChildsMenu=NULL;
@@ -32,6 +32,7 QList<socexplorerplugin*>* socexplorerpr
32 32 socexplorerplugin* socexplorerproxy::root=NULL;
33 33 socexplorerplugin* socexplorerproxy::parent=NULL;
34 34 PluginsCache* socexplorerproxy::cache=NULL;
35 QStringList* socexplorerproxy::linearDriverPathList=NULL;
35 36
36 37 socexplorerproxy::socexplorerproxy(QObject *parent) :
37 38 QObject(parent)
@@ -39,6 +40,7 socexplorerproxy::socexplorerproxy(QObje
39 40 cache = new PluginsCache;
40 41 drivers = new QList<socexplorerplugin*>;
41 42 linearDriverList=new QList<socexplorerplugin*>;
43 linearDriverPathList=new QStringList;
42 44 root = NULL;
43 45 }
44 46
@@ -50,6 +52,7 socexplorerproxy::socexplorerproxy(QMain
50 52 cache = new PluginsCache;
51 53 drivers = new QList<socexplorerplugin*>;
52 54 linearDriverList=new QList<socexplorerplugin*>;
55 linearDriverPathList=new QStringList;
53 56 root = NULL;
54 57 }
55 58
@@ -77,7 +80,7 void socexplorerproxy::loadSysDriver(con
77 80 {
78 81 socexplorerplugin* driver = pluginloader::newsocexplorerplugin(name);
79 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 90 if(pluginloader::libcanberoot(name) && !_self->instanceExists(instanceName))
88 91 {
89 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 100 if(!_self)init();
98 101 driver->setInstanceName(instanceName);
99 102 driver->parent = NULL;
100 103 drivers->append(driver);
101 104 linearDriverList->append(driver);
105 if(path.isEmpty())
106 linearDriverPathList->append(driver->baseName());
107 else
108 linearDriverPathList->append(path);
102 109 connectChildToProxy(driver);
103 110 emit _self->addPluginGUI(driver);
104 111 emit _self->clearMenu();
@@ -117,7 +124,7 void socexplorerproxy::loadChildSysDrive
117 124 bool ok=true;
118 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 140 if(ok)
134 141 {
135 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 156 if(ok)
150 157 {
151 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 166 if(!_self)init();
160 167 linearDriverList->append(driver);
168 if(path.isEmpty())
169 linearDriverPathList->append(driver->baseName());
170 else
171 linearDriverPathList->append(path);
161 172 driver->parent = parent;
162 173 driver->setInstanceName(instanceName);
163 174 parent->childs.append(driver);
@@ -264,6 +275,57 socexplorerplugin *socexplorerproxy::fin
264 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 329 bool socexplorerproxy::instanceExists(const QString &instanceName)
268 330 {
269 331 return !socexplorerproxy::instanceNameIsValid(instanceName);
@@ -312,6 +374,7 void socexplorerproxy::closeSysDriver(so
312 374 emit _self->removePluginGUI(driver);
313 375 if(driver->parent==NULL)SocExplorerEngine::removeSOC(driver);
314 376 while(driver->childs.count()!=0)closeSysDriver(driver->childs.first());
377 linearDriverPathList->removeAt(linearDriverList->indexOf(driver));
315 378 linearDriverList->removeOne(driver);
316 379 if(driver->parent!= NULL)
317 380 {
@@ -54,6 +54,8 public:
54 54 static void disconnectChildToProxy(socexplorerplugin* child);
55 55 static bool instanceNameIsValid(const QString& instanceName);
56 56 static socexplorerplugin* findPlugin(const QString &instanceName);
57 static QStringList getPluginsList();
58 static bool loadPluginsList( QStringList plugins);
57 59
58 60 QT_ENSURE_STACK_ALIGNED_FOR_SSE static void loadChildSysDriver(socexplorerplugin* parent,const QString child);
59 61
@@ -72,10 +74,10 signals:
72 74 public slots:
73 75 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadSysDriver(const QString name);
74 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 78 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadSysDriverToParent(const QString name,const QString ParentInst);
77 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 81 QT_ENSURE_STACK_ALIGNED_FOR_SSE void changeSysDriverInstName(const QString instanceName);
80 82 QT_ENSURE_STACK_ALIGNED_FOR_SSE void changeSysDriverInstName(const QString newinstanceName,const QString previnstanceName);
81 83 // QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadChild(socexplorerplugin* parent);
@@ -95,6 +97,7 private:
95 97 static QMainWindow* mainWindow;
96 98 static QList<socexplorerplugin*>* drivers;
97 99 static QList<socexplorerplugin*>* linearDriverList;
100 static QStringList* linearDriverPathList;
98 101 static socexplorerplugin* root;
99 102 static socexplorerplugin* parent;
100 103 static PluginsCache* cache;
@@ -34,7 +34,6 SocExplorerMainWindow::SocExplorerMainWi
34 34 this->makeLayout();
35 35 this->makeMenu();
36 36 SocExplorerSettings::init();
37 SocExplorerSettings::loadSession("Session1");
38 37 this->makeConnections();
39 38 this->setWindowIcon(QIcon(":/images/icon.png"));
40 39 this->setAcceptDrops(true);
@@ -54,6 +53,7 void SocExplorerMainWindow::makeObjects(
54 53 Q_UNUSED(ScriptToEval)
55 54 this->p_pluginGUIlist = new QList<QDockWidget*>();
56 55 pluginsDockContainer = new QMainWindow;
56 pluginsDockContainer->setObjectName("pluginsDockContainer");
57 57 pluginsDockContainer->setWindowFlags(Qt::Widget);
58 58 pluginsDockContainer->setDockNestingEnabled(true);
59 59 this->mainWidget = new QSplitter(Qt::Vertical);
@@ -73,11 +73,13 void SocExplorerMainWindow::makeObjects(
73 73 SocExplorerEngine::xmlModel()->scanXmlFiles();
74 74 this->regExplorer = new RegsExplorer();
75 75 this->regExplorer->setAllowedAreas(Qt::AllDockWidgetAreas);
76 this->regExplorer->setObjectName("regExplorer");
76 77 this->addPluginInterface(this->regExplorer);
77 78 this->PythonConsoleInst = new PythonConsole(socexplorerproxy::self());
78 79 this->PythonConsoleInst->addObject("SocExplorerEngine",SocExplorerEngine::self());
79 80 this->pluginManager = new dockablePluginManager();
80 81 this->toolpane = new toolBar;
82 this->toolpane->setObjectName("toolpane");
81 83 this->p_about = new aboutsocexplorer();
82 84 }
83 85
@@ -112,7 +114,8 void SocExplorerMainWindow::makeConnecti
112 114 connect(this->about,SIGNAL(triggered()),this,SLOT(showAboutBox()));
113 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 120 this->pluginManager->connect(this->pluginManager,SIGNAL(loadSysDrviver(QString)),socexplorerproxy::self(),SLOT(loadSysDriver(QString)));
118 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 126 void SocExplorerMainWindow::launchPluginManager()
124 127 {
125
126 128 if(this->pluginManager->isHidden())
127 129 {
128 130 this->pluginManager->setHidden(false);
129 131 }
130
131 132 }
132 133
133 134
@@ -158,6 +159,7 void SocExplorerMainWindow::makeMenu()
158 159 {
159 160 this->FileMenu = menuBar()->addMenu(tr("&File"));
160 161 this->SessionsMenu = this->FileMenu->addMenu(tr("&Sessions"));
162 this->loadSessions();
161 163 this->sessionManagerAction = this->FileMenu->addAction(tr("&Session manager..."));
162 164 this->SettingsMenu = menuBar()->addMenu(tr("&Settings"));
163 165 SocExplorerGUI::registerMenuBar(menuBar(),this->FileMenu,this->SettingsMenu);
@@ -177,13 +179,57 void SocExplorerMainWindow::makeMenu()
177 179 void SocExplorerMainWindow::loadSessions()
178 180 {
179 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 230 SocExplorerMainWindow::~SocExplorerMainWindow()
184 231 {
185 SocExplorerSettings::setValue("GLOBAL","LastModified",QDate::currentDate().toString(),SocExplorerSettings::Session);
186 SocExplorerSettings::sync();
232
187 233 }
188 234
189 235
@@ -242,10 +288,34 void SocExplorerMainWindow::pluginselect
242 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 316 void SocExplorerMainWindow::closeEvent(QCloseEvent *event)
248 317 {
318 saveCurrentSession();
249 319 socexplorerproxy::self()->close();
250 320 qApp->closeAllWindows();
251 321 event->accept();
@@ -40,15 +40,35
40 40 #include "regsExplorer/regsexplorer.h"
41 41 #include "socexplorergui.h"
42 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 62 class SocExplorerMainWindow : public QMainWindow
45 63 {
46 64 Q_OBJECT
47 65
66
48 67 public:
49 68 SocExplorerMainWindow(QString ScriptToEval,QWidget *parent = 0);
50 69 ~SocExplorerMainWindow();
51 70 QAction* Quit,*LoadPlugin,*ManagePlugins,*help,*regsManager,*exploreRegs,*about,*translateAction,*sessionManagerAction;
71 QList<sessionsActions_t*> sessionsActions;
52 72 QActionGroup*langActionGrp;
53 73 QMenu* FileMenu,*SettingsMenu,*PluginsMenu,*ToolsMenu,*langMenu,*helpMenu,*SessionsMenu;
54 74 QTranslator* appTranslator;
@@ -66,7 +86,8 public slots:
66 86 void setLangage(QAction* action);
67 87 void showAboutBox();
68 88 void pluginselected(const QString& instanceName);
69
89 void setActiveSession(const QString & session);
90 void showSessionManager(bool);
70 91 signals:
71 92 void translateSig();
72 93 void registerObject(QObject* object,const QString& instanceName);
@@ -77,6 +98,9 private:
77 98 void makeConnections();
78 99 void makeMenu();
79 100 void loadSessions();
101 void savePlugins();
102 void saveCurrentSession();
103 void loadCurrentSession();
80 104 QMainWindow* pluginsDockContainer;
81 105 QSplitter* mainWidget;
82 106 PythonConsole* PythonConsoleInst;
@@ -85,6 +109,7 private:
85 109 aboutsocexplorer* p_about;
86 110 QList<QDockWidget*>* p_pluginGUIlist;
87 111 QStringList p_Sessions;
112 QString p_currentSession;
88 113 SessionManagerDialog* p_SessionManagerDialog;
89 114 };
90 115
@@ -33,6 +33,8 SessionManagerDialog::SessionManagerDial
33 33 ui->setupUi(this);
34 34 connect(this->ui->NewQPB,SIGNAL(clicked(bool)),this,SLOT(newSession()));
35 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 40 SessionManagerDialog::~SessionManagerDialog()
@@ -63,6 +65,7 QStringList SessionManagerDialog::getSes
63 65 void SessionManagerDialog::show()
64 66 {
65 67 QStringList sessions = getSessionsList();
68 this->ui->listWidget->clear();
66 69 this->ui->listWidget->addItems(sessions);
67 70 QDialog::show();
68 71 }
@@ -73,7 +76,7 void SessionManagerDialog::newSession()
73 76 QString text;
74 77 do
75 78 {
76 text = QInputDialog::getText(this, tr("QInputDialog::getText()"),
79 text = QInputDialog::getText(this, tr("SocExplorer Session Manager"),
77 80 tr("Session name:"), QLineEdit::Normal,
78 81 "New Session", &ok);
79 82 exists = sessionExists(text);
@@ -83,7 +86,7 void SessionManagerDialog::newSession()
83 86 tr("The session ")+text+tr(" already exists."),
84 87 QMessageBox::Ok);
85 88 }
86 }while(ok && !text.isEmpty() && exists);
89 }while(ok && (text.isEmpty() || exists));
87 90
88 91 if (ok && !text.isEmpty())
89 92 {
@@ -102,7 +105,28 void SessionManagerDialog::newSession(QS
102 105
103 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 132 void SessionManagerDialog::deleteSession()
@@ -113,21 +137,28 void SessionManagerDialog::deleteSession
113 137 if(item && item->text().compare("default"))
114 138 {
115 139 this->ui->listWidget->removeItemWidget(item);
116 //TODO delete session FILE!
140 SocExplorerSettings::deleteSession(item->text());
117 141 delete item;
118 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 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 164 void SessionManagerDialog::updateSessionList()
@@ -39,11 +39,15 public:
39 39 QStringList getSessionsList();
40 40 public slots:
41 41 void show();
42 void newSession(QString session);
43 int sessionExists(QString session);
44 private slots:
42 45 void newSession();
43 void newSession(QString session);
44 46 void renameSession();
45 47 void deleteSession();
46 bool sessionExists(QString session);
48 void switchSession();
49 signals:
50 void switchSession(QString session);
47 51
48 52 private:
49 53 void updateSessionList();
@@ -11,7 +11,7
11 11 </rect>
12 12 </property>
13 13 <property name="windowTitle">
14 <string>Dialog</string>
14 <string>SocExplorer Session Manager</string>
15 15 </property>
16 16 <layout class="QGridLayout" name="gridLayout">
17 17 <item row="0" column="0">
General Comments 0
You need to be logged in to leave comments. Login now