Changeset 96 for trunk/src/kernel/qdragobject.cpp
- Timestamp:
- Jul 6, 2006, 11:11:46 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel/qdragobject.cpp
r8 r96 607 607 608 608 switch ( i ) { 609 #if defined(Q_WS_PM) 610 // We want "text/whatever" w/o any charset to be the first (the "default") 611 // mime type of the QTextDrag object, so that a rendering mechanism/format 612 // pair for it will be the first in the RMF list, wchich is essential for 613 // some native drop targets (i.e. WPS) to render text correctly. Note that 614 // it won't hide unicode data from Qt apps because QTextDrag::decode() 615 // for Q_WS_PM prefers unicode mime types (see the implementation below). 616 case 0: 617 return ""; 618 case 1: 619 if ( localcharset.isNull() ) { 620 QTextCodec *localCodec = QTextCodec::codecForLocale(); 621 if ( localCodec ) { 622 localcharset = localCodec->name(); 623 localcharset = localcharset.lower(); 624 stripws(localcharset); 625 } else { 626 localcharset = ""; 627 } 628 } 629 return localcharset; 630 case 2: 631 return "UTF-8"; 632 case 3: 633 return "ISO-10646-UCS-2"; 634 #else 609 635 case 0: 610 636 return "UTF-8"; … … 625 651 } 626 652 return localcharset; 653 #endif 627 654 } 628 655 return 0; … … 898 925 } 899 926 927 #if defined(Q_WS_PM) 928 // We give Unicode formats a higher priority, so that if there are several 929 // encodings of the same subtype present in the given mime source, a 930 // Unicode one will be used for decoding. Otherwise, the first recognized 931 // format will be choosen. 932 int fallbackMime = -1; 933 bool secondPass = FALSE; 934 935 const char *mime; 936 for( int i = 0; /* FOREVER */; ++i ) { 937 mime = e->format( i ); 938 if ( !mime ) { 939 // We went through all mimes but didn't find Unicode. If there is 940 // a fall-back mime, iterate again starting directly from it. 941 if ( !secondPass && fallbackMime >= 0 ) { 942 i = fallbackMime - 1; // will do ++i on continue 943 secondPass = TRUE; 944 continue; 945 } 946 break; 947 } 948 #else 900 949 const char* mime; 901 950 for (int i=0; (mime = e->format(i)); i++) { 951 #endif 902 952 if ( 0==qstrnicmp(mime,"text/",5) ) { 903 953 QCString m(mime); … … 916 966 codec = qt_findcharset(m); 917 967 if ( codec ) { 968 #if defined(Q_WS_PM) 969 if ( codec->mibEnum() == 1000 /* ISO-10646-UCS-2 */ || 970 codec->mibEnum() == 106 /* UTF-8 */ ) { 971 // no need to try it again on the second pass 972 if ( secondPass ) 973 continue; 974 } else if ( !secondPass ) { 975 // memorize the fall-back mime on the first pass 976 if ( fallbackMime < 0 ) 977 fallbackMime = i; 978 continue; 979 } 980 #endif 918 981 QByteArray payload; 919 920 982 payload = e->encodedData(mime); 921 983 if ( payload.size() ) {
Note:
See TracChangeset
for help on using the changeset viewer.