Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    28

    merging contacts

    Hi,

    I have to merge details from multiple contacts into one target contact(beside of name). currently my code look like this:
    Code:
    foreach(contact)
    {
       foreach(detail in contact)
        {
        newdetail=detail;
        newdetail.resetKey();
    
        target.save(&detail)
        }
      }
    
    // now contact detail count is like 20
    manager.saveContact(&target);  // no error
    
    QContact test;
    test=manager.contact(targetcontactid);
    
    //now test.details.count() is like before merging
    It looks like everything went ok, I checked for error for each contact operation and after contact reload details count was not changed...
    My question is: how to copy details from multiple contacts to one contact?

    seba
    Last edited by sebaw; 2011-01-19 at 16:15.

  2. #2
    Nokia Developer Expert
    Join Date
    May 2010
    Posts
    65

    Re: merging contacts

    Hi,

    Which backend are you using? Is behaviour different between the memory backend and the backend you're using?

    In your for loop, do you create a new detail each time, or do you reuse one and simply reset the key each loop? It may be a detail definition mismatch problem, if you do the latter.
    You say that the save operation doesn't report an error, but what happens if you call compatibleContact() prior to calling save? It's possible that the details which make up the large count are all empty, and on save the backend may ignore all such empty details (they may be empty due to a problem in the copy constructor / assignment operator code for QContactDetail, is my thinking here). Check that the values of the details in the contact returned by compatibleContact() are what you expect, prior to calling save.

    The answer to your question is: your algorithm should work, I believe. A detail from one contact should be able to be saved in another. I'd probably do it like this:

    QList<QContact> mergeContacts;
    QContact targetContact;

    foreach (const QContact& mergee, mergeContacts) {
    QList<QContactDetail> allDetails = mergee.details();
    for (int i = 0; i < allDetails.size(); ++i) {
    QContactDetail det = allDetails.at(i);
    targetContact.saveDetail(&det);
    }
    }

    cm.saveContact(&targetContact);

    If this sort of thing doesn't work, then I think there may be a bug in the backend, or in the detail copying/assignment code, somewhere.

    Cheers,
    Chris.

Similar Threads

  1. Mail Message Store Merging
    By jericsm in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2006-10-03, 04:25
  2. Symbian and Java Merging
    By sahink in forum Mobile Java General
    Replies: 1
    Last Post: 2005-09-02, 09:50
  3. Merging two 3gp Files.
    By ruchaitu in forum Streaming and Video
    Replies: 6
    Last Post: 2005-03-23, 06:24
  4. Merging concatenated messages in SME!
    By leksiu in forum Smart Messaging
    Replies: 3
    Last Post: 2003-03-11, 04:25

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×