This commit is contained in:
B.Melnik 2021-08-10 05:56:59 +03:00
parent 075a512758
commit 3846eeffe2
No known key found for this signature in database
GPG Key ID: 4A9B2E42E3BD4727
3 changed files with 18 additions and 9 deletions

View File

@ -47,7 +47,7 @@ Column {
profileImage = statusChatList.profileImageFn(model.chatId || model.id) || ""
}
}
originalOrder: DelegateModel.itemsIndex
originalOrder: model.position
chatId: model.chatId || model.id
name: !!statusChatList.chatNameFn ? statusChatList.chatNameFn(model) : model.name
type: model.chatType

View File

@ -65,7 +65,7 @@ Item {
popupMenu: statusChatListAndCategories.chatListPopupMenu
onReorder: function (cid, from, to) {
statusChatListAndCategories.reorderChat(categoryId, cid, from, from, to)
statusChatListAndCategories.reorderChat(categoryId, cid, from, to)
}
}

View File

@ -30,7 +30,7 @@ Rectangle {
signal clicked(var mouse)
signal unmute()
signal visualReorder(int from, int to)
signal visualReorder(int from, int to, int order)
signal reorder(int from, int to)
enum Type {
@ -73,13 +73,19 @@ Rectangle {
property real startY: 0
onMouseYChanged: {
if ((startY != mouseY )&& pressed) {
if ( (Math.abs(startY - mouseY) > 5 ) && pressed) {
held = true
}
}
onPressed: startY = mouseY
onPressAndHold: {
held = true
}
onReleased: {
reorder(statusChatListItem.DelegateModel.itemsIndex, statusChatListItem.DelegateModel.itemsIndex)
if (held) {
reorder(statusChatListItem.originalOrder, statusChatListItem.originalOrder)
}
held = false
}
@ -177,10 +183,10 @@ Rectangle {
anchors.rightMargin: 6
anchors.verticalCenter: parent.verticalCenter
text: statusChatListItem.type === StatusChatListItem.Type.PublicChat &&
text: originalOrder + (statusChatListItem.type === StatusChatListItem.Type.PublicChat &&
!statusChatListItem.name.startsWith("#") ?
"#" + statusChatListItem.name :
statusChatListItem.name
statusChatListItem.name)
elide: Text.ElideRight
color: {
if (statusChatListItem.muted && !sensor.containsMouse && !statusChatListItem.highlighted) {
@ -256,8 +262,10 @@ Rectangle {
interval: 100
repeat: false
onTriggered: {
if (dropArea.containsDrag)
visualReorder(dropArea.drag.source.DelegateModel.itemsIndex, statusChatListItem.DelegateModel.itemsIndex)
if (dropArea.containsDrag) {
dropArea.drag.source.originalOrder = statusChatListItem.originalOrder
visualReorder(dropArea.drag.source.DelegateModel.itemsIndex, statusChatListItem.DelegateModel.itemsIndex, statusChatListItem.originalOrder)
}
}
}
}
@ -309,6 +317,7 @@ Rectangle {
width: cover.width - iconLoader.item.width - 22
text: chatName.text
elide: Text.ElideRight
color: Theme.palette.directColor5
}
}
}