Advertisement
Guest User

ExpandingListView

a guest
Aug 17th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1.  
  2. Rectangle {
  3.  
  4. property alias list: list
  5. property alias mouseArea: headerMouseArea
  6. property alias headerText: headerText
  7. property alias listContainer: listContainer
  8.  
  9. id: header
  10. height: Constants.appHeaderHeight
  11. width: parent.width
  12. color: "lightgrey"
  13.  
  14. ToolIcon {
  15. id: arrow
  16. iconId: "icon-m-common-drilldown-arrow" + (theme.inverted ? "-inverse" : "")
  17. anchors.left: header.left
  18. anchors.verticalCenter: parent.verticalCenter
  19. //anchors.leftMargin: -20
  20. }
  21. Text {
  22. id: headerText
  23. anchors.left: arrow.right
  24. //anchors.leftMargin: 10
  25. font.pixelSize: Constants.expandingListViewHeaderSize
  26. anchors.verticalCenter: parent.verticalCenter
  27. }
  28. MouseArea {
  29. id: headerMouseArea
  30. anchors.fill: parent
  31. // onClicked: {
  32. // if (list.state == 'open') {
  33. // list.state = 'close';
  34. // } else if (list.count < 1) {
  35. // list.model = findingServiceWrapper.getCategories()
  36. // list.state = 'open';
  37. // }
  38. // }
  39. }
  40. Rectangle {
  41. id: listContainer
  42. width: parent.width
  43. height: 0
  44. anchors.top: header.bottom
  45. ListView {
  46. id: list
  47. anchors.fill: parent
  48. clip: true
  49. delegate:
  50. Rectangle {
  51. height: 75
  52. width: parent.width
  53. color: "lightgrey"
  54. Text {
  55. text: model.modelData.name
  56. font.pixelSize: Constants.expandingListViewItemSize
  57. anchors.verticalCenter: parent.verticalCenter
  58. anchors.left: parent.left
  59. anchors.leftMargin: 20
  60. }
  61. Rectangle {
  62. id: selectionRect
  63. color: "grey"
  64. opacity: 0
  65. anchors.fill: parent
  66. }
  67. MouseArea {
  68. anchors.fill: parent
  69. hoverEnabled: true
  70. onEntered: {
  71. selectionRect.opacity = 0.5
  72. }
  73. onExited: {
  74. selectionRect.opacity = 0
  75. }
  76. }
  77. }
  78. states: [
  79. State {
  80. name: "open"
  81. PropertyChanges { target: listContainer; height: 375; }
  82. PropertyChanges { target: arrow; rotation: 90; }
  83. },
  84. State {
  85. name: "close"
  86. PropertyChanges { target: listContainer; height: 0; }
  87. PropertyChanges { target: arrow; rotation: 0; }
  88. }
  89. ]
  90. transitions: [
  91. Transition {
  92. from: "*"; to: "open"
  93. NumberAnimation { properties: "height"; easing.type: Easing.OutBounce; duration: 1000 }
  94. NumberAnimation { properties: "rotation"; easing.type: Easing.OutBounce; duration: 1000 }
  95. },
  96. Transition {
  97. from: "*"; to: "close"
  98. NumberAnimation { properties: "height"; easing.type: Easing.OutBounce; duration: 1000 }
  99. NumberAnimation { properties: "rotation"; easing.type: Easing.OutBounce; duration: 1000 }
  100. }
  101. ]
  102. }
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement