Changeset 50602 in vbox for trunk/src/VBox
- Timestamp:
- Feb 26, 2014 12:50:39 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDataObject_win.cpp
r50561 r50602 40 40 #include "UIDnDEnumFormat_win.h" 41 41 42 UIDnDDataObject::UIDnDDataObject(const QStringList &lstFormats, 43 UIDnDDrag *pParent) 44 : mpParent(pParent), 42 UIDnDDataObject::UIDnDDataObject(CSession &session, 43 const QStringList &lstFormats, 44 QWidget *pParent) 45 : mSession(session), 46 mpParent(pParent), 45 47 mStatus(Uninitialized), 46 48 mRefCount(1), … … 286 288 int rc; 287 289 if (!mVaData.isValid()) 288 rc = mpParent->RetrieveData(strMIMEType, vaType, mVaData); 290 { 291 rc = UIDnDDrag::RetrieveData(mSession, 292 DropAction::CopyAction, 293 strMIMEType, vaType, mVaData, 294 mpParent); 295 } 289 296 else 290 297 rc = VINF_SUCCESS; /* Data already retrieved. */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDataObject_win.h
r50561 r50602 45 45 public: 46 46 47 UIDnDDataObject( const QStringList &lstFormats, UIDnDDrag*pParent);47 UIDnDDataObject(CSession &session, const QStringList &lstFormats, QWidget *pParent); 48 48 virtual ~UIDnDDataObject(void); 49 49 … … 81 81 LONG lindex = -1, DWORD dwAspect = DVASPECT_CONTENT, DVTARGETDEVICE *pTargetDevice = NULL); 82 82 83 UIDnDDrag *mpParent; 83 QWidget *mpParent; 84 CSession mSession; 84 85 Status mStatus; 85 86 LONG mRefCount; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDrag.cpp
r50595 r50602 44 44 #endif 45 45 46 UIDnDDrag::UIDnDDrag(CSession &session, const QStringList &lstFormats, 46 UIDnDDrag::UIDnDDrag(CSession &session, 47 const QStringList &lstFormats, 47 48 Qt::DropAction defAction, Qt::DropActions actions, 48 QWidget *pParent) 49 : m_pParent(pParent) 50 , m_session(session) 49 QWidget *pParent /* = NULL */) 50 : m_session(session) 51 51 , m_lstFormats(lstFormats) 52 52 , m_defAction(defAction) 53 53 , m_actions(actions) 54 , m_pParent(pParent) 54 55 #ifndef RT_OS_WINDOWS 55 56 , pMData(NULL) … … 70 71 int rc = VINF_SUCCESS; 71 72 #ifdef RT_OS_WINDOWS 72 UIDnDDropSource *pDropSource = new UIDnDDropSource( this /* pParent */);73 UIDnDDataObject *pDataObject = new UIDnDDataObject(m_ lstFormats, this /* pParent */);73 UIDnDDropSource *pDropSource = new UIDnDDropSource(m_pParent); 74 UIDnDDataObject *pDataObject = new UIDnDDataObject(m_session, m_lstFormats, m_pParent); 74 75 75 76 DWORD dwOKEffects = DROPEFFECT_NONE; … … 98 99 99 100 /* pMData is transfered to the QDrag object, so no need for deletion. */ 100 pMData = new UIDnDMimeData(m_session, m_lstFormats, 101 m_defAction, m_actions, m_pParent); 101 pMData = new UIDnDMimeData(m_session, 102 m_lstFormats, m_defAction, m_actions, 103 m_pParent); 102 104 103 105 /* Inform the MIME data object of any changes in the current action. */ … … 123 125 } 124 126 125 int UIDnDDrag::RetrieveData(const QString &strMimeType, 126 QVariant::Type vaType, QVariant &vaData) 127 /* static */ 128 int UIDnDDrag::RetrieveData(const CSession &session, 129 Qt::DropAction dropAction, 130 const QString &strMimeType, 131 QVariant::Type vaType, QVariant &vaData, 132 QWidget *pParent) 127 133 { 128 134 LogFlowFunc(("Retrieving data as type=%s (variant type=%ld)\n", … … 130 136 131 137 int rc = VINF_SUCCESS; 132 CGuest guest = m_session.GetConsole().GetGuest();138 CGuest guest = session.GetConsole().GetGuest(); 133 139 134 140 /* Start getting the data from the guest. First inform the guest we 135 141 * want the data in the specified MIME type. */ 136 142 CProgress progress = guest.DragGHDropped(strMimeType, 137 UIDnDHandler::toVBoxDnDAction( m_defAction));143 UIDnDHandler::toVBoxDnDAction(dropAction)); 138 144 if (guest.isOk()) 139 145 { 140 146 msgCenter().showModalProgressDialog(progress, 141 147 tr("Retrieving data ..."), ":/progress_dnd_gh_90px.png", 142 m_pParent);148 pParent); 143 149 if (!progress.GetCanceled()) 144 150 { … … 186 192 } 187 193 else 188 msgCenter().cannotDropData(progress, m_pParent);194 msgCenter().cannotDropData(progress, pParent); 189 195 } 190 196 else … … 193 199 else 194 200 { 195 msgCenter().cannotDropData(guest, m_pParent);201 msgCenter().cannotDropData(guest, pParent); 196 202 rc = VERR_GENERAL_FAILURE; /** @todo Fudge; do a GetResultCode() to rc translation. */ 197 203 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDrag.h
r50593 r50602 45 45 public: 46 46 47 UIDnDDrag(CSession &session, const QStringList &lstFormats, 48 Qt::DropAction defAction, 49 Qt::DropActions actions, QWidget *pParent); 50 47 UIDnDDrag(CSession &session, 48 const QStringList &lstFormats, Qt::DropAction defAction, Qt::DropActions actions, 49 QWidget *pParent = NULL); 51 50 public: 52 51 53 52 int DoDragDrop(void); 54 53 55 int RetrieveData(const QString &strMimeType, 56 QVariant::Type vaType, QVariant &vaData); 54 public: 55 56 static int RetrieveData(const CSession &session, Qt::DropAction dropAction, const QString &strMimeType, QVariant::Type vaType, QVariant &vaData, QWidget *pParent); 57 57 58 58 private: 59 59 60 QWidget *m_pParent;61 60 CSession m_session; 62 61 QStringList m_lstFormats; 63 62 Qt::DropAction m_defAction; 64 63 Qt::DropActions m_actions; 64 QWidget *m_pParent; 65 65 #ifndef RT_OS_WINDOWS 66 66 UIDnDMimeData *pMData; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDropSource_win.cpp
r50460 r50602 32 32 #include "UIDnDDropSource_win.h" 33 33 34 UIDnDDropSource::UIDnDDropSource( UIDnDDrag*pParent)34 UIDnDDropSource::UIDnDDropSource(QWidget *pParent) 35 35 : mRefCount(1), 36 36 mpParent(pParent), -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDropSource_win.h
r50460 r50602 27 27 public: 28 28 29 UIDnDDropSource( UIDnDDrag*pParent);29 UIDnDDropSource(QWidget *pParent); 30 30 virtual ~UIDnDDropSource(void); 31 31 … … 48 48 49 49 LONG mRefCount; 50 UIDnDDrag*mpParent;50 QWidget *mpParent; 51 51 DWORD mdwCurEffect; 52 52 Qt::DropActions muCurAction; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.cpp
r50595 r50602 38 38 #include "UIMessageCenter.h" 39 39 40 UIDnDMimeData::UIDnDMimeData(CSession &session, QStringList formats, 40 UIDnDMimeData::UIDnDMimeData(CSession &session, 41 QStringList formats, 41 42 Qt::DropAction defAction, Qt::DropActions actions, 42 UIDnDDrag *pParent) 43 : m_pParent(pParent) 44 , m_session(session) 43 QWidget *pParent) 44 : m_Session(session) 45 45 , m_lstFormats(formats) 46 46 , m_defAction(defAction) 47 47 , m_actions(actions) 48 , m_pParent(pParent) 48 49 , m_enmState(Dragging) 49 , m_ data(QVariant::Invalid)50 , m_vaData(QVariant::Invalid) 50 51 { 51 52 LogFlowThisFuncEnter(); … … 108 109 109 110 QVariant UIDnDMimeData::retrieveData(const QString &strMIMEType, 110 QVariant::Type type) const111 QVariant::Type vaType) const 111 112 { 112 113 LogFlowFunc(("m_enmState=%d, mimeType=%s, type=%d (%s)\n", 113 114 m_enmState, strMIMEType.toStdString().c_str(), 114 type, QVariant::typeToName(type)));115 vaType, QVariant::typeToName(vaType))); 115 116 116 117 bool fCanDrop = true; … … 142 143 && !( 143 144 /* Plain text. */ 144 type == QVariant::String145 vaType == QVariant::String 145 146 /* Binary data. */ 146 || type == QVariant::ByteArray147 || vaType == QVariant::ByteArray 147 148 /* URI list. */ 148 || type == QVariant::List))149 || vaType == QVariant::List)) 149 150 { 150 151 LogFlowFunc(("Unsupported data type=%d (%s)\n", 151 type, QVariant::typeToName(type)));152 vaType, QVariant::typeToName(vaType))); 152 153 fCanDrop = false; 153 154 } … … 157 158 LogFlowFunc(("Skipping request, m_enmState=%d ...\n", 158 159 m_enmState)); 159 return QMimeData::retrieveData(strMIMEType, type);160 return QMimeData::retrieveData(strMIMEType, vaType); 160 161 } 161 162 … … 163 164 if (m_enmState == Dropped) 164 165 { 165 AssertPtr(m_pParent); 166 rc = m_pParent->RetrieveData(strMIMEType, type, m_data); 166 rc = UIDnDDrag::RetrieveData(m_Session, 167 m_defAction, 168 strMIMEType, vaType, m_vaData, 169 m_pParent); 167 170 if (RT_SUCCESS(rc)) 168 171 { … … 178 181 LogFlowFunc(("Returning rc=%Rrc, m_enmState=%ld\n", 179 182 rc, m_enmState)); 180 return m_ data;183 return m_vaData; 181 184 } 182 185 … … 236 239 { 237 240 LogFlowFunc(("mimeType=%s, dataType=%s\n", 238 mimeType.toAscii().constData(), m_ data.typeName()));241 mimeType.toAscii().constData(), m_vaData.typeName())); 239 242 240 243 int rc = VINF_SUCCESS; 241 244 242 switch (m_ data.type())245 switch (m_vaData.type()) 243 246 { 244 247 case QVariant::String: /* Plain text. */ 245 248 { 246 QMimeData::setText(m_ data.toString());249 QMimeData::setText(m_vaData.toString()); 247 250 break; 248 251 } … … 250 253 case QVariant::ByteArray: /* Raw byte data. */ 251 254 { 252 QMimeData::setData(mimeType, m_ data.toByteArray());255 QMimeData::setData(mimeType, m_vaData.toByteArray()); 253 256 break; 254 257 } … … 256 259 case QVariant::StringList: /* URI. */ 257 260 { 258 QList<QVariant> lstData = m_ data.toList();261 QList<QVariant> lstData = m_vaData.toList(); 259 262 QList<QUrl> lstURL; 260 263 for (int i = 0; i < lstData.size(); i++) -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.h
r50595 r50602 61 61 public: 62 62 63 UIDnDMimeData(CSession &session, QStringList formats, 64 Qt::DropAction defAction, 65 Qt::DropActions actions, UIDnDDrag *pParent); 63 UIDnDMimeData(CSession &session, QStringList formats, Qt::DropAction defAction, Qt::DropActions actions, QWidget *pParent); 64 65 public: 66 66 67 67 int setData(const QString &mimeType); … … 95 95 #endif 96 96 97 protected:98 99 int retrieveDataInternal(const QString &strMimeType, QVariant::Type vaType, QVariant &vaData) const;100 101 97 private: 102 98 103 UIDnDDrag *m_pParent; 104 CSession m_session; 99 CSession m_Session; 105 100 QStringList m_lstFormats; 106 101 Qt::DropAction m_defAction; 107 102 Qt::DropActions m_actions; 103 QWidget *m_pParent; 108 104 mutable State m_enmState; 109 mutable QVariant m_ data;105 mutable QVariant m_vaData; 110 106 }; 111 107
Note:
See TracChangeset
for help on using the changeset viewer.