title: QML TreeView passes previous selection when clicking to collapse or expand
body: <p>I have a QML <code>TreeView</code> containing some <code>onClicked()</code> logic that calls a Q_INVOKABLE function that takes in the current row number and the parent row number of the <code>TreeView</code> as parameters. The problem is that when I select something, and then I click to expand or collapse something. The previous values are still getting passed which sometimes makes the application crash. I've tried to call <code>treeView.selection.clearCurrentIndex()</code> and <code>treeView.selection.clearSelection()</code> in <code>onCollapsed()</code> and <code>onExpanded()</code> which deselects the item, but for some reason still passes the values from the previously selected item. </p>
  
  <pre><code>//main.qml
  
  TreeView {
      id: treeView
      anchors.fill: parent
      model: treeviewmodel
      selection: ItemSelectionModel {
          model: treeviewmodel
      }
      TableViewColumn {
          role: "name_role"
          title: "Section Name"
      }
      onCollapsed: {
          treeView.selection.clearSelection() // deselects the item, but still passes the previous values
      }
      onExpanded: {
          treeView.selection.clearSelection()
      }
      onClicked: {
          console.log("Current Row: " + treeView.currentIndex.row + "Parent Row: " + treeView.currentIndex.parent.row)
          //I need something here that will set treeView.currentIndex.row and treeView.currentIndex.parent.row to -1
          //so that when I collapse or expand, -1 gets passed instead of the previous values
      }
  }
  </code></pre>