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


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=3e1d3b8

The following commit has been merged in the master branch:
commit 3e1d3b8dd059809134ffdb3548c1e35845df20c3
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Fri Oct 12 14:34:26 2012 +0100

    AccountsListModel now handles new accounts internally
    
    Add a setAccountManager() method to make it list which accounts are shown.
    Also make it use a d pointer
---
 KTp/Models/accounts-list-model.cpp | 40 ++++++++++++++++++++++++--------------
 KTp/Models/accounts-list-model.h   |  8 ++++++--
 2 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/KTp/Models/accounts-list-model.cpp b/KTp/Models/accounts-list-model.cpp
index 4665da4..e19c108 100644
--- a/KTp/Models/accounts-list-model.cpp
+++ b/KTp/Models/accounts-list-model.cpp
@@ -28,10 +28,19 @@
 #include <KTp/error-dictionary.h>
 
 #include <TelepathyQt/Account>
+#include <TelepathyQt/AccountManager>
+
+class AccountsListModel::Private {
+public:
+    QList<Tp::AccountPtr> accounts;
+    Tp::AccountManagerPtr accountManager;
+
+};
 
 
 AccountsListModel::AccountsListModel(QObject *parent)
- : QAbstractListModel(parent)
+ : QAbstractListModel(parent),
+   d(new AccountsListModel::Private)
 {
 }
 
@@ -39,11 +48,17 @@ AccountsListModel::~AccountsListModel()
 {
 }
 
+void AccountsListModel::setAccountManager(const Tp::AccountManagerPtr &accountManager)
+{
+    d->accountManager = accountManager;
+    connect(d->accountManager.data(), SIGNAL(newAccount(Tp::AccountPtr)), SLOT(onAccountAdded(Tp::AccountPtr)));
+}
+
 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();
+       return d->accounts.size();
     }
 
     // Otherwise, return 0 (as this is a list model, so all items
@@ -67,7 +82,7 @@ QVariant AccountsListModel::data(const QModelIndex &index, int role) const
     }
 
     QVariant data;
-    Tp::AccountPtr account = m_accounts.at(index.row());
+    Tp::AccountPtr account = d->accounts.at(index.row());
 
     switch (role) {
     case Qt::DisplayRole:
@@ -153,7 +168,7 @@ Qt::ItemFlags AccountsListModel::flags(const QModelIndex &index) const
     return QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable;
 }
 
-void AccountsListModel::addAccount(const Tp::AccountPtr &account)
+void AccountsListModel::onAccountAdded(const Tp::AccountPtr &account)
 {
     kDebug() << "Creating a new AccountItem from account:" << account.data();
 
@@ -161,7 +176,7 @@ void AccountsListModel::addAccount(const Tp::AccountPtr &account)
     bool found = false;
 
     if (!found) {
-        Q_FOREACH (const Tp::AccountPtr &ai, m_accounts) {
+        Q_FOREACH (const Tp::AccountPtr &ai, d->accounts) {
             if (ai == account) {
                 found = true;
                 break;
@@ -177,12 +192,10 @@ void AccountsListModel::addAccount(const Tp::AccountPtr &account)
         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);
+        beginInsertRows(QModelIndex(), d->accounts.size(), d->accounts.size());
+        d->accounts.append(account);
         endInsertRows();
 
-        connect(account.data(), SIGNAL(removed()), SLOT(onAccountItemRemoved()));
-
         connect(account.data(),
                 SIGNAL(stateChanged(bool)),
                 SLOT(onAccountItemUpdated()));
@@ -213,12 +226,9 @@ void AccountsListModel::onAccountItemRemoved()
 
     // 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);
+    beginRemoveRows(QModelIndex(), d->accounts.indexOf(item), d->accounts.indexOf(item));
+    d->accounts.removeAll(item);
     endRemoveRows();
-
-    // FIXME: Workaround until the KWidgetItemDelegate gets fixed (probably KDE 4.7)
-    //reset();
 }
 
 void AccountsListModel::onAccountItemUpdated()
@@ -231,7 +241,7 @@ void AccountsListModel::onAccountItemUpdated()
         return;
     }
 
-    QModelIndex index = createIndex(m_accounts.lastIndexOf(item), 0);
+    QModelIndex index = createIndex(d->accounts.lastIndexOf(item), 0);
     Q_EMIT dataChanged(index, index);
 }
 
diff --git a/KTp/Models/accounts-list-model.h b/KTp/Models/accounts-list-model.h
index c16b024..8548f3a 100644
--- a/KTp/Models/accounts-list-model.h
+++ b/KTp/Models/accounts-list-model.h
@@ -46,20 +46,24 @@ public:
 
     explicit AccountsListModel(QObject *parent = 0);
     virtual ~AccountsListModel();
+
+    void setAccountManager(const Tp::AccountManagerPtr &accountManager);
+
     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 onAccountAdded(const Tp::AccountPtr &account);
     void onAccountItemRemoved();
     void onAccountItemUpdated();
 
 private:
-    QList<Tp::AccountPtr> m_accounts;
+    class Private;
+    Private * const d;
 
     const QString connectionStateString(const Tp::AccountPtr &account) const;
     const KIcon connectionStateIcon(const Tp::AccountPtr &account) const;

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list