Changeset 338
- Timestamp:
- Nov 22, 2009, 10:43:33 PM (16 years ago)
- Location:
- trunk/src/gui/kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gui/kernel/qmime.h
r337 r338 122 122 virtual ~QPMMime(); 123 123 124 125 126 127 128 129 130 124 131 // for converting from Qt 125 virtual QList< ULONG> formatsForMimeData(const QMimeData *mimeData) const = 0;132 virtual QList<> formatsForMimeData(const QMimeData *mimeData) const = 0; 126 133 virtual bool convertFromMimeData(const QMimeData *mimeData, ULONG format, 127 134 ULONG &flags, ULONG *data) const = 0; 128 129 typedef QPair<QString, ULONG> MimeCFPair;130 131 135 // for converting to Qt 132 136 virtual QList<MimeCFPair> mimesForFormats(const QList<ULONG> &formats) const = 0; … … 154 158 converter(c), mime(f), format(cf), priority(p) {} 155 159 156 Match(QPMMime *c, ULONG f, int p) :157 converter(c), format(f), priority(p) {}158 159 160 QPMMime *converter; 160 QString mime; // used by allConvertersFromFormats()161 ULONG format; // used by allConvertersFromFormats()/allConvertersFromMimeData()161 QString mime; 162 ULONG format; 162 163 int priority; 163 164 }; -
trunk/src/gui/kernel/qmime_pm.cpp
r337 r338 204 204 205 205 /*! 206 \fn QList< ULONG> QPMMime::formatsForMimeData(const QMimeData *mimeData) const206 \fn QList<> QPMMime::formatsForMimeData(const QMimeData *mimeData) const 207 207 208 208 Returns a list of ULONG values representing the different OS/2 PM … … 210 210 precedence (the most suitable format goes first), or an empty list if 211 211 neither of the mime types provided by \a mimeData is supported by this 212 converter. 212 converter. Note that each item in the returned list is actually a pair 213 consisting of the mime type name and the corresponding format identifier. 213 214 214 215 All subclasses must reimplement this pure virtual function. … … 250 251 of \a formats, in order of precedence (the most suitable mime type comes 251 252 first), or an empty list if neither of the \a formats is supported by this 252 converter. Note that each pair in the returned list consists of the mime253 type name and the corresponding format identifier.253 converter. Note that each 254 type name and the corresponding format identifier. 254 255 255 256 All subclasses must reimplement this pure virtual function. … … 283 284 for (; it != matches.end(); ++it) { 284 285 Match &match = *it; 285 if (match.mime == fmt. first) {286 if (match.mime == fmt.) { 286 287 // replace if priority is higher, ignore otherwise 287 288 if (priority < match.priority) { 288 289 match.converter = mime; 289 match.format = fmt. second;290 match.format = fmt.; 290 291 match.priority = priority; 291 292 } … … 294 295 } 295 296 if (it == matches.end()) { 296 matches += Match(mime, fmt. first, fmt.second, priority);297 matches += Match(mime, fmt., priority); 297 298 } 298 299 } … … 309 310 QList<QPMMime*> mimes = theMimeList()->mimes(); 310 311 foreach(QPMMime *mime, mimes) { 311 QList< ULONG> cfs = mime->formatsForMimeData(mimeData);312 QList<s = mime->formatsForMimeData(mimeData); 312 313 int priority = 0; 313 foreach ( ULONG cf, cfs) {314 foreach (s) { 314 315 ++priority; 315 316 QList<Match>::iterator it = matches.begin(); 316 317 for (; it != matches.end(); ++it) { 317 318 Match &match = *it; 318 if (match.format == cf) { 319 if (mime == mimes.last()) { // QPMMimeAnyMime? 320 if (match.mime == fmt.mime){ 321 // we assume that specialized converters (that come 322 // first) provide a more precise conversion than 323 // QPMMimeAnyMime and don't let it get into the list in 324 // order to avoid unnecessary duplicate representations 325 break; 326 } 327 } 328 if (match.format == fmt.format) { 319 329 // replace if priority is higher, ignore otherwise 320 330 if (priority < match.priority) { 321 331 match.converter = mime; 332 322 333 match.priority = priority; 323 334 } … … 326 337 } 327 338 if (it == matches.end()) { 328 matches += Match(mime, cf, priority);339 matches += Match(mime, , priority); 329 340 } 330 341 } … … 355 366 356 367 // for converting from Qt 357 QList< ULONG> formatsForMimeData(const QMimeData *mimeData) const;368 QList<> formatsForMimeData(const QMimeData *mimeData) const; 358 369 bool convertFromMimeData(const QMimeData *mimeData, ULONG format, 359 370 ULONG &flags, ULONG *data) const; … … 375 386 } 376 387 377 QList< ULONG> QPMMimeText::formatsForMimeData(const QMimeData *mimeData) const378 { 379 QList< ULONG> cfs;388 QList<> QPMMimeText::formatsForMimeData(const QMimeData *mimeData) const 389 { 390 QList<s; 380 391 if (mimeData->hasText()) 381 cfs << CF_TEXT << CF_TextUnicode; 382 return cfs; 392 fmts << MimeCFPair(QLatin1String("text/plain"), CF_TEXT) 393 << MimeCFPair(QLatin1String("text/plain"), CF_TextUnicode); 394 return fmts; 383 395 } 384 396 … … 477 489 // prefer unicode over local8Bit 478 490 if (cf == CF_TextUnicode) 479 mimes.prepend( qMakePair(QString(QLatin1String("text/plain")), cf));491 mimes.prepend(), cf)); 480 492 if (cf == CF_TEXT) 481 mimes.append( qMakePair(QString(QLatin1String("text/plain")), cf));493 mimes.append(), cf)); 482 494 } 483 495 return mimes; … … 535 547 536 548 // for converting from Qt 537 QList< ULONG> formatsForMimeData(const QMimeData *mimeData) const;549 QList<> formatsForMimeData(const QMimeData *mimeData) const; 538 550 bool convertFromMimeData(const QMimeData *mimeData, ULONG format, 539 551 ULONG &flags, ULONG *data) const; … … 581 593 } 582 594 583 QList< ULONG> QPMMimeAnyMime::formatsForMimeData(const QMimeData *mimeData) const584 { 585 QList< ULONG> cfs;595 QList<> QPMMimeAnyMime::formatsForMimeData(const QMimeData *mimeData) const 596 { 597 QList<s; 586 598 587 599 QStringList mimes = QInternalMimeData::formatsHelper(mimeData); … … 591 603 cf = registerMimeType(mime); 592 604 if (cf) 593 cfs << cf;594 } 595 596 return cfs;605 ; 606 } 607 608 return s; 597 609 } 598 610 … … 631 643 mime = registerFormat(format); 632 644 if (!mime.isEmpty()) 633 mimes << qMakePair(mime, format);645 mimes << Pair(mime, format); 634 646 } 635 647
Note:
See TracChangeset
for help on using the changeset viewer.