Commit 4d770f5f authored by Sandro Knauß's avatar Sandro Knauß
Browse files

limit usage of stripEmailAddr into MessageList::Core::Item

parent 1a073f36
......@@ -475,6 +475,12 @@ void Item::setSender(const QString &sender)
d_ptr->mSender = sender;
}
QString Item::displaySender() const
{
return MessageCore::StringUtil::stripEmailAddr(sender());
}
const QString &Item::receiver() const
{
return d_ptr->mReceiver;
......@@ -485,11 +491,21 @@ void Item::setReceiver(const QString &receiver)
d_ptr->mReceiver = receiver;
}
QString Item::displayReceiver() const
{
return MessageCore::StringUtil::stripEmailAddr(receiver());
}
const QString &Item::senderOrReceiver() const
{
return d_ptr->mUseReceiver ? d_ptr->mReceiver : d_ptr->mSender;
}
QString Item::displaySenderOrReceiver() const
{
return MessageCore::StringUtil::stripEmailAddr(senderOrReceiver());
}
bool Item::useReceiver() const
{
return d_ptr->mUseReceiver;
......
......@@ -316,6 +316,11 @@ public:
*/
void setSender(const QString &sender);
/**
* Display sender.
*/
QString displaySender() const;
/**
* Returns the receiver associated to this item.
*/
......@@ -326,11 +331,21 @@ public:
*/
void setReceiver(const QString &receiver);
/**
* Display receiver.
*/
QString displayReceiver() const;
/**
* Returns the sender or the receiver, depending on the underlying StorageModel settings.
*/
const QString &senderOrReceiver() const;
/**
* Display sender or receiver.
*/
QString displaySenderOrReceiver() const;
/**
* Returns whether sender or receiver is supposed to be displayed.
*/
......
......@@ -353,8 +353,8 @@ class ItemSenderComparator
public:
static inline bool firstGreaterOrEqual(Item *first, Item *second)
{
const int ret = MessageCore::StringUtil::stripEmailAddr(first->sender()).compare(
MessageCore::StringUtil::stripEmailAddr(second->sender()), Qt::CaseInsensitive);
const int ret = first->displaySender().compare(
second->displaySender(), Qt::CaseInsensitive);
if (ret < 0) {
return false;
}
......@@ -375,8 +375,8 @@ class ItemReceiverComparator
public:
static inline bool firstGreaterOrEqual(Item *first, Item *second)
{
const int ret = MessageCore::StringUtil::stripEmailAddr(first->receiver()).compare(
MessageCore::StringUtil::stripEmailAddr(second->receiver()), Qt::CaseInsensitive);
const int ret = first->displayReceiver().compare(
second->displayReceiver(), Qt::CaseInsensitive);
if (ret < 0) {
return false;
}
......@@ -397,8 +397,8 @@ class ItemSenderOrReceiverComparator
public:
static inline bool firstGreaterOrEqual(Item *first, Item *second)
{
const int ret = MessageCore::StringUtil::stripEmailAddr(first->senderOrReceiver()).compare(
MessageCore::StringUtil::stripEmailAddr(second->senderOrReceiver()), Qt::CaseInsensitive);
const int ret = first->displaySenderOrReceiver().compare(
second->displaySenderOrReceiver(), Qt::CaseInsensitive);
if (ret < 0) {
return false;
}
......
......@@ -1336,17 +1336,17 @@ void ModelPrivate::attachMessageToGroupHeader(MessageItem *mi)
case Aggregation::GroupBySenderOrReceiver:
date = mi->date();
groupLabel = MessageCore::StringUtil::stripEmailAddr(mi->senderOrReceiver());
groupLabel = mi->displaySenderOrReceiver();
break;
case Aggregation::GroupBySender:
date = mi->date();
groupLabel = MessageCore::StringUtil::stripEmailAddr(mi->sender());
groupLabel = mi->displaySender();
break;
case Aggregation::GroupByReceiver:
date = mi->date();
groupLabel = MessageCore::StringUtil::stripEmailAddr(mi->receiver());
groupLabel = mi->displayReceiver();
break;
case Aggregation::NoGrouping:
......
......@@ -871,15 +871,15 @@ void ThemeDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
paint_right_aligned_elided_text(item->subject(), ci, painter, l, top, r, layoutDir, font);
break;
case Theme::ContentItem::SenderOrReceiver:
paint_right_aligned_elided_text(MessageCore::StringUtil::stripEmailAddr(item->senderOrReceiver()),
paint_right_aligned_elided_text(item->displaySenderOrReceiver(),
ci, painter, l, top, r, layoutDir, font);
break;
case Theme::ContentItem::Receiver:
paint_right_aligned_elided_text(MessageCore::StringUtil::stripEmailAddr(item->receiver()),
paint_right_aligned_elided_text(item->displayReceiver(),
ci, painter, l, top, r, layoutDir, font);
break;
case Theme::ContentItem::Sender:
paint_right_aligned_elided_text(MessageCore::StringUtil::stripEmailAddr(item->sender()),
paint_right_aligned_elided_text(item->displaySender(),
ci, painter, l, top, r, layoutDir, font);
break;
case Theme::ContentItem::Date:
......@@ -1030,15 +1030,15 @@ void ThemeDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
paint_left_aligned_elided_text(item->subject(), ci, painter, l, top, r, layoutDir, font);
break;
case Theme::ContentItem::SenderOrReceiver:
paint_left_aligned_elided_text(MessageCore::StringUtil::stripEmailAddr(item->senderOrReceiver()),
paint_left_aligned_elided_text(item->displaySenderOrReceiver(),
ci, painter, l, top, r, layoutDir, font);
break;
case Theme::ContentItem::Receiver:
paint_left_aligned_elided_text(MessageCore::StringUtil::stripEmailAddr(item->receiver()),
paint_left_aligned_elided_text(item->displayReceiver(),
ci, painter, l, top, r, layoutDir, font);
break;
case Theme::ContentItem::Sender:
paint_left_aligned_elided_text(MessageCore::StringUtil::stripEmailAddr(item->sender()),
paint_left_aligned_elided_text(item->displaySender(),
ci, painter, l, top, r, layoutDir, font);
break;
case Theme::ContentItem::Date:
......@@ -1282,15 +1282,15 @@ bool ThemeDelegate::hitTest(const QPoint &viewportPoint, bool exact)
compute_bounding_rect_for_right_aligned_elided_text(mHitItem->subject(), ci, l, top, r, mHitContentItemRect, layoutDir, font);
break;
case Theme::ContentItem::SenderOrReceiver:
compute_bounding_rect_for_right_aligned_elided_text(MessageCore::StringUtil::stripEmailAddr(mHitItem->senderOrReceiver()),
compute_bounding_rect_for_right_aligned_elided_text(mHitItem->displaySenderOrReceiver(),
ci, l, top, r, mHitContentItemRect, layoutDir, font);
break;
case Theme::ContentItem::Receiver:
compute_bounding_rect_for_right_aligned_elided_text(MessageCore::StringUtil::stripEmailAddr(mHitItem->receiver()),
compute_bounding_rect_for_right_aligned_elided_text(mHitItem->displayReceiver(),
ci, l, top, r, mHitContentItemRect, layoutDir, font);
break;
case Theme::ContentItem::Sender:
compute_bounding_rect_for_right_aligned_elided_text(MessageCore::StringUtil::stripEmailAddr(mHitItem->sender()),
compute_bounding_rect_for_right_aligned_elided_text(mHitItem->displaySender(),
ci, l, top, r, mHitContentItemRect, layoutDir, font);
break;
case Theme::ContentItem::Date:
......@@ -1428,15 +1428,15 @@ bool ThemeDelegate::hitTest(const QPoint &viewportPoint, bool exact)
compute_bounding_rect_for_left_aligned_elided_text(mHitItem->subject(), ci, l, top, r, mHitContentItemRect, layoutDir, font);
break;
case Theme::ContentItem::SenderOrReceiver:
compute_bounding_rect_for_left_aligned_elided_text(MessageCore::StringUtil::stripEmailAddr(mHitItem->senderOrReceiver()),
compute_bounding_rect_for_left_aligned_elided_text(mHitItem->displaySenderOrReceiver(),
ci, l, top, r, mHitContentItemRect, layoutDir, font);
break;
case Theme::ContentItem::Receiver:
compute_bounding_rect_for_left_aligned_elided_text(MessageCore::StringUtil::stripEmailAddr(mHitItem->receiver()),
compute_bounding_rect_for_left_aligned_elided_text(mHitItem->displayReceiver(),
ci, l, top, r, mHitContentItemRect, layoutDir, font);
break;
case Theme::ContentItem::Sender:
compute_bounding_rect_for_left_aligned_elided_text(MessageCore::StringUtil::stripEmailAddr(mHitItem->sender()),
compute_bounding_rect_for_left_aligned_elided_text(mHitItem->displaySender(),
ci, l, top, r, mHitContentItemRect, layoutDir, font);
break;
case Theme::ContentItem::Date:
......
......@@ -2414,12 +2414,12 @@ bool View::event(QEvent *e)
"</tr>");
if (textIsLeftToRight) {
tip += htmlCodeForStandardRow.arg(i18n("From")).arg(MessageCore::StringUtil::stripEmailAddr(mi->sender()));
tip += htmlCodeForStandardRow.arg(i18nc("Receiver of the email", "To")).arg(MessageCore::StringUtil::stripEmailAddr(mi->receiver()));
tip += htmlCodeForStandardRow.arg(i18n("From")).arg(mi->displaySender());
tip += htmlCodeForStandardRow.arg(i18nc("Receiver of the email", "To")).arg(mi->displayReceiver());
tip += htmlCodeForStandardRow.arg(i18n("Date")).arg(mi->formattedDate());
} else {
tip += htmlCodeForStandardRow.arg(MessageCore::StringUtil::stripEmailAddr(mi->sender())).arg(i18n("From"));
tip += htmlCodeForStandardRow.arg(MessageCore::StringUtil::stripEmailAddr(mi->receiver())).arg(i18nc("Receiver of the email", "To"));
tip += htmlCodeForStandardRow.arg(mi->displaySender()).arg(i18n("From"));
tip += htmlCodeForStandardRow.arg(mi->displayReceiver()).arg(i18nc("Receiver of the email", "To"));
tip += htmlCodeForStandardRow.arg(mi->formattedDate(), i18n("Date"));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment