Qt 4.8
Public Functions | Static Public Functions | Public Variables | Private Functions | Properties | Static Private Attributes | Friends | List of all members
QDragManager Class Reference

#include <qdnd_p.h>

Inheritance diagram for QDragManager:
QObject

Public Functions

void cancel (bool deleteSource=true)
 
QWidgetcurrentTarget ()
 
Qt::DropAction defaultAction (Qt::DropActions possibleActions, Qt::KeyboardModifiers modifiers) const
 
Qt::DropAction drag (QDrag *)
 
QPixmap dragCursor (Qt::DropAction action) const
 
QDragPrivatedragPrivate () const
 
void drop ()
 
void emitActionChanged (Qt::DropAction newAction)
 
bool hasCustomDragCursors () const
 
void move (const QPoint &)
 
void setCurrentTarget (QWidget *target, bool dropped=false)
 
QWidgetsource () const
 
void updateCursor ()
 
void updatePixmap ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Static Public Functions

static QDragPrivatedragPrivate (QDrag *drag)
 
static QDragManagerself ()
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 

Public Variables

bool beingCancelled
 
QDropDatadropData
 
QEventLoopeventLoop
 
QDragobject
 
bool restoreCursor
 
bool willDrop
 
QPixmap xdndMimeTransferedPixmap [2]
 
int xdndMimeTransferedPixmapIndex
 

Private Functions

bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
 QDragManager ()
 
void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
 ~QDragManager ()
 

Properties

Qt::DropAction currentActionForOverrideCursor
 
QWidgetcurrentDropTarget
 

Static Private Attributes

static QDragManagerinstance = 0
 

Friends

class QApplication
 
class QDrag
 
class QDragMoveEvent
 
class QDropEvent
 
class QWidgetPrivate
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 206 of file qdnd_p.h.

Constructors and Destructors

◆ QDragManager()

QDragManager::QDragManager ( )
private

Definition at line 132 of file qdnd.cpp.

Referenced by self().

133  : QObject(qApp)
134 {
135  Q_ASSERT(!instance);
136 
137 #ifdef Q_WS_QWS
139 #endif
140  object = 0;
141  beingCancelled = false;
142  restoreCursor = false;
143  willDrop = false;
144  eventLoop = 0;
145  dropData = new QDropData();
146  currentDropTarget = 0;
147 #ifdef Q_WS_X11
149 #endif
150 }
bool restoreCursor
Definition: qdnd_p.h:243
Qt::DropAction currentActionForOverrideCursor
Definition: qdnd_p.h:265
QEventLoop * eventLoop
Definition: qdnd_p.h:245
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define qApp
bool willDrop
Definition: qdnd_p.h:244
QDropData * dropData
Definition: qdnd_p.h:251
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753
QWidget * currentDropTarget
Definition: qdnd_p.h:272
bool beingCancelled
Definition: qdnd_p.h:242
int xdndMimeTransferedPixmapIndex
Definition: qdnd_p.h:260
static QDragManager * instance
Definition: qdnd_p.h:274

◆ ~QDragManager()

QDragManager::~QDragManager ( )
private

Definition at line 153 of file qdnd.cpp.

154 {
155 #ifndef QT_NO_CURSOR
156  if (restoreCursor)
158 #endif
159  instance = 0;
160  delete dropData;
161 }
bool restoreCursor
Definition: qdnd_p.h:243
QDropData * dropData
Definition: qdnd_p.h:251
static void restoreOverrideCursor()
Undoes the last setOverrideCursor().
static QDragManager * instance
Definition: qdnd_p.h:274

Functions

◆ cancel()

void QDragManager::cancel ( bool  deleteSource = true)

Definition at line 272 of file qdnd_mac.mm.

Referenced by QOleDropTarget::Drop(), and QDrag::~QDrag().

273 {
274  if(object) {
275  beingCancelled = true;
276  object = 0;
277  }
278 #ifndef QT_NO_ACCESSIBILITY
280 #endif
281 }
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object&#39;s accessibility information.
bool beingCancelled
Definition: qdnd_p.h:242

◆ currentTarget()

QWidget * QDragManager::currentTarget ( )

Definition at line 273 of file qdnd.cpp.

Referenced by make_widget_eventUPP(), and QApplication::notify().

