| 1 |
/* |
| 2 |
* Copyright (C) 2013 Canonical, Ltd. |
| 3 |
* |
| 4 |
* Authors: |
| 5 |
* Renato Araujo Oliveira Filho <[email protected]> |
| 6 |
* |
| 7 |
* This program is free software; you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU General Public License as published by |
| 9 |
* the Free Software Foundation; version 3. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
*/ |
| 19 |
|
| 20 |
import QtQuick 2.4 |
| 21 |
import Lomiri.Components 1.3 |
| 22 |
|
| 23 |
ListView { |
| 24 |
id: _sceneList |
| 25 |
|
| 26 |
signal sceneSelected(int start, int duration) |
| 27 |
|
| 28 |
orientation: ListView.Horizontal |
| 29 |
|
| 30 |
delegate: SceneFrame { |
| 31 |
objectName: "SceneSelector.Scene" + index |
| 32 |
active: (currentIndex == index) |
| 33 |
start: model.start |
| 34 |
duration: model.duration |
| 35 |
source: model.thumbnail |
| 36 |
|
| 37 |
width: active ? units.gu(27) : units.gu(20) |
| 38 |
anchors { |
| 39 |
top: parent.top |
| 40 |
topMargin: units.gu(2) |
| 41 |
bottom: parent.bottom |
| 42 |
} |
| 43 |
|
| 44 |
onClicked: { |
| 45 |
currentIndex = index |
| 46 |
sceneSelected(start, duration) |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
function selectSceneAt(time) { |
| 51 |
if (time <= 0) { |
| 52 |
currentIndex = -1; |
| 53 |
} |
| 54 |
|
| 55 |
if (currentItem) { |
| 56 |
if ((time >= currentItem.start) && |
| 57 |
(time <= (currentItem.start + currentItem.duration))) { |
| 58 |
return |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
for(var index = 0; index < _sceneList.model.count; index++) { |
| 63 |
var item = _sceneList.model.get(index) |
| 64 |
if (item) { |
| 65 |
if ((time >= item.start) && |
| 66 |
(time <= (item.start + item.duration))) { |
| 67 |
currentIndex = index |
| 68 |
return; |
| 69 |
} |
| 70 |
} |
| 71 |
} |
| 72 |
currentIndex = -1 |
| 73 |
} |
| 74 |
} |