[Kde-pim] [nepomuk-kde] Akonadi/Nepomuk integration with Telepathy

Tom Albers toma at kde.org
Sat Oct 3 16:40:12 BST 2009


Op Saturday 03 October 2009 16:44 schreef u:
> 3) We need to combine these with presence information. Is an akonadi
> contact resource capable of reading presence information as well?

You can set your own attributes on a contact. An attribute is a key/value pair. So you could do something like this:

Akonadi::Item item = existingItem;
MSNPresenceAttribute* presenceAttribute = new MSNPresenceAttribute;
presenceAttribute->setOnline( true );
item.addAttribute( presenceAttribute );

Creating the MSNPresenceAttribute - attributes in general - is straightforward.

Now that you have set this attribute you can use it in a model and show it in whatever view you use, for example:

QVariant PrecenseModel::data( const QModelIndex &index, int role ) const
{
    const Item item = itemForIndex( index ); // coming from the base model (Akonadi::ItemModel)

    if ( role == Qt::DisplayRole ) {
        switch ( index.column() ) {
        case 2:
            if ( item.hasAttribute<MSNPresenceAttribute>() ) {
                return item.attribute<MSNPresenceAttribute>()->precent();
            }
            break;
       }
}

You can set multiple attributes to each Item and store whatever data you want in there.

Toma
-- 
KDE Developer
-------------- next part --------------
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list