← Back to team overview

mira-dev team mailing list archive

[Branch ~mira-dev/mira/trunk] Rev 196: Update Contact Widget when a user Joins a workplace if that workplace is active

 

------------------------------------------------------------
revno: 196
fixes bug(s): https://launchpad.net/bugs/570503
committer: Alan Alvarez <aalvarez@xxxxxxxxxxxxx>
branch nick: trunk
timestamp: Wed 2010-04-28 17:37:28 -0400
message:
  Update Contact Widget when a user Joins a workplace if that workplace is active
modified:
  mira-client/include/gui/qt/GuiApp.h
  mira-client/include/gui/qt/MainWindow.h
  mira-client/src/gui/qt/GuiApp.cpp


--
lp:mira
https://code.launchpad.net/~mira-dev/mira/trunk

Your team Mira Core Development Team is subscribed to branch lp:mira.
To unsubscribe from this branch go to https://code.launchpad.net/~mira-dev/mira/trunk/+edit-subscription
=== modified file 'mira-client/include/gui/qt/GuiApp.h'
--- mira-client/include/gui/qt/GuiApp.h	2010-04-20 18:41:11 +0000
+++ mira-client/include/gui/qt/GuiApp.h	2010-04-28 21:37:28 +0000
@@ -49,7 +49,8 @@
 
     protected:
     private:
-        WorkplaceList m_workplaces;
+        Workplace*       m_activeWorkplace;
+        WorkplaceList    m_workplaces;
         QSystemTrayIcon* m_trayIcon;
 };
 } //end gui namespace

=== modified file 'mira-client/include/gui/qt/MainWindow.h'
--- mira-client/include/gui/qt/MainWindow.h	2010-04-20 18:41:11 +0000
+++ mira-client/include/gui/qt/MainWindow.h	2010-04-28 21:37:28 +0000
@@ -47,6 +47,7 @@
         void joinWorkplace();
 
     private:
+        friend class GuiApp;
         void createActions();
         void createMenus();
         void createConnections();

=== modified file 'mira-client/src/gui/qt/GuiApp.cpp'
--- mira-client/src/gui/qt/GuiApp.cpp	2010-04-20 18:41:11 +0000
+++ mira-client/src/gui/qt/GuiApp.cpp	2010-04-28 21:37:28 +0000
@@ -12,7 +12,7 @@
 using std::endl;
 
 using namespace miraclient::gui;
-GuiApp::GuiApp(int& argc, char * argv[]) : QApplication(argc,argv)
+GuiApp::GuiApp(int& argc, char * argv[]) : QApplication(argc,argv), m_activeWorkplace(NULL)
 {
     //ctor
     InitResources();
@@ -71,6 +71,8 @@
     the workplace saved by the settings.  If no workplace is saved in the settings, then it will return the first
     workplace in the list of user's workplaces.  If the user has no workplace, it will return NULL
     */
+    if (m_activeWorkplace != NULL)
+        return m_activeWorkplace;
 
     QString qname = m_settings->value("currentWP").toString();
     std::string name = qname.toStdString();
@@ -124,6 +126,16 @@
 void GuiApp::AddWorkplaceMember(const std::string& workplace, const std::string& username, char status)
 {
     WorkplaceMember member = { username, status };
+
+    // Check if workplace is active workplace first.
+    if (m_activeWorkplace != NULL && m_activeWorkplace->getName() == workplace)
+    {
+        m_activeWorkplace->addMember(member);
+        m_mainWindow->addChat(username.c_str());
+        m_mainWindow->m_contactWidget->addUser(username.c_str(), status);
+        return;
+    }
+
     for (WorkplaceList::iterator Iter = m_workplaces.begin(); Iter != m_workplaces.end(); ++Iter)
     {
         if ((*Iter)->getName() == workplace)
@@ -220,7 +232,8 @@
 
 void GuiApp::setActiveWorkplace(Workplace * wp,Utility * util)
 {
-	emit ChangedWorkplace(wp,util);
+    m_activeWorkplace = wp;
+    emit ChangedWorkplace(wp,util);
 }
 
 void GuiApp::trayMessage(const QString& title, const QString& message)