23 #include <TelepathyQt/Account>
24 #include <TelepathyQt/AccountManager>
25 #include <TelepathyQt/AccountSet>
30 class KTp::AccountsTreeProxyModel::Private
33 Tp::AccountManagerPtr accountManager;
34 Tp::AccountSetPtr accountSet;
41 d->accountManager = accountManager;
43 d->accountSet = accountManager->enabledAccounts();
44 connect(d->accountSet.data(), SIGNAL(accountAdded(Tp::AccountPtr)), SLOT(onAccountAdded(Tp::AccountPtr)));
45 connect(d->accountSet.data(), SIGNAL(accountRemoved(Tp::AccountPtr)), SLOT(onAccountRemoved(Tp::AccountPtr)));
46 Q_FOREACH(
const Tp::AccountPtr &account, d->accountSet->accounts()) {
47 onAccountAdded(account);
54 const Tp::AccountPtr account = sourceIndex.data(
KTp::AccountRole).value<Tp::AccountPtr>();
56 return QSet<QString>() << account->objectPath();
58 return QSet<QString>() << QLatin1String(
"Unknown");
65 Tp::AccountPtr account;
68 account = d->accountManager->accountForObjectPath(group);
70 return account->displayName();
73 case Qt::DecorationRole:
74 account = d->accountManager->accountForObjectPath(group);
76 return KIcon(account->iconName());
80 return QVariant::fromValue(d->accountManager->accountForObjectPath(group));
84 account = d->accountManager->accountForObjectPath(group);
86 return account->uniqueIdentifier();
94 void KTp::AccountsTreeProxyModel::onAccountChanged()
96 Tp::AccountPtr account(qobject_cast<Tp::Account*>(sender()));
97 groupChanged(account->objectPath());
100 void KTp::AccountsTreeProxyModel::onAccountAdded(
const Tp::AccountPtr &account)
102 forceGroup(account->objectPath());
103 connect(account.data(), SIGNAL(normalizedNameChanged(QString)), SLOT(onAccountChanged()));
104 connect(account.data(), SIGNAL(iconNameChanged(QString)), SLOT(onAccountChanged()));
107 void KTp::AccountsTreeProxyModel::onAccountRemoved(
const Tp::AccountPtr &account)
109 unforceGroup(account->objectPath());