messagingapp/msgui/conversationview/src/msgconversationview.cpp
changeset 51 3507212d340e
parent 46 b1f0785c289d
child 56 f42d9a78f435
equal deleted inserted replaced
49:2a272ef608c4 51:3507212d340e
   105     mEditorWidget(NULL),
   105     mEditorWidget(NULL),
   106     mContactCardWidget(contactCardWidget),
   106     mContactCardWidget(contactCardWidget),
   107     mSendUtil(NULL),
   107     mSendUtil(NULL),
   108     mVkbHost(NULL),
   108     mVkbHost(NULL),
   109     mVisibleIndex(),
   109     mVisibleIndex(),
   110     mVkbopened(false),
       
   111     mModelPopulated(false),
   110     mModelPopulated(false),
   112     mViewReady(false)
   111     mViewReady(false)
   113 {
   112 {
   114     //create send utils
   113     //create send utils
   115     mSendUtil = new MsgSendUtil(this);
   114     mSendUtil = new MsgSendUtil(this);
   291 {
   290 {
   292     addOpenItemToContextMenu(item , contextMenu,sendingState);
   291     addOpenItemToContextMenu(item , contextMenu,sendingState);
   293     addResendItemToContextMenu(item, contextMenu, sendingState);
   292     addResendItemToContextMenu(item, contextMenu, sendingState);
   294     addForwardItemToContextMenu(item, contextMenu, sendingState);
   293     addForwardItemToContextMenu(item, contextMenu, sendingState);
   295     addDownloadItemToContextMenu(item, contextMenu);
   294     addDownloadItemToContextMenu(item, contextMenu);
       
   295     addSaveItemToContextMenu(item , contextMenu,sendingState);
   296     addDeleteItemToContextMenu(item, contextMenu, sendingState);
   296     addDeleteItemToContextMenu(item, contextMenu, sendingState);
   297     addSaveItemToContextMenu(item , contextMenu,sendingState);
       
   298 }
   297 }
   299 
   298 
   300 
   299 
   301 //---------------------------------------------------------------
   300 //---------------------------------------------------------------
   302 // MsgEditorPrivate::addSaveItemToContextMenu
   301 // MsgEditorPrivate::addSaveItemToContextMenu
   621 // MsgConversationView::contactsFetched
   620 // MsgConversationView::contactsFetched
   622 // @see header file
   621 // @see header file
   623 //---------------------------------------------------------------
   622 //---------------------------------------------------------------
   624 void MsgConversationView::contactsFetched(const QVariant& value)
   623 void MsgConversationView::contactsFetched(const QVariant& value)
   625 {
   624 {
   626     CntServicesContactList contactList = 
   625     //switch to editor.
   627             qVariantValue<CntServicesContactList>(value);
   626     QVariantList params;
   628 	int count = contactList.count();
   627     params << MsgBaseView::ADD_RECIPIENTS;
   629 	if(count > 0)
   628     params << value;
   630     {
   629     launchUniEditor(params);
   631         QVariantList params;
       
   632         params << MsgBaseView::ADD_RECIPIENTS;
       
   633         params << value;
       
   634         launchUniEditor(params);
       
   635     }
       
   636 }
   630 }
   637 
   631 
   638 //---------------------------------------------------------------
   632 //---------------------------------------------------------------
   639 // MsgConversationView::imagesFetched()
   633 // MsgConversationView::imagesFetched()
   640 // @see header file
   634 // @see header file
   890 //@see header
   884 //@see header
   891 //---------------------------------------------------------------
   885 //---------------------------------------------------------------
   892 void MsgConversationView::openItem(const QModelIndex & index)
   886 void MsgConversationView::openItem(const QModelIndex & index)
   893 {
   887 {
   894     // Return if invalid index.
   888     // Return if invalid index.
   895     if (!index.isValid() || mVkbopened)
   889     if (!index.isValid())
   896     {
   890     {
   897         return;
   891         return;
   898     }
   892     }
   899     
   893     
   900     int messageType = index.data(MessageType).toInt();
   894     int messageType = index.data(MessageType).toInt();
  1008     {
  1002     {
  1009         msgIdList.clear();
  1003         msgIdList.clear();
  1010         msgIdList << messageId;
  1004         msgIdList << messageId;
  1011         ConversationsEngine::instance()->markMessagesRead(msgIdList);
  1005         ConversationsEngine::instance()->markMessagesRead(msgIdList);
  1012     }
  1006     }
  1013     
  1007 
  1014     qint32 messageProperty = index.data(MessageProperty).toInt();
       
  1015 
       
  1016     bool canForwardMessage  = true;
       
  1017     if (messageType == ConvergedMessage::Mms){
       
  1018         canForwardMessage = (messageProperty & EPreviewForward)? true:false;
       
  1019     } 
       
  1020     
       
  1021     //switch view
  1008     //switch view
  1022     QVariantList param;
  1009     QVariantList param;
  1023     param << MsgBaseView::UNIVIEWER;  // target view
  1010     param << MsgBaseView::UNIVIEWER;  // target view
  1024     param << MsgBaseView::CV; // source view
  1011     param << MsgBaseView::CV; // source view
  1025 
  1012 
  1026     param << contactId;
  1013     param << contactId;
  1027     param << messageId;
  1014     param << messageId;
  1028     param << mMessageModel->rowCount();
  1015     param << mMessageModel->rowCount();
  1029     if (canForwardMessage == true)
       
  1030     {
       
  1031       param << 1;
       
  1032     }
       
  1033     else
       
  1034    	{
       
  1035    		param << 0;
       
  1036    	}
       
  1037     emit switchView(param);
  1016     emit switchView(param);
  1038 }
  1017 }
  1039 
  1018 
  1040 //---------------------------------------------------------------
  1019 //---------------------------------------------------------------
  1041 // MsgConversationView::launchUniEditor
  1020 // MsgConversationView::launchUniEditor
  1193 // MsgConversationView::vkbOpened
  1172 // MsgConversationView::vkbOpened
  1194 // @see header file
  1173 // @see header file
  1195 //---------------------------------------------------------------
  1174 //---------------------------------------------------------------
  1196 void MsgConversationView::vkbOpened()
  1175 void MsgConversationView::vkbOpened()
  1197 {
  1176 {
  1198     mVkbopened = true;
       
  1199     
       
  1200     emit vkbOpened(true);
  1177     emit vkbOpened(true);
       
  1178     
       
  1179     scrollToBottom();
  1201     
  1180     
  1202     QRectF appRect = mVkbHost->applicationArea();    
  1181     QRectF appRect = mVkbHost->applicationArea();    
  1203     qreal spacing = 0.0;
  1182     qreal spacing = 0.0;
  1204     qreal cardHeight = 0.0;
  1183     qreal cardHeight = 0.0;
  1205     if(mContactCardWidget->isVisible())
  1184     if(mContactCardWidget->isVisible())
  1207         cardHeight = mContactCardWidget->rect().height();
  1186         cardHeight = mContactCardWidget->rect().height();
  1208         spacing = HbDeviceProfile::profile(this).unitValue();
  1187         spacing = HbDeviceProfile::profile(this).unitValue();
  1209         }
  1188         }
  1210     
  1189     
  1211     this->setMaximumHeight(appRect.height()- cardHeight - spacing);
  1190     this->setMaximumHeight(appRect.height()- cardHeight - spacing);
       
  1191     mConversationList->adjustSize();
  1212     
  1192     
  1213     disconnect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
  1193     disconnect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
       
  1194 
       
  1195 }
       
  1196 	  
       
  1197 //---------------------------------------------------------------
       
  1198 // MsgConversationView::vkbClosed
       
  1199 // @see header file
       
  1200 //---------------------------------------------------------------
       
  1201 void MsgConversationView::vkbClosed()
       
  1202 {
       
  1203     emit vkbOpened(false);
  1214     
  1204     
  1215     scrollToBottom();
  1205     scrollToBottom();
  1216 }
       
  1217 	  
       
  1218 //---------------------------------------------------------------
       
  1219 // MsgConversationView::vkbClosed
       
  1220 // @see header file
       
  1221 //---------------------------------------------------------------
       
  1222 void MsgConversationView::vkbClosed()
       
  1223 {
       
  1224     mVkbopened = false;
       
  1225     
       
  1226     emit vkbOpened(false);
       
  1227     
  1206     
  1228     this->setMaximumHeight(-1);
  1207     this->setMaximumHeight(-1);
       
  1208     mConversationList->adjustSize();    
       
  1209     
  1229     connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
  1210     connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
  1230     
       
  1231     scrollToBottom();
       
  1232 }
  1211 }
  1233 
  1212 
  1234 //---------------------------------------------------------------
  1213 //---------------------------------------------------------------
  1235 // MsgConversationView::serviceRequestError
  1214 // MsgConversationView::serviceRequestError
  1236 // @see header file
  1215 // @see header file
  1487 //---------------------------------------------------------------
  1466 //---------------------------------------------------------------
  1488 bool MsgConversationView::isSharedMessage(qint32 messageId)
  1467 bool MsgConversationView::isSharedMessage(qint32 messageId)
  1489 {
  1468 {
  1490     bool shared = false;
  1469     bool shared = false;
  1491 
  1470 
  1492     UniEditorPluginLoader* pluginLoader = new UniEditorPluginLoader();
  1471     UniDataModelLoader* pluginLoader = new UniDataModelLoader();
  1493     
  1472     
  1494     UniEditorPluginInterface* pluginInterface =
  1473     UniDataModelPluginInterface* pluginInterface =
  1495         pluginLoader->getUniEditorPlugin(ConvergedMessage::Mms);
  1474         pluginLoader->getDataModelPlugin(ConvergedMessage::Mms);
  1496 
  1475     
  1497     ConvergedMessage* msg = pluginInterface->convertFrom(messageId);    
  1476     CMsvSession* session = pluginInterface->session();
  1498     if(msg)
  1477 
  1499     {
  1478     TMsvEntry entry; 
  1500         int count = 0;
  1479     TMsvId service;
  1501         count += msg->toAddressList().count();
  1480     session->GetEntry(messageId, service, entry);
  1502         count += msg->ccAddressList().count();
  1481     
  1503         count += msg->bccAddressList().count();
  1482     if(entry.MultipleRecipients())
  1504 
  1483     {
  1505         if(count > 1)
  1484         shared = true;
  1506         {
  1485     }
  1507             shared = true;
       
  1508         }
       
  1509         
       
  1510         delete msg;
       
  1511     }
       
  1512 
       
  1513     delete pluginLoader;    
  1486     delete pluginLoader;    
  1514 
  1487 
  1515     return shared;
  1488     return shared;
  1516 }
  1489 }
  1517 
  1490