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


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

The following commit has been merged in the master branch:
commit 8978ec6dcf33c5596b7d2c9afba7ea316b62a9e8
Author: George Goldberg <grundleborg at googlemail.com>
Date:   Wed Mar 10 18:16:23 2010 +0000

    Create a nice AbstractTreeItem class, which takes care of parent/child stuff, and use it for the base contactlist class.
    
    svn path=/trunk/playground/network/telepathy-contactlist/; revision=1101725
---
 CMakeLists.txt                          |  1 +
 main-widget.h => abstract-tree-item.cpp | 49 ++++++++++++++----------
 main-widget.h => abstract-tree-item.h   | 36 +++++++++---------
 contact-item.cpp                        |  3 +-
 contact-item.h                          |  8 +++-
 contacts-list-model.cpp                 | 67 +++++++--------------------------
 contacts-list-model.h                   | 27 ++-----------
 meta-contact-item.cpp                   |  5 ++-
 meta-contact-item.h                     |  7 +++-
 9 files changed, 80 insertions(+), 123 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 323aadf..149c801 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -146,6 +146,7 @@ set (contactlist_SRCS
      nepomuk-signal-watcher.cpp
      grouped-contacts-proxy-model.cpp
      meta-contact-item.cpp
+     abstract-tree-item.cpp
 )
 
 kde4_add_ui_files (contactlist_SRCS
diff --git a/main-widget.h b/abstract-tree-item.cpp
similarity index 57%
copy from main-widget.h
copy to abstract-tree-item.cpp
index d11901e..a51b438 100644
--- a/main-widget.h
+++ b/abstract-tree-item.cpp
@@ -1,7 +1,7 @@
 /*
  * This file is part of telepathy-contactslist-prototype
  *
- * Copyright (C) 2009-2010 Collabora Ltd. <info at collabora.co.uk>
+ * Copyright (C) 2010 Collabora Ltd. <info at collabora.co.uk>
  *   @Author George Goldberg <george.goldberg at collabora.co.uk>
  *
  * This library is free software; you can redistribute it and/or
@@ -19,32 +19,41 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef TELEPATHY_CONTACTSLIST_PROTOTYPE_MAIN_WIDGET_H
-#define TELEPATHY_CONTACTSLIST_PROTOTYPE_MAIN_WIDGET_H
+#include "abstract-tree-item.h"
 
-#include "ui_main-widget.h"
+AbstractTreeItem::AbstractTreeItem()
+ : m_parent(0)
+{
+
+}
 
-#include <QtGui/QWidget>
+AbstractTreeItem::~AbstractTreeItem()
+{
 
-class ContactsListModel;
-class GroupedContactsProxyModel;
-class QSortFilterProxyModel;
+}
 
-class MainWidget : public QWidget, Ui::MainWidget
+QList<AbstractTreeItem*> AbstractTreeItem::childItems() const
 {
-    Q_OBJECT
-    
-public:
-    MainWidget(QWidget *parent = 0);
-    ~MainWidget();
+    return m_children;
+}
 
-private:
-    ContactsListModel *m_model;
-    GroupedContactsProxyModel *m_groupedContactsProxyModel;
-    QSortFilterProxyModel *m_sortFilterProxyModel;
+AbstractTreeItem *AbstractTreeItem::parentItem() const
+{
+    return m_parent;
+}
 
-};
+void AbstractTreeItem::appendChildItem(AbstractTreeItem *child)
+{
+    m_children.append(child);
+}
 
+void AbstractTreeItem::removeChildItem(AbstractTreeItem *child)
+{
+    m_children.removeOne(child);
+}
 
-#endif // Header guard
+void AbstractTreeItem::setParentItem(AbstractTreeItem *parent)
+{
+    m_parent = parent;
+}
 
diff --git a/main-widget.h b/abstract-tree-item.h
similarity index 59%
copy from main-widget.h
copy to abstract-tree-item.h
index d11901e..f1b827f 100644
--- a/main-widget.h
+++ b/abstract-tree-item.h
@@ -1,7 +1,7 @@
 /*
  * This file is part of telepathy-contactslist-prototype
  *
- * Copyright (C) 2009-2010 Collabora Ltd. <info at collabora.co.uk>
+ * Copyright (C) 2010 Collabora Ltd. <info at collabora.co.uk>
  *   @Author George Goldberg <george.goldberg at collabora.co.uk>
  *
  * This library is free software; you can redistribute it and/or
@@ -19,30 +19,28 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef TELEPATHY_CONTACTSLIST_PROTOTYPE_MAIN_WIDGET_H
-#define TELEPATHY_CONTACTSLIST_PROTOTYPE_MAIN_WIDGET_H
+#ifndef TELEPATHY_CONTACTSLIST_PROTOTYPE_ABSTRACT_TREE_ITEM_H
+#define TELEPATHY_CONTACTSLIST_PROTOTYPE_ABSTRACT_TREE_ITEM_H
 
-#include "ui_main-widget.h"
+#include <QtCore/QList>
 
-#include <QtGui/QWidget>
-
-class ContactsListModel;
-class GroupedContactsProxyModel;
-class QSortFilterProxyModel;
-
-class MainWidget : public QWidget, Ui::MainWidget
+class AbstractTreeItem
 {
-    Q_OBJECT
-    
 public:
-    MainWidget(QWidget *parent = 0);
-    ~MainWidget();
+    AbstractTreeItem();
+    virtual ~AbstractTreeItem();
 
-private:
-    ContactsListModel *m_model;
-    GroupedContactsProxyModel *m_groupedContactsProxyModel;
-    QSortFilterProxyModel *m_sortFilterProxyModel;
+    virtual void appendChildItem(AbstractTreeItem *child);
+    virtual void removeChildItem(AbstractTreeItem *child);
 
+    virtual void setParentItem(AbstractTreeItem *parent);
+
+    QList<AbstractTreeItem*> childItems() const;
+    AbstractTreeItem *parentItem() const;
+
+private:
+    QList<AbstractTreeItem*> m_children;
+    AbstractTreeItem *m_parent;
 };
 
 
diff --git a/contact-item.cpp b/contact-item.cpp
index 0c78910..e4665eb 100644
--- a/contact-item.cpp
+++ b/contact-item.cpp
@@ -28,7 +28,8 @@
 ContactItem::ContactItem(Nepomuk::PersonContact personContact,
                          Nepomuk::IMAccount imAccount,
                          QObject *parent)
-  : ContactsListModelItem(parent),
+  : QObject(parent),
+    AbstractTreeItem(),
     m_personContact(personContact),
     m_imAccount(imAccount),
     m_presenceIcon(new KIcon)
diff --git a/contact-item.h b/contact-item.h
index c278af0..f6e2da1 100644
--- a/contact-item.h
+++ b/contact-item.h
@@ -22,8 +22,8 @@
 #ifndef TELEPATHY_CONTACTSLIST_PROTOTYPE_CONTACT_ITEM_H
 #define TELEPATHY_CONTACTSLIST_PROTOTYPE_CONTACT_ITEM_H
 
+#include "abstract-tree-item.h"
 #include "nepomuk-signal-watcher.h"
-#include "contacts-list-model.h"
 
 #include "imaccount.h"
 #include "personcontact.h"
@@ -32,7 +32,10 @@
 
 #include <QObject>
 
-class ContactItem : public ContactsListModelItem, NepomukSignalWatcher::Watcher {
+class ContactItem : public QObject,
+                    public AbstractTreeItem,
+                    protected NepomukSignalWatcher::Watcher
+{
 
     Q_OBJECT
 
@@ -64,5 +67,6 @@ private:
     KIcon *m_presenceIcon;
 };
 
+
 #endif // Header guard
 
diff --git a/contacts-list-model.cpp b/contacts-list-model.cpp
index 22d0362..a800180 100644
--- a/contacts-list-model.cpp
+++ b/contacts-list-model.cpp
@@ -21,6 +21,7 @@
 
 #include "contacts-list-model.h"
 
+#include "abstract-tree-item.h"
 #include "contact-item.h"
 #include "meta-contact-item.h"
 
@@ -44,47 +45,6 @@
 
 #include <unistd.h>
 
-ContactsListModelItem::ContactsListModelItem(QObject *parent)
- : QObject(parent),
-   m_parent(0)
-{
-
-}
-
-ContactsListModelItem::~ContactsListModelItem()
-{
-
-}
-
-QList<ContactsListModelItem*> ContactsListModelItem::childItems() const
-{
-    return m_children;
-}
-
-ContactsListModelItem *ContactsListModelItem::parentItem() const
-{
-    return m_parent;
-}
-
-void ContactsListModelItem::appendChildItem(ContactsListModelItem *child)
-{
-    m_children.append(child);
-}
-
-void ContactsListModelItem::removeChildItem(ContactsListModelItem *child)
-{
-    m_children.removeOne(child);
-}
-
-void ContactsListModelItem::setParentItem(ContactsListModelItem *parent)
-{
-    m_parent = parent;
-}
-
-
-// -------------------------------------------------------------------------------------------------
-
-
 ContactsListModel::ContactsListModel(QObject *parent)
  : QAbstractItemModel(parent),
    m_rootItem(0)
@@ -92,7 +52,7 @@ ContactsListModel::ContactsListModel(QObject *parent)
     kDebug();
 
     // Create the root Item.
-    m_rootItem = new ContactsListModelItem;
+    m_rootItem = new AbstractTreeItem;
 
     // FIXME: Get the Nepomuk Resource for myself in the standardised way, once it is standardised.
     Nepomuk::Resource me(QUrl::fromEncoded("nepomuk:/myself"));
@@ -167,7 +127,7 @@ int ContactsListModel::rowCount(const QModelIndex &parent) const
     }
 
     // Get the item from the internal pointer of the ModelIndex.
-    ContactsListModelItem *item = static_cast<ContactsListModelItem*>(parent.internalPointer());
+    AbstractTreeItem *item = static_cast<AbstractTreeItem*>(parent.internalPointer());
 
     // If the item is valid, return the number of children it has.
     if (item) {
@@ -192,8 +152,8 @@ QVariant ContactsListModel::data(const QModelIndex &index, int role) const
     }
 
     // Check what type of item we have here.
-    ContactsListModelItem *clmItem = static_cast<ContactItem*>(index.internalPointer());
-    ContactItem *contactItem = qobject_cast<ContactItem*>(clmItem);
+    AbstractTreeItem *abstractItem = static_cast<AbstractTreeItem*>(index.internalPointer());
+    ContactItem *contactItem = dynamic_cast<ContactItem*>(abstractItem);
 
     kDebug() << contactItem;
 
@@ -221,7 +181,7 @@ QVariant ContactsListModel::data(const QModelIndex &index, int role) const
         return data;
     }
 
-    MetaContactItem *metaContactItem = qobject_cast<MetaContactItem*>(clmItem);
+    MetaContactItem *metaContactItem = dynamic_cast<MetaContactItem*>(abstractItem);
 
     if (metaContactItem) {
         QVariant data;
@@ -265,8 +225,8 @@ QModelIndex ContactsListModel::parent(const QModelIndex &index) const
     }
 
     // Get the item we have been passed, and it's parent
-    ContactsListModelItem *childItem = item(index);
-    ContactsListModelItem *parentItem = childItem->parentItem();
+    AbstractTreeItem *childItem = item(index);
+    AbstractTreeItem *parentItem = childItem->parentItem();
 
     // If the parent is the root item, then the parent index of the index we were passed is
     // by definition an invalid index.
@@ -275,7 +235,7 @@ QModelIndex ContactsListModel::parent(const QModelIndex &index) const
     }
 
     // The parent of the item is not the root item, meaning that the parent must have a parent too.
-    ContactsListModelItem *parentOfParentItem = parentItem->parentItem();
+    AbstractTreeItem *parentOfParentItem = parentItem->parentItem();
 
     // As stated in the previous comment, something is really wrong if it doesn't have a parent.
     Q_ASSERT(parentOfParentItem);
@@ -298,10 +258,10 @@ QModelIndex ContactsListModel::index(int row, int column, const QModelIndex &par
     }
 
     // Get the parent item.
-    ContactsListModelItem *parentItem = item(parent);
+    AbstractTreeItem *parentItem = item(parent);
 
     // Get all the parent's children.
-    QList<ContactsListModelItem*> children = parentItem->childItems();
+    QList<AbstractTreeItem*> children = parentItem->childItems();
 
     // Check the row doesn't go beyond the end of the list of children.
     if (row >= children.length()) {
@@ -314,10 +274,10 @@ QModelIndex ContactsListModel::index(int row, int column, const QModelIndex &par
     return createIndex(row, column, children.at(row));
 }
 
-ContactsListModelItem* ContactsListModel::item(const QModelIndex &index) const
+AbstractTreeItem* ContactsListModel::item(const QModelIndex &index) const
 {
     if (index.isValid()) {
-        ContactsListModelItem *item = static_cast<ContactsListModelItem*>(index.internalPointer());
+        AbstractTreeItem *item = static_cast<AbstractTreeItem*>(index.internalPointer());
          if (item) {
              return item;
          }
@@ -351,5 +311,6 @@ void ContactsListModel::onItemDirty()
    // Q_EMIT dataChanged(itemIndex, itemIndex);
 }
 
+
 #include "contacts-list-model.moc"
 
diff --git a/contacts-list-model.h b/contacts-list-model.h
index fcdf531..0d2f6d9 100644
--- a/contacts-list-model.h
+++ b/contacts-list-model.h
@@ -24,28 +24,7 @@
 
 #include <QtCore/QAbstractItemModel>
 
-class ContactItem;
-
-class ContactsListModelItem : public QObject
-{
-    Q_OBJECT
-
-public:
-    ContactsListModelItem(QObject *parent = 0);
-    virtual ~ContactsListModelItem();
-
-    virtual void appendChildItem(ContactsListModelItem *child);
-    virtual void removeChildItem(ContactsListModelItem *child);
-
-    virtual void setParentItem(ContactsListModelItem *parent);
-
-    virtual QList<ContactsListModelItem*> childItems() const;
-    virtual ContactsListModelItem *parentItem() const;
-
-private:
-    QList<ContactsListModelItem*> m_children;
-    ContactsListModelItem *m_parent;
-};
+class AbstractTreeItem;
 
 class ContactsListModel : public QAbstractItemModel
 {
@@ -78,9 +57,9 @@ private Q_SLOTS:
 private:
     Q_DISABLE_COPY(ContactsListModel);
 
-    ContactsListModelItem *item(const QModelIndex &index) const;
+    AbstractTreeItem *item(const QModelIndex &index) const;
 
-    ContactsListModelItem *m_rootItem;
+    AbstractTreeItem *m_rootItem;
 };
 
 
diff --git a/meta-contact-item.cpp b/meta-contact-item.cpp
index a450868..9e34ee4 100644
--- a/meta-contact-item.cpp
+++ b/meta-contact-item.cpp
@@ -26,7 +26,8 @@
 #include <KDebug>
 
 MetaContactItem::MetaContactItem(MetaContactType type, QObject *parent)
-  : ContactsListModelItem(parent),
+  : QObject(parent),
+    AbstractTreeItem(),
     m_type(type)
 {
     if (type == RealMetaContact) {
@@ -69,7 +70,7 @@ QString MetaContactItem::displayName() const
         return QString();
     }
 
-    ContactItem *item = qobject_cast<ContactItem*>(childItems().first());
+    ContactItem *item = dynamic_cast<ContactItem*>(childItems().first());
 
     if (!item) {
         return QString();
diff --git a/meta-contact-item.h b/meta-contact-item.h
index f75b0fb..e98ae12 100644
--- a/meta-contact-item.h
+++ b/meta-contact-item.h
@@ -22,15 +22,18 @@
 #ifndef TELEPATHY_CONTACTSLIST_PROTOTYPE_META_CONTACT_ITEM_H
 #define TELEPATHY_CONTACTSLIST_PROTOTYPE_META_CONTACT_ITEM_H
 
+#include "abstract-tree-item.h"
 #include "nepomuk-signal-watcher.h"
-#include "contacts-list-model.h"
 
 #include "person.h"
 #include "personcontact.h"
 
 #include <QObject>
 
-class MetaContactItem : public ContactsListModelItem, NepomukSignalWatcher::Watcher {
+class MetaContactItem : public QObject,
+                        public AbstractTreeItem,
+                        protected NepomukSignalWatcher::Watcher
+{
 
     Q_OBJECT
 

-- 
ktp-contact-list packaging



More information about the pkg-kde-commits mailing list