| 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 |
* Eric Gregory <[email protected]> |
| 18 |
*/ |
| 19 |
|
| 20 |
import QtQuick 2.9 |
| 21 |
import Lomiri.Components 1.3 |
| 22 |
import Lomiri.Components.Popups 1.3 |
| 23 |
import Lomiri.Components.ListItems 1.3 as ListItem |
| 24 |
import Gallery 1.0 |
| 25 |
|
| 26 |
/*! |
| 27 |
Popover dialog to delete an album. |
| 28 |
Don't forget to set the album property |
| 29 |
*/ |
| 30 |
Popover { |
| 31 |
/// The album that is to be deleted |
| 32 |
property variant album: null |
| 33 |
|
| 34 |
/// The delete album button was clicked |
| 35 |
signal deleteClicked() |
| 36 |
/// The delete album + contntents was clicked |
| 37 |
signal deleteWithContentsClicked() |
| 38 |
|
| 39 |
/// Used internally to delete the album |
| 40 |
property AlbumCollectionModel __albumCollection: AlbumCollectionModel {} |
| 41 |
/// Used internally to delete the content of the album |
| 42 |
property MediaCollectionModel __mediaCollection: MediaCollectionModel {} |
| 43 |
|
| 44 |
Column { |
| 45 |
anchors { |
| 46 |
left: parent.left |
| 47 |
top: parent.top |
| 48 |
right: parent.right |
| 49 |
} |
| 50 |
ListItem.Standard { |
| 51 |
text: i18n.tr("Delete album") |
| 52 |
selected: false |
| 53 |
onClicked: { |
| 54 |
deleteClicked() |
| 55 |
hide() |
| 56 |
__albumCollection.destroyAlbum(album) |
| 57 |
} |
| 58 |
} |
| 59 |
ListItem.Standard { |
| 60 |
text: i18n.tr("Delete album AND contents") |
| 61 |
selected: false |
| 62 |
onClicked: { |
| 63 |
deleteWithContentsClicked() |
| 64 |
hide() |
| 65 |
|
| 66 |
// Remove contents. |
| 67 |
var list = album.allMediaSources; |
| 68 |
for (var i = list.length-1; i >= 0; i--) |
| 69 |
__mediaCollection.destroyMedia(list[i], true); |
| 70 |
|
| 71 |
// Remove album. |
| 72 |
__albumCollection.destroyAlbum(album); |
| 73 |
} |
| 74 |
} |
| 75 |
} |
| 76 |
} |