[SCM] ktp-contact-list packaging branch, master, updated. debian/15.12.1-2-1070-g6c56f91

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:05:52 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=07258dd

The following commit has been merged in the master branch:
commit 07258dd327a6197a0b30fbd914782ef515fc2c7b
Author: Keith Rusler <xzekecomax at gmail.com>
Date:   Fri Apr 8 18:11:10 2011 -0500

    Added tooltips to the contact list, so users can see information about the contact
    on mouse hover on that contact. Right now it supports the basics like status, account the contact
    is on, alias and personal message the contact uses.
---
 contact-delegate.cpp | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 contact-delegate.h   |  7 ++++
 main-widget.cpp      | 21 ++++++------
 3 files changed, 107 insertions(+), 12 deletions(-)

diff --git a/contact-delegate.cpp b/contact-delegate.cpp
index 73f37e4..89514d2 100644
--- a/contact-delegate.cpp
+++ b/contact-delegate.cpp
@@ -3,13 +3,17 @@
 #include <QtGui/QPainter>
 #include <QApplication>
 #include <QStyle>
+#include <QtGui/QToolTip>
 
 #include <KIconLoader>
 #include <KIcon>
 #include <KDebug>
 #include <KGlobalSettings>
+#include <KDE/KLocale>
 
 #include "accounts-model.h"
+#include "contact-model-item.h"
+#include <QHelpEvent>
 
 const int SPACING = 4;
 const int AVATAR_SIZE = 32;
@@ -224,3 +228,90 @@ void ContactDelegate::triggerRepaint()
 {
     emit repaintItem(m_indexForHiding);
 }
+
+bool ContactDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index)
+{
+    Q_UNUSED(option);
+
+    // Check and make sure that we only want it to work on contacts and nothing else.
+    if (index.data(AccountsModel::ItemRole).userType() != qMetaTypeId<ContactModelItem*>()) {
+        return false;
+    }
+
+    if (event->type() != QEvent::ToolTip) {
+        return false;
+    }
+
+    const QString contactAvatar = index.data(AccountsModel::AvatarRole).toString();
+    const QString displayName = index.parent().data(AccountsModel::DisplayNameRole).toString();
+    const QString cmIconPath = KIconLoader::global()->iconPath(index.parent().data(AccountsModel::IconRole).toString(), 1);
+    const QString alias = index.data(AccountsModel::AliasRole).toString();
+    const QString presenceStatus = index.data(AccountsModel::PresenceMessageRole).toString();
+    QString presenseIconPath;
+    QString presenseText;
+
+    switch (index.data(AccountsModel::PresenceTypeRole).toUInt()) {
+    case Tp::ConnectionPresenceTypeAvailable:
+        presenseIconPath = KIconLoader().iconPath("user-online", 1);
+        presenseText = i18n("Online");
+        break;
+    case Tp::ConnectionPresenceTypeAway:
+        presenseIconPath = KIconLoader().iconPath("user-away", 1);
+        presenseText = i18n("Away");
+        break;
+    case Tp::ConnectionPresenceTypeExtendedAway:
+        presenseIconPath = KIconLoader().iconPath("user-away-extended", 1);
+        presenseText = i18n("Away");
+        break;
+    case Tp::ConnectionPresenceTypeBusy:
+        presenseIconPath = KIconLoader().iconPath("user-busy", 1);
+        presenseText = i18n("Busy");
+        break;
+    case Tp::ConnectionPresenceTypeOffline:
+        presenseIconPath = KIconLoader().iconPath("user-offline", 1);
+        presenseText = i18n("Offline");
+        break;
+    default:
+        presenseIconPath = KIconLoader().iconPath("task-attention", 1);
+        // What presense Text should be here??
+        break;
+    }
+
+    /* The tooltip is composed of a HTML table to display the items in it of the contact.
+     * -------------------------
+     * | account it belongs to |
+     * -------------------------
+     * | Avatar | Con's Alias  |
+     * -------------------------
+     * |        | Con's Status*|
+     * -------------------------
+     * |  Contact is blocked*  |
+     * -------------------------
+     * * Display actual status name if contact has no custom status message.
+     * * Contact is blocked will only show if the contact is blocked, else no display.
+     */
+
+    QString table;
+    table += QString("<table><th colspan='2' align='center'><b>%1</b> <img src='%2' height='16' width='16' /> %3</th>").arg(i18n("Account:"), cmIconPath, displayName);
+    if (contactAvatar.isEmpty()) {
+        table += "<tr><td></td>";
+    } else {
+        table += QString("<tr><td><img src='%1' /></td>").arg(contactAvatar);
+    }
+    table += "<td><table><tr>";
+    table += QString("<td align='right'><b>%1</b></td>").arg(i18n("Alias:"));
+    table += QString("<td>%1</td></tr>").arg(alias);
+    table += QString("<tr><td align='right'><b>%1</b></td>").arg(i18n("Status:"));
+    if (presenceStatus.isEmpty()) {
+        table += QString("<td><img src='%1' height='16' width='16' /> %2</td></tr>").arg(presenseIconPath, presenseText);
+    } else {
+        table += QString("<td><img src='%1' height='16' width='16' /> %2</td></tr>").arg(presenseIconPath, presenceStatus);
+    }
+    if (index.data(AccountsModel::BlockedRole).toBool()) {
+        table += QString("<td colspan='2'>%1</td></tr>").arg(i18n("User is blocked"));
+    }
+    table += "</table></td><tr></table>";
+    QToolTip::showText(QCursor::pos(), table, view);
+
+    return true;
+}
diff --git a/contact-delegate.h b/contact-delegate.h
index 20daa62..2a3703d 100644
--- a/contact-delegate.h
+++ b/contact-delegate.h
@@ -25,6 +25,13 @@ public Q_SLOTS:
     void reshowStatusMessageSlot();
     void fadeOutStatusMessageSlot();
     void triggerRepaint();
