Changeset 444 for trunk/src/gui/kernel
- Timestamp:
- Dec 30, 2009, 2:32:09 AM (15 years ago)
- Location:
- trunk/src/gui/kernel
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gui/kernel/qdnd_pm.cpp
r442 r444 57 57 #include "qt_os2.h" 58 58 59 #define QDND_DEBUG // in pair with qmime_pm.cpp59 #define QDND_DEBUG // in pair with qmime_pm.cpp 60 60 61 61 #ifdef QDND_DEBUG … … 89 89 bool hasFormat_sys(const QString &mimeType); 90 90 QStringList formats_sys(); 91 QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type); 91 QVariant retrieveData_sys(const QString &mimeType, 92 QVariant::Type preferredType); 92 93 93 94 private: … … 209 210 210 211 QVariant QPMDragData::retrieveData_sys(const QString &mimeType, 211 QVariant::Type type)212 QVariant::Type ype) 212 213 { 213 214 QVariant result; … … 222 223 foreach (QPMMime::DropWorker *w, workers) { 223 224 if (w->hasFormat(mimeType)) { 224 result = w->retrieveData(mimeType, type);225 result = w->retrieveData(mimeType, ype); 225 226 break; 226 227 } … … 270 271 MRESULT qt_dispatchDragAndDrop(QWidget *widget, const QMSG &qmsg) 271 272 { 272 // @todo maybe delete last*Op variables 273 274 static HWND lastDragOverHwnd = 0; // last target window 273 static QWidget *lastDragOverWidget = 0; // last target widget 275 274 static USHORT lastDragOverOp = 0; // last DM_DRAGOVER operation 276 275 277 276 static USHORT supportedOps = 0; // operations supported by all items 277 278 278 279 279 static USHORT lastDropReply = DOR_NEVERDROP; // last reply to DM_DRAGOVER 280 280 static USHORT lastOpRequest = DO_UNKNOWN; // last op requested in DM_DRAGOVER 281 281 282 static Qt::DropAction lastProposedAction = Qt:: IgnoreAction; // last proposed action282 static Qt::DropAction lastProposedAction = Qt::Action; // last proposed action 283 283 static QRect lastAnswerRect; // last accepted rectangle from the target 284 284 // @todo use lastAnswerRect to compress DM_DRAGOVER events … … 289 289 290 290 BOOL ok = FALSE; 291 292 291 293 292 294 switch (qmsg.msg) { … … 294 296 DEBUG(("DM_DRAGOVER: hwnd %lX di %p x %d y %d", qmsg.hwnd, qmsg.mp1, 295 297 SHORT1FROMMP(qmsg.mp2), SHORT2FROMMP(qmsg.mp2))); 296 297 bool first = lastDragOverHwnd != qmsg.hwnd;298 if (first) {299 // the first DM_DRAGOVER message300 lastDragOverHwnd = qmsg.hwnd;301 lastDropReply = DOR_NEVERDROP;302 lastOpRequest = DO_UNKNOWN;303 lastProposedAction = Qt::IgnoreAction;304 lastAnswerRect = QRect();305 supportedOps = DO_COPYABLE | DO_MOVEABLE | DO_LINKABLE;306 // ensure drag data is reset (just in case of a wrong msg flow...)307 dragData.reset();308 }309 310 Q_ASSERT(first || widget->acceptDrops());311 if (!widget->acceptDrops()) {312 if (!first) {313 // Odin32 apps are dramatically bogus, they continue to send314 // DM_DRAGOVER even if we reply DOR_NEVERDROP. Simulate315 // DM_DRAGLEAVE316 lastDragOverHwnd = 0;317 dragData.reset();318 }319 return MRFROM2SHORT(DOR_NEVERDROP, 0);320 }321 298 322 299 DRAGINFO *info = (DRAGINFO *)qmsg.mp1; … … 325 302 if (!ok || !info) 326 303 return MRFROM2SHORT(DOR_NEVERDROP, 0); 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 327 350 328 351 USHORT dropReply = DOR_DROP; … … 352 375 if (dropReply != DOR_NEVERDROP) { 353 376 354 bool sourceAllowsOp = false;355 356 377 if (first || lastDragOverOp != info->usOperation) { 357 378 // the current drop operation was changed by a modifier key … … 373 394 // the drop. Other platforms seem to do the same. 374 395 375 // flip y coordinate376 QPoint pnt(info->xDrop, info->yDrop);377 pnt.setY(QApplication::desktop()->height() - (pnt.y() + 1));378 pnt = widget->mapFromGlobal(pnt);379 380 QDragManager *manager = QDragManager::self();381 396 QMimeData *data = manager->source() ? manager->dragPrivate()->data : manager->dropData; 382 397 … … 388 403 QApplication::mouseButtons(), 389 404 QApplication::keyboardModifiers()); 390 QApplication::sendEvent( widget, &dee);405 QApplication::sendEvent(idget, &dee); 391 406 // if not allowed or not accepted, always reply DOR_NODROP 392 // to have DM_DRAGOVER delivered to us again in any case407 // to have DM_DRAGOVER delivered to us again 393 408 if (sourceAllowsOp && dee.isAccepted()) { 394 409 dropReply = DOR_DROP; 395 410 action = dee.dropAction(); 411 396 412 lastAnswerRect = dee.answerRect(); 397 413 } else { … … 410 426 dme.setDropAction(action); 411 427 dme.accept(); 412 QApplication::sendEvent( widget, &dme);428 QApplication::sendEvent(idget, &dme); 413 429 if (sourceAllowsOp && dme.isAccepted()) { 414 430 dropReply = DOR_DROP; 415 431 action = dme.dropAction(); 432 433 416 434 } else { 417 435 dropReply = DOR_NODROP; … … 431 449 432 450 // Odin32 apps produce incorrect message flow, ignore 433 Q_ASSERT(lastDragOver Hwnd!= 0);434 if (lastDragOver Hwnd== 0)451 Q_ASSERT(lastDragOver != 0); 452 if (lastDragOver == 0) 435 453 return 0; 436 454 437 lastDragOverHwnd = 0; 455 QDragLeaveEvent de; 456 QApplication::sendEvent(lastDragOverWidget, &de); 457 458 lastDragOverWidget = 0; 438 459 dragData.reset(); 439 460 440 if (!widget->acceptDrops())441 return 0;442 443 QDragLeaveEvent de;444 QApplication::sendEvent(widget, &de);445 461 return 0; 446 462 } … … 449 465 450 466 // Odin32 apps produce incorrect message flow, ignore 451 Q_ASSERT(lastDragOver Hwnd!= 0);452 if (lastDragOver Hwnd== 0)467 Q_ASSERT(lastDragOver != 0); 468 if (lastDragOver == 0) 453 469 return 0; 454 470 455 471 // Odin32 apps send DM_DROP even if we replied DOR_NEVERDROP or 456 472 // DOR_NODROP, simulate DM_DRAGLEAVE 457 Q_ASSERT(lastDropReply == DM_DROP); 458 if (lastDropReply != DM_DROP) { 459 WinSendMsg(qmsg.hwnd, DM_DRAGLEAVE, 0, 0); 473 Q_ASSERT(lastDropReply == DOR_DROP); 474 if (lastDropReply != DOR_DROP) { 475 QMSG qmsg2 = qmsg; 476 qmsg2.msg = DM_DRAGLEAVE; 477 qt_dispatchDragAndDrop(widget, qmsg2); 460 478 return 0; 461 479 } 462 463 lastDragOverHwnd = 0;464 465 Q_ASSERT(widget->acceptDrops());466 if (!widget->acceptDrops())467 return 0;468 480 469 481 DRAGINFO *info = (DRAGINFO *)qmsg.mp1; … … 471 483 Q_ASSERT(ok && info); 472 484 if (!ok || !info) 473 return MRFROM2SHORT(DOR_NEVERDROP, 0); 474 475 Q_ASSERT(lastOpRequest == info->usOperation); 485 return 0; 476 486 477 487 // flip y coordinate … … 480 490 pnt = widget->mapFromGlobal(pnt); 481 491 492 493 494 495 496 497 498 499 500 482 501 QDragManager *manager = QDragManager::self(); 483 502 QMimeData *data = manager->source() ? manager->dragPrivate()->data : manager->dropData; … … 492 511 de.setDropAction(action); 493 512 494 QApplication::sendEvent( widget, &de);513 QApplication::sendEvent(idget, &de); 495 514 496 515 if (lastDropReply == DOR_DROP) 497 516 de.accept(); 498 517 518 499 519 dragData.reset(de.isAccepted()); 500 520 -
trunk/src/gui/kernel/qmime.h
r443 r444 148 148 virtual HWND hwnd() const = 0; 149 149 // methods implemented if isExclusive() == TRUE and itemCount() == 0 150 virtual DRAGINFO *createDragInfo(const char *name, USHORT supportedOps)151 { return NULL; }150 virtual DRAGINFO *createDragInfo(const ame, USHORT supportedOps) 151 { return ; } 152 152 // methods implemented if itemCount() >= 0 153 153 virtual QByteArray composeFormatString() { return QByteArray(); } 154 154 virtual bool prepare(const char *drm, const char *drf, DRAGITEM *item, 155 ULONG itemIndex) { return FALSE; }155 ULONG itemIndex) { return ; } 156 156 virtual void defaultFileType(const char *&type, const char *&ext) {}; 157 157 … … 185 185 { 186 186 public: 187 virtual const QString &format(const char *drf) const = 0;187 virtual format(const char *drf) const = 0; 188 188 virtual bool provide(const char *drf, const QByteArray &allData, 189 189 ULONG itemIndex, QByteArray &itemData) = 0; … … 217 217 virtual bool hasFormat(const QString &mimeType) const = 0; 218 218 virtual QStringList formats() const = 0; 219 virtual QVariant retrieveData(const QString &mimeType, QVariant::Type type) const = 0; 219 virtual QVariant retrieveData(const QString &mimeType, 220 QVariant::Type preferredType) const = 0; 220 221 221 222 private: … … 236 237 bool hasFormat(const QString &mimeType) const; 237 238 QStringList formats() const; 238 QVariant retrieveData(const QString &mimeType, QVariant::Type type) const; 239 QVariant retrieveData(const QString &mimeType, 240 QVariant::Type preferredType) const; 239 241 240 242 // QPMObjectWindow interface -
trunk/src/gui/kernel/qmime_pm.cpp
r442 r444 60 60 #include "qdir.h" 61 61 62 #define QDND_DEBUG // in pair with qdnd_pm.cpp62 #define QDND_DEBUG // in pair with qdnd_pm.cpp 63 63 64 64 #ifdef QDND_DEBUG … … 769 769 } 770 770 771 // @todo 771 // @todo 772 772 //int QPMMime::DefaultDropWorker::formatCount() const 773 773 //{ … … 814 814 815 815 QVariant QPMMime::DefaultDropWorker::retrieveData(const QString &mimeType, 816 QVariant::Type type) const817 { 818 Q_UNUSED( type);819 820 DEBUG(() << "DefaultDropWorker::retrieveData (" << mimeType << ")");816 QVariant::Type ype) const 817 { 818 Q_UNUSED(ype); 819 820 DEBUG(() << "DefaultDropWorker::retrieveData); 821 821 822 822 QVariant ret; … … 1000 1000 bool ok = file.remove(); 1001 1001 Q_ASSERT((ok = ok)); 1002 1002 1003 } else { 1003 1004 Q_ASSERT(xfer->hstrRenderToName); … … 1088 1089 if (d->sending_DM_RENDER) 1089 1090 { 1091 1090 1092 DRAGTRANSFER *xfer = (DRAGTRANSFER *) mp1; 1091 #ifndef QT_NO_DEBUG1092 1093 qWarning("Drag item 0x%08lX sent DM_RENDERCOMPLETE w/o first " 1093 1094 "replying to DM_RENDER!\n" … … 1420 1421 All subclasses must reimplement this pure virtual function. 1421 1422 */ 1423 1424 1422 1425 1423 1426 // static … … 1788 1791 QPMMime::DefaultDragWorker *QPMMime::defaultExclDragWorker() 1789 1792 { 1790 static DefaultDragWorker defExclDragWorker( false /* exclusive */);1793 static DefaultDragWorker defExclDragWorker(e /* exclusive */); 1791 1794 return &defExclDragWorker; 1792 1795 } … … 1821 1824 QVariant::Type preferredType) const; 1822 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1823 1879 const ULONG CF_TextUnicode; 1824 1880 const ULONG CF_TextHtml; 1881 1882 1883 1884 1885 1886 1887 1825 1888 }; 1826 1889 … … 1999 2062 } 2000 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2001 2386 //////////////////////////////////////////////////////////////////////////////// 2002 2387
Note:
See TracChangeset
for help on using the changeset viewer.