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


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

The following commit has been merged in the master branch:
commit 5ffc4813c8e89b0982a9b42a84449ec6a4195656
Author: Dan Vrátil <dvratil at redhat.com>
Date:   Wed Sep 11 14:18:24 2013 +0200

    Add modelInitialized() signal to KTp::ContactsModel
    
    REVIEW: 112599
---
 KTp/Models/contacts-list-model.cpp | 30 ++++++++++++++++++++++++++++++
 KTp/Models/contacts-list-model.h   |  3 +++
 KTp/Models/contacts-model.cpp      |  6 ++++++
 KTp/Models/contacts-model.h        |  1 +
 4 files changed, 40 insertions(+)

diff --git a/KTp/Models/contacts-list-model.cpp b/KTp/Models/contacts-list-model.cpp
index 9a1b532..8dc545b 100644
--- a/KTp/Models/contacts-list-model.cpp
+++ b/KTp/Models/contacts-list-model.cpp
@@ -23,6 +23,8 @@
 #include <TelepathyQt/ContactCapabilities>
 #include <TelepathyQt/Connection>
 #include <TelepathyQt/ContactManager>
+#include <TelepathyQt/AccountSet>
+#include <KDebug>
 
 #include "contact.h"
 #include "presence.h"
@@ -31,8 +33,14 @@
 class KTp::ContactsListModel::Private
 {
 public:
+    Private():
+        initialized(false)
+    {
+    }
+
     QList<Tp::ContactPtr> contacts;
     KTp::GlobalContactManager *contactManager;
+    bool initialized;
 };
 
 
@@ -52,6 +60,23 @@ void KTp::ContactsListModel::setAccountManager(const Tp::AccountManagerPtr &acco
 {
     d->contactManager = new KTp::GlobalContactManager(accountManager, this);
     connect(d->contactManager, SIGNAL(allKnownContactsChanged(Tp::Contacts,Tp::Contacts)), SLOT(onContactsChanged(Tp::Contacts,Tp::Contacts)));
+
+    // If there are no enabled account or no account is online, emit the signal
+    // directly, because onContactsChanged won't be called
+    const QList<Tp::AccountPtr> accounts = accountManager->enabledAccounts()->accounts();
+    if (accounts.isEmpty()) {
+        d->initialized = true;
+        Q_EMIT modelInitialized();
+    } else {
+        Q_FOREACH (const Tp::AccountPtr &account, accounts) {
+            if (account->isOnline()) {
+                return;
+            }
+        }
+
+        d->initialized = true;
+        Q_EMIT modelInitialized();
+    }
 }
 
 int KTp::ContactsListModel::rowCount(const QModelIndex &parent) const
@@ -200,6 +225,11 @@ void KTp::ContactsListModel::onContactsChanged(const Tp::Contacts &added, const
             endRemoveRows();
         }
     }
+
+    if (!d->initialized) {
+        Q_EMIT modelInitialized();
+        d->initialized = true;
+    }
 }
 
 void KTp::ContactsListModel::onChanged()
diff --git a/KTp/Models/contacts-list-model.h b/KTp/Models/contacts-list-model.h
index 876a485..dc3e63f 100644
--- a/KTp/Models/contacts-list-model.h
+++ b/KTp/Models/contacts-list-model.h
@@ -40,6 +40,9 @@ public:
     int rowCount(const QModelIndex &parent) const;
     QVariant data(const QModelIndex &index, int role) const;
 
+Q_SIGNALS:
+    void modelInitialized();
+
 private Q_SLOTS:
     void onContactsChanged(const Tp::Contacts &added, const Tp::Contacts &removed);
     void onChanged();
diff --git a/KTp/Models/contacts-model.cpp b/KTp/Models/contacts-model.cpp
index 8a1b0d6..f03ad45 100644
--- a/KTp/Models/contacts-model.cpp
+++ b/KTp/Models/contacts-model.cpp
@@ -78,6 +78,9 @@ KTp::ContactsModel::ContactsModel(QObject *parent)
                                                             << KPeople::PersonsModelFeature::groupsModelFeature()
                                                             << KPeople::PersonsModelFeature::fullNameModelFeature()
                                                             << KPeople::PersonsModelFeature::nicknameModelFeature());
+        connect(personsModel, SIGNAL(modelInitialized()),
+                this, SIGNAL(modelInitialized()));
+
         d->source = new KPeopleTranslationProxy(this);
         qobject_cast<KPeopleTranslationProxy*>(d->source)->setSourceModel(personsModel);
         #endif
@@ -86,7 +89,10 @@ KTp::ContactsModel::ContactsModel(QObject *parent)
     {
         kDebug() << "Nepomuk is disabled, using normal model";
         d->source = new KTp::ContactsListModel(this);
+        connect(d->source, SIGNAL(modelInitialized()),
+                this, SIGNAL(modelInitialized()));
     }
+
 }
 
 KTp::ContactsModel::~ContactsModel()
diff --git a/KTp/Models/contacts-model.h b/KTp/Models/contacts-model.h
index 345378b..e6fb7b1 100644
--- a/KTp/Models/contacts-model.h
+++ b/KTp/Models/contacts-model.h
@@ -79,6 +79,7 @@ protected:
     virtual void setSourceModel(QAbstractItemModel *sourceModel);
 
 Q_SIGNALS:
+    void modelInitialized();
     void groupModeChanged();
     void trackUnreadMessagesChanged();
 

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list