summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandro Knauß <[email protected]>2016-04-03 11:11:32 +0200
committerSandro Knauß <[email protected]>2016-04-03 14:44:25 +0200
commit4d770f5f69150b2c5edcccbf30b836a40ae43ffc (patch)
tree1e1c83c1a696a4631c94a1ac54d278e5c2983c3d
parent1a073f36b0eafa86a974927968160d151b0b5943 (diff)
limit usage of stripEmailAddr into MessageList::Core::Item
-rw-r--r--messagelist/src/core/item.cpp16
-rw-r--r--messagelist/src/core/item.h15
-rw-r--r--messagelist/src/core/item_p.h12
-rw-r--r--messagelist/src/core/model.cpp6
-rw-r--r--messagelist/src/core/themedelegate.cpp24
-rw-r--r--messagelist/src/core/view.cpp8
6 files changed, 56 insertions, 25 deletions
diff --git a/messagelist/src/core/item.cpp b/messagelist/src/core/item.cpp
index 5167c85..9579dd7 100644
--- a/messagelist/src/core/item.cpp
+++ b/messagelist/src/core/item.cpp
@@ -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;
diff --git a/messagelist/src/core/item.h b/messagelist/src/core/item.h
index afebece..ad3af36 100644
--- a/messagelist/src/core/item.h
+++ b/messagelist/src/core/item.h
@@ -317,6 +317,11 @@ public:
void setSender(const QString &sender);
/**
+ * Display sender.
+ */
+ QString displaySender() const;
+
+ /**
* Returns the receiver associated to this item.
*/
const QString &receiver() const;
@@ -327,11 +332,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.
*/
bool useReceiver() const;
diff --git a/messagelist/src/core/item_p.h b/messagelist/src/core/item_p.h
index 91134e1..9e7cc6f 100644
--- a/messagelist/src/core/item_p.h
+++ b/messagelist/src/core/item_p.h
@@ -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;
}
diff --git a/messagelist/src/core/model.cpp b/messagelist/src/core/model.cpp
index 0086b3f..cdc3737 100644
--- a/messagelist/src/core/model.cpp
+++ b/messagelist/src/core/model.cpp
@@ -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:
diff --git a/messagelist/src/core/themedelegate.cpp b/messagelist/src/core/themedelegate.cpp
index 70d43da..4d3a2e5 100644
--- a/messagelist/src/core/themedelegate.cpp
+++ b/messagelist/src/core/themedelegate.cpp
@@ -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:
diff --git a/messagelist/src/core/view.cpp b/messagelist/src/core/view.cpp
index ed88d2c..95e0164 100644
--- a/messagelist/src/core/view.cpp
+++ b/messagelist/src/core/view.cpp
@@ -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"));
}