Changeset 56865 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jul 8, 2015 1:58:33 PM (10 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.cpp
r56555 r56865 45 45 , m_enmState(Dragging) 46 46 , m_vaData(QVariant::Invalid) 47 #ifdef RT_OS_DARWIN 48 , m_fCanDrop(false) 49 #endif 47 50 { 48 51 LogFlowThisFuncEnter(); 49 52 50 53 #ifdef DEBUG 51 LogFlowFunc(("Number of formats: %d\n", lstFormats.size())); 52 for (int i = 0; i < lstFormats.size(); i++) 53 LogFlowFunc(("\tFormat %d: %s\n", i, lstFormats.at(i).toAscii().constData())); 54 LogFlowFunc(("Number of formats: %d\n", m_lstFormats.size())); 55 for (int i = 0; i < m_lstFormats.size(); i++) 56 LogFlowFunc(("\tFormat %d: %s\n", i, m_lstFormats.at(i).toAscii().constData())); 57 #endif 58 59 #ifdef RT_OS_DARWIN 60 connect(this, SIGNAL(notifyDropped()), this, SLOT(sltDropped())); 54 61 #endif 55 62 } … … 57 64 QStringList UIDnDMIMEData::formats(void) const 58 65 { 66 LogFlowFuncEnter(); 59 67 return m_lstFormats; 60 68 } … … 62 70 bool UIDnDMIMEData::hasFormat(const QString &strMIMEType) const 63 71 { 64 bool fRc = (m_curAction != Qt::IgnoreAction); 72 bool fRc = false; 73 74 #ifdef RT_OS_DARWIN 75 if (strMIMEType.compare("application/x-qt-mime-type-name", Qt::CaseInsensitive) == 0) 76 fRc = true; 77 #endif 78 79 if (!fRc) 80 fRc = m_curAction != Qt::IgnoreAction; 81 65 82 LogFlowFunc(("%s: %RTbool (QtMimeData: %RTbool, curAction=0x%x)\n", 66 83 strMIMEType.toStdString().c_str(), fRc, QMimeData::hasFormat(strMIMEType), m_curAction)); 84 85 #ifdef RT_OS_DARWIN 86 /* 87 * On OS X hasFormat() only seems to get called on a successful 88 * drop, that is, if the host knows (and the user accepts) the drop operation. 89 * 90 * As we can't do here much since this is a const'ed function we're emitting a 91 * signal to ourselves in order to let us know that we can start receiving data 92 * from the guest within the next retrieveData() call. 93 */ 94 emit notifyDropped(); 95 #endif 96 67 97 return fRc; 68 98 } 99 100 #ifdef RT_OS_DARWIN 101 void UIDnDMIMEData::sltDropped(void) 102 { 103 LogFlowFuncEnter(); 104 m_fCanDrop = true; 105 } 106 #endif 69 107 70 108 /** … … 82 120 m_enmState, m_curAction, m_defAction, strMIMEType.toStdString().c_str(), vaType, QVariant::typeToName(vaType))); 83 121 84 bool fCanDrop = true; 122 bool fCanDrop = true; /* Accept by default. */ 85 123 86 124 #ifdef RT_OS_WINDOWS 87 /* On Windows this function will be called several times by Qt's 125 /* 126 * On Windows this function will be called several times by Qt's 88 127 * OLE-specific internals to figure out which data formats we have 89 * to offer. So just assume we can drop data here for a start.* */ 90 fCanDrop = true; 128 * to offer. So just assume we can drop data here for a start. 129 */ 130 #elif defined(RT_OS_DARWIN) 131 /* 132 * On OS X we rely on an internal flag which gets set in the overriden 133 * hasFormat() function. That function only gets called on a successful drop 134 * so that we can tell if we have to start receiving data the next time 135 * we come by here. 136 */ 137 fCanDrop = m_fCanDrop; 91 138 #else 92 /* On non-Windows our state gets updated via an own event filter 139 /* 140 * On non-Windows our state gets updated via an own event filter 93 141 * (see UIDnDMimeData::eventFilter). This filter will update the current 94 * operation state for us (based on the mouse buttons). */ 142 * operation state for us (based on the mouse buttons). 143 */ 95 144 if (m_curAction == Qt::IgnoreAction) 96 145 { … … 139 188 } 140 189 190 #ifdef RT_OS_DARWIN 191 LogFlowFunc(("Returning data for Cocoa\n")); 192 return QMimeData::retrieveData(strMIMEType, vaType); 193 #else 141 194 LogFlowFunc(("Skipping request, state=%RU32 ...\n", m_enmState)); 142 195 return QVariant(QVariant::Invalid); /* Return a NULL variant. */ 196 #endif 143 197 } 144 198 … … 204 258 m_curAction = dropAction; 205 259 } 206 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.h
r56555 r56865 67 67 int getData(const QString &strMIMEType, QVariant::Type vaType, QVariant &vaData) const; 68 68 69 #ifdef RT_OS_DARWIN 70 void notifyDropped(void) const; 71 #endif 72 69 73 public slots: 70 74 75 /** 76 * Slot indicating that the current drop target has been changed. 77 * @note Does not work on OS X. 78 */ 71 79 void sltDropActionChanged(Qt::DropAction dropAction); 80 81 #ifdef RT_OS_DARWIN 82 /** 83 * Slot indicating that the host wants us to drop the 84 * data from the guest to the host. 85 */ 86 void sltDropped(void); 87 #endif 72 88 73 89 protected: … … 111 127 mutable State m_enmState; 112 128 mutable QVariant m_vaData; 129 130 #ifdef RT_OS_DARWIN 131 /** Flag indicating whether we can drop data from the 132 * guest to the host or not. */ 133 bool m_fCanDrop; 134 #endif 113 135 }; 114 136
Note:
See TracChangeset
for help on using the changeset viewer.