[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=bcb90a5

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

    Misc code tidyup.
    
    svn path=/trunk/playground/network/telepathy-contactlist/; revision=1101726
---
 contact-item.cpp        |   6 +-
 contacts-list-model.cpp | 160 +++++++++++++++++++++++-------------------------
 contacts-list-model.h   |  22 +++----
 meta-contact-item.cpp   |  26 +-------
 meta-contact-item.h     |   4 --
 5 files changed, 92 insertions(+), 126 deletions(-)

diff --git a/contact-item.cpp b/contact-item.cpp
index e4665eb..3a59c34 100644
--- a/contact-item.cpp
+++ b/contact-item.cpp
@@ -34,8 +34,6 @@ ContactItem::ContactItem(Nepomuk::PersonContact personContact,
     m_imAccount(imAccount),
     m_presenceIcon(new KIcon)
 {
-   // kDebug() << this << ": New ContactItem: " << personContact.resourceType().toString() << imAccount.resourceType().toString();
-
     // Subscribe to Nepomuk change signals for our Nepomuk Resources.
     NepomukSignalWatcher *watcher = NepomukSignalWatcher::instance();
     watcher->registerCallbackOnSubject(m_imAccount, this);
@@ -121,6 +119,7 @@ QStringList ContactItem::groups() const
     QStringList groupNames;
 
     if (groups.isEmpty()) {
+        // FIXME: What do we do if there is no group?
         return QStringList() << "No Group";
     }
 
@@ -135,8 +134,7 @@ void ContactItem::onStatementAdded(const Soprano::Statement &statement)
 {
     Q_UNUSED(statement);
 
-    kDebug() << "Statement added called.";
-
+    updatePresenceIcon();
     Q_EMIT dirty();
 }
 
diff --git a/contacts-list-model.cpp b/contacts-list-model.cpp
index a800180..982af46 100644
--- a/contacts-list-model.cpp
+++ b/contacts-list-model.cpp
@@ -57,20 +57,14 @@ ContactsListModel::ContactsListModel(QObject *parent)
     // FIXME: Get the Nepomuk Resource for myself in the standardised way, once it is standardised.
     Nepomuk::Resource me(QUrl::fromEncoded("nepomuk:/myself"));
 
+    // Get the Nepomuk model to query.
+    Soprano::Model *model = Nepomuk::ResourceManager::instance()->mainModel();
+
     // Get ALL THE METACONTACT!!!!11!!111!!11one111!!!!eleven!!!1!
+    // FIXME: Actually make this code do something.
     QString metaContactquery = QString("select distinct ?a where { ?a a %7 . }")
             .arg(Soprano::Node::resourceToN3(Nepomuk::Vocabulary::PIMO::Person()));
 
-    QString query = QString("select distinct ?a ?b where { ?a a %1 . ?a %2 ?b . ?b a %3 . ?b %4 ?r . ?r a %3 . ?s %2 ?r . ?s a %1 . %5 %6 ?s }")
-            .arg(Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NCO::PersonContact()))
-            .arg(Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NCO::hasIMAccount()))
-            .arg(Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NCO::IMAccount()))
-            .arg(Soprano::Node::resourceToN3(Nepomuk::Vocabulary::Telepathy::isBuddyOf()))
-            .arg(Soprano::Node::resourceToN3(me.resourceUri()))
-            .arg(Soprano::Node::resourceToN3(Nepomuk::Vocabulary::PIMO::groundingOccurrence()));
-
-    Soprano::Model *model = Nepomuk::ResourceManager::instance()->mainModel();
-
     Soprano::QueryResultIterator metaIt = model->executeQuery(metaContactquery, Soprano::Query::QueryLanguageSparql);
 
     while(metaIt.next()) {
@@ -83,20 +77,30 @@ ContactsListModel::ContactsListModel(QObject *parent)
    //     connect(item, SIGNAL(dirty()), SLOT(onItemDirty()));
     }
 
