summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateu Batle <mateu.batle@collabora.co.uk>2011-06-04 15:30:40 -0500
committerMateu Batle <mateu.batle@collabora.co.uk>2011-06-04 15:30:40 -0500
commitd74173e80adb1d57838c75c1a41ab1faff5d1994 (patch)
tree9fa93cec1cef4167e8b7cba18c3400b4206c6f0b
parentbdbfa4a0f77c76f88fc16395b477c9cb41ae76ef (diff)
parenta38f2382a2cc98d67ba1d3b9c8120707f3220909 (diff)
Merge remote branch "asoliver/connection"
Reviewed by: Mateu Batle Sastre <mateu.batle@collabora.co.uk>
-rw-r--r--NEWS2
-rw-r--r--TelepathyQt4Yell/Models/accounts-model-item.cpp20
-rw-r--r--TelepathyQt4Yell/Models/accounts-model-item.h2
-rw-r--r--TelepathyQt4Yell/Models/accounts-model.cpp29
4 files changed, 24 insertions, 29 deletions
diff --git a/NEWS b/NEWS
index f603d31..42c0832 100644
--- a/NEWS
+++ b/NEWS
@@ -7,7 +7,7 @@ Enhancements:
* ...
Fixes:
- * ...
+ * Make the account model item use the status of the Connection object instead of the account one
telepathy-qt4-yell 0.1.5 (2011-05-26)
======================================
diff --git a/TelepathyQt4Yell/Models/accounts-model-item.cpp b/TelepathyQt4Yell/Models/accounts-model-item.cpp
index 2c51764..1122003 100644
--- a/TelepathyQt4Yell/Models/accounts-model-item.cpp
+++ b/TelepathyQt4Yell/Models/accounts-model-item.cpp
@@ -63,11 +63,6 @@ void AccountsModelItem::Private::setStatusMessage(const QString &value)
AccountsModelItem::AccountsModelItem(const Tp::AccountPtr &account)
: mPriv(new Private(account))
{
- if (!mPriv->mAccount->connection().isNull()) {
- // call the connection changed slot so that signals get connected
- onConnectionChanged(mPriv->mAccount->connection());
- }
-
connect(mPriv->mAccount.data(),
SIGNAL(removed()),
SLOT(onRemoved()));
@@ -123,9 +118,6 @@ AccountsModelItem::AccountsModelItem(const Tp::AccountPtr &account)
SIGNAL(onlinenessChanged(bool)),
SLOT(onChanged()));
connect(mPriv->mAccount.data(),
- SIGNAL(connectionStatusChanged(Tp::ConnectionStatus)),
- SLOT(onStatusChanged(Tp::ConnectionStatus)));
- connect(mPriv->mAccount.data(),
SIGNAL(connectionChanged(Tp::ConnectionPtr)),
SLOT(onConnectionChanged(Tp::ConnectionPtr)));
}
@@ -296,14 +288,11 @@ void AccountsModelItem::onContactsChanged(const Tp::Contacts &addedContacts,
void AccountsModelItem::onStatusChanged(Tp::ConnectionStatus status)
{
onChanged();
-
emit connectionStatusChanged(mPriv->mAccount->uniqueIdentifier(), status);
}
void AccountsModelItem::onConnectionChanged(const Tp::ConnectionPtr &connection)
{
- onChanged();
-
// if the connection is invalid or disconnected, clear the contacts list
if (connection.isNull()
|| !connection->isValid()
@@ -314,17 +303,18 @@ void AccountsModelItem::onConnectionChanged(const Tp::ConnectionPtr &connection)
return;
}
- mPriv->mManager = connection->contactManager();
+ connect(connection.data(), SIGNAL(statusChanged(Tp::ConnectionStatus)),
+ SLOT(onStatusChanged(Tp::ConnectionStatus)));
+ onStatusChanged(connection->status());
+ mPriv->mManager = connection->contactManager();
connect(mPriv->mManager.data(),
SIGNAL(allKnownContactsChanged(Tp::Contacts,Tp::Contacts,
Tp::Channel::GroupMemberChangeDetails)),
SLOT(onContactsChanged(Tp::Contacts,Tp::Contacts)));
-
connect(mPriv->mManager.data(),
SIGNAL(stateChanged(Tp::ContactListState)),
SLOT(onContactManagerStateChanged(Tp::ContactListState)));
-
onContactManagerStateChanged(mPriv->mManager->state());
}
@@ -358,6 +348,8 @@ void AccountsModelItem::clearContacts()
emit childrenRemoved(this, i, i);
}
}
+ } else {
+ emit childrenRemoved(this, 0, size() - 1);
}
}
diff --git a/TelepathyQt4Yell/Models/accounts-model-item.h b/TelepathyQt4Yell/Models/accounts-model-item.h
index 87ffe03..c73dae9 100644
--- a/TelepathyQt4Yell/Models/accounts-model-item.h
+++ b/TelepathyQt4Yell/Models/accounts-model-item.h
@@ -58,6 +58,7 @@ public:
public Q_SLOTS:
void addKnownContacts();
+ void onConnectionChanged(const Tp::ConnectionPtr &connection);
Q_SIGNALS:
void connectionStatusChanged(const QString &accountId, int status);
@@ -69,7 +70,6 @@ private Q_SLOTS:
void onStatusChanged(Tp::ConnectionStatus status);
- void onConnectionChanged(const Tp::ConnectionPtr &connection);
void onContactManagerStateChanged(Tp::ContactListState state);
void onContactsChanged(const Tp::Contacts &added,
const Tp::Contacts &removed);
diff --git a/TelepathyQt4Yell/Models/accounts-model.cpp b/TelepathyQt4Yell/Models/accounts-model.cpp
index 45c897a..dcc0a7c 100644
--- a/TelepathyQt4Yell/Models/accounts-model.cpp
+++ b/TelepathyQt4Yell/Models/accounts-model.cpp
@@ -64,18 +64,15 @@ AccountsModel::AccountsModel(const Tp::AccountManagerPtr &am, QObject *parent)
connect(mPriv->mTree,
SIGNAL(childrenRemoved(TreeNode*,int,int)),
SLOT(onItemsRemoved(TreeNode*,int,int)));
-
- foreach (Tp::AccountPtr account, mPriv->mAM->allAccounts()) {
- AccountsModelItem *item = new AccountsModelItem(account);
- connect(item, SIGNAL(connectionStatusChanged(QString,int)),
- this, SIGNAL(accountConnectionStatusChanged(QString,int)));
- mPriv->mTree->addChild(item);
- }
-
connect(mPriv->mAM.data(),
SIGNAL(newAccount(Tp::AccountPtr)),
SLOT(onNewAccount(Tp::AccountPtr)));
+ // load existing accounts
+ foreach (Tp::AccountPtr account, mPriv->mAM->allAccounts()) {
+ onNewAccount(account);
+ }
+
QHash<int, QByteArray> roles;
roles[ItemRole] = "item";
roles[IdRole] = "id";
@@ -132,12 +129,18 @@ AccountsModel::~AccountsModel()
void AccountsModel::onNewAccount(const Tp::AccountPtr &account)
{
- AccountsModelItem *accountNode = new AccountsModelItem(account);
-
- connect(accountNode, SIGNAL(connectionStatusChanged(QString,int)),
+ AccountsModelItem *item = new AccountsModelItem(account);
+ connect(item, SIGNAL(connectionStatusChanged(QString,int)),
this, SIGNAL(accountConnectionStatusChanged(QString,int)));
-
- onItemsAdded(mPriv->mTree, QList<TreeNode *>() << accountNode);
+ onItemsAdded(mPriv->mTree, QList<TreeNode *>() << item);
+
+ // this is done here because the item needs to be added to the tree so that the necessary signals
+ // are in place to detect when adding contacts to the account item
+ // otherwise, addKnownContacts will be called, but the contacts will not be added to the model
+ if (!account->connection().isNull()
+ && account->connection()->isValid()) {
+ item->onConnectionChanged(account->connection());
+ }
}
void AccountsModel::onItemChanged(TreeNode *node)