From: Denis Dolzhenko Date: Mon, 25 Jul 2016 10:56:53 +0000 (+0300) Subject: Fixed: Edit a single draft-message when body is not empty X-Git-Tag: submit/tizen/20160810.144952^2~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F10%2F81310%2F1;p=profile%2Fmobile%2Fapps%2Fnative%2Fmessage.git Fixed: Edit a single draft-message when body is not empty Change-Id: Id4348e471ce420b1af8fa3b4a6fdfc15d7d6668c Signed-off-by: Denis Dolzhenko --- diff --git a/src/Conversation/ConvList/Controller/inc/ConvList.h b/src/Conversation/ConvList/Controller/inc/ConvList.h index abd2cac..4a5d28e 100644 --- a/src/Conversation/ConvList/Controller/inc/ConvList.h +++ b/src/Conversation/ConvList/Controller/inc/ConvList.h @@ -101,6 +101,13 @@ namespace Msg void deleteSelectedItems(); /** + * @brief Delete items by MsgId list. + * @param[in] MsgId list. + * @return true if one or more items were removed. + */ + bool deleteItems(const MsgIdList &idList); + + /** * @brief Get message count * @return message count */ @@ -167,7 +174,7 @@ namespace Msg ListView *m_pList; ConvListItemMap m_ConvListItemMap; DateLineItemSet m_DateLineItemSet; - IConvListListener *m_pListner; + IConvListListener *m_pListener; App &m_App; WorkingDirRef m_WorkingDir; FileViewer m_FileViewer; diff --git a/src/Conversation/ConvList/Controller/src/ConvList.cpp b/src/Conversation/ConvList/Controller/src/ConvList.cpp index da9dd5c..d383528 100644 --- a/src/Conversation/ConvList/Controller/src/ConvList.cpp +++ b/src/Conversation/ConvList/Controller/src/ConvList.cpp @@ -37,7 +37,7 @@ ConvList::ConvList(Evas_Object *parent, App &app, WorkingDirRef workingDir) , m_pList(nullptr) , m_ConvListItemMap() , m_DateLineItemSet() - , m_pListner(nullptr) + , m_pListener(nullptr) , m_App(app) , m_WorkingDir(workingDir) , m_FileViewer() @@ -56,7 +56,7 @@ ConvList::~ConvList() void ConvList::setListener(IConvListListener *l) { - m_pListner = l; + m_pListener = l; } void ConvList::setMode(ConvList::Mode mode) @@ -204,6 +204,25 @@ void ConvList::deleteItem(ConvListItem *item) m_pList->deleteItem(*item); } +bool ConvList::deleteItems(const MsgIdList &idList) +{ + bool res = false; + for(const MsgId &id: idList) + { + ConvListItem *deleted = getItem(id); + if(deleted) + { + res = true; + deleteItem(deleted); + } + } + + if(m_pListener && m_pList->isEmpty()) + m_pListener->onAllItemsDeleted(*this); + + return res; +} + void ConvList::demoteItem(ConvListItem *item) { dateLineDelIfNec(item); @@ -297,8 +316,8 @@ void ConvList::selectListItems(bool state) item->setCheckedState(state, false); } m_pList->updateRealizedItems(); - if(m_pListner) - m_pListner->onConvListItemChecked(); + if(m_pListener) + m_pListener->onConvListItemChecked(); } void ConvList::onListItemLongPressed(ListItem &listItem) @@ -317,8 +336,8 @@ void ConvList::onListItemChecked(ListItem &listItem) bool allSelected = isAllListItemSelected(); m_pSelectAll->setCheckState(allSelected); - if(m_pListner) - m_pListner->onConvListItemChecked(); + if(m_pListener) + m_pListener->onConvListItemChecked(); } void ConvList::onMsgStorageUpdate(const MsgIdList &msgIdList) @@ -359,33 +378,25 @@ void ConvList::onMsgStorageInsert(const MsgIdList &msgIdList) void ConvList::onMsgStorageDelete(const MsgIdList &msgIdList) { - for(auto &itemId: msgIdList) - { - ConvListItem *deleted = getItem(itemId); - if(deleted) - deleteItem(deleted); - } - - if(m_pListner && m_pList->isEmpty()) - m_pListner->onAllItemsDeleted(*this); + deleteItems(msgIdList); } void ConvList::onForwardMsg(ConvListItem &item) { - if(m_pListner) - m_pListner->onForwardMsg(item.getMsgId()); + if(m_pListener) + m_pListener->onForwardMsg(item.getMsgId()); } void ConvList::onSlideShow(ConvListItem &item) { - if(m_pListner) - m_pListner->onSlideShow(item.getMsgId()); + if(m_pListener) + m_pListener->onSlideShow(item.getMsgId()); } void ConvList::onEditDraftMsg(ConvListItem &item) { - if(m_pListner) - m_pListner->onEditDraftMsg(item.getMsgId()); + if(m_pListener) + m_pListener->onEditDraftMsg(item.getMsgId()); } void ConvList::onContactChanged() diff --git a/src/Conversation/Main/Controller/inc/Conversation.h b/src/Conversation/Main/Controller/inc/Conversation.h index d9f55bc..e8683b7 100644 --- a/src/Conversation/Main/Controller/inc/Conversation.h +++ b/src/Conversation/Main/Controller/inc/Conversation.h @@ -184,7 +184,7 @@ namespace Msg bool read(Message &msg); bool readMsgAddress(Message &msg); void write(const Message &msg); - void saveDraftMsg(); + MsgId saveDraftMsg(); void editDraftMsg(MsgId id); void onNaviOkButtonClicked(); diff --git a/src/Conversation/Main/Controller/src/Conversation.cpp b/src/Conversation/Main/Controller/src/Conversation.cpp index 18f81d4..43e938d 100644 --- a/src/Conversation/Main/Controller/src/Conversation.cpp +++ b/src/Conversation/Main/Controller/src/Conversation.cpp @@ -524,9 +524,9 @@ void Conversation::sendMessage() m_pListener->onConversationSentMessage(); } -void Conversation::saveDraftMsg() +MsgId Conversation::saveDraftMsg() { - MSG_LOG(""); + MsgId msgId; if(!isBodyEmpty()) { MessageRef msg = getMsgEngine().getComposer().createMessage(m_IsMms ? Message::MT_MMS : Message::MT_SMS); @@ -534,10 +534,11 @@ void Conversation::saveDraftMsg() { read(*msg); msg->setMessageStorageType(Message::MS_Phone); - MsgId msgId = getMsgEngine().getStorage().saveMessage(*msg, false); + msgId = getMsgEngine().getStorage().saveMessage(*msg, false); MSG_LOG("Draft message id = ", msgId); } } + return msgId; } void Conversation::editDraftMsg(MsgId id) @@ -545,13 +546,17 @@ void Conversation::editDraftMsg(MsgId id) MessageRef msg = getMsgEngine().getStorage().getMessage(id); if(msg) { - saveDraftMsg(); // TODO: Check case if edit single(int ConvList) when Body not empty + MsgId draftMsgId = saveDraftMsg(); m_pBody->clear(); - if(m_pConvList->getMessageCount() <= 1) + if(m_pConvList->getMessageCount() <= 1 && !draftMsgId.isValid()) setThreadId(ThreadId()); write(*msg); - getMsgEngine().getStorage().deleteMessage(id); + if(getMsgEngine().getStorage().deleteMessage(id)) + { + // Fast remove item in order to avoid blink: + m_pConvList->deleteItems({id}); + } m_pBody->setFocus(true); } } @@ -1126,7 +1131,11 @@ void Conversation::onAllItemsDeleted(ConvList &list) { MSG_LOG(""); if(m_Mode != NewMessageMode) - onHwBackButtonClicked(); + { + auto convList = getMsgEngine().getStorage().getConversationList(m_ThreadId); + if(convList && convList->getLength() == 0) + onHwBackButtonClicked(); + } } void Conversation::onEditDraftMsg(MsgId id)