将文件从应用程序拖到资源管理器.我的应用程序可以复制吗?

将文件从应用程序拖到资源管理器.我的应用程序可以复制吗?

问题描述:

在Qml中,我可以使用 text/uri-list MIME类型开始拖动,以便将应用程序中的复制动作启动到文件浏览器中,例如

In Qml I can start a drag using the text/uri-list mime type in order to start a copy action from my application into a file explorer, e.g.

        Item {
            id: draggable
            anchors.fill: parent
            Drag.active: mouseArea.drag.active
            Drag.hotSpot.x: 0
            Drag.hotSpot.y: 0
            Drag.mimeData: { "text/uri-list": "file:///home/myname/Desktop/avatar.jpeg" }
            Drag.supportedActions: Qt.CopyAction
            Drag.dragType: Drag.Automatic
            Drag.onDragStarted: { }
            Drag.onDragFinished: {
                console.log("Time to copy")
            }
        } // Item

        Item {
            id: draggable
            anchors.fill: parent
            Drag.active: mouseArea.drag.active
            Drag.hotSpot.x: 0
            Drag.hotSpot.y: 0
            Drag.mimeData: { "text/uri-list": "https://farm1.staticflickr.com/713/21777111068_e3310cfb94_k.jpg" }
            Drag.supportedActions: Qt.CopyAction
            Drag.dragType: Drag.Automatic
            Drag.onDragStarted: { }
            Drag.onDragFinished: {
                console.log("Time to copy")
            }
        } // Item

(另请参见 Qt快速示例-externaldraganddrop )

在给定 file: http: URI的情况下,此方法工作正常.

This works fine given file: and http: URIs.

但是,我的真实数据不能作为URI使用,而是存储在数据库中.我无法快速存储到temp,因为这可能需要几秒钟的时间,并且用户不希望在开始拖动时出现延迟.

However my real data is not available as an URI but stored in a database. I cannot quickly store to temp because that can take seconds and user does not want a delay in the moment he starts a drag.

是否可以在删除后获取目标URI并自行复制?还是只有目标可以复制?

Is it somehow possible to get the target URI after the drop and do the copying myself? Or can only the target do the copying?

在后一种情况下,是否需要通过内部HTTP服务器使数据可用?我什至如何知道Linux,Windows和OS X上的文件浏览器支持哪种URI方案?

In the later case, do I need to make my data available via an internal HTTP-Server? How do I even know which URI scheme is supported by the file browsers on Linux, Windows and OS X?

我会使用类似的东西:

Drag.mimeData: { "text/uri-list": "http://localhost:8080/datarepository?id=12345" }

然后,我将在应用程序内HTTP服务器上提供请求的数据(然后在我的示例中可以轻松地从数据库中提取ID等于 12345 的对象)...(复制操作开始后,如果您的用户在系统从数据库中提取对象时等待几秒钟,我认为这并不可惜.

and then I'll make available the requested data on an in-application HTTP server (that then can easily extract the object having ID equal to 12345 in my example from DB)... (once the copy operation has started I don't think that it is a shame if your user waits some seconds while the system extracts the object from the DB).