ContactList.qml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. StackItem {
  29. id: root
  30. hasBack: false
  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: 70
  41. ColumnLayout {
  42. anchors.fill: parent
  43. anchors.margins: 10
  44. Row {
  45. Layout.alignment: Qt.AlignVCenter
  46. spacing: 5
  47. PrimaryText {
  48. id: firstName
  49. text: contactDelegate.contact.firstName
  50. }
  51. PrimaryText {
  52. id: middleName
  53. text: contactDelegate.contact.middleName
  54. }
  55. PrimaryText {
  56. id: lastName
  57. text: contactDelegate.contact.lastName
  58. }
  59. }
  60. Row {
  61. Layout.alignment: Qt.AlignVCenter
  62. SecondaryText {
  63. id: defaultPhoneNumberText
  64. property PhoneNumber defaultPhoneNumber: contactDelegate.contact.phonesData.length > 0 ?
  65. contactDelegate.contact.phonesData[0] : null
  66. visible: defaultPhoneNumber != null
  67. text: defaultPhoneNumber ?
  68. "+" + defaultPhoneNumber.countryCode + " " + defaultPhoneNumber.number : ""
  69. }
  70. }
  71. }
  72. Rectangle {
  73. color:"#cfdfe7"
  74. anchors.left: parent.left
  75. anchors.right: parent.right
  76. height: 1
  77. }
  78. Rectangle {
  79. color:"#cfdfe7"
  80. anchors.left: parent.left
  81. anchors.right: parent.right
  82. anchors.top: parent.bottom
  83. height: 1
  84. visible: (contactList.count - 1) === model.index
  85. }
  86. }
  87. }
  88. FloatingRoundButton {
  89. enabled: !contactList.moving
  90. anchors.bottom: parent.bottom
  91. anchors.right: parent.right
  92. anchors.margins: 10
  93. icon: "qrc:/images/plus.png"
  94. onClicked: root.requestAddContact()
  95. }
  96. }