/* * Copyright (C) 2012-2015 Canonical, Ltd. * * 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 QtContacts 5.0 import Lomiri.Components 1.3 import Lomiri.Components.ListItems 1.3 import Lomiri.Contacts 0.1 import Lomiri.AddressBook.Base 0.1 ContactDetailBase { id: root property bool isNewContact: contact && contact.contactId.length === 0 property real myHeight: label.height + units.gu(6) + addressBooksSelector.childrenRect.height property var contactModel: null property string selectedCollectionId: Contacts.defaultCollectionId signal changed() function save() { // only changes the collection for new contacts if (!isNewContact) { return; } root.contact.collectionId = selectedCollectionId } function getSelectedSource() { if (sources.model.count <= 0) return -1 var selectedSourceId = sources.model.get(sources.selectedIndex).sourceId if (selectedSourceId) { return selectedSourceId } else { return -1 } } function contactIsReadOnly(contact) { var sources = sourceModel.contacts var contactSyncTarget = contact.syncTarget.value(SyncTarget.SyncTarget + 1) for (var i = 0; i < writableSources.count; i++) { var source = writableSources.get(i) if (source.sourceId === contactSyncTarget) { return false } } return true } detail: root.contact ? contact.detail(ContactDetail.SyncTarget) : null implicitHeight: isNewContact ? myHeight : 0 visible: height > 0 ContactDetailTitle { id: label title: i18n.dtr("lomiri-addressbook-app", "Addressbook") } AddressBooksSelector { id: addressBooksSelector currentCollectionId: Contacts.defaultCollectionId contactModel: root.contactModel anchors { left: parent.left leftMargin: units.gu(2) top: label.bottom topMargin: units.gu(2) right: parent.right rightMargin: units.gu(2) bottom: parent.bottom bottomMargin: units.gu(2) } onAddressBookChanged: { root.selectedCollectionId = collectionId } } }