QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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 QString customUriProviderKey () const
 Type of custom URI recognized by the handler. More...
 
virtual void handleCustomUriDrop (const QgsMimeDataUtils::Uri &uri) const
 Called from QGIS after a drop event with custom URI known by the handler. More...
 
virtual bool handleFileDrop (const QString &file)
 Called when the specified file has been dropped onto QGIS. More...
 
virtual void handleMimeData (const QMimeData *data)
 Called when the specified mime data has been dropped onto QGIS. More...
 

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.

  1. The simplest approach is to implement handeFileDrop() when they need to handle dropped files (i.e. with mime type "text/uri-list").
  2. Reimplement handleCustomUriDrop() when they want to handle dropped custom QgsMimeDataUtils::Uri entries, for instance handling dropping custom entries from the browser tree (with mime type "application/x-vnd.qgis.qgis.uri"). In this case the implementation's customUriProviderKey() must match the uri entry's providerKey.
  3. Reimplement handleMimeData() to directly handle dropped QMimeData. 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 via handleMimeData() (e.g. dragging files from explorer to QGIS will lock the explorer window until the drop handling has been complete). Accordingly handleMimeData() implementations must return quickly and defer any intensive or slow processing.
Since
QGIS 3.0

Definition at line 47 of file qgscustomdrophandler.h.

Member Function Documentation

◆ 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 18 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 23 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 33 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).

Definition at line 28 of file qgscustomdrophandler.cpp.


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