199 void MsgUnifiedEditorView::initView() |
176 void MsgUnifiedEditorView::initView() |
200 { |
177 { |
201 if (!HbStyleLoader::registerFilePath(":/layouts")) { |
178 if (!HbStyleLoader::registerFilePath(":/layouts")) { |
202 QDEBUG_WRITE("ERROR: MsgUnifiedEditorView -> HbStyleLoader::registerFilePath"); |
179 QDEBUG_WRITE("ERROR: MsgUnifiedEditorView -> HbStyleLoader::registerFilePath"); |
203 } |
180 } |
204 HbScrollArea* scrollArea = new HbScrollArea(this); |
181 |
205 this->setWidget(scrollArea); |
182 //message monitor. |
206 |
183 mMsgMonitor = new MsgUnifiedEditorMonitor(this); |
207 mContentWidget = new HbWidget(this); |
184 |
208 scrollArea->setContentWidget(mContentWidget); |
185 //Set the invalid msg id |
209 |
186 mOpenedMessageId.setId(-1); |
210 mMainLayout = new QGraphicsLinearLayout(Qt::Vertical, mContentWidget); |
187 |
|
188 mMainLayout = new QGraphicsLinearLayout(Qt::Vertical, this); |
211 qreal vTopSpacing = 0.0; |
189 qreal vTopSpacing = 0.0; |
212 qreal vItemSpacing = 0.0; |
190 qreal vItemSpacing = 0.0; |
213 style()->parameter("hb-param-margin-gene-top",vTopSpacing); |
191 style()->parameter("hb-param-margin-gene-top",vTopSpacing); |
214 style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing); |
192 style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing); |
215 |
|
216 mMainLayout->setContentsMargins(0,vTopSpacing,0,0); |
193 mMainLayout->setContentsMargins(0,vTopSpacing,0,0); |
217 mMainLayout->setSpacing(vItemSpacing); |
194 mMainLayout->setSpacing(vItemSpacing); |
218 |
195 |
219 mMsgMonitor = new MsgUnifiedEditorMonitor(this); |
196 mScrollArea = new MsgUnifiedEditorScrollArea(mMsgMonitor,this); |
220 connect(mMsgMonitor, SIGNAL(enableSend(bool)), this, SLOT(enableSendButton(bool))); |
197 mMainLayout->addItem(mScrollArea); |
221 |
198 |
222 mToField = new MsgUnifiedEditorAddress( LOC_TO, mContentWidget ); |
199 mBodyEditor = new MsgUnifiedEditorBodyEditor(this); |
223 |
200 |
224 mBody = new MsgUnifiedEditorBody( mContentWidget); |
201 connect(mScrollArea,SIGNAL(enableMenuAction(int,bool)),this,SLOT(enableMenuAction(int,bool))); |
225 |
202 |
226 mMainLayout->addItem(mToField); |
203 connect(mBodyEditor, SIGNAL(contentsChanged(const QVariant&)), |
227 mMainLayout->addItem(mBody); |
204 mMsgMonitor,SLOT(handleContentsChanged(const QVariant&))); |
228 |
205 |
229 //Set the invalid msg id |
206 connect(mMsgMonitor,SIGNAL(enableSend(bool)), |
230 mOpenedMessageId.setId(-1); |
207 mBodyEditor,SLOT(enableSendButton(bool))); |
231 |
208 |
232 connect(mToField, SIGNAL(sendMessage()), this, SLOT(send())); |
209 connect(mBodyEditor,SIGNAL(sendMessage()),this,SLOT(send())); |
233 connect(mToField, SIGNAL(contentChanged()), |
210 |
234 mMsgMonitor, SLOT(handleContentChange())); |
211 connect(mMsgMonitor,SIGNAL(contentsChanged()),this,SLOT(onContentChanged())); |
235 connect(mToField, SIGNAL(contentChanged()),this,SLOT(onContentChanged())); |
212 |
236 |
213 mMainLayout->addItem(mBodyEditor); |
237 connect(mBody, SIGNAL(sendMessage()), this, SLOT(send())); |
214 |
238 connect(mBody, SIGNAL(contentChanged()),this,SLOT(onContentChanged())); |
215 } |
239 connect(mBody, SIGNAL(contentChanged()), |
216 |
240 mMsgMonitor, SLOT(handleContentChange())); |
217 //--------------------------------------------------------------- |
241 connect(mBody, SIGNAL(enableSendButton(bool)), this, SLOT(enableSendButton(bool))); |
218 // MsgUnifiedEditorView::addMenu |
242 |
219 // @see header file |
243 } |
220 //--------------------------------------------------------------- |
244 |
|
245 void MsgUnifiedEditorView::addMenu() |
221 void MsgUnifiedEditorView::addMenu() |
246 { |
222 { |
247 //Create Menu Options |
223 //Create Menu Options |
248 HbMenu* mainMenu = this->menu(); |
224 HbMenu* mainMenu = this->menu(); |
249 mainMenu->setFocusPolicy(Qt::NoFocus); |
225 mainMenu->setFocusPolicy(Qt::NoFocus); |
250 |
226 |
251 //if subject field / cc,bcc fields are already present don't add corresponding actions. |
227 //attach sub menu |
252 if(!mSubjectField) |
228 HbMenu* attachMenu = mainMenu->addMenu(LOC_ATTACH); |
253 { |
229 mPhotoAction = attachMenu->addAction(LOC_PHOTO,this,SLOT(fetchImages())); |
254 mSubjectAction = mainMenu->addAction(LOC_ADD_SUBJECT); |
230 mSoundAction = attachMenu->addAction(LOC_SOUND,this,SLOT(fetchAudio())); |
255 } |
231 attachMenu->addAction(LOC_BUSINESS_CARD,this,SLOT(fetchContacts())); |
256 |
232 |
257 if(!mCcField) |
233 //subject action |
258 { |
234 mSubjectAction = mainMenu->addAction(LOC_ADD_SUBJECT); |
259 mCcBccAction = mainMenu->addAction(LOC_ADD_CC_BCC); |
235 //CcBcc action |
260 } |
236 mCcBccAction = mainMenu->addAction(LOC_ADD_CC_BCC); |
261 |
237 connect(mSubjectAction,SIGNAL(triggered()),this, SLOT(addSubject())); |
|
238 connect(mCcBccAction,SIGNAL(triggered()),this, SLOT(addCcBcc())); |
|
239 |
|
240 //priority sub menu |
262 HbMenu* prioritySubMenu = mainMenu->addMenu(LOC_PRIORITY); |
241 HbMenu* prioritySubMenu = mainMenu->addMenu(LOC_PRIORITY); |
263 |
242 |
264 HbAction* highPriorityAction = prioritySubMenu->addAction(LOC_HIGH); |
243 HbAction* highPriorityAction = prioritySubMenu->addAction(LOC_HIGH); |
265 highPriorityAction->setData(ConvergedMessage::High); |
244 highPriorityAction->setData(ConvergedMessage::High); |
266 |
245 |
267 HbAction* normalPriorityAction = prioritySubMenu->addAction(LOC_NORMAL); |
246 HbAction* normalPriorityAction = prioritySubMenu->addAction(LOC_NORMAL); |
268 normalPriorityAction->setData(ConvergedMessage::Normal); |
247 normalPriorityAction->setData(ConvergedMessage::Normal); |
269 |
248 |
270 HbAction* lowPriorityAction = prioritySubMenu->addAction(LOC_LOW); |
249 HbAction* lowPriorityAction = prioritySubMenu->addAction(LOC_LOW); |
271 lowPriorityAction->setData(ConvergedMessage::Low); |
250 lowPriorityAction->setData(ConvergedMessage::Low); |
272 |
251 |
|
252 connect(highPriorityAction, SIGNAL(triggered()), mScrollArea, SLOT(changePriority())); |
|
253 connect(normalPriorityAction, SIGNAL(triggered()), mScrollArea, SLOT(changePriority())); |
|
254 connect(lowPriorityAction, SIGNAL(triggered()), mScrollArea, SLOT(changePriority())); |
|
255 |
|
256 |
273 HbAction* deleteMsgAction = mainMenu->addAction(LOC_DELETE_MESSAGE); |
257 HbAction* deleteMsgAction = mainMenu->addAction(LOC_DELETE_MESSAGE); |
274 |
|
275 connect(mSubjectAction,SIGNAL(triggered()),this, SLOT(addSubject())); |
|
276 connect(mCcBccAction,SIGNAL(triggered()),this, SLOT(addCcBcc())); |
|
277 connect(highPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority())); |
|
278 connect(normalPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority())); |
|
279 connect(lowPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority())); |
|
280 connect(deleteMsgAction,SIGNAL(triggered()),this, SLOT(deleteMessage())); |
258 connect(deleteMsgAction,SIGNAL(triggered()),this, SLOT(deleteMessage())); |
281 |
259 |
282 } |
260 } |
283 |
261 |
|
262 //--------------------------------------------------------------- |
|
263 // MsgUnifiedEditorView::openDraftsMessage |
|
264 // @see header file |
|
265 //--------------------------------------------------------------- |
284 void MsgUnifiedEditorView::openDraftsMessage(const QVariantList& editorData) |
266 void MsgUnifiedEditorView::openDraftsMessage(const QVariantList& editorData) |
285 { |
267 { |
286 // unpack editor's data |
268 // unpack editor's data |
287 // first arg is convergedmessage |
269 // first arg is convergedmessage |
288 QByteArray dataArray = editorData.at(0).toByteArray(); |
270 QByteArray dataArray = editorData.at(0).toByteArray(); |
399 case MsgBaseView::FORWARD_MSG: |
383 case MsgBaseView::FORWARD_MSG: |
400 { |
384 { |
401 fetchMessageFromStore(*messageDetails->id(), |
385 fetchMessageFromStore(*messageDetails->id(), |
402 messageDetails->messageType(), |
386 messageDetails->messageType(), |
403 UniEditorPluginInterface::Forward); |
387 UniEditorPluginInterface::Forward); |
404 } |
388 return; |
405 break; |
389 } |
406 case MsgBaseView::REPLY_MSG: |
390 case MsgBaseView::REPLY_MSG: |
407 { |
391 { |
408 fetchMessageFromStore(*messageDetails->id(), |
392 fetchMessageFromStore(*messageDetails->id(), |
409 messageDetails->messageType(), |
393 messageDetails->messageType(), |
410 UniEditorPluginInterface::Reply); |
394 UniEditorPluginInterface::Reply); |
411 } |
395 return; |
412 break; |
396 } |
413 case MsgBaseView::REPLY_ALL_MSG: |
397 case MsgBaseView::REPLY_ALL_MSG: |
414 { |
398 { |
415 fetchMessageFromStore(*messageDetails->id(), |
399 fetchMessageFromStore(*messageDetails->id(), |
416 messageDetails->messageType(), |
400 messageDetails->messageType(), |
417 UniEditorPluginInterface::ReplyAll); |
401 UniEditorPluginInterface::ReplyAll); |
418 } |
402 return; |
419 break; |
403 } |
420 default: |
404 default: |
421 break; |
405 break; |
422 } |
406 } |
423 |
407 |
424 // additional common operations for non-forwarded messages |
408 populateContentIntoEditor(*messageDetails,false,false); |
425 if(editorOp != MsgBaseView::FORWARD_MSG) |
409 |
426 { |
|
427 if(editorOp == MsgBaseView::ADD_RECIPIENTS) |
|
428 { |
|
429 // CV sends contact card address as the first address |
|
430 ConvergedMessageAddressList toAddresses = |
|
431 messageDetails->toAddressList(); |
|
432 int addrCount = toAddresses.count(); |
|
433 if(addrCount > 0) |
|
434 { |
|
435 // add contact card address first |
|
436 ConvergedMessageAddress *firstAddress = |
|
437 new ConvergedMessageAddress(); |
|
438 firstAddress->setAlias(toAddresses.at(0)->alias()); |
|
439 firstAddress->setAddress(toAddresses.at(0)->address()); |
|
440 ConvergedMessageAddressList firstList; |
|
441 firstList << firstAddress; |
|
442 mToField->setAddresses(firstList); |
|
443 |
|
444 // add remaining contacts now |
|
445 ConvergedMessageAddressList otherList; |
|
446 for(int i=1; i<addrCount; i++) |
|
447 { |
|
448 otherList << toAddresses.at(i); |
|
449 } |
|
450 mToField->setAddresses(otherList); |
|
451 } |
|
452 } |
|
453 else |
|
454 { |
|
455 mToField->setAddresses(messageDetails->toAddressList()); |
|
456 } |
|
457 QString bodyTxt = messageDetails->bodyText(); |
|
458 mBody->setText(bodyTxt); |
|
459 |
|
460 int attachmentCount = messageDetails->attachments().count(); |
|
461 QStringList pendingAttList; |
|
462 for(int i=0; i<attachmentCount; i++) |
|
463 { |
|
464 int imageSize=0; |
|
465 QString mimeType; |
|
466 TMsgMediaType mediaType = EMsgMediaUnknown; |
|
467 QString filePath = messageDetails->attachments().at(i)->filePath(); |
|
468 |
|
469 |
|
470 UniEditorGenUtils* genUtils = q_check_ptr(new UniEditorGenUtils); |
|
471 |
|
472 TRAP_IGNORE(genUtils->getFileInfoL(filePath,imageSize, |
|
473 mimeType,mediaType)); |
|
474 delete genUtils; |
|
475 switch(mediaType) |
|
476 { |
|
477 case EMsgMediaImage: |
|
478 { |
|
479 mBody->setImage(filePath); |
|
480 } |
|
481 break; |
|
482 case EMsgMediaAudio: |
|
483 { |
|
484 mBody->setAudio(filePath); |
|
485 } |
|
486 break; |
|
487 default: |
|
488 { |
|
489 pendingAttList << filePath; |
|
490 } |
|
491 break; |
|
492 } |
|
493 } |
|
494 // add pending attachments in bulk |
|
495 addAttachments(pendingAttList); |
|
496 } |
|
497 delete messageDetails; |
410 delete messageDetails; |
498 } |
411 } |
499 |
412 |
500 void MsgUnifiedEditorView::populateContentIntoEditor( |
413 //--------------------------------------------------------------- |
501 const ConvergedMessage& messageDetails,bool draftMessage) |
414 // MsgUnifiedEditorView::populateContentIntoEditor |
|
415 // @see header file |
|
416 //--------------------------------------------------------------- |
|
417 void MsgUnifiedEditorView::populateContentIntoEditor(const ConvergedMessage& messageDetails, |
|
418 bool draftMessage, |
|
419 bool checkForInline) |
502 { |
420 { |
503 // skip first-time MMS type switch note for draft |
421 // skip first-time MMS type switch note for draft |
|
422 if(draftMessage) |
|
423 { |
504 mMsgMonitor->setSkipNote(true); |
424 mMsgMonitor->setSkipNote(true); |
505 mToField->skipMaxRecipientQuery(true); |
425 } |
506 |
426 |
507 mToField->setAddresses(messageDetails.toAddressList(),draftMessage); |
427 //scrollarea populate contents |
508 if(messageDetails.ccAddressList().count() > 0 ) |
428 mScrollArea->populateContent(messageDetails,draftMessage,checkForInline); |
509 { |
429 |
510 if(!mCcField) |
430 //body editor populate contents |
511 { |
431 mBodyEditor->populateContent(messageDetails); |
512 addCcBcc(); |
432 |
513 } |
|
514 mCcField->setAddresses(messageDetails.ccAddressList(),draftMessage); |
|
515 } |
|
516 if(messageDetails.bccAddressList().count() > 0 ) |
|
517 { |
|
518 if(!mBccField) |
|
519 { |
|
520 addCcBcc(); |
|
521 } |
|
522 mBccField->setAddresses(messageDetails.bccAddressList(),draftMessage); |
|
523 } |
|
524 if(messageDetails.subject().size() > 0) |
|
525 { |
|
526 if(!mSubjectField) |
|
527 { |
|
528 addSubject(); |
|
529 } |
|
530 mSubjectField->setText(messageDetails.subject()); |
|
531 } |
|
532 |
|
533 if(messageDetails.priority()==ConvergedMessage::High || |
|
534 messageDetails.priority() == ConvergedMessage::Low) |
|
535 { |
|
536 if(!mSubjectField) |
|
537 { |
|
538 addSubject(); |
|
539 } |
|
540 mSubjectField->setPriority(messageDetails.priority()); |
|
541 } |
|
542 |
|
543 QString bodyTxt = messageDetails.bodyText(); |
|
544 mBody->setText(bodyTxt); |
|
545 |
|
546 ConvergedMessageAttachmentList attachmentList = |
|
547 messageDetails.attachments(); |
|
548 int attachmentCount = attachmentList.count(); |
|
549 |
|
550 UniEditorGenUtils* genUtils = q_check_ptr(new UniEditorGenUtils); |
|
551 |
|
552 QStringList pendingAttList; |
|
553 for( int i=0; i < attachmentCount; i++ ) |
|
554 { |
|
555 QString filePath = messageDetails.attachments().at(i)->filePath(); |
|
556 |
|
557 if(attachmentList.at(i)->attachmentType() == |
|
558 ConvergedMessageAttachment::EInline) |
|
559 { |
|
560 int imageSize=0; |
|
561 QString mimeType; |
|
562 TMsgMediaType mediaType = EMsgMediaUnknown; |
|
563 TRAP_IGNORE(genUtils->getFileInfoL(filePath,imageSize, |
|
564 mimeType,mediaType)); |
|
565 |
|
566 switch(mediaType) |
|
567 { |
|
568 case EMsgMediaImage: |
|
569 { |
|
570 mBody->setImage(filePath,draftMessage); |
|
571 break; |
|
572 } |
|
573 case EMsgMediaAudio: |
|
574 { |
|
575 mBody->setAudio(filePath); |
|
576 break; |
|
577 } |
|
578 default: |
|
579 { |
|
580 pendingAttList << filePath; |
|
581 break; |
|
582 } |
|
583 } |
|
584 } |
|
585 else |
|
586 { |
|
587 pendingAttList << filePath; |
|
588 } |
|
589 } |
|
590 // add pending attachments to editor |
|
591 addAttachments(pendingAttList); |
|
592 |
|
593 delete genUtils; |
|
594 // ensure that any msg-type change after this are shown |
|
595 mToField->skipMaxRecipientQuery(false); |
|
596 mMsgMonitor->setSkipNote(false); |
433 mMsgMonitor->setSkipNote(false); |
597 } |
434 } |
598 |
435 |
599 void MsgUnifiedEditorView::addToolBar() |
436 //--------------------------------------------------------------- |
600 { |
437 // MsgUnifiedEditorView::addSubject |
601 //Create Tool Bar |
438 // @see header file |
602 HbToolBar *toolBar = new HbToolBar(); |
439 //--------------------------------------------------------------- |
603 toolBar->setOrientation(Qt::Horizontal); |
440 void MsgUnifiedEditorView::addSubject(bool needFocus) |
604 |
441 { |
605 //tool bar extension for attach action. |
442 //triggered from menu so need a focus. |
606 HbToolBarExtension* attachExtension = new HbToolBarExtension(); |
|
607 mAttachAction = toolBar->addExtension(attachExtension); |
|
608 mAttachAction->setIcon(HbIcon(ATTACH_ICON)); |
|
609 |
|
610 mTBExtnContentWidget = new HbListWidget(); |
|
611 mTBExtnContentWidget->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed); |
|
612 mTBExtnContentWidget->addItem(LOC_PHOTO); |
|
613 mTBExtnContentWidget->addItem(LOC_SOUND); |
|
614 mTBExtnContentWidget->addItem(LOC_BUSINESS_CARD); |
|
615 |
|
616 HbListViewItem *prototype = mTBExtnContentWidget->listItemPrototype(); |
|
617 HbFrameBackground frame(POPUP_LIST_FRAME, HbFrameDrawer::NinePieces); |
|
618 prototype->setDefaultFrame(frame); |
|
619 |
|
620 connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)), |
|
621 this, SLOT(handleViewExtnActivated(HbListWidgetItem*))); |
|
622 connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)), |
|
623 attachExtension, SLOT(close())); |
|
624 |
|
625 attachExtension->setContentWidget(mTBExtnContentWidget); |
|
626 |
|
627 //Add Action to the toolbar and show toolbar |
|
628 mSendAction = toolBar->addAction(HbIcon(SEND_ICON),QString(),this,SLOT(send())); |
|
629 mSendAction->setDisabled(true); |
|
630 |
|
631 setToolBar(toolBar); |
|
632 } |
|
633 |
|
634 void MsgUnifiedEditorView::addSubject() |
|
635 { |
|
636 if(mSubjectField) |
|
637 { // do nothing if already present |
|
638 return; |
|
639 } |
|
640 |
|
641 int index =0; |
|
642 int offset = 1; |
|
643 if(mAttachmentContainer) |
|
644 { |
|
645 ++offset; |
|
646 } |
|
647 index = mMainLayout->count() - offset; |
|
648 |
|
649 mSubjectField = new MsgUnifiedEditorSubject( mContentWidget); |
|
650 |
|
651 mMainLayout->insertItem(index,mSubjectField); |
|
652 connect(mSubjectField, SIGNAL(contentChanged()), |
|
653 mMsgMonitor, SLOT(handleContentChange())); |
|
654 connect(mSubjectField, SIGNAL(contentChanged()),this,SLOT(onContentChanged())); |
|
655 |
|
656 //set focus to subject field. |
|
657 HbAction* subjectAction = qobject_cast<HbAction*>(this->sender()); |
443 HbAction* subjectAction = qobject_cast<HbAction*>(this->sender()); |
658 if(subjectAction) |
444 if(subjectAction) |
659 { |
445 { |
660 setFocus(mSubjectField); |
446 needFocus = true; |
661 } |
447 } |
662 |
448 mScrollArea->addSubject(needFocus); |
663 // remove mainmenu's "Add Subject" action |
449 } |
664 if(mSubjectAction) |
450 |
665 { |
451 //--------------------------------------------------------------- |
666 HbMenu* mainMenu = this->menu(); |
452 // MsgUnifiedEditorView::addCcBcc |
667 mainMenu->removeAction(mSubjectAction); |
453 // @see header file |
668 mSubjectAction->setParent(NULL); |
454 //--------------------------------------------------------------- |
669 delete mSubjectAction; |
455 void MsgUnifiedEditorView::addCcBcc(bool needFocus) |
670 } |
456 { |
671 } |
|
672 |
|
673 void MsgUnifiedEditorView::addCcBcc() |
|
674 { |
|
675 if(mCcField && mBccField) |
|
676 { // do nothing if already present |
|
677 return; |
|
678 } |
|
679 |
|
680 mCcField = new MsgUnifiedEditorAddress( LOC_CC, mContentWidget ); |
|
681 mBccField = new MsgUnifiedEditorAddress( LOC_BCC, mContentWidget ); |
|
682 mCcField->skipMaxRecipientQuery(true); |
|
683 mBccField->skipMaxRecipientQuery(true); |
|
684 |
|
685 connect(mCcField, SIGNAL(sendMessage()), this, SLOT(send())); |
|
686 connect(mCcField, SIGNAL(contentChanged()), mMsgMonitor, SLOT(handleContentChange())); |
|
687 connect(mCcField, SIGNAL(contentChanged()),this,SLOT(onContentChanged())); |
|
688 |
|
689 connect(mBccField, SIGNAL(sendMessage()), this, SLOT(send())); |
|
690 connect(mBccField, SIGNAL(contentChanged()), mMsgMonitor, SLOT(handleContentChange())); |
|
691 connect(mBccField, SIGNAL(contentChanged()),this,SLOT(onContentChanged())); |
|
692 |
|
693 HbWidget* groupWidget = new HbWidget(mContentWidget); |
|
694 groupWidget->setContentsMargins(0,0,0,0); |
|
695 |
|
696 QGraphicsLinearLayout* ccBccLayout = new QGraphicsLinearLayout(Qt::Vertical, groupWidget); |
|
697 ccBccLayout->setContentsMargins(0,0,0,0); |
|
698 |
|
699 qreal vItemSpacing = 0.0; |
|
700 style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing); |
|
701 ccBccLayout->setSpacing(vItemSpacing); |
|
702 ccBccLayout->addItem(mCcField); |
|
703 ccBccLayout->addItem(mBccField); |
|
704 |
|
705 HbGroupBox* groupBox = new HbGroupBox(0); |
|
706 groupBox->setObjectName("groupBox"); |
|
707 |
|
708 groupBox->setContentWidget(groupWidget); |
|
709 groupBox->setHeading(LOC_OTHER_RECIPIENTS_EXPAND); |
|
710 mMainLayout->insertItem(1,groupBox); |
|
711 connect(groupBox, SIGNAL(toggled(bool)), this, SLOT(updateOtherRecipientCount(bool))); |
|
712 |
|
713 // add subject field too |
|
714 addSubject(); |
|
715 |
|
716 //set focus to Cc field. |
457 //set focus to Cc field. |
717 HbAction* ccBccAction = qobject_cast<HbAction*>(this->sender()); |
458 HbAction* ccBccAction = qobject_cast<HbAction*>(this->sender()); |
718 if(mCcBccAction) |
459 if(ccBccAction) |
719 { |
460 { |
720 setFocus(mCcField); |
461 needFocus = true; |
721 } |
462 } |
722 |
463 |
723 // remove mainmenu's "Add Cc/Bcc" & "Add Subject" actions |
464 mScrollArea->addCcBcc(needFocus); |
724 if(mCcBccAction) |
|
725 { |
|
726 HbMenu* mainmenu = this->menu(); |
|
727 mainmenu->removeAction(mCcBccAction); |
|
728 mCcBccAction->setParent(NULL); |
|
729 delete mCcBccAction; |
|
730 } |
|
731 |
|
732 this->updateGeometry(); |
|
733 } |
|
734 |
|
735 void MsgUnifiedEditorView::updateOtherRecipientCount(bool state) |
|
736 { |
|
737 HbGroupBox* groupBox = qobject_cast<HbGroupBox*>(sender()); |
|
738 if(groupBox) |
|
739 { |
|
740 if(!state) |
|
741 { |
|
742 groupBox->setHeading(LOC_OTHER_RECIPIENTS_EXPAND); |
|
743 } |
|
744 else |
|
745 { |
|
746 int addrCount = mCcField->addressCount(); |
|
747 addrCount += mBccField->addressCount(); |
|
748 if(addrCount > 0) |
|
749 { |
|
750 groupBox->setHeading(LOC_OTHER_RECIPIENTS(addrCount)); |
|
751 } |
|
752 } |
|
753 } |
|
754 } |
|
755 |
|
756 void MsgUnifiedEditorView::changePriority() |
|
757 { |
|
758 HbAction* action = qobject_cast<HbAction*>(sender()); |
|
759 |
|
760 ConvergedMessage::Priority priority = ConvergedMessage::Normal; |
|
761 if(action) |
|
762 { |
|
763 int data = action->data().toInt(); |
|
764 priority = ConvergedMessage::Priority(data); |
|
765 } |
|
766 |
|
767 addSubject(); |
465 addSubject(); |
768 mSubjectField->setPriority(priority); |
466 } |
769 } |
467 |
770 |
468 //--------------------------------------------------------------- |
|
469 // MsgUnifiedEditorView::deleteMessage |
|
470 // @see header file |
|
471 //--------------------------------------------------------------- |
771 void MsgUnifiedEditorView::deleteMessage() |
472 void MsgUnifiedEditorView::deleteMessage() |
772 { |
473 { |
773 HbMessageBox::question(LOC_NOTE_DELETE_MESSAGE,this, |
474 HbMessageBox::question(LOC_NOTE_DELETE_MESSAGE,this, |
774 SLOT(onDialogDeleteMsg(HbAction*)), |
475 SLOT(onDialogDeleteMsg(HbAction*)), |
775 HbMessageBox::Delete | HbMessageBox::Cancel); |
476 HbMessageBox::Delete | HbMessageBox::Cancel); |
776 } |
477 } |
777 |
478 |
778 void MsgUnifiedEditorView::removeAttachmentContainer() |
479 //--------------------------------------------------------------- |
779 { |
480 // MsgUnifiedEditorView::addAttachments |
780 if(mAttachmentContainer) |
481 // @see header file |
781 { |
482 //--------------------------------------------------------------- |
782 mMainLayout->removeItem(mAttachmentContainer); |
|
783 mAttachmentContainer->setParent(NULL); |
|
784 delete mAttachmentContainer; |
|
785 mAttachmentContainer = NULL; |
|
786 } |
|
787 } |
|
788 |
|
789 void MsgUnifiedEditorView::addAttachments(QStringList files) |
483 void MsgUnifiedEditorView::addAttachments(QStringList files) |
790 { |
484 { |
791 int fcount = files.count(); |
485 mScrollArea->addAttachments(files); |
792 int i=0; |
486 } |
793 for(i=0; i<fcount; i++) |
487 |
794 { |
488 //--------------------------------------------------------------- |
795 int status = addAttachment(files.at(i)); |
489 // MsgUnifiedEditorView::send |
796 if(status == MsgAttachmentContainer::EAddSizeExceed) |
490 // @see header file |
797 { |
491 //--------------------------------------------------------------- |
798 QString displayStr = QString(LOC_UNABLE_TO_ADD_ATTACHMENTS) |
|
799 .arg(fcount-i).arg(fcount); |
|
800 HbNotificationDialog::launchDialog(displayStr); |
|
801 break; |
|
802 } |
|
803 } |
|
804 } |
|
805 |
|
806 int MsgUnifiedEditorView::addAttachment(const QString& filepath) |
|
807 { |
|
808 // do nothing if filepath is empty |
|
809 if(filepath.isEmpty()) |
|
810 { |
|
811 return MsgAttachmentContainer::EAddSuccess; |
|
812 } |
|
813 |
|
814 if(!mAttachmentContainer) |
|
815 { |
|
816 mAttachmentContainer = new MsgAttachmentContainer( mContentWidget); |
|
817 connect(mAttachmentContainer, SIGNAL(emptyAttachmentContainer()), |
|
818 this, SLOT(removeAttachmentContainer())); |
|
819 connect(mAttachmentContainer, SIGNAL(contentChanged()), |
|
820 mMsgMonitor, SLOT(handleContentChange())); |
|
821 connect(mAttachmentContainer, SIGNAL(contentChanged()), |
|
822 this,SLOT(onContentChanged())); |
|
823 |
|
824 int index = mMainLayout->count() - 1; |
|
825 mMainLayout->insertItem(index,mAttachmentContainer); |
|
826 } |
|
827 |
|
828 int ret = mAttachmentContainer->addAttachment(filepath); |
|
829 if(ret != MsgAttachmentContainer::EAddSuccess) |
|
830 { |
|
831 // delete container, if it is empty |
|
832 if(mAttachmentContainer->count() == 0) |
|
833 { |
|
834 removeAttachmentContainer(); |
|
835 } |
|
836 } |
|
837 return ret; |
|
838 } |
|
839 |
|
840 void MsgUnifiedEditorView::send() |
492 void MsgUnifiedEditorView::send() |
841 { |
493 { |
842 activateInputBlocker(); |
494 activateInputBlocker(); |
843 |
495 |
844 // first run the address validation tests |
496 // first run the address validation tests |
845 if( !mToField->validateContacts() || |
497 if(!mScrollArea->contactsValid() || |
846 (mCcField && !mCcField->validateContacts()) || |
498 !MsgUnifiedEditorMonitor::readyForSend()) |
847 (mBccField && !mBccField->validateContacts()) ) |
|
848 { |
499 { |
849 deactivateInputBlocker(); |
500 deactivateInputBlocker(); |
850 return; |
501 return; |
851 } |
502 } |
852 |
503 |
853 // converged msg for sending |
504 // converged msg for sending |
854 ConvergedMessage msg; |
505 ConvergedMessage msg; |
855 ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType(); |
506 ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType(); |
856 msg.setMessageType(messageType); |
507 msg.setMessageType(messageType); |
857 |
508 |
858 // we need to remove duplicate addresses |
509 |
859 bool removeDuplicates = true; |
|
860 ConvergedMessageAddressList addresses = |
|
861 mToField->addresses(removeDuplicates); |
|
862 if(messageType == ConvergedMessage::Sms && |
|
863 addresses.isEmpty()) |
|
864 { |
|
865 // no recipient specified for sms, do not send msg |
|
866 deactivateInputBlocker(); |
|
867 return; |
|
868 } |
|
869 |
|
870 ConvergedMessageAddressList ccAddresses; |
|
871 ConvergedMessageAddressList bccAddresses; |
|
872 if(mCcField) |
|
873 { |
|
874 ccAddresses = mCcField->addresses(removeDuplicates); |
|
875 } |
|
876 if(mBccField) |
|
877 { |
|
878 bccAddresses = mBccField->addresses(removeDuplicates); |
|
879 } |
|
880 if( messageType == ConvergedMessage::Mms && |
|
881 addresses.isEmpty() && |
|
882 ccAddresses.isEmpty() && |
|
883 bccAddresses.isEmpty()) |
|
884 { |
|
885 // no recipient specified for mms, do not send msg |
|
886 deactivateInputBlocker(); |
|
887 return; |
|
888 } |
|
889 |
|
890 //close vkb before switching view. |
510 //close vkb before switching view. |
891 mVkbHost->closeKeypad(true); |
511 mVkbHost->closeKeypad(true); |
892 |
512 |
893 int result = packMessage(msg); |
513 int result = packMessage(msg); |
894 if(result == KErrNotFound) |
514 if(result == KErrNotFound) |
915 mPluginLoader = new UniEditorPluginLoader(this); |
535 mPluginLoader = new UniEditorPluginLoader(this); |
916 } |
536 } |
917 |
537 |
918 UniEditorPluginInterface* pluginInterface = |
538 UniEditorPluginInterface* pluginInterface = |
919 mPluginLoader->getUniEditorPlugin(messageType); |
539 mPluginLoader->getUniEditorPlugin(messageType); |
920 //TODO delete the entry |
540 //delete the entry |
921 pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId()); |
541 pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId()); |
922 } |
542 } |
923 |
543 |
924 ConvergedMessageAddressList addrList = addresses; |
544 ConvergedMessageAddressList addrList = msg.toAddressList() + |
925 QString receipient; |
545 msg.ccAddressList() + |
926 |
546 msg.bccAddressList(); |
|
547 |
927 int recepientCount = addrList.count(); |
548 int recepientCount = addrList.count(); |
928 if(recepientCount) |
549 |
929 { |
550 QVariantList params; |
930 receipient = addrList.at(0)->address(); |
551 |
931 } |
552 if(recepientCount == 1 ) |
932 |
553 { |
933 if( mCcField && mBccField) |
554 params << MsgBaseView::CV; // target view |
934 { |
555 params << MsgBaseView::UNIEDITOR; // source view |
935 addrList = ccAddresses; |
556 QString receipient = addrList.at(0)->address(); |
936 int ccCount = addrList.count(); |
557 params << receipient; |
937 recepientCount += ccCount; |
558 } |
938 if(ccCount) |
559 else |
939 { |
560 { |
940 receipient = addrList.at(0)->address(); |
561 params << MsgBaseView::CLV;// target view |
941 } |
562 params << MsgBaseView::UNIEDITOR; // source view |
942 |
|
943 addrList = bccAddresses; |
|
944 int bccCount = addrList.count(); |
|
945 recepientCount += bccCount; |
|
946 if(bccCount) |
|
947 { |
|
948 receipient = addrList.at(0)->address(); |
|
949 } |
|
950 } |
|
951 |
|
952 QVariantList params; |
|
953 |
|
954 if(recepientCount == 1 ) |
|
955 { |
|
956 params << MsgBaseView::CV; // target view |
|
957 params << MsgBaseView::UNIEDITOR; // source view |
|
958 |
|
959 params << receipient; |
|
960 } |
|
961 else |
|
962 { |
|
963 params << MsgBaseView::CLV;// target view |
|
964 params << MsgBaseView::UNIEDITOR; // source view |
|
965 } |
563 } |
966 deactivateInputBlocker(); |
564 deactivateInputBlocker(); |
967 emit switchView(params); |
565 emit switchView(params); |
|
566 |
|
567 mCanSaveToDrafts = false; |
968 } |
568 } |
969 else |
569 else |
970 { |
570 { |
971 deactivateInputBlocker(); |
571 deactivateInputBlocker(); |
972 if(sendResult == KErrNotFound) |
572 if(sendResult == KErrNotFound) |
973 { |
573 { |
974 if (messageType == ConvergedMessage::Sms) |
574 if (messageType == ConvergedMessage::Sms) |
975 { |
575 { |
976 HbMessageBox::question(LOC_DIALOG_SMS_SETTINGS_INCOMPLETE, |
576 HbMessageBox::question(LOC_DIALOG_SMS_SETTINGS_INCOMPLETE, |
977 this,SLOT(onDialogSmsSettings(HbAction*)), |
577 this,SLOT(onDialogSmsSettings(HbAction*)), |
978 HbMessageBox::Ok | HbMessageBox::Cancel); |
578 HbMessageBox::Ok | HbMessageBox::Cancel); |
979 } |
579 } |
980 else |
580 else |
981 { |
581 { |
982 HbMessageBox::question(LOC_DIALOG_MMS_SETTINGS_INCOMPLETE, |
582 HbMessageBox::question(LOC_DIALOG_MMS_SETTINGS_INCOMPLETE, |
983 this,SLOT(onDialogMmsSettings(HbAction*)), |
583 this,SLOT(onDialogMmsSettings(HbAction*)), |
984 HbMessageBox::Ok | HbMessageBox::Cancel); |
584 HbMessageBox::Ok | HbMessageBox::Cancel); |
985 } |
585 } |
986 } |
586 } |
987 } |
587 } |
988 } |
588 } |
989 |
589 |
|
590 //--------------------------------------------------------------- |
|
591 // MsgUnifiedEditorView::packMessage |
|
592 // @see header file |
|
593 //--------------------------------------------------------------- |
990 int MsgUnifiedEditorView::packMessage(ConvergedMessage &msg, bool isSave) |
594 int MsgUnifiedEditorView::packMessage(ConvergedMessage &msg, bool isSave) |
991 { |
595 { |
992 // reset reply-path if originating SME constraint is broken |
596 // reset reply-path if originating SME constraint is broken |
993 if(mReplyPath && isReplyPathBroken()) |
597 if(mReplyPath && isReplyPathBroken()) |
994 { |
598 { |
1001 msg.setOriginatingSC(mOriginatingSC); |
605 msg.setOriginatingSC(mOriginatingSC); |
1002 } |
606 } |
1003 |
607 |
1004 ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType(); |
608 ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType(); |
1005 msg.setMessageType(messageType); |
609 msg.setMessageType(messageType); |
1006 // If isSave is true (save to draft usecase), then don't remove duplicates |
|
1007 // If isSave is false (send usecase), then remove duplicates |
|
1008 bool removeDuplicates = !isSave; |
|
1009 ConvergedMessageAddressList addresses = |
|
1010 mToField->addresses(removeDuplicates); |
|
1011 ConvergedMessageAddressList ccAddresses; |
|
1012 ConvergedMessageAddressList bccAddresses; |
|
1013 ConvergedMessageAttachmentList mediaList; |
|
1014 int errorCode = 0; |
|
1015 //Don't format the addresses for save to drfats case |
|
1016 if(!isSave) |
|
1017 { |
|
1018 formatAddresses(addresses); |
|
1019 } |
|
1020 |
|
1021 msg.addToRecipients(addresses); |
|
1022 msg.setBodyText(mBody->text()); |
|
1023 msg.setDirection(ConvergedMessage::Outgoing); |
610 msg.setDirection(ConvergedMessage::Outgoing); |
1024 QDateTime time = QDateTime::currentDateTime(); |
611 QDateTime time = QDateTime::currentDateTime(); |
1025 msg.setTimeStamp(time.toTime_t()); |
612 msg.setTimeStamp(time.toTime_t()); |
1026 |
613 |
1027 if(messageType == ConvergedMessage::Mms) |
614 |
1028 { |
615 //pack message data from mscrollarea. |
1029 if(mCcField) |
616 int errorCode = mScrollArea->packMessage(msg,isSave); |
1030 { |
617 |
1031 ccAddresses = mCcField->addresses(removeDuplicates); |
618 //pack message data from body editor. |
1032 } |
619 mBodyEditor->packMessage(msg); |
1033 |
620 |
1034 if(mBccField) |
621 return errorCode; |
1035 { |
622 } |
1036 bccAddresses = mBccField->addresses(removeDuplicates); |
623 |
1037 } |
624 //--------------------------------------------------------------- |
1038 |
625 // MsgUnifiedEditorView::saveContentToDrafts |
1039 if(removeDuplicates) |
626 // @see header file |
1040 { |
627 //--------------------------------------------------------------- |
1041 int matchDigitsCount = MsgUnifiedEditorAddress::contactMatchDigits(); |
|
1042 //comapre cc and to field,remove duplicate from cc |
|
1043 foreach(ConvergedMessageAddress *ccAddress,ccAddresses) |
|
1044 { |
|
1045 foreach(ConvergedMessageAddress *toAddress,addresses) |
|
1046 { |
|
1047 if(0 == ccAddress->address().right(matchDigitsCount).compare(toAddress->address().right(matchDigitsCount))) |
|
1048 { |
|
1049 ccAddresses.removeOne(ccAddress); |
|
1050 } |
|
1051 } |
|
1052 } |
|
1053 //comapre bcc and cc field,remove duplicate from bcc |
|
1054 foreach(ConvergedMessageAddress *bccAddress,bccAddresses) |
|
1055 { |
|
1056 foreach(ConvergedMessageAddress *ccAddress,ccAddresses) |
|
1057 { |
|
1058 if(0 == bccAddress->address().right(matchDigitsCount).compare(ccAddress->address().right(matchDigitsCount))) |
|
1059 { |
|
1060 bccAddresses.removeOne(bccAddress); |
|
1061 } |
|
1062 } |
|
1063 } |
|
1064 //comapre bcc and to field,remove duplicate from bcc |
|
1065 foreach(ConvergedMessageAddress *bccAddress,bccAddresses) |
|
1066 { |
|
1067 foreach(ConvergedMessageAddress *toAddress,addresses) |
|
1068 { |
|
1069 if(0 == bccAddress->address().right(matchDigitsCount).compare(toAddress->address().right(matchDigitsCount))) |
|
1070 { |
|
1071 bccAddresses.removeOne(bccAddress); |
|
1072 } |
|
1073 } |
|
1074 } |
|
1075 } |
|
1076 |
|
1077 if(ccAddresses.count()>0) |
|
1078 { |
|
1079 //Don't format the addresses for save to drfats case |
|
1080 if(!isSave) |
|
1081 { |
|
1082 formatAddresses(ccAddresses); |
|
1083 } |
|
1084 msg.addCcRecipients(ccAddresses); |
|
1085 } |
|
1086 if(bccAddresses.count()>0) |
|
1087 { |
|
1088 //Don't format the addresses for save to drfats case |
|
1089 if(!isSave) |
|
1090 { |
|
1091 formatAddresses(bccAddresses); |
|
1092 } |
|
1093 msg.addBccRecipients(bccAddresses); |
|
1094 } |
|
1095 if(mSubjectField) |
|
1096 { |
|
1097 msg.setSubject(mSubjectField->text()); |
|
1098 msg.setPriority(mSubjectField->priority()); |
|
1099 } |
|
1100 |
|
1101 QStringList mediafiles(mBody->mediaContent()); |
|
1102 if (!mediafiles.isEmpty()) |
|
1103 { |
|
1104 for (int i = 0; i < mediafiles.size(); ++i) |
|
1105 { |
|
1106 if(QFile::exists(mediafiles.at(i))) |
|
1107 { |
|
1108 ConvergedMessageAttachment* attachment = |
|
1109 new ConvergedMessageAttachment( |
|
1110 mediafiles.at(i), |
|
1111 ConvergedMessageAttachment::EInline); |
|
1112 mediaList << attachment; |
|
1113 } |
|
1114 else |
|
1115 { mBody->removeMediaContent(mediafiles.at(i)); |
|
1116 errorCode = KErrNotFound; |
|
1117 } |
|
1118 } |
|
1119 |
|
1120 } |
|
1121 if(mediaList.count() > 0) |
|
1122 { |
|
1123 msg.addAttachments(mediaList); |
|
1124 } |
|
1125 } |
|
1126 |
|
1127 // sms/mms attachment list |
|
1128 ConvergedMessageAttachmentList attachmentList; |
|
1129 if(mAttachmentContainer) |
|
1130 { |
|
1131 MsgUnifiedEditorAttachmentList editorAttachmentList = |
|
1132 mAttachmentContainer->attachmentList(); |
|
1133 for (int i = 0; i < editorAttachmentList.count(); ++i) |
|
1134 { |
|
1135 if(QFile::exists(editorAttachmentList.at(i)->path())) |
|
1136 { |
|
1137 ConvergedMessageAttachment* attachment = |
|
1138 new ConvergedMessageAttachment( |
|
1139 editorAttachmentList.at(i)->path(), |
|
1140 ConvergedMessageAttachment::EAttachment); |
|
1141 attachmentList << attachment; |
|
1142 } |
|
1143 else |
|
1144 { |
|
1145 mAttachmentContainer->deleteAttachment(editorAttachmentList.at(i)); |
|
1146 errorCode = KErrNotFound; |
|
1147 } |
|
1148 } |
|
1149 } |
|
1150 if(attachmentList.count() > 0) |
|
1151 { |
|
1152 msg.addAttachments(attachmentList); |
|
1153 } |
|
1154 return errorCode; |
|
1155 } |
|
1156 |
|
1157 int MsgUnifiedEditorView::saveContentToDrafts() |
628 int MsgUnifiedEditorView::saveContentToDrafts() |
1158 { |
629 { |
1159 if(!mCanSaveToDrafts) |
630 if(!mCanSaveToDrafts) |
1160 { |
631 { |
1161 return mOpenedMessageId.getId(); // return currently opened message id |
632 return mOpenedMessageId.getId(); // return currently opened message id |
1162 } |
633 } |
1163 |
634 |
1164 activateInputBlocker(); |
635 activateInputBlocker(); |
1165 ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType(); |
636 ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType(); |
1166 |
637 |
1167 ConvergedMessageAddressList addresses = mToField->addresses(); |
|
1168 |
|
1169 UniEditorPluginInterface* pluginInterface = NULL; |
638 UniEditorPluginInterface* pluginInterface = NULL; |
1170 |
639 |
1171 if( mOpenedMessageId.getId() != -1) |
640 if( mOpenedMessageId.getId() != -1) |
1172 { |
641 { |
1173 if(!mPluginLoader) |
642 if(!mPluginLoader) |
1174 { |
643 { |
1175 mPluginLoader = new UniEditorPluginLoader(this); |
644 mPluginLoader = new UniEditorPluginLoader(this); |
1176 } |
645 } |
1177 |
646 |
1178 pluginInterface = |
647 pluginInterface = mPluginLoader->getUniEditorPlugin(messageType); |
1179 mPluginLoader->getUniEditorPlugin(messageType); |
648 } |
1180 } |
649 |
1181 |
650 // if empty msg, do not save |
1182 if(messageType == ConvergedMessage::Sms && |
651 if( MsgUnifiedEditorMonitor::messageSize() <= 0 && |
1183 addresses.isEmpty() && |
652 MsgUnifiedEditorMonitor::msgAddressCount() <= 0 ) |
1184 MsgUnifiedEditorMonitor::bodySize() <= 0 && |
|
1185 MsgUnifiedEditorMonitor::containerSize() <= 0) |
|
1186 { |
653 { |
1187 if(mOpenedMessageId.getId() != -1) |
654 if(mOpenedMessageId.getId() != -1) |
1188 { |
655 { |
1189 pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId()); |
656 pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId()); |
1190 } |
657 } |
1191 |
658 |
1192 // if empty msg, do not save |
|
1193 deactivateInputBlocker(); |
659 deactivateInputBlocker(); |
1194 return INVALID_MSGID; |
660 return INVALID_MSGID; |
1195 } |
661 } |
1196 |
662 |
1197 ConvergedMessageAddressList ccAddresses; |
|
1198 ConvergedMessageAddressList bccAddresses; |
|
1199 if(mCcField) |
|
1200 { |
|
1201 ccAddresses = mCcField->addresses(); |
|
1202 } |
|
1203 if(mBccField) |
|
1204 { |
|
1205 bccAddresses = mBccField->addresses(); |
|
1206 } |
|
1207 int subectSize =0; |
|
1208 if(mSubjectField) |
|
1209 { |
|
1210 subectSize = mSubjectField->text().size(); |
|
1211 } |
|
1212 |
|
1213 if( messageType == ConvergedMessage::Mms && |
|
1214 addresses.isEmpty() && |
|
1215 ccAddresses.isEmpty() && |
|
1216 bccAddresses.isEmpty() && |
|
1217 subectSize <= 0 && |
|
1218 MsgUnifiedEditorMonitor::bodySize() <= 0 && |
|
1219 MsgUnifiedEditorMonitor::containerSize() <= 0) |
|
1220 { |
|
1221 if(mOpenedMessageId.getId() != -1) |
|
1222 { |
|
1223 pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId()); |
|
1224 } |
|
1225 // if empty msg, do not send |
|
1226 deactivateInputBlocker(); |
|
1227 return INVALID_MSGID; |
|
1228 } |
|
1229 ConvergedMessage msg; |
663 ConvergedMessage msg; |
1230 int result = packMessage(msg, true); |
664 int result = packMessage(msg, true); |
1231 if(result == KErrNotFound) |
665 if(result == KErrNotFound) |
1232 { |
666 { |
1233 HbNotificationDialog::launchDialog(LOC_NOTE_FILES_MISSED_DRAFTS); |
667 HbNotificationDialog::launchDialog(LOC_NOTE_FILES_MISSED_DRAFTS); |
1234 if(messageType == ConvergedMessage::Sms && |
668 } |
1235 addresses.isEmpty() && |
669 |
1236 MsgUnifiedEditorMonitor::bodySize() <= 0 && |
|
1237 MsgUnifiedEditorMonitor::containerSize() <= 0) |
|
1238 { |
|
1239 if(mOpenedMessageId.getId() != -1) |
|
1240 { |
|
1241 pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId()); |
|
1242 } |
|
1243 |
|
1244 // if empty msg, do not save |
|
1245 deactivateInputBlocker(); |
|
1246 return INVALID_MSGID; |
|
1247 } |
|
1248 } |
|
1249 // save to drafts |
670 // save to drafts |
1250 MsgSendUtil *sendUtil = new MsgSendUtil(this); |
671 MsgSendUtil *sendUtil = new MsgSendUtil(this); |
1251 int msgId = sendUtil->saveToDrafts(msg); |
672 int msgId = sendUtil->saveToDrafts(msg); |
1252 delete sendUtil; |
673 delete sendUtil; |
1253 |
674 |
1635 { |
1016 { |
1636 mainWindow()->setInteractive(true); |
1017 mainWindow()->setInteractive(true); |
1637 } |
1018 } |
1638 |
1019 |
1639 //--------------------------------------------------------------- |
1020 //--------------------------------------------------------------- |
1640 // MsgUnifiedEditorView::setAttachOptionEnabled |
1021 // MsgUnifiedEditorView::enableMenuAction |
1641 // @see header file |
1022 // @see header file |
1642 //-------------------------------------------------------------- |
1023 //-------------------------------------------------------------- |
1643 void MsgUnifiedEditorView::setAttachOptionEnabled( |
1024 void MsgUnifiedEditorView::enableMenuAction(int action, bool enable) |
1644 MsgUnifiedEditorView::TBE_AttachOption opt, bool enable) |
1025 { |
1645 { |
1026 switch(action) |
1646 HbListWidgetItem* wgtItem = mTBExtnContentWidget->item(opt); |
1027 { |
1647 wgtItem->setEnabled(enable); |
1028 case SOUND: |
|
1029 { |
|
1030 if(mSoundAction) |
|
1031 { |
|
1032 mSoundAction->setEnabled(enable); |
|
1033 } |
|
1034 break; |
|
1035 } |
|
1036 case PHOTO: |
|
1037 { |
|
1038 if(mPhotoAction) |
|
1039 { |
|
1040 mPhotoAction->setEnabled(enable); |
|
1041 } |
|
1042 break; |
|
1043 } |
|
1044 case SUBJECT: //subject action has to be removed |
|
1045 { |
|
1046 // remove mainmenu's "Add Subject" action |
|
1047 if(mSubjectAction) |
|
1048 { |
|
1049 this->menu()->removeAction(mSubjectAction); |
|
1050 mSubjectAction->setParent(NULL); |
|
1051 delete mSubjectAction; |
|
1052 mSubjectAction = NULL; |
|
1053 } |
|
1054 break; |
|
1055 } |
|
1056 case CCBCC: //CcBcc action has to be removed |
|
1057 { |
|
1058 // remove mainmenu's "Add Cc/Bcc" & "Add Subject" actions |
|
1059 if(mCcBccAction) |
|
1060 { |
|
1061 this->menu()->removeAction(mCcBccAction); |
|
1062 mCcBccAction->setParent(NULL); |
|
1063 delete mCcBccAction; |
|
1064 mCcBccAction = NULL; |
|
1065 } |
|
1066 break; |
|
1067 } |
|
1068 |
|
1069 default: |
|
1070 break; |
|
1071 } |
1648 } |
1072 } |
1649 |
1073 |
1650 //--------------------------------------------------------------- |
1074 //--------------------------------------------------------------- |
1651 // MsgUnifiedEditorView::vkbOpened |
1075 // MsgUnifiedEditorView::vkbOpened |
1652 // @see header file |
1076 // @see header file |
1653 //--------------------------------------------------------------- |
1077 //--------------------------------------------------------------- |
1654 void MsgUnifiedEditorView::vkbOpened() |
1078 void MsgUnifiedEditorView::vkbOpened() |
1655 { |
1079 { |
1656 hideChrome(true); |
1080 hideChrome(true); |
1657 |
1081 |
|
1082 //get focussed object. |
|
1083 HbInputMethod* im = HbInputMethod::activeInputMethod(); |
|
1084 HbInputFocusObject* focusObj = im->focusObject(); |
|
1085 if(focusObj) |
|
1086 { |
|
1087 QObject* obj = focusObj->object(); |
|
1088 mFocusedWidget = qobject_cast<QGraphicsWidget*>(obj); |
|
1089 HbAbstractEdit* editor = qobject_cast<HbAbstractEdit*>(obj); |
|
1090 if(editor) |
|
1091 { |
|
1092 connect(editor,SIGNAL(contentsChanged()),this,SLOT(ensureVisibility())); |
|
1093 } |
|
1094 } |
|
1095 |
|
1096 QRectF appRect = mVkbHost->applicationArea(); |
|
1097 |
|
1098 if(this->mainWindow()->orientation() == Qt::Vertical) |
|
1099 { |
|
1100 this->setMaximumHeight(appRect.height()); |
|
1101 mScrollArea->resize(-1,-1); |
|
1102 } |
|
1103 else |
|
1104 { |
|
1105 if(mFocusedWidget) |
|
1106 { |
|
1107 qreal vItemSpacing = 0.0; |
|
1108 style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing); |
|
1109 |
|
1110 mMinHeight = mFocusedWidget->minimumHeight(); |
|
1111 mMaxHeight = mFocusedWidget->maximumHeight(); |
|
1112 qreal newHeight = appRect.height()-vItemSpacing-1; |
|
1113 mFocusedWidget->setMinimumHeight(newHeight); |
|
1114 mFocusedWidget->setMaximumHeight(newHeight); |
|
1115 mFocusedWidget->resize(mFocusedWidget->rect().width(),newHeight); |
|
1116 |
|
1117 } |
|
1118 } |
|
1119 |
|
1120 //do layouting after some delay. |
|
1121 QTimer::singleShot(50,this,SLOT(doLayout())); |
|
1122 |
1658 disconnect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened())); |
1123 disconnect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened())); |
1659 } |
1124 connect(this->mainWindow(),SIGNAL(aboutToChangeOrientation()),this,SLOT(resetLayout())); |
1660 |
1125 } |
|
1126 |
1661 //--------------------------------------------------------------- |
1127 //--------------------------------------------------------------- |
1662 // MsgUnifiedEditorView::vkbClosed |
1128 // MsgUnifiedEditorView::vkbClosed |
1663 // @see header file |
1129 // @see header file |
1664 //--------------------------------------------------------------- |
1130 //--------------------------------------------------------------- |
1665 void MsgUnifiedEditorView::vkbClosed() |
1131 void MsgUnifiedEditorView::vkbClosed() |
1666 { |
1132 { |
1667 hideChrome(false); |
1133 hideChrome(false); |
1668 |
1134 |
|
1135 resetLayout(); |
|
1136 |
1669 connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened())); |
1137 connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened())); |
1670 } |
1138 |
1671 |
1139 disconnect(this->mainWindow(),SIGNAL(aboutToChangeOrientation()),this,SLOT(resetLayout())); |
1672 //--------------------------------------------------------------- |
1140 } |
1673 // MsgUnifiedEditorView::vkbAboutToOpen |
1141 |
1674 // @see header file |
1142 //--------------------------------------------------------------- |
1675 //--------------------------------------------------------------- |
1143 // MsgUnifiedEditorView::doLayout |
1676 void MsgUnifiedEditorView::vkbAboutToOpen() |
1144 // @see header file |
1677 { |
1145 //--------------------------------------------------------------- |
1678 //This is done to avoid user action on attachment |
1146 void MsgUnifiedEditorView::doLayout() |
1679 //toolbar button when vkb is opening |
1147 { |
1680 mAttachAction->setDisabled(true); |
1148 if(mFocusedWidget && mVkbHost->keypadStatus() == HbVkbHost::HbVkbStatusOpened) |
1681 disconnect(mVkbHost,SIGNAL(aboutToOpen()), |
1149 { |
1682 this,SLOT(vkbAboutToOpen())); |
1150 if(this->mainWindow()->orientation() == Qt::Vertical) |
1683 } |
1151 { |
1684 |
1152 ensureVisibility(); |
1685 //--------------------------------------------------------------- |
1153 } |
1686 // MsgUnifiedEditorView::vkbAboutToClose |
1154 else |
1687 // @see header file |
1155 { |
1688 //--------------------------------------------------------------- |
1156 qreal vItemSpacing = 0.0; |
1689 void MsgUnifiedEditorView::vkbAboutToClose() |
1157 style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing); |
1690 { |
1158 |
1691 mAttachAction->setDisabled(false); |
1159 if(mScrollArea->isAncestorOf(mFocusedWidget)) |
1692 connect(mVkbHost,SIGNAL(aboutToOpen()), |
1160 { |
1693 this,SLOT(vkbAboutToOpen())); |
1161 QPointF p = mScrollArea->mapFromScene(mFocusedWidget->scenePos()); |
|
1162 mScrollArea->scrollContentsTo(p,0); |
|
1163 mScrollArea->enableScrolling(false); |
|
1164 mScrollArea->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff); |
|
1165 } |
|
1166 |
|
1167 QPointF pp = mapFromScene(mFocusedWidget->scenePos()); |
|
1168 qreal delta = pp.y() - vItemSpacing; |
|
1169 this->setTransform(QTransform::fromTranslate(0, -delta), true); |
|
1170 } |
|
1171 } |
|
1172 } |
|
1173 |
|
1174 //--------------------------------------------------------------- |
|
1175 // MsgUnifiedEditorView::resetLayout |
|
1176 // @see header file |
|
1177 //--------------------------------------------------------------- |
|
1178 void MsgUnifiedEditorView::resetLayout() |
|
1179 { |
|
1180 //disconnect signal from previously focused object. |
|
1181 if(mFocusedWidget) |
|
1182 { |
|
1183 HbAbstractEdit* editor = qobject_cast<HbAbstractEdit*>(mFocusedWidget); |
|
1184 disconnect(editor,SIGNAL(contentsChanged()),this,SLOT(ensureVisibility())); |
|
1185 } |
|
1186 |
|
1187 if(this->mainWindow()->orientation() == Qt::Vertical) |
|
1188 { |
|
1189 this->setMaximumHeight(-1); |
|
1190 mScrollArea->scrollContentsTo(QPointF(0,0),0); |
|
1191 mScrollArea->resize(-1,-1); |
|
1192 } |
|
1193 else |
|
1194 { |
|
1195 this->resetTransform(); |
|
1196 |
|
1197 if(mFocusedWidget) |
|
1198 { |
|
1199 if(mMinHeight >0) |
|
1200 { |
|
1201 mFocusedWidget->setMinimumHeight(mMinHeight); |
|
1202 mMinHeight = 0.0; |
|
1203 } |
|
1204 if(mMaxHeight >0) |
|
1205 { |
|
1206 mFocusedWidget->setMaximumHeight(mMaxHeight); |
|
1207 mMaxHeight = 0.0; |
|
1208 } |
|
1209 |
|
1210 if(mScrollArea->isAncestorOf(mFocusedWidget)) |
|
1211 { |
|
1212 mScrollArea->enableScrolling(true); |
|
1213 mScrollArea->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAutoHide); |
|
1214 mScrollArea->scrollContentsTo(QPointF(0,0),0); |
|
1215 } |
|
1216 |
|
1217 mFocusedWidget = NULL; |
|
1218 } |
|
1219 |
|
1220 } |
|
1221 } |
|
1222 |
|
1223 //--------------------------------------------------------------- |
|
1224 // MsgUnifiedEditorView::ensureVisibility |
|
1225 // @see header file |
|
1226 //--------------------------------------------------------------- |
|
1227 void MsgUnifiedEditorView::ensureVisibility() |
|
1228 { |
|
1229 if(mFocusedWidget && mVkbHost->keypadStatus() == HbVkbHost::HbVkbStatusOpened) |
|
1230 { |
|
1231 if(this->mainWindow()->orientation() == Qt::Vertical) |
|
1232 { |
|
1233 if ( mScrollArea->isAncestorOf(mFocusedWidget)) |
|
1234 { |
|
1235 QRectF scrollRect = mScrollArea->sceneBoundingRect(); |
|
1236 QRectF editorRect = mFocusedWidget->sceneBoundingRect(); |
|
1237 |
|
1238 if (!scrollRect.contains(editorRect) || |
|
1239 scrollRect.intersects(editorRect)) |
|
1240 { |
|
1241 |
|
1242 if (editorRect.height() < scrollRect.height()) { |
|
1243 // Whole editor rect fits into scroll area. Move it there. |
|
1244 if (editorRect.bottom() > scrollRect.bottom()) { |
|
1245 // Scroll upwards. |
|
1246 mScrollArea->ensureVisible(mScrollArea->contentWidget()->mapFromScene(editorRect.bottomLeft())); |
|
1247 } else { |
|
1248 // Scroll downwards. |
|
1249 mScrollArea->ensureVisible(mScrollArea->contentWidget()->mapFromScene(editorRect.topLeft())); |
|
1250 } |
|
1251 } |
|
1252 } |
|
1253 } |
|
1254 } |
|
1255 } |
|
1256 } |
|
1257 |
|
1258 //--------------------------------------------------------------- |
|
1259 // MsgUnifiedEditorView::focusChanged |
|
1260 // @see header file |
|
1261 //--------------------------------------------------------------- |
|
1262 void MsgUnifiedEditorView::focusChanged() |
|
1263 { |
|
1264 //disconnect signal from previously focused object. |
|
1265 if(mFocusedWidget) |
|
1266 { |
|
1267 HbAbstractEdit* editor = qobject_cast<HbAbstractEdit*>(mFocusedWidget); |
|
1268 disconnect(editor,SIGNAL(contentsChanged()),this,SLOT(ensureVisibility())); |
|
1269 } |
|
1270 |
|
1271 //connect signal for newly focused object. |
|
1272 HbInputMethod* im = HbInputMethod::activeInputMethod(); |
|
1273 HbInputFocusObject* focusObj = im->focusObject(); |
|
1274 if(focusObj) |
|
1275 { |
|
1276 QObject* obj = focusObj->object(); |
|
1277 mFocusedWidget = qobject_cast<QGraphicsWidget*>(obj); |
|
1278 HbAbstractEdit* editor = qobject_cast<HbAbstractEdit*>(obj); |
|
1279 if(editor) |
|
1280 { |
|
1281 connect(editor,SIGNAL(contentsChanged()),this,SLOT(ensureVisibility())); |
|
1282 } |
|
1283 } |
1694 } |
1284 } |
1695 |
1285 |
1696 //--------------------------------------------------------------- |
1286 //--------------------------------------------------------------- |
1697 // MsgUnifiedEditorView::onAudioSelected |
1287 // MsgUnifiedEditorView::onAudioSelected |
1698 // @see header file |
1288 // @see header file |
1699 //--------------------------------------------------------------- |
1289 //--------------------------------------------------------------- |
1700 void |
1290 void MsgUnifiedEditorView::onAudioSelected(QString& filePath) |
1701 MsgUnifiedEditorView::onAudioSelected(QString& filePath) |
|
1702 { |
1291 { |
1703 if (!filePath.isEmpty()) |
1292 if (!filePath.isEmpty()) |
1704 { |
1293 { |
1705 mBody->setAudio(filePath); |
1294 mScrollArea->setAudio(filePath); |
1706 } |
1295 } |
1707 } |
1296 } |
1708 |
1297 |
1709 //--------------------------------------------------------------- |
1298 //--------------------------------------------------------------- |
1710 // MsgUnifiedEditorView::hideChrome |
1299 // MsgUnifiedEditorView::hideChrome |
1711 // |
1300 // |