/usr/share/kde4/apps/plasma/plasmoids/org.kde.homerun-kicker/contents/ui/ItemListView.qml is in plasma-widget-homerun-kicker 1.2.1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | /*
* Copyright (C) 2013 by Eike Hein <hein@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 1.1
import org.kde.plasma.components 0.1 as PlasmaComponents
import org.kde.plasma.extras 0.1 as PlasmaExtras
import org.kde.qtextracomponents 0.1 as QtExtra
FocusScope {
id: itemList
width: theme.defaultFont.mSize.width * 18
height: itemDialog.parent.childItemListHeight
property Item dialog: null
property QtObject childDialog: null
property int childItemListHeight
property bool containsMouse: mouseEventListener.containsMouse || (childDialog != null && childDialog.mainItem.containsMouse)
property alias model: listView.model
property alias currentIndex: listView.currentIndex
property alias currentItem: listView.currentItem
property int itemHeight: Math.max(theme.defaultFont.mSize.height, theme.smallIconSize) + listItemSvg.margins.top + listItemSvg.margins.bottom
onFocusChanged: {
if (focus) {
main.focusChanged();
}
}
onContainsMouseChanged: {
if (!containsMouse) {
resetIndexTimer.start();
} else {
resetIndexTimer.stop();
}
}
Timer {
id: dialogSpawnTimer
interval: 70
repeat: false
onTriggered: {
if (!plasmoid.popupShowing) {
return;
}
childDialog = itemListDialogComponent.createObject(itemList);
childDialog.setAttribute(Qt.WA_X11NetWmWindowTypeMenu, true)
childDialog.visible = true;
}
}
Timer {
id: resetIndexTimer
interval: (dialog != null) ? 50 : 150
repeat: false
onTriggered: {
if (focus) {
currentIndex = -1;
}
}
}
QtExtra.MouseEventListener {
id: mouseEventListener
anchors.fill: parent
hoverEnabled: true
onContainsMouseChanged: {
listView.eligibleWidth = listView.width;
}
PlasmaExtras.ScrollArea {
anchors.fill: parent
ListView {
id: listView
property int eligibleWidth: width
// HACK: Hack to work around bug in ScrollArea that causes the overflow
// deco to be visible when it shouldn't be.
contentHeight: itemList.height - 1
focus: true
snapMode: ListView.SnapToItem
spacing: 0
keyNavigationWraps: (dialog != null || itemList != sourcesList)
model: itemList.model
delegate: ItemListDelegate {}
highlight: PlasmaComponents.Highlight { anchors.fill: listView.currentItem }
onCountChanged: {
currentIndex = -1;
// HACK: https://bugreports.qt-project.org/browse/QTBUG-20927
// If you read this: This made me want to cry.
for (var i = 0; i < contentItem.children.length; ++i)
{
contentItem.children[i].y = i * itemHeight;
}
}
onCurrentIndexChanged: {
if (currentIndex != -1) {
itemList.focus = true;
if (currentItem != null && !currentItem.hasChildren || !plasmoid.popupShowing) {
return;
}
if (childDialog) {
childDialog.visible = false;
childDialog.delayedDestroy();
}
if (model != undefined && "modelForRow" in model) {
var maxHeight = (Math.floor(windowSystem.workArea().height / itemHeight) - 1) * itemHeight;
childItemListHeight = Math.min(model.modelForRow(currentIndex).count * itemHeight, maxHeight);
}
dialogSpawnTimer.restart();
} else if (childDialog != null) {
dialogSpawnTimer.stop();
childDialog.visible = false;
childDialog.delayedDestroy();
childDialog = null;
}
}
Keys.onPressed: {
if (event.key == Qt.Key_Right && childDialog != null) {
childDialog.mainItem.focus = true;
childDialog.mainItem.currentIndex = 0;
} else if (event.key == Qt.Key_Left && dialog != null) {
dialog.parent.focus = true;
dialog.destroy();
} else if (event.key != Qt.Key_Escape && event.text != "") {
searchField.appendText(event.text);
}
}
function focusChanged() {
if (!itemList.focus && listView.currentIndex != -1 && childDialog == null) {
listView.currentIndex = -1;
}
}
Component.onCompleted: {
main.focusChanged.connect(focusChanged);
}
Component.onDestruction: {
main.focusChanged.disconnect(focusChanged);
}
}
}
}
}
|