Merge lp:~renatofilho/address-book-app/fix-1199983 into lp:address-book-app

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Renato Araujo Oliveira Filho
Approved revision: 53
Merged at revision: 78
Proposed branch: lp:~renatofilho/address-book-app/fix-1199983
Merge into: lp:address-book-app
Diff against target: 139 lines (+61/-1)
4 files modified
src/imports/ContactEdit/ContactEditor.qml (+1/-0)
src/imports/ContactList/ContactListPage.qml (+3/-0)
src/imports/Ubuntu/Contacts/ContactSimpleListView.qml (+56/-1)
src/imports/main.qml (+1/-0)
To merge this branch: bzr merge lp:~renatofilho/address-book-app/fix-1199983
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Bill Filler (community) Approve
Review via email: mp+185057@code.launchpad.net

Commit message

Move list view to new contact after creation.

Description of the change

To test this you will need this qtpim branch: https://codereview.qt-project.org/62404

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

if the list is not expanded then you don't see the new contact. Whenever a new contact is added the list should be expanded if it's collapsed so the contact becomes visible

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

If the list is not expanded, then it won't scroll the new entry into view.

Steps to reproduce
1) have enough contacts to fill more than one page
2) collapse the list
3) add a contact with name "Zzzz Zzzz"

Expected results:
- list expanded and new entry visible

Results:
- list expanded but new entry not visible

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

test, works

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
53. By Renato Araujo Oliveira Filho

Merged mainline.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/imports/ContactEdit/ContactEditor.qml'
2--- src/imports/ContactEdit/ContactEditor.qml 2013-09-23 20:30:17 +0000
3+++ src/imports/ContactEdit/ContactEditor.qml 2013-09-23 20:31:21 +0000
4@@ -258,6 +258,7 @@
5
6 onContactsChanged: {
7 if (saving) {
8+ pageStack.contactCreated(contactEditor.contact)
9 pageStack.pop()
10 } else if (contactEditor.contact) {
11 for (var i=0; i < contactEditor.model.contacts.length; i++) {
12
13=== modified file 'src/imports/ContactList/ContactListPage.qml'
14--- src/imports/ContactList/ContactListPage.qml 2013-09-17 22:19:02 +0000
15+++ src/imports/ContactList/ContactListPage.qml 2013-09-23 20:31:21 +0000
16@@ -138,5 +138,8 @@
17 pageStack.push(Qt.resolvedUrl("../ContactEdit/ContactEditor.qml"),
18 {model: contactList.listModel, contactId: contactId, newPhoneNumber: phoneNumber })
19 }
20+ onContactCreated: {
21+ contactList.positionViewAtContact(contact)
22+ }
23 }
24 }
25
26=== modified file 'src/imports/Ubuntu/Contacts/ContactSimpleListView.qml'
27--- src/imports/Ubuntu/Contacts/ContactSimpleListView.qml 2013-09-21 21:59:30 +0000
28+++ src/imports/Ubuntu/Contacts/ContactSimpleListView.qml 2013-09-23 20:31:21 +0000
29@@ -149,6 +149,14 @@
30 This property holds the current contact expanded
31 */
32 property int currentContactExpanded: -1
33+
34+ /*!
35+ \qmlproperty bool animating
36+
37+ This property holds if the list is on animating state (expanding/collapsing)
38+ */
39+ readonly property alias animating: priv.animating
40+
41 /*!
42 \qmlproperty bool showSections
43
44@@ -169,6 +177,37 @@
45 */
46 signal detailClicked(QtObject contact, QtObject detail)
47
48+ /*!
49+ Retrieve the contact index inside of the list
50+ */
51+ function getIndex(contact)
52+ {
53+ var contacts = listModel.contacts;
54+
55+ for (var i = 0, count = contacts.length; i < count; i++) {
56+ var itemId = contacts[i].contactId
57+ if (itemId === contact.contactId) {
58+ return i
59+ }
60+ }
61+
62+ return -1
63+ }
64+
65+ /*!
66+ Scroll the list to requested contact if the contact exists in the list
67+ */
68+ function positionViewAtContact(contact)
69+ {
70+ if (expanded) {
71+ positionViewAtIndex(getIndex(contact), ListView.Center)
72+ } else {
73+ priv.pendingTargetIndex = getIndex(contact)
74+ priv.pendingTargetMode = ListView.Center
75+ expanded = true
76+ }
77+ }
78+
79 function formatToDisplay(contact, contactDetail, detailFields) {
80 if (!contact) {
81 return ""
82@@ -192,7 +231,7 @@
83 }
84
85 clip: true
86- snapMode: ListView.NoSnap
87+ snapMode: ListView.SnapToItem
88 section {
89 property: showSections ? "contact.tag.tag" : ""
90 criteria: ViewSection.FirstCharacter
91@@ -236,6 +275,9 @@
92 sourceComponent: height > units.gu(5) ? delegateItem : null
93 asynchronous: false
94 height: contactListView.expanded ? (((currentContactExpanded == index) && detailToPick != 0) ? delegateHeight : units.gu(10) ) : 0
95+ onHeightChanged: {
96+ priv.animating = (height != 0) && (height != units.gu(10))
97+ }
98 width: parent.width
99 visible: loaderDelegate.status == Loader.Ready
100
101@@ -256,6 +298,15 @@
102 when: loaderDelegate.status == Loader.Ready
103 }
104 }
105+
106+ onAnimatingChanged: {
107+ if (!animating && priv.pendingTargetIndex >= 0) {
108+ contactListView.positionViewAtIndex(priv.pendingTargetIndex, priv.pendingTargetMode)
109+ priv.pendingTargetIndex = -1
110+ priv.pendingTargetMode = null
111+ }
112+ }
113+
114 Component {
115 id: delegateItem
116 Item {
117@@ -524,6 +575,10 @@
118
119 property int currentOperation: -1
120 property string activeSection: ""
121+ property bool animating: false
122+
123+ property int pendingTargetIndex: 0
124+ property variant pendingTargetMode: null
125
126 function scrollToSection() {
127 var index = Sections.getIndexFor(activeSection)
128
129=== modified file 'src/imports/main.qml'
130--- src/imports/main.qml 2013-09-23 20:30:17 +0000
131+++ src/imports/main.qml 2013-09-23 20:31:21 +0000
132@@ -48,6 +48,7 @@
133 signal contactRequested(string contactId)
134 signal createContactRequested(string phoneNumber)
135 signal editContatRequested(string contactId, string phoneNumber)
136+ signal contactCreated(QtObject contact)
137
138 anchors {
139 fill: parent

Subscribers

People subscribed via source and target branches