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();
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
MSG_LOG_WARN("Msg address list is empty");
}
}
+ else
+ {
+ m_RecipThumbId = invalidThumbId;
+ }
}
void ConvList::navigateTo(MsgId msgId)
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;
m_pList->insertBeforeItem(*item, *m_pComposeItem);
else
m_pList->appendItem(*item);
+ updateSelectAllItem();
}
void ConvList::deleteItem(ConvListItem *item)
dateLineDelIfNec(item);
m_ConvListItemMap.erase(item->getMsgId());
m_pList->deleteItem(*item);
+ updateSelectAllItem();
}
bool ConvList::deleteItems(const MsgIdList &idList)
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);
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)
void ConvList::onListItemChecked(ListItem &listItem)
{
- bool allSelected = isAllListItemSelected();
- m_pSelectAll->setCheckState(allSelected);
-
+ updateSelectAllItem();
if(m_pListener)
m_pListener->onConvListItemChecked();
}
MsgConversationItemRef item = m_MsgEngine.getStorage().getConversationItem(msgId);
if(item)
{
- appendItem(*item);
+ insertItem(*item);
inserted = true;
}
}