| 1 |
/* |
| 2 |
* Copyright (C) 2012-2015 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 |
* Authors: |
| 17 |
* Charles Lindsay <[email protected]> |
| 18 |
*/ |
| 19 |
|
| 20 |
import QtQuick 2.9 |
| 21 |
import Lomiri.Components 1.3 |
| 22 |
import "../Utility" |
| 23 |
import "../../js/Gallery.js" as Gallery |
| 24 |
|
| 25 |
// A ListView meant to hold OrganicMediaLists in some form or another. |
| 26 |
Page { |
| 27 |
id: organicView |
| 28 |
|
| 29 |
/*! |
| 30 |
*/ |
| 31 |
signal mediaSourcePressed(var mediaSource, var thumbnailRect) |
| 32 |
signal positionEventsAtBeginning() |
| 33 |
|
| 34 |
/*! |
| 35 |
*/ |
| 36 |
property alias model: organicList.model |
| 37 |
/*! |
| 38 |
*/ |
| 39 |
property alias delegate: organicList.delegate |
| 40 |
/*! |
| 41 |
*/ |
| 42 |
property SelectionState selection |
| 43 |
|
| 44 |
// readonly |
| 45 |
// Some duplication from OrganicMediaList, to make certain things easier. |
| 46 |
property int organicMediaListMediaPerPattern: 6 // OrganicMediaList.mediaPerPattern |
| 47 |
/*! |
| 48 |
*/ |
| 49 |
property real organicMediaListPatternWidth: units.gu(49) // OrganicMediaList.patternWidth |
| 50 |
/*! |
| 51 |
*/ |
| 52 |
property real organicMediaListMargin: units.gu(1) |
| 53 |
|
| 54 |
// This property exists only for the benefit of AP tests that |
| 55 |
// can't access C++ objects |
| 56 |
property int _eventCount: model.count |
| 57 |
|
| 58 |
function positionViewAtBeginning() { |
| 59 |
organicList.positionViewAtBeginning(); |
| 60 |
//FIXME Initial content is hide bellow Page Header after a positionViewAtBeginning() |
| 61 |
organicList.contentY = units.gu(7) * -1; |
| 62 |
positionEventsAtBeginning() |
| 63 |
} |
| 64 |
|
| 65 |
ScrollView { |
| 66 |
id: scrollWrapper |
| 67 |
anchors.top: parent.top |
| 68 |
anchors.topMargin: units.gu(6) //header height |
| 69 |
anchors.bottom: parent.bottom |
| 70 |
width: parent.width |
| 71 |
contentItem: organicList |
| 72 |
} |
| 73 |
|
| 74 |
ListView { |
| 75 |
id: organicList |
| 76 |
|
| 77 |
anchors.fill: parent |
| 78 |
anchors.rightMargin: units.gu(2) |
| 79 |
clip: true |
| 80 |
maximumFlickVelocity: units.gu(350) |
| 81 |
flickDeceleration: maximumFlickVelocity * 0.8 |
| 82 |
cacheBuffer: 0 |
| 83 |
onFlickStarted: cacheBuffer = height * 3; |
| 84 |
|
| 85 |
// The OrganicMediaList only has a half margin at the top and bottom, since |
| 86 |
// when repeated that means a full margin between rows. This pads it out |
| 87 |
// so we also get a full row on top and bottom of the whole bunch. |
| 88 |
header: Item { |
| 89 |
width: parent.width |
| 90 |
height: organicMediaListMargin |
| 91 |
} |
| 92 |
footer: Item { |
| 93 |
width: parent.width |
| 94 |
height: organicMediaListMargin |
| 95 |
} |
| 96 |
|
| 97 |
displaced: Transition { |
| 98 |
NumberAnimation { |
| 99 |
properties: "x,y" |
| 100 |
duration: Gallery.FAST_DURATION |
| 101 |
easing.type: Easing.InQuint |
| 102 |
} |
| 103 |
} |
| 104 |
// TODO: specify add and remove transitions here too. When I tried |
| 105 |
// initially, QML ignored it. |
| 106 |
} |
| 107 |
} |