Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-37139

phoneNumbers.length attribute gets lost when copied to ListModel

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.1.0
    • PIM: Contacts
    • None
    • Jolla Sailfish 1.0.3.8 (Qt 5.x), QtContacts 5.x

    Description

      I have come across some strangeness using QtContacts 5.0 on Sailfish.

      For various reasons partially lost in the mists of time, I copy contacts (or rather a subset of contract roles) from the ContactModel to a a normal ListModel.

      One of the roles copied is "phoneNumbers". This has a child property "length" indicating the number of phoneNumbers available for the contact.

      phoneNumbers.length is available (defined) direct from the ContactModel, but is undefined when I try to use it from the ListModel. So the console.log in the function appendContact() gives a valid result, but the console.log in populate() gives undefined.

      Other properties, including the phone numbers in phoneNumbers are defined when accessed from the ListModel.

      Equivalent code works in Haramtatan / Qt 4.7.4 Mobility 1.2

      import QtContacts 5.0
      .....

      ContactModel

      { id: phoneContactsModelInternal }

      ListModel {
      id: localContactModelInternal
      function populate() {
      clear();
      for (var i = 0; i < phoneContactsModelInternal.contacts.length; i++)

      { appendContact(phoneContactsModelInternal.contacts[i]); console.log("checking number of phoneNumbers: " + localContactModel.get(i).phoneNumbers.length); }

      }
      function appendContact(contact) {
      localContactModel.append(

      {"contactId": contact.contactId, "displayLabel": contact.displayLabel.label, "phoneNumbers": contact.phoneNumbers, "phoneNumbersCount": contact.phoneNumbers.length}

      );
      console.log("appending: " + contact.displayLabel.label + ", numbers: " +
      contact.phoneNumbers.length)
      }
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            chrisadams Christopher Adams
            flyingsheep Christopher Lamb
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes