[SCM] ktp-accounts-kcm packaging branch, master, updated. debian/15.12.1-1-1157-gc4589c5
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:02:49 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-accounts-kcm.git;a=commitdiff;h=3c263c0
The following commit has been merged in the master branch:
commit 3c263c0b518293f7bf0390b926f6a75ca4420189
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Fri Oct 19 08:58:54 2012 -0700
Use AccontsListModel from KTp Common Internals
---
src/CMakeLists.txt | 2 +-
src/accounts-list-delegate.cpp | 4 +-
src/accounts-list-model.cpp | 290 -----------------------------------------
src/accounts-list-model.h | 71 ----------
src/edit-account-dialog.h | 5 +-
src/kcm-telepathy-accounts.cpp | 22 +---
src/kcm-telepathy-accounts.h | 3 -
7 files changed, 9 insertions(+), 388 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fd55553..62aef14 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -12,7 +12,6 @@ set (kcm_ktp_accounts_SRCS
salut-enabler.cpp
salut-message-widget.cpp
kcm-telepathy-accounts.cpp
- accounts-list-model.cpp
add-account-assistant.cpp
edit-account-dialog.cpp
account-identity-dialog.cpp
@@ -38,6 +37,7 @@ target_link_libraries (kcm_ktp_accounts
${KDE4_KDEUI_LIBS}
${TELEPATHY_QT4_LIBRARIES}
${KTP_LIBRARIES}
+ ${KTP_MODELS_LIBRARIES}
${KDE4_KIO_LIBS}
)
diff --git a/src/accounts-list-delegate.cpp b/src/accounts-list-delegate.cpp
index d157ce3..1612941 100644
--- a/src/accounts-list-delegate.cpp
+++ b/src/accounts-list-delegate.cpp
@@ -21,13 +21,11 @@
#include "accounts-list-delegate.h"
-#include "account-item.h"
-#include "accounts-list-model.h"
#include "edit-display-name-button.h"
#include "change-icon-button.h"
#include <KTp/presence.h>
-#include <KTp/Models/accounts-model.h>
+#include <KTp/Models/accounts-list-model.h>
#include <KDE/KLocale>
#include <KDE/KIconButton>
diff --git a/src/accounts-list-model.cpp b/src/accounts-list-model.cpp
deleted file mode 100644
index b9c4b85..0000000
--- a/src/accounts-list-model.cpp
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * This file is part of telepathy-accounts-kcm
- *
- * Copyright (C) 2009 Collabora Ltd. <info at collabora.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "accounts-list-model.h"
-
-#include "account-item.h"
-
-#include <KDebug>
-#include <KIcon>
-#include <KLocalizedString>
-#include <KPixmapSequence>
-
-#include <KTp/error-dictionary.h>
-
-#include <TelepathyQt/Account>
-
-
-AccountsListModel::AccountsListModel(QObject *parent)
- : QAbstractListModel(parent)
-{
-}
-
-AccountsListModel::~AccountsListModel()
-{
-}
-
-int AccountsListModel::rowCount(const QModelIndex & parent) const
-{
- // If the index is the root item, then return the row count.
- if (parent == QModelIndex()) {
- return m_accounts.size();
- }
-
- // Otherwise, return 0 (as this is a list model, so all items
- // are children of the root item).
- return 0;
-}
-
-int AccountsListModel::columnCount(const QModelIndex& parent) const
-{
- Q_UNUSED(parent);
-
- // Column count is always 1
- return 1;
-}
-
-
-QVariant AccountsListModel::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid()) {
- return QVariant();
- }
-
- QVariant data;
- Tp::AccountPtr account = m_accounts.at(index.row());
-
- switch (role) {
- case Qt::DisplayRole:
- data = QVariant(account->displayName());
- break;
-
- case Qt::DecorationRole:
- data = QVariant(KIcon(account->iconName()));
- break;
-
- case Qt::CheckStateRole:
- if (account->isEnabled()) {
- data = QVariant(Qt::Checked);
- } else {
- data = QVariant(Qt::Unchecked);
- }
- break;
-
- case AccountsListModel::ConnectionStateRole:
- data = QVariant(account->connectionStatus());
- break;
-
- case AccountsListModel::ConnectionStateDisplayRole:
- data = QVariant(connectionStateString(account));
- break;
-
- case AccountsListModel::ConnectionStateIconRole:
- data = QVariant(connectionStateIcon(account));
- break;
-
- case AccountsListModel::ConnectionErrorMessageDisplayRole:
- data = QVariant(connectionStatusReason(account));
- break;
-
- case AccountsListModel::ConnectionProtocolNameRole:
- data = QVariant(account->protocolName());
- break;
-
- case AccountsListModel::AccountRole:
- data = QVariant::fromValue<Tp::AccountPtr>(account);
- break;
-
- default:
- break;
- }
-
- return data;
-}
-
-bool AccountsListModel::setData(const QModelIndex &index, const QVariant &value, int role)
-{
- if (!index.isValid()) {
- return false;
- }
- if (role == Qt::CheckStateRole) {
- //this is index from QSortFilterProxyModel
- index.data(AccountRole).value<Tp::AccountPtr>()->setEnabled(value.toInt() == Qt::Checked);
- return true;
- }
-
- return false;
-}
-
-QModelIndex AccountsListModel::index(int row, int column, const QModelIndex& parent) const
-{
- if (row < 0 || column < 0 || parent != QModelIndex()) {
- return QModelIndex();
- }
-
- if (row < rowCount() && column < columnCount()) {
- return createIndex(row, column);
- }
-
- return QModelIndex();
-}
-
-
-Qt::ItemFlags AccountsListModel::flags(const QModelIndex &index) const
-{
- if (!index.isValid()) {
- return QAbstractItemModel::flags(index);
- }
- return QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable;
-}
-
-void AccountsListModel::addAccount(const Tp::AccountPtr &account)
-{
- kDebug() << "Creating a new AccountItem from account:" << account.data();
-
- // Check if the account is already in the model.
- bool found = false;
-
- if (!found) {
- Q_FOREACH (const Tp::AccountPtr &ai, m_accounts) {
- if (ai == account) {
- found = true;
- break;
- }
- }
- }
-
- if (found) {
- kWarning() << "Requested to add account"
- << account.data()
- << "to model, but it is already present. Doing nothing.";
- } else {
- kDebug() << "Account not already in model. Create new AccountItem from account:"
- << account.data();
-
- beginInsertRows(QModelIndex(), m_accounts.size(), m_accounts.size());
- m_accounts.append(account);
- endInsertRows();
-
- connect(account.data(), SIGNAL(removed()), SLOT(onAccountItemRemoved()));
-
- connect(account.data(),
- SIGNAL(stateChanged(bool)),
- SLOT(onAccountItemUpdated()));
- connect(account.data(),
- SIGNAL(displayNameChanged(QString)),
- SLOT(onAccountItemUpdated()));
- connect(account.data(),
- SIGNAL(connectionStatusChanged(Tp::ConnectionStatus)),
- SLOT(onAccountItemUpdated()));
- connect(account.data(),
- SIGNAL(iconNameChanged(QString)),
- SLOT(onAccountItemUpdated()));
- connect(account.data(),
- SIGNAL(stateChanged(bool)),
- SLOT(onAccountItemUpdated()));
- }
-}
-
-void AccountsListModel::onAccountItemRemoved()
-{
- Tp::AccountPtr item = Tp::AccountPtr(qobject_cast<Tp::Account*>(sender()));
-
- Q_ASSERT(item);
- if (!item) {
- kWarning() << "Not an AccountItem pointer:" << sender();
- return;
- }
-
- // We can be pretty sure that there is only one reference to a specific AccountItem in the list
- // If we screw up here, the styling delegate will screw up even more
- beginRemoveRows(QModelIndex(), m_accounts.indexOf(item), m_accounts.indexOf(item));
- m_accounts.removeAll(item);
- endRemoveRows();
-
- // FIXME: Workaround until the KWidgetItemDelegate gets fixed (probably KDE 4.7)
- //reset();
-}
-
-void AccountsListModel::onAccountItemUpdated()
-{
- Tp::AccountPtr item = Tp::AccountPtr(qobject_cast<Tp::Account*>(sender()));
-
- Q_ASSERT(item);
- if (!item) {
- kWarning() << "Not an AccountItem pointer:" << sender();
- return;
- }
-
- QModelIndex index = createIndex(m_accounts.lastIndexOf(item), 0);
- Q_EMIT dataChanged(index, index);
-}
-
-const QString AccountsListModel::connectionStateString(const Tp::AccountPtr &account) const
-{
- if (account->isEnabled()) {
- switch (account->connectionStatus()) {
- case Tp::ConnectionStatusConnected:
- return i18n("Online");
- case Tp::ConnectionStatusConnecting:
- return i18nc("This is a connection state", "Connecting");
- case Tp::ConnectionStatusDisconnected:
- return i18nc("This is a connection state", "Disconnected");
- default:
- return i18nc("This is an unknown connection state", "Unknown");
- }
- } else {
- return i18nc("This is a disabled account", "Disabled");
- }
-}
-
-const KIcon AccountsListModel::connectionStateIcon(const Tp::AccountPtr &account) const
-{
- if (account->isEnabled()) {
- switch (account->connectionStatus()) {
- case Tp::ConnectionStatusConnected:
- return KIcon(QLatin1String("user-online"));
- case Tp::ConnectionStatusConnecting:
- //imho this is not really worth animating, but feel free to play around..
- return KIcon(KPixmapSequence(QLatin1String("process-working"), 22).frameAt(0));
- case Tp::ConnectionStatusDisconnected:
- return KIcon(QLatin1String("user-offline"));
- default:
- return KIcon(QLatin1String("user-offline"));
- }
- } else {
- return KIcon();
- }
-}
-
-const QString AccountsListModel::connectionStatusReason(const Tp::AccountPtr &account) const
-{
- if (!account->isEnabled()) {
- return i18n("Click checkbox to enable");
- }
- else if (account->connectionStatusReason() == Tp::ConnectionStatusReasonRequested) {
- return QString();
- }
- else {
- return KTp::ErrorDictionary::displayShortErrorMessage(account->connectionError());
- }
-}
-
-#include "accounts-list-model.moc"
diff --git a/src/accounts-list-model.h b/src/accounts-list-model.h
deleted file mode 100644
index 66b84ef..0000000
--- a/src/accounts-list-model.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * This file is part of telepathy-accounts-kcm
- *
- * Copyright (C) 2009 Collabora Ltd. <info at collabora.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef TELEPATHY_ACCOUNTS_KCM_ACCOUNTS_LIST_MODEL_H
-#define TELEPATHY_ACCOUNTS_KCM_ACCOUNTS_LIST_MODEL_H
-
-#include <QtCore/QAbstractListModel>
-
-#include <TelepathyQt/Account>
-
-class AccountItem;
-class KIcon;
-
-class AccountsListModel : public QAbstractListModel
-{
- Q_OBJECT
- Q_DISABLE_COPY(AccountsListModel);
-
-public:
- enum Roles {
- ConnectionStateRole = Qt::UserRole,
- ConnectionStateDisplayRole = Qt::UserRole+1,
- ConnectionStateIconRole,
- ConnectionErrorMessageDisplayRole,
- ConnectionProtocolNameRole,
- AccountRole
- };
-
- explicit AccountsListModel(QObject *parent = 0);
- virtual ~AccountsListModel();
- virtual int rowCount(const QModelIndex & parent = QModelIndex()) const;
- virtual int columnCount(const QModelIndex &parent = QModelIndex()) 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);
- virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
- void addAccount(const Tp::AccountPtr &account);
-
-private Q_SLOTS:
- void onAccountItemRemoved();
- void onAccountItemUpdated();
-
-private:
- QList<Tp::AccountPtr> m_accounts;
-
- const QString connectionStateString(const Tp::AccountPtr &account) const;
- const KIcon connectionStateIcon(const Tp::AccountPtr &account) const;
- const QString connectionStatusReason(const Tp::AccountPtr &account) const;
-};
-
-Q_DECLARE_METATYPE(Tp::AccountPtr)
-
-#endif // header guard
-
diff --git a/src/edit-account-dialog.h b/src/edit-account-dialog.h
index 37b51f6..afa13b8 100644
--- a/src/edit-account-dialog.h
+++ b/src/edit-account-dialog.h
@@ -21,10 +21,11 @@
#ifndef KCM_TELEPATHY_ACCOUNTS_EDIT_ACCOUNT_DIALOG_H
#define KCM_TELEPATHY_ACCOUNTS_EDIT_ACCOUNT_DIALOG_H
-#include "account-item.h"
-
#include <KDialog>
+#include <TelepathyQt/Types>
+#include <TelepathyQt/PendingOperation>
+
class EditAccountDialog : public KDialog
{
Q_OBJECT
diff --git a/src/kcm-telepathy-accounts.cpp b/src/kcm-telepathy-accounts.cpp
index c60d268..f2e40ad 100644
--- a/src/kcm-telepathy-accounts.cpp
+++ b/src/kcm-telepathy-accounts.cpp
@@ -23,11 +23,11 @@
#include "ui_main-widget.h"
-#include "accounts-list-model.h"
#include "add-account-assistant.h"
#include "edit-account-dialog.h"
#include "accounts-list-delegate.h"
#include "account-identity-dialog.h"
+#include "salut-enabler.h"
#include <QtGui/QLabel>
#include <QtGui/QSortFilterProxyModel>
@@ -40,8 +40,10 @@
#include <KMessageWidget>
#include <KPixmapSequenceOverlayPainter>
#include <KDebug>
+#include <KPixmapSequence>
#include <KTp/wallet-utils.h>
+#include <KTp/Models/accounts-list-model.h>
#include <TelepathyQt/Account>
#include <TelepathyQt/AccountFactory>
@@ -52,8 +54,6 @@
#include <TelepathyQt/ConnectionManager>
-#include "salut-enabler.h"
-#include <KPixmapSequence>
K_PLUGIN_FACTORY(KCMTelepathyAccountsFactory, registerPlugin<KCMTelepathyAccounts>();)
K_EXPORT_PLUGIN(KCMTelepathyAccountsFactory("telepathy_accounts", "telepathy-accounts-kcm"))
@@ -231,23 +231,9 @@ void KCMTelepathyAccounts::onAccountManagerReady(Tp::PendingOperation *op)
return;
}
- // Add all the accounts to the Accounts Model.
- QList<Tp::AccountPtr> accounts = m_accountManager->allAccounts();
- Q_FOREACH (const Tp::AccountPtr &account, accounts) {
- m_accountsListModel->addAccount(account);
- }
-
- onModelDataChanged();
-
- connect(m_accountManager.data(),
- SIGNAL(newAccount(Tp::AccountPtr)),
- SLOT(onAccountCreated(Tp::AccountPtr)));
+ m_accountsListModel->setAccountManager(m_accountManager);
}
-void KCMTelepathyAccounts::onAccountCreated(const Tp::AccountPtr &account)
-{
- m_accountsListModel->addAccount(account);
-}
void KCMTelepathyAccounts::onSelectedItemChanged(const QModelIndex ¤t, const QModelIndex &previous)
{
diff --git a/src/kcm-telepathy-accounts.h b/src/kcm-telepathy-accounts.h
index 29629eb..823ce6b 100644
--- a/src/kcm-telepathy-accounts.h
+++ b/src/kcm-telepathy-accounts.h
@@ -58,10 +58,7 @@ public Q_SLOTS:
private Q_SLOTS:
void onAccountManagerReady(Tp::PendingOperation *op);
- void onAccountCreated(const Tp::AccountPtr &account);
-
void onAccountEnabledChanged(const QModelIndex &index, bool enabled);
-
void onSelectedItemChanged(const QModelIndex ¤t, const QModelIndex &previous);
void onAddAccountClicked();
void onEditAccountClicked();
--
ktp-accounts-kcm packaging
More information about the pkg-kde-commits
mailing list