|
|
A widget for drag support.
If you require only drop support you dont need this widget, you just need KDndDropZone.
| KDNDWidget ( QWidget *_parent=0, const char *_name=0, WFlags f=0 ) |
Constructor.
| ~KDNDWidget () |
Destructor.
| void startDrag ( KDNDIcon *_icon, char *_data, int _size, int _type, int _dx, int _dy ) |
Start a drag.
Call this function when you notice that the user wants to drag something around, usually from a dndMouseMoveEvent.
Parameters:
| _icon | The icon that the user can drag around. |
| _data | A pointer to the data being dragged. A deep copy is made of this data, so you don't need to maintain its value after you call this function. |
| _size | The length of the data pointed to by _data. |
| _type | The type of the data that is being dragged, eg DndURL. |
| _dx | ,_dy The difference between the icons upper left corner and the mouse pointer. For example when the user clicks the mouse over the middle of a pixmap, _dx and _dy would be ' - pixmap.width() / 2 ' and ' - pixmap.height() / 2 '. This is just provided for look and feel. |
| Window findRootWindow ( QPoint & p ) |
Finds the root window belonging to the global point p.
| void mouseMoveEvent ( QMouseEvent * ) |
This function MUST be called by your implementation if you overload it.
In nearly all cases, you probably mean to call dndMouseMoveEvent().
See also: dndMouseMoveEvent
| void mouseReleaseEvent ( QMouseEvent * ) |
This function MUST be called by your implementation if you overload it.
In nearly all cases, you probably mean to call dndMouseReleaseEvent().
See also: dndMouseReleaseEvent
| void rootDropEvent ( int _x, int _y ) |
A root drop occurred.
At the point (_x,_y) the user dropped the icon. If there is now window below this point, this function is called. Usually it emits a XEvent, so that every application gets informed about this. This function is only called if the drag started in this widget.
See KApplication for details on receiving root drop events.
| void rootDropEvent () |
Perform internal housekeeping after a root drop event.
If you must overload rootDropEvent(...), call this function at the end to do some clean up.
| void dragEndEvent () |
Called when a drag is ended.
This function is only called if the drag started in this widget. Overload it to do your own clean up.
| void dndMouseMoveEvent ( QMouseEvent * ) |
Overload this instead of mouseMoveEvent. Ususally drags are started in this functions. A implementation might look like this:
void KFileView::dndMouseMoveEvent( QMouseEvent * _mouse )
{
// 'pressed' is set in mousePressedEvent(...)
if ( !pressed )
return;
int x = _mouse->pos().x();
int y = _mouse->pos().y();
if ( abs( x - press_x ) > Dnd_X_Precision || abs( y - press_y ) > Dnd_Y_Precision )
{
QString data = "Transfer me";
QPoint p = mapToGlobal( _mouse->pos() );
QPixmap pixmap = typ->getPixmap( filename );
int dx = - pixmap.width() / 2;
int dy = - pixmap.height() / 2;
startDrag( new KDNDIcon( pixmap, p.x() + dx, p.y() + dy ), data.data(), data.length(), DndText, dx, dy );
}
else
{
Do something different
}
The function is only called if the mouse movement was not part of a drag process.
| void dndMouseReleaseEvent ( QMouseEvent * ) |
Your mouse release event function.
Usually you will only set 'pressed' ( see dndMouseMoveEvent) to FALSE here. The function is only called if the release event had nothing to do with DND.
| bool drag |
Are we just doing DND ?
| char * dndData |
The data that is currently dragged.
| int dndSize |
data size
| int dndType |
data type
| int dndOffsetX |
The offset we got from 'startDrag'
| int dndOffsetY |
The offset we got from 'startDrag'
| KDNDIcon * dndIcon |
The icon we are moving around
| Window dndLastWindow |
The last window we entered with the mouse pointer.