diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index 091837b8b4..49370bb31c 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -125,7 +125,6 @@ #include #include #include -#include #include #include #include @@ -1444,11 +1443,11 @@ QByteArray QImageReader::imageFormat(QIODevice *device) #ifndef QT_NO_IMAGEFORMATPLUGIN void supportedImageHandlerFormats(QFactoryLoader *loader, QImageIOPlugin::Capability cap, - QSet *result); + QList *result); void supportedImageHandlerMimeTypes(QFactoryLoader *loader, QImageIOPlugin::Capability cap, - QSet *result); + QList *result); #endif /*! @@ -1481,7 +1480,7 @@ void supportedImageHandlerMimeTypes(QFactoryLoader *loader, QList QImageReader::supportedImageFormats() { - QSet formats; + QList formats; for (int i = 0; i < _qt_NumFormats; ++i) formats << _qt_BuiltInFormats[i].extension; @@ -1489,12 +1488,9 @@ QList QImageReader::supportedImageFormats() supportedImageHandlerFormats(loader(), QImageIOPlugin::CanRead, &formats); #endif // QT_NO_IMAGEFORMATPLUGIN - QList sortedFormats; - for (QSet::ConstIterator it = formats.constBegin(); it != formats.constEnd(); ++it) - sortedFormats << *it; - - std::sort(sortedFormats.begin(), sortedFormats.end()); - return sortedFormats; + std::sort(formats.begin(), formats.end()); + formats.erase(std::unique(formats.begin(), formats.end()), formats.end()); + return formats; } /*! @@ -1508,7 +1504,7 @@ QList QImageReader::supportedImageFormats() QList QImageReader::supportedMimeTypes() { - QSet mimeTypes; + QList mimeTypes; for (int i = 0; i < _qt_NumFormats; ++i) mimeTypes << _qt_BuiltInFormats[i].mimeType; @@ -1516,12 +1512,9 @@ QList QImageReader::supportedMimeTypes() supportedImageHandlerMimeTypes(loader(), QImageIOPlugin::CanRead, &mimeTypes); #endif // QT_NO_IMAGEFORMATPLUGIN - QList sortedMimeTypes; - for (QSet::ConstIterator it = mimeTypes.constBegin(); it != mimeTypes.constEnd(); ++it) - sortedMimeTypes << *it; - - std::sort(sortedMimeTypes.begin(), sortedMimeTypes.end()); - return sortedMimeTypes; + std::sort(mimeTypes.begin(), mimeTypes.end()); + mimeTypes.erase(std::unique(mimeTypes.begin(), mimeTypes.end()), mimeTypes.end()); + return mimeTypes; } QT_END_NAMESPACE diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp index c12dbb6544..7b8af90357 100644 --- a/src/gui/image/qimagewriter.cpp +++ b/src/gui/image/qimagewriter.cpp @@ -678,7 +678,7 @@ bool QImageWriter::supportsOption(QImageIOHandler::ImageOption option) const #ifndef QT_NO_IMAGEFORMATPLUGIN void supportedImageHandlerFormats(QFactoryLoader *loader, QImageIOPlugin::Capability cap, - QSet *result) + QList *result) { typedef QMultiMap PluginKeyMap; typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator; @@ -687,6 +687,7 @@ void supportedImageHandlerFormats(QFactoryLoader *loader, const PluginKeyMapConstIterator cend = keyMap.constEnd(); int i = -1; QImageIOPlugin *plugin = 0; + result->reserve(result->size() + keyMap.size()); for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it) { if (it.key() != i) { i = it.key(); @@ -694,13 +695,13 @@ void supportedImageHandlerFormats(QFactoryLoader *loader, } const QByteArray key = it.value().toLatin1(); if (plugin && (plugin->capabilities(0, key) & cap) != 0) - result->insert(key); + result->append(key); } } void supportedImageHandlerMimeTypes(QFactoryLoader *loader, QImageIOPlugin::Capability cap, - QSet *result) + QList *result) { QList metaDataList = loader->metaData(); @@ -713,7 +714,7 @@ void supportedImageHandlerMimeTypes(QFactoryLoader *loader, const int keyCount = keys.size(); for (int k = 0; k < keyCount; ++k) { if (plugin && (plugin->capabilities(0, keys.at(k).toString().toLatin1()) & cap) != 0) - result->insert(mimeTypes.at(k).toString().toLatin1()); + result->append(mimeTypes.at(k).toString().toLatin1()); } } } @@ -746,7 +747,7 @@ void supportedImageHandlerMimeTypes(QFactoryLoader *loader, */ QList QImageWriter::supportedImageFormats() { - QSet formats; + QList formats; #ifndef QT_NO_IMAGEFORMAT_BMP formats << "bmp"; #endif @@ -770,12 +771,9 @@ QList QImageWriter::supportedImageFormats() supportedImageHandlerFormats(loader(), QImageIOPlugin::CanWrite, &formats); #endif // QT_NO_IMAGEFORMATPLUGIN - QList sortedFormats; - for (QSet::ConstIterator it = formats.constBegin(); it != formats.constEnd(); ++it) - sortedFormats << *it; - - std::sort(sortedFormats.begin(), sortedFormats.end()); - return sortedFormats; + std::sort(formats.begin(), formats.end()); + formats.erase(std::unique(formats.begin(), formats.end()), formats.end()); + return formats; } /*! @@ -788,7 +786,7 @@ QList QImageWriter::supportedImageFormats() */ QList QImageWriter::supportedMimeTypes() { - QSet mimeTypes; + QList mimeTypes; #ifndef QT_NO_IMAGEFORMAT_BMP mimeTypes << "image/bmp"; #endif @@ -814,12 +812,9 @@ QList QImageWriter::supportedMimeTypes() supportedImageHandlerMimeTypes(loader(), QImageIOPlugin::CanWrite, &mimeTypes); #endif // QT_NO_IMAGEFORMATPLUGIN - QList sortedMimeTypes; - for (QSet::ConstIterator it = mimeTypes.constBegin(); it != mimeTypes.constEnd(); ++it) - sortedMimeTypes << *it; - - std::sort(sortedMimeTypes.begin(), sortedMimeTypes.end()); - return sortedMimeTypes; + std::sort(mimeTypes.begin(), mimeTypes.end()); + mimeTypes.erase(std::unique(mimeTypes.begin(), mimeTypes.end()), mimeTypes.end()); + return mimeTypes; } QT_END_NAMESPACE