- Timestamp:
- Nov 22, 2009, 11:25:06 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gui/kernel/qmime_pm.cpp
r338 r339 108 108 \row \o \c CF_TEXT \o \c text/plain (system codepage, 109 109 zero-terminated string) 110 \row \o \c "text/unicode" \o \c text/plain (16-bit Unicode, Mozilla-compatible, 111 zero-terminated string) 110 \row \o \c "text/unicode" \o \c text/plain (16-bit Unicode, 111 zero-terminated string, Mozilla-compatible) 112 \row \o \c "text/html" \o \c text/html (16-bit Unicode, 113 zero-terminated string, Mozilla-compatible) 112 114 \row \o \c CF_BITMAP \o \c{image/xyz}, where \c xyz is 113 115 a \l{QImageWriter::supportedImageFormats()}{Qt image format} 114 116 \row \o \c "x-mime:<mime>" \o data in the format corresponding to the given 115 117 MIME type \c <mime> … … 377 379 378 380 const ULONG CF_TextUnicode; 381 const ULONG CF_TextHtml; 379 382 }; 380 383 381 384 QPMMimeText::QPMMimeText() 382 // "text/unicode" is what Mozilla uses to for unicode, so Qt apps will 383 // be able to interchange unicode text with Mozilla apps 385 // "text/unicode" is what Mozilla uses to for unicode 384 386 : CF_TextUnicode (registerMimeType(QLatin1String("text/unicode"))) 387 // "text/html" is what Mozilla uses to for HTML 388 , CF_TextHtml (registerMimeType(QLatin1String("text/html"))) 385 389 { 386 390 } … … 389 393 { 390 394 QList<MimeCFPair> fmts; 395 // prefer HTML as it's reacher 396 if (mimeData->hasHtml()) 397 fmts << MimeCFPair(QLatin1String("text/html"), CF_TextHtml); 398 // prefer unicode over local8Bit 391 399 if (mimeData->hasText()) 392 fmts << MimeCFPair(QLatin1String("text/plain"), CF_T EXT)393 << MimeCFPair(QLatin1String("text/plain"), CF_T extUnicode);400 fmts << MimeCFPair(QLatin1String("text/plain"), CF_TextUnicode) 401 << MimeCFPair(QLatin1String("text/plain"), CF_TEXT); 394 402 return fmts; 395 403 } … … 441 449 if (j < r.size()) 442 450 o[j] = '\0'; 443 } else if (format == CF_TextUnicode ) {451 } else if (format == CF_TextUnicode || CF_TextHtml) { 444 452 QString str = mimeData->text(); 445 453 const QChar *u = str.unicode(); … … 486 494 { 487 495 QList<MimeCFPair> mimes; 488 foreach(ULONG cf, formats) { 489 // prefer unicode over local8Bit 490 if (cf == CF_TextUnicode) 491 mimes.prepend(MimeCFPair(QLatin1String("text/plain"), cf)); 492 if (cf == CF_TEXT) 493 mimes.append(MimeCFPair(QLatin1String("text/plain"), cf)); 494 } 496 // prefer HTML as it's reacher 497 if (formats.contains(CF_TextHtml)) 498 mimes << MimeCFPair(QLatin1String("text/html"), CF_TextHtml); 499 // prefer unicode over local8Bit 500 if (formats.contains(CF_TextUnicode)) 501 mimes << MimeCFPair(QLatin1String("text/plain"), CF_TextUnicode); 502 if (formats.contains(CF_TEXT)) 503 mimes << MimeCFPair(QLatin1String("text/plain"), CF_TEXT); 495 504 return mimes; 496 505 } … … 502 511 QVariant ret; 503 512 504 // @todo why is it startsWith? the rest of the mime specification (encoding, 505 // etc) isn't taken into account... Anyway, copied the logic from Windows. 506 if (!mimeType.startsWith("text/plain")) 513 if (!mimeType.startsWith("text/plain") && 514 !mimeType.startsWith("text/html")) 507 515 return ret; 508 516 if (!(flags & CFI_POINTER) || !data) … … 526 534 } 527 535 str = QString::fromLocal8Bit(r); 528 } else if (format == CF_TextUnicode ) {536 } else if (format == CF_TextUnicode || CF_TextHtml) { 529 537 str = QString::fromUtf16((const unsigned short *)data); 530 538 str.replace(QLatin1String("\r\n"), QLatin1String("\n"));
Note:
See TracChangeset
for help on using the changeset viewer.