[SCM] ktp-contact-list packaging branch, master, updated. debian/15.12.1-2-1070-g6c56f91

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:11:49 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=f137bc4

The following commit has been merged in the master branch:
commit f137bc40258d908c8d314ce3f09a64a184fa3e79
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Sat Dec 29 12:13:51 2012 +0000

    Add a model that allows for easy grouping of ContactsListModel wrapping all proxies up into a simple class
    
    Note this class is currently called ContactsModel2 because the ktp-common-internals model is not deleted yet, and not namespaced
---
 contacts-model.cpp                         | 53 ++++++++++++++++++++++++++++++
 dialogs/contact-info.h => contacts-model.h | 38 +++++++++++----------
 2 files changed, 73 insertions(+), 18 deletions(-)

diff --git a/contacts-model.cpp b/contacts-model.cpp
new file mode 100644
index 0000000..6e2c667
--- /dev/null
+++ b/contacts-model.cpp
@@ -0,0 +1,53 @@
+#include "contacts-model.h"
+
+#include <KTp/Models/accounts-tree-proxy-model.h>
+#include <KTp/Models/groups-tree-proxy-model.h>
+
+ContactsModel2::ContactsModel2(QObject *parent)
+    : ContactsFilterModel(parent),
+      m_source(new KTp::ContactsListModel(this)),
+      m_groupMode(NoGrouping)
+{
+
+}
+
+void ContactsModel2::setAccountManager(const Tp::AccountManagerPtr &accountManager)
+{
+    m_accountManager = accountManager;
+
+    setGroupMode(m_groupMode); //reload the groups, as AccountGrouping now needs a real accountManager
+    m_source->setAccountManager(accountManager);
+}
+
+void ContactsModel2::setGroupMode(ContactsModel2::GroupMode mode)
+{
+
+    m_groupMode = mode;
+
+    if (!m_accountManager) {
+        mode = NoGrouping; //don't waste time doing any grouping if account manager is not really ready.. as we will have nothing to group anyway
+    }
+
+    if (m_proxy) {
+        m_proxy.data()->deleteLater();
+    }
+
+    switch (mode) {
+    case NoGrouping:
+        setSourceModel(m_source);
+        break;
+    case AccountGrouping:
+        m_proxy = new AccountsTreeProxyModel(m_source, m_accountManager);
+        setSourceModel(m_proxy.data());
+        break;
+    case GroupGrouping:
+        m_proxy = new GroupsTreeProxyModel(m_source);
+        setSourceModel(m_proxy.data());
+        break;
+    }
+}
+
+ContactsModel2::GroupMode ContactsModel2::groupMode() const
+{
+    return m_groupMode;
+}
diff --git a/dialogs/contact-info.h b/contacts-model.h
similarity index 52%
copy from dialogs/contact-info.h
copy to contacts-model.h
index ef81d03..bc845c0 100644
--- a/dialogs/contact-info.h
+++ b/contacts-model.h
@@ -1,5 +1,5 @@
 /*
- * Dialog for showing contact info
+ * Model of all accounts with inbuilt grouping and filtering
  *
  * Copyright (C) 2011 David Edmundson <kde at davidedmundson.co.uk>
  *
@@ -18,29 +18,31 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#ifndef CONTACTSMODEL2_H
+#define CONTACTSMODEL2_H
 
-#ifndef CONTACTINFO_H
-#define CONTACTINFO_H
+#include <KTp/Models/contacts-filter-model.h>
+#include <KTp/Models/contacts-list-model.h>
+#include <KTp/Models/abstract-grouping-proxy-model.h>
 
-#include <KDialog>
-#include <TelepathyQt/Contact>
+#include <TelepathyQt/Types>
 
-
-namespace Ui {
-    class ContactInfo;
-}
-
-class ContactInfo : public KDialog
+class ContactsModel2 : public ContactsFilterModel
 {
-    Q_OBJECT
-
 public:
-    explicit ContactInfo(const Tp::ContactPtr &contact, QWidget *parent = 0);
-    ~ContactInfo();
+    enum GroupMode {NoGrouping, AccountGrouping, GroupGrouping};
+
+    ContactsModel2(QObject *parent);
+    void setAccountManager (const Tp::AccountManagerPtr &accountManager);
+
+    void setGroupMode(GroupMode mode);
+    GroupMode groupMode() const;
 
 private:
-    Ui::ContactInfo *ui;
-    KIcon iconForPresenceState(Tp::Contact::PresenceState state) const;
+    GroupMode m_groupMode;
+    QWeakPointer<AbstractGroupingProxyModel> m_proxy;
+    KTp::ContactsListModel *m_source;
+    Tp::AccountManagerPtr m_accountManager;
 };
 
-#endif // CONTACTINFO_H
+#endif // CONTACTSMODEL_H

-- 
ktp-contact-list packaging



More information about the pkg-kde-commits mailing list