本文整理汇总了C++中QMimeType::globPatterns方法的典型用法代码示例。如果您正苦于以下问题:C++ QMimeType::globPatterns方法的具体用法?C++ QMimeType::globPatterns怎么用?C++ QMimeType::globPatterns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMimeType
的用法示例。
在下文中一共展示了QMimeType::globPatterns方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: prepareImages
void LocalImageLoaderPrivate::prepareImages() {
QString file, filename, mime;
int32 filesize = 0;
QImage img;
QByteArray data;
PeerId peer;
uint64 id, jpeg_id = 0;
ToPrepareMediaType type;
{
QMutexLocker lock(loader->toPrepareMutex());
ToPrepareMedias &list(loader->toPrepareMedias());
if (list.isEmpty()) return;
file = list.front().file;
img = list.front().img;
data = list.front().data;
peer = list.front().peer;
id = list.front().id;
type = list.front().type;
}
if (img.isNull()) {
if (!file.isEmpty()) {
QFileInfo info(file);
if (type == ToPrepareAuto) {
QString lower(file.toLower());
const QStringList &photoExtensions(cPhotoExtensions());
for (QStringList::const_iterator i = photoExtensions.cbegin(), e = photoExtensions.cend(); i != e; ++i) {
if (lower.lastIndexOf(*i) == lower.size() - i->size()) {
if (info.size() < MaxUploadPhotoSize) {
type = ToPreparePhoto;
break;
}
}
}
if (type == ToPrepareAuto && info.size() < MaxUploadDocumentSize) {
type = ToPrepareDocument;
}
}
if (type != ToPrepareAuto && info.size() < MaxUploadPhotoSize) {
img = App::readImage(file);
}
if (type == ToPrepareDocument) {
mime = QMimeDatabase().mimeTypeForFile(info).name();
}
filename = info.fileName();
filesize = info.size();
} else if (!data.isEmpty()) {
img = App::readImage(data);
if (type == ToPrepareAuto) {
if (!img.isNull() && data.size() < MaxUploadPhotoSize) {
type = ToPreparePhoto;
} else if (data.size() < MaxUploadDocumentSize) {
type = ToPrepareDocument;
} else {
img = QImage();
}
}
QMimeType mimeType = QMimeDatabase().mimeTypeForData(data);
if (type == ToPrepareDocument) {
mime = mimeType.name();
}
filename = qsl("Document");
QStringList patterns = mimeType.globPatterns();
if (!patterns.isEmpty()) {
filename = patterns.front().replace('*', filename);
}
filesize = data.size();
}
} else {
if (type == ToPrepareDocument) {
filename = filedialogDefaultName(qsl("image"), qsl(".png"), QString(), true);
QMimeType mimeType = QMimeDatabase().mimeTypeForName("image/png");
data = QByteArray();
{
QBuffer b(&data);
img.save(&b, "PNG");
}
filesize = data.size();
} else {
type = ToPreparePhoto; // only photo from QImage
filename = qsl("Untitled.jpg");
filesize = 0;
}
}
if ((img.isNull() && (type != ToPrepareDocument || !filesize)) || type == ToPrepareAuto || (img.isNull() && file.isEmpty() && data.isEmpty())) { // if could not decide what type
{
QMutexLocker lock(loader->toPrepareMutex());
ToPrepareMedias &list(loader->toPrepareMedias());
list.pop_front();
}
QTimer::singleShot(1, this, SLOT(prepareImages()));
emit imageFailed(id);
} else {
PreparedPhotoThumbs photoThumbs;
QVector<MTPPhotoSize> photoSizes;
//.........这里部分代码省略.........