[Kde-pim] Re: Availability of attributes

Kevin Krammer kevin.krammer at gmx.at
Mon Mar 7 09:37:52 GMT 2011


On Monday, 2011-03-07, Christian Mollekopf wrote:
> On Monday 07 March 2011 09:30:40 Kevin Krammer wrote:
> > 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".
> 
> Clear
> 
> > 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
> 
> But if i fetch the item without having
> fetchScope().fetchAttribute<Attribute>(true) set, I have an item which is
> valid, but doesn't have the attribute, no?

Right, my bad.

> Or can I always check if the attribute is available, if the item is valid,
> and just need to fetch the attribute (trought the monitor or explicitly)
> if I want to access the content of the attribute? (Which was my initial
> question)

No, you need to attempt getting the attribute before you can decide whether it 
exists or not.

Cheers,
Kevin
-- 
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/958521c6/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