void KFileItemModel::prepareItemsForSorting(QList<ItemData*>& itemDataList)
{
switch (m_sortRole) {
+ case ExtensionRole:
case PermissionsRole:
case OwnerRole:
case GroupRole:
data.insert(sharedValue("text"), item.text());
}
+ if (m_requestRole[ExtensionRole]) {
+ data.insert(sharedValue("extension"), QFileInfo(item.name()).suffix());
+ }
+
if (m_requestRole[SizeRole] && !isDir) {
data.insert(sharedValue("size"), item.size());
}
{ "creationtime", CreationTimeRole, kli18nc("@label", "Created"), KLazyLocalizedString(), false, false },
{ "accesstime", AccessTimeRole, kli18nc("@label", "Accessed"), KLazyLocalizedString(), false, false },
{ "type", TypeRole, kli18nc("@label", "Type"), KLazyLocalizedString(), false, false },
+ { "extension", ExtensionRole, kli18nc("@label", "Extension"), KLazyLocalizedString(), false, false },
{ "rating", RatingRole, kli18nc("@label", "Rating"), KLazyLocalizedString(), true, false },
{ "tags", TagsRole, kli18nc("@label", "Tags"), KLazyLocalizedString(), true, false },
{ "comment", CommentRole, kli18nc("@label", "Comment"), KLazyLocalizedString(), true, false },
enum RoleType {
// User visible roles:
NoRole, NameRole, SizeRole, ModificationTimeRole, CreationTimeRole, AccessTimeRole, PermissionsRole, OwnerRole,
- GroupRole, TypeRole, DestinationRole, PathRole, DeletionTimeRole,
+ GroupRole, TypeRole, ExtensionRole, DestinationRole, PathRole, DeletionTimeRole,
// User visible roles available with Baloo:
CommentRole, TagsRole, RatingRole, DimensionsRole, WidthRole, HeightRole, ImageDateTimeRole, OrientationRole,
WordCountRole, TitleRole, AuthorRole, LineCountRole, ArtistRole, GenreRole, AlbumRole, DurationRole, TrackRole, ReleaseYearRole,
inline bool KFileItemModel::isRoleValueNatural(RoleType roleType)
{
return (roleType == TypeRole ||
+ roleType == ExtensionRole ||
roleType == TagsRole ||
roleType == CommentRole ||
roleType == TitleRole ||
QAction* descending = m_actionCollection->action(QStringLiteral("descending"));
QAction* ascending = m_actionCollection->action(QStringLiteral("ascending"));
- if (role == "text" || role == "type" || role == "tags" || role == "comment") {
+ if (role == "text" || role == "type" || role == "extension" || role == "tags" || role == "comment") {
descending->setText(i18nc("Sort descending", "Z-A"));
ascending->setText(i18nc("Sort ascending", "A-Z"));
} else if (role == "size") {