SchedulPage.qml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import QtQuick
  2. import QtQuick.Controls 2.5
  3. import QtQuick.Layouts 1.3
  4. Rectangle {
  5. id: schedulList
  6. width: parent.width
  7. height: parent.height
  8. color: 'transparent'
  9. property StackView stack: null
  10. Component.onCompleted: {
  11. }
  12. function stateText(value)
  13. {
  14. if(value==0) return '(离线)';
  15. else if(value==1) return '(等待)';
  16. else return '(使用中)';
  17. }
  18. Rectangle {
  19. width: parent.width
  20. height: parent.height
  21. anchors.top: parent.top
  22. anchors.horizontalCenter: parent.horizontalCenter
  23. anchors.verticalCenter: parent.verticalCenter
  24. color: 'transparent'
  25. border.width:1
  26. border.color:"red"
  27. GridView {
  28. id: carGrid
  29. anchors.fill: parent
  30. cellWidth: 300
  31. cellHeight: 300
  32. focus: true
  33. anchors.leftMargin: 160
  34. anchors.rightMargin: 160
  35. anchors.topMargin: 160
  36. anchors.bottomMargin: 160
  37. x:100
  38. model: appModel.car
  39. /*
  40. Rectangle {
  41. width: 350
  42. height: 350
  43. radius: 5
  44. // border.color: mainAppColor
  45. color: 'transparent'
  46. }
  47. */
  48. delegate: Item {
  49. required property string name
  50. required property int uid
  51. required property string state
  52. width: 300
  53. height: 300
  54. Image {
  55. id: myIcon
  56. width: 200
  57. height: 200
  58. anchors.horizontalCenter: parent.horizontalCenter
  59. anchors.verticalCenter: parent.verticalCenter
  60. fillMode: Image.PreserveAspectFit
  61. source: 'qrc:/images/car1.png'
  62. }
  63. Text {
  64. anchors {
  65. top: myIcon.bottom
  66. topMargin: 10
  67. horizontalCenter: parent.horizontalCenter
  68. }
  69. text: parent.name + stateText(parent.state)
  70. color: '#eaf4fc'
  71. font.family: alibaba.name
  72. font.pointSize: 20
  73. Timer{
  74. id: timerRefresh
  75. interval:1000
  76. onTriggered: {
  77. stateText(parent.state)
  78. }
  79. }
  80. }
  81. MouseArea {
  82. anchors.fill: parent
  83. onClicked: {
  84. if(appModel.idle(parent.uid))
  85. {
  86. parent.GridView.view.currentIndex = parent.uid
  87. console.log(parent.GridView.view.currentIndex)
  88. //carSelect(parent.GridView.view.currentIndex)
  89. page_detail.visible = true
  90. page_detail.stack = stack
  91. page_detail.refresh()
  92. stack.push(page_detail, {
  93. "name": parent.name,
  94. "uid": parent.uid
  95. })
  96. }
  97. }
  98. }
  99. }
  100. }
  101. }
  102. }