[Merge] lp:~renatofilho/address-book-app/refactory-url-handler into lp:~phablet-team/address-book-app/staging
Tiago Salem Herrmann
tiago.herrmann at canonical.com
Mon Jul 14 16:35:49 UTC 2014
Review: Needs Fixing
Diff comments:
> === modified file 'src/app/addressbookapp.cpp'
> --- src/app/addressbookapp.cpp 2014-07-04 23:10:37 +0000
> +++ src/app/addressbookapp.cpp 2014-07-11 22:12:00 +0000
> @@ -39,11 +39,12 @@
> {
> qDebug() << "usage:"
> << arguments.at(0).toUtf8().constData()
> - << "[addressbook:///addphone?id=<contact-id>&phone=<phone-number>"
> - << "[addressbook:///contact?id=<contact-id>"
> - << "[addressbook:///create?phone=<phone-number>"
> - << "[addressbook:///pick?single=<true/false>"
> - << "[addressbook:///importvcard?url=<vcard-file>"
> + << "[addressbook:///addphone?id=<contact-id>&phone=<phone-number>]"
> + << "[addressbook:///addnewphone?phone=<phone-number>]"
> + << "[addressbook:///contact?id=<contact-id>]"
> + << "[addressbook:///create?phone=<phone-number>]"
> + << "[addressbook:///pick?single=<true/false>]"
> + << "[addressbook:///importvcard?url=<vcard-file>]"
> << "[--fullscreen]"
> << "[--help]"
> << "[-testability]";
> @@ -305,6 +306,11 @@
> args << "url";
> methodsMetaData.insert("importvcard", args);
> args.clear();
> +
> + //addnewphone
> + args << "phone";
> + methodsMetaData.insert("addnewphone", args);
> + args.clear();
> }
>
> QUrlQuery query(url);
>
> === modified file 'src/imports/ContactEdit/ContactEditor.qml'
> --- src/imports/ContactEdit/ContactEditor.qml 2014-06-17 17:30:40 +0000
> +++ src/imports/ContactEdit/ContactEditor.qml 2014-07-11 22:12:00 +0000
> @@ -82,8 +82,8 @@
> // 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)
> + if (newContact && pageStack.contactListPage) {
> + pageStack.contactListPage.moveListToContact(contact)
> }
> }
> pageStack.pop()
>
> === modified file 'src/imports/ContactList/ContactListPage.qml'
> --- src/imports/ContactList/ContactListPage.qml 2014-07-02 23:23:19 +0000
> +++ src/imports/ContactList/ContactListPage.qml 2014-07-11 22:12:00 +0000
> @@ -35,12 +35,15 @@
> property var onlineAccountsMessageDialog: null
> property QtObject contactIndex: null
> property bool contactsLoaded: false
> + property string newPhoneToAdd: ""
> + property bool allowToQuit: false
>
> readonly property bool syncEnabled: application.syncEnabled
> readonly property var contactModel: contactList.listModel ? contactList.listModel : null
> readonly property bool searching: (state === "searching")
>
> - function createEmptyContact(phoneNumber) {
> + function createEmptyContact(phoneNumber)
> + {
> var details = [ {detail: "PhoneNumber", field: "number", value: phoneNumber},
> {detail: "EmailAddress", field: "emailAddress", value: ""},
> {detail: "Name", field: "firstName", value: ""}
> @@ -63,13 +66,63 @@
> var newContact = mainPage.createEmptyContact(phoneNumber)
> //WORKAROUND: SKD changes the page header as soon as the page get created
> // setting active false will avoid that
> - mainPage.showBottomEdgePage(Qt.resolvedUrl("../ContactEdit/ContactEditor.qml"),
> - {model: contactList.listModel,
> - contact: newContact,
> - active: false,
> - enabled: false,
> - initialFocusSection: "name"})
> -
> + if (bottomEdgeEnabled) {
> + mainPage.showBottomEdgePage(Qt.resolvedUrl("../ContactEdit/ContactEditor.qml"),
> + {model: contactList.listModel,
> + contact: newContact,
> + active: false,
> + enabled: false,
> + initialFocusSection: "name"})
> + } else {
> + pageStack.push(Qt.resolvedUrl("../ContactEdit/ContactEditor.qml"),
> + {model: contactList.listModel,
> + contact: newContact,
> + initialFocusSection: "name"})
> + }
> + }
> +
> + function showContact(contactId)
> + {
> + pageStack.push(Qt.resolvedUrl("../ContactView/ContactView.qml"),
> + {model: contactList.listModel, contactId: contactId})
> + }
> +
> + function addPhoneToContact(contactId, phoneNumber)
> + {
> + pageStack.push(Qt.resolvedUrl("../ContactView/ContactView.qml"),
> + {model: contactList.listModel,
> + contactId: contactId,
> + addPhoneToContact: phoneNumber})
> + }
> +
> + function importContact(urls)
> + {
> + if (urls.length > 0) {
> + var importDialog = Qt.createQmlObject("VCardImportDialog{}",
> + mainPage,
> + "VCardImportDialog")
> + if (importDialog) {
> + importDialog.importVCards(contactList.listModel, urls)
> + }
> + }
> + }
> +
> + function startPickMode(isSingleSelection)
> + {
> + pickMode = true
> + pickMultipleContacts = !isSingleSelection
> + contactList.startSelection()
> + }
> +
> + function moveListToContact(contact)
> + {
> + contactIndex = contact
> + }
> +
> + function addNewPhone(phoneNumber)
> + {
> + newPhoneToAdd = phoneNumber
> + state = "newphone"
> }
>
> title: contactList.isInSelectionMode ? i18n.tr("Select Contacts") : i18n.tr("Contacts")
> @@ -124,13 +177,34 @@
> }
> }
>
> + Button {
> + id: addNewContactButton
> + objectName: "addNewContact"
> +
> + text: i18n.tr("+ New Contact")
> + anchors {
> + top: parent.top
> + left: parent.left
> + right: parent.right
> + margins: visible ? units.gu(2) : 0
> + }
> + height: visible ? units.gu(4) : 0
> + visible: false
> + onClicked: {
> + mainPage.createContactWithPhoneNumber(mainPage.newPhoneToAdd)
> + mainPage.newPhoneToAdd = ""
> + mainPage.state = ""
> + }
> + }
> +
> flickable: null //contactList.fastScrolling ? null : contactList.view
> ContactsUI.ContactListView {
> id: contactList
> objectName: "contactListView"
>
> anchors {
> - top: parent.top
> + top: addNewContactButton.bottom
> + topMargin: addNewContactButton.visible ? units.gu(2) : 0
> left: parent.left
> bottom: keyboard.top
> right: parent.right
> @@ -139,7 +213,8 @@
> detailToPick: ContactDetail.PhoneNumber
> multiSelectionEnabled: true
> multipleSelection: !pickMode ||
> - mainPage.pickMultipleContacts || (contactExporter.active && contactExporter.isMultiple)
> + mainPage.pickMultipleContacts ||
> + (contactExporter.active && contactExporter.isMultiple)
>
> leftSideAction: Action {
> iconName: "delete"
> @@ -174,6 +249,11 @@
> Qt.openUrlExternally("tel:///" + encodeURIComponent(detail.number))
> else if (action == "message")
> Qt.openUrlExternally("message:///" + encodeURIComponent(detail.number))
> + else if (mainPage.state == "newphone") {
> + mainPage.addPhoneToContact(contact.contactId, mainPage.newPhoneToAdd)
> + mainPage.newPhoneToAdd = ""
> + mainPage.state = ""
> + }
> }
>
> onSelectionDone: {
> @@ -247,7 +327,7 @@
> text: i18n.tr("Select All")
> iconName: "filter"
> onTriggered: {
> - if (contactList.selectedItems.count == contactList.count) {
> + if (contactList.selectedItems.count === contactList.count) {
> contactList.clearSelection()
> } else {
> contactList.selectAll()
> @@ -272,6 +352,21 @@
> id: toolbarItemsNormalMode
>
> visible: false
> + back: mainPage.allowToQuit ? quitButton : null
> +
> + ToolbarButton {
> + id: quitButton
> +
> + visible: false
> + action: Action {
> + objectName: "quitApp"
> +
> + visible: mainPage.allowToQuit
> + iconName: "back"
> + text: i18n.tr("Quit")
> + onTriggered: Qt.quit()
> + }
> + }
> ToolbarButton {
> objectName: "Sync"
> action: Action {
> @@ -329,7 +424,6 @@
> onTextChanged: contactList.currentIndex = -1
> inputMethodHints: Qt.ImhNoPredictiveText
> }
> -
> states: [
> State {
> name: ""
> @@ -339,6 +433,21 @@
> }
> },
> State {
> + name: "newphone"
> + PropertyChanges {
> + target: addNewContactButton
> + visible: true
> + }
> + PropertyChanges {
> + target: mainPage
> + bottomEdgeEnabled: false
> + }
> + PropertyChanges {
> + target: contactList
> + detailToPick: -1
> + }
> + },
> + State {
> name: "searching"
> PropertyChanges {
> target: mainPage
> @@ -356,6 +465,7 @@
> PropertyChanges {
> target: mainPage
> tools: toolbarItemsSelectionMode
> + bottomEdgeEnabled: false
> }
> }
> ]
> @@ -392,35 +502,6 @@
> initialFocusSection: "name"})
> }
>
> - Connections {
> - target: pageStack
> - onCreateContactRequested: mainPage.createContactWithPhoneNumber(phoneNumber)
> - onContactRequested: {
> - pageStack.push(Qt.resolvedUrl("../ContactView/ContactView.qml"),
> - {model: contactList.listModel, contactId: contactId})
> - }
> - onEditContatRequested: {
> - pageStack.push(Qt.resolvedUrl("../ContactView/ContactView.qml"),
> - {model: contactList.listModel,
> - contactId: contactId,
> - addPhoneToContact: phoneNumber})
> - }
> - onContactCreated: {
> - mainPage.contactIndex = contact
> - }
> -
> - onImportContactRequested: {
> - if (urls.length > 0) {
> - var importDialog = Qt.createQmlObject("VCardImportDialog{}",
> - mainPage,
> - "VCardImportDialog")
> - if (importDialog) {
> - importDialog.importVCards(contactList.listModel, urls)
> - }
> - }
> - }
> - }
> -
> KeyboardRectangle {
> id: keyboard
> }
> @@ -435,7 +516,6 @@
> }
> }
>
> -
> QtObject {
> id: contactExporter
>
> @@ -470,25 +550,22 @@
> }
>
> Component.onCompleted: {
> - if (pickMode) {
> - contactList.startSelection()
> - } else if ((contactList.count === 0) &&
> + if ((contactList.count === 0) &&
> application.firstRun &&
> !mainPage.syncEnabled) {
> mainPage.onlineAccountsMessageDialog = PopupUtils.open(onlineAccountsDialog, null)
> }
>
> - if (TEST_DATA != "") {
> + if (TEST_DATA !== "") {
> contactList.listModel.importContacts("file://" + TEST_DATA)
> }
>
> - if (!pickMode) {
> - mainPage.setBottomEdgePage(Qt.resolvedUrl("../ContactEdit/ContactEditor.qml"),
> - {model: contactList.listModel,
> - contact: mainPage.createEmptyContact(""),
> - active: false,
> - enabled: false,
> - initialFocusSection: "name"})
> - }
> + mainPage.setBottomEdgePage(Qt.resolvedUrl("../ContactEdit/ContactEditor.qml"),
> + {model: contactList.listModel,
> + contact: mainPage.createEmptyContact(""),
> + active: false,
> + enabled: false,
> + initialFocusSection: "name"})
> + pageStack.contactListPage = mainPage
> }
> }
>
> === modified file 'src/imports/ContactView/ContactDetailAvatarView.qml'
> --- src/imports/ContactView/ContactDetailAvatarView.qml 2014-07-08 14:20:01 +0000
> +++ src/imports/ContactView/ContactDetailAvatarView.qml 2014-07-11 22:12:00 +0000
> @@ -28,7 +28,8 @@
> implicitWidth: units.gu(10)
>
> Connections {
> - target: root.contact.avatar
> + target: root.contact ? root.contact.detail(ContactDetail.Avatar) : null
> + ignoreUnknownSignals: true
> onDetailChanged: avatar.reload()
> }
>
>
> === modified file 'src/imports/MainWindow.qml'
> --- src/imports/MainWindow.qml 2014-06-26 15:46:45 +0000
> +++ src/imports/MainWindow.qml 2014-07-11 22:12:00 +0000
> @@ -24,6 +24,7 @@
> id: mainWindow
>
> property string modelErrorMessage: ""
> + readonly property bool appActive: Qt.application.active
>
> width: units.gu(40)
> height: units.gu(71)
> @@ -32,54 +33,73 @@
>
> signal applicationReady()
>
> - function contact(contactId) {
> - mainStack.contactRequested(contactId)
> - }
> -
> - function create(phoneNumber) {
> - mainStack.createContactRequested(phoneNumber)
> - }
> -
> - function addphone(contactId, phoneNumber) {
> - mainStack.newPhoneNumber = phoneNumber
> - mainStack.editContatRequested(contactId, phoneNumber)
> - }
> -
> - function pick(single) {
> - var isSingle = (single == "true")
> - mainStack.push(Qt.createComponent("ContactList/ContactListPage.qml"), { pickMode: true, pickMultipleContacts: !isSingle})
> - }
> -
> - function importvcard(_url) {
> - mainStack.importContactRequested([_url])
> + function resetStack()
> + {
> + while(mainStack.depth > 1) {
> + mainStack.pop()
> + }
> + }
> +
> + function contact(contactId)
> + {
> + resetStack()
> + if (mainStack.contactListPage) {
> + mainStack.contactListPage.allowToQuit = true
> + mainStack.contactListPage.showContact(contactId)
> + }
> + }
> +
> + function create(phoneNumber)
> + {
> + resetStack()
> + if (mainStack.contactListPage) {
> + mainStack.contactListPage.allowToQuit = true
> + mainStack.contactListPage.createContactWithPhoneNumber(phoneNumber)
> + }
> + }
> +
> + function addphone(contactId, phoneNumber)
> + {
> + resetStack()
> + if (mainStack.contactListPage) {
> + mainStack.contactListPage.allowToQuit = true
> + mainStack.contactListPage.addPhoneToContact(contactId, phoneNumber)
> + }
> + }
> +
> + function pick(single)
> + {
> + resetStack()
> + if (mainStack.contactListPage) {
> + mainStack.contactListPage.allowToQuit = true
> + mainStack.contactListPage.startPickMode(single == "true")
> + }
> + }
> +
> + function importvcard(_url)
> + {
> + resetStack()
> + if (mainStack.contactListPage) {
> + mainStack.contactListPage.allowToQuit = true
> + mainStack.contactListPage.importContactRequested([_url])
> + }
> + }
> +
> + function addnewphone(phoneNumer)
> + {
> + resetStack()
> + if (mainStack.contactListPage) {
> + mainStack.contactListPage.allowToQuit = true
> + mainStack.contactListPage.addNewPhone(phoneNumer)
> + }
> }
>
> PageStack {
> id: mainStack
>
> - property string newPhoneNumber: ""
> -
> - signal contactRequested(string contactId)
> - signal createContactRequested(string phoneNumber)
> - signal editContatRequested(string contactId, string phoneNumber)
> - signal contactCreated(QtObject contact)
> - signal contactModelError(string errorMessage)
> - signal importContactRequested(var urls)
> -
> - anchors {
> - fill: parent
> - Behavior on bottomMargin {
> - NumberAnimation {
> - duration: 175
> - easing.type: Easing.OutQuad
> - }
> - }
> - }
> -
> - onContactModelError: {
> - modelErrorMessage = errorMessage
> - PopupUtils.open(errorDialog, null)
> - }
> + property var contactListPage: null
> +
> + anchors.fill: parent
> }
>
> Component.onCompleted: {
> @@ -133,4 +153,16 @@
> }
> }
> }
> +
> +
> + // If appliacion wass called from url handler and lost the focus reset the app to normal state
please fix the typos
> + onAppActiveChanged: {
> + if (!appActive &&
> + mainStack.contactListPage &&
> + mainStack.contactListPage.allowToQuit) {
> + resetStack()
> + mainStack.contactListPage.allowToQuit = false
> + mainStack.contactListPage.state = ""
> + }
> + }
> }
>
> === modified file 'src/imports/Ubuntu/Contacts/ContactSimpleListView.qml'
> --- src/imports/Ubuntu/Contacts/ContactSimpleListView.qml 2014-07-09 15:30:13 +0000
> +++ src/imports/Ubuntu/Contacts/ContactSimpleListView.qml 2014-07-11 22:12:00 +0000
> @@ -358,10 +358,10 @@
> contactListView.currentIndex = -1
> return
> // check if we should expand and display the details picker
> - } else if (detailToPick !== 0) {
> + } else if (detailToPick !== -1) {
> contactListView.currentIndex = index
> return
> - } else if (detailToPick == 0) {
> + } else if (detailToPick == -1) {
> contactListView.detailClicked(contact, null, "")
> }
> }
>
--
https://code.launchpad.net/~renatofilho/address-book-app/refactory-url-handler/+merge/226446
Your team Ubuntu Phablet Team is subscribed to branch lp:~phablet-team/address-book-app/staging.
More information about the Ubuntu-reviews
mailing list