author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 23 Jun 2010 18:09:17 +0300 | |
changeset 43 | 35b64624a9e7 |
parent 34 | 84197e66a4bd |
child 44 | 36f374c67aa8 |
permissions | -rw-r--r-- |
31 | 1 |
/* |
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description:Conversation Base view. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include "msgconversationbaseview.h" |
|
19 |
||
20 |
// SYSTEM INCLUDES |
|
21 |
#include <QGraphicsLinearLayout> |
|
22 |
#include <HbMainWindow> |
|
23 |
#include <HbNotificationDialog> |
|
24 |
||
25 |
#include <xqaiwrequest.h> |
|
26 |
#include <xqappmgr.h> |
|
27 |
||
28 |
#include <cntservicescontact.h> |
|
29 |
#include <qtcontactsglobal.h> |
|
30 |
#include <qtcontacts.h> |
|
31 |
#include <ccsdefs.h> |
|
32 |
#include <XQSettingsManager> |
|
33 |
#include <QTimer> |
|
34 |
||
35 |
// USER INCLUDES |
|
36 |
#include "msgconversationview.h" |
|
37 |
#include "conversationsengine.h" |
|
38 |
#include "msgviewdefines.h" |
|
39 |
#include "conversationsenginedefines.h" |
|
40 |
#include "msgcontactcardwidget.h" |
|
41 |
#include "conversationidpsconsts.h" |
|
42 |
||
43 |
QTM_USE_NAMESPACE |
|
44 |
||
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
45 |
const int INVALID_MSGID = -1; |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
46 |
|
31 | 47 |
// LOCALIZATION |
48 |
#define LOC_SAVED_TO_DRAFTS hbTrId("txt_messaging_dpopinfo_saved_to_drafts") |
|
49 |
||
50 |
//--------------------------------------------------------------- |
|
51 |
// MsgConversationBaseView::MsgConversationBaseView |
|
52 |
// Constructor |
|
53 |
//--------------------------------------------------------------- |
|
54 |
MsgConversationBaseView::MsgConversationBaseView(QGraphicsItem* parent) : |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
55 |
MsgBaseView(parent), mConversationId(-1), mCVIdkey(XQSettingsKey::TargetPublishAndSubscribe, |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
56 |
KMsgCVIdProperty, KMsgCVIdKey) |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
57 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
58 |
connect(this->mainWindow(), SIGNAL(viewReady()), this, SLOT(doDelayedConstruction())); |
31 | 59 |
initView(); |
60 |
} |
|
61 |
||
62 |
//--------------------------------------------------------------- |
|
63 |
// MsgConversationBaseView::~MsgConversationBaseView |
|
64 |
// Destructor |
|
65 |
//--------------------------------------------------------------- |
|
66 |
MsgConversationBaseView::~MsgConversationBaseView() |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
67 |
{ |
31 | 68 |
} |
69 |
||
70 |
//--------------------------------------------------------------- |
|
71 |
// MsgConversationBaseView::openConversationView |
|
72 |
// Launches conversation view for entry id and mode |
|
73 |
//--------------------------------------------------------------- |
|
74 |
void MsgConversationBaseView::openConversation(qint64 convId) |
|
75 |
{ |
|
76 |
ConversationsEngine::instance()->getConversations(convId); |
|
77 |
mConversationId = convId; |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
78 |
connect(this->mainWindow(), SIGNAL(viewReady()), this, SLOT(doDelayedConstruction())); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
79 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
80 |
// publsih conversation id |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
81 |
mSettingsManager->writeItemValue(mCVIdkey, (int) mConversationId); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
82 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
83 |
if (mConversationView) { |
31 | 84 |
mConversationView->refreshView(); |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
85 |
} |
31 | 86 |
} |
87 |
||
88 |
//--------------------------------------------------------------- |
|
89 |
// MsgConversationBaseView::initView |
|
90 |
// create and initialise the conversationview |
|
91 |
//--------------------------------------------------------------- |
|
92 |
void MsgConversationBaseView::initView() |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
93 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
94 |
|
31 | 95 |
// Create header widget |
96 |
mContactCard = new MsgContactCardWidget(this); |
|
97 |
||
98 |
mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); |
|
99 |
||
100 |
qreal spacing = HbDeviceProfile::profile(this).unitValue(); |
|
101 |
mMainLayout->setSpacing(spacing); |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
102 |
mMainLayout->setContentsMargins(CONTENT_MARGIN, CONTENT_MARGIN, CONTENT_MARGIN, CONTENT_MARGIN); |
31 | 103 |
|
104 |
mMainLayout->addItem(mContactCard); |
|
105 |
||
106 |
/** |
|
107 |
* Create conversation view and connect to proper signals. |
|
108 |
* NOTE: contactCardWidget is NOT parent of MsgConversationView. |
|
109 |
* Just passing reference to MsgConversationView. |
|
110 |
*/ |
|
111 |
mConversationView = new MsgConversationView(mContactCard); |
|
112 |
||
113 |
mConversationView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
114 |
||
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
115 |
connect(mConversationView, SIGNAL(closeConversationView()), this, SLOT(closeConversationView())); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
116 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
117 |
connect(mConversationView, SIGNAL(replyStarted()), this, SLOT(markMessagesAsRead())); |
31 | 118 |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
119 |
connect(mConversationView, SIGNAL(switchView(const QVariantList&)), this, |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
120 |
SIGNAL(switchView(const QVariantList&))); |
31 | 121 |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
122 |
connect(mConversationView, SIGNAL(vkbOpened(bool)), this, SLOT(hideChrome(bool))); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
123 |
connect(mConversationView, SIGNAL(vkbOpened(bool)), mContactCard, SLOT(ignoreSignals(bool))); |
31 | 124 |
|
125 |
this->setMenu(mConversationView->menu()); |
|
126 |
||
127 |
mMainLayout->addItem(mConversationView); |
|
128 |
||
129 |
this->setLayout(mMainLayout); |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
130 |
|
31 | 131 |
mSettingsManager = new XQSettingsManager(this); |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
132 |
|
31 | 133 |
} |
134 |
||
135 |
//--------------------------------------------------------------- |
|
136 |
// MsgConversationBaseView::closeConversationView |
|
137 |
// close conversation view |
|
138 |
//--------------------------------------------------------------- |
|
139 |
void MsgConversationBaseView::closeConversationView() |
|
140 |
{ |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
141 |
markMessagesAsRead(); |
31 | 142 |
} |
143 |
||
144 |
//--------------------------------------------------------------- |
|
145 |
// MsgConversationBaseView::markMessagesAsRead |
|
146 |
// Mark unread msgs in cv as read |
|
147 |
//--------------------------------------------------------------- |
|
148 |
void MsgConversationBaseView::markMessagesAsRead() |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
149 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
150 |
if (mConversationId >= 0) { |
31 | 151 |
ConversationsEngine::instance()->markConversationRead(mConversationId); |
152 |
} |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
153 |
} |
31 | 154 |
|
155 |
//--------------------------------------------------------------- |
|
156 |
// MsgConversationBaseView::saveContentToDrafts |
|
157 |
// saves the editors content to drafts |
|
158 |
//--------------------------------------------------------------- |
|
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
159 |
int MsgConversationBaseView::saveContentToDrafts() |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
160 |
{ |
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
161 |
int msgId = INVALID_MSGID; |
31 | 162 |
bool result = false; |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
163 |
if (mConversationId >= 0) { |
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
164 |
msgId = mConversationView->saveContentToDrafts(); |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
165 |
} |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
166 |
|
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
167 |
if (msgId != INVALID_MSGID) { |
31 | 168 |
HbNotificationDialog::launchDialog(LOC_SAVED_TO_DRAFTS); |
169 |
} |
|
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
170 |
return msgId; |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
171 |
} |
31 | 172 |
|
173 |
//--------------------------------------------------------------- |
|
174 |
// MsgConversationBaseView::conversationId |
|
175 |
// get the conversation ID |
|
176 |
//--------------------------------------------------------------- |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
177 |
qint64 MsgConversationBaseView::conversationId() |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
178 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
179 |
return mConversationId; |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
180 |
} |
31 | 181 |
|
182 |
//--------------------------------------------------------------- |
|
183 |
// MsgConversationBaseView::clearContent |
|
184 |
// clears conversation view content |
|
185 |
//--------------------------------------------------------------- |
|
186 |
void MsgConversationBaseView::clearContent() |
|
187 |
{ |
|
188 |
ConversationsEngine::instance()->clearConversations(); |
|
189 |
mConversationView->clearEditors(); |
|
190 |
} |
|
191 |
||
192 |
//--------------------------------------------------------------- |
|
193 |
// MsgConversationBaseView::handleOk |
|
194 |
// |
|
195 |
//--------------------------------------------------------------- |
|
196 |
void MsgConversationBaseView::handleOk(const QVariant& result) |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
197 |
{ |
31 | 198 |
Q_UNUSED(result) |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
199 |
} |
31 | 200 |
|
201 |
//--------------------------------------------------------------- |
|
202 |
// MsgConversationBaseView::handleError |
|
203 |
// |
|
204 |
//--------------------------------------------------------------- |
|
205 |
void MsgConversationBaseView::handleError(int errorCode, const QString& errorMessage) |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
206 |
{ |
31 | 207 |
Q_UNUSED(errorMessage) |
208 |
Q_UNUSED(errorCode) |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
209 |
} |
31 | 210 |
|
211 |
//--------------------------------------------------------------- |
|
212 |
// MsgConversationBaseView::doDelayedConstruction |
|
213 |
// |
|
214 |
//--------------------------------------------------------------- |
|
215 |
void MsgConversationBaseView::doDelayedConstruction() |
|
216 |
{ |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
217 |
disconnect(this->mainWindow(), SIGNAL(viewReady()), this, SLOT(doDelayedConstruction())); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
218 |
QTimer::singleShot(50, this, SLOT(handleViewReady())); |
31 | 219 |
} |
220 |
||
221 |
//--------------------------------------------------------------- |
|
222 |
// MsgConversationBaseView::handleViewReady |
|
223 |
// |
|
224 |
//--------------------------------------------------------------- |
|
225 |
void MsgConversationBaseView::handleViewReady() |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
226 |
{ |
31 | 227 |
ConversationsEngine::instance()->fetchMoreConversations(); |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
228 |
} |
31 | 229 |
|
230 |
//--------------------------------------------------------------- |
|
231 |
// MsgConversationBaseView::hideChrome |
|
232 |
// |
|
233 |
//--------------------------------------------------------------- |
|
234 |
void MsgConversationBaseView::hideChrome(bool hide) |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
235 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
236 |
if (hide) { |
31 | 237 |
this->hideItems(Hb::StatusBarItem | Hb::TitleBarItem); |
238 |
this->setContentFullScreen(true); |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
239 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
240 |
if (this->mainWindow()->orientation() == Qt::Horizontal) { |
31 | 241 |
mMainLayout->removeItem(mContactCard); |
242 |
mContactCard->hide(); |
|
243 |
} |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
244 |
} |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
245 |
else { |
31 | 246 |
this->showItems(Hb::StatusBarItem | Hb::TitleBarItem); |
247 |
this->setContentFullScreen(false); |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
248 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
249 |
if (!mContactCard->isVisible()) { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
250 |
mMainLayout->insertItem(0, mContactCard); |
31 | 251 |
mContactCard->show(); |
252 |
} |
|
253 |
} |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
254 |
} |
31 | 255 |
|
256 |
//--------------------------------------------------------------- |
|
257 |
// MsgConversationBaseView::setPSCVId |
|
258 |
// |
|
259 |
//--------------------------------------------------------------- |
|
260 |
void MsgConversationBaseView::setPSCVId(bool setId) |
|
261 |
{ |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
262 |
if (setId) { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
263 |
mSettingsManager->writeItemValue(mCVIdkey, (int) mConversationId); |
31 | 264 |
} |
265 |
else { |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
266 |
mSettingsManager->writeItemValue(mCVIdkey, -1); |
31 | 267 |
} |
268 |
} |
|
269 |
// EOF |