| •1 |
/* |
| 2 |
* Copyright (C) 2024 UBports Foundation. |
| 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 QtContacts 5.0 as QtContacts |
| 20 |
|
| 21 |
import Lomiri.AddressBook.Base 0.1 |
| 22 |
import Lomiri.Contacts 0.1 |
| 23 |
|
| 24 |
|
| 25 |
Item { |
| 26 |
id: root |
| 27 |
|
| 28 |
visible: implicitHeight > 0 |
| 29 |
implicitHeight:(collections.length > 1) ? contents.implicitHeight : 0 |
| 30 |
|
| 31 |
property var model: null |
| 32 |
property var constituents: [] |
| 33 |
property var collections: ContactsJS.getCollections(root.model) |
| 34 |
property bool editable: true |
| 35 |
|
| 36 |
Column { |
| 37 |
id: contents |
| 38 |
spacing: units.gu(1) |
| 39 |
width: parent.width |
| 40 |
visible: label.text.length > 0 |
| 41 |
height: childrenRect.height |
| 42 |
|
| 43 |
ContactDetailTitle { |
| 44 |
title: i18n.dtr("lomiri-addressbook-app", "Addressbook") |
| 45 |
} |
| 46 |
|
| 47 |
Rectangle { |
| 48 |
|
| 49 |
anchors { |
| 50 |
left: parent.left |
| 51 |
right: parent.right |
| 52 |
leftMargin: units.gu(2) |
| 53 |
rightMargin: units.gu(2) |
| 54 |
} |
| 55 |
height: childrenRect.height |
| 56 |
color: theme.palette.normal.background |
| 57 |
|
| 58 |
Label { |
| 59 |
id: label |
| 60 |
anchors.left: parent.left |
| 61 |
anchors.right: parent.right |
| 62 |
height: units.gu(3) |
| 63 |
fontSize: "medium" |
| 64 |
text: { |
| 65 |
|
| 66 |
var addressbooks = [] |
| 67 |
for (var i = 0; i < root.constituents.length; i++) { |
| 68 |
var constituent = constituents[i] |
| 69 |
for(var j = 0 ; i < root.collections.length ; ++j) { |
| 70 |
var col = root.collections[j] |
| 71 |
if (constituent.collectionId === col.collectionId) { |
| 72 |
console.log(col.name, col.readOnly) |
| 73 |
if (col.readOnly) { |
| 74 |
root.editable = false |
| 75 |
} |
| 76 |
|
| 77 |
addressbooks.push(col.name) |
| 78 |
break; |
| 79 |
} |
| 80 |
} |
| 81 |
} |
| 82 |
return addressbooks.join(' - ') |
| 83 |
} |
| 84 |
elide: Label.ElideRight |
| 85 |
} |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
} |