Dekko
Loading...
Searching...
No Matches
IdentitiesListPage.qml
1import QtQuick 2.4
2import QtQuick.Controls.Suru 2.2
3import Lomiri.Components 1.3
4import Dekko.Mail.API 1.0
5import Dekko.Mail.Stores.Accounts 1.0
6import Dekko.Mail.Stores.Settings 1.0
7import MazDB 1.0
8import Dekko.Lomiri.Constants 1.0
9import Dekko.Lomiri.Components 1.0
10import "../models"
11
13
14 pageHeader {
15 title: qsTr("Identities")
16 backAction: Action {
17 iconName: "back"
18 onTriggered: {
19 ViewActions.popStageArea(ViewKeys.settingsStack2)
20 ViewActions.popStageArea(ViewKeys.settingsStack1)
21 }
22 }
23 primaryAction: Action {
24 iconName: "contact-new"
25 onTriggered: SettingsActions.openSettingsGroup(Qt.resolvedUrl("./NewIdentityPage.qml"))
26 }
27 }
28
29 MazDBSortProxy {
30 id: proxy
31 sortCallBack: function (left, right) {
32 return left < right
33 }
34 // Sort by the accountName as we use this for the sections
35 sortBy: "accountName"
36 // make sure the listmodel is initialized before adding it to the proxy
37 model: identitiesModel.source ? identitiesModel : null
38
39 }
40
42 id: identitiesModel
43 }
44
46
47 ScrollView {
48 anchors.fill: parent
49 ListView {
50 anchors.fill: parent
51 section.property: "accountName"
52 section.delegate: Rectangle {
53 height: units.gu(3)
54 width: parent.width
55 color: Suru.secondaryBackgroundColor
56 Label {
57 anchors {
58 left: parent.left
59 leftMargin: units.gu(1.5)
60 verticalCenter: parent.verticalCenter
61 }
62 text: section
63 }
64 Line {
65 anchors {
66 left: parent.left
67 right: parent.right
68 bottom: parent.bottom
69 }
70 }
71 }
72
73 add: DekkoAnimation.listViewAddTransition
74 addDisplaced: DekkoAnimation.listViewAddDisplacedTransition
75 remove: DekkoAnimation.listViewRemoveTransition
76 removeDisplaced: DekkoAnimation.listViewRemoveDisplacedTransition
77 model: proxy.model ? proxy : null
78 delegate: ListItem {
79 height: layout.height
80 leadingActions: ListItemActions {
81 actions: [
82 Action {
83 iconName: "delete"
84 onTriggered: AccountActions.removeIdentity(model.id)
85 }
86 ]
87 }
88
89 onClicked: {
90 // If there is already an identity open for editing
91 // we want to prevent it saving overwise it will overwrite
92 // the tempIdentity we store here on page destruction
93 // as a result of calling openSettingsGroup
94 SettingsStore.saveGroupDisabled = true
95 // Indicate this is an already existing identity
96 SettingsStore.tempIsNew = false
97 // Set the values to load
98 SettingsStore.tempIdentity = model.value
99 SettingsActions.openSettingsGroup(Qt.resolvedUrl("./EditIdentityPage.qml"))
100 // re-enable saving settings groups so that we save state on layout transitions
101 SettingsStore.saveGroupDisabled = false
102 }
103
104 ListItemLayout {
105 id: layout
106 readonly property bool isDefault: AccountStore.identities.defaultIdentity === model.id
107 title.text: isDefault ? model.name + qsTr(" (Default)") : model.name
108 subtitle.text: model.email
109 summary.text: model.signature
110 summary.maximumLineCount: 1
111 ProgressionSlot {}
112 }
113 }
114 }
115 }
116 }
117}