[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=fdd7513
The following commit has been merged in the master branch:
commit fdd751357d3c830efe851b6c52397d3a10b50cde
Author: George Goldberg <grundleborg at googlemail.com>
Date: Fri Jul 24 18:50:59 2009 +0000
Improve the appearance of the Accounts List view.
- Add a checkbox to enable/disable accounts.
- Show their icon in the view.
- Update the item in the view when its display name or state change.
Thanks to Matteo Nardi for the patch.
svn path=/trunk/playground/network/telepathy-accounts-kcm/; revision=1002001
---
KTp/Models/accounts-list-model.cpp | 61 ++++++++++++++++++++++++++++++--------
KTp/Models/accounts-list-model.h | 2 ++
2 files changed, 51 insertions(+), 12 deletions(-)
diff --git a/KTp/Models/accounts-list-model.cpp b/KTp/Models/accounts-list-model.cpp
index 7b7d8db..92c1b12 100644
--- a/KTp/Models/accounts-list-model.cpp
+++ b/KTp/Models/accounts-list-model.cpp
@@ -24,6 +24,7 @@
#include <KCategorizedSortFilterProxyModel>
#include <KDebug>
+#include <KIcon>
#include <TelepathyQt4/Account>
@@ -57,35 +58,47 @@ int AccountsListModel::rowCount(const QModelIndex &index) const
QVariant AccountsListModel::data(const QModelIndex &index, int role) const
{
- // FIXME: This is a basic implementation just so I can see what's going
- // on while developing this code further. Needs expanding.
QVariant data;
+ Tp::AccountPtr account = m_readyAccounts.at(index.row())->account();
switch(role)
{
case Qt::DisplayRole:
- data = QVariant(m_readyAccounts.at(index.row())->account()->displayName());
+ data = QVariant(account->displayName());
break;
+
+ case Qt::DecorationRole:
+ //FIXME: we need to move kopete protocol icons to oxygen..
+ data = QVariant(KIcon(account->icon()));
+ break;
+
+ case Qt::CheckStateRole:
+ if(account->isEnabled()) {
+ data = QVariant(Qt::Checked);
+ }
+ else {
+ data = QVariant(Qt::Unchecked);
+ }
+ break;
+
case KCategorizedSortFilterProxyModel::CategoryDisplayRole:
- if(m_readyAccounts.at(index.row())->account()->isValidAccount())
- {
+ if(account->isValidAccount()) {
data = QVariant(QString("Valid Accounts"));
}
- else
- {
+ else {
data = QVariant(QString("Invalid Accounts"));
}
break;
+
case KCategorizedSortFilterProxyModel::CategorySortRole:
- if(m_readyAccounts.at(index.row())->account()->isValidAccount())
- {
+ if(account->isValidAccount()) {
data = QVariant(4);
}
- else
- {
+ else {
data = QVariant(5);
}
break;
+
default:
break;
}
@@ -93,6 +106,21 @@ QVariant AccountsListModel::data(const QModelIndex &index, int role) const
return data;
}
+bool AccountsListModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ kDebug();
+ if(role == Qt::CheckStateRole) {
+ m_readyAccounts.at(index.row())->account()->setEnabled(value.toInt() == Qt::Checked);
+ return true;
+ }
+ return false;
+}
+
+Qt::ItemFlags AccountsListModel::flags(const QModelIndex &index) const
+{
+ return QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable;
+}
+
void AccountsListModel::addAccount(const Tp::AccountPtr &account)
{
kDebug() << "Creating a new AccountItem from account:" << account.data();
@@ -194,8 +222,17 @@ void AccountsListModel::onAccountItemRemoved()
void AccountsListModel::onAccountItemUpdated()
{
kDebug();
+
+ AccountItem *item = qobject_cast<AccountItem*>(sender());
- // TODO: Implement me!
+ Q_ASSERT(item);
+ if (!item) {
+ kWarning() << "Not an AccountItem pointer:" << sender();
+ return;
+ }
+
+ QModelIndex index = createIndex(m_readyAccounts.lastIndexOf(item), 0);
+ emit dataChanged(index, index);
}
diff --git a/KTp/Models/accounts-list-model.h b/KTp/Models/accounts-list-model.h
index cdffda8..02fd381 100644
--- a/KTp/Models/accounts-list-model.h
+++ b/KTp/Models/accounts-list-model.h
@@ -37,6 +37,8 @@ public:
virtual ~AccountsListModel();
virtual int rowCount(const QModelIndex &index) const;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ virtual Qt::ItemFlags flags(const QModelIndex &index) const;
+ virtual bool setData(const QModelIndex &index, const QVariant &value, int role);
void addAccount(const Tp::AccountPtr &account);
private Q_SLOTS:
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list