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


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

The following commit has been merged in the master branch:
commit a72952953fcc8f16c71ccb3bed1a2fde5e9fde7b
Author: George Goldberg <grundleborg at googlemail.com>
Date:   Sun Jul 19 15:01:02 2009 +0000

    Tidy up the code a bit.
    - Use kdelibs coding style consistently.
    - Remove some cruft.
    - Make method names a bit more sensible.
    - Use ASSERTS properly so that non-debug builds give a warning where they happen.
    
    svn path=/trunk/playground/network/telepathy-accounts-kcm/; revision=999269
---
 KTp/Models/accounts-list-model.cpp | 82 ++++++++++++++++++++++++--------------
 KTp/Models/accounts-list-model.h   |  2 +-
 2 files changed, 53 insertions(+), 31 deletions(-)

diff --git a/KTp/Models/accounts-list-model.cpp b/KTp/Models/accounts-list-model.cpp
index 1ae396f..d67e3f1 100644
--- a/KTp/Models/accounts-list-model.cpp
+++ b/KTp/Models/accounts-list-model.cpp
@@ -22,8 +22,8 @@
 
 #include "account-item.h"
 
-#include <kcategorizedsortfilterproxymodel.h>
-#include <kdebug.h>
+#include <KCategorizedSortFilterProxyModel>
+#include <KDebug>
 
 #include <TelepathyQt4/Account>
 
@@ -41,11 +41,13 @@ AccountsListModel::~AccountsListModel()
 
 int AccountsListModel::rowCount(const QModelIndex &index) const
 {
-    if(index == QModelIndex())
-    {
+    // If the index is the root item, then return the row count.
+    if (index == QModelIndex()) {
        return m_readyAccounts.size();
     }
 
+    // Otherwise, return 0 (as this is a list model, so all items
+    // are children of the root item).
     return 0;
 }
 
@@ -90,75 +92,95 @@ QVariant AccountsListModel::data(const QModelIndex &index, int role) const
 void AccountsListModel::addAccount(Tp::AccountPtr account)
 {
     kDebug() << "Creating a new AccountItem from account:" << account.data();
+
     // Check if the account is already in the model.
     bool found = false;
 
-    foreach(const AccountItem* ai, m_unreadyAccounts)
-    {
-        if(ai->account() == account)
-        {
+    foreach (const AccountItem* ai, m_unreadyAccounts) {
+        if (ai->account() == account) {
             found = true;
             break;
         }
     }
-    if(!found)
-    {
-        foreach(const AccountItem* ai, m_readyAccounts)
-        {
-            if(ai->account() == account)
-            {
+
+    if (!found) {
+        foreach (const AccountItem* ai, m_readyAccounts) {
+            if (ai->account() == account) {
                 found = true;
                 break;
             }
         }
     }
 
-    if(found)
-    {
-       kDebug() << "Requested to add account"
-               << account
-               << "to model, but it is already present. Doing nothing.";
-   }
-   else
-   {
+    if (found) {
+       kWarning() << "Requested to add account"
+                  << account.data()
+                  << "to model, but it is already present. Doing nothing.";
+   } else {
+       kDebug() << "Account not already in model. Create new AccountItem from account:"
+                << account.data();
+
        AccountItem *item = new AccountItem(account, this);
        m_unreadyAccounts.append(item);
-       connect(item, SIGNAL(ready()), this, SLOT(onAccountItemReady()));
-       connect(item, SIGNAL(removed()), this, SLOT(onAccountItemRemoved()));
-       connect(item, SIGNAL(updated()), this, SLOT(onAccountItemUpdated()));
+       connect(item, SIGNAL(ready()), SLOT(onAccountItemReady()));
+       connect(item, SIGNAL(removed()), SLOT(onAccountItemRemoved()));
+       connect(item, SIGNAL(updated()), SLOT(onAccountItemUpdated()));
    }
 }
 
 void AccountsListModel::onAccountItemReady()
 {
     AccountItem *item = qobject_cast<AccountItem*>(sender());
+
     Q_ASSERT(item);
+    if (!item) {
+        kWarning() << "Not an AccountItem pointer:" << sender();
+        return;
+    }
+
     Q_ASSERT(m_unreadyAccounts.contains(item));
+    if (!m_unreadyAccounts.contains(item)) {
+        kWarning() << "Unready Accounts list does not contain Account Item:" << item;
+        return;
+    }
+
     Q_ASSERT(!m_readyAccounts.contains(item));
+    if (m_readyAccounts.contains(item)) {
+        kWarning() << "Ready Accounts list already contains Account Item:" << item;
+        return;
+    }
 
     beginInsertRows(QModelIndex(), m_readyAccounts.size(), m_readyAccounts.size());
     m_readyAccounts.append(item);
     m_unreadyAccounts.removeAll(item);
     endInsertRows();
-
-    Q_ASSERT(!m_unreadyAccounts.contains(item));
-    Q_ASSERT(m_readyAccounts.contains(item));
 }
 
 void AccountsListModel::onAccountItemRemoved()
 {
     AccountItem *item = qobject_cast<AccountItem*>(sender());
+
     Q_ASSERT(item);
-    Q_ASSERT(!m_unreadyAccounts.contains(item));
-    Q_ASSERT(m_readyAccounts.contains(item));
+    if (!item) {
+        kWarning() << "Not an AccountItem pointer:" << sender();
+        return;
+    }
 
     beginRemoveRows(QModelIndex(), m_readyAccounts.lastIndexOf(item)-1,
                     m_readyAccounts.lastIndexOf(item)-1);
     m_readyAccounts.removeAll(item);
+    m_unreadyAccounts.removeAll(item);
     endRemoveRows();
 
     Q_ASSERT(!m_readyAccounts.contains(item));
+    if (m_readyAccounts.contains(item)) {
+        kWarning() << "Ready Accounts still contains Accout Item:" << item;
+    }
+
     Q_ASSERT(!m_unreadyAccounts.contains(item));
+    if (m_unreadyAccounts.contains(item)) {
+        kWarning() << "Unready Accounts still contains Account Item:" << item;
+    }
 }
 
 void AccountsListModel::onAccountItemUpdated()
diff --git a/KTp/Models/accounts-list-model.h b/KTp/Models/accounts-list-model.h
index d46eac5..016c2e1 100644
--- a/KTp/Models/accounts-list-model.h
+++ b/KTp/Models/accounts-list-model.h
@@ -47,8 +47,8 @@ private Q_SLOTS:
 private:
     QList<AccountItem*> m_unreadyAccounts;
     QList<AccountItem*> m_readyAccounts;
-
 };
 
+
 #endif // header guard
 

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list