274 {
275  return currentDropTarget;
276 }
QWidget * currentDropTarget
Definition: qdnd_p.h:272

◆ defaultAction()

Qt::DropAction QDragManager::defaultAction ( Qt::DropActions  possibleActions,
Qt::KeyboardModifiers  modifiers 
) const

Definition at line 194 of file qdnd.cpp.

Referenced by QDropEvent::QDropEvent(), and qt_mac_dnd_update_action().

196 {
197 #ifdef QDND_DEBUG
198  qDebug("QDragManager::defaultAction(Qt::DropActions possibleActions)");
199  qDebug("keyboard modifiers : %s", KeyboardModifiersToString(modifiers).latin1());
200 #endif
201 
204 
205  if (defaultAction == Qt::IgnoreAction) {
206  //This means that the drag was initiated by QDrag::start and we need to
207  //preserve the old behavior
208 #ifdef Q_WS_MAC
209  defaultAction = Qt::MoveAction;
210 #else
211  defaultAction = Qt::CopyAction;
212 #endif
213  }
214 
215 #ifdef Q_WS_MAC
216  if (modifiers & Qt::ControlModifier && modifiers & Qt::AltModifier)
217  defaultAction = Qt::LinkAction;
218  else if (modifiers & Qt::AltModifier)
219  defaultAction = Qt::CopyAction;
220  else if (modifiers & Qt::ControlModifier)
221  defaultAction = Qt::MoveAction;
222 #else
223  if (modifiers & Qt::ControlModifier && modifiers & Qt::ShiftModifier)
224  defaultAction = Qt::LinkAction;
225  else if (modifiers & Qt::ControlModifier)
226  defaultAction = Qt::CopyAction;
227  else if (modifiers & Qt::ShiftModifier)
228  defaultAction = Qt::MoveAction;
229  else if (modifiers & Qt::AltModifier)
230  defaultAction = Qt::LinkAction;
231 #endif
232 
233  // if the object is set take the list of possibles from it
234  if (object)
235  possibleActions = object->d_func()->possible_actions;
236 
237 #ifdef QDND_DEBUG
238  qDebug("possible actions : %s", dragActionsToString(possibleActions).latin1());
239 #endif
240 
241  // Check if the action determined is allowed
242  if (!(possibleActions & defaultAction)) {
243  if (possibleActions & Qt::CopyAction)
244  defaultAction = Qt::CopyAction;
245  else if (possibleActions & Qt::MoveAction)
246  defaultAction = Qt::MoveAction;
247  else if (possibleActions & Qt::LinkAction)
248  defaultAction = Qt::LinkAction;
249  else
250  defaultAction = Qt::IgnoreAction;
251  }
252 
253 #ifdef QDND_DEBUG
254  qDebug("default action : %s", dragActionsToString(defaultAction).latin1());
255 #endif
256 
257  return defaultAction;
258 }
double d
Definition: qnumeric_p.h:62
Qt::DropAction defaultAction(Qt::DropActions possibleActions, Qt::KeyboardModifiers modifiers) const
Definition: qdnd.cpp:194
Q_CORE_EXPORT void qDebug(const char *,...)
DropAction
Definition: qnamespace.h:1597
QDragPrivate * dragPrivate() const
Definition: qdnd_p.h:231
Qt::DropAction defaultDropAction
Definition: qdnd_p.h:185

◆ drag()

Qt::DropAction QDragManager::drag ( QDrag o)

Definition at line 530 of file qdnd_mac.mm.

Referenced by QX11Data::dndEnable(), QOleDropTarget::Drop(), QDrag::exec(), and QDrag::start().

531 {
532 
533  if(qt_mac_in_drag) { //just make sure..
534  qWarning("Qt: Internal error: WH0A, unexpected condition reached");
535  return Qt::IgnoreAction;
536  }
537  if(object == o)
538  return Qt::IgnoreAction;
539  /* At the moment it seems clear that Mac OS X does not want to drag with a non-left button
540  so we just bail early to prevent it */
541  if(!(GetCurrentEventButtonState() & kEventMouseButtonPrimary))
542  return Qt::IgnoreAction;
543 
544  if(object) {
546  cancel();
547  beingCancelled = false;
548  }
549 
550  object = o;
551  dragPrivate()->target = 0;
552 
553 #ifndef QT_NO_ACCESSIBILITY
555 #endif
556 
557  //setup the data
559  dragBoard.setMimeData(dragPrivate()->data);
560 
561  //create the drag
562  OSErr result;
563  DragRef dragRef;
564  if((result = NewDragWithPasteboard(dragBoard.pasteBoard(), &dragRef)))
565  return Qt::IgnoreAction;
566  //setup the actions
567  DragActions possibleActions = qt_mac_dnd_map_qt_actions(dragPrivate()->possible_actions);
568  SetDragAllowableActions(dragRef, //local
569  possibleActions,
570  true);
571  SetDragAllowableActions(dragRef, //remote (same as local)
572  possibleActions,
573  false);
574 
575 
576  QPoint hotspot;
577  QPixmap pix = dragPrivate()->pixmap;
578  if(pix.isNull()) {
579  if(dragPrivate()->data->hasText() || dragPrivate()->data->hasUrls()) {
580  //get the string
582  : dragPrivate()->data->urls().first().toString();
583  if(s.length() > 26)
584  s = s.left(23) + QChar(0x2026);
585  if(!s.isEmpty()) {
586  //draw it
587  QFont f(qApp->font());
588  f.setPointSize(12);
589  QFontMetrics fm(f);
590  const int width = fm.width(s);
591  const int height = fm.height();
592  if(width > 0 && height > 0) {
593  QPixmap tmp(width, height);
594  QPainter p(&tmp);
595  p.fillRect(0, 0, tmp.width(), tmp.height(), Qt::color0);
596  p.setPen(Qt::color1);
597  p.setFont(f);
598  p.drawText(0, fm.ascent(), s);
599  p.end();
600  //save it
601  pix = tmp;
602  hotspot = QPoint(tmp.width() / 2, tmp.height() / 2);
603  }
604  }
605  } else {
606  pix = QPixmap(default_pm);
608  }
609  } else {
610  hotspot = dragPrivate()->hotspot;
611  }
612 
613  //so we must fake an event
614  EventRecord fakeEvent;
615  GetGlobalMouse(&(fakeEvent.where));
616  fakeEvent.message = 0;
617  fakeEvent.what = mouseDown;
618  fakeEvent.when = EventTimeToTicks(GetCurrentEventTime());
619  fakeEvent.modifiers = GetCurrentKeyModifiers();
620  if(GetCurrentEventButtonState() & 2)
621  fakeEvent.modifiers |= controlKey;
622 
623  //find the hotspot in relation to the pixmap
624  Point boundsPoint;
625  boundsPoint.h = fakeEvent.where.h - hotspot.x();
626  boundsPoint.v = fakeEvent.where.v - hotspot.y();
627  Rect boundsRect;
628  SetRect(&boundsRect, boundsPoint.h, boundsPoint.v, boundsPoint.h + pix.width(), boundsPoint.v + pix.height());
629 
630  //set the drag image
631  QRegion dragRegion(boundsPoint.h, boundsPoint.v, pix.width(), pix.height()), pixRegion;
632  if(!pix.isNull()) {
633  HIPoint hipoint = { -hotspot.x(), -hotspot.y() };
634  CGImageRef img = (CGImageRef)pix.macCGHandle();
635  SetDragImageWithCGImage(dragRef, img, &hipoint, 0);
636  CGImageRelease(img);
637  }
638 
639  SetDragItemBounds(dragRef, (ItemReference)1 , &boundsRect);
640  { //do the drag
641  qt_mac_in_drag = true;
642  qt_mac_dnd_update_action(dragRef);
643  result = TrackDrag(dragRef, &fakeEvent, QMacSmartQuickDrawRegion(dragRegion.toQDRgn()));
644  qt_mac_in_drag = false;
645  }
646  object = 0;
647  if(result == noErr) {
648  // Check if the receiver points us to
649  // a file location. If so, we need to do
650  // the file copy/move ourselves:
651  QCFType<CFURLRef> pasteLocation = 0;
652  PasteboardCopyPasteLocation(dragBoard.pasteBoard(), &pasteLocation);
653  if (pasteLocation){
654  Qt::DropAction action = o->d_func()->defaultDropAction;
655  if (action == Qt::IgnoreAction){
656  if (o->d_func()->possible_actions & Qt::MoveAction)
657  action = Qt::MoveAction;
658  else if (o->d_func()->possible_actions & Qt::CopyAction)
659  action = Qt::CopyAction;
660 
661  }
662  bool atleastOne = false;
663  QList<QUrl> urls = o->mimeData()->urls();
664  for (int i = 0; i < urls.size(); ++i){
665  QUrl fromUrl = urls.at(i);
666  QString filename = QFileInfo(fromUrl.path()).fileName();
667  QUrl toUrl(QCFString::toQString(CFURLGetString(pasteLocation)) + filename);
668  if (action == Qt::MoveAction){
669  if (QFile::rename(fromUrl.path(), toUrl.path()))
670  atleastOne = true;
671  } else if (action == Qt::CopyAction){
672  if (QFile::copy(fromUrl.path(), toUrl.path()))
673  atleastOne = true;
674  }
675  }
676  if (atleastOne){
677  DisposeDrag(dragRef);
678  o->setMimeData(0);
679  o->deleteLater();
680  return action;
681  }
682  }
683 
684  DragActions ret = kDragActionNothing;
685  GetDragDropAction(dragRef, &ret);
686  DisposeDrag(dragRef); //cleanup
687  o->setMimeData(0);
688  o->deleteLater();
690  }
691  DisposeDrag(dragRef); //cleanup
692  return Qt::IgnoreAction;
693 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
void setPointSize(int)
Sets the point size to pointSize.
Definition: qfont.cpp:1099
bool hasUrls() const
Returns true if the object can return a list of urls; otherwise returns false.
Definition: qmimedata.cpp:352
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object&#39;s accessibility information.
static DragActions qt_mac_dnd_map_qt_actions(Qt::DropActions qActions)
Definition: qdnd_mac.mm:137
bool rename(const QString &newName)
Renames the file currently specified by fileName() to newName.
Definition: qfile.cpp:766
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
void setMimeData(QMimeData *data)
Sets the data to be sent to the given MIME data.
Definition: qdrag.cpp:142
QString toString(FormattingOptions options=None) const
Returns the human-displayable string representation of the URL.
Definition: qurl.cpp:5896
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
static const int default_pm_hotx
Definition: qdnd_mac.mm:95
void removeEventFilter(QObject *)
Removes an event filter object obj from this object.
Definition: qobject.cpp:2099
QWidget * target
Definition: qdnd_p.h:178
static QString toQString(CFStringRef cfstr)
Definition: qcore_mac.cpp:47
struct CGImage * CGImageRef
static const char *const default_pm[]
Definition: qdnd_mac.mm:98
void cancel(bool deleteSource=true)
Definition: qdnd_mac.mm:272
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
static const int default_pm_hoty
Definition: qdnd_mac.mm:96
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
bool qt_mac_in_drag
Definition: qdnd_mac.mm:78
QString path() const
Returns the path of the URL.
Definition: qurl.cpp:4977
static Qt::DropAction qt_mac_dnd_map_mac_default_action(DragActions macActions)
Definition: qdnd_mac.mm:162
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
QString text() const
Returns a plain text (MIME type text/plain) representation of the data.
Definition: qmimedata.cpp:364
QPixmap pixmap
Definition: qdnd_p.h:180
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define qApp
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static Qt::DropActions possible_actions
Definition: qdnd_qws.cpp:79
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
QPoint hotspot
Definition: qdnd_p.h:181
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QList< QUrl > urls() const
Returns a list of URLs contained within the MIME data object.
Definition: qmimedata.cpp:310
DropAction
Definition: qnamespace.h:1597
QWidget * source
Definition: qdnd_p.h:177
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
static void qt_mac_dnd_update_action(DragReference dragRef)
Definition: qdnd_mac.mm:184
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
QMimeData * data
Definition: qdnd_p.h:179
QMimeData * mimeData() const
Returns the MIME data that is encapsulated by the drag object.
Definition: qdrag.cpp:155
bool hasText() const
Returns true if the object can return plain text (MIME type text/plain); otherwise returns false...
Definition: qmimedata.cpp:389
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
bool copy(const QString &newName)
Copies the file currently specified by fileName() to a file called newName.
Definition: qfile.cpp:926
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
bool beingCancelled
Definition: qdnd_p.h:242
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
static QUrl toUrl(Register *reg, int type, QDeclarativeContextData *context, bool *ok=0)
QDragPrivate * dragPrivate() const
Definition: qdnd_p.h:231
static QString fileName(const QString &fileUrl)
void deleteLater()
Schedules this object for deletion.
Definition: qobject.cpp:2145

◆ dragCursor()

QPixmap QDragManager::dragCursor ( Qt::DropAction  action) const

Definition at line 170 of file qdnd.cpp.

Referenced by QOleDropSource::createCursors().

171 {
172  QDragPrivate * d = dragPrivate();
173  if (d && d->customCursors.contains(action))
174  return d->customCursors[action];
175  else if (action == Qt::MoveAction)
177  else if (action == Qt::CopyAction)
179  else if (action == Qt::LinkAction)
181 #ifdef Q_WS_WIN
182  else if (action == Qt::IgnoreAction)
184 #endif
185  return QPixmap();
186 }
double d
Definition: qnumeric_p.h:62
QMap< Qt::DropAction, QPixmap > customCursors
Definition: qdnd_p.h:184
static QApplicationPrivate * instance()
QPixmap getPixmapCursor(Qt::CursorShape cshape)
if(void) toggleToolbarShown
bool contains(const Key &key) const
Returns true if the map contains an item with key key; otherwise returns false.
Definition: qmap.h:553
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
QDragPrivate * dragPrivate() const
Definition: qdnd_p.h:231

◆ dragPrivate() [1/2]

QDragPrivate* QDragManager::dragPrivate ( ) const
inline

◆ dragPrivate() [2/2]

static QDragPrivate* QDragManager::dragPrivate ( QDrag drag)
inlinestatic

Definition at line 232 of file qdnd_p.h.

232 { return drag ? drag->d_func() : 0; }

◆ drop()

void QDragManager::drop ( )

Definition at line 287 of file qdnd_mac.mm.

Referenced by QOleDropTarget::Drop(), and findRealWindow().

288 {
289 }

◆ emitActionChanged()

void QDragManager::emitActionChanged ( Qt::DropAction  newAction)
inline

Definition at line 253 of file qdnd_p.h.

Referenced by QOleDropSource::GiveFeedback(), handle_xdnd_status(), qt_mac_dnd_update_action(), and qt_xdnd_send_leave().

253 { if (object) emit object->actionChanged(newAction); }
#define emit
Definition: qobjectdefs.h:76

◆ eventFilter()

bool QDragManager::eventFilter ( QObject ,
QEvent  
)
privatevirtual

Filters events if this object has been installed as an event filter for the watched object.

In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.

Example:

class MainWindow : public QMainWindow
{
public:
MainWindow();
protected:
bool eventFilter(QObject *obj, QEvent *ev);
private:
QTextEdit *textEdit;
};
MainWindow::MainWindow()
{
textEdit = new QTextEdit;
setCentralWidget(textEdit);
textEdit->installEventFilter(this);
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
if (obj == textEdit) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
qDebug() << "Ate key press" << keyEvent->key();
return true;
} else {
return false;
}
} else {
// pass the event on to the parent class
return QMainWindow::eventFilter(obj, event);
}
}

Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.

Warning
If you delete the receiver object in this function, be sure to return true. Otherwise, Qt will forward the event to the deleted object and the program might crash.
See also
installEventFilter()

Reimplemented from QObject.

Definition at line 263 of file qdnd_mac.mm.

Referenced by QOleDropTarget::Drop().

264 {
265  return false;
266 }

◆ hasCustomDragCursors()

bool QDragManager::hasCustomDragCursors ( ) const

Definition at line 188 of file qdnd.cpp.

Referenced by QOleDropSource::createCursors().

189 {
190  QDragPrivate * d = dragPrivate();
191  return d && !d->customCursors.isEmpty();
192 }
double d
Definition: qnumeric_p.h:62
QMap< Qt::DropAction, QPixmap > customCursors
Definition: qdnd_p.h:184
bool isEmpty() const
Returns true if the map contains no items; otherwise returns false.
Definition: qmap.h:203
QDragPrivate * dragPrivate() const
Definition: qdnd_p.h:231

◆ move()

void QDragManager::move ( const QPoint globalPos)

Definition at line 283 of file qdnd_mac.mm.

Referenced by QOleDropTarget::Drop(), and findRealWindow().

284 {
285 }

◆ self()

QDragManager * QDragManager::self ( )
static

◆ setCurrentTarget()

void QDragManager::setCurrentTarget ( QWidget target,
bool  dropped = false 
)

Definition at line 260 of file qdnd.cpp.

Referenced by QApplication::notify().

261 {
262  if (currentDropTarget == target)
263  return;
264 
265  currentDropTarget = target;
266  if (!dropped && object) {
267  object->d_func()->target = target;
268  emit object->targetChanged(target);
269  }
270 
271 }
#define emit
Definition: qobjectdefs.h:76
QWidget * currentDropTarget
Definition: qdnd_p.h:272

◆ source()

QWidget* QDragManager::source ( ) const
inline

Definition at line 230 of file qdnd_p.h.

Referenced by QOleDropTarget::DragOver(), QOleDropTarget::Drop(), QOleDropTarget::sendDragEnterEvent(), and QDropEvent::source().

230 { return object ? object->d_func()->source : 0; }

◆ timerEvent()

void QDragManager::timerEvent ( QTimerEvent event)
privatevirtual

This event handler can be reimplemented in a subclass to receive timer events for the object.

QTimer provides a higher-level interface to the timer functionality, and also more general information about timers. The timer event is passed in the event parameter.

See also
startTimer(), killTimer(), event()

Reimplemented from QObject.

Definition at line 259 of file qdnd_mac.mm.

Referenced by QOleDropTarget::Drop().

260 {
261 }

◆ updateCursor()

void QDragManager::updateCursor ( )

Definition at line 268 of file qdnd_mac.mm.

Referenced by handle_xdnd_status(), and qt_xdnd_send_leave().

269 {
270 }

◆ updatePixmap()

void QDragManager::updatePixmap ( )

Definition at line 696 of file qdnd_mac.mm.

Referenced by QOleDropTarget::Drop().

697 {
698 }

Friends and Related Functions

◆ QApplication

friend class QApplication
friend

Definition at line 215 of file qdnd_p.h.

◆ QDrag

friend class QDrag
friend

Definition at line 212 of file qdnd_p.h.

◆ QDragMoveEvent

friend class QDragMoveEvent
friend

Definition at line 213 of file qdnd_p.h.

◆ QDropEvent

friend class QDropEvent
friend

Definition at line 214 of file qdnd_p.h.

◆ QWidgetPrivate

friend class QWidgetPrivate
friend

Definition at line 217 of file qdnd_p.h.

Properties

◆ beingCancelled

bool QDragManager::beingCancelled

Definition at line 242 of file qdnd_p.h.

Referenced by QDragManager().

◆ currentActionForOverrideCursor

Qt::DropAction QDragManager::currentActionForOverrideCursor
private

Definition at line 265 of file qdnd_p.h.

Referenced by QDragManager().

◆ currentDropTarget

QWidget* QDragManager::currentDropTarget
private

Definition at line 272 of file qdnd_p.h.

Referenced by currentTarget(), QDragManager(), and setCurrentTarget().

◆ dropData

QDropData* QDragManager::dropData

◆ eventLoop

QEventLoop* QDragManager::eventLoop

Definition at line 245 of file qdnd_p.h.

Referenced by QDragManager().

◆ instance

QDragManager * QDragManager::instance = 0
staticprivate

Definition at line 274 of file qdnd_p.h.

Referenced by QDragManager(), self(), and ~QDragManager().

◆ object

QDrag* QDragManager::object

◆ restoreCursor

bool QDragManager::restoreCursor

Definition at line 243 of file qdnd_p.h.

Referenced by QDragManager(), and ~QDragManager().

◆ willDrop

bool QDragManager::willDrop

Definition at line 244 of file qdnd_p.h.

Referenced by handle_xdnd_status(), QDragManager(), and qt_xdnd_send_leave().

◆ xdndMimeTransferedPixmap

QPixmap QDragManager::xdndMimeTransferedPixmap[2]

Definition at line 259 of file qdnd_p.h.

Referenced by QX11Data::xdndMimeDataForAtom().

◆ xdndMimeTransferedPixmapIndex

int QDragManager::xdndMimeTransferedPixmapIndex

Definition at line 260 of file qdnd_p.h.

Referenced by QDragManager(), and QX11Data::xdndMimeDataForAtom().


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