author | hgs |
Tue, 19 Oct 2010 11:30:16 +0530 | |
changeset 76 | 60a8a215b0ec |
parent 73 | ecf6a73a9186 |
permissions | -rw-r--r-- |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* Main window of the messaging application. Activates the default view. |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
* |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
*/ |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
#include "msgmainwindow.h" |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
#include "msgviewmanager.h" |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
#include "msgserviceinterface.h" |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
#include "msgsendserviceinterface.h" |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
#include "conversationsengine.h" |
73 | 25 |
#include "msgactivityhandler.h" |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
|
73 | 27 |
#include <hbapplication.h> |
62 | 28 |
#include <QKeyEvent> |
73 | 29 |
#include <afactivation.h> |
30 |
#include <afactivitystorage.h> |
|
62 | 31 |
|
73 | 32 |
const int INVALID_MSGID = -1; |
33 |
||
34 |
//--------------------------------------------------------------- |
|
35 |
// MsgMainWindow::MsgMainWindow |
|
36 |
// Constructor |
|
37 |
//--------------------------------------------------------------- |
|
76 | 38 |
MsgMainWindow::MsgMainWindow(bool serviceRequest, |
39 |
MsgActivityHandler *handler, |
|
40 |
QWidget *parent) : |
|
41 |
HbMainWindow(parent), mMsgSI(0), mMsgSendSI(0),mActivityHandler(handler) |
|
73 | 42 |
{ |
43 |
initialize(serviceRequest); |
|
44 |
} |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
45 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
46 |
//--------------------------------------------------------------- |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
47 |
// MsgMainWindow::MsgMainWindow |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
48 |
// Constructor |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
49 |
//--------------------------------------------------------------- |
73 | 50 |
void MsgMainWindow::initialize(bool serviceRequest) |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
51 |
{ |
73 | 52 |
int activityMsgId = INVALID_MSGID; |
53 |
||
54 |
||
76 | 55 |
AfActivation *activation = mActivityHandler->activation(); |
73 | 56 |
|
57 |
Af::ActivationReason reason = activation->reason(); |
|
58 |
||
59 |
if (reason == Af::ActivationReasonActivity) |
|
60 |
{ |
|
61 |
// set service request to false , since its a activity launch |
|
62 |
serviceRequest = false; |
|
63 |
||
64 |
QString actName = activation->name(); |
|
65 |
||
76 | 66 |
QVariant data = mActivityHandler->activitiyStorage()-> |
67 |
activityData(actName); |
|
73 | 68 |
|
76 | 69 |
activityMsgId = mActivityHandler->parseActivityData(data); |
73 | 70 |
} |
71 |
||
37 | 72 |
mViewManager = new MsgViewManager(serviceRequest,this,this,activityMsgId); |
76 | 73 |
mViewManager->setActivityHandler(mActivityHandler); |
74 |
||
37 | 75 |
mMsgSI = new MsgServiceInterface(NULL,mViewManager); |
76 |
mMsgSendSI = new MsgSendServiceInterface(NULL,mViewManager); |
|
73 | 77 |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
78 |
//Model creation |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
79 |
ConversationsEngine::instance(); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
80 |
|
73 | 81 |
// clear the old activities |
76 | 82 |
mActivityHandler->clearActivities(); |
73 | 83 |
|
84 |
// Set the main window pointer to activity handler. |
|
76 | 85 |
mActivityHandler->setMainWindow(this); |
73 | 86 |
|
87 |
// connect to aboutToQuit signal to save drafts content |
|
88 |
QObject::connect(qApp, SIGNAL(aboutToQuit()), |
|
76 | 89 |
mActivityHandler, SLOT(saveActivity())); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
90 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
91 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
92 |
//--------------------------------------------------------------- |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
93 |
// MsgMainWindow::~MsgMainWindow |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
94 |
// Constructor |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
95 |
//--------------------------------------------------------------- |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
96 |
MsgMainWindow::~MsgMainWindow() |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
97 |
{ |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
98 |
if (mMsgSI) |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
99 |
{ |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
100 |
delete mMsgSI; |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
101 |
mMsgSI = NULL; |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
102 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
103 |
if (mMsgSendSI) |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
104 |
{ |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
105 |
delete mMsgSendSI; |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
106 |
mMsgSendSI = NULL; |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
107 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
108 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
109 |
delete ConversationsEngine::instance(); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
110 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
111 |
|
37 | 112 |
//--------------------------------------------------------------- |
113 |
// MsgMainWindow::viewManager |
|
114 |
// Constructor |
|
115 |
//--------------------------------------------------------------- |
|
116 |
MsgViewManager* MsgMainWindow::viewManager() |
|
117 |
{ |
|
118 |
return mViewManager; |
|
119 |
} |
|
62 | 120 |
|
121 |
//--------------------------------------------------------------- |
|
122 |
// MsgMainWindow::keyPressEvent |
|
123 |
// @see header |
|
124 |
//--------------------------------------------------------------- |
|
125 |
void MsgMainWindow::keyPressEvent(QKeyEvent *event) |
|
126 |
{ |
|
127 |
bool eventHandled = false; |
|
128 |
if (Qt::Key_Yes == event->key()) { |
|
129 |
eventHandled = mViewManager->handleKeyEvent(event->key()); |
|
130 |
} |
|
131 |
||
132 |
if (eventHandled) { |
|
133 |
event->accept(); |
|
134 |
} |
|
135 |
else { |
|
136 |
HbMainWindow::keyPressEvent(event); |
|
137 |
} |
|
138 |
||
139 |
} |
|
73 | 140 |
|
76 | 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 |
||
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
153 |
// End of file |