~osomon/webbrowser-app/fix-main-page-dimensions

« back to all changes in this revision

Viewing changes to src/app/webbrowser/TimelineView.qml

  • Committer: CI bot
  • Author(s): Olivier Tilloy
  • Date: 2014-05-22 16:29:42 UTC
  • mfrom: (541.1.8 optimize-activity-view)
  • Revision ID: ps-jenkins@lists.canonical.com-20140522162942-yforzm2pmlap375u
Various optimizations to the activity view. Fixes: 1260980

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
        anchors.fill: parent
46
46
        verticalLayoutDirection: ListView.BottomToTop
47
47
        clip: true
 
48
        interactive: loaded
 
49
        boundsBehavior: Flickable.StopAtBounds
48
50
 
49
 
        model: ListModel {
50
 
            ListElement { timeframe: "today" }
51
 
            ListElement { timeframe: "yesterday" }
52
 
            ListElement { timeframe: "last7days" }
53
 
            ListElement { timeframe: "thismonth" }
54
 
            ListElement { timeframe: "thisyear" }
55
 
            ListElement { timeframe: "older" }
56
 
        }
 
51
        model: ListModel {}
57
52
        currentIndex: -1
58
53
 
 
54
        readonly property var timeframes: ["today", "yesterday", "last7days", "thismonth", "thisyear", "older"]
 
55
        readonly property bool loaded: model.count == timeframes.length
 
56
        Timer {
 
57
            interval: 1
 
58
            repeat: true
 
59
            running: !timeline.loaded
 
60
            onTriggered: timeline.model.append({ timeframe: timeline.timeframes[timeline.model.count] })
 
61
        }
 
62
 
59
63
        header: TabsList {
60
64
            width: parent.width
61
65
            height: units.gu(24)
107
111
                    right: parent.right
108
112
                }
109
113
                height: 0
110
 
                clip: true
 
114
                opacity: 0.0
 
115
                visible: opacity > 0
111
116
 
112
117
                Rectangle {
113
118
                    anchors.fill: parent
163
168
 
164
169
                    spacing: units.gu(2)
165
170
                    orientation: ListView.Horizontal
 
171
                    boundsBehavior: Flickable.StopAtBounds
166
172
 
167
173
                    model: entriesView.model
168
174
 
189
195
                    PropertyChanges {
190
196
                        target: entriesView
191
197
                        height: units.gu(19)
192
 
                        clip: false
 
198
                        opacity: 1.0
193
199
                    }
194
200
                }
195
201
 
196
202
                transitions: Transition {
197
203
                    SequentialAnimation {
198
 
                        UbuntuNumberAnimation { property: "height" }
 
204
                        UbuntuNumberAnimation { properties: "height,opacity" }
199
205
                        ScriptAction {
200
206
                            // XXX: This action is instantaneous, the view jumps to the index
201
207
                            // without animating contentY. Unfortunately, manipulating contentY
219
225
 
220
226
                spacing: units.gu(2)
221
227
                orientation: ListView.Horizontal
 
228
                boundsBehavior: Flickable.StopAtBounds
222
229
 
223
230
                model: HistoryDomainListChronologicalModel {
224
231
                    sourceModel: HistoryDomainListModel {
225
232
                        sourceModel: HistoryTimeframeModel {
226
 
                            sourceModel: historyModel
227
 
                            start: {
 
233
                            function setStart() {
228
234
                                var date = new Date()
229
235
                                if (model.timeframe == "yesterday") {
230
236
                                    date.setDate(date.getDate() - 1)
242
248
                                date.setMinutes(0)
243
249
                                date.setSeconds(0)
244
250
                                date.setMilliseconds(0)
245
 
                                return date
 
251
                                start = date
246
252
                            }
247
 
                            end: {
 
253
                            function setEnd() {
248
254
                                var date = new Date()
249
255
                                if (model.timeframe == "yesterday") {
250
256
                                    date.setDate(date.getDate() - 1)
262
268
                                date.setMinutes(59)
263
269
                                date.setSeconds(59)
264
270
                                date.setMilliseconds(999)
265
 
                                return date
 
271
                                end = date
 
272
                            }
 
273
                            Component.onCompleted: {
 
274
                                setStart()
 
275
                                setEnd()
 
276
                                sourceModel = historyModel
266
277
                            }
267
278
                        }
268
279
                    }
300
311
                }
301
312
            }
302
313
        }
 
314
 
 
315
        ActivityIndicator {
 
316
            anchors.horizontalCenter: parent.horizontalCenter
 
317
            y: timeline.height - timeline.contentHeight - units.gu(8)
 
318
            visible: y > 0
 
319
            running: !timeline.loaded
 
320
        }
303
321
    }
304
322
 
305
323
    onVisibleChanged: {