+    // Get all the Telepathy PersonContacts that are not in a metacontact
+    // FIXME: At the moment, this just gets all Telepathy PersonContacts.
+    QString query = QString("select distinct ?a ?b where { ?a a %1 . ?a %2 ?b . ?b a %3 . ?b %4 ?r . ?r a %3 . ?s %2 ?r . ?s a %1 . %5 %6 ?s }")
+            .arg(Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NCO::PersonContact()))
+            .arg(Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NCO::hasIMAccount()))
+            .arg(Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NCO::IMAccount()))
+            .arg(Soprano::Node::resourceToN3(Nepomuk::Vocabulary::Telepathy::isBuddyOf()))
+            .arg(Soprano::Node::resourceToN3(me.resourceUri()))
+            .arg(Soprano::Node::resourceToN3(Nepomuk::Vocabulary::PIMO::groundingOccurrence()));
+
     Soprano::QueryResultIterator it = model->executeQuery(query, Soprano::Query::QueryLanguageSparql);
 
     // Iterate over all the IMAccounts/PersonContacts found.
     while(it.next()) {
         Nepomuk::PersonContact foundPersonContact(it.binding("a").uri());
         Nepomuk::IMAccount foundIMAccount(it.binding("b").uri());
-      //  kDebug() << this << ": Found Contact:" << foundIMAccount.imIDs().first();
 
-        // And create a ContactItem for each one.
+        // Create a fake metacontact to hold this item.
         MetaContactItem *metaContactItem = new MetaContactItem(MetaContactItem::FakeMetaContact, 0);
         metaContactItem->setParentItem(m_rootItem);
         m_rootItem->appendChildItem(metaContactItem);
         connect(metaContactItem, SIGNAL(dirty()), SLOT(onItemDirty()));
 
+        // And create the contact item itself, parenting it to the fake meta contact we just created.
         ContactItem *item = new ContactItem(foundPersonContact, foundIMAccount, 0);
         item->setParentItem(metaContactItem);
         metaContactItem->appendChildItem(item);
@@ -113,53 +117,25 @@ int ContactsListModel::columnCount(const QModelIndex &parent) const
 {
     Q_UNUSED(parent);
 
-    // List view, so all items have the same number of columns
+    // All items have the same number of columns
     return 1;
 }
 
-int ContactsListModel::rowCount(const QModelIndex &parent) const
-{
-    kDebug();
-
-    // If the parent is invalid, then this request is for the root item.
-    if (!parent.isValid()) {
-        return m_rootItem->childItems().length();
-    }
-
-    // Get the item from the internal pointer of the ModelIndex.
-    AbstractTreeItem *item = static_cast<AbstractTreeItem*>(parent.internalPointer());
-
-    // If the item is valid, return the number of children it has.
-    if (item) {
-        kDebug() << item->childItems().length();
-        return item->childItems().length();
-    }
-
-    // Otherwise, return 0
-    return 0;
-}
-
 QVariant ContactsListModel::data(const QModelIndex &index, int role) const
 {
-    kDebug() << "index:" << index << "parent:" << index.parent();
     // Only column 0 is valid.
     if (index.column() != 0) {
         return QVariant();
     }
 
-    if (index.internalPointer() == m_rootItem) {
-        kDebug() << "Internal root item pointe rwtf?";
-    }
-
     // Check what type of item we have here.
     AbstractTreeItem *abstractItem = static_cast<AbstractTreeItem*>(index.internalPointer());
     ContactItem *contactItem = dynamic_cast<ContactItem*>(abstractItem);
 
-    kDebug() << contactItem;
-
     if (contactItem) {
-        kDebug() << "Is a contact Item." << contactItem;
+
         QVariant data;
+
         switch(role)
         {
         case Qt::DisplayRole:
@@ -187,6 +163,7 @@ QVariant ContactsListModel::data(const QModelIndex &index, int role) const
         QVariant data;
         switch(role)
         {
+            // FIXME: Implement all the roles properly for meta contacts.
         case Qt::DisplayRole:
             data.setValue<QString>(metaContactItem->displayName());
             break;
@@ -217,6 +194,39 @@ Qt::ItemFlags ContactsListModel::flags(const QModelIndex &index) const
     return QAbstractItemModel::flags(index);
 }
 
+QVariant ContactsListModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+    Q_UNUSED(section);
+
+    if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
+        return QVariant("Contact Name");
+    }
+
+    return QVariant();
+}
+
+QModelIndex ContactsListModel::index(int row, int column, const QModelIndex &parent) const
+{
+    // 1 column list, so invalid index if the column is not 1.
+    if (parent.isValid() && parent.column() != 0) {
+        return QModelIndex();
+    }
+
+    // Get the parent item.
+    AbstractTreeItem *parentItem = item(parent);
+
+    // Get all the parent's children.
+    QList<AbstractTreeItem*> children = parentItem->childItems();
+
+    // Check the row doesn't go beyond the end of the list of children.
+    if (row >= children.length()) {
+        return QModelIndex();
+    }
+
+    // Return the index to the item.
+    return createIndex(row, column, children.at(row));
+}
+
 QModelIndex ContactsListModel::parent(const QModelIndex &index) const
 {
     // If the index is invalid, return an invalid parent index.
@@ -248,53 +258,23 @@ QModelIndex ContactsListModel::parent(const QModelIndex &index) const
     return createIndex(parentOfParentItem->childItems().lastIndexOf(parentItem), 0, parentItem);
 }
 
-QModelIndex ContactsListModel::index(int row, int column, const QModelIndex &parent) const
+int ContactsListModel::rowCount(const QModelIndex &parent) const
 {
-    kDebug();
-    // 1 column list, so invalid index if the column is not 1.
-    if (parent.isValid() && parent.column() != 0) {
-        kDebug() << "Wrong column";
-        return QModelIndex();
-    }
-
-    // Get the parent item.
-    AbstractTreeItem *parentItem = item(parent);
-
-    // Get all the parent's children.
-    QList<AbstractTreeItem*> children = parentItem->childItems();
-
-    // Check the row doesn't go beyond the end of the list of children.
-    if (row >= children.length()) {
-        kDebug() << "Bounds error";
-        return QModelIndex();
+    // If the parent is invalid, then this request is for the root item.
+    if (!parent.isValid()) {
+        return m_rootItem->childItems().length();
     }
 
-    // Return the index to the item.
-    kDebug() << "AOK:" << row << column << children.at(row);
-    return createIndex(row, column, children.at(row));
-}
-
-AbstractTreeItem* ContactsListModel::item(const QModelIndex &index) const
-{
-    if (index.isValid()) {
-        AbstractTreeItem *item = static_cast<AbstractTreeItem*>(index.internalPointer());
-         if (item) {
-             return item;
-         }
-     }
-
-     return m_rootItem;
-}
-
-QVariant ContactsListModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
-    Q_UNUSED(section);
+    // Get the item from the internal pointer of the ModelIndex.
+    AbstractTreeItem *item = static_cast<AbstractTreeItem*>(parent.internalPointer());
 
-    if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
-        return QVariant("Contact Name");
+    // If the item is valid, return the number of children it has.
+    if (item) {
+        return item->childItems().length();
     }
 
-    return QVariant();
+    // Otherwise, return 0
+    return 0;
 }
 
 void ContactsListModel::onItemDirty()
@@ -311,6 +291,18 @@ void ContactsListModel::onItemDirty()
    // Q_EMIT dataChanged(itemIndex, itemIndex);
 }
 
+AbstractTreeItem* ContactsListModel::item(const QModelIndex &index) const
+{
+    if (index.isValid()) {
+        AbstractTreeItem *item = static_cast<AbstractTreeItem*>(index.internalPointer());
+         if (item) {
+             return item;
+         }
+     }
+
+     return m_rootItem;
+}
+
 
 #include "contacts-list-model.moc"
 
diff --git a/contacts-list-model.h b/contacts-list-model.h
index 0d2f6d9..5d608fa 100644
--- a/contacts-list-model.h
+++ b/contacts-list-model.h
@@ -39,17 +39,17 @@ public:
     explicit ContactsListModel(QObject *parent = 0);
     virtual ~ContactsListModel();
 
-     virtual QVariant data(const QModelIndex &index, int role) const;
-     virtual Qt::ItemFlags flags(const QModelIndex &index) const;
-     virtual QVariant headerData(int section,
-                                 Qt::Orientation orientation,
-                                 int role = Qt::DisplayRole) const;
-     virtual QModelIndex index(int row,
-                               int column,
-                               const QModelIndex &parent = QModelIndex()) const;
-     virtual QModelIndex parent(const QModelIndex &index) const;
-     virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
-     virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
+    virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
+    virtual QVariant data(const QModelIndex &index, int role) const;
+    virtual Qt::ItemFlags flags(const QModelIndex &index) const;
+    virtual QVariant headerData(int section,
+                                Qt::Orientation orientation,
+                                int role = Qt::DisplayRole) const;
+    virtual QModelIndex index(int row,
+                              int column,
+                              const QModelIndex &parent = QModelIndex()) const;
+    virtual QModelIndex parent(const QModelIndex &index) const;
+    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
 
 private Q_SLOTS:
     void onItemDirty();
diff --git a/meta-contact-item.cpp b/meta-contact-item.cpp
index 9e34ee4..02baba7 100644
--- a/meta-contact-item.cpp
+++ b/meta-contact-item.cpp
@@ -33,11 +33,11 @@ MetaContactItem::MetaContactItem(MetaContactType type, QObject *parent)
     if (type == RealMetaContact) {
         // A Real metacontact. Wait for the setPimoPerson to be called before
         // setting everything up.
-        kDebug() << "Constructing new Real MetaContact.";
+ 
     } else if (type == FakeMetaContact) {
         // A fake Meta-Contact. There is no PIMO:Person, so wait for setPersonContact()
         // to be called before doing the setup.
-        kDebug() << "Constructing new Fake MetaContact.";
+
     }
 }
 
@@ -50,8 +50,6 @@ void MetaContactItem::onStatementAdded(const Soprano::Statement &statement)
 {
     Q_UNUSED(statement);
 
-    kDebug() << "Statement added called.";
-
     Q_EMIT dirty();
 }
 
@@ -66,6 +64,7 @@ void MetaContactItem::setPimoPerson(const Nepomuk::Person& pimoPerson)
 
 QString MetaContactItem::displayName() const
 {
+    // FIXME: What should we actually return here?
     if (childItems().isEmpty()) {
         return QString();
     }
@@ -78,26 +77,7 @@ QString MetaContactItem::displayName() const
 
     return item->displayName();
 }
-/*
-void MetaContactItem::setPersonContact(const Nepomuk::PersonContact &personContact)
-{
-    // This should only be called if the meta contact is fake.
-    Q_ASSERT(m_type == FakeMetaContact);
-    if (m_type != FakeMetaContact) {
-        kWarning() << "setPersonContact called on real meta contact. This should not happen.";
-        return;
-    }
-
-    // The list of personContacts should be empty when this is called.
-    Q_ASSERT(!m_personContacts.isEmpty());
-    if (!m_personContacts.isEmpty()) {
-        kWarning() << "We already have a person contact set for this fake meta contact.";
-        return;
-    }
 
-    m_personContacts.insert(personContact);
-}
-*/
 
 #include "meta-contact-item.moc"
 
diff --git a/meta-contact-item.h b/meta-contact-item.h
index e98ae12..ae1b72e 100644
--- a/meta-contact-item.h
+++ b/meta-contact-item.h
@@ -47,10 +47,6 @@ public:
     ~MetaContactItem();
 
     QString displayName() const;
-/*    const KIcon& presenceIcon() const;
-    qint64 presenceType() const;
-    QStringList groups() const;
-*/
 
     void setPimoPerson(const Nepomuk::Person &pimoPerson);
 

-- 
ktp-contact-list packaging



More information about the pkg-kde-commits mailing list