ContactList.qml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * MIT License
  3. *
  4. * Copyright (c) 2019 Alexey Edelev <semlanik@gmail.com>
  5. *
  6. * This file is part of qtprotobuf project https://git.semlanik.org/semlanik/qtprotobuf
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy of this
  9. * software and associated documentation files (the "Software"), to deal in the Software
  10. * without restriction, including without limitation the rights to use, copy, modify,
  11. * merge, publish, distribute, sublicense, and/or sell copies of the Software, and
  12. * to permit persons to whom the Software is furnished to do so, subject to the following
  13. * conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in all copies
  16. * or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  19. * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  20. * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
  21. * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  22. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. * DEALINGS IN THE SOFTWARE.
  24. */
  25. import QtQuick 2.9
  26. import QtQuick.Controls.Material 2.9
  27. import QtQuick.Layouts 1.1
  28. import qtprotobuf.examples.addressbook 1.0
  29. ListView {
  30. id: contactList
  31. anchors.fill: parent
  32. delegate: Rectangle {
  33. id: contactDelegate
  34. property Contact contact: model.modelData
  35. color: "#81D4FA"
  36. width: contactList.width
  37. height: 80
  38. ColumnLayout {
  39. anchors.fill: parent
  40. anchors.margins: 10
  41. Row {
  42. Layout.alignment: Qt.AlignVCenter
  43. Text {
  44. id: firstName
  45. color: "#FFFFFF"
  46. text: contactDelegate.contact.firstName
  47. font.pointSize: 12
  48. }
  49. Text {
  50. id: middleName
  51. anchors.verticalCenter: parent.verticalCenter
  52. color: "#FFFFFF"
  53. text: contactDelegate.contact.middleName
  54. font.pointSize: 12
  55. }
  56. Text {
  57. id: lastName
  58. anchors.verticalCenter: parent.verticalCenter
  59. color: "#FFFFFF"
  60. text: contactDelegate.contact.lastName
  61. font.pointSize: 12
  62. }
  63. }
  64. Row {
  65. Layout.alignment: Qt.AlignVCenter
  66. Text {
  67. id: job
  68. color: "#EEEEEE"
  69. text: contactDelegate.contact.job.title
  70. font.pointSize: 12
  71. Component.onCompleted: {
  72. console.log('contactDelegate.contact.job: ' + contactDelegate.contact.job.title);
  73. }
  74. }
  75. }
  76. }
  77. Rectangle {
  78. color:"#EEEEEE"
  79. anchors.left: parent.left
  80. anchors.right: parent.right
  81. height: 2
  82. }
  83. Rectangle {
  84. color:"#EEEEEE"
  85. anchors.left: parent.left
  86. anchors.right: parent.right
  87. anchors.top: parent.bottom
  88. height: 2
  89. visible: (contactList.count - 1) === model.index
  90. }
  91. }
  92. }