summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Moreira Magalhaes (andrunko) <andre.magalhaes@collabora.co.uk>2011-04-14 03:46:48 -0300
committerAndre Moreira Magalhaes (andrunko) <andre.magalhaes@collabora.co.uk>2011-04-14 03:46:48 -0300
commit0dabeb0dd6a344c433bc07a9849ad7a4a85dfc61 (patch)
tree38588da7327defc775ad65cbd38e1a5d136be14e
parentefdbc762b4eeb7344ccc7838c6df670c7fc7cb15 (diff)
parent866987299a1eb88559916f70bd524ceeeed4faa6 (diff)
Merge remote-tracking branch 'boiko/kde_fixes'
-rw-r--r--NEWS5
-rw-r--r--TelepathyQt4Yell/Models/accounts-model-item.cpp24
-rw-r--r--TelepathyQt4Yell/Models/accounts-model-item.h3
-rw-r--r--TelepathyQt4Yell/Models/accounts-model.cpp22
-rw-r--r--TelepathyQt4Yell/Models/accounts-model.h2
5 files changed, 47 insertions, 9 deletions
diff --git a/NEWS b/NEWS
index eb9e86a..e9614af 100644
--- a/NEWS
+++ b/NEWS
@@ -4,10 +4,11 @@ telepathy-qt4-yell 0.1.2 (UNRELEASED)
The "..." release.
Enhancements:
- * ...
+ * Add some convenience methods to the AccountsModel
Fixes:
- * ...
+ * Fix the contact list loading
+ * Fix filtering of accounts through proxies when the connection status changes
telepathy-qt4-yell 0.1.1 (2011-02-16)
======================================
diff --git a/TelepathyQt4Yell/Models/accounts-model-item.cpp b/TelepathyQt4Yell/Models/accounts-model-item.cpp
index 9320112..488f51f 100644
--- a/TelepathyQt4Yell/Models/accounts-model-item.cpp
+++ b/TelepathyQt4Yell/Models/accounts-model-item.cpp
@@ -63,11 +63,8 @@ AccountsModelItem::AccountsModelItem(const Tp::AccountPtr &account)
: mPriv(new Private(account))
{
if (!mPriv->mAccount->connection().isNull()) {
- Tp::ContactManagerPtr manager = account->connection()->contactManager();
- connect(manager.data(),
- SIGNAL(allKnownContactsChanged(Tp::Contacts,Tp::Contacts,
- Tp::Channel::GroupMemberChangeDetails)),
- SLOT(onContactsChanged(Tp::Contacts,Tp::Contacts)));
+ // call the connection changed slot so that signals get connected
+ onConnectionChanged(mPriv->mAccount->connection());
}
connect(mPriv->mAccount.data(),
@@ -288,6 +285,8 @@ void AccountsModelItem::onContactsChanged(const Tp::Contacts &addedContacts,
void AccountsModelItem::onStatusChanged(Tp::ConnectionStatus status)
{
+ onChanged();
+
emit connectionStatusChanged(mPriv->mAccount->uniqueIdentifier(), status);
}
@@ -310,8 +309,19 @@ void AccountsModelItem::onConnectionChanged(const Tp::ConnectionPtr &connection)
Tp::Channel::GroupMemberChangeDetails)),
SLOT(onContactsChanged(Tp::Contacts,Tp::Contacts)));
- clearContacts();
- addKnownContacts();
+ connect(manager.data(),
+ SIGNAL(stateChanged(Tp::ContactListState)),
+ SLOT(onContactManagerStateChanged(Tp::ContactListState)));
+
+ onContactManagerStateChanged(manager->state());
+}
+
+void AccountsModelItem::onContactManagerStateChanged(Tp::ContactListState state)
+{
+ if (state == Tp::ContactListStateSuccess) {
+ clearContacts();
+ addKnownContacts();
+ }
}
void AccountsModelItem::clearContacts()
diff --git a/TelepathyQt4Yell/Models/accounts-model-item.h b/TelepathyQt4Yell/Models/accounts-model-item.h
index 3f5b092..87ffe03 100644
--- a/TelepathyQt4Yell/Models/accounts-model-item.h
+++ b/TelepathyQt4Yell/Models/accounts-model-item.h
@@ -55,6 +55,8 @@ public:
Q_INVOKABLE void setRequestedPresence(int type, const QString &status, const QString &statusMessage);
void clearContacts();
+
+public Q_SLOTS:
void addKnownContacts();
Q_SIGNALS:
@@ -68,6 +70,7 @@ 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 cc3501f..a855bf2 100644
--- a/TelepathyQt4Yell/Models/accounts-model.cpp
+++ b/TelepathyQt4Yell/Models/accounts-model.cpp
@@ -242,6 +242,28 @@ Tp::AccountPtr AccountsModel::accountForIndex(const QModelIndex &index) const
}
}
+Tp::AccountPtr AccountsModel::accountForContactIndex(const QModelIndex &index) const
+{
+ TreeNode *contactNode = mPriv->node(index);
+ AccountsModelItem *item = qobject_cast<AccountsModelItem *>(contactNode->parent());
+ if (item) {
+ return item->account();
+ } else {
+ return Tp::AccountPtr();
+ }
+}
+
+Tp::ContactPtr AccountsModel::contactForIndex(const QModelIndex& index) const
+{
+ TreeNode *contactNode = mPriv->node(index);
+ ContactModelItem *item = qobject_cast<ContactModelItem *>(contactNode);
+ if (item) {
+ return item->contact();
+ } else {
+ return Tp::ContactPtr();
+ }
+}
+
Qt::ItemFlags AccountsModel::flags(const QModelIndex &index) const
{
if (index.isValid()) {
diff --git a/TelepathyQt4Yell/Models/accounts-model.h b/TelepathyQt4Yell/Models/accounts-model.h
index ed8c1b7..39421c4 100644
--- a/TelepathyQt4Yell/Models/accounts-model.h
+++ b/TelepathyQt4Yell/Models/accounts-model.h
@@ -105,6 +105,8 @@ public:
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex &index, int role) const;
Tp::AccountPtr accountForIndex(const QModelIndex &index) const;
+ Tp::AccountPtr accountForContactIndex(const QModelIndex &index) const;
+ Tp::ContactPtr contactForIndex(const QModelIndex &index) const;
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);