All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Radiant::DropEvent Class Reference

This class abstracts drag and drop events. More...

#include <Radiant/DropEvent.hpp>

Inheritance diagram for Radiant::DropEvent:
Patterns::NotCopyable

Public Member Functions

 DropEvent (const QList< QUrl > &urls, Nimble::Vector2 loc)
 Creates a drop event that contains a collection of URLs. More...
 
 DropEvent (const QDropEvent &de, Nimble::Vector2 loc)
 Create a drop event from QDropEvent. More...
 
bool hasUrls () const
 Check whether the event contains URLs. More...
 
Nimble::Vector2 location () const
 Returns the location of the drop event in scene coordinates. More...
 
QList< QUrl > urls () const
 Return the list of URLs. More...
 
 ~DropEvent ()
 Deletes the drop event.
 

Static Public Member Functions

static void addDropListener (DropListener *l)
 Registers a DropListener object. More...
 
static bool deliverDropToListeners (const DropEvent &e)
 Deliver a DropEvent to all the registered listeners. More...
 
static void removeDropListener (DropListener *l)
 Removes a DropListener object from the list of registered listeners. More...
 

Detailed Description

This class abstracts drag and drop events.

Instances of this class are generated when a drag and drop action is completed. The DropEvent is an experimental part of Cornerstone, and its API may change yet.

Examples:
DropHandlerExample.cpp.

Constructor & Destructor Documentation

Radiant::DropEvent::DropEvent ( const QList< QUrl > &  urls,
Nimble::Vector2  loc 
)

Creates a drop event that contains a collection of URLs.

Parameters
urlsList of urls to store with event
locLocation of drop in Application's scene coordinates
Radiant::DropEvent::DropEvent ( const QDropEvent &  de,
Nimble::Vector2  loc 
)

Create a drop event from QDropEvent.

Parameters
deQDropEvent to copy
locdrop location in Application's scene coordinates

Member Function Documentation

static void Radiant::DropEvent::addDropListener ( DropListener l)
static

Registers a DropListener object.

After calling this function, the listener is active and will receive drop events. This function is thread-safe.

Parameters
lThe listener to be registered.
Examples:
DropHandlerExample.cpp.
static bool Radiant::DropEvent::deliverDropToListeners ( const DropEvent e)
static

Deliver a DropEvent to all the registered listeners.

This function iterates through the list of DropListener object that have been registered with addDropListener. For each listener it will call the Radiant::DropListener::dropEvent, until the the list is exhausted or one of the function calls returns true. This function is thread-safe.

Parameters
eThe DropEvent to be delivered
Returns
True if some listeners accepted event, false otherwise.
bool Radiant::DropEvent::hasUrls ( ) const

Check whether the event contains URLs.

Returns
True if event contains URLs
Nimble::Vector2 Radiant::DropEvent::location ( ) const

Returns the location of the drop event in scene coordinates.

In most cases, you need to convert this location to object coordinates. For Widgets, this can be done with MultiWidgets::Widget::mapFromScene function - assuming that there is no complex view hierarchy that causes extra transformations.

Returns
Location of the drop event in scene coordinates.
Examples:
DropHandlerExample.cpp.
static void Radiant::DropEvent::removeDropListener ( DropListener l)
static

Removes a DropListener object from the list of registered listeners.

After calling this function, the listener is no longer active and will receive no further drop events. This function is thread-safe.

Parameters
lThe listener to be removed.
QList<QUrl> Radiant::DropEvent::urls ( ) const

Return the list of URLs.

Returns
URLs related to event
Examples:
DropHandlerExample.cpp.