+    /**
+     * Reimplements the help tooltip for the contact delegate.
+     *
+     * When the user hovers over a contact it will display their information like Alias, which contact belongs to what account,
+     * is this contact blocked, their status message if their is one, etc.
+     */
+    bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index);
 
 Q_SIGNALS:
     void repaintItem(QModelIndex);
diff --git a/main-widget.cpp b/main-widget.cpp
index 7bde815..a24ccf0 100644
--- a/main-widget.cpp
+++ b/main-widget.cpp
@@ -562,19 +562,16 @@ void MainWidget::onCustomContextMenuRequested(const QPoint &)
 
     //menu->addSeparator();
 
-    // TODO Remove when Telepathy actually supports blocking.
+    // TODO: Remove when Telepathy actually supports blocking.
     /*if (contact->isBlocked()) {
-     *        action = menu->addAction(i18n("Unlock User"));
-     *        connect(action, SIGNAL(triggered(bool)),
-     T p::Avatar avatar = m_model->data(m_modelFilter->mapToSource(m_modelFilter->index(0, 0)*),
-     AccountsModel::AvatarRole).value<Tp::Avatar>();
-     icon.addPixmap(QPixmap::fromImage(QImage::fromData(avatar.avatarData)).scaled(64, 64));
-     *                SLOT(slotUnblockContactTriggered()));
-} else {
-    action = menu->addAction(i18n("Block User"));
-    connect(action, SIGNAL(triggered(bool)),
-    SLOT(slotBlockContactTriggered()));
-}*/
+        action = menu->addAction(i18n("Unblock User"));
+        connect(action, SIGNAL(triggered(bool)),
+                SLOT(slotUnblockContactTriggered()));
+    } else {
+        action = menu->addAction(i18n("Blocked"));
+        connect(action, SIGNAL(triggered(bool)),
+                SLOT(slotBlockContactTriggered()));
+    }*/
 
     menu->exec(QCursor::pos());
 }

-- 
ktp-contact-list packaging



More information about the pkg-kde-commits mailing list