summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-07-12 23:57:26 (GMT)
committerMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-07-12 23:57:26 (GMT)
commitf0323c26d0a5a1a494b3ed5d1ca6df452df3507e (patch)
treeca5b7e1e96da5b9ea1de11b2d3a8935c800791f7
parent99b5688725343321aad1caa232cca97066681bdc (diff)
Fix duplicate mimetype elimination
-rw-r--r--core/document.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/core/document.cpp b/core/document.cpp
index af842e1..0ad18db 100644
--- a/core/document.cpp
+++ b/core/document.cpp
@@ -4281,7 +4281,22 @@ QStringList Document::supportedMimeTypes() const
{
result << md.mimeTypes();
}
- result.removeDuplicates();
+
+ // Remove duplicate mimetypes represented by different names
+ QMimeDatabase mimeDatabase;
+ QSet<QMimeType> uniqueMimetypes;
+ for (const QString &mimeName : result) {
+ uniqueMimetypes.insert(mimeDatabase.mimeTypeForName(mimeName));
+ }
+ result.clear();
+ for (const QMimeType &mimeType : uniqueMimetypes) {
+ result.append(mimeType.name());
+ }
+
+ // Sorting by mimetype name doesn't make a ton of sense,
+ // but ensures that the list is ordered the same way every time
+ qSort(result);
+
d->m_supportedMimeTypes = result;
}
return result;