messagingapp/msgui/msgapp/src/msgmainwindow.cpp
changeset 76 60a8a215b0ec
parent 73 ecf6a73a9186
equal deleted inserted replaced
73:ecf6a73a9186 76:60a8a215b0ec
    33 
    33 
    34 //---------------------------------------------------------------
    34 //---------------------------------------------------------------
    35 // MsgMainWindow::MsgMainWindow
    35 // MsgMainWindow::MsgMainWindow
    36 // Constructor
    36 // Constructor
    37 //---------------------------------------------------------------
    37 //---------------------------------------------------------------
    38 MsgMainWindow::MsgMainWindow(bool serviceRequest, QWidget *parent) :
    38 MsgMainWindow::MsgMainWindow(bool serviceRequest,
    39 HbMainWindow(parent), mMsgSI(0), mMsgSendSI(0)
    39     MsgActivityHandler *handler,
       
    40     QWidget *parent) :
       
    41 HbMainWindow(parent), mMsgSI(0), mMsgSendSI(0),mActivityHandler(handler)
    40 {
    42 {
    41     initialize(serviceRequest);    
    43     initialize(serviceRequest);    
    42 }
    44 }
    43 
    45 
    44 //---------------------------------------------------------------
    46 //---------------------------------------------------------------
    47 //---------------------------------------------------------------
    49 //---------------------------------------------------------------
    48 void MsgMainWindow::initialize(bool serviceRequest)
    50 void MsgMainWindow::initialize(bool serviceRequest)
    49 {
    51 {
    50     int activityMsgId = INVALID_MSGID;
    52     int activityMsgId = INVALID_MSGID;
    51     
    53     
    52     MsgActivityHandler* activityHandler = 
       
    53             new MsgActivityHandler(this);
       
    54         
    54         
    55     AfActivation *activation = new AfActivation( this );
    55     AfActivation *activation = mActivityHandler->activation();
    56     
    56     
    57     Af::ActivationReason reason = activation->reason();      
    57     Af::ActivationReason reason = activation->reason();      
    58     
    58     
    59     if (reason == Af::ActivationReasonActivity) 
    59     if (reason == Af::ActivationReasonActivity) 
    60         {
    60         {
    61         // set service request to false , since its a activity launch
    61         // set service request to false , since its a activity launch
    62         serviceRequest = false;
    62         serviceRequest = false;
    63         
    63         
    64         QString actName = activation->name();
    64         QString actName = activation->name();
    65                 
    65                 
    66         QVariant data = activityHandler->activitiyStorage()->activityData(actName);        
    66         QVariant data = mActivityHandler->activitiyStorage()->
       
    67                                                          activityData(actName);        
    67         
    68         
    68         activityMsgId = activityHandler->parseActivityData(data);
    69         activityMsgId = mActivityHandler->parseActivityData(data);
    69         }
    70         }
    70     
    71     
    71     mViewManager = new MsgViewManager(serviceRequest,this,this,activityMsgId);
    72     mViewManager = new MsgViewManager(serviceRequest,this,this,activityMsgId);
       
    73     mViewManager->setActivityHandler(mActivityHandler);
       
    74     
    72     mMsgSI = new MsgServiceInterface(NULL,mViewManager);
    75     mMsgSI = new MsgServiceInterface(NULL,mViewManager);
    73     mMsgSendSI = new MsgSendServiceInterface(NULL,mViewManager);
    76     mMsgSendSI = new MsgSendServiceInterface(NULL,mViewManager);
    74             
    77             
    75     //Model creation
    78     //Model creation
    76     ConversationsEngine::instance();
    79     ConversationsEngine::instance();
    77     
    80     
    78     // clear the old activities
    81     // clear the old activities
    79     activityHandler->clearActivities();
    82     mActivityHandler->clearActivities();
    80     
    83     
    81     // Set the main window pointer to activity handler.
    84     // Set the main window pointer to activity handler.
    82     activityHandler->setMainWindow(this); 
    85     mActivityHandler->setMainWindow(this); 
    83     
    86     
    84     // connect to aboutToQuit signal to save drafts content
    87     // connect to aboutToQuit signal to save drafts content
    85     QObject::connect(qApp, SIGNAL(aboutToQuit()), 
    88     QObject::connect(qApp, SIGNAL(aboutToQuit()), 
    86             activityHandler, SLOT(saveActivity()));
    89         mActivityHandler, SLOT(saveActivity()));
    87 }
    90 }
    88 
    91 
    89 //---------------------------------------------------------------
    92 //---------------------------------------------------------------
    90 // MsgMainWindow::~MsgMainWindow
    93 // MsgMainWindow::~MsgMainWindow
    91 // Constructor
    94 // Constructor
   133         HbMainWindow::keyPressEvent(event);
   136         HbMainWindow::keyPressEvent(event);
   134     }
   137     }
   135 
   138 
   136 }
   139 }
   137 
   140 
       
   141 //---------------------------------------------------------------
       
   142 // MsgMainWindow::eventFilter
       
   143 // @see header
       
   144 //---------------------------------------------------------------
       
   145 bool MsgMainWindow::eventFilter(QObject *obj, QEvent *event)
       
   146 {
       
   147     if (event->type() == QEvent::ApplicationActivate) {
       
   148         mViewManager->handleApplicationActive();
       
   149     }
       
   150     return QObject::eventFilter(obj, event);
       
   151 }
       
   152 
   138 // End of file
   153 // End of file