本文整理汇总了C++中kmimetype::Ptr::parentMimeTypes方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::parentMimeTypes方法的具体用法?C++ Ptr::parentMimeTypes怎么用?C++ Ptr::parentMimeTypes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kmimetype::Ptr
的用法示例。
在下文中一共展示了Ptr::parentMimeTypes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testMimeTypeParent
void KMimeTypeTest::testMimeTypeParent()
{
// All file-like mimetypes inherit from octet-stream
const KMimeType::Ptr wordperfect = KMimeType::mimeType("application/vnd.wordperfect");
QVERIFY(wordperfect);
QCOMPARE(wordperfect->parentMimeTypes().join(","), QString("application/octet-stream"));
QVERIFY(wordperfect->is("application/octet-stream"));
QVERIFY(KMimeType::mimeType("image/svg+xml-compressed")->is("application/x-gzip"));
// Check that msword derives from ole-storage [it didn't in 0.20, but we added it to kde.xml]
const KMimeType::Ptr msword = KMimeType::mimeType("application/msword");
QVERIFY(msword);
const KMimeType::Ptr olestorage = KMimeType::mimeType("application/x-ole-storage");
QVERIFY(olestorage);
QVERIFY(msword->is(olestorage->name()));
QVERIFY(msword->is("application/octet-stream"));
const KMimeType::Ptr directory = KMimeType::mimeType("inode/directory");
QVERIFY(directory);
QCOMPARE(directory->parentMimeTypes().count(), 0);
QVERIFY(!directory->is("application/octet-stream"));
// Check that text/x-patch knows that it inherits from text/plain (it says so explicitly)
const KMimeType::Ptr plain = KMimeType::mimeType("text/plain");
const KMimeType::Ptr derived = KMimeType::mimeType("text/x-patch");
QVERIFY(derived);
QCOMPARE(derived->parentMimeTypes().join(","), plain->name());
QVERIFY(derived->is("text/plain"));
QVERIFY(derived->is("application/octet-stream"));
// Check that application/x-shellscript inherits from application/x-executable
// (Otherwise KRun cannot start shellscripts...)
// This is a test for multiple inheritance...
const KMimeType::Ptr shellscript = KMimeType::mimeType("application/x-shellscript");
QVERIFY(shellscript);
QVERIFY(shellscript->is("text/plain"));
QVERIFY(shellscript->is("application/x-executable"));
const QStringList shellParents = shellscript->parentMimeTypes();
QVERIFY(shellParents.contains("text/plain"));
QVERIFY(shellParents.contains("application/x-executable"));
QCOMPARE(shellParents.count(), 2); // only the above two
const QStringList allShellParents = shellscript->allParentMimeTypes();
QVERIFY(allShellParents.contains("text/plain"));
QVERIFY(allShellParents.contains("application/x-executable"));
QVERIFY(allShellParents.contains("application/octet-stream"));
// Must be least-specific last, i.e. breadth first.
QCOMPARE(allShellParents.last(), QString("application/octet-stream"));
// Check that text/x-mrml knows that it inherits from text/plain (implicitly)
const KMimeType::Ptr mrml = KMimeType::mimeType("text/x-mrml");
if (!mrml) {
QSKIP("kdelibs not installed");
}
QVERIFY(mrml->is("text/plain"));
QVERIFY(mrml->is("application/octet-stream"));
}