[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9
Maximiliano Curia
maxy at moszumanska.debian.org
Mon May 9 09:05:42 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=d20d2bc
The following commit has been merged in the master branch:
commit d20d2bcb371da8bb3a893161c0d97ec2dfd4040e
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.
---
KTp/Models/accounts-list-model.cpp | 79 ++++++++++----------------------------
KTp/Models/accounts-list-model.h | 4 +-
2 files changed, 21 insertions(+), 62 deletions(-)
diff --git a/KTp/Models/accounts-list-model.cpp b/KTp/Models/accounts-list-model.cpp
index e0cf9bd..6dae79f 100644
--- a/KTp/Models/accounts-list-model.cpp
+++ b/KTp/Models/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/KTp/Models/accounts-list-model.h b/KTp/Models/accounts-list-model.h
index 815719a..38deb93 100644
--- a/KTp/Models/accounts-list-model.h
+++ b/KTp/Models/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;
};
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list