| 1 |
/* |
| 2 |
* Copyright (C) 2015, 2017 |
| 3 |
* Andrew Hayzen <[email protected]> |
| 4 |
* Victor Thompson <[email protected]> |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License as published by |
| 8 |
* the Free Software Foundation; version 3. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
import QtQuick 2.12 |
| 20 |
import Lomiri.Components 1.3 |
| 21 |
|
| 22 |
State { |
| 23 |
id: selectionState |
| 24 |
name: "selection" |
| 25 |
|
| 26 |
property PageHeader thisHeader: PageHeader { |
| 27 |
id: multiselectheader |
| 28 |
|
| 29 |
flickable: thisPage.flickable |
| 30 |
visible: thisPage.state === "selection" |
| 31 |
title: i18n.tr("Locations") |
| 32 |
|
| 33 |
leadingActionBar { |
| 34 |
actions: [ |
| 35 |
Action { |
| 36 |
text: i18n.tr("exit reorder mode") |
| 37 |
iconName: "back" |
| 38 |
onTriggered: listview.closeSelection() |
| 39 |
} |
| 40 |
] |
| 41 |
} |
| 42 |
|
| 43 |
trailingActionBar { |
| 44 |
actions: [ |
| 45 |
Action { |
| 46 |
iconName: listview.getSelectedIndices().length === listview.model.count ? "select-none" : "select" |
| 47 |
text: listview.getSelectedIndices().length === listview.model.count ? i18n.ctr("location list page, unselect all button description","Unselect All") : i18n.ctr("location list page, select all button description","Select All") |
| 48 |
onTriggered: { |
| 49 |
if (listview.getSelectedIndices().length === listview.model.count) { |
| 50 |
listview.clearSelection() |
| 51 |
} else { |
| 52 |
listview.selectAll() |
| 53 |
} |
| 54 |
} |
| 55 |
}, |
| 56 |
Action { |
| 57 |
enabled: listview.getSelectedIndices().length > 0 |
| 58 |
iconName: "delete" |
| 59 |
text: i18n.tr("Delete") |
| 60 |
visible: removable |
| 61 |
|
| 62 |
onTriggered: { |
| 63 |
removed(listview.getSelectedIndices()) |
| 64 |
|
| 65 |
listview.closeSelection() |
| 66 |
} |
| 67 |
} |
| 68 |
] |
| 69 |
} |
| 70 |
|
| 71 |
//creates option to swipe in header to close a page by using a MouseArea |
| 72 |
// MouseArea { |
| 73 |
// id: swipeToActionArea |
| 74 |
// anchors.fill: parent |
| 75 |
// //allows click events for items underneath the mouse area |
| 76 |
// propagateComposedEvents: true |
| 77 |
// //configure drag behavior for header |
| 78 |
// drag.target: parent |
| 79 |
// drag.axis: Drag.YAxis |
| 80 |
// drag.minimumY: 0 |
| 81 |
// drag.threshold: locationsheader.height/3 |
| 82 |
// drag.maximumY: locationsheader.height*3 |
| 83 |
// onReleased: { |
| 84 |
// bottomEdge.collapse(); |
| 85 |
// delayTimer.start(); |
| 86 |
// } |
| 87 |
// Timer { |
| 88 |
// id: delayTimer |
| 89 |
// //interval needs to be a minimum of 200, otherwise collapse is not entirely finished |
| 90 |
// //this will result in the page flickering when y is set back to zero |
| 91 |
// interval: 200; running: false; repeat: false; |
| 92 |
// onTriggered: { |
| 93 |
// multiselectheader.y = 0 //reset to zero position |
| 94 |
// } |
| 95 |
// } |
| 96 |
// } |
| 97 |
} |
| 98 |
|
| 99 |
property ListView listview |
| 100 |
property bool removable: false |
| 101 |
property Page thisPage |
| 102 |
|
| 103 |
signal removed(var selectedIndices) |
| 104 |
|
| 105 |
PropertyChanges { |
| 106 |
target: thisPage |
| 107 |
header: thisHeader |
| 108 |
} |
| 109 |
} |