227 SLOT(itemActivated(const QModelIndex &))); |
226 SLOT(itemActivated(const QModelIndex &))); |
228 QObject::connect(mMessageListWidget, |
227 QObject::connect(mMessageListWidget, |
229 SIGNAL(longPressed(HbAbstractViewItem*, QPointF)), this, |
228 SIGNAL(longPressed(HbAbstractViewItem*, QPointF)), this, |
230 SLOT(showItemContextMenu(HbAbstractViewItem*, QPointF))); |
229 SLOT(showItemContextMenu(HbAbstractViewItem*, QPointF))); |
231 mMessageListWidget->setFocus(); |
230 mMessageListWidget->setFocus(); |
232 mItemContextMenu = new HbMenu(); |
|
233 } |
231 } |
234 } |
232 } |
235 |
233 |
236 |
234 |
237 /*! |
235 /*! |
312 QObject::connect(mMessageListModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)), |
310 QObject::connect(mMessageListModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)), |
313 this, SLOT(itemsRemoved())); |
311 this, SLOT(itemsRemoved())); |
314 QObject::connect(mMessageListModel, SIGNAL(setNewParam(NmUiStartParam*)), |
312 QObject::connect(mMessageListModel, SIGNAL(setNewParam(NmUiStartParam*)), |
315 this, SLOT(reloadViewContents(NmUiStartParam*))); |
313 this, SLOT(reloadViewContents(NmUiStartParam*))); |
316 |
314 |
317 if (mMessageListModel->rowCount()==0){ |
315 mPreviousModelCount=mMessageListModel->rowCount(); |
|
316 if (mPreviousModelCount==0){ |
318 showNoMessagesText(); |
317 showNoMessagesText(); |
319 } |
318 } |
320 else{ |
319 else{ |
321 hideNoMessagesText(); |
320 hideNoMessagesText(); |
322 } |
321 } |
400 Long keypress handling |
399 Long keypress handling |
401 */ |
400 */ |
402 void NmMessageListView::showItemContextMenu(HbAbstractViewItem *listViewItem, const QPointF &coords) |
401 void NmMessageListView::showItemContextMenu(HbAbstractViewItem *listViewItem, const QPointF &coords) |
403 { |
402 { |
404 NM_FUNCTION; |
403 NM_FUNCTION; |
405 |
404 |
406 if (listViewItem) { |
405 if (listViewItem) { |
|
406 // Recreate item context menu each time it is called |
|
407 if (mItemContextMenu){ |
|
408 mItemContextMenu->clearActions(); |
|
409 delete mItemContextMenu; |
|
410 mItemContextMenu=NULL; |
|
411 } |
|
412 mItemContextMenu = new HbMenu(); |
407 // Store long press item for later use with response |
413 // Store long press item for later use with response |
408 mLongPressedItem = mMessageListModel->data( |
414 mLongPressedItem = mMessageListModel->data( |
409 listViewItem->modelIndex(), Qt::DisplayRole).value<NmMessageListModelItem*>(); |
415 listViewItem->modelIndex(), Qt::DisplayRole).value<NmMessageListModelItem*>(); |
410 if (mItemContextMenu && mLongPressedItem && mLongPressedItem->itemType() == |
416 if (mItemContextMenu && mLongPressedItem && mLongPressedItem->itemType() == |
411 NmMessageListModelItem::NmMessageItemMessage) { |
417 NmMessageListModelItem::NmMessageItemMessage) { |
572 // Handle toolbar commands here |
578 // Handle toolbar commands here |
573 else if ( actionResponse.menuType() == NmActionToolbar ) { |
579 else if ( actionResponse.menuType() == NmActionToolbar ) { |
574 if ( actionResponse.responseCommand() == NmActionResponseCommandNewMail ) { |
580 if ( actionResponse.responseCommand() == NmActionResponseCommandNewMail ) { |
575 // Check that given start response has mailbox and folder id's |
581 // Check that given start response has mailbox and folder id's |
576 if (actionResponse.mailboxId()!=0){ |
582 if (actionResponse.mailboxId()!=0){ |
577 if (mUiEngine.isSendingMessage()) { |
583 NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageEditor, |
578 // sending is ongoing so just show a note |
584 actionResponse.mailboxId(), mStartParam->folderId()); |
579 QString noteText = hbTrId("txt_mail_dialog_still_sending"); |
585 // startParam ownerhips transfers |
580 |
586 mApplication.enterNmUiView(startParam); |
581 // get message subject from the message being sent |
|
582 const NmMessage *message = mUiEngine.messageBeingSent(); |
|
583 if (message) { |
|
584 noteText = noteText.arg(NmUtilities::truncate(message->envelope().subject(), 20)); |
|
585 } |
|
586 HbMessageBox::warning(noteText); |
|
587 } |
|
588 else { |
|
589 NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageEditor, |
|
590 actionResponse.mailboxId(), mStartParam->folderId()); |
|
591 // startParam ownerhips transfers |
|
592 mApplication.enterNmUiView(startParam); |
|
593 } |
|
594 } |
587 } |
595 } |
588 } |
596 if (actionResponse.responseCommand() == NmActionResponseCommandSearch) { |
589 if (actionResponse.responseCommand() == NmActionResponseCommandSearch) { |
597 // Check that the given start response has mailbox and folder IDs. |
590 // Check that the given start response has mailbox and folder IDs. |
598 if (actionResponse.mailboxId() != 0) { |
591 if (actionResponse.mailboxId() != 0) { |
599 if (mUiEngine.isSendingMessage()) { |
592 NmUiStartParam *startParam = |
600 // Sending is ongoing so just show a note. |
593 new NmUiStartParam(NmUiViewMessageSearchList, |
601 QString noteText = hbTrId("txt_mail_dialog_still_sending"); |
594 actionResponse.mailboxId(), |
602 |
595 mStartParam->folderId()); |
603 // Get the message subject from the message being sent. |
596 |
604 const NmMessage *message = mUiEngine.messageBeingSent(); |
597 // startParam ownership transfers. |
605 |
598 mApplication.enterNmUiView(startParam); |
606 if (message) { |
|
607 noteText = noteText.arg( |
|
608 NmUtilities::truncate(message->envelope().subject(), 20)); |
|
609 } |
|
610 |
|
611 HbMessageBox::warning(noteText); |
|
612 } |
|
613 else { |
|
614 NmUiStartParam *startParam = |
|
615 new NmUiStartParam(NmUiViewMessageSearchList, |
|
616 actionResponse.mailboxId(), |
|
617 mStartParam->folderId()); |
|
618 |
|
619 // startParam ownership transfers. |
|
620 mApplication.enterNmUiView(startParam); |
|
621 } |
|
622 } |
599 } |
623 } |
600 } |
624 } |
601 } |
625 } |
602 } |
626 |
603 |
720 NM_FUNCTION; |
697 NM_FUNCTION; |
721 |
698 |
722 Q_UNUSED(parent); |
699 Q_UNUSED(parent); |
723 Q_UNUSED(end); |
700 Q_UNUSED(end); |
724 |
701 |
725 // If "no messages" label is shown, hide it and display the message list |
702 // Hide no messages if previous model count has been zero |
726 // widget. |
703 // and new items have been added to the list |
727 if (mNoMessagesLabel && mNoMessagesLabel->isVisible()) { |
704 if (mPreviousModelCount==0) { |
728 mNoMessagesLabel->hide(); |
705 hideNoMessagesText(); |
729 mMessageListWidget->show(); |
|
730 } |
706 } |
731 |
707 |
732 // Make sure the top of the list is kept visible by scrolling back to the |
708 // Make sure the top of the list is kept visible by scrolling back to the |
733 // top if necessary. |
709 // top if necessary. |
734 if (start == 0 && mMessageListWidget) { |
710 if (start == 0 && mMessageListWidget) { |