summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qdnd.cpp35
1 files changed, 10 insertions, 25 deletions
diff --git a/src/gui/kernel/qdnd.cpp b/src/gui/kernel/qdnd.cpp
index 21f9b46654..a59612474b 100644
--- a/src/gui/kernel/qdnd.cpp
+++ b/src/gui/kernel/qdnd.cpp
@@ -149,17 +149,12 @@ Qt::DropAction QDragManager::drag(QDrag *o)
#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD))
-static QStringList imageReadMimeFormats()
+static QStringList imageMimeFormats(const QList<QByteArray> &imageFormats)
{
QStringList formats;
- QList<QByteArray> imageFormats = QImageReader::supportedImageFormats();
- const int numImageFormats = imageFormats.size();
- formats.reserve(numImageFormats);
- for (int i = 0; i < numImageFormats; ++i) {
- QString format = QLatin1String("image/");
- format += QString::fromLatin1(imageFormats.at(i).toLower());
- formats.append(format);
- }
+ formats.reserve(imageFormats.size());
+ for (const auto &format : imageFormats)
+ formats.append(QLatin1String("image/") + QLatin1String(format.toLower()));
//put png at the front because it is best
int pngIndex = formats.indexOf(QLatin1String("image/png"));
@@ -169,25 +164,15 @@ static QStringList imageReadMimeFormats()
return formats;
}
-
-static QStringList imageWriteMimeFormats()
+static inline QStringList imageReadMimeFormats()
{
- QStringList formats;
- QList<QByteArray> imageFormats = QImageWriter::supportedImageFormats();
- const int numImageFormats = imageFormats.size();
- formats.reserve(numImageFormats);
- for (int i = 0; i < numImageFormats; ++i) {
- QString format = QLatin1String("image/");
- format += QString::fromLatin1(imageFormats.at(i).toLower());
- formats.append(format);
- }
+ return imageMimeFormats(QImageReader::supportedImageFormats());
+}
- //put png at the front because it is best
- int pngIndex = formats.indexOf(QLatin1String("image/png"));
- if (pngIndex != -1 && pngIndex != 0)
- formats.move(pngIndex, 0);
- return formats;
+static inline QStringList imageWriteMimeFormats()
+{
+ return imageMimeFormats(QImageWriter::supportedImageFormats());
}
QInternalMimeData::QInternalMimeData()