| 1 |
/* |
| 2 |
* Copyright (C) 2013 Canonical Ltd |
| 3 |
* |
| 4 |
* This program is free software: you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License version 3 as |
| 6 |
* published by the Free Software Foundation. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
* |
| 16 |
* Authored by: Arto Jalkanen <[email protected]> |
| 17 |
*/ |
| 18 |
import QtQuick 2.4 |
| 19 |
import Lomiri.Components 1.3 |
| 20 |
import Lomiri.FileManager.folderlistmodel 1.0 |
| 21 |
|
| 22 |
ListItem { |
| 23 |
id: del |
| 24 |
height: layout.height |
| 25 |
|
| 26 |
function getTextSize (subtitle) { |
| 27 |
switch (globalSettings.listSize) { |
| 28 |
case 0: return Label.Small - (subtitle ? 1 : 0) |
| 29 |
case 1: return Label.Medium - (subtitle ? 1 : 0) |
| 30 |
case 2: return Label.Large - (subtitle ? 1 : 0) |
| 31 |
case 3: return Label.XLarge - (subtitle ? 1 : 0) |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
property string title |
| 36 |
property string subtitle |
| 37 |
property string summary |
| 38 |
property string iconName |
| 39 |
property string path |
| 40 |
property bool showProgressionSlot |
| 41 |
property bool isSelected |
| 42 |
|
| 43 |
// Because Flickable is used over ListView?? |
| 44 |
// we cannot set the highlight component so |
| 45 |
// instead fudge it here with a rectangle. |
| 46 |
Rectangle { |
| 47 |
anchors.fill: parent |
| 48 |
color: theme.palette.selected.base |
| 49 |
visible: del.isSelected |
| 50 |
} |
| 51 |
|
| 52 |
ListItemLayout { |
| 53 |
id: layout |
| 54 |
title.text: del.title |
| 55 |
subtitle.text: del.subtitle |
| 56 |
summary.text: del.summary |
| 57 |
|
| 58 |
title.textSize: getTextSize() |
| 59 |
subtitle.textSize: getTextSize(true) |
| 60 |
summary.textSize: getTextSize(true) |
| 61 |
|
| 62 |
Item { |
| 63 |
SlotsLayout.position: SlotsLayout.Leading |
| 64 |
height: units.gu(5) * (layout.title.font.pixelSize / FontUtils.sizeToPixels("medium")) |
| 65 |
width: height |
| 66 |
|
| 67 |
Icon { |
| 68 |
anchors.fill: parent |
| 69 |
visible: !image.visible |
| 70 |
name: del.iconName |
| 71 |
} |
| 72 |
|
| 73 |
Image { |
| 74 |
id: image |
| 75 |
anchors.fill: parent |
| 76 |
sourceSize: Qt.size(image.width, image.height) |
| 77 |
visible: status == Image.Ready |
| 78 |
|
| 79 |
source: model.mimeType.indexOf("image/") > -1 ? "image://thumbnailer/file://" + delegate.path : "" |
| 80 |
fillMode: Image.PreserveAspectFit |
| 81 |
asynchronous: true |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
ProgressionSlot{ |
| 86 |
visible: del.showProgressionSlot |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
// WORKAROUND: Postpone removal of delegates until all the child UITK Popups are closed. |
| 91 |
// TODO: Provide a less "hackish" fix |
| 92 |
ListView.onRemove: SequentialAnimation { |
| 93 |
PropertyAction { target: del; property: "ListView.delayRemove"; value: true } |
| 94 |
NumberAnimation { target: del; property: "scale"; to: 0; duration: 250; easing.type: Easing.InOutQuad } |
| 95 |
PropertyAction { target: del; property: "ListView.delayRemove"; value: false } |
| 96 |
} |
| 97 |
} |