ContactList.qml 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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: defaultPhoneNumberText
  68. property PhoneNumber defaultPhoneNumber: contactDelegate.contact.phonesData.length > 0 ?
  69. contactDelegate.contact.phonesData[0] : null
  70. visible: defaultPhoneNumber != null
  71. color: "#EEEEEE"
  72. text: defaultPhoneNumber ?
  73. "+" + defaultPhoneNumber.countryCode + " " + defaultPhoneNumber.number : ""
  74. font.pointSize: 12
  75. }
  76. }
  77. }
  78. Rectangle {
  79. color:"#EEEEEE"
  80. anchors.left: parent.left
  81. anchors.right: parent.right
  82. height: 2
  83. }
  84. Rectangle {
  85. color:"#EEEEEE"
  86. anchors.left: parent.left
  87. anchors.right: parent.right
  88. anchors.top: parent.bottom
  89. height: 2
  90. visible: (contactList.count - 1) === model.index
  91. }
  92. }
  93. }