Merge lp:~qqworini/ubuntu-rssreader-app/edit-topic-confirm into lp:~ubuntu-shorts-dev/ubuntu-rssreader-app/trunk

Proposed by Joey Chan
Status: Merged
Approved by: David Planella
Approved revision: 68
Merged at revision: 68
Proposed branch: lp:~qqworini/ubuntu-rssreader-app/edit-topic-confirm
Merge into: lp:~ubuntu-shorts-dev/ubuntu-rssreader-app/trunk
Diff against target: 246 lines (+126/-26)
3 files modified
feeds/TopicComponent.qml (+29/-15)
feeds/TopicManagement.qml (+83/-11)
ubuntu-rssreader-app.qml (+14/-0)
To merge this branch: bzr merge lp:~qqworini/ubuntu-rssreader-app/edit-topic-confirm
Reviewer Review Type Date Requested Status
Roman Shchekin Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+186300@code.launchpad.net

Commit message

add confirm/cancel buttons for edit topic

Description of the change

add confirm/cancel buttons for edit topic

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Roman Shchekin (mrqtros) wrote :

Seems that all is ok.

review: Approve
Revision history for this message
David Planella (dpm) wrote :

Top-approving as per Roman's comment.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'feeds/TopicComponent.qml'
2--- feeds/TopicComponent.qml 2013-08-20 15:17:56 +0000
3+++ feeds/TopicComponent.qml 2013-09-18 12:16:38 +0000
4@@ -18,6 +18,8 @@
5 property int topicId
6 property int modelIndex
7
8+ signal edit()
9+
10 // onClicked: isExpended = !isExpended ;
11
12 onStateChanged:{
13@@ -38,6 +40,26 @@
14 }
15 }
16
17+ function cancelEdit() {
18+ rowTopicContent.isEditing = false
19+ inputTopicName.text = topicName
20+ }
21+
22+ function confirmEdit() {
23+ var result = DB.updateTag(topicComponent.topicId, inputTopicName.text)
24+ if (result.rowsAffected == 1)
25+ {
26+ mainView.changeTopicName(topicComponent.topicId, inputTopicName.text)
27+ labelTopicName.text = inputTopicName.text
28+ topicName = inputTopicName.text
29+ }
30+ else
31+ {
32+ inputTopicName.text = labelTopicName.text
33+ }
34+ cancelEdit()
35+ }
36+
37 Column{
38 id: columnContent
39 anchors{ left: parent.left; right: parent.right }
40@@ -96,24 +118,12 @@
41 smooth: true
42
43 MouseArea{
44+ enabled: !rowTopicContent.isEditing
45 anchors { fill: parent; margins: units.gu(-1) }
46 onClicked:
47 {
48- if (rowTopicContent.isEditing)
49- {
50- var result = DB.updateTag(topicComponent.topicId, inputTopicName.text)
51- if (result.rowsAffected == 1)
52- {
53- labelTopicName.text = inputTopicName.text
54- }
55- else
56- {
57- inputTopicName.text = labelTopicName.text
58- }
59- }
60- else
61- {}
62- rowTopicContent.isEditing = !rowTopicContent.isEditing
63+ rowTopicContent.isEditing = true
64+ topicComponent.edit()
65 }
66 }
67 }
68@@ -139,6 +149,10 @@
69
70 Behavior on width { UbuntuNumberAnimation{} }
71
72+ onAccepted: {
73+ Qt.inputMethod.hide()
74+ }
75+
76 Connections {
77 target: Qt.inputMethod
78 onVisibleChanged: {
79
80=== modified file 'feeds/TopicManagement.qml'
81--- feeds/TopicManagement.qml 2013-09-01 14:35:33 +0000
82+++ feeds/TopicManagement.qml 2013-09-18 12:16:38 +0000
83@@ -12,17 +12,7 @@
84
85 title: i18n.tr("Management")
86 flickable: content
87- tools: ToolbarItems {
88- id: toolbar
89-
90- ToolbarButton {
91- id: actionsButton
92- text: i18n.tr("Add Feed")
93- iconSource: Qt.resolvedUrl("../icons_tmp/add.svg")
94- onTriggered: pageStack.push(appendFeedPage/*, {"isDirty" : true}*/) ;
95- visible: true
96- }
97- }
98+ tools: toolbar
99
100 Component.onCompleted:
101 {
102@@ -50,6 +40,53 @@
103
104 }
105
106+ ToolbarItems {
107+ id: toolbar
108+
109+ ToolbarButton {
110+ id: actionsButton
111+ text: i18n.tr("Add Feed")
112+ iconSource: Qt.resolvedUrl("../icons_tmp/add.svg")
113+ onTriggered: pageStack.push(appendFeedPage/*, {"isDirty" : true}*/) ;
114+ visible: true
115+ }
116+ }
117+
118+ ToolbarItems {
119+ id: editConfirm
120+ opened: true
121+ locked: true
122+ visible: false
123+// anchors.bottom: content.bottom
124+
125+ property int editIndex
126+
127+ back: Button {
128+ id: cancelButton
129+ text: i18n.tr("Cancel")
130+ gradient: UbuntuColors.greyGradient
131+ anchors.verticalCenter: parent.verticalCenter
132+ onClicked: {
133+ topicList.currentItem.cancelEdit()
134+ topicManagement.state = ""
135+ editConfirm.visible = false
136+ topicList.currentIndex = -1
137+ }
138+ }
139+
140+ Button {
141+ id: confirmButton
142+ text: i18n.tr("Confirm")
143+ anchors.verticalCenter: parent.verticalCenter
144+ onClicked: {
145+ topicList.currentItem.confirmEdit()
146+ topicManagement.state = ""
147+ editConfirm.visible = false
148+ topicList.currentIndex = -1
149+ }
150+ }
151+ }
152+
153 Flickable {
154 id: content
155 anchors.fill: parent
156@@ -103,6 +140,7 @@
157 anchors{ left: parent.left; right: parent.right }
158 height: contentItem.childrenRect.height
159 interactive: false
160+ currentIndex: -1
161 // clip: true
162
163 signal collapseAllItem()
164@@ -129,12 +167,29 @@
165 anchors{ left: parent.left; right: parent.right }
166 height: topicItem.height
167
168+ function cancelEdit() {
169+ topicItem.cancelEdit()
170+ }
171+
172+ function confirmEdit() {
173+ topicItem.confirmEdit()
174+ }
175+
176 TopicComponent{
177 id: topicItem
178 topicName: model.name
179 topicId: model.id
180 modelIndex: index
181 // isExpended: delegateRoot.isExpended
182+
183+ onEdit: {
184+ if (topicList.currentItem)
185+ topicList.currentItem.cancelEdit()
186+ editConfirm.editIndex = index
187+ topicManagement.state = "editMode"
188+ editConfirm.visible = true
189+ topicList.currentIndex = index
190+ }
191 }
192
193 DropArea {
194@@ -221,4 +276,21 @@
195 }
196 }
197
198+ states: [
199+ State {
200+ name: ""
201+ PropertyChanges {
202+ target: topicManagement
203+ tools: toolbar
204+ }
205+ },
206+ State {
207+ name: "editMode"
208+ PropertyChanges {
209+ target: topicManagement
210+ tools: editConfirm
211+ }
212+ }
213+ ]
214+
215 }
216
217=== modified file 'ubuntu-rssreader-app.qml'
218--- ubuntu-rssreader-app.qml 2013-09-11 11:56:41 +0000
219+++ ubuntu-rssreader-app.qml 2013-09-18 12:16:38 +0000
220@@ -87,6 +87,11 @@
221 pageStack.push(editFeed) ;
222 }
223
224+ // change the topic name if the name changed by management
225+ function changeTopicName(topicId, newName) {
226+ repeater.changeTopicName(topicId, newName)
227+ }
228+
229 PageStack {
230 id: pageStack
231
232@@ -216,6 +221,15 @@
233 function reloadSaved() {
234 repeater.itemAt(repeater.model - 1).reload()
235 }
236+
237+ function changeTopicName(topicId, newName) {
238+ for(var i = 0; i < repeater.count; i++) {
239+ if (repeater.itemAt(i).topicId == topicId) {
240+ repeater.itemAt(i).title = newName
241+ break
242+ }
243+ }
244+ }
245 } // Repeater
246 }
247

Subscribers

People subscribed via source and target branches