[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/network/telepathy-accounts-kcm/src
From: George Goldberg <grundleborg () googlemail ! com>
Date: 2009-02-14 20:14:20
Message-ID: 1234642460.702754.30657.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 926203 by gberg:
Start to implement the internal storage of the AccountsListModel.
M +5 -0 account-item.cpp
M +1 -0 account-item.h
M +64 -1 accounts-list-model.cpp
M +19 -1 accounts-list-model.h
--- trunk/playground/network/telepathy-accounts-kcm/src/account-item.cpp #926202:926203
@@ -54,6 +54,11 @@
// TODO: Implement me...
}
+Telepathy::Client::Account* AccountItem::account() const
+{
+ return m_account;
+}
+
void AccountItem::onBecomeReadyFinished(Telepathy::Client::PendingOperation *op)
{
Q_ASSERT(op->isFinished());
--- trunk/playground/network/telepathy-accounts-kcm/src/account-item.h #926202:926203
@@ -40,6 +40,7 @@
public:
explicit AccountItem(Telepathy::Client::Account *account, AccountsListModel *parent = 0);
virtual ~AccountItem();
+ Telepathy::Client::Account* account() const;
private Q_SLOTS:
void onBecomeReadyFinished(Telepathy::Client::PendingOperation *op);
--- trunk/playground/network/telepathy-accounts-kcm/src/accounts-list-model.cpp #926202:926203
@@ -20,10 +20,17 @@
#include "accounts-list-model.h"
+#include "account-item.h"
+
+#include <kdebug.h>
+
+#include <TelepathyQt4/Client/Account>
+
AccountsListModel::AccountsListModel(QObject *parent)
: QAbstractListModel(parent)
{
- // TODO: Implement me!
+ m_unreadyAccounts.clear();
+ m_readyAccounts.clear();
}
AccountsListModel::~AccountsListModel()
@@ -43,6 +50,62 @@
return QVariant();
}
+void AccountsListModel::addAccount(Telepathy::Client::Account *account)
+{
+ // 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)
+ {
+ 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
+ {
+ 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()));
+ }
+}
+
+void AccountsListModel::onAccountItemReady()
+{
+ // TODO: Implement me!
+}
+
+void AccountsListModel::onAccountItemRemoved()
+{
+ // TODO: Implement me!
+}
+
+void AccountsListModel::onAccountItemUpdated()
+{
+ // TODO: Implement me!
+}
+
+
#include "accounts-list-model.moc"
--- trunk/playground/network/telepathy-accounts-kcm/src/accounts-list-model.h #926202:926203
@@ -21,8 +21,16 @@
#ifndef TELEPATHY_ACCOUNTS_KCM_ACCOUNTS_LIST_MODEL_H
#define TELEPATHY_ACCOUNTS_KCM_ACCOUNTS_LIST_MODEL_H
-#include <QAbstractListModel>
+#include <QtCore/QAbstractListModel>
+class AccountItem;
+
+namespace Telepathy {
+ namespace Client {
+ class Account;
+ }
+}
+
class AccountsListModel : public QAbstractListModel
{
Q_OBJECT
@@ -33,7 +41,17 @@
virtual ~AccountsListModel();
virtual int rowCount(const QModelIndex &index) const;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ void addAccount(Telepathy::Client::Account *account);
+private Q_SLOTS:
+ void onAccountItemReady();
+ void onAccountItemRemoved();
+ void onAccountItemUpdated();
+
+private:
+ QList<AccountItem*> m_unreadyAccounts;
+ QList<AccountItem*> m_readyAccounts;
+
};
#endif // header guard
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic