author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 11 Jun 2010 13:35:48 +0300 | |
changeset 34 | 84197e66a4bd |
parent 31 | ebfee66fde93 |
child 43 | 35b64624a9e7 |
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 |
||
45 |
// LOCALIZATION |
|
46 |
#define LOC_SAVED_TO_DRAFTS hbTrId("txt_messaging_dpopinfo_saved_to_drafts") |
|
47 |
||
48 |
//--------------------------------------------------------------- |
|
49 |
// MsgConversationBaseView::MsgConversationBaseView |
|
50 |
// Constructor |
|
51 |
//--------------------------------------------------------------- |
|
52 |
MsgConversationBaseView::MsgConversationBaseView(QGraphicsItem* parent) : |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
53 |
MsgBaseView(parent), mConversationId(-1), mCVIdkey(XQSettingsKey::TargetPublishAndSubscribe, |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
54 |
KMsgCVIdProperty, KMsgCVIdKey) |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
55 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
56 |
connect(this->mainWindow(), SIGNAL(viewReady()), this, SLOT(doDelayedConstruction())); |
31 | 57 |
initView(); |
58 |
} |
|
59 |
||
60 |
//--------------------------------------------------------------- |
|
61 |
// MsgConversationBaseView::~MsgConversationBaseView |
|
62 |
// Destructor |
|
63 |
//--------------------------------------------------------------- |
|
64 |
MsgConversationBaseView::~MsgConversationBaseView() |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
65 |
{ |
31 | 66 |
} |
67 |
||
68 |
//--------------------------------------------------------------- |
|
69 |
// MsgConversationBaseView::openConversationView |
|
70 |
// Launches conversation view for entry id and mode |
|
71 |
//--------------------------------------------------------------- |
|
72 |
void MsgConversationBaseView::openConversation(qint64 convId) |
|
73 |
{ |
|
74 |
ConversationsEngine::instance()->getConversations(convId); |
|
75 |
mConversationId = convId; |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
76 |
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
|
77 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
78 |
// publsih conversation id |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
79 |
mSettingsManager->writeItemValue(mCVIdkey, (int) mConversationId); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
80 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
81 |
if (mConversationView) { |
31 | 82 |
mConversationView->refreshView(); |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
83 |
} |
31 | 84 |
} |
85 |
||
86 |
//--------------------------------------------------------------- |
|
87 |
// MsgConversationBaseView::initView |
|
88 |
// create and initialise the conversationview |
|
89 |
//--------------------------------------------------------------- |
|
90 |
void MsgConversationBaseView::initView() |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
91 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
92 |
|
31 | 93 |
// Create header widget |
94 |
mContactCard = new MsgContactCardWidget(this); |
|
95 |
||
96 |
mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); |
|
97 |
||
98 |
qreal spacing = HbDeviceProfile::profile(this).unitValue(); |
|
99 |
mMainLayout->setSpacing(spacing); |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
100 |
mMainLayout->setContentsMargins(CONTENT_MARGIN, CONTENT_MARGIN, CONTENT_MARGIN, CONTENT_MARGIN); |
31 | 101 |
|
102 |
mMainLayout->addItem(mContactCard); |
|
103 |
||
104 |
/** |
|
105 |
* Create conversation view and connect to proper signals. |
|
106 |
* NOTE: contactCardWidget is NOT parent of MsgConversationView. |
|
107 |
* Just passing reference to MsgConversationView. |
|
108 |
*/ |
|
109 |
mConversationView = new MsgConversationView(mContactCard); |
|
110 |
||
111 |
mConversationView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
112 |
||
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
113 |
connect(mConversationView, SIGNAL(closeConversationView()), this, SLOT(closeConversationView())); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
114 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
115 |
connect(mConversationView, SIGNAL(replyStarted()), this, SLOT(markMessagesAsRead())); |
31 | 116 |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
117 |
connect(mConversationView, SIGNAL(switchView(const QVariantList&)), this, |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
118 |
SIGNAL(switchView(const QVariantList&))); |
31 | 119 |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
120 |
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
|
121 |
connect(mConversationView, SIGNAL(vkbOpened(bool)), mContactCard, SLOT(ignoreSignals(bool))); |
31 | 122 |
|
123 |
this->setMenu(mConversationView->menu()); |
|
124 |
||
125 |
mMainLayout->addItem(mConversationView); |
|
126 |
||
127 |
this->setLayout(mMainLayout); |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
128 |
|
31 | 129 |
mSettingsManager = new XQSettingsManager(this); |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
130 |
|
31 | 131 |
} |
132 |
||
133 |
//--------------------------------------------------------------- |
|
134 |
// MsgConversationBaseView::closeConversationView |
|
135 |
// close conversation view |
|
136 |
//--------------------------------------------------------------- |
|
137 |
void MsgConversationBaseView::closeConversationView() |
|
138 |
{ |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
139 |
markMessagesAsRead(); |
31 | 140 |
} |
141 |
||
142 |
//--------------------------------------------------------------- |
|
143 |
// MsgConversationBaseView::markMessagesAsRead |
|
144 |
// Mark unread msgs in cv as read |
|
145 |
//--------------------------------------------------------------- |
|
146 |
void MsgConversationBaseView::markMessagesAsRead() |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
147 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
148 |
if (mConversationId >= 0) { |
31 | 149 |
ConversationsEngine::instance()->markConversationRead(mConversationId); |
150 |
} |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
151 |
} |
31 | 152 |
|
153 |
//--------------------------------------------------------------- |
|
154 |
// MsgConversationBaseView::saveContentToDrafts |
|
155 |
// saves the editors content to drafts |
|
156 |
//--------------------------------------------------------------- |
|
157 |
void MsgConversationBaseView::saveContentToDrafts() |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
158 |
{ |
31 | 159 |
bool result = false; |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
160 |
if (mConversationId >= 0) { |
31 | 161 |
result = mConversationView->saveContentToDrafts(); |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
162 |
} |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
163 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
164 |
if (result) { |
31 | 165 |
HbNotificationDialog::launchDialog(LOC_SAVED_TO_DRAFTS); |
166 |
} |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
167 |
} |
31 | 168 |
|
169 |
//--------------------------------------------------------------- |
|
170 |
// MsgConversationBaseView::conversationId |
|
171 |
// get the conversation ID |
|
172 |
//--------------------------------------------------------------- |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
173 |
qint64 MsgConversationBaseView::conversationId() |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
174 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
175 |
return mConversationId; |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
176 |
} |
31 | 177 |
|
178 |
//--------------------------------------------------------------- |
|
179 |
// MsgConversationBaseView::clearContent |
|
180 |
// clears conversation view content |
|
181 |
//--------------------------------------------------------------- |
|
182 |
void MsgConversationBaseView::clearContent() |
|
183 |
{ |
|
184 |
ConversationsEngine::instance()->clearConversations(); |
|
185 |
mConversationView->clearEditors(); |
|
186 |
} |
|
187 |
||
188 |
//--------------------------------------------------------------- |
|
189 |
// MsgConversationBaseView::handleOk |
|
190 |
// |
|
191 |
//--------------------------------------------------------------- |
|
192 |
void MsgConversationBaseView::handleOk(const QVariant& result) |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
193 |
{ |
31 | 194 |
Q_UNUSED(result) |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
195 |
} |
31 | 196 |
|
197 |
//--------------------------------------------------------------- |
|
198 |
// MsgConversationBaseView::handleError |
|
199 |
// |
|
200 |
//--------------------------------------------------------------- |
|
201 |
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
|
202 |
{ |
31 | 203 |
Q_UNUSED(errorMessage) |
204 |
Q_UNUSED(errorCode) |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
205 |
} |
31 | 206 |
|
207 |
//--------------------------------------------------------------- |
|
208 |
// MsgConversationBaseView::doDelayedConstruction |
|
209 |
// |
|
210 |
//--------------------------------------------------------------- |
|
211 |
void MsgConversationBaseView::doDelayedConstruction() |
|
212 |
{ |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
213 |
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
|
214 |
QTimer::singleShot(50, this, SLOT(handleViewReady())); |
31 | 215 |
} |
216 |
||
217 |
//--------------------------------------------------------------- |
|
218 |
// MsgConversationBaseView::handleViewReady |
|
219 |
// |
|
220 |
//--------------------------------------------------------------- |
|
221 |
void MsgConversationBaseView::handleViewReady() |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
222 |
{ |
31 | 223 |
ConversationsEngine::instance()->fetchMoreConversations(); |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
224 |
} |
31 | 225 |
|
226 |
//--------------------------------------------------------------- |
|
227 |
// MsgConversationBaseView::hideChrome |
|
228 |
// |
|
229 |
//--------------------------------------------------------------- |
|
230 |
void MsgConversationBaseView::hideChrome(bool hide) |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
231 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
232 |
if (hide) { |
31 | 233 |
this->hideItems(Hb::StatusBarItem | Hb::TitleBarItem); |
234 |
this->setContentFullScreen(true); |
|
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 (this->mainWindow()->orientation() == Qt::Horizontal) { |
31 | 237 |
mMainLayout->removeItem(mContactCard); |
238 |
mContactCard->hide(); |
|
239 |
} |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
240 |
} |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
241 |
else { |
31 | 242 |
this->showItems(Hb::StatusBarItem | Hb::TitleBarItem); |
243 |
this->setContentFullScreen(false); |
|
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 |
if (!mContactCard->isVisible()) { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
246 |
mMainLayout->insertItem(0, mContactCard); |
31 | 247 |
mContactCard->show(); |
248 |
} |
|
249 |
} |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
250 |
} |
31 | 251 |
|
252 |
//--------------------------------------------------------------- |
|
253 |
// MsgConversationBaseView::setPSCVId |
|
254 |
// |
|
255 |
//--------------------------------------------------------------- |
|
256 |
void MsgConversationBaseView::setPSCVId(bool setId) |
|
257 |
{ |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
258 |
if (setId) { |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
259 |
mSettingsManager->writeItemValue(mCVIdkey, (int) mConversationId); |
31 | 260 |
} |
261 |
else { |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
262 |
mSettingsManager->writeItemValue(mCVIdkey, -1); |
31 | 263 |
} |
264 |
} |
|
265 |
// EOF |