diff -Nru address-book-app-0.2+14.04.20140325.2/debian/changelog address-book-app-0.2+14.04.20140327/debian/changelog --- address-book-app-0.2+14.04.20140325.2/debian/changelog 2014-03-27 18:24:23.000000000 +0000 +++ address-book-app-0.2+14.04.20140327/debian/changelog 2014-03-27 18:24:23.000000000 +0000 @@ -1,3 +1,10 @@ +address-book-app (0.2+14.04.20140327-0ubuntu1) trusty; urgency=low + + [ Renato Araujo Oliveira Filho ] + * Implemented support to create contacts in different sources. + + -- Ubuntu daily release Thu, 27 Mar 2014 18:19:51 +0000 + address-book-app (0.2+14.04.20140325.2-0ubuntu1) trusty; urgency=low [ Leo Arias ] diff -Nru address-book-app-0.2+14.04.20140325.2/src/imports/Common/ContactDetailBase.qml address-book-app-0.2+14.04.20140327/src/imports/Common/ContactDetailBase.qml --- address-book-app-0.2+14.04.20140325.2/src/imports/Common/ContactDetailBase.qml 2014-03-25 13:35:01.000000000 +0000 +++ address-book-app-0.2+14.04.20140327/src/imports/Common/ContactDetailBase.qml 2014-03-27 18:19:43.000000000 +0000 @@ -61,6 +61,10 @@ imMap[QtContacts.OnlineAccount.Protocol] = "imProtocol" imMap[QtContacts.OnlineAccount.Capabilities] = "imCaps" + // SyncTarget + var syncTargetMap = {} + syncTargetMap[QtContacts.SyncTarget.SyncTarget] = "syncTarget" + // all var detailMap = {} detailMap[QtContacts.ContactDetail.Name] = nameMap @@ -68,6 +72,7 @@ detailMap[QtContacts.ContactDetail.Email] = emailMap detailMap[QtContacts.ContactDetail.Address] = addressMap detailMap[QtContacts.ContactDetail.OnlineAccount] = imMap + detailMap[QtContacts.ContactDetail.SyncTarget] = syncTargetMap // detail name var detailNameMap = {} @@ -76,6 +81,7 @@ detailNameMap[QtContacts.ContactDetail.Email] = "email" detailNameMap[QtContacts.ContactDetail.Address] = "address" detailNameMap[QtContacts.ContactDetail.OnlineAccount] = "onlineAccount" + detailNameMap[QtContacts.ContactDetail.SyncTarget] = "syncTarget" if ((detail in detailMap) && (field in detailMap[detail])) { return detailMap[detail][field] diff -Nru address-book-app-0.2+14.04.20140325.2/src/imports/ContactEdit/CMakeLists.txt address-book-app-0.2+14.04.20140327/src/imports/ContactEdit/CMakeLists.txt --- address-book-app-0.2+14.04.20140325.2/src/imports/ContactEdit/CMakeLists.txt 2014-03-25 13:35:01.000000000 +0000 +++ address-book-app-0.2+14.04.20140327/src/imports/ContactEdit/CMakeLists.txt 2014-03-27 18:19:43.000000000 +0000 @@ -7,6 +7,7 @@ ContactDetailOnlineAccountsEditor.qml ContactDetailOrganizationsEditor.qml ContactDetailPhoneNumbersEditor.qml + ContactDetailSyncTargetEditor.qml ContactDetailWithTypeEditor.qml ContactEditor.qml ContactFetchError.qml diff -Nru address-book-app-0.2+14.04.20140325.2/src/imports/ContactEdit/ContactDetailSyncTargetEditor.qml address-book-app-0.2+14.04.20140327/src/imports/ContactEdit/ContactDetailSyncTargetEditor.qml --- address-book-app-0.2+14.04.20140325.2/src/imports/ContactEdit/ContactDetailSyncTargetEditor.qml 1970-01-01 00:00:00.000000000 +0000 +++ address-book-app-0.2+14.04.20140327/src/imports/ContactEdit/ContactDetailSyncTargetEditor.qml 2014-03-27 18:19:43.000000000 +0000 @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2012-2013 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.0 +import QtContacts 5.0 +import Ubuntu.Components 0.1 +import Ubuntu.Components.ListItems 0.1 as ListItem + +import "../Common" + +ContactDetailBase { + id: root + + function save() { + // only changes the target sync for new contacts + if (!isNewContact) { + return; + } + var activeSource = getSelectedSource() + if (!activeSource) { + return; + } + + if (!root.detail) { + root.detail = root.contact.syncTarget + } + root.detail.syncTarget = activeSource + } + + function getSelectedSource() { + var selectedContact = sourceModel.contacts[sources.selectedIndex] + if (selectedContact) { + return selectedContact.guid.guid + } else { + return -1 + } + } + + property bool isNewContact: contact && contact.contactId === "qtcontacts:::" + property real myHeight: sources.containerHeight + units.gu(4) + label.height + + detail: contact ? contact.detail(ContactDetail.SyncTarget) : null + implicitHeight: isNewContact ? myHeight : 0 + + ContactModel { + id: sourceModel + + manager: QTCONTACTS_MANAGER_OVERRIDE && QTCONTACTS_MANAGER_OVERRIDE != "" ? QTCONTACTS_MANAGER_OVERRIDE : "galera" + filter: DetailFilter { + detail: ContactDetail.Type + field: Type.TypeField + value: Type.Group + matchFlags: DetailFilter.MatchExactly + } + } + + Label { + id: label + + text: i18n.tr("Addressbook") + anchors { + left: parent.left + top: parent.top + right: parent.right + margins: units.gu(2) + } + height: root.active ? units.gu(4) : units.gu(3) + } + + OptionSelector { + id: sources + + anchors { + left: parent.left + leftMargin: units.gu(2) + top: label.bottom + topMargin: units.gu(1) + right: parent.right + rightMargin: units.gu(2) + bottom: parent.bottom + bottomMargin: units.gu(2) + } + + model: sourceModel + delegate: OptionSelectorDelegate { + text: contact.displayLabel.label + height: units.gu(5) + } + + containerHeight: sourceModel.contacts.length > 4 ? itemHeight * 4 : itemHeight * sourceModel.contacts.length + } +} + diff -Nru address-book-app-0.2+14.04.20140325.2/src/imports/ContactEdit/ContactEditor.qml address-book-app-0.2+14.04.20140327/src/imports/ContactEdit/ContactEditor.qml --- address-book-app-0.2+14.04.20140325.2/src/imports/ContactEdit/ContactEditor.qml 2014-03-25 13:35:29.000000000 +0000 +++ address-book-app-0.2+14.04.20140327/src/imports/ContactEdit/ContactEditor.qml 2014-03-27 18:19:43.000000000 +0000 @@ -79,7 +79,11 @@ if (changed) { // backend error will be handled by the root page (contact list) + var newContact = (contact.model == null) contactEditor.model.saveContact(contact) + if (newContact) { + pageStack.contactCreated(contact) + } } pageStack.pop() } @@ -177,6 +181,7 @@ } height: implicitHeight + units.gu(3) KeyNavigation.tab: avatarEditor + KeyNavigation.backtab : syncTargetEditor } ContactDetailAvatarEditor { @@ -257,6 +262,20 @@ } height: implicitHeight KeyNavigation.backtab : addressesEditor + KeyNavigation.tab: syncTargetEditor + } + + ContactDetailSyncTargetEditor { + id: syncTargetEditor + + contact: contactEditor.contact + anchors { + left: parent.left + right: parent.right + } + height: implicitHeight + KeyNavigation.backtab : organizationsEditor + KeyNavigation.tab: nameEditor } } } diff -Nru address-book-app-0.2+14.04.20140325.2/src/imports/ContactList/ContactListPage.qml address-book-app-0.2+14.04.20140327/src/imports/ContactList/ContactListPage.qml --- address-book-app-0.2+14.04.20140325.2/src/imports/ContactList/ContactListPage.qml 2014-03-25 13:35:29.000000000 +0000 +++ address-book-app-0.2+14.04.20140327/src/imports/ContactList/ContactListPage.qml 2014-03-27 18:19:43.000000000 +0000 @@ -26,6 +26,8 @@ property bool pickMode: false property bool pickMultipleContacts: false + property QtObject contactIndex: null + property var contactModel: contactList.listModel ? contactList.listModel : null function createEmptyContact(phoneNumber) { var details = [ {detail: "PhoneNumber", field: "number", value: phoneNumber}, @@ -165,7 +167,17 @@ {model: contactList.listModel, contactId: contactId, newPhoneNumber: phoneNumber }) } onContactCreated: { - contactList.positionViewAtContact(contact) + mainPage.contactIndex = contact + } + } + + Connections { + target: mainPage.contactModel + onContactsChanged: { + if (contactIndex) { + contactList.positionViewAtContact(mainPage.contactIndex) + mainPage.contactIndex = null + } } } @@ -186,6 +198,7 @@ } } + Component.onCompleted: { if (pickMode) { contactList.startSelection() diff -Nru address-book-app-0.2+14.04.20140325.2/src/imports/ContactView/CMakeLists.txt address-book-app-0.2+14.04.20140327/src/imports/ContactView/CMakeLists.txt --- address-book-app-0.2+14.04.20140325.2/src/imports/ContactView/CMakeLists.txt 2014-03-25 13:35:01.000000000 +0000 +++ address-book-app-0.2+14.04.20140327/src/imports/ContactView/CMakeLists.txt 2014-03-27 18:19:43.000000000 +0000 @@ -11,6 +11,7 @@ ContactDetailOrganizationsView.qml ContactDetailPhoneNumbersView.qml ContactDetailPhoneNumberView.qml + ContactDetailSyncTargetView.qml ContactDetailWithTypeView.qml ContactHeaderView.qml ContactView.qml diff -Nru address-book-app-0.2+14.04.20140325.2/src/imports/ContactView/ContactDetailSyncTargetView.qml address-book-app-0.2+14.04.20140327/src/imports/ContactView/ContactDetailSyncTargetView.qml --- address-book-app-0.2+14.04.20140325.2/src/imports/ContactView/ContactDetailSyncTargetView.qml 1970-01-01 00:00:00.000000000 +0000 +++ address-book-app-0.2+14.04.20140327/src/imports/ContactView/ContactDetailSyncTargetView.qml 2014-03-27 18:19:43.000000000 +0000 @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2014 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.0 +import Ubuntu.Components 0.1 +import QtContacts 5.0 as QtContacts + +ContactDetailGroupWithTypeView { + id: root + + title: i18n.tr("Addressbook") + defaultIcon: "image://theme/contact-group" + detailType: QtContacts.ContactDetail.SyncTarget + typeModel: null + + fields: [ QtContacts.SyncTarget.SyncTarget ] +} diff -Nru address-book-app-0.2+14.04.20140325.2/src/imports/ContactView/ContactView.qml address-book-app-0.2+14.04.20140327/src/imports/ContactView/ContactView.qml --- address-book-app-0.2+14.04.20140325.2/src/imports/ContactView/ContactView.qml 2014-03-25 13:35:29.000000000 +0000 +++ address-book-app-0.2+14.04.20140327/src/imports/ContactView/ContactView.qml 2014-03-27 18:19:43.000000000 +0000 @@ -137,6 +137,15 @@ } height: implicitHeight } + + ContactDetailSyncTargetView { + contact: root.contact + anchors { + left: parent.left + right: parent.right + } + height: implicitHeight + } } } diff -Nru address-book-app-0.2+14.04.20140325.2/src/imports/Ubuntu/Contacts/ContactDelegate.qml address-book-app-0.2+14.04.20140327/src/imports/Ubuntu/Contacts/ContactDelegate.qml --- address-book-app-0.2+14.04.20140325.2/src/imports/Ubuntu/Contacts/ContactDelegate.qml 2014-03-25 13:35:01.000000000 +0000 +++ address-book-app-0.2+14.04.20140327/src/imports/Ubuntu/Contacts/ContactDelegate.qml 2014-03-27 18:19:43.000000000 +0000 @@ -116,7 +116,7 @@ onPressAndHold: item.pressAndHold(index, contact) onItemRemoved: { - contactsModel.removeContact(contact.contactId) + listModel.removeContact(contact.contactId) } } @@ -131,7 +131,7 @@ } onStatusChanged: { if (status == Loader.Ready) { - pickerLoader.item.contactsModel = contactsModel + pickerLoader.item.contactsModel = listModel pickerLoader.item.detailType = detailToPick pickerLoader.item.contactId = contact.contactId } diff -Nru address-book-app-0.2+14.04.20140325.2/src/imports/Ubuntu/Contacts/ContactListView.qml address-book-app-0.2+14.04.20140327/src/imports/Ubuntu/Contacts/ContactListView.qml --- address-book-app-0.2+14.04.20140325.2/src/imports/Ubuntu/Contacts/ContactListView.qml 2014-03-25 13:35:01.000000000 +0000 +++ address-book-app-0.2+14.04.20140327/src/imports/Ubuntu/Contacts/ContactListView.qml 2014-03-27 18:19:43.000000000 +0000 @@ -102,14 +102,44 @@ } } - DetailFilter { - id: favouritesFilter + ContactModel { + id: allContactsModel + + manager: root.manager + sortOrders: root.sortOrders + fetchHint: root.fetchHint + + onErrorChanged: { + if (error) { + busyIndicator.busy = false + contactListView.error(error) + } + } + } + + ContactModel { + id: favouritesContactsModel + + manager: root.manager + sortOrders: root.sortOrders + fetchHint: root.fetchHint + filter: DetailFilter { + id: favouritesFilter + + detail: ContactDetail.Favorite + field: Favorite.Favorite + value: true + matchFlags: DetailFilter.MatchExactly + } + + onErrorChanged: { + if (error) { + busyIndicator.busy = false + contactListView.error(error) + } + } - detail: ContactDetail.Favorite - field: Favorite.Favorite - value: true - matchFlags: DetailFilter.MatchExactly } - filter: showFavourites ? favouritesFilter : null + listModel: showFavourites ? favouritesContactsModel : allContactsModel } diff -Nru address-book-app-0.2+14.04.20140325.2/src/imports/Ubuntu/Contacts/ContactSimpleListView.qml address-book-app-0.2+14.04.20140327/src/imports/Ubuntu/Contacts/ContactSimpleListView.qml --- address-book-app-0.2+14.04.20140325.2/src/imports/Ubuntu/Contacts/ContactSimpleListView.qml 2014-03-25 13:35:01.000000000 +0000 +++ address-book-app-0.2+14.04.20140327/src/imports/Ubuntu/Contacts/ContactSimpleListView.qml 2014-03-27 18:19:43.000000000 +0000 @@ -85,7 +85,17 @@ This property holds a list of sort orders used by the contacts model. \sa SortOrder */ - property alias sortOrders: contactsModel.sortOrders + property list sortOrders : [ + SortOrder { + id: sortOrder + + detail: ContactDetail.DisplayLabel + field: DisplayLabel.Label + direction: Qt.AscendingOrder + blankPolicy: SortOrder.BlanksLast + caseSensitivity: Qt.CaseInsensitive + } + ] /*! \qmlproperty FetchHint fetchHint @@ -93,7 +103,16 @@ \sa FetchHint */ - property alias fetchHint: contactsModel.fetchHint + property var fetchHint : FetchHint { + detailTypesHint: { + var hints = [ contactListView.titleDetail, ContactDetail.Tag, ContactDetail.DisplayLabel ] + + if (contactListView.showAvatar) { + hints.push(ContactDetail.Avatar) + } + return hints + } + } /*! \qmlproperty Filter filter @@ -101,7 +120,7 @@ \sa Filter */ - property alias filter: contactsModel.filter + property var filter /*! \qmlproperty bool multiSelectionEnabled @@ -156,7 +175,7 @@ This property holds the manager uri of the contact backend engine. By default this is set to "galera" */ - property alias manager: contactsModel.manager + property string manager: QTCONTACTS_MANAGER_OVERRIDE && QTCONTACTS_MANAGER_OVERRIDE != "" ? QTCONTACTS_MANAGER_OVERRIDE : "galera" /*! This handler is called when any error occurs in the contact model @@ -172,16 +191,32 @@ signal detailClicked(QtObject contact, QtObject detail) /*! - Retrieve the contact index inside of the list + Retrieve the contact index inside of the list based on contact id or contact name if the id is empty */ function getIndex(contact) { - var contacts = listModel.contacts; + var contacts = listModel.contacts + var contactId = null + var firstName + var middleName + var lastName + + if (contact.contactId !== "qtcontacts:::") { + contactId = contact.contactId + } else { + firstName = contact.name.firstName + middleName = contact.name.middleName + lastName = contact.name.lastName + } for (var i = 0, count = contacts.length; i < count; i++) { - var itemId = contacts[i].contactId - if (itemId === contact.contactId) { + var c = contacts[i] + if (contactId && (c.contactId === contactId)) { return i + } else if ((c.name.firstName === firstName) && + (c.name.middleName === middleName) && + (c.name.lastName === lastName)) { + return i } } @@ -418,42 +453,6 @@ ] } - ContactModel { - id: contactsModel - - manager: QTCONTACTS_MANAGER_OVERRIDE && QTCONTACTS_MANAGER_OVERRIDE != "" ? QTCONTACTS_MANAGER_OVERRIDE : "galera" - sortOrders: [ - SortOrder { - id: sortOrder - - detail: ContactDetail.DisplayLabel - field: DisplayLabel.Label - direction: Qt.AscendingOrder - blankPolicy: SortOrder.BlanksLast - caseSensitivity: Qt.CaseInsensitive - } - ] - - fetchHint: FetchHint { - detailTypesHint: { - var hints = [ contactListView.titleDetail, ContactDetail.Tag, ContactDetail.DisplayLabel ] - - if (contactListView.showAvatar) { - hints.push(ContactDetail.Avatar) - } - return hints - } - } - - onErrorChanged: { - if (error) { - busyIndicator.busy = false - contactListView.error(error) - } - } - - } - onContentHeightChanged: { if (priv.activeSection !== "") { dirtyHeightTimer.restart() @@ -472,7 +471,7 @@ ContactFetch { id: contactFetch - model: contactsModel + model: contactListView.listModel onContactFetched: contactListView.contactClicked(contact) }