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
*/
ListView *m_pList;
ConvListItemMap m_ConvListItemMap;
DateLineItemSet m_DateLineItemSet;
- IConvListListener *m_pListner;
+ IConvListListener *m_pListener;
App &m_App;
WorkingDirRef m_WorkingDir;
FileViewer m_FileViewer;
, m_pList(nullptr)
, m_ConvListItemMap()
, m_DateLineItemSet()
- , m_pListner(nullptr)
+ , m_pListener(nullptr)
, m_App(app)
, m_WorkingDir(workingDir)
, m_FileViewer()
void ConvList::setListener(IConvListListener *l)
{
- m_pListner = l;
+ m_pListener = l;
}
void ConvList::setMode(ConvList::Mode mode)
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);
item->setCheckedState(state, false);
}
m_pList->updateRealizedItems();
- if(m_pListner)
- m_pListner->onConvListItemChecked();
+ if(m_pListener)
+ m_pListener->onConvListItemChecked();
}
void ConvList::onListItemLongPressed(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)
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()
bool read(Message &msg);
bool readMsgAddress(Message &msg);
void write(const Message &msg);
- void saveDraftMsg();
+ MsgId saveDraftMsg();
void editDraftMsg(MsgId id);
void onNaviOkButtonClicked();
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);
{
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)
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);
}
}
{
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)