2024-03-17 23:06:06 +01:00
|
|
|
import QtQuick 2.4
|
|
|
|
import QtQuick.Layouts 1.2
|
|
|
|
import QtQml.Models 2.2
|
|
|
|
import QtQuick.Controls 2.4 as Controls
|
|
|
|
import org.kde.kirigami 2.5 as Kirigami
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: delegate
|
|
|
|
|
|
|
|
property ListView view
|
|
|
|
implicitHeight : listItem.implicitHeight
|
|
|
|
|
|
|
|
signal moveRequested(int oldIndex, int newIndex)
|
|
|
|
|
|
|
|
Kirigami.SwipeListItem {
|
|
|
|
id: listItem
|
2024-04-01 14:40:19 +02:00
|
|
|
alwaysVisibleActions: true // default is broken in mobile/tablet mode
|
2024-03-17 23:06:06 +01:00
|
|
|
contentItem: RowLayout {
|
|
|
|
Kirigami.ListItemDragHandle {
|
|
|
|
listItem: listItem
|
|
|
|
listView: view
|
|
|
|
enabled: !nativeInterface.hasEntryFilter
|
|
|
|
onMoveRequested:
|
|
|
|
(oldIndex, newIndex) => delegate.moveRequested(oldIndex, newIndex)
|
|
|
|
}
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
RowLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
Kirigami.Icon {
|
|
|
|
width: Kirigami.Units.iconSizes.smallMedium
|
|
|
|
height: Kirigami.Units.iconSizes.smallMedium
|
|
|
|
Layout.fillHeight: true
|
|
|
|
source: delegateModel.isNode(
|
2024-04-01 14:24:28 +02:00
|
|
|
index) ? "folder-symbolic" : "view-list-details-symbolic"
|
2024-03-17 23:06:06 +01:00
|
|
|
}
|
|
|
|
Controls.Label {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2024-04-01 15:32:47 +02:00
|
|
|
Layout.maximumWidth: availableWidth - listItem.overlayWidth
|
|
|
|
elide: Text.ElideRight
|
2024-03-17 23:06:06 +01:00
|
|
|
text: model.name
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
onClicked: (mouse) => {
|
|
|
|
if (mouse.button === Qt.RightButton) {
|
|
|
|
entryContextMenu.popup()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
delegateModel.handleEntryClicked(index, model.name)
|
|
|
|
}
|
|
|
|
onPressAndHold: entryContextMenu.popup()
|
|
|
|
}
|
|
|
|
Controls.Menu {
|
|
|
|
id: entryContextMenu
|
|
|
|
Controls.MenuItem {
|
|
|
|
icon.name: "edit-cut"
|
|
|
|
text: qsTr("Cut")
|
|
|
|
enabled: !nativeInterface.hasEntryFilter
|
|
|
|
onTriggered: {
|
|
|
|
nativeInterface.cutEntry(
|
|
|
|
entryModel.index(index, 0,
|
|
|
|
rootIndex))
|
|
|
|
showPassiveNotification(qsTr("Cut %1").arg(
|
|
|
|
model.name))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Controls.MenuItem {
|
|
|
|
icon.name: "edit-delete"
|
|
|
|
text: qsTr("Delete")
|
|
|
|
enabled: !nativeInterface.hasEntryFilter
|
|
|
|
onTriggered: confirmDeletionDialog.confirmDeletion(
|
|
|
|
model.name, index)
|
|
|
|
}
|
|
|
|
Controls.MenuItem {
|
|
|
|
icon.name: "edit-rename"
|
|
|
|
text: qsTr("Rename")
|
|
|
|
enabled: !nativeInterface.hasEntryFilter
|
|
|
|
onTriggered: renameDialog.renameEntry(model.name,
|
|
|
|
index)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
actions: [
|
|
|
|
Kirigami.Action {
|
|
|
|
icon.name: "edit-cut"
|
|
|
|
text: qsTr("Cut")
|
|
|
|
enabled: !nativeInterface.hasEntryFilter
|
|
|
|
onTriggered: {
|
|
|
|
nativeInterface.cutEntry(entryModel.index(index, 0,
|
|
|
|
rootIndex))
|
|
|
|
showPassiveNotification(text + " " + model.name)
|
|
|
|
}
|
|
|
|
shortcut: StandardKey.Cut
|
|
|
|
},
|
|
|
|
Kirigami.Action {
|
|
|
|
icon.name: "edit-delete"
|
|
|
|
text: qsTr("Delete")
|
|
|
|
enabled: !nativeInterface.hasEntryFilter
|
|
|
|
onTriggered: confirmDeletionDialog.confirmDeletion(
|
|
|
|
model.name, index)
|
|
|
|
shortcut: StandardKey.Delete
|
|
|
|
},
|
|
|
|
Kirigami.Action {
|
|
|
|
icon.name: "edit-rename"
|
|
|
|
text: qsTr("Rename")
|
|
|
|
enabled: !nativeInterface.hasEntryFilter
|
|
|
|
onTriggered: renameDialog.renameEntry(model.name, index)
|
|
|
|
shortcut: "F2"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|