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

ParentChange does not reparent back to correct ListItem on second use

    XMLWordPrintable

Details

    • Ia3f4d16ee8855d163a7f6118a0bc1f8492727940

    Description

      Run the example below. First click the second item in the list. It animates over to the other view. Click the item again and it animates back. Now click another item and it move over to the second view. But now when you click that item instead of going back to where it came from it goes back to the position of the first item you clicked. It seems once you do this once everything is reparented back to the first item you selected and not its original parent.

      import QtQuick 2.0
      
      
      Item {
          id: root
          width: 800
          height: 600
          property string currentView : "list"
      
          states: [
              State {
                  name: "move"
                  when: currentView === "fullScreen"
                  ParentChange {
                      target: list.currentItem.listItem
                      parent: innerHolder
                      x: 0
                      y: 0
                  }
              }
          ]
      
          transitions: [
              Transition {
                  from: ""
                  to: "move"
                  SequentialAnimation {
                      ParentAnimation {
                          via: list.currentItem;
                          NumberAnimation {  properties: "x, y"; duration: 500; easing.type: Easing.InOutQuad }
                      }
                  }
      
              },
              Transition {
                  from: "move"
                  to: ""
                  SequentialAnimation {
                      ParentAnimation {
                          NumberAnimation { properties: "x, y"; duration: 500; easing.type: Easing.InOutQuad }
                      }
      
                  }
      
              }
          ]
      
      
      
      
          Flickable {
              id: holder
              width: 400
              height: 600
              x: 420
              boundsBehavior: Flickable.DragOverBounds
              flickableDirection: Flickable.VerticalFlick
              Rectangle {
                  id: innerHolder
                  color: "pink"
                  anchors.fill: parent
                  Text {
                      anchors.centerIn: parent
                      text: "Flick up and down"
                      font.pixelSize: 30
                      MouseArea {
                          anchors.fill: parent
                          onClicked: {
                              list.currentIndex = 2;
                              list.currentItem.x = 50;
                          }
                      }
      
                  }
              }
          }
      
          ListView {
              id: list
              width: 400
              height: 600
      
              signal itemClicked
              highlightFollowsCurrentItem: false
      
              onItemClicked: {
                  switch (currentView){
                  case "list":
                      currentView = "fullScreen";
                      break;
      
                  case "fullScreen":
                      currentView = "list";
                      break;
                  }
              }
      
              model: 100
              delegate:  Item {
                  id: wrapper
                  width: 400
                  height: 100
                  z: index
                  property alias listItem : internalItem
                  Rectangle {
                      id: internalItem
                      width: 400
                      height: 150
      
                      border.width: 1
                      color: index % 2 ? "grey" : "lightgrey"
                      MouseArea {
                          anchors.fill: parent
                          onClicked:  {
                              wrapper.ListView.view.currentIndex = index;
                              wrapper.ListView.view.itemClicked();
                          }
      
      
                      }
                  }
              }
          }
      
      }
      
      
      
      

      Attachments

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

        Activity

          People

            brasser Michael Brasser (closed Nokia identity) (Inactive)
            designker Nigel Hietala
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes