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


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

The following commit has been merged in the master branch:
commit dfbf9b79fa2e8364972889e40ee3de49d9e71b32
Author: Siddhartha Sahu <sh.siddhartha at gmail.com>
Date:   Thu Oct 24 22:21:58 2013 +0530

    Add Declarative support for showing only one active chat
    
    REVIEW: 113354
---
 KTp/Declarative/conversations-model.cpp | 25 ++++++++++++++++++++-----
 KTp/Declarative/conversations-model.h   |  5 +++++
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/KTp/Declarative/conversations-model.cpp b/KTp/Declarative/conversations-model.cpp
index 630d403..4e3489a 100644
--- a/KTp/Declarative/conversations-model.cpp
+++ b/KTp/Declarative/conversations-model.cpp
@@ -37,6 +37,7 @@ class ConversationsModel::ConversationsModelPrivate
 {
   public:
     QList<Conversation*> conversations;
+    int activeChatIndex;
 };
 
 ConversationsModel::ConversationsModel(QObject *parent) :
@@ -47,6 +48,7 @@ ConversationsModel::ConversationsModel(QObject *parent) :
     QHash<int, QByteArray> roles;
     roles[ConversationRole] = "conversation";
     setRoleNames(roles);
+    d->activeChatIndex = -1;
     connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), SIGNAL(totalUnreadCountChanged()));
     connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), SIGNAL(totalUnreadCountChanged()));
 }
@@ -101,24 +103,26 @@ void ConversationsModel::handleChannels(const Tp::MethodInvocationContextPtr<> &
 
     Q_ASSERT(textChannel);
 
-
     //find the relevant channelRequest
     Q_FOREACH(const Tp::ChannelRequestPtr channelRequest, channelRequests) {
         kDebug() << channelRequest->hints().allHints();
         shouldDelegate = channelRequest->hints().hint(QLatin1String("org.freedesktop.Telepathy.ChannelRequest"), QLatin1String("DelegateToPreferredHandler")).toBool();
     }
 
-
     //loop through all conversations checking for matches
 
     //if we are handling and we're not told to delegate it, update the text channel
     //if we are handling but should delegate, call delegate channel
+    int i = 0;
     Q_FOREACH(Conversation *convo, d->conversations) {
         if (convo->target()->id() == textChannel->targetId() &&
                 convo->textChannel()->targetHandleType() == textChannel->targetHandleType())
         {
             if (!shouldDelegate) {
                 convo->setTextChannel(textChannel);
+                //Update the active chat index to this channel
+                d->activeChatIndex = i;
+                Q_EMIT activeChatIndexChanged();
             } else {
                 if (convo->textChannel() == textChannel) {
                     convo->delegateToProperClient();
@@ -127,21 +131,27 @@ void ConversationsModel::handleChannels(const Tp::MethodInvocationContextPtr<> &
             handled = true;
             break;
         }
+        i++;
     }
 
     //if we are not handling channel already and should not delegate, add the conversation
     //if we not handling the channel but should delegate it, do nothing.
-
     if (!handled && !shouldDelegate) {
         beginInsertRows(QModelIndex(), rowCount(), rowCount());
         Conversation *newConvo = new Conversation(textChannel, account, this);
-        d->conversations.append(newConvo);
         connect(newConvo, SIGNAL(conversationCloseRequested()), SLOT(onConversationCloseRequested()));
         connect(newConvo->messages(), SIGNAL(unreadCountChanged(int)), SIGNAL(totalUnreadCountChanged()));
+        d->conversations.append(newConvo);
         endInsertRows();
+
+        //If this is a locally generated request or there is no active chat, the index of the newly inserted conversation is saved as the active chat
+        //The model is reset to load the newly created chat channel
+        if(textChannel->isRequested() || d->activeChatIndex == -1) {
+            d->activeChatIndex = rowCount() - 1;
+            Q_EMIT activeChatIndexChanged();
+        }
         context->setFinished();
     }
-
 }
 
 bool ConversationsModel::bypassApproval() const
@@ -192,3 +202,8 @@ int ConversationsModel::totalUnreadCount() const
     }
     return ret;
 }
+
+int ConversationsModel::activeChatIndex() const
+{
+    return d->activeChatIndex;
+}
diff --git a/KTp/Declarative/conversations-model.h b/KTp/Declarative/conversations-model.h
index 1691238..7f128b3 100644
--- a/KTp/Declarative/conversations-model.h
+++ b/KTp/Declarative/conversations-model.h
@@ -31,6 +31,7 @@ class ConversationsModel : public QAbstractListModel, public Tp::AbstractClientH
 {
     Q_OBJECT
     Q_PROPERTY(int totalUnreadCount READ totalUnreadCount NOTIFY totalUnreadCountChanged)
+    Q_PROPERTY(int activeChatIndex READ activeChatIndex NOTIFY activeChatIndexChanged)
 
   public:
     explicit ConversationsModel(QObject *parent=0);
@@ -42,6 +43,9 @@ class ConversationsModel : public QAbstractListModel, public Tp::AbstractClientH
     /** @returns the sum of all unread messages among all conversations */
     int totalUnreadCount() const;
 
+    /** @returns the index of the active chat, ie one the user is interacting with */
+    int activeChatIndex() const;
+
     enum role {
         ConversationRole = Qt::UserRole
     };
@@ -69,6 +73,7 @@ class ConversationsModel : public QAbstractListModel, public Tp::AbstractClientH
 
   Q_SIGNALS:
       void totalUnreadCountChanged();
+      void activeChatIndexChanged();
 };
 
 #endif // CONVERSATIONS_MODEL_H

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list