Dekko
Loading...
Searching...
No Matches
ContactsListView.qml
1import QtQuick 2.4
2import Lomiri.Components 1.3
3import Lomiri.Components.ListItems 1.3 as ListItems
4import Dekko.Contacts 1.0
5import Dekko.Lomiri.Components 1.0
6import Dekko.Lomiri.Constants 1.0
7import "../../actions/views"
8
9Item {
10
11 readonly property bool slimMode: state === ContactKeys.slimPicker
12 readonly property bool standardMode: state === ContactKeys.standardPicker
13 // if no addressbook is set then the combined contacts model is used.
14 // set this if you want to limit results to a single addressbook
15 property AddressBook addressBook
16 property alias filterEmailOnly: sortedContacts.emailOnly
17
18 signal contactClicked(var contact);
19
20 Item {
21 id: sf
22 anchors {
23 left: parent.left
24 top: parent.top
25 right: parent.right
26 }
27
28 height: units.gu(5)
29 width: parent.width
30 TextField {
31 id: tf
32 anchors {
33 fill: parent
34 margins: units.gu(0.5)
35 }
36 placeholderText: qsTr("Search")
37 }
38 }
39
40 ScrollView {
41 anchors {
42 left: parent.left
43 top: sf.bottom
44 right: parent.right
45 bottom: parent.bottom
46 }
47 ListView {
48 id: lv
49 anchors.fill: parent
50 model: searchModel
51// add: DekkoAnimation.listViewAddTransition
52// addDisplaced: DekkoAnimation.listViewAddDisplacedTransition
53// remove: DekkoAnimation.listViewRemoveTransition
54// removeDisplaced: DekkoAnimation.listViewRemoveDisplacedTransition
55
56 delegate: ListItem {
57 height: layout.height
58 property var contact: model.qtObject
59 ListItemLayout {
60 id: layout
61 title.text: contact.firstname
62 height: slimMode ? units.gu(5) : units.gu(7)
63 Avatar {
64 height: slimMode ? units.gu(3.5) : units.gu(5.5)
65 width: height
66 fontSize: slimMode ? "medium" : "large"
67 name: contact.firstname
68 initials: contact.initials
69 email: contact.emailAddresses.count ? contact.emailAddresses.getFirst().address : ""
70 SlotsLayout.position: SlotsLayout.Leading
71 }
72 }
73 onClicked: contactClicked(model.qtObject)
74 leadingActions: ListItemActions {
75 actions: [
76 Action {
77 iconName: "delete"
78 onTriggered: ContactActions.removeContact(model.qtObject)
79 }
80 ]
81 }
82 }
83
84 // Ok so this took a bit of figuring out. We have to add \x00 to
85 // be able to use a qtObject property for sections.
86 section.property: "section\x00"
87 section.labelPositioning: ViewSection.InlineLabels | ViewSection.CurrentLabelAtStart
88 section.delegate: Component {
90 text: section
91 backgroundEnabled: true
92 }
93 }
94 }
95 }
96 state: ContactKeys.standardPicker
97 states: [
98 State {
99 name: ContactKeys.slimPicker
100 },
101 State {
102 name: ContactKeys.standardPicker
103 }
104 ]
105}