From a92c91ee21723b19737dcf6fa65f5789a144682c Mon Sep 17 00:00:00 2001 From: Denis Dolzhenko Date: Wed, 3 Feb 2016 15:41:13 +0200 Subject: [PATCH] Refact + fix: Text style in thread list items. Change-Id: Ibe51b79c9b2a286de3bc9fccd076cf381cca3894 Signed-off-by: Denis Dolzhenko --- .../Controller/src/BaseThreadListItem.cpp | 2 +- src/MsgThread/Controller/src/MsgSearchListItem.cpp | 3 +- src/MsgThread/Controller/src/ThreadListItem.cpp | 12 ++--- .../Controller/src/ThreadSearchListItem.cpp | 4 +- src/MsgThread/View/inc/ThreadListViewItem.h | 10 +++- src/MsgThread/View/src/ThreadListViewItem.cpp | 54 ++++++++++++++++++---- 6 files changed, 64 insertions(+), 21 deletions(-) diff --git a/src/MsgThread/Controller/src/BaseThreadListItem.cpp b/src/MsgThread/Controller/src/BaseThreadListItem.cpp index 3908c2a..b477082 100644 --- a/src/MsgThread/Controller/src/BaseThreadListItem.cpp +++ b/src/MsgThread/Controller/src/BaseThreadListItem.cpp @@ -69,7 +69,7 @@ void BaseThreadListItem::updateThumbnail(const MsgAddress &addr) void BaseThreadListItem::updateTime(time_t time) { - m_Time = std::string("7:40"); // TODO: remove hardcode + m_Time = decorateTimeText(std::string("7:40")); // TODO: remove hardcode } std::string BaseThreadListItem::getName() diff --git a/src/MsgThread/Controller/src/MsgSearchListItem.cpp b/src/MsgThread/Controller/src/MsgSearchListItem.cpp index bb40825..6bcd35d 100644 --- a/src/MsgThread/Controller/src/MsgSearchListItem.cpp +++ b/src/MsgThread/Controller/src/MsgSearchListItem.cpp @@ -47,7 +47,7 @@ void MsgSearchListItem::updateThumbnail(const Message &msg) void MsgSearchListItem::update(const Message &msg, const std::string &searchWord) { m_MsgId = msg.getId(); - m_Message = TextDecorator::highlightKeyword(msg.getText(), searchWord); + m_Message = decorateMessageText(TextDecorator::highlightKeyword(msg.getText(), searchWord)); const MsgAddressList &addressList = msg.getAddressList(); int addrCount = addressList.getLength(); @@ -56,6 +56,7 @@ void MsgSearchListItem::update(const Message &msg, const std::string &searchWord m_Name = addressList.at(0).getAddress(); if(addrCount > 1) m_Name += " + " + std::to_string(addrCount - 1); + m_Name = decorateNameText(m_Name); } updateThumbnail(msg); diff --git a/src/MsgThread/Controller/src/ThreadListItem.cpp b/src/MsgThread/Controller/src/ThreadListItem.cpp index 9c87b42..263dec0 100644 --- a/src/MsgThread/Controller/src/ThreadListItem.cpp +++ b/src/MsgThread/Controller/src/ThreadListItem.cpp @@ -58,29 +58,29 @@ Evas_Object *ThreadListItem::getIcon() void ThreadListItem::updateModel(const MsgThreadItem &threadItem) { m_ThreadId = threadItem.getId(); - m_Message = threadItem.getLastMessage(); - m_Name = threadItem.getName(); + m_Message = decorateMessageText(threadItem.getLastMessage()); + m_Name = decorateNameText(threadItem.getName()); State state = NormalState; if(threadItem.isSending()) { state = StatusState; - m_Status = msg("IDS_MSG_BODY_SENDING_ING_M_STATUS_ABB"); + m_Status = decorateSendingText(msg("IDS_MSG_BODY_SENDING_ING_M_STATUS_ABB")); } else if(threadItem.hasFailedMessage()) { state = StatusState; - m_Status = msg("IDS_MSG_BODY_FAILED_M_STATUS_ABB2"); + m_Status = decorateFailedText(msg("IDS_MSG_BODY_FAILED_M_STATUS_ABB2")); } else if(threadItem.hasDraftMessage()) { state = StatusState; - m_Status = msg("IDS_MSG_BODY_DRAFT_M_STATUS_ABB"); + m_Status = decorateDraftText(msg("IDS_MSG_BODY_DRAFT_M_STATUS_ABB")); } else if(int unreadCount = threadItem.getUnreadCount() > 0) { state = IconState; - m_UnreadCount = std::to_string(unreadCount); + m_UnreadCount = decorateUnreadText(std::to_string(unreadCount)); } setState(state, false); diff --git a/src/MsgThread/Controller/src/ThreadSearchListItem.cpp b/src/MsgThread/Controller/src/ThreadSearchListItem.cpp index e614322..b8cbf8e 100644 --- a/src/MsgThread/Controller/src/ThreadSearchListItem.cpp +++ b/src/MsgThread/Controller/src/ThreadSearchListItem.cpp @@ -39,8 +39,8 @@ ThreadId ThreadSearchListItem::getThreadId() const void ThreadSearchListItem::update(const MsgThreadItem &item, const std::string &searchWord) { m_ThreadId = item.getId(); - m_Name = TextDecorator::highlightKeyword(item.getName(), searchWord); - m_Message = item.getLastMessage(); + m_Name = decorateNameText(TextDecorator::highlightKeyword(item.getName(), searchWord)); + m_Message = decorateMessageText(item.getLastMessage()); updateThumbnail(item); updateTime(item.getTime()); } diff --git a/src/MsgThread/View/inc/ThreadListViewItem.h b/src/MsgThread/View/inc/ThreadListViewItem.h index c6b4a95..0e65c68 100644 --- a/src/MsgThread/View/inc/ThreadListViewItem.h +++ b/src/MsgThread/View/inc/ThreadListViewItem.h @@ -41,8 +41,6 @@ namespace Msg void setState(State state, bool updateUi); State getState() const; - Evas_Object *makeUnreadIcon(const std::string &text); - protected: virtual std::string getName() = 0; virtual std::string getMessage() = 0; @@ -52,6 +50,14 @@ namespace Msg virtual Evas_Object *getIcon(); using ListItem::getState; + Evas_Object *makeUnreadIcon(const std::string &text) const; + std::string decorateNameText(const std::string &text) const; + std::string decorateMessageText(const std::string &text) const; + std::string decorateTimeText(const std::string &text) const; + std::string decorateUnreadText(const std::string &text) const; + std::string decorateFailedText(const std::string &text) const; + std::string decorateSendingText(const std::string &text) const; + std::string decorateDraftText(const std::string &text) const; private: virtual std::string getText(ListItem &item, const char *part); diff --git a/src/MsgThread/View/src/ThreadListViewItem.cpp b/src/MsgThread/View/src/ThreadListViewItem.cpp index 76c81a3..c1cbfd1 100644 --- a/src/MsgThread/View/src/ThreadListViewItem.cpp +++ b/src/MsgThread/View/src/ThreadListViewItem.cpp @@ -19,8 +19,8 @@ #include "Logger.h" #include "PathUtils.h" #include "ThumbnailMaker.h" -#include "TextDecorator.h" #include "ListView.h" +#include "TextDecorator.h" #include #include @@ -41,9 +41,11 @@ namespace const TextStyle nameTextStyle(44, "#131313FF"); const TextStyle msgTextStyle(38, "#969696FF"); - const TextStyle statusTextStyle(36, "#e43d3dFF"); - const TextStyle timeTextStyle(36, "#969696FF"); - const TextStyle unreadTextStyle(36, "#969696FF"); + const TextStyle timeTextStyle(32, "#969696FF"); + const TextStyle unreadTextStyle(34, "#e43d3dFF"); + const TextStyle failedTextStyle(32, "#e43d3dFF"); + const TextStyle draftTextStyle(32, "#e43d3dFF"); + const TextStyle sendingTextStyle(32, "#969696FF"); } ThreadListViewItem::ThreadListViewItem(Elm_Genlist_Item_Type type) @@ -60,20 +62,20 @@ std::string ThreadListViewItem::getText(ListItem &item, const char *part) { if(!strcmp(part, messagePart)) { - return TextDecorator::make(getMessage(), msgTextStyle); + return getMessage(); } else if(!strcmp(part, namePart)) { - return TextDecorator::make(getName(), nameTextStyle); + return getName(); } else if(!strcmp(part, timePart)) { - return TextDecorator::make(getTime(), timeTextStyle); + return getTime(); } else if(!strcmp(part, statusPart)) { if(m_State == StatusState) - return TextDecorator::make(getStatus(), statusTextStyle); + return getStatus(); } return ""; @@ -118,7 +120,7 @@ ThreadListViewItem::State ThreadListViewItem::getState() const return m_State; } -Evas_Object *ThreadListViewItem::makeUnreadIcon(const std::string &text) +Evas_Object *ThreadListViewItem::makeUnreadIcon(const std::string &text) const { Evas_Object *label = elm_label_add(*getOwner()); evas_object_show(label); @@ -137,3 +139,37 @@ Evas_Object *ThreadListViewItem::getIcon() return nullptr; } +std::string ThreadListViewItem::decorateNameText(const std::string &text) const +{ + return TextDecorator::make(text, nameTextStyle); +} + +std::string ThreadListViewItem::decorateMessageText(const std::string &text) const +{ + return TextDecorator::make(text, msgTextStyle); +} + +std::string ThreadListViewItem::decorateTimeText(const std::string &text) const +{ + return TextDecorator::make(text, timeTextStyle); +} + +std::string ThreadListViewItem::decorateUnreadText(const std::string &text) const +{ + return TextDecorator::make(text, unreadTextStyle); +} + +std::string ThreadListViewItem::decorateFailedText(const std::string &text) const +{ + return TextDecorator::make(text, failedTextStyle); +} + +std::string ThreadListViewItem::decorateSendingText(const std::string &text) const +{ + return TextDecorator::make(text, sendingTextStyle); +} + +std::string ThreadListViewItem::decorateDraftText(const std::string &text) const +{ + return TextDecorator::make(text, draftTextStyle); +} -- 2.7.4