Merge lp:~osomon/webbrowser-app/simplify-historyviewwide into lp:webbrowser-app

Proposed by Olivier Tilloy
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 1399
Merged at revision: 1412
Proposed branch: lp:~osomon/webbrowser-app/simplify-historyviewwide
Merge into: lp:webbrowser-app
Diff against target: 124 lines (+31/-44)
1 file modified
src/app/webbrowser/HistoryViewWide.qml (+31/-44)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/simplify-historyviewwide
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
system-apps-ci-bot continuous-integration Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+291258@code.launchpad.net

Commit message

Simplify the implementation of HistoryViewWide quite a bit,
and as a side effect fix a unit test failure when run against the staging branch of the UITK.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/app/webbrowser/HistoryViewWide.qml'
--- src/app/webbrowser/HistoryViewWide.qml 2016-03-01 09:59:31 +0000
+++ src/app/webbrowser/HistoryViewWide.qml 2016-04-07 14:01:51 +0000
@@ -109,7 +109,7 @@
109109
110 spacing: units.gu(1)110 spacing: units.gu(1)
111111
112 Item {112 FocusScope {
113 width: units.gu(40)113 width: units.gu(40)
114 height: parent.height114 height: parent.height
115115
@@ -118,54 +118,17 @@
118 objectName: "lastVisitDateListView"118 objectName: "lastVisitDateListView"
119119
120 anchors.fill: parent120 anchors.fill: parent
121 focus: true
121122
122 currentIndex: 0123 currentIndex: 0
123 onCurrentIndexChanged: {124 onCurrentIndexChanged: urlsListView.ViewItems.selectedIndices = []
124 if (currentItem) {
125 historyLastVisitDateModel.lastVisitDate = currentItem.lastVisitDate
126 }
127 urlsListView.ViewItems.selectedIndices = []
128 }
129
130 // Manually track the current date, so that we can detect when
131 // the ListView automatically changes the currentItem as result
132 // of a change in the model that removes the currentItem.
133 // When this happens, we reset the currentItem to "all dates".
134 property date currentDate
135
136 // Ignore currentItemChanged signals while we are changing the
137 // currentIndex manually (as a result of either UP and DOWN key
138 // presses, or clicking on items)
139 // Any other emission of currentItemChanged will therefore be
140 // from ListView changing it automatically.
141 function explicitlyChangeCurrentIndex(changeAction) {
142 explicitlySettingCurrentIndex = true
143 changeAction()
144 explicitlySettingCurrentIndex = false
145 currentDate = currentItem.lastVisitDate
146 }
147 property bool explicitlySettingCurrentIndex: false
148 Keys.onDownPressed: explicitlyChangeCurrentIndex(incrementCurrentIndex)
149 Keys.onUpPressed: explicitlyChangeCurrentIndex(function() {
150 if (lastVisitDateListView.currentIndex == 0 && searchMode) {
151 searchQuery.focus = true
152 } else {
153 lastVisitDateListView.decrementCurrentIndex()
154 }
155 })
156
157 onCurrentItemChanged: {
158 if (explicitlySettingCurrentIndex) return;
159 if (currentItem.lastVisitDate.valueOf() !== currentDate.valueOf()) {
160 currentIndex = 0
161 }
162 }
163125
164 model: HistoryLastVisitDateListModel {126 model: HistoryLastVisitDateListModel {
165 sourceModel: historyLastVisitDateModel.model127 sourceModel: historyLastVisitDateModel.model
166 }128 }
167129
168 delegate: ListItem {130 delegate: ListItem {
131 id: lastVisitDateDelegate
169 objectName: "lastVisitDateDelegate"132 objectName: "lastVisitDateDelegate"
170133
171 property var lastVisitDate: model.lastVisitDate134 property var lastVisitDate: model.lastVisitDate
@@ -215,7 +178,7 @@
215 }178 }
216179
217 fontSize: "small"180 fontSize: "small"
218 color: (!lastVisitDateListView.activeFocus && (lastVisitDateListView.currentIndex == index)) ? UbuntuColors.orange : UbuntuColors.darkGrey181 color: (!lastVisitDateListView.activeFocus && lastVisitDateDelegate.ListView.isCurrentItem) ? UbuntuColors.orange : UbuntuColors.darkGrey
219 }182 }
220183
221 divider {184 divider {
@@ -227,10 +190,34 @@
227 Behavior on opacity { UbuntuNumberAnimation {} }190 Behavior on opacity { UbuntuNumberAnimation {} }
228 }191 }
229192
230 onClicked: ListView.view.explicitlyChangeCurrentIndex(function() { ListView.view.currentIndex = index })193 onClicked: ListView.view.currentIndex = index
194
195 ListView.onRemove: {
196 if (ListView.isCurrentItem) {
197 // For some reason, setting the current index here
198 // results in it being reset to its previous value
199 // right away. Delaying it with a timer so the
200 // operation is queued does the trick.
201 resetIndexTimer.restart()
202 }
203 }
231 }204 }
232205
233 highlight: ListViewHighlight {}206 highlight: ListViewHighlight {}
207
208 Timer {
209 id: resetIndexTimer
210 interval: 0
211 onTriggered: lastVisitDateListView.currentIndex = 0
212 }
213 }
214
215 Keys.onUpPressed: {
216 if (searchMode) {
217 searchQuery.focus = true
218 } else {
219 event.accepted = false
220 }
234 }221 }
235222
236 Scrollbar {223 Scrollbar {
@@ -254,7 +241,7 @@
254241
255 model: SortFilterModel {242 model: SortFilterModel {
256 id: historyLastVisitDateModel243 id: historyLastVisitDateModel
257 property date lastVisitDate244 readonly property date lastVisitDate: lastVisitDateListView.currentItem ? lastVisitDateListView.currentItem.lastVisitDate : ""
258 filter {245 filter {
259 property: "lastVisitDateString"246 property: "lastVisitDateString"
260 pattern: new RegExp(lastVisitDate.isValid() ? "^%1$".arg(Qt.formatDate(lastVisitDate, "yyyy-MM-dd")) : "")247 pattern: new RegExp(lastVisitDate.isValid() ? "^%1$".arg(Qt.formatDate(lastVisitDate, "yyyy-MM-dd")) : "")

Subscribers

People subscribed via source and target branches

to status/vote changes: