ContactList.qml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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.Layouts 1.1
  27. import qtprotobuf.examples.addressbook 1.0
  28. Item {
  29. id: root
  30. anchors.fill: parent
  31. property alias model: contactList.model
  32. signal requestAddContact()
  33. ListView {
  34. id: contactList
  35. anchors.fill: parent
  36. delegate: Item {
  37. id: contactDelegate
  38. property Contact contact: model.modelData
  39. width: contactList.width
  40. height: 80
  41. ColumnLayout {
  42. anchors.fill: parent
  43. anchors.margins: 10
  44. Row {
  45. Layout.alignment: Qt.AlignVCenter
  46. spacing: 5
  47. Text {
  48. id: firstName
  49. color: "#FFFFFF"
  50. text: contactDelegate.contact.firstName
  51. font.pointSize: 12
  52. font.weight: Font.Bold
  53. }
  54. Text {
  55. id: middleName
  56. anchors.verticalCenter: parent.verticalCenter
  57. color: "#FFFFFF"
  58. text: contactDelegate.contact.middleName
  59. font.pointSize: 12
  60. font.weight: Font.Bold
  61. }
  62. Text {
  63. id: lastName
  64. anchors.verticalCenter: parent.verticalCenter
  65. color: "#FFFFFF"
  66. text: contactDelegate.contact.lastName
  67. font.pointSize: 12
  68. font.weight: Font.Bold
  69. }
  70. }
  71. Row {
  72. Layout.alignment: Qt.AlignVCenter
  73. Text {
  74. id: defaultPhoneNumberText
  75. property PhoneNumber defaultPhoneNumber: contactDelegate.contact.phonesData.length > 0 ?
  76. contactDelegate.contact.phonesData[0] : null
  77. visible: defaultPhoneNumber != null
  78. color: "#EEEEEE"
  79. text: defaultPhoneNumber ?
  80. "+" + defaultPhoneNumber.countryCode + " " + defaultPhoneNumber.number : ""
  81. font.pointSize: 12
  82. }
  83. }
  84. }
  85. Rectangle {
  86. color:"#EEEEEE"
  87. anchors.left: parent.left
  88. anchors.right: parent.right
  89. height: 2
  90. }
  91. Rectangle {
  92. color:"#EEEEEE"
  93. anchors.left: parent.left
  94. anchors.right: parent.right
  95. anchors.top: parent.bottom
  96. height: 2
  97. visible: (contactList.count - 1) === model.index
  98. }
  99. }
  100. }
  101. FloatingRoundButton {
  102. anchors.bottom: parent.bottom
  103. anchors.right: parent.right
  104. anchors.margins: 10
  105. icon: "qrc:/images/plus.png"
  106. onClicked: root.requestAddContact()
  107. }
  108. }