QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsCustomDropHandler Class Reference

Abstract base class that may be implemented to handle new types of data to be dropped in QGIS. More...

#include <qgscustomdrophandler.h>

Inheritance diagram for QgsCustomDropHandler:
Inheritance graph
[legend]

Public Member Functions

virtual bool canHandleCustomUriCanvasDrop (const QgsMimeDataUtils::Uri &uri, QgsMapCanvas *canvas)
 Returns true if the handler is capable of handling the provided mime uri when dropped onto a map canvas.
 
virtual bool canHandleMimeData (const QMimeData *data)
 Returns true if the handler is capable of handling the provided mime data.
 
virtual QString customUriProviderKey () const
 Type of custom URI recognized by the handler.
 
virtual bool handleCustomUriCanvasDrop (const QgsMimeDataUtils::Uri &uri, QgsMapCanvas *canvas) const
 Called from QGIS after a drop event with custom uri known by the handler occurs onto a map canvas.
 
virtual void handleCustomUriDrop (const QgsMimeDataUtils::Uri &uri) const
 Called from QGIS after a drop event with custom URI known by the handler.
 
virtual bool handleFileDrop (const QString &file)
 Called when the specified file has been dropped onto QGIS.
 
virtual Q_DECL_DEPRECATED void handleMimeData (const QMimeData *data)
 Called when the specified mime data has been dropped onto QGIS.
 
virtual bool handleMimeDataV2 (const QMimeData *data)
 Called when the specified mime data has been dropped onto QGIS.
 

Detailed Description

Abstract base class that may be implemented to handle new types of data to be dropped in QGIS.

Implementations have three approaches they can use to handle drops.

Definition at line 46 of file qgscustomdrophandler.h.

Member Function Documentation

◆ canHandleCustomUriCanvasDrop()

bool QgsCustomDropHandler::canHandleCustomUriCanvasDrop ( const QgsMimeDataUtils::Uri uri,
QgsMapCanvas canvas 
)
virtual

Returns true if the handler is capable of handling the provided mime uri when dropped onto a map canvas.

The base class implementation returns false regardless of mime data.

This method is called when mime data is dragged over a map canvas, in order to determine whether any handlers are capable of handling the data and to determine whether the drag action should be accepted.

Warning
Subclasses should be very careful about implementing this. If they incorrectly return true to a uri, it will prevent the default application drop handling from occurring and will break the ability to drag and drop layers and files onto QGIS.
Since
QGIS 3.10

Definition at line 50 of file qgscustomdrophandler.cpp.

◆ canHandleMimeData()

bool QgsCustomDropHandler::canHandleMimeData ( const QMimeData *  data)
virtual

Returns true if the handler is capable of handling the provided mime data.

The base class implementation returns false regardless of mime data.

This method is called when mime data is dragged over the QGIS window, in order to determine whether any handlers are capable of handling the data and to determine whether the drag action should be accepted.

Since
QGIS 3.10

Definition at line 29 of file qgscustomdrophandler.cpp.

◆ customUriProviderKey()

QString QgsCustomDropHandler::customUriProviderKey ( ) const
virtual

Type of custom URI recognized by the handler.

This must match the URI entry's providerKey in order for handleCustomUriDrop() to be called.

See also
handleCustomUriDrop()

Definition at line 19 of file qgscustomdrophandler.cpp.

◆ handleCustomUriCanvasDrop()

bool QgsCustomDropHandler::handleCustomUriCanvasDrop ( const QgsMimeDataUtils::Uri uri,
QgsMapCanvas canvas 
) const
virtual

Called from QGIS after a drop event with custom uri known by the handler occurs onto a map canvas.

In order for handleCustomUriCanvasDrop() to be called, subclasses must also implement customUriProviderKey() to indicate the providerKey value which the handler accepts.

If the function returns true, it means the handler has accepted the drop and it should not be further processed (e.g. by other QgsCustomDropHandlers).

Subclasses which implement this must also implement corresponding versions of canHandleCustomUriCanvasDrop().

See also
customUriProviderKey()
canHandleCustomUriCanvasDrop()
Since
QGIS 3.10

Definition at line 55 of file qgscustomdrophandler.cpp.

◆ handleCustomUriDrop()

void QgsCustomDropHandler::handleCustomUriDrop ( const QgsMimeDataUtils::Uri uri) const
virtual

Called from QGIS after a drop event with custom URI known by the handler.

In order for handleCustomUriDrop() to be called, subclasses must also implement customUriProviderKey() to indicate the providerKey value which the handler accepts.

See also
customUriProviderKey()

Definition at line 24 of file qgscustomdrophandler.cpp.

◆ handleFileDrop()

bool QgsCustomDropHandler::handleFileDrop ( const QString &  file)
virtual

Called when the specified file has been dropped onto QGIS.

If true is returned, then the handler has accepted this file and it should not be further processed (e.g. by other QgsCustomDropHandlers).

The base class implementation does nothing.

This method is not called directly while drop handling is occurring, so the limitations described in handleMimeData() about returning quickly do not apply.

Definition at line 44 of file qgscustomdrophandler.cpp.

◆ handleMimeData()

void QgsCustomDropHandler::handleMimeData ( const QMimeData *  data)
virtual

Called when the specified mime data has been dropped onto QGIS.

The base class implementation does nothing.

Subclasses should take care when overriding this method. When a drop event occurs, Qt will lock the source application of the drag for the duration of the drop event handling (e.g. dragging files from explorer to QGIS will lock the explorer window until the drop handling has been complete).

Accordingly, only implementations must be lightweight and return ASAP. (For instance by copying the relevant parts of data and then handling the data after a short timeout).

Deprecated:
QGIS 3.10. Use handleMimeDataV2() instead.

Definition at line 34 of file qgscustomdrophandler.cpp.

◆ handleMimeDataV2()

bool QgsCustomDropHandler::handleMimeDataV2 ( const QMimeData *  data)
virtual

Called when the specified mime data has been dropped onto QGIS.

The base class implementation does nothing.

Subclasses should take care when overriding this method. When a drop event occurs, Qt will lock the source application of the drag for the duration of the drop event handling (e.g. dragging files from explorer to QGIS will lock the explorer window until the drop handling has been complete).

Accordingly, only implementations must be lightweight and return ASAP. (For instance by copying the relevant parts of data and then handling the data after a short timeout).

If the function returns true, it means the handler has accepted the drop and it should not be further processed (e.g. by other QgsCustomDropHandlers)

Since
QGIS 3.10

Definition at line 39 of file qgscustomdrophandler.cpp.


The documentation for this class was generated from the following files: