[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:00:50 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-accounts-kcm.git;a=commitdiff;h=4935dd3

The following commit has been merged in the master branch:
commit 4935dd329584fa63871f2f64879c71901d424fbf
Author: Martin Klapetek <martin.klapetek at gmail.com>
Date:   Tue Dec 27 15:15:48 2011 +0100

    Get rid of itemForIndex and add new AccountsListModel role to return AccountItem
    
    Reviewed-by: David Edmundson
---
 src/account-item.h             |  1 +
 src/accounts-list-delegate.cpp | 13 ++++++++++++-
 src/accounts-list-model.cpp    | 10 +++++++---
 src/accounts-list-model.h      |  7 ++++---
 src/kcm-telepathy-accounts.cpp |  6 +++---
 5 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/src/account-item.h b/src/account-item.h
index 8a7bde0..f59853a 100644
--- a/src/account-item.h
+++ b/src/account-item.h
@@ -68,6 +68,7 @@ private:
     KIcon* m_icon;
 };
 
+Q_DECLARE_METATYPE(AccountItem*);
 
 #endif // header guard
 
diff --git a/src/accounts-list-delegate.cpp b/src/accounts-list-delegate.cpp
index f670e0f..4feb8df 100644
--- a/src/accounts-list-delegate.cpp
+++ b/src/accounts-list-delegate.cpp
@@ -29,6 +29,9 @@
 
 #include <KDebug>
 #include <KLocale>
+#include <QSortFilterProxyModel>
+
+#include "account-item.h"
 
 AccountsListDelegate::AccountsListDelegate(QAbstractItemView *itemView, QObject *parent)
     : KWidgetItemDelegate(itemView, parent)
@@ -49,13 +52,17 @@ QList<QWidget*> AccountsListDelegate::createItemWidgets() const
 {
     QCheckBox *checkbox = new QCheckBox();
     checkbox->setToolTip(i18n("Enable account"));
-    connect(checkbox, SIGNAL(toggled(bool)), SLOT(onCheckBoxToggled(bool)));
+    connect(checkbox, SIGNAL(clicked(bool)), SLOT(onCheckBoxToggled(bool)));
     return QList<QWidget*>() << checkbox;
 }
 
 
 void AccountsListDelegate::updateItemWidgets(const QList<QWidget *> widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const
 {
+    if (!index.isValid()) {
+        return;
+    }
+
     QCheckBox* checkbox = qobject_cast<QCheckBox*>(widgets.at(0));
     if (checkbox) {
         int topMargin = (option.rect.height() - checkbox->height()) / 2;
@@ -86,6 +93,10 @@ void AccountsListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
     //draws Checkbox | Icon | AccountName  | ConnectionIcon | ConnectionState
     //               |      | errorMessage |                |
 
+    if (!index.isValid()) {
+        return;
+    }
+
     QStyle *style = QApplication::style();
 
     style->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter, 0);
diff --git a/src/accounts-list-model.cpp b/src/accounts-list-model.cpp
index b1a6e05..58db79e 100644
--- a/src/accounts-list-model.cpp
+++ b/src/accounts-list-model.cpp
@@ -104,6 +104,10 @@ QVariant AccountsListModel::data(const QModelIndex &index, int role) const
         data = QVariant(m_accounts.at(index.row())->connectionProtocolName());
         break;
 
+    case AccountsListModel::AccountItemRole:
+        data = QVariant::fromValue<AccountItem*>(m_accounts.at(index.row()));
+        break;
+
     default:
         break;
     }
@@ -118,8 +122,8 @@ bool AccountsListModel::setData(const QModelIndex &index, const QVariant &value,
     }
     kDebug();
     if(role == Qt::CheckStateRole) {
-        m_accounts.at(index.row())->account()->setEnabled(value.toInt() == Qt::Checked);
-        kDebug() << "shit";
+        //this is index from QSortFilterProxyModel
+        index.data(AccountItemRole).value<AccountItem*>()->account()->setEnabled(value.toInt() == Qt::Checked);
         return true;
     }
 
@@ -230,7 +234,7 @@ void AccountsListModel::onAccountItemRemoved()
     endRemoveRows();
 
     // FIXME: Workaround until the KWidgetItemDelegate gets fixed (probably KDE 4.7)
-    reset();
+    //reset();
     delete item;
 }
 
diff --git a/src/accounts-list-model.h b/src/accounts-list-model.h
index 1101172..061c192 100644
--- a/src/accounts-list-model.h
+++ b/src/accounts-list-model.h
@@ -35,9 +35,10 @@ class AccountsListModel : public QAbstractListModel
 public:
     enum Roles {
         ConnectionStateDisplayRole = Qt::UserRole+1,
-        ConnectionStateIconRole = Qt::UserRole+2,
-        ConnectionErrorMessageDisplayRole = Qt::UserRole+3,
-        ConnectionProtocolNameRole = Qt::UserRole+4
+        ConnectionStateIconRole,
+        ConnectionErrorMessageDisplayRole,
+        ConnectionProtocolNameRole,
+        AccountItemRole
     };
 
     explicit AccountsListModel(QObject *parent = 0);
diff --git a/src/kcm-telepathy-accounts.cpp b/src/kcm-telepathy-accounts.cpp
index fea2ab8..3f0853d 100644
--- a/src/kcm-telepathy-accounts.cpp
+++ b/src/kcm-telepathy-accounts.cpp
@@ -213,7 +213,7 @@ void KCMTelepathyAccounts::onAccountEnabledChanged(const QModelIndex &index, boo
 
     if (enabled) {
         // connect the account
-        AccountItem *item = m_accountsListModel->itemForIndex(index);
+        AccountItem *item = index.data(AccountsListModel::AccountItemRole).value<AccountItem*>();
         if (item) {
             item->account()->setRequestedPresence(Tp::Presence::available());
         }
@@ -300,7 +300,7 @@ void KCMTelepathyAccounts::onEditAccountClicked()
     }
 
     QModelIndex index = m_currentListView->currentIndex();
-    AccountItem *item = m_accountsListModel->itemForIndex(m_currentModel->mapToSource(index));
+    AccountItem *item = index.data(AccountsListModel::AccountItemRole).value<AccountItem*>();
 
     if (!item)
         return;
@@ -319,7 +319,7 @@ void KCMTelepathyAccounts::onRemoveAccountClicked()
                                         i18n("Remove Account"), KGuiItem(i18n("Remove Account"), "edit-delete"), KStandardGuiItem::cancel(),
                                         QString(), KMessageBox::Notify | KMessageBox::Dangerous) == KMessageBox::Continue)
     {
-        AccountItem *item = m_accountsListModel->itemForIndex(m_currentModel->mapToSource(index));
+        AccountItem *item = index.data(AccountsListModel::AccountItemRole).value<AccountItem*>();
         KTp::WalletInterface wallet(this->effectiveWinId());
         wallet.removeAccount(item->account());
 

-- 
ktp-accounts-kcm packaging



More information about the pkg-kde-commits mailing list