author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 00:13:15 +0300 | |
changeset 72 | 6f657153cbc5 |
parent 70 | a15d9966050f |
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:Message List View for the messaging application. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include "msglistview.h" |
|
19 |
||
20 |
// SYSTEM INCLUDES |
|
21 |
#include <hbmenu.h> |
|
22 |
#include <hbaction.h> |
|
23 |
#include <hbtoolbar.h> |
|
24 |
#include <hbtoolbarextension.h> |
|
25 |
#include <hblistview.h> |
|
26 |
#include <hblistwidget.h> |
|
27 |
#include <hblistwidgetitem.h> |
|
28 |
#include <hbgroupbox.h> |
|
29 |
#include <hbmessagebox.h> |
|
30 |
#include <hbframebackground.h> |
|
31 |
#include <QSortFilterProxyModel> |
|
32 |
#include <QGraphicsLinearLayout> |
|
33 |
#include <hblistviewitem.h> |
|
34 |
#include <HbStyleLoader> |
|
35 |
#include <HbMainWindow> |
|
36 |
#include <xqaiwrequest.h> |
|
37 |
#include <xqappmgr.h> |
|
38 |
#include <qtcontacts.h> |
|
39 |
||
40 |
// USER INCLUDES |
|
41 |
#include "msgconversationviewinterface.h" |
|
42 |
#include "debugtraces.h" |
|
43 |
#include "conversationsengine.h" |
|
44 |
#include "conversationsenginedefines.h" |
|
45 |
#include "convergedmessage.h" |
|
46 |
#include "msglistviewitem.h" |
|
47 |
||
48 |
QTM_USE_NAMESPACE |
|
49 |
||
50 |
//Icons |
|
51 |
const QString POPUP_LIST_FRAME("qtg_fr_popup_list_normal"); |
|
52 |
const QString NEW_MESSAGE_ICON("qtg_mono_create_message"); |
|
53 |
const QString SORT_ICON("qtg_mono_sort"); |
|
54 |
||
55 |
//Localized constants |
|
56 |
||
57 |
#define LOC_DIALOG_DELETE_CONVERSATION hbTrId("txt_messaging_dialog_delete_conversation") |
|
70
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
58 |
#define LOC_DIALOG_UNABLE_TO_DELETE_CONVERSATION hbTrId("txt_messaging_dialog_unable_to_delete_conversation") |
31 | 59 |
|
60 |
//itemspecific menu |
|
61 |
#define LOC_OPEN hbTrId("txt_common_menu_open") |
|
62 |
#define LOC_SAVETO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts") |
|
63 |
#define LOC_DELETE_CONVERSATION hbTrId("txt_messaging_menu_delete_conversation") |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
64 |
#define LOC_OPEN_CONTACT_INFO hbTrId("txt_messaging_menu_contact_info") |
31 | 65 |
|
66 |
//main menu |
|
67 |
#define LOC_SETTINGS hbTrId("txt_messaging_opt_settings") |
|
68 |
||
69 |
#define LOC_TB_VIEW_EXTN hbTrId("txt_messaging_button_view") |
|
70 |
#define LOC_TB_EXTN_DRAFTS hbTrId("txt_messaging_button_drafts") |
|
71 |
#define LOC_TB_EXTN_CONVERSATIONS hbTrId("txt_messaging_button_conversations") |
|
72 |
||
73 |
#define LOC_VIEW_HEADING hbTrId("txt_messaging_title_conversations") |
|
74 |
||
75 |
//--------------------------------------------------------------- |
|
76 |
// MsgListView::MsgListView |
|
77 |
// @see header |
|
78 |
//--------------------------------------------------------------- |
|
79 |
MsgListView::MsgListView(QGraphicsItem *parent) : |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
80 |
MsgBaseView(parent) |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
81 |
{ |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
82 |
//These changes are needed for splash implementation to avoid flicker |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
83 |
setupToolBar(); |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
84 |
setupMenu(); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
85 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
86 |
// Create parent layout. |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
87 |
mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
88 |
mMainLayout->setContentsMargins(0, 0, 0, 0); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
89 |
mMainLayout->setSpacing(0); |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
90 |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
91 |
// Create view heading. |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
92 |
HbGroupBox *viewHeading = new HbGroupBox(); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
93 |
viewHeading->setHeading(LOC_VIEW_HEADING); |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
94 |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
95 |
// Add view heading widget to main layout. |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
96 |
mMainLayout->addItem(viewHeading); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
97 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
98 |
this->setLayout(mMainLayout); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
99 |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
100 |
connect(this->mainWindow(), SIGNAL(viewReady()), this, |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
101 |
SLOT(doDelayedConstruction())); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
102 |
} |
31 | 103 |
|
104 |
//--------------------------------------------------------------- |
|
105 |
// MsgListView::~MsgListView |
|
106 |
// @see header |
|
107 |
//--------------------------------------------------------------- |
|
108 |
MsgListView::~MsgListView() |
|
109 |
{ |
|
110 |
||
111 |
} |
|
112 |
||
113 |
//--------------------------------------------------------------- |
|
114 |
// MsgListView::longPressed |
|
115 |
// @see header |
|
116 |
//--------------------------------------------------------------- |
|
117 |
void MsgListView::longPressed(HbAbstractViewItem* viewItem, const QPointF& point) |
|
118 |
{ |
|
119 |
if (this->isVisible()) { |
|
120 |
// Set the current index as the present Item's index. |
|
121 |
// By default it will not be set. |
|
122 |
mMsgList->setCurrentIndex(viewItem->modelIndex(), QItemSelectionModel::Select); |
|
123 |
||
124 |
// Create new menu |
|
125 |
HbMenu *contextMenu = new HbMenu(); |
|
126 |
contextMenu->setAttribute(Qt::WA_DeleteOnClose); |
|
127 |
//open menu option |
|
128 |
contextMenu->addAction(LOC_OPEN,this,SLOT(openConversation())); |
|
129 |
||
130 |
//save to contacts for unresolved. |
|
131 |
int msgType = viewItem->modelIndex().data(MessageType).toInt(); |
|
132 |
if(msgType == ConvergedMessage::Sms || |
|
133 |
msgType == ConvergedMessage::Mms || |
|
134 |
msgType == ConvergedMessage::BioMsg) |
|
135 |
{ |
|
136 |
qint64 contactId = mMsgList->currentIndex().data(ContactId).toLongLong(); |
|
137 |
if(contactId < 0) |
|
138 |
{ |
|
139 |
contextMenu->addAction(LOC_SAVETO_CONTACTS,this,SLOT(saveToContacts())); |
|
140 |
} |
|
141 |
else |
|
142 |
{ |
|
143 |
contextMenu->addAction(LOC_OPEN_CONTACT_INFO,this,SLOT(contactInfo())); |
|
144 |
} |
|
145 |
} |
|
146 |
||
147 |
//delete conversation |
|
148 |
contextMenu->addAction(LOC_DELETE_CONVERSATION,this,SLOT(deleteItem())); |
|
149 |
||
150 |
contextMenu->setPreferredPos(point); |
|
151 |
contextMenu->show(); |
|
152 |
} |
|
153 |
} |
|
154 |
||
155 |
//--------------------------------------------------------------- |
|
156 |
// MsgListView::openConversation |
|
157 |
// @see header |
|
158 |
//--------------------------------------------------------------- |
|
159 |
void MsgListView::openConversation(const QModelIndex& index) |
|
160 |
{ |
|
161 |
//TODO: model populating possibilities. |
|
162 |
if (index.isValid()) { |
|
163 |
QVariant conversationId = index.data(ConversationId); |
|
164 |
||
165 |
// Launch conversation view |
|
166 |
QVariantList param; |
|
167 |
param << MsgBaseView::CV; // target view |
|
168 |
param << MsgBaseView::CLV; // source view |
|
169 |
||
170 |
param << conversationId; |
|
171 |
||
172 |
emit switchView(param); |
|
173 |
} |
|
174 |
} |
|
175 |
||
176 |
//--------------------------------------------------------------- |
|
177 |
// MsgListView::sendNewMessage |
|
178 |
// @see header |
|
179 |
//--------------------------------------------------------------- |
|
180 |
void MsgListView::sendNewMessage() |
|
181 |
{ |
|
182 |
QVariantList param; |
|
183 |
param << MsgBaseView::UNIEDITOR; // target view |
|
184 |
param << MsgBaseView::CLV; // source view |
|
185 |
||
186 |
emit switchView(param); |
|
187 |
} |
|
188 |
||
189 |
//--------------------------------------------------------------- |
|
190 |
// MsgListView::settings |
|
191 |
// @see header |
|
192 |
//--------------------------------------------------------------- |
|
193 |
void MsgListView::settings() |
|
194 |
{ |
|
195 |
// Launch message settings |
|
196 |
QVariantList param; |
|
197 |
param << MsgBaseView::MSGSETTINGS; |
|
198 |
param << MsgBaseView::CLV; |
|
199 |
emit switchView(param); |
|
200 |
} |
|
201 |
||
202 |
//--------------------------------------------------------------- |
|
203 |
// MsgListView::openConversation |
|
204 |
// @see header |
|
205 |
//--------------------------------------------------------------- |
|
206 |
void MsgListView::openConversation() |
|
207 |
{ |
|
208 |
QModelIndex modelIndex = mMsgList->currentIndex(); |
|
209 |
openConversation(modelIndex); |
|
210 |
} |
|
211 |
||
212 |
//--------------------------------------------------------------- |
|
213 |
// MsgListView::showContact |
|
214 |
// @see header |
|
215 |
//--------------------------------------------------------------- |
|
216 |
void MsgListView::showContact() |
|
217 |
{ |
|
218 |
} |
|
219 |
||
220 |
//--------------------------------------------------------------- |
|
221 |
// MsgListView::deleteItem |
|
222 |
// @see header |
|
223 |
//--------------------------------------------------------------- |
|
224 |
void MsgListView::deleteItem() |
|
225 |
{ |
|
226 |
#ifdef _DEBUG_TRACES_ |
|
227 |
qDebug() << "Inside MsgListView::deleteItem"; |
|
228 |
#endif |
|
70
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
229 |
QModelIndex index = mMsgList->currentIndex(); |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
230 |
if (index.isValid()) |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
231 |
{ |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
232 |
int sendState = index.data(SendingState).toInt(); |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
233 |
if(ConvergedMessage::Sending == sendState) |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
234 |
{ |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
235 |
//confirmation dialog. |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
236 |
HbMessageBox::information(LOC_DIALOG_UNABLE_TO_DELETE_CONVERSATION, |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
237 |
0,0, |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
238 |
HbMessageBox::Ok); |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
239 |
} |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
240 |
// not in sending state and hence can be deleted. |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
241 |
else |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
242 |
{ |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
243 |
//confirmation dialog. |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
244 |
HbMessageBox::question(LOC_DIALOG_DELETE_CONVERSATION, |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
245 |
this,SLOT(onDialogDeleteMsg(HbAction*)), |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
246 |
HbMessageBox::Delete | HbMessageBox::Cancel); |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
247 |
} |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
248 |
|
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
249 |
} |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
250 |
|
31 | 251 |
#ifdef _DEBUG_TRACES_ |
252 |
qDebug() << " Leaving MsgConversationView::deleteItem"; |
|
253 |
#endif |
|
254 |
} |
|
255 |
||
256 |
//--------------------------------------------------------------- |
|
257 |
// MsgListView::setupView |
|
258 |
// @see header |
|
259 |
//--------------------------------------------------------------- |
|
260 |
void MsgListView::setupListView() |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
261 |
{ |
31 | 262 |
// Register the custorm css path. |
263 |
HbStyleLoader::registerFilePath(":/clv"); |
|
264 |
||
265 |
mMsgList = new HbListView(this); |
|
266 |
mMsgList->setClampingStyle(HbScrollArea::BounceBackClamping); |
|
267 |
||
268 |
mMsgList->setLayoutName("custom"); |
|
269 |
mMsgList->setItemRecycling(true); |
|
72
6f657153cbc5
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
270 |
mMsgList->setItemPixmapCacheEnabled(true); |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
271 |
mMsgList->setUniformItemSizes(true); |
31 | 272 |
|
273 |
MsgListViewItem *prototype = new MsgListViewItem(this); |
|
274 |
mMsgList->setItemPrototype(prototype); |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
275 |
mMsgList->setModel(ConversationsEngine::instance()->getConversationsSummaryModel()); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
276 |
|
31 | 277 |
// Single tap list item |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
278 |
connect(mMsgList, SIGNAL(activated(const QModelIndex&)), this, |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
279 |
SLOT(openConversation(const QModelIndex&))); |
31 | 280 |
|
281 |
// Long tap list item |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
282 |
connect(mMsgList, |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
283 |
SIGNAL(longPressed(HbAbstractViewItem*, const QPointF&)), this, |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
284 |
SLOT(longPressed(HbAbstractViewItem*, const QPointF&))); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
285 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
286 |
// enable tap after delete is completed |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
287 |
connect(ConversationsEngine::instance(), |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
288 |
SIGNAL(conversationListEntryDeleted( int )), this, |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
289 |
SLOT(enableListitem( int ))); |
31 | 290 |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
291 |
// Add list view to main layout. |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
292 |
mMainLayout->addItem(mMsgList); |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
293 |
} |
31 | 294 |
|
295 |
//--------------------------------------------------------------- |
|
296 |
// MsgListView::addMenu |
|
297 |
// @see header |
|
298 |
//--------------------------------------------------------------- |
|
299 |
void MsgListView::setupMenu() |
|
300 |
{ |
|
301 |
// Main menu |
|
302 |
HbMenu* mainMenu = this->menu(); |
|
303 |
mainMenu->addAction(LOC_SETTINGS,this,SLOT(settings())); |
|
304 |
} |
|
305 |
||
306 |
//--------------------------------------------------------------- |
|
307 |
// MsgListView::setupToolBar |
|
308 |
// @see header |
|
309 |
//--------------------------------------------------------------- |
|
310 |
void MsgListView::setupToolBar() |
|
311 |
{ |
|
312 |
// ToolBar |
|
313 |
HbToolBar *toolBar = this->toolBar(); |
|
314 |
toolBar->setOrientation(Qt::Horizontal); |
|
315 |
||
316 |
// Create & setup ToolBar Extension |
|
317 |
HbToolBarExtension *viewExtn = new HbToolBarExtension(); |
|
318 |
HbAction *viewAction = toolBar->addExtension(viewExtn); |
|
319 |
viewAction->setIcon(HbIcon(SORT_ICON)); |
|
320 |
||
321 |
mViewExtnList = new HbListWidget(); |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
322 |
mViewExtnList->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed); |
31 | 323 |
mViewExtnList->addItem(LOC_TB_EXTN_DRAFTS); |
324 |
mViewExtnList->addItem(LOC_TB_EXTN_CONVERSATIONS); |
|
325 |
||
326 |
HbListViewItem *prototype = mViewExtnList->listItemPrototype(); |
|
327 |
HbFrameBackground frame(POPUP_LIST_FRAME, HbFrameDrawer::NinePieces); |
|
328 |
prototype->setDefaultFrame(frame); |
|
329 |
||
330 |
connect(mViewExtnList, SIGNAL(activated(HbListWidgetItem*)), |
|
331 |
this,SLOT(handleViewExtnActivated(HbListWidgetItem*))); |
|
332 |
connect(mViewExtnList, SIGNAL(released(HbListWidgetItem*)), viewExtn, SLOT(close())); |
|
333 |
||
334 |
viewExtn->setContentWidget(mViewExtnList); |
|
335 |
||
336 |
// Create & setup 2nd ToolBar button. |
|
337 |
toolBar->addAction(HbIcon(NEW_MESSAGE_ICON),"",this,SLOT(sendNewMessage())); |
|
338 |
} |
|
339 |
||
340 |
//--------------------------------------------------------------- |
|
341 |
// MsgListView::handleViewExtnActivated |
|
342 |
// @see header |
|
343 |
//--------------------------------------------------------------- |
|
344 |
void MsgListView::handleViewExtnActivated(HbListWidgetItem *item) |
|
345 |
{ |
|
346 |
int row = mViewExtnList->row(item); |
|
347 |
if (DRAFTS_EXTN == row) { |
|
348 |
QVariantList param; |
|
349 |
param << MsgBaseView::DLV; // target view |
|
350 |
param << MsgBaseView::CLV; // source view |
|
351 |
||
352 |
emit switchView(param); |
|
353 |
} |
|
354 |
} |
|
355 |
||
356 |
//--------------------------------------------------------------- |
|
357 |
// MsgListView::doDelayedConstruction |
|
358 |
// @see header |
|
359 |
//--------------------------------------------------------------- |
|
360 |
void MsgListView::doDelayedConstruction() |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
361 |
{ |
31 | 362 |
setupListView(); |
363 |
||
364 |
disconnect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction())); |
|
365 |
} |
|
366 |
||
367 |
//--------------------------------------------------------------- |
|
368 |
// MsgListView::saveToContacts |
|
369 |
// @see header |
|
370 |
//--------------------------------------------------------------- |
|
371 |
void MsgListView::saveToContacts() |
|
372 |
{ |
|
373 |
//save to contacts with phone number field prefilled. |
|
374 |
QList<QVariant> args; |
|
375 |
||
376 |
QString data = mMsgList->currentIndex().data(DisplayName).toString(); |
|
377 |
||
378 |
QString type = QContactPhoneNumber::DefinitionName; |
|
379 |
||
380 |
args << type; |
|
381 |
args << data; |
|
382 |
||
383 |
//service stuff. |
|
70
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
384 |
QString service("phonebookservices"); |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
385 |
QString interface("com.nokia.symbian.IContactsEdit"); |
31 | 386 |
QString operation("editCreateNew(QString,QString)"); |
387 |
||
388 |
XQAiwRequest* request; |
|
389 |
XQApplicationManager appManager; |
|
70
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
390 |
request = appManager.create(service, interface, operation, true); // embedded |
31 | 391 |
if ( request == NULL ) |
392 |
{ |
|
393 |
return; |
|
394 |
} |
|
395 |
||
396 |
request->setArguments(args); |
|
397 |
request->send(); |
|
398 |
||
399 |
delete request; |
|
400 |
} |
|
401 |
||
402 |
//--------------------------------------------------------------- |
|
403 |
// MsgListView::contactInfo |
|
404 |
// @see header |
|
405 |
//--------------------------------------------------------------- |
|
406 |
void MsgListView::contactInfo() |
|
407 |
{ |
|
408 |
//open contact info. |
|
409 |
QList<QVariant> args; |
|
410 |
||
411 |
int contactId = mMsgList->currentIndex().data(ContactId).toInt(); |
|
412 |
||
413 |
args << contactId; |
|
414 |
||
415 |
//service stuff. |
|
70
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
416 |
QString service("phonebookservices"); |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
417 |
QString interface("com.nokia.symbian.IContactsView"); |
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
418 |
QString operation("openContactCard(int)"); |
31 | 419 |
|
420 |
XQAiwRequest* request; |
|
421 |
XQApplicationManager appManager; |
|
70
a15d9966050f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
52
diff
changeset
|
422 |
request = appManager.create(service, interface, operation, true); // embedded |
31 | 423 |
if ( request == NULL ) |
424 |
{ |
|
425 |
return; |
|
426 |
} |
|
427 |
||
428 |
request->setArguments(args); |
|
429 |
request->send(); |
|
430 |
||
431 |
delete request; |
|
432 |
} |
|
433 |
||
434 |
//--------------------------------------------------------------- |
|
435 |
// MsgListView::onDialogDeleteMsg |
|
436 |
// @see header |
|
437 |
//--------------------------------------------------------------- |
|
438 |
void MsgListView::onDialogDeleteMsg(HbAction* action) |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
439 |
{ |
31 | 440 |
HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
441 |
if (action == dlg->actions().at(0)) |
31 | 442 |
{ |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
443 |
QModelIndex index = mMsgList->currentIndex(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
444 |
if (index.isValid()) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
445 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
446 |
HbAbstractViewItem *item = mMsgList->currentViewItem(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
447 |
item->ungrabGesture(Qt::TapGesture); |
31 | 448 |
qint64 conversationId = index.data(ConversationId).toLongLong(); |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
449 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
450 |
ConversationsEngine::instance()->deleteConversations( |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
451 |
conversationId); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
452 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
453 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
454 |
|
31 | 455 |
} |
456 |
} |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
457 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
458 |
//--------------------------------------------------------------- |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
459 |
// MsgListView::enableListitem |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
460 |
// @see header |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
461 |
//--------------------------------------------------------------- |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
462 |
void MsgListView::enableListitem(int conversationId) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
463 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
464 |
QAbstractItemModel* proxyModel = mMsgList->model(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
465 |
QModelIndexList indexList = proxyModel->match(proxyModel->index(0, 0), |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
466 |
ConversationId, conversationId, 1, Qt::MatchExactly); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
467 |
HbAbstractViewItem* item = NULL; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
468 |
int count = indexList.count(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
469 |
// only item is expected to be the result of the above match function |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
470 |
if (1 == count) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
471 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
472 |
item = mMsgList->itemByIndex(indexList[0]); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
473 |
if (item) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
474 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
475 |
item->grabGesture(Qt::TapGesture); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
476 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
477 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
478 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
479 |
} |
31 | 480 |
|
481 |
//EOF |