Lundi, le 1 août 2011, à 11:32, Eric Lapuyade a écrit:
> On 30/07/2011 01:24, Friedrich W. H. Kossebau wrote:
> > Are you sure here about the memory contact manager as default one?
> > Can you tell what contactMgr.managerUri() returns as string?
>
> managerName() returns "memory"
> managerURI() returns "qtcontacts:memory:id=simulator"
Thanks, so it's sure which backend to blame for any possibly wrong behaviour
;)
> > Hm, did this compile? IMNSHO this needs to be:
> > QContact contact = list[0];
>
> Possibly. The code I have included here is not the actual code, it's
> just for illustration. The actual code implements a custom ContactModel
> class derived from QAbstractListModel, and used by a QML view. The
> contacts are actually displayed in the view, so I am sure about which
> one I'm manipulating, even after reload.
Okay. Still, I urge you to base identification on the localId of the contacts,
not their index in the list of contacts as returned by the manager, if you do
not already, as other backends pretty sure might behave differently.
> > Who stored the contacts? And have any favorite details been stored
> > before?
>
> Those are the default contacts in the simulator.
Ah, okay (never used the simulator so far)
> > Because by default a QContact does not have a QContactFavorite detail. So
> >
> > contact.detail<QContactFavorite>()
> >
> > will just return a default QContactFavorite().
> > Test the returned detail with .isEmpty() to see yourself.
> > With an empty detail any fields will have the same value as converting a
> > QVariant() to the field type will have.
>
> I understand that, but....
>
> >> // invert favorite detail and save it back into the contact
> >> favorite.setFavorite(!favorite.isFavorite());
> >> contactP->saveDetail(&favorite);
>
> ... wouldn't that above create the favorite detail if it didn't exist?
"Would create" as in: would add a QContactFavorite detail with field Favorite
set to true to the *contactP, yes.
So after saving to the manager and refetching like in the code you gave, after
QContact contact2 = list2[0];
contact.detail<QContactFavorite>().isFavorite() should be true, if
contact2.localId() == contact.localId().
Is it?
Cheers
Friedrich
--
Desktop Summit 2011 in Berlin - Registered already? - www.desktopsummit.org
_______________________________________________
MeeGo-dev mailing list
[email protected]
http://lists.meego.com/listinfo/meego-dev
http://wiki.meego.com/Mailing_list_guidelines