[Kde-pim] Re: Availability of attributes

Christian Mollekopf chrigi_1 at fastmail.fm
Mon Mar 7 09:22:48 GMT 2011


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?

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)

Cheers,

Chris

> 
> 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.
_______________________________________________
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