From: Denis Dolzhenko Date: Fri, 23 Sep 2016 14:38:40 +0000 (+0300) Subject: TizenRefApp-7283 Delete mode in Conversation does not work properly X-Git-Tag: submit/tizen/20160927.142535^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8e51d8fb4d2a2be428f883b28827cb344fd1839d;p=profile%2Fmobile%2Fapps%2Fnative%2Fmessage.git TizenRefApp-7283 Delete mode in Conversation does not work properly Change-Id: Ib9840197af8329884340eece82d3be0a8a185e35 Signed-off-by: Denis Dolzhenko --- diff --git a/src/Conversation/ConvList/Controller/inc/ConvList.h b/src/Conversation/ConvList/Controller/inc/ConvList.h index 68f9ef3e..0807b3a0 100644 --- a/src/Conversation/ConvList/Controller/inc/ConvList.h +++ b/src/Conversation/ConvList/Controller/inc/ConvList.h @@ -148,10 +148,10 @@ namespace Msg Evas_Object *createList(Evas_Object *parent); void fill(); void selectListItems(bool state); - bool isAllListItemSelected() const; + void updateSelectAllItem(); ConvListItem *getItem(MsgId msgId) const; - void appendItem(const MsgConversationItem &item); - void appendItem(ConvListItem *item); + void insertItem(const MsgConversationItem &item); + void insertItem(ConvListItem *item); void deleteItem(ConvListItem *item); void demoteItem(ConvListItem *item); //move down existing item void clear(); diff --git a/src/Conversation/ConvList/Controller/src/ConvList.cpp b/src/Conversation/ConvList/Controller/src/ConvList.cpp index 3007a345..e4b4fb5b 100644 --- a/src/Conversation/ConvList/Controller/src/ConvList.cpp +++ b/src/Conversation/ConvList/Controller/src/ConvList.cpp @@ -128,16 +128,29 @@ void ConvList::fill() for(int i = 0; i < convListLen; ++i) { MsgConversationItem &item = convList->at(i); - appendItem(item); + insertItem(item); } } void ConvList::setThreadId(ThreadId id, const std::string &searchWord) { - m_ThreadId = id; - m_SearchWord = searchWord; - updateRecipThumbId(); - fill(); + bool fillList = false; + + if(m_ThreadId != id) + { + fillList = true; + m_ThreadId = id; + updateRecipThumbId(); + } + + if(searchWord != m_SearchWord) + { + fillList = true; + m_SearchWord = searchWord; + } + + if(fillList) + fill(); } ThreadId ConvList::getThreadId() const @@ -161,6 +174,10 @@ void ConvList::updateRecipThumbId() MSG_LOG_WARN("Msg address list is empty"); } } + else + { + m_RecipThumbId = invalidThumbId; + } } void ConvList::navigateTo(MsgId msgId) @@ -183,15 +200,15 @@ ConvListItem *ConvList::getItem(MsgId msgId) const return it != m_ConvListItemMap.end() ? it->second : nullptr; } -void ConvList::appendItem(const MsgConversationItem &item) +void ConvList::insertItem(const MsgConversationItem &item) { if(item.getDirection() == Message::MD_Received) - appendItem(new ConvListItem(item, m_App, m_BubbleEntityFactory, m_SearchWord, m_RecipThumbId)); + insertItem(new ConvListItem(item, m_App, m_BubbleEntityFactory, m_SearchWord, m_RecipThumbId)); else - appendItem(new ConvListItem(item, m_App, m_BubbleEntityFactory, m_SearchWord)); + insertItem(new ConvListItem(item, m_App, m_BubbleEntityFactory, m_SearchWord)); } -void ConvList::appendItem(ConvListItem *item) +void ConvList::insertItem(ConvListItem *item) { dateLineAddIfNec(item); m_ConvListItemMap[item->getMsgId()] = item; @@ -200,6 +217,7 @@ void ConvList::appendItem(ConvListItem *item) m_pList->insertBeforeItem(*item, *m_pComposeItem); else m_pList->appendItem(*item); + updateSelectAllItem(); } void ConvList::deleteItem(ConvListItem *item) @@ -207,6 +225,7 @@ void ConvList::deleteItem(ConvListItem *item) dateLineDelIfNec(item); m_ConvListItemMap.erase(item->getMsgId()); m_pList->deleteItem(*item); + updateSelectAllItem(); } bool ConvList::deleteItems(const MsgIdList &idList) @@ -311,18 +330,6 @@ int ConvList::getMessageCheckedCount() const return count; } -bool ConvList::isAllListItemSelected() const -{ - // Simple but not fast impl: - auto items = getConvItems(); - for(ConvListItem *item : items) - { - if(!item->getCheckedState()) - return false; - } - return true; -} - void ConvList::selectListItems(bool state) { m_pList->checkAllItems(state); @@ -330,6 +337,24 @@ void ConvList::selectListItems(bool state) m_pListener->onConvListItemChecked(); } +void ConvList::updateSelectAllItem() +{ + if(m_Mode == SelectMode && m_pSelectAll) + { + bool check = true; + auto items = getConvItems(); + for(ConvListItem *item : items) + { + if(!item->getCheckedState()) + { + check = false; + break; + } + } + m_pSelectAll->setCheckState(check); + } +} + ComposeListItem &ConvList::getComposeItem() { if(!m_pComposeItem) @@ -360,9 +385,7 @@ void ConvList::onSelectAllChanged(Evas_Object *obj, void *eventInfo) void ConvList::onListItemChecked(ListItem &listItem) { - bool allSelected = isAllListItemSelected(); - m_pSelectAll->setCheckState(allSelected); - + updateSelectAllItem(); if(m_pListener) m_pListener->onConvListItemChecked(); } @@ -394,7 +417,7 @@ void ConvList::onMsgStorageInsert(const MsgIdList &msgIdList) MsgConversationItemRef item = m_MsgEngine.getStorage().getConversationItem(msgId); if(item) { - appendItem(*item); + insertItem(*item); inserted = true; } } diff --git a/src/Conversation/Recipients/Controller/src/ConvRecipientsPanel.cpp b/src/Conversation/Recipients/Controller/src/ConvRecipientsPanel.cpp index deac2545..b5c92789 100644 --- a/src/Conversation/Recipients/Controller/src/ConvRecipientsPanel.cpp +++ b/src/Conversation/Recipients/Controller/src/ConvRecipientsPanel.cpp @@ -140,9 +140,12 @@ void ConvRecipientsPanel::update(const MsgAddressList &addressList) void ConvRecipientsPanel::update(const ThreadId &threadId) { - clear(); - m_ThreadId = threadId; - m_pMbe->update(threadId); + if(m_ThreadId != threadId) + { + clear(); + m_ThreadId = threadId; + m_pMbe->update(threadId); + } } MbeRecipients::AppendItemStatus ConvRecipientsPanel::appendItem(const std::string &address,