本文整理汇总了C++中QMimeType::suffixes方法的典型用法代码示例。如果您正苦于以下问题:C++ QMimeType::suffixes方法的具体用法?C++ QMimeType::suffixes怎么用?C++ QMimeType::suffixes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMimeType
的用法示例。
在下文中一共展示了QMimeType::suffixes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QMimeDatabase
Vector<String> MIMETypeRegistry::getExtensionsForMIMEType(const String& mimeTypeName)
{
Vector<String> extensions;
QMimeType mimeType = QMimeDatabase().mimeTypeForName(mimeTypeName);
if (mimeType.isValid() && !mimeType.isDefault()) {
Q_FOREACH(const QString& suffix, mimeType.suffixes()) {
extensions.append(suffix);
}
}
示例2: formatMimeTypeInfo
QString MimetypeModel::formatMimeTypeInfo(const QMimeType &t)
{
QString result;
QTextStream str(&result);
str << "<html><head/><body><h3><center>" << t.name() << "</center></h3><br><table>";
const QStringList &aliases = t.aliases();
if (!aliases.isEmpty())
str << "<tr><td>Aliases:</td><td>" << " (" << aliases << ')';
str << "</td></tr>"
<< "<tr><td>Comment:</td><td>" << t.comment() << "</td></tr>"
<< "<tr><td>Icon name:</td><td>" << t.iconName() << "</td></tr>"
<< "<tr><td>Generic icon name</td><td>" << t.genericIconName() << "</td></tr>";
const QString &filter = t.filterString();
if (!filter.isEmpty())
str << "<tr><td>Filter:</td><td>" << t.filterString() << "</td></tr>";
const QStringList &patterns = t.globPatterns();
if (!patterns.isEmpty())
str << "<tr><td>Glob patterns:</td><td>" << patterns << "</td></tr>";
const QStringList &parentMimeTypes = t.parentMimeTypes();
if (!parentMimeTypes.isEmpty())
str << "<tr><td>Parent types:</td><td>" << t.parentMimeTypes() << "</td></tr>";
QStringList suffixes = t.suffixes();
if (!suffixes.isEmpty()) {
str << "<tr><td>Suffixes:</td><td>";
const QString &preferredSuffix = t.preferredSuffix();
if (!preferredSuffix.isEmpty()) {
suffixes.removeOne(preferredSuffix);
str << "<b>" << preferredSuffix << "</b> ";
}
str << suffixes << "</td></tr>";
}
str << "</table></body></html>";
return result;
}
示例3: request
/*!
* \internal
*/
QGeometry *MeshLoaderFunctor::operator()()
{
if (m_sourcePath.isEmpty()) {
qCWarning(Render::Jobs) << Q_FUNC_INFO << "Mesh is empty, nothing to load";
return nullptr;
}
QStringList ext;
if (!Qt3DCore::QDownloadHelperService::isLocal(m_sourcePath)) {
if (m_sourceData.isEmpty()) {
if (m_mesh) {
// Output a warning in the case a user is calling the functor directly
// in the frontend
if (m_nodeManagers == nullptr || m_downloaderService == nullptr) {
qWarning() << "Mesh source points to a remote URL. Remotes meshes can only be loaded if the geometry is processed by the Qt3DRender backend";
return nullptr;
}
Qt3DCore::QDownloadRequestPtr request(new MeshDownloadRequest(m_mesh, m_sourcePath, m_nodeManagers));
m_downloaderService->submitRequest(request);
}
return nullptr;
}
QMimeDatabase db;
QMimeType mtype = db.mimeTypeForData(m_sourceData);
if (mtype.isValid()) {
ext = mtype.suffixes();
}
QFileInfo finfo(m_sourcePath.path());
ext << finfo.suffix();
ext.removeAll(QLatin1String(""));
if (!ext.contains(QLatin1String("obj")))
ext << QLatin1String("obj");
} else {
QString filePath = Qt3DRender::QUrlHelper::urlToLocalFileOrQrc(m_sourcePath);
QFileInfo finfo(filePath);
if (finfo.suffix().isEmpty())
ext << QLatin1String("obj");
else
ext << finfo.suffix();
}
QScopedPointer<QGeometryLoaderInterface> loader;
for (const QString &e: qAsConst(ext)) {
loader.reset(qLoadPlugin<QGeometryLoaderInterface, QGeometryLoaderFactory>(geometryLoader(), e));
if (loader)
break;
}
if (!loader) {
qCWarning(Render::Jobs, "unsupported format encountered (%s)", qPrintable(ext.join(QLatin1String(", "))));
return nullptr;
}
if (m_sourceData.isEmpty()) {
QString filePath = Qt3DRender::QUrlHelper::urlToLocalFileOrQrc(m_sourcePath);
QFile file(filePath);
if (!file.open(QIODevice::ReadOnly)) {
qCDebug(Render::Jobs) << "Could not open file" << filePath << "for reading";
return nullptr;
}
if (loader->load(&file, m_meshName))
return loader->geometry();
qCWarning(Render::Jobs) << Q_FUNC_INFO << "Mesh loading failure for:" << filePath;
} else {
QT_PREPEND_NAMESPACE(QBuffer) buffer(&m_sourceData);
if (!buffer.open(QIODevice::ReadOnly)) {
return nullptr;
}
if (loader->load(&buffer, m_meshName))
return loader->geometry();
qCWarning(Render::Jobs) << Q_FUNC_INFO << "Mesh loading failure for:" << m_sourcePath;
}
return nullptr;
}