[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:04 UTC 2016


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

The following commit has been merged in the master branch:
commit a5f7ab674e6f8d9bfe28df283f321c069bb7543f
Author: Martin Klapetek <martin.klapetek at gmail.com>
Date:   Wed Feb 23 13:33:11 2011 +0100

    Show only those capabilities in the overlay, that are acutaly present.
---
 contactoverlays.cpp   | 133 ++++++++++++++++++++++++++++++++++++++++++++++----
 contactoverlays.h     |  36 ++++++++++++++
 fakecontactsmodel.cpp |   3 +-
 main-widget.cpp       |   9 +++-
 4 files changed, 169 insertions(+), 12 deletions(-)

diff --git a/contactoverlays.cpp b/contactoverlays.cpp
index 4f73373..54f6c0f 100644
--- a/contactoverlays.cpp
+++ b/contactoverlays.cpp
@@ -28,6 +28,8 @@
 #include <KIconLoader>
 #include <KDebug>
 
+#include <TelepathyQt4/ContactCapabilities>
+
 class TextChannelContactOverlay::Button : public ContactViewHoverButton
 {
 public:
@@ -130,11 +132,11 @@ void TextChannelContactOverlay::slotClicked(bool checked)
 
 bool TextChannelContactOverlay::checkIndex(const QModelIndex& index) const
 {
-    if(index.data(ModelRoles::UserStatusRole).value<Tp::ConnectionPresenceType>() == Tp::ConnectionPresenceTypeOffline) {
-        return false;
+    if(index.data(ModelRoles::ContactCapabilities).value<Tp::ContactCapabilities>().textChats()) {
+        return true;
     }
     
-    return true;
+    return false;
 }
 
 // ------------------------------------------------------------------------
@@ -242,11 +244,11 @@ void AudioChannelContactOverlay::slotClicked(bool checked)
 
 bool AudioChannelContactOverlay::checkIndex(const QModelIndex& index) const
 {
-    if(index.data(ModelRoles::UserStatusRole).value<Tp::ConnectionPresenceType>() == Tp::ConnectionPresenceTypeOffline) {
-        return false;
+    if(index.data(ModelRoles::ContactCapabilities).value<Tp::ContactCapabilities>().streamedMediaAudioCalls()) {
+        return true;
     }
-
-    return true;
+    
+    return false;
 }
 
 // ----------------------------------------------------------
@@ -353,9 +355,120 @@ void VideoChannelContactOverlay::slotClicked(bool checked)
 
 bool VideoChannelContactOverlay::checkIndex(const QModelIndex& index) const
 {
-    if(index.data(ModelRoles::UserStatusRole).value<Tp::ConnectionPresenceType>() == Tp::ConnectionPresenceTypeOffline) {
-        return false;
+    if(index.data(ModelRoles::ContactCapabilities).value<Tp::ContactCapabilities>().streamedMediaVideoCallsWithAudio()) {
+        return true;
+    }
+    
+    return false;
+}
+
+// ----------------------------------------------------------
+
+class FileTransferContactOverlay::Button : public ContactViewHoverButton
+{
+public:
+    
+    Button(QAbstractItemView* parentView, const KGuiItem& gui);
+    virtual QSize sizeHint() const;
+    
+protected:
+    
+    KGuiItem gui;
+    
+    virtual QPixmap icon();
+    virtual void updateToolTip();
+    
+};
+
+FileTransferContactOverlay::Button::Button(QAbstractItemView* parentView, const KGuiItem& gui)
+: ContactViewHoverButton(parentView), gui(gui)
+{
+}
+
+QSize FileTransferContactOverlay::Button::sizeHint() const
+{
+    return QSize(KIconLoader::SizeSmall, KIconLoader::SizeSmall);
+}
+
+QPixmap FileTransferContactOverlay::Button::icon()
+{
+    return KIconLoader::global()->loadIcon(gui.iconName(),
+                                           KIconLoader::NoGroup,
+                                           KIconLoader::SizeSmall);
+}
+
+void FileTransferContactOverlay::Button::updateToolTip()
+{
+    setToolTip(gui.toolTip());
+}
+
+// -------------------------------------------------------------------------
+
+FileTransferContactOverlay::FileTransferContactOverlay(QObject* parent)
+: HoverButtonDelegateOverlay(parent),
+m_referenceModel(0)
+{
+    m_gui = KGuiItem(i18n("Send file"), "mail-attachment", 
+                     i18n("Send file"), i18n("Whats this"));          
+}
+
+FileTransferContactOverlay::Button *FileTransferContactOverlay::button() const
+{
+    return static_cast<Button*>(HoverButtonDelegateOverlay::button());
+}
+
+void FileTransferContactOverlay::setReferenceModel(const FakeContactsModel* model)
+{
+    m_referenceModel = model;
+}
+
+void FileTransferContactOverlay::setActive(bool active)
+{
+    HoverButtonDelegateOverlay::setActive(active);
+    
+    if (active)
+    {
+        connect(button(), SIGNAL(clicked(bool)),
+                this, SLOT(slotClicked(bool)));
+    }
+    else
+    {
+        // button is deleted
+    }
+}
+
+ContactViewHoverButton* FileTransferContactOverlay::createButton()
+{
+    return new Button(view(), m_gui);
+}
+
+void FileTransferContactOverlay::updateButton(const QModelIndex& index)
+{
+    const QRect rect = m_view->visualRect(index);
+    const QSize size = button()->size();
+    
+    const int gap = 5;
+    const int x   = rect.right() - gap - 132 - size.width();
+    const int y   = rect.bottom() - gap - size.height();
+    button()->move(QPoint(x, y));
+}
+
+void FileTransferContactOverlay::slotClicked(bool checked)
+{
+    Q_UNUSED(checked);
+    QModelIndex index = button()->index();
+    
+    if (index.isValid())
+    {
+        //emit activated(index);
+    }
+}
+
+bool FileTransferContactOverlay::checkIndex(const QModelIndex& index) const
+{
+    if(index.data(ModelRoles::ContactCapabilities).value<Tp::ContactCapabilities>().fileTransfers()) {
+        return true;
     }
     
-    return true;
+    return false;
 }
\ No newline at end of file
diff --git a/contactoverlays.h b/contactoverlays.h
index 9b4aa13..1db34ca 100644
--- a/contactoverlays.h
+++ b/contactoverlays.h
@@ -139,4 +139,40 @@ protected:
     Button *button() const;
 };
 
+// ---------------------------------------------------------------------
+
+class FileTransferContactOverlay : public HoverButtonDelegateOverlay
+{
+    Q_OBJECT
+    
+public:
+    
+    FileTransferContactOverlay(QObject* parent);
+    virtual void setActive(bool active);
+    
+    void setReferenceModel(const FakeContactsModel* model);
+    
+Q_SIGNALS:
+    
+    //void activated(const ImageInfo& info);
+    
+protected:
+    
+    virtual ContactViewHoverButton* createButton();
+    virtual void updateButton(const QModelIndex& index);
+    virtual bool checkIndex(const QModelIndex& index) const;
+    
+protected Q_SLOTS:
+    
+    void slotClicked(bool checked);
+    
+protected:
+    
+    KGuiItem                 m_gui;
+    const FakeContactsModel* m_referenceModel;
+    
+    class Button;
+    Button *button() const;
+};
+
 #endif // VERSIONSOVERLAYS_H
diff --git a/fakecontactsmodel.cpp b/fakecontactsmodel.cpp
index 66c5953..08d565a 100644
--- a/fakecontactsmodel.cpp
+++ b/fakecontactsmodel.cpp
@@ -25,6 +25,7 @@
 #include <TelepathyQt4/PendingReady>
 #include <TelepathyQt4/PendingContacts>
 #include <TelepathyQt4/AvatarData>
+#include <TelepathyQt4/ContactCapabilities>
 
 #include "fakecontactsmodel.h"
 
@@ -174,7 +175,7 @@ QVariant FakeContactsModel::data(const QModelIndex& index, int role) const
         }
         else if(role == ModelRoles::ContactCapabilities)
         {
-            return qVariantFromValue<Tp::ConnectionCapabilities>(contact->data()->capabilities());
+            return QVariant::fromValue<Tp::ContactCapabilities>(contact->data()->capabilities());
         }
     }
     else 
diff --git a/main-widget.cpp b/main-widget.cpp
index 5536012..1a8a694 100644
--- a/main-widget.cpp
+++ b/main-widget.cpp
@@ -307,7 +307,8 @@ MainWidget::MainWidget(QWidget *parent)
     
     Tp::ContactFactoryPtr contactFactory = Tp::ContactFactory::create(Tp::Features()  << Tp::Contact::FeatureAlias
                                                                       << Tp::Contact::FeatureAvatarData
-                                                                      << Tp::Contact::FeatureSimplePresence);
+                                                                      << Tp::Contact::FeatureSimplePresence
+                                                                      << Tp::Contact::FeatureCapabilities);
     
     Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());
     
@@ -602,9 +603,12 @@ void MainWidget::addActionOverlay()
         AudioChannelContactOverlay* audioOverlay = new AudioChannelContactOverlay(this);
         VideoChannelContactOverlay* videoOverlay = new VideoChannelContactOverlay(this);
         
+        FileTransferContactOverlay* fileOverlay = new FileTransferContactOverlay(this);
+        
         m_delegate->installOverlay(textOverlay);
         m_delegate->installOverlay(audioOverlay);
         m_delegate->installOverlay(videoOverlay);
+        m_delegate->installOverlay(fileOverlay);
         
         textOverlay->setView(m_contactsListView);
         textOverlay->setActive(true);
@@ -615,6 +619,9 @@ void MainWidget::addActionOverlay()
         videoOverlay->setView(m_contactsListView);
         videoOverlay->setActive(true);
         
+        fileOverlay->setView(m_contactsListView);
+        fileOverlay->setActive(true);
+        
         connect(textOverlay, SIGNAL(overlayActivated(QModelIndex)),
                 m_delegate, SLOT(hideStatusMessageSlot(QModelIndex)));
         

-- 
ktp-contact-list packaging



More information about the pkg-kde-commits mailing list