diff --git a/keditfiletype/filetypedetails.cpp b/keditfiletype/filetypedetails.cpp --- a/keditfiletype/filetypedetails.cpp +++ b/keditfiletype/filetypedetails.cpp @@ -181,7 +181,10 @@ void FileTypeDetails::updateRemoveButton() { - removeExtButton->setEnabled(extensionLB->count()>0); + // The "main" glob pattern (the first glob pattern in the system-wide mime .xml file) + // will always be re-added by QMimeDatabase (see QMimeBinaryProvider::loadMimeTypePrivate() + // in qtbase upstream), even if the user the removes it; so no point removing it to begin with. + removeExtButton->setEnabled(extensionLB->currentRow() != 0); } void FileTypeDetails::updateIcon(const QString &icon) @@ -351,7 +354,7 @@ void FileTypeDetails::enableExtButtons() { - removeExtButton->setEnabled(true); + updateRemoveButton(); } void FileTypeDetails::refresh() diff --git a/keditfiletype/mimetypedata.cpp b/keditfiletype/mimetypedata.cpp --- a/keditfiletype/mimetypedata.cpp +++ b/keditfiletype/mimetypedata.cpp @@ -273,7 +273,6 @@ } QStringList storedPatterns = m_mimetype.globPatterns(); - storedPatterns.sort(); // see ctor if ( storedPatterns != m_patterns) { qDebug() << "Mimetype Patterns Dirty: old=" << storedPatterns << "m_patterns=" << m_patterns; @@ -517,11 +516,6 @@ void MimeTypeData::setPatterns(const QStringList &p) { m_patterns = p; - // Sort them, since update-mime-database doesn't respect order (order of globs file != order of xml), - // and this code says things like if (m_mimetype.patterns() == m_patterns). - // We could also sort in KMimeType::setPatterns but this would just slow down the - // normal use case (anything else than this KCM) for no good reason. - m_patterns.sort(); } bool MimeTypeData::matchesFilter(const QString& filter) const diff --git a/keditfiletype/tests/filetypestest.cpp b/keditfiletype/tests/filetypestest.cpp --- a/keditfiletype/tests/filetypestest.cpp +++ b/keditfiletype/tests/filetypestest.cpp @@ -145,14 +145,13 @@ QCOMPARE(data.minorType(), QStringLiteral("plain")); QVERIFY(!data.isMeta()); QStringList patterns = data.patterns(); - QVERIFY(patterns.contains(QStringLiteral("*.txt"))); + QVERIFY(patterns.contains(QStringLiteral("*.inf"))); QVERIFY(!patterns.contains(QStringLiteral("*.toto"))); // When the user changes the patterns const QStringList origPatterns = patterns; - patterns.removeAll(QStringLiteral("*.txt")); + patterns.removeAll(QStringLiteral("*.inf")); patterns.append(QStringLiteral("*.toto")); // yes, a french guy wrote this, as you can see - patterns.sort(); // for future comparisons QVERIFY(!data.isDirty()); data.setPatterns(patterns); QVERIFY(data.isDirty()); @@ -166,7 +165,6 @@ QCOMPARE(data.patterns(), patterns); // Check what's in QMimeDatabase QStringList newPatterns = db.mimeTypeForName(QStringLiteral("text/plain")).globPatterns(); - newPatterns.sort(); QCOMPARE(newPatterns, patterns); QVERIFY(!data.isDirty()); @@ -177,7 +175,6 @@ MimeTypeWriter::runUpdateMimeDatabase(); // Check what's in QMimeDatabase newPatterns = db.mimeTypeForName(QStringLiteral("text/plain")).globPatterns(); - newPatterns.sort(); QCOMPARE(newPatterns, origPatterns); } @@ -292,7 +289,7 @@ QMimeType mime = db.mimeTypeForName(mimeTypeName); QVERIFY(mime.isValid()); QCOMPARE(mime.comment(), QStringLiteral("Fake MimeType")); - QCOMPARE(mime.globPatterns(), patterns); // must sort them if more than one + QCOMPARE(mime.globPatterns(), patterns); // Testcase for the shaman.xml bug QCOMPARE(db.mimeTypeForFile(QStringLiteral("/whatever/foo.pkg.tar.gz")).name(), QStringLiteral("fake/unit-test-fake-mimetype"));