41 #include "conversationsenginedefines.h" |
41 #include "conversationsenginedefines.h" |
42 #include "convergedmessage.h" |
42 #include "convergedmessage.h" |
43 #include "convergedmessageid.h" |
43 #include "convergedmessageid.h" |
44 |
44 |
45 // LOCAL CONSTANTS |
45 // LOCAL CONSTANTS |
46 const QString LIST_ITEM_FRAME("qtg_fr_list_normal"); |
|
47 const QString POPUP_LIST_FRAME("qtg_fr_popup_list_normal"); |
46 const QString POPUP_LIST_FRAME("qtg_fr_popup_list_normal"); |
48 const QString NEW_MESSAGE_ICON("qtg_mono_create_message"); |
47 const QString NEW_MESSAGE_ICON("qtg_mono_create_message"); |
49 const QString SORT_ICON("qtg_mono_sort"); |
48 const QString SORT_ICON("qtg_mono_sort"); |
50 |
49 |
51 // LOCALIZATION CONSTANTS |
50 // LOCALIZATION CONSTANTS |
65 #define LOC_TB_EXTN_CONVERSATIONS hbTrId("txt_messaging_button_conversations") |
64 #define LOC_TB_EXTN_CONVERSATIONS hbTrId("txt_messaging_button_conversations") |
66 |
65 |
67 // Confirmation note |
66 // Confirmation note |
68 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message") |
67 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message") |
69 #define LOC_DELETE_ALL_DRAFTS hbTrId("txt_messaging_dialog_delate_all_drafts") |
68 #define LOC_DELETE_ALL_DRAFTS hbTrId("txt_messaging_dialog_delate_all_drafts") |
70 #define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete") |
|
71 #define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel") |
|
72 |
69 |
73 //--------------------------------------------------------------- |
70 //--------------------------------------------------------------- |
74 // DraftsListView::DraftsListView |
71 // DraftsListView::DraftsListView |
75 // @see header |
72 // @see header |
76 //--------------------------------------------------------------- |
73 //--------------------------------------------------------------- |
77 DraftsListView::DraftsListView(QGraphicsItem *parent) : |
74 DraftsListView::DraftsListView(QGraphicsItem *parent) : |
78 MsgBaseView(parent), mListView(0), mViewExtnList(0), mToolBar(0) |
75 MsgBaseView(parent), |
|
76 mListView(0), |
|
77 mViewExtnList(0), |
|
78 mToolBar(0) |
79 { |
79 { |
80 // Delayed loading. |
80 // Delayed loading. |
81 connect(this->mainWindow(), SIGNAL(viewReady()), this, SLOT(doDelayedLoading())); |
81 connect(this->mainWindow(), SIGNAL(viewReady()), this, SLOT(doDelayedLoading())); |
82 } |
82 } |
83 |
83 |
118 HbToolBarExtension *viewExtn = new HbToolBarExtension(); |
118 HbToolBarExtension *viewExtn = new HbToolBarExtension(); |
119 HbAction *viewAction = mToolBar->addExtension(viewExtn); |
119 HbAction *viewAction = mToolBar->addExtension(viewExtn); |
120 viewAction->setIcon(HbIcon(SORT_ICON)); |
120 viewAction->setIcon(HbIcon(SORT_ICON)); |
121 |
121 |
122 mViewExtnList = new HbListWidget(); |
122 mViewExtnList = new HbListWidget(); |
|
123 mViewExtnList->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed); |
123 mViewExtnList->addItem(LOC_TB_EXTN_DRAFTS); |
124 mViewExtnList->addItem(LOC_TB_EXTN_DRAFTS); |
124 mViewExtnList->addItem(LOC_TB_EXTN_CONVERSATIONS); |
125 mViewExtnList->addItem(LOC_TB_EXTN_CONVERSATIONS); |
125 |
126 |
126 HbListViewItem *prototype = mViewExtnList->listItemPrototype(); |
127 HbListViewItem *prototype = mViewExtnList->listItemPrototype(); |
127 HbFrameBackground frame(POPUP_LIST_FRAME, HbFrameDrawer::NinePieces); |
128 HbFrameBackground frame(POPUP_LIST_FRAME, HbFrameDrawer::NinePieces); |
161 mListView->setItemRecycling(true); |
162 mListView->setItemRecycling(true); |
162 mListView->setUniformItemSizes(true); |
163 mListView->setUniformItemSizes(true); |
163 mListView->setClampingStyle(HbScrollArea::BounceBackClamping); |
164 mListView->setClampingStyle(HbScrollArea::BounceBackClamping); |
164 |
165 |
165 // Register the custorm css path. |
166 // Register the custorm css path. |
166 HbStyleLoader::registerFilePath(":/xml/hblistviewitem.css"); |
167 HbStyleLoader::registerFilePath(":/dlv"); |
167 // mListView->setLayoutName("custom"); |
168 // mListView->setLayoutName("custom"); |
168 |
169 |
169 // Set list item properties. |
170 // Set list item properties. |
170 HbListViewItem *prototype = mListView->listItemPrototype(); |
171 HbListViewItem *prototype = mListView->listItemPrototype(); |
171 prototype->setGraphicsSize(HbListViewItem::SmallIcon); |
172 prototype->setGraphicsSize(HbListViewItem::SmallIcon); |
172 prototype->setStretchingStyle(HbListViewItem::StretchLandscape); |
173 prototype->setStretchingStyle(HbListViewItem::StretchLandscape); |
173 prototype->setSecondaryTextRowCount(1, 1); |
174 prototype->setSecondaryTextRowCount(1, 1); |
174 HbFrameBackground frame(LIST_ITEM_FRAME, HbFrameDrawer::NinePieces); |
|
175 prototype->setDefaultFrame(frame); |
|
176 |
175 |
177 // Create and set model |
176 // Create and set model |
178 QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this); |
177 QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this); |
179 proxyModel->setDynamicSortFilter(true); |
178 proxyModel->setDynamicSortFilter(true); |
180 proxyModel->setSourceModel(ConversationsEngine::instance()->getDraftsModel()); |
179 proxyModel->setSourceModel(ConversationsEngine::instance()->getDraftsModel()); |
227 |
226 |
228 if (!index.isValid()) { |
227 if (!index.isValid()) { |
229 return; |
228 return; |
230 } |
229 } |
231 |
230 |
232 bool result = HbMessageBox::question(LOC_DELETE_MESSAGE, LOC_BUTTON_DELETE, LOC_BUTTON_CANCEL); |
231 HbMessageBox::question(LOC_DELETE_MESSAGE, |
233 |
232 this,SLOT(onDialogDeleteMsg(HbAction*)), |
234 if (result) { |
233 HbMessageBox::Delete | HbMessageBox::Cancel); |
235 int msgId = index.data(ConvergedMsgId).toInt(); |
|
236 QList<int> msgIdList; |
|
237 msgIdList.append(msgId); |
|
238 ConversationsEngine::instance()->deleteMessages(msgIdList); |
|
239 } |
|
240 |
234 |
241 } |
235 } |
242 |
236 |
243 //------------------------------------------------------------------------------ |
237 //------------------------------------------------------------------------------ |
244 // DraftsListView::deleteAllDraftMessage |
238 // DraftsListView::deleteAllDraftMessage |
245 // @see header |
239 // @see header |
246 //------------------------------------------------------------------------------ |
240 //------------------------------------------------------------------------------ |
247 void DraftsListView::deleteAllDraftMessage() |
241 void DraftsListView::deleteAllDraftMessage() |
248 { |
242 { |
249 bool result = HbMessageBox::question(LOC_DELETE_ALL_DRAFTS, LOC_BUTTON_DELETE, |
243 HbMessageBox::question(LOC_DELETE_ALL_DRAFTS, |
250 LOC_BUTTON_CANCEL); |
244 this,SLOT(onDialogDeleteAllMessages(HbAction*)), |
251 |
245 HbMessageBox::Delete | HbMessageBox::Cancel); |
252 if (result) { |
|
253 ConversationsEngine::instance()->deleteAllDraftMessages(); |
|
254 } |
|
255 } |
246 } |
256 |
247 |
257 //------------------------------------------------------------------------------ |
248 //------------------------------------------------------------------------------ |
258 // DraftsListView::createNewMessage |
249 // DraftsListView::createNewMessage |
259 // @see header |
250 // @see header |
303 |
294 |
304 // Set the current index as tapped items index. |
295 // Set the current index as tapped items index. |
305 mListView->setCurrentIndex(item->modelIndex(), QItemSelectionModel::Select); |
296 mListView->setCurrentIndex(item->modelIndex(), QItemSelectionModel::Select); |
306 |
297 |
307 HbMenu *contextMenu = new HbMenu(); |
298 HbMenu *contextMenu = new HbMenu(); |
308 |
299 contextMenu->setAttribute(Qt::WA_DeleteOnClose); |
309 // Open |
300 // Open |
310 HbAction* openAction = contextMenu->addAction(LOC_COMMON_OPEN); |
301 HbAction* openAction = contextMenu->addAction(LOC_COMMON_OPEN); |
311 connect(openAction, SIGNAL(triggered()), this, SLOT(openDraftMessage())); |
302 connect(openAction, SIGNAL(triggered()), this, SLOT(openDraftMessage())); |
312 |
303 |
313 // Delete |
304 // Delete |
314 HbAction *deletAction = contextMenu->addAction(LOC_COMMON_DELETE); |
305 HbAction *deletAction = contextMenu->addAction(LOC_COMMON_DELETE); |
315 connect(deletAction, SIGNAL(triggered()), this, SLOT(deleteDraftMessage())); |
306 connect(deletAction, SIGNAL(triggered()), this, SLOT(deleteDraftMessage())); |
316 |
307 |
317 contextMenu->exec(coords); |
308 contextMenu->setPreferredPos(coords); |
318 delete contextMenu; |
309 contextMenu->show(); |
319 } |
310 } |
320 } |
311 } |
321 |
312 |
322 //------------------------------------------------------------------------------ |
313 //------------------------------------------------------------------------------ |
323 // DraftsListView::handleViewExtnActivated |
314 // DraftsListView::handleViewExtnActivated |
351 mainMenu->addAction(LOC_MENU_DELETE_ALL, this, SLOT(deleteAllDraftMessage())); |
342 mainMenu->addAction(LOC_MENU_DELETE_ALL, this, SLOT(deleteAllDraftMessage())); |
352 } |
343 } |
353 } |
344 } |
354 } |
345 } |
355 |
346 |
|
347 //------------------------------------------------------------------------------ |
|
348 // DraftsListView::onDialogDeleteMsg |
|
349 // @see header |
|
350 //------------------------------------------------------------------------------ |
|
351 void DraftsListView::onDialogDeleteMsg(HbAction* action) |
|
352 { |
|
353 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
354 if (action == dlg->actions().at(0)) { |
|
355 QModelIndex index = mListView->currentIndex(); |
|
356 if (index.isValid()) { |
|
357 int msgId = index.data(ConvergedMsgId).toInt(); |
|
358 QList<int> msgIdList; |
|
359 msgIdList.append(msgId); |
|
360 ConversationsEngine::instance()->deleteMessages(msgIdList); |
|
361 } |
|
362 |
|
363 } |
|
364 } |
|
365 |
|
366 //------------------------------------------------------------------------------ |
|
367 // DraftsListView::onDialogDeleteMsg |
|
368 // @see header |
|
369 //------------------------------------------------------------------------------ |
|
370 void DraftsListView::onDialogDeleteAllMessages(HbAction* action) |
|
371 { |
|
372 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
373 if (action == dlg->actions().at(0)) { |
|
374 ConversationsEngine::instance()->deleteAllDraftMessages(); |
|
375 } |
|
376 } |
|
377 |
356 // EOF |
378 // EOF |