VirtualBox

Ignore:
Timestamp:
Feb 26, 2014 9:48:29 AM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
92467
Message:

DnD: Windows build fix.

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  
    123123}
    124124
     125int 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
    125203#include "UIDnDDrag.moc"
    126204
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.cpp

    r50593 r50595  
    4040UIDnDMimeData::UIDnDMimeData(CSession &session, QStringList formats,
    4141                             Qt::DropAction defAction, Qt::DropActions actions,
    42                              QWidget *pParent)
     42                             UIDnDDrag *pParent)
    4343    : m_pParent(pParent)
    4444    , m_session(session)
     
    164164    {
    165165        AssertPtr(m_pParent);
    166         rc = retrieveDataInternal(strMIMEType, type, m_data);
     166        rc = m_pParent->RetrieveData(strMIMEType, type, m_data);
    167167        if (RT_SUCCESS(rc))
    168168        {
     
    179179                 rc, m_enmState));
    180180    return m_data;
    181 }
    182 
    183 int UIDnDMimeData::retrieveDataInternal(const QString &strMimeType,
    184                                         QVariant::Type vaType, QVariant &vaData) const
    185 {
    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 we
    193      * 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                 else
    243                     rc = VERR_NO_DATA;
    244             }
    245             else
    246                 msgCenter().cannotDropData(progress, m_pParent);
    247         }
    248         else
    249             rc = VERR_CANCELLED;
    250     }
    251     else
    252     {
    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;
    259181}
    260182
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.h

    r50593 r50595  
    6363    UIDnDMimeData(CSession &session, QStringList formats,
    6464                  Qt::DropAction defAction,
    65                   Qt::DropActions actions, QWidget *pParent);
     65                  Qt::DropActions actions, UIDnDDrag *pParent);
    6666
    6767    int setData(const QString &mimeType);
     
    101101private:
    102102
    103     QWidget          *m_pParent;
     103    UIDnDDrag        *m_pParent;
    104104    CSession          m_session;
    105105    QStringList       m_lstFormats;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette