mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
Merge pull request #353 from YACReader/fix_drag_n_drop_grid_view
Fix drag&drop in the comics grid view
This commit is contained in:
commit
24f855b21d
@ -18,7 +18,7 @@ SplitView {
|
||||
color: info_container.color
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
Rectangle {
|
||||
id: main
|
||||
clip: true
|
||||
|
||||
@ -413,46 +413,6 @@ Rectangle {
|
||||
grid.contentX = grid.originX
|
||||
}
|
||||
|
||||
DropArea {
|
||||
anchors.fill: parent
|
||||
|
||||
onEntered: {
|
||||
if(drag.hasUrls)
|
||||
{
|
||||
if(dropManager.canDropUrls(drag.urls, drag.action))
|
||||
{
|
||||
drag.accepted = true;
|
||||
}else
|
||||
drag.accepted = false;
|
||||
}
|
||||
else if (dropManager.canDropFormats(drag.formats)) {
|
||||
drag.accepted = true;
|
||||
} else
|
||||
drag.accepted = false;
|
||||
}
|
||||
|
||||
onDropped: {
|
||||
if(drop.hasUrls && dropManager.canDropUrls(drop.urls, drop.action))
|
||||
{
|
||||
dropManager.droppedFiles(drop.urls, drop.action);
|
||||
}
|
||||
else{
|
||||
if (dropManager.canDropFormats(drop.formats))
|
||||
{
|
||||
var destItem = grid.itemAt(drop.x,drop.y + grid.contentY);
|
||||
var destLocalX = grid.mapToItem(destItem,drop.x,drop.y + grid.contentY).x
|
||||
var realIndex = grid.indexAt(drop.x,drop.y + grid.contentY);
|
||||
|
||||
if(realIndex === -1)
|
||||
realIndex = grid.count - 1;
|
||||
|
||||
var destIndex = destLocalX < (grid.cellWidth / 2) ? realIndex : realIndex + 1;
|
||||
dropManager.droppedComicsForResortingAt(drop.getDataAsString(), destIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property Component currentComicView: Component {
|
||||
id: currentComicView
|
||||
Rectangle {
|
||||
@ -809,11 +769,51 @@ Rectangle {
|
||||
currentIndexHelper.setCurrentIndex(ci);
|
||||
grid.currentIndex = ci;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
DropArea {
|
||||
anchors.fill: parent
|
||||
|
||||
onEntered: drag => {
|
||||
if(drag.hasUrls)
|
||||
{
|
||||
if(dropManager.canDropUrls(drag.urls, drag.action))
|
||||
{
|
||||
drag.accepted = true;
|
||||
}else
|
||||
drag.accepted = false;
|
||||
}
|
||||
else if (dropManager.canDropFormats(drag.formats)) {
|
||||
drag.accepted = true;
|
||||
} else
|
||||
drag.accepted = false;
|
||||
}
|
||||
|
||||
onDropped: drop => {
|
||||
if(drop.hasUrls && dropManager.canDropUrls(drop.urls, drop.action))
|
||||
{
|
||||
dropManager.droppedFiles(drop.urls, drop.action);
|
||||
}
|
||||
else{
|
||||
if (dropManager.canDropFormats(drop.formats))
|
||||
{
|
||||
var destItem = grid.itemAt(drop.x,drop.y + grid.contentY);
|
||||
var destLocalX = grid.mapToItem(destItem,drop.x,drop.y + grid.contentY).x
|
||||
var realIndex = grid.indexAt(drop.x,drop.y + grid.contentY);
|
||||
|
||||
if(realIndex === -1)
|
||||
realIndex = grid.count - 1;
|
||||
|
||||
var destIndex = destLocalX < (grid.cellWidth / 2) ? realIndex : realIndex + 1;
|
||||
dropManager.droppedComicsForResortingAt("", destIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: info_container
|
||||
objectName: "infoContainer"
|
||||
SplitView.preferredWidth: 350
|
||||
@ -868,5 +868,5 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ SplitView {
|
||||
color: info_container.color
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
Rectangle {
|
||||
id: main
|
||||
clip: true
|
||||
|
||||
@ -416,46 +416,6 @@ Rectangle {
|
||||
grid.contentX = grid.originX
|
||||
}
|
||||
|
||||
DropArea {
|
||||
anchors.fill: parent
|
||||
|
||||
onEntered: {
|
||||
if(drag.hasUrls)
|
||||
{
|
||||
if(dropManager.canDropUrls(drag.urls, drag.action))
|
||||
{
|
||||
drag.accepted = true;
|
||||
}else
|
||||
drag.accepted = false;
|
||||
}
|
||||
else if (dropManager.canDropFormats(drag.formats)) {
|
||||
drag.accepted = true;
|
||||
} else
|
||||
drag.accepted = false;
|
||||
}
|
||||
|
||||
onDropped: {
|
||||
if(drop.hasUrls && dropManager.canDropUrls(drop.urls, drop.action))
|
||||
{
|
||||
dropManager.droppedFiles(drop.urls, drop.action);
|
||||
}
|
||||
else{
|
||||
if (dropManager.canDropFormats(drop.formats))
|
||||
{
|
||||
var destItem = grid.itemAt(drop.x,drop.y + grid.contentY);
|
||||
var destLocalX = grid.mapToItem(destItem,drop.x,drop.y + grid.contentY).x
|
||||
var realIndex = grid.indexAt(drop.x,drop.y + grid.contentY);
|
||||
|
||||
if(realIndex === -1)
|
||||
realIndex = grid.count - 1;
|
||||
|
||||
var destIndex = destLocalX < (grid.cellWidth / 2) ? realIndex : realIndex + 1;
|
||||
dropManager.droppedComicsForResortingAt(drop.getDataAsString(), destIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property Component currentComicView: Component {
|
||||
id: currentComicView
|
||||
Rectangle {
|
||||
@ -816,11 +776,51 @@ Rectangle {
|
||||
currentIndexHelper.setCurrentIndex(ci);
|
||||
grid.currentIndex = ci;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
DropArea {
|
||||
anchors.fill: parent
|
||||
|
||||
onEntered: drag => {
|
||||
if(drag.hasUrls)
|
||||
{
|
||||
if(dropManager.canDropUrls(drag.urls, drag.action))
|
||||
{
|
||||
drag.accepted = true;
|
||||
}else
|
||||
drag.accepted = false;
|
||||
}
|
||||
else if (dropManager.canDropFormats(drag.formats)) {
|
||||
drag.accepted = true;
|
||||
} else
|
||||
drag.accepted = false;
|
||||
}
|
||||
|
||||
onDropped: drop => {
|
||||
if(drop.hasUrls && dropManager.canDropUrls(drop.urls, drop.action))
|
||||
{
|
||||
dropManager.droppedFiles(drop.urls, drop.action);
|
||||
}
|
||||
else{
|
||||
if (dropManager.canDropFormats(drop.formats))
|
||||
{
|
||||
var destItem = grid.itemAt(drop.x,drop.y + grid.contentY);
|
||||
var destLocalX = grid.mapToItem(destItem,drop.x,drop.y + grid.contentY).x
|
||||
var realIndex = grid.indexAt(drop.x,drop.y + grid.contentY);
|
||||
|
||||
if(realIndex === -1)
|
||||
realIndex = grid.count - 1;
|
||||
|
||||
var destIndex = destLocalX < (grid.cellWidth / 2) ? realIndex : realIndex + 1;
|
||||
dropManager.droppedComicsForResortingAt("", destIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: info_container
|
||||
objectName: "infoContainer"
|
||||
SplitView.preferredWidth: 350
|
||||
@ -875,5 +875,5 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user