: public BubbleBgEntity
{
public:
- BubbleTextEntity(BubbleBgViewItem::BgType type, Message::Direction direction, const std::string &text);
+ BubbleTextEntity(BubbleBgViewItem::BgType type, Message::Direction direction, std::string text);
virtual ~BubbleTextEntity();
virtual BubbleTextViewItem *createView(Evas_Object *parent);
std::string m_Text;
};
- inline BubbleTextEntity::BubbleTextEntity(BubbleBgViewItem::BgType type, Message::Direction direction, const std::string &text)
+ inline BubbleTextEntity::BubbleTextEntity(BubbleBgViewItem::BgType type, Message::Direction direction, std::string text)
: BubbleBgEntity(TextItem, type, direction)
- , m_Text(text)
+ , m_Text(std::move(text))
{
}
private:
ConvListViewItem::ConvItemType getConvItemType(const MsgConversationItem &item);
void prepareBubble(const MsgConversationItem &item, const std::string &searchWord);
- BubbleEntity *createTextEntity(BubbleBgViewItem::BgType bgType, Message::Direction direction, const MsgConvMedia &media, const std::string &searchWord);
- BubbleEntity *createTextEntity(BubbleBgViewItem::BgType bgType, Message::Direction direction, std::string text, bool markup, const std::string &searchWord);
+ BubbleEntity *createTextEntity(BubbleBgViewItem::BgType bgType, Message::Direction direction, const MsgConvMedia &media, std::string searchWord);
+ BubbleEntity *createTextEntity(BubbleBgViewItem::BgType bgType, Message::Direction direction, std::string text, bool markup, std::string searchWord);
void addEntity(BubbleEntity *entity);
void updateEntityBgType(BubbleBgViewItem::BgType bgType);
BubbleBgViewItem::BgType getBubbleBgType(const MsgConversationItem &item);
using namespace Msg;
-namespace
-{
- bool findText(const std::string &text, const std::string &searchWord)
- {
- if(text.empty() || searchWord.empty())
- return false;
-
- std::string s(markupToUtf8(text));
- std::transform(s.begin(), s.end(), s.begin(), tolower);
- std::string sw(markupToUtf8(searchWord));
- std::transform(sw.begin(), sw.end(), sw.begin(), tolower);
- size_t size = s.find(sw);
- return size != std::string::npos;
- }
-}
-
ConvListItem::ConvListItem(const MsgConversationItem &item,
App &app,
BubbleEntityFactory &bubbleEntityFactory,
}
-BubbleEntity *ConvListItem::createTextEntity(BubbleBgViewItem::BgType bgType, Message::Direction direction, const MsgConvMedia &media, const std::string &searchWord)
+BubbleEntity *ConvListItem::createTextEntity(BubbleBgViewItem::BgType bgType, Message::Direction direction, const MsgConvMedia &media, std::string searchWord)
{
std::string text = FileUtils::readTextFile(media.getPath());
-
- if(findText(text, searchWord))
- showSearch();
- return m_BubbleEntityFactory.createTextEntity(utf8ToMarkup(text), bgType, direction);
+ return createTextEntity(bgType, direction, std::move(text), true, std::move(searchWord));
}
-BubbleEntity *ConvListItem::createTextEntity(BubbleBgViewItem::BgType bgType, Message::Direction direction, std::string text, bool markup, const std::string &searchWord)
+BubbleEntity *ConvListItem::createTextEntity(BubbleBgViewItem::BgType bgType, Message::Direction direction, std::string text, bool markup, std::string searchWord)
{
- if(findText(text, searchWord))
+ bool found = false;
+ std::string markupText = markup ? utf8ToMarkup(text) : std::move(text);
+ std::string markupSearchWord = markup ? utf8ToMarkup(searchWord) : std::move(searchWord);
+ std::string resText = TextDecorator::highlightKeyword(std::move(markupText), markupSearchWord, &found);
+
+ if(found)
showSearch();
- std::string resText = markup ? utf8ToMarkup(text) : std::move(text);
- return m_BubbleEntityFactory.createTextEntity(resText, bgType, direction);
+
+ return m_BubbleEntityFactory.createTextEntity(std::move(resText), bgType, direction);
}
BubbleDownloadButtonEntity *ConvListItem::findDownloadButton() const
Message::Direction direction = item.getDirection();
if(item.isRestrictedByDpm())
{
- addEntity(createTextEntity(BubbleBgViewItem::RestrictedStyle, direction, msg("IDS_MSG_BODY_COULDNT_RECEIVE_THIS_MESSAGE_THE_SECURITY_POLICY_PREVENTS_RECEIVING_MESSAGES"), true, ""));
+ addEntity(createTextEntity(BubbleBgViewItem::RestrictedStyle, direction, msg("IDS_MSG_BODY_COULDNT_RECEIVE_THIS_MESSAGE_THE_SECURITY_POLICY_PREVENTS_RECEIVING_MESSAGES"), false, ""));
}
else if(!MsgUtils::isMms(m_Type))
{
else if(m_Type == Message::MT_MMS_Noti)
{
std::string text = MessageDetailContent::getMmsNotiConvListItemContent(m_App, m_MsgId);
- addEntity(createTextEntity(bgType, direction, text, false, searchWord));
+ addEntity(createTextEntity(bgType, direction, std::move(text), false, searchWord));
addEntity(m_BubbleEntityFactory.createDownloadButtonEntity(direction));
updateDownloadButton();
}