messagingapp/msgui/msgapp/src/msgmainwindow.cpp
changeset 76 60a8a215b0ec
parent 73 ecf6a73a9186
--- a/messagingapp/msgui/msgapp/src/msgmainwindow.cpp	Tue Oct 05 13:58:47 2010 +0530
+++ b/messagingapp/msgui/msgapp/src/msgmainwindow.cpp	Tue Oct 19 11:30:16 2010 +0530
@@ -35,8 +35,10 @@
 // MsgMainWindow::MsgMainWindow
 // Constructor
 //---------------------------------------------------------------
-MsgMainWindow::MsgMainWindow(bool serviceRequest, QWidget *parent) :
-HbMainWindow(parent), mMsgSI(0), mMsgSendSI(0)
+MsgMainWindow::MsgMainWindow(bool serviceRequest,
+    MsgActivityHandler *handler,
+    QWidget *parent) :
+HbMainWindow(parent), mMsgSI(0), mMsgSendSI(0),mActivityHandler(handler)
 {
     initialize(serviceRequest);    
 }
@@ -49,10 +51,8 @@
 {
     int activityMsgId = INVALID_MSGID;
     
-    MsgActivityHandler* activityHandler = 
-            new MsgActivityHandler(this);
         
-    AfActivation *activation = new AfActivation( this );
+    AfActivation *activation = mActivityHandler->activation();
     
     Af::ActivationReason reason = activation->reason();      
     
@@ -63,12 +63,15 @@
         
         QString actName = activation->name();
                 
-        QVariant data = activityHandler->activitiyStorage()->activityData(actName);        
+        QVariant data = mActivityHandler->activitiyStorage()->
+                                                         activityData(actName);        
         
-        activityMsgId = activityHandler->parseActivityData(data);
+        activityMsgId = mActivityHandler->parseActivityData(data);
         }
     
     mViewManager = new MsgViewManager(serviceRequest,this,this,activityMsgId);
+    mViewManager->setActivityHandler(mActivityHandler);
+    
     mMsgSI = new MsgServiceInterface(NULL,mViewManager);
     mMsgSendSI = new MsgSendServiceInterface(NULL,mViewManager);
             
@@ -76,14 +79,14 @@
     ConversationsEngine::instance();
     
     // clear the old activities
-    activityHandler->clearActivities();
+    mActivityHandler->clearActivities();
     
     // Set the main window pointer to activity handler.
-    activityHandler->setMainWindow(this); 
+    mActivityHandler->setMainWindow(this); 
     
     // connect to aboutToQuit signal to save drafts content
     QObject::connect(qApp, SIGNAL(aboutToQuit()), 
-            activityHandler, SLOT(saveActivity()));
+        mActivityHandler, SLOT(saveActivity()));
 }
 
 //---------------------------------------------------------------
@@ -135,4 +138,16 @@
 
 }
 
+//---------------------------------------------------------------
+// MsgMainWindow::eventFilter
+// @see header
+//---------------------------------------------------------------
+bool MsgMainWindow::eventFilter(QObject *obj, QEvent *event)
+{
+    if (event->type() == QEvent::ApplicationActivate) {
+        mViewManager->handleApplicationActive();
+    }
+    return QObject::eventFilter(obj, event);
+}
+
 // End of file