Changeset 470 for trunk/src/gui/kernel
- Timestamp:
- Jan 23, 2010, 3:44:11 PM (16 years ago)
- Location:
- trunk/src/gui/kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gui/kernel/qdnd_pm.cpp
r469 r470 913 913 } 914 914 915 if (!mimeData->formats().count()) { 916 // The drag source doesn't provide any format, so we've got no workers. 917 // Although it may look strange, but it is a supported case: for 918 // example, designer uses it a lot for in-process DnD. Instead of MIME 919 // data, it works directly with the QMimeData object from the drag 920 // source. We will go through the converters passing a special value of 921 // QString::null as MIME type -- one of them (e.g. QPMAnyMime) should 922 // take it over and return itself. 923 Q_ASSERT(!workers.count()); 924 DEBUG(() << "QPMCoopDragWorker: Source provides NO data, looking for a " 925 "converter that can handle this"); 926 foreach (QPMMime *mime, QPMMime::all()) { 927 DragWorker *wrk = mime->dragWorkerFor(QString::null, mimeData); 928 if (wrk) { 929 workers.append(wrk); 930 break; 931 } 932 } 933 } 934 915 935 #if defined(QDND_DEBUG) 916 936 foreach (DragWorker *wrk, workers) { -
trunk/src/gui/kernel/qmime_pm.cpp
r465 r470 365 365 return formats; 366 366 367 // DRM_SHAREDMEM comes first to prevent native DRM_OS2FILE 368 // rendering on the target side w/o involving the source. 369 // Also, we add <DRM_SHAREDMEM,DRF_POINTERDATA> just like WPS does it 370 // (however, it doesn't help when dropping objects to it -- WPS still 371 // chooses DRM_OS2FILE). 372 formats = "(DRM_SHAREDMEM,DRM_OS2FILE)x(" + formats + ")," 373 "<DRM_SHAREDMEM,DRF_POINTERDATA>"; 367 if (qstrcmp(formats, "DRF_NULL") == 0) { 368 // special case, see QPMMimeAnyMime::dragWorkerFor() 369 formats = "<DRM_NULL," + formats + ">"; 370 } else { 371 // DRM_SHAREDMEM comes first to prevent native DRM_OS2FILE 372 // rendering on the target side w/o involving the source. 373 // Also, we add <DRM_SHAREDMEM,DRF_POINTERDATA> just like WPS does it 374 // (however, it doesn't help when dropping objects to it -- WPS still 375 // chooses DRM_OS2FILE). 376 formats = "(DRM_SHAREDMEM,DRM_OS2FILE)x(" + formats + ")," 377 "<DRM_SHAREDMEM,DRF_POINTERDATA>"; 378 } 374 379 375 380 DEBUG(() << "DefaultDragWorker: formats" << formats … … 477 482 << req->provider); 478 483 479 // We would li le to post WM_USER to ourselves to do actual rendering484 // We would like to post WM_USER to ourselves to do actual rendering 480 485 // after we return from DM_RENDER. But we are inside DrgDrag() at this 481 486 // point (our DND implementation is fully synchronous by design), so … … 483 488 // DrgDrag(). Thus, we have to send it. 484 489 485 WinSendMsg(hwnd(), WM_USER, MPFROMLONG(xfer->pditem->ulItemID),486 490 WinSendMsg(hwnd(), WM_USER, 491 MPFROMLONG(xfer->pditem->ulItemID), MPFROMP(req)); 487 492 488 493 return (MRESULT)TRUE; … … 827 832 if (!provider) 828 833 return ret; 834 835 if (mimeType.isEmpty()) { 836 // special case, see QPMMimeAnyMime::dropWorkerFor() 837 return ret; 838 } 829 839 830 840 QByteArray drf = provider->drf(mimeType); … … 1117 1127 Provider *provider) 1118 1128 { 1119 Q_ASSERT(!mimeType.isEmpty() && provider); 1120 if (!mimeType.isEmpty() && provider && !d->exclusive) { 1129 // note: as a special case, mimeType may be null (see 1130 // QPMCoopDragWorker::collectWorkers()) 1131 1132 Q_ASSERT(provider); 1133 if (provider && !d->exclusive) { 1121 1134 // ensure there are no dups (several providers for the same mime) 1122 1135 if (!d->providerFor(mimeType)) … … 1291 1304 { 1292 1305 ULONG cf = WinAddAtom(WinQuerySystemAtomTable(), mime.toLocal8Bit()); 1293 if (!cf) {1294 1306 #ifndef QT_NO_DEBUG 1307 if (!cf) 1295 1308 qWarning("QPMMime: WinAddAtom failed with 0x%lX", 1296 1309 WinGetLastError(NULLHANDLE)); 1297 1310 #endif 1298 return 0;1299 }1300 1311 1301 1312 return cf; … … 2723 2734 QString &type, QString &ext) 2724 2735 { 2725 // file type = mime 2726 type = format(drf); 2727 Q_ASSERT(!type.isEmpty()); 2736 if (qstrcmp(drf, "DRF_NULL") == 0) { 2737 // special case (see QPMMimeAnyMime::dragWorkerFor()) 2738 type = QString::null; 2739 } else { 2740 // file type = mime 2741 type = format(drf); 2742 Q_ASSERT(!type.isEmpty()); 2743 } 2728 2744 2729 2745 // no way to determine the extension … … 2759 2775 QMimeData *mimeData) 2760 2776 { 2777 if (mimeType.isEmpty()) { 2778 // special case: QMimeData with no formats() (see 2779 // QPMCoopDragWorker::collectWorkers()) 2780 Q_ASSERT(!mimeData->formats().count()); 2781 // add an exclusive provider with a special format DRF_NULL. Note that 2782 // any attemt to render this format should fail so we don't expect 2783 // AnyDragProvider::format()/provide() to be actually called. 2784 DefaultDragWorker *defWorker = defaultExclDragWorker(); 2785 defWorker->addProvider(QByteArray("DRF_NULL"), &anyDragProvider); 2786 return defWorker; 2787 } 2788 2761 2789 ULONG cf = cfMap.value(mimeType); 2762 2790 if (!cf) … … 2788 2816 DefaultDropWorker *defWorker = defaultDropWorker(); 2789 2817 bool atLeastOneSupported = false; 2818 2819 if (qstrcmp(queryHSTR(item->hstrRMF), "<DRM_NULL,DRF_NULL>") == 0) { 2820 // special case: QMimeData with no formats() (see 2821 // QPMCoopDragWorker::collectWorkers()), use a special MIME format 2822 // value of null. Note that any attemt to retrieve data in this 2823 // format should fail so we don't expect AnyDropProvider::drf()/ 2824 // provide() to be actually called. 2825 defWorker->addProvider(QString::null, &anyDropProvider); 2826 return defWorker; 2827 } 2790 2828 2791 2829 // check that we support one of DRMs and the format is CF_hhhhhhh … … 2864 2902 if (atomStr.startsWith(mimePrefix)) { 2865 2903 // the format represents the mime type we can recognize 2866 // increase the reference count2867 ULONG cf = QPMMime::registerMimeType(atomStr);2868 Q_ASSERT(cf == format);2869 2904 // extract the real mime type (w/o our prefix) 2870 2905 mime = atomStr.mid(mimePrefix.size()); 2906 Q_ASSERT(!mime.isEmpty()); 2871 2907 if (!mime.isEmpty()) { 2908 // increase the reference count (will decrease on destruction) 2909 ULONG cf = QPMMime::registerMimeType(atomStr); 2910 Q_ASSERT(cf == format); 2872 2911 cfMap[mime] = cf; 2873 2912 mimeMap[cf] = mime;
Note:
See TracChangeset
for help on using the changeset viewer.