Changeset 50595 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Feb 26, 2014 9:48:29 AM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 92467
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDrag.cpp
r50593 r50595 123 123 } 124 124 125 int UIDnDDrag::RetrieveData(const QString &strMimeType, 126 QVariant::Type vaType, QVariant &vaData) 127 { 128 LogFlowFunc(("Retrieving data as type=%s (variant type=%ld)\n", 129 strMimeType.toAscii().constData(), vaType)); 130 131 int rc = VINF_SUCCESS; 132 CGuest guest = m_session.GetConsole().GetGuest(); 133 134 /* Start getting the data from the guest. First inform the guest we 135 * want the data in the specified MIME type. */ 136 CProgress progress = guest.DragGHDropped(strMimeType, 137 UIDnDHandler::toVBoxDnDAction(m_defAction)); 138 if (guest.isOk()) 139 { 140 msgCenter().showModalProgressDialog(progress, 141 tr("Retrieving data ..."), ":/progress_dnd_gh_90px.png", 142 m_pParent); 143 if (!progress.GetCanceled()) 144 { 145 rc = ( progress.isOk() 146 && progress.GetResultCode() == 0) 147 ? VINF_SUCCESS : VERR_GENERAL_FAILURE; /** @todo Fudge; do a GetResultCode() to rc translation. */ 148 149 if (RT_SUCCESS(rc)) 150 { 151 /* After the data successfully arrived from the guest, we query it from Main. */ 152 QVector<uint8_t> vecData = guest.DragGHGetData(); 153 if (!vecData.isEmpty()) 154 { 155 switch (vaType) 156 { 157 case QVariant::String: 158 { 159 vaData = QVariant(QString(reinterpret_cast<const char*>(vecData.constData()))); 160 break; 161 } 162 163 case QVariant::ByteArray: 164 { 165 QByteArray ba(reinterpret_cast<const char*>(vecData.constData()), vecData.size()); 166 vaData = QVariant(ba); 167 break; 168 } 169 170 case QVariant::StringList: 171 { 172 QString strData = QString(reinterpret_cast<const char*>(vecData.constData())); 173 QStringList lstString = strData.split("\r\n", QString::SkipEmptyParts); 174 175 vaData = QVariant(lstString); 176 break; 177 } 178 179 default: 180 rc = VERR_NOT_SUPPORTED; 181 break; 182 } 183 } 184 else 185 rc = VERR_NO_DATA; 186 } 187 else 188 msgCenter().cannotDropData(progress, m_pParent); 189 } 190 else 191 rc = VERR_CANCELLED; 192 } 193 else 194 { 195 msgCenter().cannotDropData(guest, m_pParent); 196 rc = VERR_GENERAL_FAILURE; /** @todo Fudge; do a GetResultCode() to rc translation. */ 197 } 198 199 LogFlowFuncLeaveRC(rc); 200 return rc; 201 } 202 125 203 #include "UIDnDDrag.moc" 126 204 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.cpp
r50593 r50595 40 40 UIDnDMimeData::UIDnDMimeData(CSession &session, QStringList formats, 41 41 Qt::DropAction defAction, Qt::DropActions actions, 42 QWidget*pParent)42 UIDnDDrag *pParent) 43 43 : m_pParent(pParent) 44 44 , m_session(session) … … 164 164 { 165 165 AssertPtr(m_pParent); 166 rc = retrieveDataInternal(strMIMEType, type, m_data);166 rc = m_pParent->RetrieveData(strMIMEType, type, m_data); 167 167 if (RT_SUCCESS(rc)) 168 168 { … … 179 179 rc, m_enmState)); 180 180 return m_data; 181 }182 183 int UIDnDMimeData::retrieveDataInternal(const QString &strMimeType,184 QVariant::Type vaType, QVariant &vaData) const185 {186 LogFlowFunc(("Retrieving data as type=%s (variant type=%ld)\n",187 strMimeType.toAscii().constData(), vaType));188 189 int rc = VINF_SUCCESS;190 CGuest guest = m_session.GetConsole().GetGuest();191 192 /* Start getting the data from the guest. First inform the guest we193 * want the data in the specified MIME type. */194 CProgress progress = guest.DragGHDropped(strMimeType,195 UIDnDHandler::toVBoxDnDAction(m_defAction));196 if (guest.isOk())197 {198 msgCenter().showModalProgressDialog(progress,199 tr("Retrieving data ..."), ":/progress_dnd_gh_90px.png",200 m_pParent);201 if (!progress.GetCanceled())202 {203 rc = ( progress.isOk()204 && progress.GetResultCode() == 0)205 ? VINF_SUCCESS : VERR_GENERAL_FAILURE; /** @todo Fudge; do a GetResultCode() to rc translation. */206 207 if (RT_SUCCESS(rc))208 {209 /* After the data successfully arrived from the guest, we query it from Main. */210 QVector<uint8_t> vecData = guest.DragGHGetData();211 if (!vecData.isEmpty())212 {213 switch (vaType)214 {215 case QVariant::String:216 {217 vaData = QVariant(QString(reinterpret_cast<const char*>(vecData.constData())));218 break;219 }220 221 case QVariant::ByteArray:222 {223 QByteArray ba(reinterpret_cast<const char*>(vecData.constData()), vecData.size());224 vaData = QVariant(ba);225 break;226 }227 228 case QVariant::StringList:229 {230 QString strData = QString(reinterpret_cast<const char*>(vecData.constData()));231 QStringList lstString = strData.split("\r\n", QString::SkipEmptyParts);232 233 vaData = QVariant(lstString);234 break;235 }236 237 default:238 rc = VERR_NOT_SUPPORTED;239 break;240 }241 }242 else243 rc = VERR_NO_DATA;244 }245 else246 msgCenter().cannotDropData(progress, m_pParent);247 }248 else249 rc = VERR_CANCELLED;250 }251 else252 {253 msgCenter().cannotDropData(guest, m_pParent);254 rc = VERR_GENERAL_FAILURE; /** @todo Fudge; do a GetResultCode() to rc translation. */255 }256 257 LogFlowFuncLeaveRC(rc);258 return rc;259 181 } 260 182 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.h
r50593 r50595 63 63 UIDnDMimeData(CSession &session, QStringList formats, 64 64 Qt::DropAction defAction, 65 Qt::DropActions actions, QWidget*pParent);65 Qt::DropActions actions, UIDnDDrag *pParent); 66 66 67 67 int setData(const QString &mimeType); … … 101 101 private: 102 102 103 QWidget*m_pParent;103 UIDnDDrag *m_pParent; 104 104 CSession m_session; 105 105 QStringList m_lstFormats;
Note:
See TracChangeset
for help on using the changeset viewer.