[kde-doc-english] [trojita/addressbook] src/Gui: GUI: Decorate contacts based on whether they's in the address book

Jan Kundrát jkt at flaska.net
Fri May 24 15:35:54 UTC 2013


Git commit bf1e955d8285d8c9be9daa248b5a7a222e156965 by Jan Kundrát.
Committed on 24/05/2013 at 15:54.
Pushed by jkt into branch 'addressbook'.

GUI: Decorate contacts based on whether they's in the address book

M  +6    -1    src/Gui/EnvelopeView.cpp
M  +4    -0    src/Gui/EnvelopeView.h
M  +1    -0    src/Gui/MessageView.h
M  +9    -0    src/Gui/Window.cpp
M  +1    -0    src/Gui/Window.h

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

diff --git a/src/Gui/EnvelopeView.cpp b/src/Gui/EnvelopeView.cpp
index 7042ac5..b0106d2 100644
--- a/src/Gui/EnvelopeView.cpp
+++ b/src/Gui/EnvelopeView.cpp
@@ -60,7 +60,10 @@ QString EnvelopeView::htmlizeAddresses(const QList<Imap::Message::MailAddress> &
     Q_ASSERT(!addresses.isEmpty());
     QStringList buf;
     Q_FOREACH(const Imap::Message::MailAddress &addr, addresses) {
-        buf << addr.prettyName(Imap::Message::MailAddress::FORMAT_CLICKABLE);
+        QStringList matchingDisplayNames;
+        emit addressDetailsRequested(addr.mailbox + QLatin1Char('@') + addr.host, matchingDisplayNames);
+        QString icon = matchingDisplayNames.isEmpty() ? " [unknown]" : " [in abook]";
+        buf << addr.prettyName(Imap::Message::MailAddress::FORMAT_CLICKABLE) + icon;
     }
     return buf.join(QLatin1String(", "));
 }
@@ -151,6 +154,8 @@ void EnvelopeView::onLinkHovered(const QString &target)
 void EnvelopeView::connectWithMessageView(MessageView *messageView)
 {
     connect(this, SIGNAL(linkActivated(QString)), messageView, SLOT(headerLinkActivated(QString)));
+    connect(this, SIGNAL(addressDetailsRequested(QString,QStringList&)),
+            messageView, SIGNAL(addressDetailsRequested(QString,QStringList&)));
 }
 
 }
diff --git a/src/Gui/EnvelopeView.h b/src/Gui/EnvelopeView.h
index 1ae4651..e5edb5a 100644
--- a/src/Gui/EnvelopeView.h
+++ b/src/Gui/EnvelopeView.h
@@ -46,6 +46,10 @@ public:
 
     void connectWithMessageView(MessageView *messageView);
 
+signals:
+    /** Emitted when requesting a list of addresses for a given mail */
+    void addressDetailsRequested(const QString &mail, QStringList &addresses);
+
 private slots:
     void onLinkHovered(const QString &target);
 
diff --git a/src/Gui/MessageView.h b/src/Gui/MessageView.h
index bdbad36..73c4595 100644
--- a/src/Gui/MessageView.h
+++ b/src/Gui/MessageView.h
@@ -90,6 +90,7 @@ signals:
     void messageChanged();
     void linkHovered(const QString &url);
     void searchRequestedBy(QWebView *webView);
+    void addressDetailsRequested(const QString &mail, QStringList &addresses);
 private:
     bool eventFilter(QObject *object, QEvent *event);
     Imap::Message::Envelope envelope() const;
diff --git a/src/Gui/Window.cpp b/src/Gui/Window.cpp
index 424204e..8d93d5a 100644
--- a/src/Gui/Window.cpp
+++ b/src/Gui/Window.cpp
@@ -509,6 +509,8 @@ void MainWindow::createWidgets()
     connect(m_messageWidget->messageView, SIGNAL(messageChanged()), this, SLOT(scrollMessageUp()));
     connect(m_messageWidget->messageView, SIGNAL(messageChanged()), this, SLOT(slotUpdateMessageActions()));
     connect(m_messageWidget->messageView, SIGNAL(linkHovered(QString)), this, SLOT(slotShowLinkTarget(QString)));
+    connect(m_messageWidget->messageView, SIGNAL(addressDetailsRequested(QString,QStringList&)),
+            this, SLOT(fillMatchingAbookEntries(QString,QStringList&)));
     if (QSettings().value(Common::SettingsNames::appLoadHomepage, QVariant(true)).toBool() &&
         !QSettings().value(Common::SettingsNames::imapStartOffline).toBool()) {
         m_messageWidget->messageView->setHomepageUrl(QUrl(QString::fromUtf8("http://welcome.trojita.flaska.net/%1").arg(QCoreApplication::applicationVersion())));
@@ -867,6 +869,8 @@ void MainWindow::msgListDoubleClicked(const QModelIndex &index)
     Q_ASSERT(realModel == model);
 
     CompleteMessageWidget *widget = new CompleteMessageWidget();
+    connect(widget->messageView, SIGNAL(addressDetailsRequested(QString,QStringList&)),
+            this, SLOT(fillMatchingAbookEntries(QString,QStringList&)));
     widget->messageView->setMessage(index);
     widget->setFocusPolicy(Qt::StrongFocus);
     widget->setWindowTitle(message->envelope(model).subject);
@@ -1582,6 +1586,11 @@ void MainWindow::slotShowLinkTarget(const QString &link)
     }
 }
 
+void MainWindow::fillMatchingAbookEntries(const QString &mail, QStringList &displayNames)
+{
+    displayNames = addressBook()->prettyNamesForAddress(mail);
+}
+
 void MainWindow::slotShowAboutTrojita()
 {
     QMessageBox::about(this, trUtf8("About Trojitá"),
diff --git a/src/Gui/Window.h b/src/Gui/Window.h
index 7b9f02f..a59d4ff 100644
--- a/src/Gui/Window.h
+++ b/src/Gui/Window.h
@@ -139,6 +139,7 @@ private slots:
     void scrollMessageUp();
     void showConnectionStatus(QObject *parser, Imap::ConnectionState state);
     void slotShowLinkTarget(const QString &link);
+    void fillMatchingAbookEntries(const QString &mail, QStringList &displayNames);
     void slotShowAboutTrojita();
     void slotDonateToTrojita();
 



More information about the kde-doc-english mailing list