Source Code (Use browser search to find items of interest.)

Class Index

qt'QDragObject (./qt-2.1.0/src/kernel/qdragobject.h:39)

class Q_EXPORT QDragObject: public QObject, public QMimeSource {
    Q_OBJECT
public:
    QDragObject( QWidget * dragSource = 0, const char * name = 0 );
    virtual ~QDragObject();

    bool drag();
    bool dragMove();
    void dragCopy();

    virtual void setPixmap(QPixmap);
    virtual void setPixmap(QPixmap, QPoint hotspot);
    QPixmap pixmap() const;
    QPoint pixmapHotSpot() const;

    QWidget * source();
    static QWidget * target();

    static void setTarget(QWidget*);

    enum DragMode { DragDefault, DragCopy, DragMove, DragCopyOrMove };

protected:
    virtual bool drag(DragMode);

private:
    QDragData * d;
};


qt'QDragObject::target() (./qt-2.1.0/src/kernel/qdragobject.cpp:57)

QWidget * QDragObject::target()
{
    return last_target;
}

/*!
  \internal
  Sets the target.
*/

qt'QDragObject::setTarget() (./qt-2.1.0/src/kernel/qdragobject.cpp:66)

void QDragObject::setTarget(QWidget* t)
{
    last_target = t;
}


qt'QDragObject::QDragObject() (./qt-2.1.0/src/kernel/qdragobject.cpp:273)

QDragObject::QDragObject( QWidget * dragSource, const char * name )
    : QObject( dragSource, name )
{
    d = new QDragData();
    if ( !manager && qApp )
	(void)new QDragManager();
}


/*! Destroys the drag object, cancelling any drag-and-drop operation
  in which it is involved, and frees up the storage used. */


qt'QDragObject::~QDragObject() (./qt-2.1.0/src/kernel/qdragobject.cpp:285)

QDragObject::~QDragObject()
{
    if ( manager && manager->object == this )
	manager->cancel( FALSE );
    delete d;
}

/*!
  Set the pixmap \a pm to display while dragging the object.
  The platform-specific
  implementation will use this in a loose fashion - so provide a small masked
  pixmap, but do not require that the user ever sees it in all its splendor.
  In particular, cursors on Windows 95 are of limited size.

  The \a hotspot is the point on (or off) the pixmap that should be under the
  cursor as it is dragged. It is relative to the top-left pixel of the pixmap.
*/

qt'QDragObject::setPixmap() (./qt-2.1.0/src/kernel/qdragobject.cpp:302)

void QDragObject::setPixmap(QPixmap pm, QPoint hotspot)
{
    d->pixmap = pm;
    d->hot = hotspot;
    if ( manager && manager->object == this )
	manager->updatePixmap();
}

/*!
  \overload
  Uses a hotspot that positions the pixmap below and to the
  right of the mouse pointer.  This allows the user to clearly
  see the point on the window which they are dragging the data onto.
*/

qt'QDragObject::setPixmap() (./qt-2.1.0/src/kernel/qdragobject.cpp:316)

void QDragObject::setPixmap(QPixmap pm)
{
    setPixmap(pm,QPoint(-10,-10));
}

/*!
  Returns the currently set pixmap
  (which \link QPixmap::isNull() isNull()\endlink if none is set).
*/

qt'QDragObject::pixmap() (./qt-2.1.0/src/kernel/qdragobject.cpp:325)

QPixmap QDragObject::pixmap() const
{
    return d->pixmap;
}

/*!
  Returns the currently set pixmap hitspot.
*/

qt'QDragObject::pixmapHotSpot() (./qt-2.1.0/src/kernel/qdragobject.cpp:333)

QPoint QDragObject::pixmapHotSpot() const
{
    return d->hot;
}

/*!
  Starts a drag operation using the contents of this object,
  using DragDefault mode.

  The function returns TRUE if the caller should delete the
  original copy of the dragged data (but also note target()).

  Note that if the drag contains \e references to information
  (eg. file names is a QUriDrag are references)
  then the return value should always be ignored, as the target
  is expected to manipulate the referred-to content directly.
  On X11 the return value should always be correct anyway, but
  on Windows this is not necessarily the case (eg. the file manager
  starts a background process to move files, so the source
  <em>must not</em> delete the files!)
*/

qt'QDragObject::drag() (./qt-2.1.0/src/kernel/qdragobject.cpp:354)

bool QDragObject::drag()
{
    return drag( DragDefault );
}


/*!
  Starts a drag operation using the contents of this object,
  using DragMove mode.
*/

qt'QDragObject::dragMove() (./qt-2.1.0/src/kernel/qdragobject.cpp:364)

bool QDragObject::dragMove()
{
    return drag( DragMove );
}


/*!
  Starts a drag operation using the contents of this object,
  using DragCopy mode.

  See drag(DragMove) for important further information.
*/

qt'QDragObject::dragCopy() (./qt-2.1.0/src/kernel/qdragobject.cpp:376)

void QDragObject::dragCopy()
{
    (void)drag( DragCopy );
}


/*! \enum QDragObject::DragMode

  This enum type decides which of several types of drag each
  individual drag is.  The available types are: <ul>
   <li>\c DragDefault - the mode is determined heuristically.
   <li>\c DragCopy - the data is copied, never moved.
   <li>\c DragMove - the data is moved, if dragged at all.
   <li>\c DragCopyOrMove - the user chooses the mode
	    by using control key to switch from the default.
  </ul>
*/


/*!
  Starts a drag operation using the contents of this object.

  At this point, the object becomes owned by Qt, not the
  application.  You should not delete the drag object nor
  anything it references.  The actual transfer of data to
  the target application will be done during future event
  processing - after that time the drag object will be deleted.

  Returns TRUE if the dragged data was dragged as a \e move,
  indicating that the caller should remove the original source
  of the data (the drag object must continue to have a copy).

  Normally one of simpler drag(), dragMove(), or dragCopy() functions
  would be used instead.

  \warning in Qt 1.x, drag operations all return FALSE.  This will change
	    in later versions - the functions are provided in this way to
	    assist preemptive development - code both move and copy with
	    Qt 1.x to be prepared.
*/

qt'QDragObject::drag() (./qt-2.1.0/src/kernel/qdragobject.cpp:416)

bool QDragObject::drag( DragMode mode )
{ // ### In Qt 1.x?  huh?
    if ( manager )
	return manager->drag( this, mode );
    else
	return FALSE;
}



/*!  Returns a pointer to the drag source where this object originated.
*/


qt'QDragObject::source() (./qt-2.1.0/src/kernel/qdragobject.cpp:429)

QWidget * QDragObject::source()
{
    if ( parent()->isWidgetType() )
	return (QWidget *)parent();
    else
	return 0;
}


// NOT REVISED
/*! \class QDragObject qdragobject.h

  \brief The QDragObject encapsulates MIME-based information transfer.

  \ingroup draganddrop

  QDragObject is the base class for all data that needs to be transferred
  between and within applications, both for drag-and-drop and for the
  clipboard.

  See the \link dnd.html Drag-and-drop documentation\endlink for
  an overview of how to provide drag-and-drop in your application.

  See the QClipboard documentation for
  an overview of how to provide cut-and-paste in your application.
*/

static