[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:58:31 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-accounts-kcm.git;a=commitdiff;h=a155af2
The following commit has been merged in the master branch:
commit a155af2a73579b172c898601483f87c2cf2808af
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Mon Jan 3 00:18:31 2011 +0000
Make use of AccountFactory
This reduces the complexity of the account list model as it no longer
needs to maintain two lists for ready and unready account.
---
src/account-item.cpp | 32 +----------------
src/account-item.h | 5 ++-
src/accounts-list-model.cpp | 79 +++++++++++-------------------------------
src/accounts-list-model.h | 4 +--
src/kcm-telepathy-accounts.cpp | 16 ++++++---
src/kcm-telepathy-accounts.h | 2 +-
6 files changed, 36 insertions(+), 102 deletions(-)
diff --git a/src/account-item.cpp b/src/account-item.cpp
index 6072a63..a670a1b 100644
--- a/src/account-item.cpp
+++ b/src/account-item.cpp
@@ -48,23 +48,7 @@ AccountItem::AccountItem(const Tp::AccountPtr &account, AccountsListModel *paren
SIGNAL(displayNameChanged(const QString&)),
SIGNAL(updated()));
- //initialize icon only when the account is ready
- connect(this, SIGNAL(ready()), SLOT(generateIcon()));
-
- // We should look to see if the "account" instance we are passed is ready
- // yet. If not, we should get it ready now.
- Tp::Features features;
- features << Tp::Account::FeatureCore
- << Tp::Account::FeatureAvatar
- << Tp::Account::FeatureProtocolInfo;
-
- if (m_account->isReady(features)) {
- QTimer::singleShot(0, this, SIGNAL(ready()));
- } else {
- connect(m_account->becomeReady(features),
- SIGNAL(finished(Tp::PendingOperation*)),
- SLOT(onAccountReady(Tp::PendingOperation*)));
- }
+ generateIcon();
}
AccountItem::~AccountItem()
@@ -123,20 +107,6 @@ void AccountItem::generateIcon()
Q_EMIT(updated());
}
-void AccountItem::onAccountReady(Tp::PendingOperation *op)
-{
- kDebug();
-
- if (op->isError()) {
- kDebug() << "An error occurred in making and Account ready."
- << op->errorName()
- << op->errorMessage();
- return;
- }
-
- Q_EMIT ready();
-}
-
void AccountItem::onAccountRemoved(Tp::PendingOperation *op)
{
kDebug();
diff --git a/src/account-item.h b/src/account-item.h
index 75e2411..a0b2a09 100644
--- a/src/account-item.h
+++ b/src/account-item.h
@@ -52,12 +52,11 @@ Q_SIGNALS:
void ready();
void removed();
void updated();
- void protocolSelected(QString, QString);
- void setTitleForCustomPages(QString, QList<QString>);
+ void protocolSelected(QString, QString);
+ void setTitleForCustomPages(QString, QList<QString>);
private Q_SLOTS:
void generateIcon();
- void onAccountReady(Tp::PendingOperation *op);
void onAccountRemoved(Tp::PendingOperation *op);
private:
diff --git a/src/accounts-list-model.cpp b/src/accounts-list-model.cpp
index e0cf9bd..6dae79f 100644
--- a/src/accounts-list-model.cpp
+++ b/src/accounts-list-model.cpp
@@ -32,8 +32,7 @@ AccountsListModel::AccountsListModel(QObject *parent)
{
kDebug();
- m_unreadyAccounts.clear();
- m_readyAccounts.clear();
+ m_accounts.clear();
}
AccountsListModel::~AccountsListModel()
@@ -47,7 +46,7 @@ int AccountsListModel::rowCount(const QModelIndex &index) const
{
// If the index is the root item, then return the row count.
if (index == QModelIndex()) {
- return m_readyAccounts.size();
+ return m_accounts.size();
}
// Otherwise, return 0 (as this is a list model, so all items
@@ -58,7 +57,7 @@ int AccountsListModel::rowCount(const QModelIndex &index) const
QVariant AccountsListModel::data(const QModelIndex &index, int role) const
{
QVariant data;
- Tp::AccountPtr account = m_readyAccounts.at(index.row())->account();
+ Tp::AccountPtr account = m_accounts.at(index.row())->account();
switch(role)
{
@@ -67,7 +66,7 @@ QVariant AccountsListModel::data(const QModelIndex &index, int role) const
break;
case Qt::DecorationRole:
- data = QVariant(m_readyAccounts.at(index.row())->icon());
+ data = QVariant(m_accounts.at(index.row())->icon());
break;
case Qt::CheckStateRole:
@@ -90,7 +89,7 @@ bool AccountsListModel::setData(const QModelIndex &index, const QVariant &value,
{
kDebug();
if(role == Qt::CheckStateRole) {
- m_readyAccounts.at(index.row())->account()->setEnabled(value.toInt() == Qt::Checked);
+ m_accounts.at(index.row())->account()->setEnabled(value.toInt() == Qt::Checked);
return true;
}
return false;
@@ -103,20 +102,14 @@ Qt::ItemFlags AccountsListModel::flags(const QModelIndex &index) const
void AccountsListModel::addAccount(const Tp::AccountPtr &account)
{
+ qDebug() << "here 5";
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) {
- found = true;
- break;
- }
- }
-
if (!found) {
- foreach (const AccountItem* ai, m_readyAccounts) {
+ foreach (const AccountItem* ai, m_accounts) {
if (ai->account() == account) {
found = true;
break;
@@ -133,8 +126,11 @@ void AccountsListModel::addAccount(const Tp::AccountPtr &account)
<< account.data();
AccountItem *item = new AccountItem(account, this);
- m_unreadyAccounts.append(item);
- connect(item, SIGNAL(ready()), SLOT(onAccountItemReady()));
+
+ beginInsertRows(QModelIndex(), m_accounts.size(), m_accounts.size());
+ m_accounts.append(item);
+ endInsertRows();
+
connect(item, SIGNAL(removed()), SLOT(onAccountItemRemoved()));
connect(item, SIGNAL(updated()), SLOT(onAccountItemUpdated()));
}
@@ -148,7 +144,7 @@ void AccountsListModel::removeAccount(const QModelIndex &index)
kDebug() << "Can't remove Account: Invalid index";
return;
}
- AccountItem *accountItem = m_readyAccounts.at(index.row());
+ AccountItem *accountItem = m_accounts.at(index.row());
Q_ASSERT(accountItem);
@@ -164,39 +160,10 @@ AccountItem* AccountsListModel::itemForIndex(const QModelIndex &index)
return 0;
}
- AccountItem *accountItem = m_readyAccounts.at(index.row());
+ AccountItem *accountItem = m_accounts.at(index.row());
return accountItem;
}
-void AccountsListModel::onAccountItemReady()
-{
- kDebug();
-
- 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();
-}
void AccountsListModel::onAccountItemRemoved()
{
@@ -210,21 +177,15 @@ void AccountsListModel::onAccountItemRemoved()
return;
}
- beginRemoveRows(QModelIndex(), m_readyAccounts.lastIndexOf(item),
- m_readyAccounts.lastIndexOf(item));
- m_readyAccounts.removeAll(item);
- m_unreadyAccounts.removeAll(item);
+ beginRemoveRows(QModelIndex(), m_accounts.lastIndexOf(item),
+ m_accounts.lastIndexOf(item));
+ m_accounts.removeAll(item);
endRemoveRows();
- Q_ASSERT(!m_readyAccounts.contains(item));
- if (m_readyAccounts.contains(item)) {
+ Q_ASSERT(!m_accounts.contains(item));
+ if (m_accounts.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()
@@ -239,7 +200,7 @@ void AccountsListModel::onAccountItemUpdated()
return;
}
- QModelIndex index = createIndex(m_readyAccounts.lastIndexOf(item), 0);
+ QModelIndex index = createIndex(m_accounts.lastIndexOf(item), 0);
emit dataChanged(index, index);
}
diff --git a/src/accounts-list-model.h b/src/accounts-list-model.h
index 815719a..38deb93 100644
--- a/src/accounts-list-model.h
+++ b/src/accounts-list-model.h
@@ -51,13 +51,11 @@ public Q_SLOTS:
void onTitleForCustomPages(QString, QList<QString>);
private Q_SLOTS:
- void onAccountItemReady();
void onAccountItemRemoved();
void onAccountItemUpdated();
private:
- QList<AccountItem*> m_unreadyAccounts;
- QList<AccountItem*> m_readyAccounts;
+ QList<AccountItem*> m_accounts;
};
diff --git a/src/kcm-telepathy-accounts.cpp b/src/kcm-telepathy-accounts.cpp
index c2579d2..83550b8 100644
--- a/src/kcm-telepathy-accounts.cpp
+++ b/src/kcm-telepathy-accounts.cpp
@@ -30,6 +30,7 @@
#include <KMessageBox>
#include <TelepathyQt4/Account>
+#include <TelepathyQt4/AccountFactory>
#include <TelepathyQt4/PendingOperation>
#include <TelepathyQt4/PendingReady>
#include <TelepathyQt4/Types>
@@ -50,7 +51,13 @@ KCMTelepathyAccounts::KCMTelepathyAccounts(QWidget *parent, const QVariantList&
Tp::registerTypes();
// Start setting up the Telepathy AccountManager.
- m_accountManager = Tp::AccountManager::create();
+
+ Tp::AccountFactoryPtr accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus(),
+ Tp::Features() << Tp::Account::FeatureCore
+ << Tp::Account::FeatureAvatar
+ << Tp::Account::FeatureProtocolInfo);
+
+ m_accountManager = Tp::AccountManager::create(accountFactory);
connect(m_accountManager->becomeReady(),
SIGNAL(finished(Tp::PendingOperation*)),
@@ -116,13 +123,12 @@ void KCMTelepathyAccounts::onAccountManagerReady(Tp::PendingOperation *op)
}
connect(m_accountManager.data(),
- SIGNAL(accountCreated(const QString &)),
- SLOT(onAccountCreated(const QString &)));
+ SIGNAL(newAccount (Tp::AccountPtr)),
+ SLOT(onAccountCreated(Tp::AccountPtr)));
}
-void KCMTelepathyAccounts::onAccountCreated(const QString &path)
+void KCMTelepathyAccounts::onAccountCreated(const Tp::AccountPtr &account)
{
- Tp::AccountPtr account = m_accountManager->accountForPath(path);
m_accountsListModel->addAccount(account);
}
diff --git a/src/kcm-telepathy-accounts.h b/src/kcm-telepathy-accounts.h
index 513db22..9ea44c3 100644
--- a/src/kcm-telepathy-accounts.h
+++ b/src/kcm-telepathy-accounts.h
@@ -50,7 +50,7 @@ public Q_SLOTS:
private Q_SLOTS:
void onAccountManagerReady(Tp::PendingOperation *op);
- void onAccountCreated(const QString &path);
+ void onAccountCreated(const Tp::AccountPtr &account);
void onSelectedItemChanged();
void onAddAccountClicked();
--
ktp-accounts-kcm packaging
More information about the pkg-kde-commits
mailing list