Changeset 337
- Timestamp:
- Nov 22, 2009, 9:48:35 PM (16 years ago)
- Location:
- trunk/src/gui/kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gui/kernel/qmime.h
r334 r337 135 135 QVariant::Type preferredType) const = 0; 136 136 137 138 137 139 static ULONG registerMimeType(const QString &mime); 138 140 139 141 static ULONG allocateMemory(size_t size); 140 142 static void freeMemory(ULONG addr); 143 144 141 145 142 146 private: -
trunk/src/gui/kernel/qmime_pm.cpp
r335 r337 100 100 to MIME formats. 101 101 102 Qt has predefined support for the following PM Clipboard formats: 102 Qt has predefined support for the following PM Clipboard formats (custom 103 formats registered in the system atom table by name are given in double 104 quotes): 103 105 104 106 \table 105 107 \header \o PM Format \o Equivalent MIME type 106 \row \o \c CF_TEXT \o \c text/plain 107 \row \o \c CF_BITMAP \o \c{image/xyz}, where \c xyz is 108 a \l{QImageWriter::supportedImageFormats()}{Qt image format} 108 \row \o \c CF_TEXT \o \c text/plain (system codepage, 109 zero-terminated string) 110 \row \o \c "text/unicode" \o \c text/plain (16-bit Unicode, Mozilla-compatible, 111 zero-terminated string) 112 \row \o \c CF_BITMAP \o \c{image/xyz}, where \c xyz is 113 a \l{QImageWriter::supportedImageFormats()}{Qt image format} 114 \row \o \c "x-mime:<mime>" \o data in the format corresponding to the given 115 MIME type \c <mime> 109 116 \endtable 110 117 111 An example use of this class would be to map the PM Metafile 112 clipboard format (\c CF_METAFILE) to and from the MIME type 118 Note that all "x-mime:<mime>" formats use the CFI_POINTER storage type. That 119 is, the clipboard contains a pointer to the memory block containing the MIME 120 data in the corresponding format. The first 4 bytes of this memory block 121 always contain the length of the subsequent MIME data array, in bytes. 122 123 An example use of this class by the user application would be to map the 124 PM Metafile clipboard format (\c CF_METAFILE) to and from the MIME type 113 125 \c{image/x-metafile}. This conversion might simply be adding or removing a 114 126 header, or even just passing on the data. See \l{Drag and Drop} for more … … 167 179 ULONG data = 0; 168 180 169 // allocate giveable memory for the array + dword for its size170 APIRET arc = DosAllocSharedMem((PVOID *)&data, NULL, size + 4,181 // allocate giveable memory for the array 182 APIRET arc = DosAllocSharedMem((PVOID *)&data, NULL, size, 171 183 PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE); 172 184 if (arc != NO_ERROR) { … … 177 189 } 178 190 179 /// @todo I think we don't need it any more180 #if 0181 // get the size rounded to the page boundary (4K)182 ULONG sz = ~0, flags = 0;183 arc = DosQueryMem((PVOID)(data + size - 1), &sz, &flags);184 if (arc != NO_ERROR) {185 #ifndef QT_NO_DEBUG186 qWarning("QPMMime::allocateMemory: DosQueryMem failed with %lu", arc);187 #endif188 DosFreeMem((PVOID)data);189 return 0;190 }191 sz += (size - 1);192 // store the exact size to the last dword of the last page193 *(((ULONG *)(data + sz)) - 1) = size;194 #endif195 196 191 return data; 197 192 } … … 226 221 Converts the \a mimeData to the specified \a format. 227 222 228 If \a data is not NULL, a handle to the converted data should then beplaced223 If \a data is not NULL, a handle to the converted data should placed 229 224 in a variable pointed to by \a data and with the necessary flags describing 230 225 the handle returned in the \a flags variable. 231 226 232 The following flags describing the data type are recognized:227 The following flags describing the data type are recognized: 233 228 234 229 \table … … 280 275 281 276 QList<QPMMime*> mimes = theMimeList()->mimes(); 282 for (int i = mimes.size()-1; i >= 0; --i) {283 QList<MimeCFPair> fmts = mime s[i]->mimesForFormats(formats);277 for) { 278 QList<MimeCFPair> fmts = mime->mimesForFormats(formats); 284 279 int priority = 0; 285 280 foreach (MimeCFPair fmt, fmts) { … … 291 286 // replace if priority is higher, ignore otherwise 292 287 if (priority < match.priority) { 293 match.converter = mime s[i];288 match.converter = mime; 294 289 match.format = fmt.second; 295 290 match.priority = priority; … … 299 294 } 300 295 if (it == matches.end()) { 301 matches += Match(mime s[i], fmt.first, fmt.second, priority);296 matches += Match(mime, fmt.first, fmt.second, priority); 302 297 } 303 298 } … … 313 308 314 309 QList<QPMMime*> mimes = theMimeList()->mimes(); 315 for (int i = mimes.size()-1; i >= 0; --i) {316 QList<ULONG> cfs = mime s[i]->formatsForMimeData(mimeData);310 for) { 311 QList<ULONG> cfs = mime->formatsForMimeData(mimeData); 317 312 int priority = 0; 318 313 foreach (ULONG cf, cfs) { … … 324 319 // replace if priority is higher, ignore otherwise 325 320 if (priority < match.priority) { 326 match.converter = mime s[i];321 match.converter = mime; 327 322 match.priority = priority; 328 323 } … … 331 326 } 332 327 if (it == matches.end()) { 333 matches += Match(mime s[i], cf, priority);328 matches += Match(mime, cf, priority); 334 329 } 335 330 } … … 337 332 338 333 return matches; 334 335 336 337 338 339 340 341 342 343 344 345 346 339 347 } 340 348 … … 346 354 QPMMimeText(); 347 355 356 348 357 QList<ULONG> formatsForMimeData(const QMimeData *mimeData) const; 349 358 bool convertFromMimeData(const QMimeData *mimeData, ULONG format, 350 359 ULONG &flags, ULONG *data) const; 351 360 361 352 362 QList<MimeCFPair> mimesForFormats(const QList<ULONG> &formats) const; 353 363 QVariant convertFromFormat(ULONG format, ULONG flags, ULONG data, … … 519 529 //////////////////////////////////////////////////////////////////////////////// 520 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 521 721 QPMMimeList::QPMMimeList() 522 722 : initialized(false) … … 535 735 if (!initialized) { 536 736 initialized = true; 737 537 738 new QPMMimeText; 538 739 } … … 542 743 { 543 744 init(); 544 list. append(mime);745 list.pend(mime); 545 746 } 546 747
Note:
See TracChangeset
for help on using the changeset viewer.