[SCM] ktp-accounts-kcm packaging branch, master, updated. debian/15.12.1-1-1157-gc4589c5
Maximiliano Curia
maxy at moszumanska.debian.org
Fri May 27 23:57:38 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-accounts-kcm.git;a=commitdiff;h=37f6d6c
The following commit has been merged in the master branch:
commit 37f6d6c006944204d5586f16906f795cf19d1cd8
Author: George Goldberg <grundleborg at googlemail.com>
Date: Tue Jul 28 16:12:55 2009 +0000
Implement removing of accounts.
Thanks to Matteo Nardi for the patch.
BUG: 201396
svn path=/trunk/playground/network/telepathy-accounts-kcm/; revision=1003684
---
src/account-item.cpp | 37 +++++++++++++++++++++++++++++++------
src/account-item.h | 2 ++
src/accounts-list-model.cpp | 38 +++++++++++++++++---------------------
src/accounts-list-model.h | 1 +
src/kcm-telepathy-accounts.cpp | 42 ++++++++++++++++++++++++++++++++++--------
src/kcm-telepathy-accounts.h | 5 ++---
src/main-widget.ui | 13 +++++++------
7 files changed, 94 insertions(+), 44 deletions(-)
diff --git a/src/account-item.cpp b/src/account-item.cpp
index ee3ba69..6395481 100644
--- a/src/account-item.cpp
+++ b/src/account-item.cpp
@@ -35,6 +35,14 @@ AccountItem::AccountItem(const Tp::AccountPtr &account, AccountsListModel *paren
{
kDebug();
+ //connect AccountPtr signals to AccountItem signals
+ connect(m_account.data(),
+ SIGNAL(stateChanged(bool)),
+ SIGNAL(updated()));
+ connect(m_account.data(),
+ SIGNAL(displayNameChanged(const QString&)),
+ SIGNAL(updated()));
+
// We should look to see if the "account" instance we are passed is ready
// yet. If not, we should get it ready now.
// FIXME: What features should we check are ready?
@@ -60,6 +68,16 @@ Tp::AccountPtr AccountItem::account() const
return m_account;
}
+void AccountItem::remove()
+{
+ kDebug() << "Account about to be removed";
+
+ Tp::PendingOperation *op = m_account->remove();
+ connect(op,
+ SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(onAccountRemoved(Tp::PendingOperation*)));
+}
+
void AccountItem::onAccountReady(Tp::PendingOperation *op)
{
kDebug();
@@ -71,15 +89,22 @@ void AccountItem::onAccountReady(Tp::PendingOperation *op)
return;
}
- connect(m_account.data(),
- SIGNAL(stateChanged(bool)),
- SIGNAL(updated()));
- connect(m_account.data(),
- SIGNAL(displayNameChanged(const QString&)),
- SIGNAL(updated()));
Q_EMIT ready();
}
+void AccountItem::onAccountRemoved(Tp::PendingOperation *op)
+{
+ kDebug();
+
+ if (op->isError()) {
+ kDebug() << "An error occurred removing the Account."
+ << op->errorName()
+ << op->errorMessage();
+ return;
+ }
+
+ Q_EMIT removed();
+}
#include "account-item.moc"
diff --git a/src/account-item.h b/src/account-item.h
index 2fc70b8..3fe1c58 100644
--- a/src/account-item.h
+++ b/src/account-item.h
@@ -40,9 +40,11 @@ public:
explicit AccountItem(const Tp::AccountPtr &account, AccountsListModel *parent = 0);
virtual ~AccountItem();
Tp::AccountPtr account() const;
+ void remove();
private Q_SLOTS:
void onAccountReady(Tp::PendingOperation *op);
+ void onAccountRemoved(Tp::PendingOperation *op);
Q_SIGNALS:
void ready();
diff --git a/src/accounts-list-model.cpp b/src/accounts-list-model.cpp
index 92c1b12..54fc370 100644
--- a/src/accounts-list-model.cpp
+++ b/src/accounts-list-model.cpp
@@ -22,7 +22,6 @@
#include "account-item.h"
-#include <KCategorizedSortFilterProxyModel>
#include <KDebug>
#include <KIcon>
@@ -81,24 +80,6 @@ QVariant AccountsListModel::data(const QModelIndex &index, int role) const
}
break;
- case KCategorizedSortFilterProxyModel::CategoryDisplayRole:
- if(account->isValidAccount()) {
- data = QVariant(QString("Valid Accounts"));
- }
- else {
- data = QVariant(QString("Invalid Accounts"));
- }
- break;
-
- case KCategorizedSortFilterProxyModel::CategorySortRole:
- if(account->isValidAccount()) {
- data = QVariant(4);
- }
- else {
- data = QVariant(5);
- }
- break;
-
default:
break;
}
@@ -160,6 +141,21 @@ void AccountsListModel::addAccount(const Tp::AccountPtr &account)
}
}
+void AccountsListModel::removeAccount(const QModelIndex &index)
+{
+ kDebug();
+
+ if(!index.isValid()) {
+ kDebug() << "Can't remove Account: Invalid index";
+ return;
+ }
+ AccountItem *accountItem = m_readyAccounts.at(index.row());
+
+ Q_ASSERT(accountItem);
+
+ accountItem->remove();
+}
+
void AccountsListModel::onAccountItemReady()
{
kDebug();
@@ -202,8 +198,8 @@ void AccountsListModel::onAccountItemRemoved()
return;
}
- beginRemoveRows(QModelIndex(), m_readyAccounts.lastIndexOf(item)-1,
- m_readyAccounts.lastIndexOf(item)-1);
+ beginRemoveRows(QModelIndex(), m_readyAccounts.lastIndexOf(item),
+ m_readyAccounts.lastIndexOf(item));
m_readyAccounts.removeAll(item);
m_unreadyAccounts.removeAll(item);
endRemoveRows();
diff --git a/src/accounts-list-model.h b/src/accounts-list-model.h
index 02fd381..6922833 100644
--- a/src/accounts-list-model.h
+++ b/src/accounts-list-model.h
@@ -40,6 +40,7 @@ public:
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);
+ void removeAccount(const QModelIndex &index);
private Q_SLOTS:
void onAccountItemReady();
diff --git a/src/kcm-telepathy-accounts.cpp b/src/kcm-telepathy-accounts.cpp
index e7043f7..1d8cea6 100644
--- a/src/kcm-telepathy-accounts.cpp
+++ b/src/kcm-telepathy-accounts.cpp
@@ -23,9 +23,10 @@
#include "accounts-list-model.h"
#include "add-account-assistant.h"
-#include <KCategorizedSortFilterProxyModel>
-#include <KCategoryDrawer>
#include <KGenericFactory>
+#include <KIcon>
+#include <KLocale>
+#include <KMessageBox>
#include <TelepathyQt4/Account>
#include <TelepathyQt4/PendingOperation>
@@ -38,7 +39,6 @@ K_EXPORT_PLUGIN(KCMTelepathyAccountsFactory("telepathy_accounts", "kcm_telepathy
KCMTelepathyAccounts::KCMTelepathyAccounts(QWidget *parent, const QVariantList& args)
: KCModule(KCMTelepathyAccountsFactory::componentData(), parent, args),
- m_accountsListProxyModel(0),
m_accountsListModel(0),
m_addAccountAssistant(0)
{
@@ -53,18 +53,24 @@ KCMTelepathyAccounts::KCMTelepathyAccounts(QWidget *parent, const QVariantList&
// Set up the UI stuff.
setupUi(this);
- m_accountsListView->setCategoryDrawer(new KCategoryDrawer);
m_accountsListModel = new AccountsListModel(this);
- m_accountsListProxyModel = new KCategorizedSortFilterProxyModel(this);
- m_accountsListProxyModel->setSourceModel(m_accountsListModel);
- m_accountsListView->setModel(m_accountsListProxyModel);
- m_accountsListProxyModel->setCategorizedModel(true);
+ m_accountsListView->setModel(m_accountsListModel);
+
+ m_addAccountButton->setIcon(KIcon("list-add"));
+ m_editAccountButton->setIcon(KIcon("configure"));
+ m_removeAccountButton->setIcon(KIcon("edit-delete"));
// Connect to useful signals from the UI elements.
connect(m_addAccountButton,
SIGNAL(clicked()),
SLOT(onAddAccountClicked()));
+ connect(m_removeAccountButton,
+ SIGNAL(clicked()),
+ SLOT(onRemoveAccountClicked()));
+ connect(m_accountsListView->selectionModel(),
+ SIGNAL(currentChanged(QModelIndex, QModelIndex)),
+ SLOT(onSelectedItemChanged()));
}
KCMTelepathyAccounts::~KCMTelepathyAccounts()
@@ -102,6 +108,13 @@ void KCMTelepathyAccounts::onAccountManagerReady(Tp::PendingOperation *op)
}
}
+void KCMTelepathyAccounts::onSelectedItemChanged()
+{
+ bool isAccount = m_accountsListView->currentIndex().isValid();
+ m_removeAccountButton->setEnabled(isAccount);
+ m_editAccountButton->setEnabled(isAccount);
+}
+
void KCMTelepathyAccounts::onAddAccountClicked()
{
kDebug();
@@ -130,6 +143,19 @@ void KCMTelepathyAccounts::onAddAccountClicked()
kWarning() << "Cannot create a new AddAccountAssistant. One already exists.";
}
+void KCMTelepathyAccounts::onRemoveAccountClicked()
+{
+ kDebug();
+ QModelIndex index = m_accountsListView->currentIndex();
+
+ if ( KMessageBox::warningContinueCancel( this, i18n( "Are you sure you want to remove the account \"%1\"?", m_accountsListModel->data(index, Qt::DisplayRole).toString()),
+ i18n( "Remove Account" ), KGuiItem(i18n( "Remove Account" ), "edit-delete"), KStandardGuiItem::cancel(),
+ QString(), KMessageBox::Notify | KMessageBox::Dangerous ) == KMessageBox::Continue )
+ {
+ m_accountsListModel->removeAccount(index);
+ }
+}
+
void KCMTelepathyAccounts::onAddAccountAssistantCancelled()
{
kDebug();
diff --git a/src/kcm-telepathy-accounts.h b/src/kcm-telepathy-accounts.h
index 04797aa..a90d5b2 100644
--- a/src/kcm-telepathy-accounts.h
+++ b/src/kcm-telepathy-accounts.h
@@ -30,8 +30,6 @@
class AccountsListModel;
class AddAccountAssistant;
-class KCategorizedSortFilterProxyModel;
-
namespace Tp {
class PendingOperation;
}
@@ -52,11 +50,12 @@ public Q_SLOTS:
private Q_SLOTS:
void onAccountManagerReady(Tp::PendingOperation *op);
+ void onSelectedItemChanged();
void onAddAccountClicked();
+ void onRemoveAccountClicked();
void onAddAccountAssistantCancelled();
private:
- KCategorizedSortFilterProxyModel *m_accountsListProxyModel;
Tp::AccountManagerPtr m_accountManager;
AccountsListModel *m_accountsListModel;
AddAccountAssistant *m_addAccountAssistant;
diff --git a/src/main-widget.ui b/src/main-widget.ui
index 33017dd..b8ad1e5 100644
--- a/src/main-widget.ui
+++ b/src/main-widget.ui
@@ -14,7 +14,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
- <widget class="KCategorizedView" name="m_accountsListView">
+ <widget class="QListView" name="m_accountsListView">
<property name="iconSize">
<size>
<width>32</width>
@@ -39,6 +39,9 @@
</item>
<item>
<widget class="KPushButton" name="m_editAccountButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="text">
<string>Edit Account</string>
</property>
@@ -46,6 +49,9 @@
</item>
<item>
<widget class="KPushButton" name="m_removeAccountButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="text">
<string>Remove Account</string>
</property>
@@ -74,11 +80,6 @@
</widget>
<customwidgets>
<customwidget>
- <class>KCategorizedView</class>
- <extends>QListView</extends>
- <header>kcategorizedview.h</header>
- </customwidget>
- <customwidget>
<class>KPushButton</class>
<extends>QPushButton</extends>
<header>kpushbutton.h</header>
--
ktp-accounts-kcm packaging
More information about the pkg-kde-commits
mailing list