CommitList.qml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import QtQuick 2.0
  2. FlickPager {
  3. id: root
  4. property QtObject graphModel: null
  5. property QtObject commitsModel: null
  6. signal commitClicked(var commit)
  7. QtObject {
  8. id: d
  9. property int commitsWidth: 0
  10. property int graphWidth: 0
  11. property int fullMessageWidth: 600
  12. }
  13. width: 120
  14. clip: true
  15. state: "full"
  16. states: [
  17. State {
  18. name: "full"
  19. PropertyChanges {
  20. target: root
  21. width: d.fullMessageWidth + d.commitsWidth + d.graphWidth
  22. }
  23. },
  24. State {
  25. name: "commitsOnly"
  26. PropertyChanges {
  27. target: root
  28. width: d.commitsWidth + d.graphWidth
  29. }
  30. },
  31. State {
  32. name: "treeOnly"
  33. PropertyChanges {
  34. target: root
  35. width: 120
  36. }
  37. }
  38. ]
  39. transitions: [
  40. Transition {
  41. NumberAnimation {
  42. properties: "width"
  43. duration: 200
  44. }
  45. }
  46. ]
  47. content: Item {
  48. id: innerItem
  49. width: root.width
  50. height: graph.height
  51. Column {
  52. anchors.left: parent.left
  53. anchors.right: parent.right
  54. clip: true
  55. spacing: graph.spacingV
  56. Repeater {
  57. model: root.commitsModel
  58. Rectangle {
  59. width: parent.width
  60. height: graph.elementHeight
  61. color: textSelector.containsMouse ? "#bbbbbb" : "#00bbbbbb"
  62. Item {
  63. width: root.width - graph.width
  64. height: sha1.height
  65. anchors.right: parent.right
  66. Text {
  67. id: sha1
  68. font.family: "Inconsolata"
  69. font.pointSize: 12
  70. anchors.left: parent.left
  71. text: "[" + model.shortSha1 + "]"
  72. Component.onCompleted: {
  73. d.commitsWidth = sha1.width + 10
  74. }
  75. }
  76. Text {
  77. anchors.left: sha1.right
  78. anchors.right: parent.right
  79. anchors.leftMargin: 10
  80. anchors.rightMargin: 10
  81. verticalAlignment: Text.AlignVCenter
  82. text: model.summary
  83. elide: Text.ElideRight
  84. }
  85. }
  86. //TODO: Make as part of graph
  87. // Row {
  88. // anchors.left: parent.left
  89. // Text {
  90. // verticalAlignment: Text.AlignVCenter
  91. // horizontalAlignment: Text.AlignLeft
  92. // text: graphPointData.branch
  93. // }
  94. // Text {
  95. // verticalAlignment: Text.AlignVCenter
  96. // horizontalAlignment: Text.AlignLeft
  97. // text: graphPointData.tag
  98. // }
  99. // }
  100. MouseArea {
  101. id: textSelector
  102. anchors.fill: parent
  103. hoverEnabled: true
  104. focus: true
  105. onClicked: {
  106. root.commitClicked(model.modelData)
  107. }
  108. }
  109. }
  110. }
  111. }
  112. Graph {
  113. id: graph
  114. model: root.graphModel
  115. onWidthChanged: {
  116. d.graphWidth = graph.width
  117. }
  118. }
  119. }
  120. }