##// END OF EJS Templates
Session manager ready for release.
jeandet -
r97:9f8fee223cb9 default
parent child
Show More
@@ -118,6 +118,9 void SocExplorerMainWindow::makeConnecti
118 118
119 119 connect(this->sessionManagerAction, SIGNAL(triggered(bool)),this,SLOT(showSessionManager(bool)));
120 120 connect(this->p_SessionManagerDialog, SIGNAL(switchSession(QString)),this,SLOT(setActiveSession(QString)));
121 connect(this->p_SessionManagerDialog, SIGNAL(sessionRenamed(QString,QString)),this,SLOT(renameSession(QString,QString)));
122 connect(this->p_SessionManagerDialog, SIGNAL(sessionAdded(QString)),this,SLOT(addSession(QString)));
123 connect(this->p_SessionManagerDialog, SIGNAL(sessionRemoved(QString)),this,SLOT(removeSession(QString)));
121 124 connect(this->sessionsActions,SIGNAL(triggered(QAction*)),this,SLOT(setActiveSession(QAction*)));
122 125
123 126 this->pluginManager->connect(this->pluginManager,SIGNAL(loadSysDrviver(QString)),socexplorerproxy::self(),SLOT(loadSysDriver(QString)));
@@ -193,13 +196,7 void SocExplorerMainWindow::loadSessions
193 196 }
194 197 foreach (stext, p_Sessions)
195 198 {
196 sact = new QAction(stext,this);
197 sact->setCheckable(true);
198 sact->setData(stext);
199 if(p_currentSession==stext)
200 sact->setChecked(true);
201 sessionsActions->addAction(sact);
202 SessionsMenu->addAction(sact);
199 addSession(stext);
203 200 }
204 201 }
205 202
@@ -316,14 +313,45 void SocExplorerMainWindow::showSessionM
316 313 this->p_SessionManagerDialog->show();
317 314 }
318 315
319 //TODO handle rename
320 void SocExplorerMainWindow::sessionListChanged()
316 void SocExplorerMainWindow::renameSession(const QString &oldName, const QString &newName)
317 {
318 for(int i=0;i<sessionsActions->actions().count();i++)
319 {
320 if(Q_UNLIKELY(sessionsActions->actions().at(i)->text()==oldName))
321 {
322 sessionsActions->actions().at(i)->setText(newName);
323 }
324 }
325 }
326
327 void SocExplorerMainWindow::addSession(const QString &newSession)
321 328 {
329 QAction* sact = new QAction(newSession,this);
330 sact->setCheckable(true);
331 sact->setData(newSession);
332 if(Q_UNLIKELY(p_currentSession==newSession))
333 sact->setChecked(true);
334 sessionsActions->addAction(sact);
335 SessionsMenu->addAction(sact);
336 }
322 337
338 void SocExplorerMainWindow::removeSession(const QString &session)
339 {
340 QAction* sact;
341 foreach (sact, sessionsActions->actions())
342 {
343 if(Q_UNLIKELY(sact->text()==session))
344 {
345 sessionsActions->removeAction(sact);
346 SessionsMenu->removeAction(sact);
347 delete sact;
348 }
349 }
323 350 }
324 351
325 352
326 353
354
327 355 void SocExplorerMainWindow::closeEvent(QCloseEvent *event)
328 356 {
329 357 saveCurrentSession();
@@ -71,7 +71,9 public slots:
71 71 void setActiveSession(const QString & session);
72 72 void setActiveSession(QAction* session);
73 73 void showSessionManager(bool);
74 void sessionListChanged();
74 void renameSession(const QString& oldName,const QString& newName);
75 void addSession(const QString& newSession);
76 void removeSession(const QString& session);
75 77 signals:
76 78 void translateSig();
77 79 void registerObject(QObject* object,const QString& instanceName);
@@ -100,6 +100,7 void SessionManagerDialog::newSession(QS
100 100 {
101 101 this->ui->listWidget->addItem(session);
102 102 updateSessionList();
103 emit sessionAdded(session);
103 104 }
104 105 }
105 106
@@ -127,7 +128,8 void SessionManagerDialog::renameSession
127 128 if (ok && !text.isEmpty())
128 129 {
129 130 item->setText(text);
130 SocExplorerSettings::renameSession(text,OldText);
131 SocExplorerSettings::renameSession(OldText,text);
132 emit sessionRenamed(OldText,text);
131 133 updateSessionList();
132 134 emit sessionListChanged();
133 135 }
@@ -142,6 +144,7 void SessionManagerDialog::deleteSession
142 144 {
143 145 this->ui->listWidget->removeItemWidget(item);
144 146 SocExplorerSettings::deleteSession(item->text());
147 emit sessionRemoved(item->text());
145 148 delete item;
146 149 updateSessionList();
147 150 }
@@ -49,7 +49,9 private slots:
49 49 signals:
50 50 void switchSession(QString session);
51 51 void sessionListChanged();
52
52 void sessionRenamed(const QString& oldName,const QString& newName);
53 void sessionRemoved(const QString& session);
54 void sessionAdded(const QString& newSession);
53 55 private:
54 56 void updateSessionList();
55 57 Ui::SessionManagerDialog *ui;
General Comments 0
You need to be logged in to leave comments. Login now