ContactsView.qml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. import QtQuick 1.1
  5. import QtMobility.contacts 1.1
  6. import "JavaScript.js" as JavaScript
  7. Rectangle {
  8. id: container
  9. anchors.fill: parent
  10. opacity: 0
  11. gradient: Gradient {
  12. GradientStop { position: 0.0; color: "#a5cbe0" }
  13. GradientStop { position: 1.0; color: "#388cc8" }
  14. }
  15. property int rowHeight: 100
  16. function show() {
  17. container.opacity = 0.9
  18. }
  19. Behavior on opacity {
  20. NumberAnimation { duration: 300 }
  21. }
  22. ContactModel {
  23. id: contactModel
  24. sortOrders: [
  25. SortOrder {
  26. detail:ContactDetail.Name
  27. field:Name.DisplayLabel
  28. direction:Qt.AscendingOrder
  29. }
  30. ]
  31. }
  32. Component.onCompleted: {
  33. }
  34. // Contact row for PathView
  35. Component {
  36. id: pathContactDelegate
  37. Image {
  38. scale: PathView.elementScale
  39. opacity: PathView.elementOpacity
  40. z: PathView.elementZ
  41. source: "qrc:/images/back_contactlist.png"
  42. width: PathView.width
  43. height: container.rowHeight
  44. clip: true
  45. Text {
  46. anchors.verticalCenter: parent.verticalCenter
  47. anchors.left: parent.left
  48. anchors.leftMargin: 20
  49. color:"black";
  50. text: model.contact.name.firstName + " " + model.contact.name.lastName
  51. font.pixelSize:30
  52. }
  53. MouseArea {
  54. anchors.fill: parent
  55. onClicked: {
  56. main.showContacts(false);
  57. var nro = model.contact.phoneNumber.number;
  58. if (nro.length > 0) {
  59. JavaScript.sendLocationTo(model.contact.phoneNumber.number);
  60. }
  61. }
  62. }
  63. }
  64. }
  65. // Contact row for ListView
  66. Component {
  67. id: listContactDelegate
  68. Image {
  69. source: "qrc:/images/back_contactlist.png"
  70. width: ListView.width
  71. height: container.rowHeight
  72. clip: true
  73. Text {
  74. anchors.verticalCenter: parent.verticalCenter
  75. anchors.left: parent.left
  76. anchors.leftMargin: 20
  77. color:"black";
  78. text: model.contact.name.firstName + " " + model.contact.name.lastName
  79. font.pixelSize:30
  80. }
  81. MouseArea {
  82. anchors.fill: parent
  83. onClicked: {
  84. main.showContacts(false);
  85. JavaScript.sendLocationTo(model.contact.phoneNumber.number);
  86. }
  87. }
  88. }
  89. }
  90. // No contact message
  91. Image {
  92. id: searchingMsg
  93. opacity: contactModel.contacts.length==0 ? 1 : 0
  94. width: parent.width * 0.8
  95. height: container.rowHeight
  96. anchors.centerIn: parent
  97. source: "qrc:/images/back_contactlist.png"
  98. smooth: true
  99. Text {
  100. anchors.centerIn: parent
  101. text: "No contacts found"
  102. smooth: true
  103. font.pointSize: 8
  104. }
  105. }
  106. MouseArea {
  107. id: mainMouseArea
  108. anchors.fill: parent
  109. onClicked: {
  110. main.showContacts(false);
  111. }
  112. }
  113. // ListView show one contact and PathView shows if there is more that one
  114. ListView {
  115. id: lview
  116. opacity: contactModel.contacts.length < 2 ? 1 : 0
  117. width: parent.width * 0.8
  118. height: container.rowHeight
  119. anchors.centerIn: parent
  120. model: contactModel
  121. delegate: listContactDelegate
  122. }
  123. // Used when more than one contact exists
  124. PathView {
  125. id: pview
  126. opacity: contactModel.contacts.length > 1 ? 1 : 0
  127. width: parent.width * 0.8
  128. height: parent.height * 0.6
  129. anchors.centerIn: parent
  130. clip: true
  131. pathItemCount: 4
  132. model: contactModel
  133. delegate: pathContactDelegate
  134. property int xCap: width * 0.5
  135. property int yCap: container.rowHeight * 0.5
  136. path:
  137. Path {
  138. // Top
  139. startX: pview.xCap; startY: pview.yCap
  140. PathAttribute { name: "elementScale"; value: 0.85}
  141. PathAttribute { name: "elementZ"; value: 10 }
  142. PathAttribute { name: "elementOpacity"; value: 0 }
  143. // Mid
  144. PathQuad { x: pview.xCap; y: pview.height * 0.5;
  145. controlX: pview.xCap; controlY: pview.yCap }
  146. PathAttribute { name: "elementScale"; value: 1 }
  147. PathAttribute { name: "elementZ"; value: 100 }
  148. PathAttribute { name: "elementOpacity"; value: 1 }
  149. // Low
  150. PathQuad { x: pview.xCap; y: pview.height - pview.yCap;
  151. controlX: pview.xCap; controlY: pview.height - pview.yCap}
  152. PathAttribute { name: "elementScale"; value: 0.85 }
  153. PathAttribute { name: "elementZ"; value: 1 }
  154. PathAttribute { name: "elementOpacity"; value: 0 }
  155. }
  156. }
  157. }