Item {
id: delegate
- property int textSingleLineHeight: 0
-
height: details.item.y + details.item.height + 5
// anchors { left: parent.left; right: parent.right; verticalCenter: parent.verticalCenter; margins: 10 }
anchors.fill: parent
anchors { left: parent.left; right: parent.right; top: borderImage.bottom; margins: 5 }
horizontalAlignment: Text.AlignHCenter
clip: true;
- elide: Text.ElideRight
+ wrapMode: Text.Wrap
Behavior on height {
id: textHeightBehavior
NumberAnimation { duration: 150 }
id: details
z: 1
sourceComponent: detailsComponent
- state: parent.state
anchors { left: primaryText.left; right: primaryText.right; top: primaryText.bottom }
}
-// Loader {
-// id: buttons
-// height: 0
-// anchors { horizontalCenter: parent.horizontalCenter; top: details.bottom }
-// onLoaded: {
-// item.visible = false
-// }
-// }
-
Component {
id: detailsComponent
Item {
- state: delegate.state
height: messageRow.height + addressRow.height + timeRow.height
width: parent.width
DetailEditorRow { id: messageRow; image: "qrc:/res/images/envelope.png"; text: userProfile.message }
DetailRow { id: timeRow; state: "expanded"; anchors.top: addressRow.bottom; image: "qrc:/res/images/clock.png"; text: userProfile.time }
}
}
-
- MouseArea {
- anchors.fill: parent
- onClicked: delegate.state = !delegate.state
- }
-
- Component.onCompleted: {
- textSingleLineHeight = primaryText.height
- }
-
- states: [
- State {
- name: "expanded"
- when: delegate.ListView.isCurrentItem
- PropertyChanges {
- target: buttons
- height: buttons.status == Loader.Ready ? buttons.item.childrenRect.height : 0
- explicit: true
- }
- PropertyChanges {
- target: primaryText
- height: paintedHeight
- }
- },
- State {
- name: ""
- when: !delegate.ListView.isCurrentItem
- PropertyChanges {
- target: primaryText
- explicit: true
- height: textSingleLineHeight
- }
- }
- ]
-
- onStateChanged: {
- if (buttons.status == Loader.Ready) {
- buttons.item.visible = (state == "expanded")
- }
- }
-
- transitions: [
- Transition {
- from: ""
- to: "expanded"
- SequentialAnimation {
- PropertyAction { target: textHeightBehavior; property: "enabled"; value: true }
- PropertyAction { target: primaryText; property: "wrapMode"; value: Text.Wrap }
- PropertyAction { target: primaryText; property: "elide"; value: Text.ElideNone }
- }
- },
- Transition {
- from: "expanded"
- to: ""
- SequentialAnimation {
- PropertyAction { target: textHeightBehavior; property: "enabled"; value: false }
- NumberAnimation { target: primaryText; properties: "height"; duration: 150 }
- PropertyAction { target: primaryText; property: "wrapMode"; value: Text.NoWrap }
- PropertyAction { target: primaryText; property: "elide"; value: Text.ElideRight }
- }
- }
- ]
}