/* * Copyright (C) 2024 UBports Foundation. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.4 import Lomiri.Components 1.3 import QtContacts 5.0 as QtContacts import Lomiri.AddressBook.Base 0.1 import Lomiri.Contacts 0.1 Item { id: root visible: implicitHeight > 0 implicitHeight:(collections.length > 1) ? contents.implicitHeight : 0 property var model: null property var constituents: [] property var collections: ContactsJS.getCollections(root.model) property bool editable: true Column { id: contents spacing: units.gu(1) width: parent.width visible: label.text.length > 0 height: childrenRect.height ContactDetailTitle { title: i18n.dtr("lomiri-addressbook-app", "Addressbook") } Rectangle { anchors { left: parent.left right: parent.right leftMargin: units.gu(2) rightMargin: units.gu(2) } height: childrenRect.height color: theme.palette.normal.background Label { id: label anchors.left: parent.left anchors.right: parent.right height: units.gu(3) fontSize: "medium" text: { var addressbooks = [] for (var i = 0; i < root.constituents.length; i++) { var constituent = constituents[i] for(var j = 0 ; i < root.collections.length ; ++j) { var col = root.collections[j] if (constituent.collectionId === col.collectionId) { console.log(col.name, col.readOnly) if (col.readOnly) { root.editable = false } addressbooks.push(col.name) break; } } } return addressbooks.join(' - ') } elide: Label.ElideRight } } } }