[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdecore
From: David Faure <faure () kde ! org>
Date: 2007-03-26 12:01:04
Message-ID: 1174910464.939838.24314.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 646651 by dfaure:
Implicit inheritance from text/plain (for text/* mimetypes) and from \
application/octet-stream (for all file types) as written in the shared-mime spec.
M +14 -1 services/kmimetype.cpp
M +21 -1 tests/kmimetypetest.cpp
--- trunk/KDE/kdelibs/kdecore/services/kmimetype.cpp #646650:646651
@@ -490,7 +490,20 @@
QString KMimeType::parentMimeType() const
{
- return d->m_parentMimeType;
+ if (!d->m_parentMimeType.isEmpty())
+ return d->m_parentMimeType;
+ const QString myName = name();
+ const QString myGroup = myName.left(myName.indexOf('/'));
+ // All text/* types are subclasses of text/plain.
+ if (myGroup == "text" && myName != "text/plain")
+ return "text/plain";
+ // All real-file mimetypes implicitly derive from application/octet-stream
+ if (myGroup != "inode" &&
+ // kde extensions
+ myGroup != "all" && myGroup != "fonts" && myGroup != "media" && myGroup != \
"print" && myGroup != "uri" + && myName != "application/octet-stream")
+ return "application/octet-stream";
+ return QString();
}
bool KMimeType::is( const QString& mimeTypeName ) const
--- trunk/KDE/kdelibs/kdecore/tests/kmimetypetest.cpp #646650:646651
@@ -272,11 +272,31 @@
if ( !KSycoca::isAvailable() )
QSKIP( "ksycoca not available", SkipAll );
- // Check that text/x-patch knows that inherits from text/plain
+ // All file-like mimetypes inherit from octet-stream
+ const KMimeType::Ptr msword = KMimeType::mimeType("application/msword");
+ QVERIFY(msword);
+ QCOMPARE(msword->parentMimeType(), QString("application/octet-stream"));
+ QVERIFY(msword->is("application/octet-stream"));
+
+ const KMimeType::Ptr directory = KMimeType::mimeType("inode/directory");
+ QVERIFY(directory);
+ QCOMPARE(directory->parentMimeType(), QString());
+ QVERIFY(!directory->is("application/octet-stream"));
+
+ // Check that text/x-patch knows that it inherits from text/plain (it says so \
explicitely) const KMimeType::Ptr plain = KMimeType::mimeType( "text/plain" );
const KMimeType::Ptr derived = KMimeType::mimeType( "text/x-patch" );
QVERIFY( derived );
QCOMPARE( derived->parentMimeType(), plain->name() );
+ QVERIFY( derived->is("text/plain") );
+ QVERIFY( derived->is("application/octet-stream") );
+
+ // Check that text/mrml knows that it inherits from text/plain (implicitly)
+ const KMimeType::Ptr mrml = KMimeType::mimeType("text/mrml");
+ if (!mrml)
+ QSKIP("kdelibs not installed", SkipAll);
+ QVERIFY(mrml->is("text/plain"));
+ QVERIFY(mrml->is("application/octet-stream"));
}
// Helper method for all the trader tests
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic