[kde-doc-english] [trojita] src: GUI: Ignore the human-readable part when it's just a repetition of the actual e-mail address
Jan Kundrát
jkt at flaska.net
Thu May 23 22:38:34 UTC 2013
Git commit e17a03474acaa215d878955f928b2444d100fcbb by Jan Kundrát.
Committed on 24/05/2013 at 00:35.
Pushed by jkt into branch 'master'.
GUI: Ignore the human-readable part when it's just a repetition of the actual e-mail address
This is more or less just a limitation of the current address parsing code --
the dialog denies addresses like "foo at example.org <foo at example.org>".
M +3 -1 src/Gui/ComposeWidget.cpp
M +2 -0 src/Gui/Window.cpp
M +6 -0 src/Imap/Parser/MailAddress.cpp
M +2 -0 src/Imap/Parser/MailAddress.h
http://commits.kde.org/trojita/e17a03474acaa215d878955f928b2444d100fcbb
diff --git a/src/Gui/ComposeWidget.cpp b/src/Gui/ComposeWidget.cpp
index 1a3016a..9d1a9a4 100644
--- a/src/Gui/ComposeWidget.cpp
+++ b/src/Gui/ComposeWidget.cpp
@@ -671,7 +671,9 @@ bool ComposeWidget::setReplyMode(const Composer::ReplyMode mode)
while (!m_recipients.isEmpty())
removeRecipient(0);
- Q_FOREACH(const Composer::RecipientList::value_type &recipient, list) {
+ Q_FOREACH(Composer::RecipientList::value_type recipient, list) {
+ if (!recipient.second.hasUsefulDisplayName())
+ recipient.second.name.clear();
addRecipient(m_recipients.size(), recipient.first, recipient.second.asPrettyString());
}
diff --git a/src/Gui/Window.cpp b/src/Gui/Window.cpp
index f4a54d1..424204e 100644
--- a/src/Gui/Window.cpp
+++ b/src/Gui/Window.cpp
@@ -1455,6 +1455,8 @@ void MainWindow::slotComposeMailUrl(const QUrl &url)
Imap::Message::MailAddress addr(q.queryItemValue(QLatin1String("X-Trojita-DisplayName")), QString(),
list[0], list[1]);
#endif
+ if (!addr.hasUsefulDisplayName())
+ addr.name.clear();
RecipientsType recipients;
recipients << qMakePair<Composer::RecipientKind,QString>(Composer::ADDRESS_TO, addr.asPrettyString());
invokeComposeDialog(QString(), QString(), recipients);
diff --git a/src/Imap/Parser/MailAddress.cpp b/src/Imap/Parser/MailAddress.cpp
index a2daf36..5cf31d7 100644
--- a/src/Imap/Parser/MailAddress.cpp
+++ b/src/Imap/Parser/MailAddress.cpp
@@ -257,6 +257,12 @@ QString MailAddress::asPrettyString() const
name + QLatin1Char(' ') + QLatin1Char('<') + asSMTPMailbox() + QLatin1Char('>');
}
+/** @short Is the human-readable part "useful", i.e. does it contain something else besides the e-mail address? */
+bool MailAddress::hasUsefulDisplayName() const
+{
+ return !name.isEmpty() && name.trimmed().toLower() != asSMTPMailbox().toLower();
+}
+
QTextStream &operator<<(QTextStream &stream, const MailAddress &address)
{
stream << '"' << address.name << "\" <";
diff --git a/src/Imap/Parser/MailAddress.h b/src/Imap/Parser/MailAddress.h
index e894a7f..d4057d9 100644
--- a/src/Imap/Parser/MailAddress.h
+++ b/src/Imap/Parser/MailAddress.h
@@ -71,6 +71,8 @@ public:
QByteArray asMailHeader() const;
QString asPrettyString() const;
+ bool hasUsefulDisplayName() const;
+
static QString prettyList(const QList<MailAddress> &list, FormattingMode mode);
static QString prettyList(const QVariantList &list, FormattingMode mode);
More information about the kde-doc-english
mailing list