[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9

Maximiliano Curia maxy at moszumanska.debian.org
Mon May 9 09:04:56 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=0ca5329

The following commit has been merged in the master branch:
commit 0ca532989fa675cc0a9ace4633600429e584a55a
Author: Lasath Fernando <kde at lasath.org>
Date:   Mon Feb 6 22:50:25 2012 +1100

    Make MessagesModel automaticall remove invalided chats and Implement close button
---
 KTp/Declarative/conversation.cpp        | 29 ++++++++++++++++++++++++++++-
 KTp/Declarative/conversation.h          | 12 ++++++++++++
 KTp/Declarative/conversations-model.cpp | 14 ++++++++++++++
 KTp/Declarative/conversations-model.h   |  1 +
 KTp/Declarative/messages-model.cpp      |  9 +++++++++
 KTp/Declarative/messages-model.h        |  4 +++-
 6 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/KTp/Declarative/conversation.cpp b/KTp/Declarative/conversation.cpp
index 89cd4e8..48193dc 100644
--- a/KTp/Declarative/conversation.cpp
+++ b/KTp/Declarative/conversation.cpp
@@ -29,9 +29,12 @@ class Conversation::ConversationPrivate
 public:
     MessagesModel *messages;
     ConversationTarget *target;
+    bool valid;
 };
 
-Conversation::Conversation(const Tp::TextChannelPtr& channel, const Tp::AccountPtr& account, QObject *parent) :
+Conversation::Conversation(const Tp::TextChannelPtr& channel,
+                           const Tp::AccountPtr& account,
+                           QObject *parent) :
         QObject(parent),
         d (new ConversationPrivate)
 {
@@ -41,6 +44,10 @@ Conversation::Conversation(const Tp::TextChannelPtr& channel, const Tp::AccountP
     d->messages->setTextChannel(channel);
 
     d->target = new ConversationTarget(channel->targetContact(), this);
+
+    d->valid = channel->isValid();
+    connect(channel.data(), SIGNAL(invalidated(Tp::DBusProxy*,QString,QString)),
+            SLOT(invalidate(Tp::DBusProxy*,QString,QString)));
 }
 
 Conversation::Conversation(QObject *parent) : QObject(parent)
@@ -59,6 +66,26 @@ ConversationTarget* Conversation::target() const
     return d->target;
 }
 
+bool Conversation::isValid()
+{
+    return d->valid;
+}
+
+void Conversation::invalidate(Tp::DBusProxy* proxy, const QString& errorName, const QString& errorMessage)
+{
+    kDebug() << proxy << errorName << ":" << errorMessage;
+
+    d->valid = false;
+
+    Q_EMIT validityChanged(d->valid);
+}
+
+void Conversation::requestClose()
+{
+    kDebug();
+    d->messages->requestClose();
+}
+
 Conversation::~Conversation()
 {
     kDebug();
diff --git a/KTp/Declarative/conversation.h b/KTp/Declarative/conversation.h
index a072a51..3c491c7 100644
--- a/KTp/Declarative/conversation.h
+++ b/KTp/Declarative/conversation.h
@@ -38,6 +38,7 @@ Q_OBJECT
 
 Q_PROPERTY(ConversationTarget* target READ target CONSTANT);
 Q_PROPERTY(MessagesModel* messages READ messages CONSTANT);
+Q_PROPERTY(bool valid READ isValid NOTIFY validityChanged);
 
 public:
     Conversation(const Tp::TextChannelPtr &channel, const Tp::AccountPtr &account, QObject *parent = 0);
@@ -47,6 +48,17 @@ public:
     MessagesModel* messages() const;
     ConversationTarget* target() const;
 
+    bool isValid();
+
+Q_SIGNALS:
+    void validityChanged(bool isValid);
+
+public Q_SLOTS:
+    void requestClose();
+
+private Q_SLOTS:
+    void invalidate(Tp::DBusProxy *proxy, const QString &errorName, const QString &errorMessage);
+
 private:
     class ConversationPrivate;
     ConversationPrivate *d;
diff --git a/KTp/Declarative/conversations-model.cpp b/KTp/Declarative/conversations-model.cpp
index ad13f67..c46f8f6 100644
--- a/KTp/Declarative/conversations-model.cpp
+++ b/KTp/Declarative/conversations-model.cpp
@@ -83,10 +83,24 @@ void ConversationsModel::onInconmingConversation(Conversation *newConvo)
     if (!handled) {
         beginInsertRows(QModelIndex(), rowCount(), rowCount());
         d->conversations.append(newConvo);
+        connect(newConvo, SIGNAL(validityChanged(bool)), SLOT(handleValidityChange(bool)));
         endInsertRows();
     }
 }
 
+void ConversationsModel::handleValidityChange(bool valid)
+{
+    if(!valid) {
+        Conversation* sender = qobject_cast<Conversation*>(QObject::sender());
+        int index = d->conversations.indexOf(sender);
+        beginRemoveRows(QModelIndex(), index, index);
+
+        d->conversations.removeAt(index);
+        sender->deleteLater();
+        endRemoveRows();
+    }
+}
+
 ConversationsModel::~ConversationsModel()
 {
     delete d;
diff --git a/KTp/Declarative/conversations-model.h b/KTp/Declarative/conversations-model.h
index 6d38c3d..a4c0f03 100644
--- a/KTp/Declarative/conversations-model.h
+++ b/KTp/Declarative/conversations-model.h
@@ -47,6 +47,7 @@ private:
 
 private Q_SLOTS:
     void onInconmingConversation(Conversation *convo);
+    void handleValidityChange(bool);
 };
 
 #endif // CONVERSATIONS_MODEL_H
diff --git a/KTp/Declarative/messages-model.cpp b/KTp/Declarative/messages-model.cpp
index 3b4d4db..4d0667c 100644
--- a/KTp/Declarative/messages-model.cpp
+++ b/KTp/Declarative/messages-model.cpp
@@ -282,6 +282,15 @@ MessagesModel::~MessagesModel()
     delete d;
 }
 
+void MessagesModel::requestClose()
+{
+    kDebug();
+
+    Tp::PendingOperation *op = d->textChannel->requestClose();
+    connect(op, SIGNAL(finished(Tp::PendingOperation*)),
+            SLOT(verifyPendingOperation(Tp::PendingOperation*)));
+}
+
 void MessagesModel::printallmessages()
 {
     Q_FOREACH(MessageItem msg, d->messages) {
diff --git a/KTp/Declarative/messages-model.h b/KTp/Declarative/messages-model.h
index 8da3626..4ae99d3 100644
--- a/KTp/Declarative/messages-model.h
+++ b/KTp/Declarative/messages-model.h
@@ -51,8 +51,10 @@ public:
     bool isVisibleToUser() const;
     void setVisibleToUser(bool visible);
 
+    int  unreadCount() const;
     void acknowledgeAllMessages();
-    int unreadCount() const;
+
+    void requestClose();
 
     //debug function. will do whatever I feel like at the time ;-)
     Q_INVOKABLE void printallmessages();

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list