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
1=== modified file 'src/app/webbrowser/HistoryViewWide.qml'
2--- src/app/webbrowser/HistoryViewWide.qml 2016-03-01 09:59:31 +0000
3+++ src/app/webbrowser/HistoryViewWide.qml 2016-04-07 14:01:51 +0000
4@@ -109,7 +109,7 @@
5
6 spacing: units.gu(1)
7
8- Item {
9+ FocusScope {
10 width: units.gu(40)
11 height: parent.height
12
13@@ -118,54 +118,17 @@
14 objectName: "lastVisitDateListView"
15
16 anchors.fill: parent
17+ focus: true
18
19 currentIndex: 0
20- onCurrentIndexChanged: {
21- if (currentItem) {
22- historyLastVisitDateModel.lastVisitDate = currentItem.lastVisitDate
23- }
24- urlsListView.ViewItems.selectedIndices = []
25- }
26-
27- // Manually track the current date, so that we can detect when
28- // the ListView automatically changes the currentItem as result
29- // of a change in the model that removes the currentItem.
30- // When this happens, we reset the currentItem to "all dates".
31- property date currentDate
32-
33- // Ignore currentItemChanged signals while we are changing the
34- // currentIndex manually (as a result of either UP and DOWN key
35- // presses, or clicking on items)
36- // Any other emission of currentItemChanged will therefore be
37- // from ListView changing it automatically.
38- function explicitlyChangeCurrentIndex(changeAction) {
39- explicitlySettingCurrentIndex = true
40- changeAction()
41- explicitlySettingCurrentIndex = false
42- currentDate = currentItem.lastVisitDate
43- }
44- property bool explicitlySettingCurrentIndex: false
45- Keys.onDownPressed: explicitlyChangeCurrentIndex(incrementCurrentIndex)
46- Keys.onUpPressed: explicitlyChangeCurrentIndex(function() {
47- if (lastVisitDateListView.currentIndex == 0 && searchMode) {
48- searchQuery.focus = true
49- } else {
50- lastVisitDateListView.decrementCurrentIndex()
51- }
52- })
53-
54- onCurrentItemChanged: {
55- if (explicitlySettingCurrentIndex) return;
56- if (currentItem.lastVisitDate.valueOf() !== currentDate.valueOf()) {
57- currentIndex = 0
58- }
59- }
60+ onCurrentIndexChanged: urlsListView.ViewItems.selectedIndices = []
61
62 model: HistoryLastVisitDateListModel {
63 sourceModel: historyLastVisitDateModel.model
64 }
65
66 delegate: ListItem {
67+ id: lastVisitDateDelegate
68 objectName: "lastVisitDateDelegate"
69
70 property var lastVisitDate: model.lastVisitDate
71@@ -215,7 +178,7 @@
72 }
73
74 fontSize: "small"
75- color: (!lastVisitDateListView.activeFocus && (lastVisitDateListView.currentIndex == index)) ? UbuntuColors.orange : UbuntuColors.darkGrey
76+ color: (!lastVisitDateListView.activeFocus && lastVisitDateDelegate.ListView.isCurrentItem) ? UbuntuColors.orange : UbuntuColors.darkGrey
77 }
78
79 divider {
80@@ -227,10 +190,34 @@
81 Behavior on opacity { UbuntuNumberAnimation {} }
82 }
83
84- onClicked: ListView.view.explicitlyChangeCurrentIndex(function() { ListView.view.currentIndex = index })
85+ onClicked: ListView.view.currentIndex = index
86+
87+ ListView.onRemove: {
88+ if (ListView.isCurrentItem) {
89+ // For some reason, setting the current index here
90+ // results in it being reset to its previous value
91+ // right away. Delaying it with a timer so the
92+ // operation is queued does the trick.
93+ resetIndexTimer.restart()
94+ }
95+ }
96 }
97
98 highlight: ListViewHighlight {}
99+
100+ Timer {
101+ id: resetIndexTimer
102+ interval: 0
103+ onTriggered: lastVisitDateListView.currentIndex = 0
104+ }
105+ }
106+
107+ Keys.onUpPressed: {
108+ if (searchMode) {
109+ searchQuery.focus = true
110+ } else {
111+ event.accepted = false
112+ }
113 }
114
115 Scrollbar {
116@@ -254,7 +241,7 @@
117
118 model: SortFilterModel {
119 id: historyLastVisitDateModel
120- property date lastVisitDate
121+ readonly property date lastVisitDate: lastVisitDateListView.currentItem ? lastVisitDateListView.currentItem.lastVisitDate : ""
122 filter {
123 property: "lastVisitDateString"
124 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: