79 // MsgListView::MsgListView |
76 // MsgListView::MsgListView |
80 // @see header |
77 // @see header |
81 //--------------------------------------------------------------- |
78 //--------------------------------------------------------------- |
82 MsgListView::MsgListView(QGraphicsItem *parent) : |
79 MsgListView::MsgListView(QGraphicsItem *parent) : |
83 MsgBaseView(parent) |
80 MsgBaseView(parent) |
84 { |
81 { |
85 connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction())); |
82 //These changes are needed for splash implementation to avoid flicker |
86 } |
83 setupToolBar(); |
|
84 setupMenu(); |
|
85 |
|
86 // Create parent layout. |
|
87 mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); |
|
88 mMainLayout->setContentsMargins(0, 0, 0, 0); |
|
89 mMainLayout->setSpacing(0); |
|
90 |
|
91 // Create view heading. |
|
92 HbGroupBox *viewHeading = new HbGroupBox(); |
|
93 viewHeading->setHeading(LOC_VIEW_HEADING); |
|
94 |
|
95 // Add view heading widget to main layout. |
|
96 mMainLayout->addItem(viewHeading); |
|
97 |
|
98 this->setLayout(mMainLayout); |
|
99 |
|
100 connect(this->mainWindow(), SIGNAL(viewReady()), this, |
|
101 SLOT(doDelayedConstruction())); |
|
102 } |
87 |
103 |
88 //--------------------------------------------------------------- |
104 //--------------------------------------------------------------- |
89 // MsgListView::~MsgListView |
105 // MsgListView::~MsgListView |
90 // @see header |
106 // @see header |
91 //--------------------------------------------------------------- |
107 //--------------------------------------------------------------- |
209 void MsgListView::deleteItem() |
224 void MsgListView::deleteItem() |
210 { |
225 { |
211 #ifdef _DEBUG_TRACES_ |
226 #ifdef _DEBUG_TRACES_ |
212 qDebug() << "Inside MsgListView::deleteItem"; |
227 qDebug() << "Inside MsgListView::deleteItem"; |
213 #endif |
228 #endif |
214 |
|
215 QModelIndex index = mMsgList->currentIndex(); |
|
216 qint64 conversationId = index.data(ConversationId).toLongLong(); |
|
217 |
|
218 //confirmation dialog. |
229 //confirmation dialog. |
219 bool result = HbMessageBox::question(LOC_DIALOG_DELETE_CONVERSATION, |
230 HbMessageBox::question(LOC_DIALOG_DELETE_CONVERSATION, |
220 LOC_BUTTON_DELETE, LOC_BUTTON_CANCEL); |
231 this,SLOT(onDialogDeleteMsg(HbAction*)), |
221 if (result) |
232 HbMessageBox::Delete | HbMessageBox::Cancel); |
222 { |
|
223 ConversationsEngine::instance()->deleteConversations(conversationId); |
|
224 } |
|
225 |
|
226 #ifdef _DEBUG_TRACES_ |
233 #ifdef _DEBUG_TRACES_ |
227 qDebug() << " Leaving MsgConversationView::deleteItem"; |
234 qDebug() << " Leaving MsgConversationView::deleteItem"; |
228 #endif |
235 #endif |
229 } |
236 } |
230 |
237 |
231 //--------------------------------------------------------------- |
238 //--------------------------------------------------------------- |
232 // MsgListView::setupView |
239 // MsgListView::setupView |
233 // @see header |
240 // @see header |
234 //--------------------------------------------------------------- |
241 //--------------------------------------------------------------- |
235 void MsgListView::setupListView() |
242 void MsgListView::setupListView() |
236 { |
243 { |
237 // Create parent layout. |
|
238 QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical); |
|
239 mainLayout->setContentsMargins(0, 0, 0, 0); |
|
240 mainLayout->setSpacing(0); |
|
241 |
|
242 // Create view heading. |
|
243 HbGroupBox *viewHeading = new HbGroupBox(); |
|
244 viewHeading->setHeading(LOC_VIEW_HEADING); |
|
245 |
|
246 // Register the custorm css path. |
244 // Register the custorm css path. |
247 HbStyleLoader::registerFilePath(":/xml/msglistviewitem.css"); |
245 HbStyleLoader::registerFilePath(":/clv"); |
248 HbStyleLoader::registerFilePath(":/xml/msglistviewitem.widgetml"); |
|
249 |
246 |
250 mMsgList = new HbListView(this); |
247 mMsgList = new HbListView(this); |
251 mMsgList->setScrollingStyle(HbScrollArea::PanOrFlick); |
248 mMsgList->setScrollingStyle(HbScrollArea::PanOrFlick); |
252 mMsgList->setClampingStyle(HbScrollArea::BounceBackClamping); |
249 mMsgList->setClampingStyle(HbScrollArea::BounceBackClamping); |
253 |
250 |
254 mMsgList->setLayoutName("custom"); |
251 mMsgList->setLayoutName("custom"); |
255 mMsgList->setItemRecycling(true); |
252 mMsgList->setItemRecycling(true); |
256 mMsgList->setUniformItemSizes(true); |
253 mMsgList->setUniformItemSizes(true); |
257 |
254 |
258 MsgListViewItem *prototype = new MsgListViewItem(this); |
255 MsgListViewItem *prototype = new MsgListViewItem(this); |
259 mMsgList->setItemPrototype(prototype); |
256 mMsgList->setItemPrototype(prototype); |
260 |
257 mMsgList->setModel(ConversationsEngine::instance()->getConversationsSummaryModel()); |
261 // Set proxy model |
258 |
262 QSortFilterProxyModel* proxyModel = new QSortFilterProxyModel(this); |
|
263 proxyModel->setDynamicSortFilter(true); |
|
264 proxyModel->setSourceModel(ConversationsEngine::instance()->getConversationsSummaryModel()); |
|
265 proxyModel->setSortRole(TimeStamp); |
|
266 proxyModel->sort(0, Qt::DescendingOrder); |
|
267 |
|
268 mMsgList->setModel(proxyModel); |
|
269 |
|
270 connect(ConversationsEngine::instance(), SIGNAL(conversationListModelPopulated()), |
|
271 this, SLOT(populateListView())); |
|
272 |
|
273 // Single tap list item |
259 // Single tap list item |
274 connect(mMsgList, SIGNAL(activated(const QModelIndex&)), |
260 connect(mMsgList, SIGNAL(activated(const QModelIndex&)), this, |
275 this, SLOT(openConversation(const QModelIndex&))); |
261 SLOT(openConversation(const QModelIndex&))); |
276 |
262 |
277 // Long tap list item |
263 // Long tap list item |
278 connect(mMsgList, SIGNAL(longPressed(HbAbstractViewItem*, const QPointF&)), |
264 connect(mMsgList, |
279 this, SLOT(longPressed(HbAbstractViewItem*, const QPointF&))); |
265 SIGNAL(longPressed(HbAbstractViewItem*, const QPointF&)), this, |
280 |
266 SLOT(longPressed(HbAbstractViewItem*, const QPointF&))); |
281 // Add all widgets to main layout. |
267 |
282 mainLayout->addItem(viewHeading); |
268 // enable tap after delete is completed |
283 mainLayout->addItem(mMsgList); |
269 connect(ConversationsEngine::instance(), |
284 |
270 SIGNAL(conversationListEntryDeleted( int )), this, |
285 this->setLayout(mainLayout); |
271 SLOT(enableListitem( int ))); |
286 } |
272 |
|
273 // Add list view to main layout. |
|
274 mMainLayout->addItem(mMsgList); |
|
275 } |
287 |
276 |
288 //--------------------------------------------------------------- |
277 //--------------------------------------------------------------- |
289 // MsgListView::addMenu |
278 // MsgListView::addMenu |
290 // @see header |
279 // @see header |
291 //--------------------------------------------------------------- |
280 //--------------------------------------------------------------- |
421 request->send(); |
409 request->send(); |
422 |
410 |
423 delete request; |
411 delete request; |
424 } |
412 } |
425 |
413 |
|
414 //--------------------------------------------------------------- |
|
415 // MsgListView::onDialogDeleteMsg |
|
416 // @see header |
|
417 //--------------------------------------------------------------- |
|
418 void MsgListView::onDialogDeleteMsg(HbAction* action) |
|
419 { |
|
420 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
421 if (action == dlg->actions().at(0)) |
|
422 { |
|
423 QModelIndex index = mMsgList->currentIndex(); |
|
424 if (index.isValid()) |
|
425 { |
|
426 HbAbstractViewItem *item = mMsgList->currentViewItem(); |
|
427 item->ungrabGesture(Qt::TapGesture); |
|
428 qint64 conversationId = index.data(ConversationId).toLongLong(); |
|
429 |
|
430 ConversationsEngine::instance()->deleteConversations( |
|
431 conversationId); |
|
432 |
|
433 } |
|
434 |
|
435 } |
|
436 } |
|
437 |
|
438 //--------------------------------------------------------------- |
|
439 // MsgListView::enableListitem |
|
440 // @see header |
|
441 //--------------------------------------------------------------- |
|
442 void MsgListView::enableListitem(int conversationId) |
|
443 { |
|
444 QAbstractItemModel* proxyModel = mMsgList->model(); |
|
445 QModelIndexList indexList = proxyModel->match(proxyModel->index(0, 0), |
|
446 ConversationId, conversationId, 1, Qt::MatchExactly); |
|
447 HbAbstractViewItem* item = NULL; |
|
448 int count = indexList.count(); |
|
449 // only item is expected to be the result of the above match function |
|
450 if (1 == count) |
|
451 { |
|
452 item = mMsgList->itemByIndex(indexList[0]); |
|
453 if (item) |
|
454 { |
|
455 item->grabGesture(Qt::TapGesture); |
|
456 } |
|
457 } |
|
458 |
|
459 } |
|
460 |
426 //EOF |
461 //EOF |