Debian Codegraph @

src/imports/Lomiri/AddressBook/Base/RemoveContactsDialog.qml

raw ◀ ▶
Source reconstructed at patch state 0 of 2 — not the installed (fully patched) source.
2 Debian patches touch this file
1 /*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 import QtQuick 2.4
18 import Lomiri.Components 1.3
19 import Lomiri.Components.Popups 1.3
20
21 Dialog {
22 objectName: "removeContactsDialog"
23
24 property var contacts: []
25
26 signal canceled()
27 signal accepted()
28
29 function removeContacts(model)
30 {
31 var ids = []
32 for(var i=0, iMax=contacts.length; i < iMax; i++) {
33 ids.push(contacts[i].contactId)
34 }
35 model.removeContacts(ids)
36 }
37
38 title: {
39 if (contacts.length == 0) {
40 return i18n.dtr("lomiri-addressbook-app", "No contact selected.")
41 } else if (contacts.length == 1) {
42 return contacts[0].displayLabel.label
43 } else {
44 return i18n.dtr("lomiri-addressbook-app", "Multiple contacts")
45 }
46 }
47 text: {
48 if (contacts.length == 1) {
49 return i18n.dtr("lomiri-addressbook-app", "Are you sure that you want to remove this contact?")
50 } else {
51 return i18n.dtr("lomiri-addressbook-app", "Are you sure that you want to remove all selected contacts?")
52 }
53 }
54
55 Button {
56 id: acceptButton
57 objectName: "removeContactsDialog.Yes"
58 anchors {
59 left: parent.left
60 right: parent.right
61 margins: units.gu(1)
62 }
63 text: i18n.dtr("lomiri-addressbook-app", "Remove")
64 color: theme.palette.normal.negative
65 action: Action {
66 shortcut: "return"
67 onTriggered: accepted()
68 }
69 }
70
71 Button {
72 id: cancelButton
73 objectName: "removeContactsDialog.No"
74 anchors {
75 left: parent.left
76 right: parent.right
77 margins: units.gu(1)
78 }
79 text: i18n.dtr("lomiri-addressbook-app", "Cancel")
80 action: Action {
81 shortcut: "esc"
82 onTriggered: canceled()
83 }
84 }
85 }