[Kde-pim] Re: Availability of attributes

Kevin Krammer kevin.krammer at gmx.at
Mon Mar 7 08:30:40 GMT 2011


On Monday, 2011-03-07, Christian Mollekopf wrote:
> On Monday 07 March 2011 08:44:15 Kevin Krammer wrote:
> > On Monday, 2011-03-07, Christian Mollekopf wrote:
> > > Hi,
> > > 
> > > I need to know in the trash job, if an item/collection already has an
> > > attribute or not. I know that I have to fetch the attribute if I need
> > > the content of the attribute, but I'm not sure if I need to fetch it
> > > as well if I just need to know if the entity has the attribute using:
> > > 
> > > item.hasAttribute<Akonadi::EntityDeletedAttribute>()
> > 
> > It depends on how you got the item.
> > 
> > If you created the item locally and did not add the attribute yourself,
> > you have no way of knowing whether someone else has added it.
> > 
> > If you got the item through a monitor, you can use the monitor's item
> > fetch scope to make sure if gets the attribute if it exists.
> 
> Ok, so you're saying that if the item was fetched with a normal monitor,
> NOT having:
> 
> fetchjob->fetchScope().fetchAttribute<EntityDeletedAttribute>(true);
> 
> set, It is also not possible to check if the item has the attribute.

Right. Your process doesn't have direct access to the Akonadi server backend, 
so the only way to get data is to ask the server.

> Is there any possibility for me to differentiate between  "Item doesn't
> have this attribute" <-> "We don't know if the item has the attribute or
> not"?

If you have tried fetching the attribute (implicitly through a monitor or 
explicitly through an item fetch job) and it is not availale then it's "item 
doesn't have this attribute".
If you haven't attempted attribute fetching in any form it is "We don't know 
if the item has the attibute or not".

so

if ( item.isValid() && !item.hasAttribute<EntityDeletedAttribute>(() )
// doesn't have

if ( !item.isValid() )
// don't know

Cheers,
Kevin

P,S,; You could additionally set a flag as a hint which items could have the 
attribute but of course you would still ahv to check at som point to be sure.

-- 
Kevin Krammer, KDE developer, xdg-utils developer
KDE user support, developer mentoring
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20110307/dc5c0667/attachment.sig>
-------------- 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