[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [trojita] src/Gui: Composer: try to be smart with the type of the next recipient
From:       Jan_Kundrát <jkt () flaska ! net>
Date:       2013-01-01 9:40:37
Message-ID: 20130101094037.4FD23A6091 () git ! kde ! org
[Download RAW message or body]

Git commit ea877933bb251b835827574148c75fc402a8da41 by Jan Kundrát.
Committed on 01/01/2013 at 10:33.
Pushed by jkt into branch 'master'.

Composer: try to be smart with the type of the next recipient

A usability feature suggested by tss on IRC.

M  +19   -3    src/Gui/ComposeWidget.cpp
M  +1    -0    src/Gui/ComposeWidget.h

http://commits.kde.org/trojita/ea877933bb251b835827574148c75fc402a8da41

diff --git a/src/Gui/ComposeWidget.cpp b/src/Gui/ComposeWidget.cpp
index 03cfdf5..ed866b2 100644
--- a/src/Gui/ComposeWidget.cpp
+++ b/src/Gui/ComposeWidget.cpp
@@ -344,7 +344,7 @@ void ComposeWidget::setData(const QList<QPair<RecipientKind, \
QString> > &recipie  if (recipients.isEmpty())
         addRecipient(0, Imap::Mailbox::MessageComposer::Recipient_To, QString());
     else
-        addRecipient(recipients.size(), recipients.last().first, QString());
+        addRecipient(recipients.size(), \
recipientKindForNextRow(recipients.last().first), QString());  \
ui->subject->setText(subject);  ui->mailText->setText(body);
     m_composer->setInReplyTo(inReplyTo);
@@ -353,6 +353,22 @@ void ComposeWidget::setData(const QList<QPair<RecipientKind, \
QString> > &recipie  slotUpdateSignature();
 }
 
+/** @short Find out what type of recipient to use for the last row */
+ComposeWidget::RecipientKind ComposeWidget::recipientKindForNextRow(const \
RecipientKind kind) +{
+    using namespace Imap::Mailbox;
+    switch (kind) {
+    case MessageComposer::Recipient_To:
+        // Heuristic: if the last one is "to", chances are that the next one shall \
not be "to" as well. +        // Cc is reasonable here.
+        return MessageComposer::Recipient_Cc;
+    case MessageComposer::Recipient_Cc:
+    case MessageComposer::Recipient_Bcc:
+        // In any other case, it is probably better to just reuse the type of the \
last row +        return kind;
+    }
+}
+
 //BEGIN QFormLayout workarounds
 
 /** First issue: QFormLayout messes up rows by never removing them
@@ -466,7 +482,7 @@ void ComposeWidget::updateRecipientList()
         }
     }
     if (!haveEmpty)
-        addRecipient(m_recipients.count(), \
currentRecipient(m_recipients.last().first), QString()); +        \
addRecipient(m_recipients.count(), \
recipientKindForNextRow(currentRecipient(m_recipients.last().first)), QString());  }
 
 void ComposeWidget::collapseRecipients()
@@ -479,7 +495,7 @@ void ComposeWidget::collapseRecipients()
     // an empty recipient line just lost focus -> we "place it at the end", ie. \
simply remove it  // and append a clone
     bool needEmpty = false;
-    RecipientKind carriedKind = Imap::Mailbox::MessageComposer::Recipient_To;
+    RecipientKind carriedKind = \
                recipientKindForNextRow(Imap::Mailbox::MessageComposer::Recipient_To);
                
     for (int i = 0; i < m_recipients.count() - 1; ++i) { // sic! on the -1, no \
action if it trails anyway  if (m_recipients.at(i).second == edit) {
             carriedKind = currentRecipient(m_recipients.last().first);
diff --git a/src/Gui/ComposeWidget.h b/src/Gui/ComposeWidget.h
index eb2b589..50d1167 100644
--- a/src/Gui/ComposeWidget.h
+++ b/src/Gui/ComposeWidget.h
@@ -85,6 +85,7 @@ private slots:
 
 private:
     static QByteArray extractMailAddress(const QString &text, bool &ok);
+    static RecipientKind recipientKindForNextRow(const RecipientKind kind);
     void addRecipient(int position, RecipientKind kind, const QString &address);
     bool parseRecipients(QList<QPair<RecipientKind, Imap::Message::MailAddress> > \
&results);  void removeRecipient(int position);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic