[SCM] ktp-accounts-kcm packaging branch, master, updated. debian/15.12.1-1-1157-gc4589c5
Maximiliano Curia
maxy at moszumanska.debian.org
Fri May 27 23:57:13 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-accounts-kcm.git;a=commitdiff;h=21f87e4
The following commit has been merged in the master branch:
commit 21f87e4014d5607a61e3af467f258caff5100041
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
---
src/account-item.cpp | 25 +++++++------
src/account-item.h | 4 +--
src/accounts-list-model.cpp | 82 ++++++++++++++++++++++++++----------------
src/accounts-list-model.h | 2 +-
src/kcm-telepathy-accounts.cpp | 40 +++++++++------------
src/kcm-telepathy-accounts.h | 11 +++---
6 files changed, 88 insertions(+), 76 deletions(-)
diff --git a/src/account-item.cpp b/src/account-item.cpp
index 30d063b..b44c48d 100644
--- a/src/account-item.cpp
+++ b/src/account-item.cpp
@@ -22,7 +22,7 @@
#include "accounts-list-model.h"
-#include <kdebug.h>
+#include <KDebug>
#include <QtCore/QTimer>
@@ -36,15 +36,13 @@ AccountItem::AccountItem(Tp::AccountPtr account, AccountsListModel *parent)
// We should look to see if the "account" instance we are passed is ready
// yet. If not, we should get it ready now.
// FIXME: What features should we check are ready?
- if(m_account->isReady())
- {
+ if (m_account->isReady()) {
QTimer::singleShot(0, this, SIGNAL(ready()));
- }
- else
- {
+ } else {
// FIXME: What features should we get ready with?
- connect(m_account->becomeReady(), SIGNAL(finished(Tp::PendingOperation*)),
- this, SLOT(onBecomeReadyFinished(Tp::PendingOperation*)), Qt::QueuedConnection);
+ connect(m_account->becomeReady(),
+ SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(onAccountReady(Tp::PendingOperation*)));
}
}
@@ -58,17 +56,18 @@ Tp::AccountPtr AccountItem::account() const
return m_account;
}
-void AccountItem::onBecomeReadyFinished(Tp::PendingOperation *op)
+void AccountItem::onAccountReady(Tp::PendingOperation *op)
{
-
- if(op->isError())
- {
- kDebug() << "An error occurred in making and Account ready.";
+ if (op->isError()) {
+ kDebug() << "An error occurred in making and Account ready."
+ << op->errorName()
+ << op->errorMessage();
return;
}
Q_EMIT ready();
}
+
#include "account-item.moc"
diff --git a/src/account-item.h b/src/account-item.h
index 7dde8be..e754c5d 100644
--- a/src/account-item.h
+++ b/src/account-item.h
@@ -42,7 +42,7 @@ public:
Tp::AccountPtr account() const;
private Q_SLOTS:
- void onBecomeReadyFinished(Tp::PendingOperation *op);
+ void onAccountReady(Tp::PendingOperation *op);
Q_SIGNALS:
void ready();
@@ -51,8 +51,8 @@ Q_SIGNALS:
private:
Tp::AccountPtr m_account;
-
};
+
#endif // header guard
diff --git a/src/accounts-list-model.cpp b/src/accounts-list-model.cpp
index 1ae396f..d67e3f1 100644
--- a/src/accounts-list-model.cpp
+++ b/src/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/src/accounts-list-model.h b/src/accounts-list-model.h
index d46eac5..016c2e1 100644
--- a/src/accounts-list-model.h
+++ b/src/accounts-list-model.h
@@ -47,8 +47,8 @@ private Q_SLOTS:
private:
QList<AccountItem*> m_unreadyAccounts;
QList<AccountItem*> m_readyAccounts;
-
};
+
#endif // header guard
diff --git a/src/kcm-telepathy-accounts.cpp b/src/kcm-telepathy-accounts.cpp
index ee57ee2..8de1881 100644
--- a/src/kcm-telepathy-accounts.cpp
+++ b/src/kcm-telepathy-accounts.cpp
@@ -22,9 +22,9 @@
#include "accounts-list-model.h"
-#include <kcategorizedsortfilterproxymodel.h>
-#include <kcategorydrawer.h>
-#include <kgenericfactory.h>
+#include <KCategorizedSortFilterProxyModel>
+#include <KCategoryDrawer>
+#include <KGenericFactory>
#include <TelepathyQt4/Account>
#include <TelepathyQt4/PendingOperation>
@@ -40,8 +40,12 @@ KCMTelepathyAccounts::KCMTelepathyAccounts(QWidget *parent, const QVariantList&
m_accountsListProxyModel(0),
m_accountsListModel(0)
{
- // Start up required telepathy components.
- startAccountManager();
+ // Start setting up the Telepathy AccountManager.
+ m_accountManager = Tp::AccountManager::create();
+
+ connect(m_accountManager->becomeReady(),
+ SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(startAccountManagerFinished(Tp::PendingOperation*)));
// Set up the UI stuff.
setupUi(this);
@@ -68,31 +72,19 @@ void KCMTelepathyAccounts::load()
return;
}
-void KCMTelepathyAccounts::startAccountManager()
+void KCMTelepathyAccounts::onAccountManagerReady(Tp::PendingOperation *op)
{
- // This slot is called on construction to set up a telepathy accountmanager
- // instance.
- m_accountManager = Tp::AccountManager::create();
+ kDebug();
- connect(m_accountManager->becomeReady(), SIGNAL(finished(Tp::PendingOperation*)),
- this, SLOT(startAccountManagerFinished(Tp::PendingOperation*)));
-}
-
-void KCMTelepathyAccounts::startAccountManagerFinished(Tp::PendingOperation *op)
-{
- if(op->isError())
- {
- kDebug() << "An error occurred making the AccountManager ready.";
+ // Check the pending operation completed successfully.
+ if (op->isError()) {
+ kDebug() << "becomeReady() failed:" << op->errorName() << op->errorMessage();
return;
}
- else
- {
- kDebug() << "AccountManager became ready successfully.";
- }
+ // Add all the accounts to the Accounts Model.
QList<Tp::AccountPtr> accounts = m_accountManager->allAccounts();
- foreach(Tp::AccountPtr account, accounts)
- {
+ foreach (Tp::AccountPtr account, accounts) {
m_accountsListModel->addAccount(account);
}
}
diff --git a/src/kcm-telepathy-accounts.h b/src/kcm-telepathy-accounts.h
index 904bcec..b3b83dd 100644
--- a/src/kcm-telepathy-accounts.h
+++ b/src/kcm-telepathy-accounts.h
@@ -23,7 +23,7 @@
#include "ui_main-widget.h"
-#include <kcmodule.h>
+#include <KCModule>
#include <TelepathyQt4/AccountManager>
@@ -43,21 +43,20 @@ class KCMTelepathyAccounts : public KCModule, Ui::MainWidget
public:
explicit KCMTelepathyAccounts(QWidget *parent = 0,
const QVariantList& args = QVariantList());
- ~KCMTelepathyAccounts();
+ virtual ~KCMTelepathyAccounts();
public Q_SLOTS:
- void load();
+ virtual void load();
private Q_SLOTS:
- void startAccountManager();
- void startAccountManagerFinished(Tp::PendingOperation *op);
+ void onAccountManagerReady(Tp::PendingOperation *op);
private:
KCategorizedSortFilterProxyModel *m_accountsListProxyModel;
Tp::AccountManagerPtr m_accountManager;
AccountsListModel *m_accountsListModel;
-
};
+
#endif // header guard
--
ktp-accounts-kcm packaging
More information about the pkg-kde-commits
mailing list