~ubuntu-branches/ubuntu/trusty/unity-2d/trusty

« back to all changes in this revision

Viewing changes to shell/dash/ListViewWithHeaders.qml

  • Committer: Package Import Robot
  • Author(s): Łukasz 'sil2100' Zemczak
  • Date: 2012-06-13 17:36:33 UTC
  • mfrom: (50.1.1 precise-proposed)
  • Revision ID: package-import@ubuntu.com-20120613173633-mjx0fepo2gb5h7pa
Tags: 5.12.0-0ubuntu1.1
* Fix issue with unity-2d sending the wrong event timestamp when closing an
  application window; This bug was exposed by a recent Firefox update which
  changed the way Firefox handled windows based on timestamps. (LP: #1010466)
  - panel/applets/appname/windowhelper.cpp

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
 
44
44
    property bool giveFocus: false
45
45
 
 
46
    function focusFirstHeader() {
 
47
        focusPath.reset()
 
48
        focusPath.currentItem.header.forceActiveFocus()
 
49
    }
 
50
 
 
51
    function focusLastHeader() {
 
52
        focusPath.focusLastRow()
 
53
        focusPath.currentItem.header.forceActiveFocus()
 
54
    }
 
55
 
 
56
    function focusNextHeader() {
 
57
        var moved = focusPath.moveToNext()
 
58
        if (moved) {
 
59
            focusPath.currentItem.header.forceActiveFocus()
 
60
        }
 
61
        return moved
 
62
    }
 
63
 
 
64
    function focusPreviousHeader() {
 
65
        if (!focusPath.currentItem.header.activeFocus) {
 
66
            focusPath.currentItem.header.forceActiveFocus()
 
67
            return true
 
68
        } else {
 
69
            var moved = focusPath.moveToPrevious()
 
70
            if (moved) {
 
71
                focusPath.currentItem.header.forceActiveFocus()
 
72
            }
 
73
            return moved
 
74
        }
 
75
    }
 
76
 
 
77
    function isListEmpty() {
 
78
        var empty = true
 
79
        for (var i = 0; empty && i < categories.count; i++) {
 
80
            var category = categories.itemAt(i);
 
81
            empty = !category.body.visible && !category.header.visible
 
82
        }
 
83
        return empty
 
84
    }
 
85
 
46
86
    FocusPath {
47
87
        id: focusPath
48
88
        item: categoriesColumn
75
115
            var newContentY = -1;
76
116
 
77
117
            if (scroll.contentY > itemTop) {
78
 
                newContentY = itemTop
 
118
                newContentY = Math.max(0, itemTop)
79
119
            } else if ((scroll.contentY + scroll.height) < itemBottom) {
80
120
                newContentY = itemBottom - scroll.height;
81
121
            }
101
141
                    FocusPath.index: index
102
142
                    FocusPath.skip: !headerLoader.item.visible && !bodyLoader.item.visible
103
143
 
 
144
                    property alias bodyLoader: bodyLoader
 
145
                    property alias body: bodyLoader.item
 
146
                    property alias header: headerLoader.item
104
147
 
105
148
                    Column {
106
149
 
125
168
 
126
169
                            onActiveFocusChanged: {
127
170
                                if (visible && item && item.activeFocus) {
 
171
                                    var categoryOnTopIndex = focusPath.previousIndex()
 
172
                                    if (categoryOnTopIndex != -1) {
 
173
                                        categories.itemAt(categoryOnTopIndex).body.item.focusLastRow()
 
174
                                        categories.itemAt(categoryOnTopIndex).bodyLoader.focus = true
 
175
                                    }
 
176
 
 
177
                                    focusPath.currentItem.body.item.focusFirstElement()
128
178
                                    scroll.moveToPosition(item)
129
179
                                }
130
180
                            }