本文整理汇总了C++中QMimeType::genericIconName方法的典型用法代码示例。如果您正苦于以下问题:C++ QMimeType::genericIconName方法的具体用法?C++ QMimeType::genericIconName怎么用?C++ QMimeType::genericIconName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMimeType
的用法示例。
在下文中一共展示了QMimeType::genericIconName方法的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: data
QVariant DirModel::data(const QModelIndex &index, int role) const
{
//its not for QML
#if defined(REGRESSION_TEST_FOLDERLISTMODEL)
if (!index.isValid() ||
(role != Qt::DisplayRole && role != Qt::DecorationRole && role != Qt::BackgroundRole)
)
{
return QVariant();
}
if (role == Qt::DecorationRole && index.column() == 0)
{
QIcon icon;
QMimeType mime = mDirectoryContents.at(index.row()).mimeType();
if (mime.isValid())
{
if (QIcon::hasThemeIcon(mime.iconName()) ) {
icon = QIcon::fromTheme(mime.iconName());
}
else if (QIcon::hasThemeIcon(mime.genericIconName())) {
icon = QIcon::fromTheme(mime.genericIconName());
}
}
if (icon.isNull())
{
if (mDirectoryContents.at(index.row()).isLocal())
{
icon = QFileIconProvider().icon(mDirectoryContents.at(index.row()).diskFileInfo());
}
else
if (mDirectoryContents.at(index.row()).isDir())
{
icon = QFileIconProvider().icon(QFileIconProvider::Folder);
}
else
{
icon = QFileIconProvider().icon(QFileIconProvider::File);
}
}
return icon;
}
if (role == Qt::BackgroundRole && index.column() == 0)
{
if (mDirectoryContents.at(index.row()).isSelected())
{
//TODO it'd better to get some style or other default
// background color
return QBrush(Qt::lightGray);
}
return QVariant();
}
role = FileNameRole + index.column();
#else
if (role < FileNameRole || role > TrackCoverRole) {
qWarning() << Q_FUNC_INFO << this << "Got an out of range role: " << role;
return QVariant();
}
if (index.row() < 0 || index.row() >= mDirectoryContents.count()) {
qWarning() << "Attempted to access out of range row: " << index.row();
return QVariant();
}
if (index.column() != 0)
return QVariant();
#endif
const DirItemInfo &fi = mDirectoryContents.at(index.row());
switch (role) {
case FileNameRole:
return fi.fileName();
case AccessedDateRole:
return fi.lastRead();
case CreationDateRole:
return fi.created();
case ModifiedDateRole:
return fi.lastModified();
case FileSizeRole: {
if (fi.isDir() && fi.isLocal())
{
return dirItems(fi.diskFileInfo());
}
return fileSize(fi.size());
}
case IconSourceRole: {
const QString &fileName = fi.fileName();
if (fi.isDir())
return QLatin1String("image://theme/icon-m-common-directory");
if (fileName.endsWith(QLatin1String(".jpg"), Qt::CaseInsensitive) ||
fileName.endsWith(QLatin1String(".png"), Qt::CaseInsensitive)) {
return QLatin1String("image://nemoThumbnail/") + fi.filePath();
}
return "image://theme/icon-m-content-document";
}
case FilePathRole:
return fi.filePath();
//.........这里部分代码省略.........