Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1.  
  2. import QtQuick 2.10
  3. import QtQuick.Controls 2.3
  4. import QtQuick.Layouts 1.3
  5.  
  6. ColumnLayout {
  7. id: root
  8. anchors.margins: 3
  9. spacing: 3
  10.  
  11. signal startTest(string testName)
  12.  
  13. Component {
  14. id: myDataComponent
  15.  
  16. QtObject {
  17. property string name
  18. property bool passed
  19. }
  20. }
  21.  
  22. property var testListModel: [
  23. {
  24. "title": "Video tests",
  25. "tests": [
  26. myDataComponent.createObject(null, {name: "Video Test 1920x1200", passed: false}),
  27. {
  28. "name" : "Video Test 1280x800",
  29. "passed" : true
  30. },
  31. {
  32. "name" : "Video Test 800x480",
  33. "passed" : false
  34. }
  35. ]
  36. }
  37. ]
  38.  
  39. Frame {
  40.  
  41. ListView {
  42.  
  43. implicitWidth: 600
  44. implicitHeight: 500
  45.  
  46. clip: true
  47. anchors.fill: parent
  48.  
  49. model: testListModel
  50.  
  51. delegate: Column {
  52. property bool showList: false
  53. anchors.left: parent.left
  54. anchors.right: parent.right
  55. Button {
  56. anchors.left: parent.left
  57. anchors.right: parent.right
  58. text: modelData.title
  59. onClicked: paneTestList.shown = !paneTestList.shown
  60. }
  61.  
  62. Pane {
  63. id: paneTestList
  64. property bool shown: false
  65. visible: height > 0
  66. height: shown ? implicitHeight: 0
  67. Behavior on height {
  68. NumberAnimation {
  69. easing.type: Easing.InOutQuad
  70. }
  71. }
  72.  
  73. clip: true
  74. anchors.left: parent.left
  75. anchors.right: parent.right
  76.  
  77. Column {
  78. anchors.left: parent.left
  79. anchors.right: parent.right
  80. spacing: 3
  81.  
  82. Repeater {
  83. id: testList
  84. model: modelData.tests
  85. anchors.fill: parent
  86.  
  87. delegate: RowLayout {
  88. anchors.left: parent.left
  89. anchors.right: parent.right
  90. spacing: 10
  91.  
  92. Rectangle {
  93. implicitHeight: 40
  94. implicitWidth: 40
  95. Image {
  96. source: "start.png"
  97. fillMode: Image.PreserveAspectFit
  98.  
  99. anchors.centerIn: parent
  100. anchors.fill: parent
  101.  
  102. height: sourceSize.height
  103.  
  104. }
  105. MouseArea {
  106. anchors.fill: parent
  107. onClicked: {
  108. console.log("Button pressed!!!" + modelData.name)
  109. modelData.passed = true
  110. //testListModelChanged()
  111. modelDataChanged()
  112. console.log("Data has been changed: " + modelData.passed)
  113.  
  114. modelData.name = "PassedBlahBlah"
  115. console.log("New name = " + modelData.name)
  116. }
  117. }
  118. }
  119.  
  120. Label {
  121. text: modelData.name
  122. Layout.fillWidth: true
  123. }
  124.  
  125. Rectangle {
  126. implicitHeight: 40
  127. implicitWidth: 40
  128. Image {
  129. source: {
  130. modelData.passed ? "passed.png" : "failed.png"
  131. }
  132. fillMode: Image.PreserveAspectFit
  133.  
  134. anchors.centerIn: parent
  135. anchors.fill: parent
  136. //sourceSize.height: button.background.height - 6
  137. //height: sourceSize.height
  138. }
  139. }
  140. }
  141. }
  142. }
  143. }
  144. }
  145.  
  146. }
  147. }
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement