UIDnDMimeData(CSession &session, QStringList formats, Qt::DropAction defAction, Qt::DropActions actions, QWidget *pParent) : m_pParent(pParent) , m_session(session) , m_formats(formats) , m_defAction(defAction) , m_actions(actions) , m_fState(Dragging) { /* This is unbelievable hacky, but I didn't found another way. Stupid * Qt QDrag interface is so less verbose, that we in principle know * nothing about what happens when the user drag something around. It * is possible that the target request data (s. retrieveData) while the * mouse button is still pressed. This isn't something we can support, * cause it would mean transferring the data from the guest while the * mouse is still moving (thing of a 2GB file ...). So the idea is to * detect the mouse release event and only after this happened, allow * data to be retrieved. Unfortunately the QDrag object eats all events * while a drag is going on (see QDragManager in the Qt src's). So what * we do, is installing an event filter after the QDrag::exec is called * to be last in the event filter queue and therefore called before the * one installed by the QDrag object. * * Todo: test this on all supported platforms (X11 works) */ QTimer::singleShot(0, this, SLOT(sltInstallEventFilter())); }
UIDnDMimeData::UIDnDMimeData(CSession &session, CDnDSource &dndSource, QStringList formats, Qt::DropAction defAction, Qt::DropActions actions, QWidget *pParent) : m_Session(session) , m_DnDSource(dndSource) , m_lstFormats(formats) , m_defAction(defAction) , m_actions(actions) , m_pParent(pParent) , m_enmState(Dragging) , m_vaData(QVariant::Invalid) { LogFlowThisFuncEnter(); /* * This is unbelievable hacky, but I didn't find another way. Stupid * Qt QDrag interface is so less verbose, that we in principle know * nothing about what happens when the user drag something around. It * is possible that the target on the host requests data * (@sa retrieveData) while the mouse button still is pressed. This * isn't something we should support, because it would mean transferring * the data from the guest while the mouse is still moving (think of * transferring a 2GB file from the guest to the host ...). So the idea is * to detect the mouse release event and only after this happened, allow * data to be retrieved. Unfortunately the QDrag object eats all events * while a drag is going on (see QDragManager in the Qt src's). * * So what we now are going to do is installing an event filter after the * QDrag::exec is called, so that this event filter then would be * the last in the event filter queue and therefore called before the * one installed by the QDrag object (which then in turn would * munch all events). * ** @todo Test this on all supported platforms (X11 works). * * Note: On Windows the above hack is not needed because as soon as Qt calls * OLE's DoDragDrop routine internally (via QtDrag::exec), no mouse * events will come through anymore. At this point DoDragDrop is modal * and will take care of all the input handling. */ #ifndef RT_OS_WINDOWS QTimer::singleShot(0, this, SLOT(sltInstallEventFilter())); #endif #ifdef DEBUG LogFlowFunc(("Number of formats: %d\n", formats.size())); for (int i = 0; i < formats.size(); i++) LogFlowFunc(("\tFormat %d: %s\n", i, formats.at(i).toAscii().constData())); #endif }