本文整理汇总了C++中kmimetype::Ptr::mainExtension方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::mainExtension方法的具体用法?C++ Ptr::mainExtension怎么用?C++ Ptr::mainExtension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kmimetype::Ptr
的用法示例。
在下文中一共展示了Ptr::mainExtension方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testFromThread
void KMimeTypeTest::testFromThread()
{
// Some simple tests to test more API from testThreads without using _data()
KMimeType::Ptr mime = KMimeType::mimeType("application/pdf");
QVERIFY(mime);
QCOMPARE(mime->mainExtension(), QString::fromLatin1(".pdf"));
}
示例2: saveFile
QString saveFile(KoDocument *document, const QString &filename, const QString &outname)
{
QString saveAs = outname;
// use the name and add -roundtrip
if (outname.isEmpty()) {
saveAs = filename;
int dotPos = saveAs.lastIndexOf('.');
if (dotPos != -1) {
saveAs.truncate(dotPos);
}
saveAs += "-roundtrip";
}
QByteArray mimetype = document->nativeFormatMimeType();
KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
Q_ASSERT(mime);
QString extension = mime->mainExtension();
saveAs += extension;
KUrl url;
url.setPath(saveAs);
document->setOutputMimeType(mimetype, 0);
document->saveAs(url);
kDebug(31000) << "save done";
return saveAs;
}
示例3: testPatterns
void KMimeTypeTest::testPatterns()
{
QFETCH(QString, mimeType);
QFETCH(QString, patterns);
QFETCH(QString, mainExtension);
KMimeType::Ptr mime = KMimeType::mimeType( mimeType );
QVERIFY(mime);
// Sort both lists; order is unreliable since shared-mime-info uses hashes internally.
QStringList expectedPatterns = patterns.split(';');
expectedPatterns.sort();
QStringList mimePatterns = mime->patterns();
if (mimeType == "application/vnd.oasis.opendocument.text" && mimePatterns.contains("*.fodt")) {
QSKIP("Skipping test which would fail due to an upstream bug, see https://bugs.freedesktop.org/show_bug.cgi?id=31242", SkipSingle);
}
if (mimeType == "application/vnd.oasis.opendocument.presentation" && mimePatterns.contains("*.fodp")) {
QSKIP("Skipping test which would fail due to an upstream bug, see https://bugs.freedesktop.org/show_bug.cgi?id=31242", SkipSingle);
}
// shared-mime-info 0.30 adds *,v to text/plain, let's add it from this test so that it works
// with older versions too.
if (mimeType == "text/plain" && !mimePatterns.contains("*,v"))
mimePatterns.append("*,v");
mimePatterns.sort();
QCOMPARE(mimePatterns.join(";"), expectedPatterns.join(";"));
QCOMPARE(mime->mainExtension(), mainExtension);
}
示例4: executeStrategy
void KNewFileMenuPrivate::executeStrategy()
{
m_tempFileToDelete = m_copyData.tempFileToDelete();
const QString src = m_copyData.sourceFileToCopy();
QString chosenFileName = expandTilde(m_copyData.chosenFileName(), true);
if (src.isEmpty())
return;
KUrl uSrc(src);
if (uSrc.isLocalFile()) {
// In case the templates/.source directory contains symlinks, resolve
// them to the target files. Fixes bug #149628.
KFileItem item(uSrc, QString(), KFileItem::Unknown);
if (item.isLink())
uSrc.setPath(item.linkDest());
if (!m_copyData.m_isSymlink) {
// If the file is not going to be detected as a desktop file, due to a
// known extension (e.g. ".pl"), append ".desktop". #224142.
QFile srcFile(uSrc.toLocalFile());
if (srcFile.open(QIODevice::ReadOnly)) {
KMimeType::Ptr wantedMime = KMimeType::findByUrl(uSrc);
KMimeType::Ptr mime = KMimeType::findByNameAndContent(m_copyData.m_chosenFileName, srcFile.read(1024));
//kDebug() << "mime=" << mime->name() << "wantedMime=" << wantedMime->name();
if (!mime->is(wantedMime->name()))
chosenFileName += wantedMime->mainExtension();
}
}
}
// The template is not a desktop file [or it's a URL one]
// Copy it.
KUrl::List::const_iterator it = m_popupFiles.constBegin();
for (; it != m_popupFiles.constEnd(); ++it)
{
KUrl dest(*it);
dest.addPath(KIO::encodeFileName(chosenFileName));
KUrl::List lstSrc;
lstSrc.append(uSrc);
KIO::Job* kjob;
if (m_copyData.m_isSymlink) {
kjob = KIO::symlink(src, dest);
// This doesn't work, FileUndoManager registers new links in copyingLinkDone,
// which KIO::symlink obviously doesn't emit... Needs code in FileUndoManager.
//KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Link, lstSrc, dest, kjob);
} else {
//kDebug(1203) << "KIO::copyAs(" << uSrc.url() << "," << dest.url() << ")";
KIO::CopyJob * job = KIO::copyAs(uSrc, dest);
job->setDefaultPermissions(true);
kjob = job;
KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Copy, lstSrc, dest, job);
}
kjob->ui()->setWindow(m_parentWidget);
QObject::connect(kjob, SIGNAL(result(KJob*)), q, SLOT(slotResult(KJob*)));
}
}