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

Qt Contacts 5.0 Filter: Unable to assign int to [unknown property type]

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • None
    • 5.1.0
    • PIM: Contacts
    • None
    • SailfishOS Alpha SDK (latest version available), running on the Emulator
      Host is OSX
      qt5-qtdeclarative-pim-contacts-5.1.0+git4-1.3.12.i486
    • ef85e412310fd155508031021c57eedfa5622e83

    Description

      Hi All

      I am experimenting with QtContacts 5.0 on SailfishOS using QML
      .
      However things go pear-shaped when I try and filter the contacts:

      I get the error:
      file:///usr/share/ContactsDemo/qml/pages/FirstPage.qml:62: Unable to assign int to
      [unknown property type]

      This refers to the detail: ContactDetail.Name of the Filter, even though it was able to
      use an identical property to sort.

      Having delved into the source of QDeclarativeContactSortOrder and
      QDeclarativeContactDetailFilter, I see that the first declares detail to be of type int,
      but the second declares detail to be QDeclarativeContactDetail::DetailType

      class QDeclarativeContactSortOrder :public QObject, public QQmlParserStatus
      {
      Q_OBJECT
      Q_PROPERTY(int detail READ detail WRITE setDetail NOTIFY sortOrderChanged)

      class QDeclarativeContactDetailFilter : public QDeclarativeContactFilter, public
      QQmlParserStatus
      {
      Q_OBJECT
      Q_PROPERTY(QDeclarativeContactDetail::DetailType detail READ detail WRITE setDetail
      NOTIFY valueChanged())

      However I have got no further in figuring out what I am doing wrong / what is going wrong.

      Something very similar to the code below works on Harmattan./Qt 4.7.4 /Qt Mobility Contacts: On Harmattan Filtering works for Name.firstName and Name.lastName, but not for DisplayLabel.Label (see https://bugreports.qt-project.org/browse/QTBUG-35259). In fact I was trying to reproduce the DisplayLabel filter problem on Qt5.0 when I found that I cannot filter at all....

      Any ideas?

      Thanks

      Chris

      //Start FirstPage.qml
      import QtQuick 2.0
      import Sailfish.Silica 1.0
      import QtContacts 5.0
      Page {
      id: page
      ContactModel {
      id: contactsModel
      manager: "memory"
      Component.onCompleted:

      { //contactsModel.importContacts(Qt.resolvedUrl("example.vcf")) page.insertContact("Mary", "Curie", "+41791234545") page.insertContact("Empress", "of Blandings", "+41791234546") page.insertContact("Big", "Lebowski", "+41791234546") page.insertContact("Clive", "Sinclair", "+41791234546") page.insertContact("Winston", "Churchill", "+41791234547") }

      sortOrders: [
      SortOrder

      { detail: ContactDetail.Name field: Name.FirstName direction: Qt.AscendingOrder }

      ]
      filter: detailFilter1
      }
      DetailFilter

      { id: detailFilter1 detail: ContactDetail.Name field: Name.FirstName value: "M" matchFlags: Filter.MatchContains }

      ListView {
      id: contactList
      anchors.fill: parent
      model: contactsModel
      delegate:contactDelegate
      clip: true
      onCountChanged:

      { contactList.currentIndex = -1; console.log("Contacts Count: contactList.count: " + count); }

      }
      Component {
      id: contactDelegate
      PhoneContactsDelegate {
      }
      }
      function insertContact(firstName, lastName, phoneNumber) {
      // read in values from the input fields
      var displaylabel = firstName.trim() + " " + lastName.trim()
      var values = [firstName,
      lastName,
      displaylabel,
      phoneNumber]
      var newContact = Qt.createQmlObject("import QtContacts 5.0; Contact{ }", page)
      setDetailValues(newContact, values)
      newContact.save()
      contactsModel.saveContact(newContact)
      }
      function setDetailValues(c, values)

      { c.name.firstName = values[0] c.name.lastName = values[1] c.displayLabel.label = values[2] c.phoneNumber.number = values[3] }

      }
      //End FirstPage.qml
      //Start PhoneContactsDelegate.qml
      import QtQuick 2.0
      Item {
      id: backGroundRect
      width: parent.width
      height: 80
      Text {
      id: nameText
      anchors

      {left: parent.left; leftMargin: 10; right: parent.right; rightMargin: 10; top: parent.top}

      font.pointSize: 30
      font.weight: Font.DemiBold
      text: model.contact.displayLabel.label.trim();
      }
      Text {
      id: numberText
      anchors

      {left: parent.left; leftMargin: 10; right: parent.right; rightMargin: 10; top: nameText.bottom}

      font.pointSize: 20
      font.weight: Font.Light
      text: model.contact.phoneNumber.number // + ", " + model.contact.contactId
      }
      }
      //End PhoneContactsDelegate.qml

      Attachments

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

        Activity

          People

            ritt.ks Konstantin Ritt
            flyingsheep Christopher Lamb
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes