I finally figured it out. It only started working after I got my data from a QAbstractTableModel. I guess otherwise the rows were not redrawn.
In any case, here is what I ended up with:
import QtQuick 2.4
import QtQuick.Window 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import MoeFileModel 1.0
Window {
visible: true
width: 800
height:600
FileModelHandler {
id: fileModelHandler
}
TableView {
id: tv
anchors.fill: parent
model: fileModelHandler
rowDelegate: Rectangle {
property int sizeOpen: 60
property int sizeClosed: 20
id: rowDelegate
color: styleData.alternate ? "#666666" : "#555555"
height: getSize() // styleData.selected? sizeOpen : sizeClosed
function getSize()
{
if(!tv.selection.contains(styleData.row))
{
doClose.start();
return sizeClosed;
}
return sizeOpen;
}
MouseArea {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
height: sizeClosed
propagateComposedEvents: true
preventStealing: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
if(rowDelegate.sizeOpen == rowDelegate.height)
{
tv.selection.deselect(styleData.row);
doClose.start()
}
else
{
tv.selection.clear();
tv.selection.select(styleData.row);
doOpen.start();
}
}
}
ParallelAnimation {
id: doOpen
running: false
NumberAnimation { target: rowDelegate; easing.type: Easing.OutSine; property: "height"; to: sizeOpen; duration: 100 }
}
ParallelAnimation {
id: doClose
running: false
NumberAnimation { target: rowDelegate; easing.type: Easing.OutSine; property: "height"; to: sizeClosed; duration: 100; }
}
}
// columns go here...
TableViewColumn {}
}
}
import QtQuick 2.4
import QtQuick.Window 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import MoeFileModel 1.0
Window {
visible: true
width: 800
height:600
FileModelHandler {
id: fileModelHandler
}
TableView {
id: tv
anchors.fill: parent
model: fileModelHandler
rowDelegate: Rectangle {
property int sizeOpen: 60
property int sizeClosed: 20
id: rowDelegate
color: styleData.alternate ? "#666666" : "#555555"
height: getSize() // styleData.selected? sizeOpen : sizeClosed
function getSize()
{
if(!tv.selection.contains(styleData.row))
{
doClose.start();
return sizeClosed;
}
return sizeOpen;
}
MouseArea {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
height: sizeClosed
propagateComposedEvents: true
preventStealing: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
if(rowDelegate.sizeOpen == rowDelegate.height)
{
tv.selection.deselect(styleData.row);
doClose.start()
}
else
{
tv.selection.clear();
tv.selection.select(styleData.row);
doOpen.start();
}
}
}
ParallelAnimation {
id: doOpen
running: false
NumberAnimation { target: rowDelegate; easing.type: Easing.OutSine; property: "height"; to: sizeOpen; duration: 100 }
}
ParallelAnimation {
id: doClose
running: false
NumberAnimation { target: rowDelegate; easing.type: Easing.OutSine; property: "height"; to: sizeClosed; duration: 100; }
}
}
// columns go here...
TableViewColumn {}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks