UIDnDMIMEData.cpp revision 82391de567696f10b21a762fde6a06fe3c266d28
/* $Id$ */
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* UIDnDMIMEData class implementation
*/
/*
* Copyright (C) 2011-2014 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/* Qt includes: */
#include <QApplication>
#include <QFileInfo>
#include <QKeyEvent>
#include <QMimeData>
#include <QStringList>
#include <QTimer>
#include <QUrl>
#ifdef LOG_GROUP
#endif
#define LOG_GROUP LOG_GROUP_GUEST_DND
/* GUI includes: */
#include "UIDnDMIMEData.h"
#include "UIDnDDrag.h"
#include "UIMessageCenter.h"
{
/*
* 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
#endif
#ifdef DEBUG
#endif
}
{
}
{
return m_lstFormats;
}
{
LogFlowFunc(("%s: %RTbool (QtMimeData: %RTbool)\n",
return fRc;
}
{
LogFlowFunc(("m_enmState=%d, mimeType=%s, type=%d (%s)\n",
bool fCanDrop = true;
#ifdef RT_OS_WINDOWS
/* On Windows this function will be called several times by Qt's
* OLE-specific internals to figure out which data formats we have
* to offer. So just assume we can drop data here for a start.* */
fCanDrop = true;
#else
/* On non-Windows our state gets updated via an own event filter
* (see UIDnDMimeData::eventFilter). This filter will update the current
* operation state for us (based on the mouse buttons). */
if (m_enmState != Dropped)
fCanDrop = false;
#endif
/* Do we support the requested MIME type? */
if ( fCanDrop
{
LogFlowFunc(("Unsupported MIME type=%s\n",
fCanDrop = false;
}
/* Supported types. See below in the switch statement. */
if ( fCanDrop
&& !(
/* Plain text. */
/* Binary data. */
/* URI list. */
{
LogFlowFunc(("Unsupported data type=%d (%s)\n",
fCanDrop = false;
}
if (!fCanDrop)
{
LogFlowFunc(("Skipping request, m_enmState=%d ...\n",
m_enmState));
}
int rc = VINF_SUCCESS;
if (m_enmState == Dropped)
{
if (RT_SUCCESS(rc))
{
/* Tell ourselves that data became available. */
}
else
{
}
}
LogFlowFunc(("Returning rc=%Rrc, m_enmState=%ld\n",
rc, m_enmState));
}
#ifndef RT_OS_WINDOWS
{
if (pEvent)
{
{
#ifdef DEBUG_andy
{
LogFlowFunc(("MouseMove: x=%d, y=%d, buttons=0x%x\n",
break;
}
#endif
case QEvent::MouseButtonRelease:
{
LogFlowFunc(("MouseButtonRelease\n"));
break;
}
{
/* ESC pressed? */
{
LogFlowFunc(("ESC pressed, cancelling drag'n drop operation\n"));
}
break;
}
default:
break;
}
}
/* Propagate the event further. */
return false;
}
void UIDnDMimeData::sltInstallEventFilter(void)
{
LogFlowFunc(("Installing event filter ...\n"));
qApp->installEventFilter(this);
}
#endif /* RT_OS_WINDOWS */
{
LogFlowFunc(("mimeType=%s, dataType=%s\n",
int rc = VINF_SUCCESS;
{
{
break;
}
{
break;
}
{
{
#ifdef DEBUG
LogFlowFunc(("\tURL: %s (fExists=%RTbool, fIsDir=%RTbool, cb=%RU64)\n",
#endif
}
if (RT_SUCCESS(rc))
break;
}
default:
break;
}
return rc;
}
#include "UIDnDMIMEData.moc"