if (dateTime.isValid()) {
text = formatDate(dateTime);
}
+ } else if (role == "dimensions") {
+ const auto dimensions = roleValue.toSize();
+ if (dimensions.isValid()) {
+ text = i18nc("width x height", "%1 x %2", dimensions.width(), dimensions.height());
+ }
} else {
text = KStandardItemListWidgetInformant::roleText(role, values);
}
break;
}
+ case DimensionsRole: {
+ const QByteArray role = roleForType(m_sortRole);
+ const QSize dimensionsA = a->values.value(role).toSize();
+ const QSize dimensionsB = b->values.value(role).toSize();
+
+ if (dimensionsA.width() == dimensionsB.width()) {
+ result = dimensionsA.height() - dimensionsB.height();
+ } else {
+ result = dimensionsA.width() - dimensionsB.width();
+ }
+ break;
+ }
+
default: {
const QByteArray role = roleForType(m_sortRole);
const QString roleValueA = a->values.value(role).toString();
{ "wordCount", WordCountRole, kli18nc("@label", "Word Count"), kli18nc("@label", "Document"), true, true },
{ "lineCount", LineCountRole, kli18nc("@label", "Line Count"), kli18nc("@label", "Document"), true, true },
{ "imageDateTime", ImageDateTimeRole, kli18nc("@label", "Date Photographed"), kli18nc("@label", "Image"), true, true },
+ { "dimensions", DimensionsRole, kli18nc("@label width x height", "Dimensions"), kli18nc("@label", "Image"), true, true },
{ "width", WidthRole, kli18nc("@label", "Width"), kli18nc("@label", "Image"), true, true },
{ "height", HeightRole, kli18nc("@label", "Height"), kli18nc("@label", "Image"), true, true },
{ "orientation", OrientationRole, kli18nc("@label", "Orientation"), kli18nc("@label", "Image"), true, true },
NoRole, NameRole, SizeRole, ModificationTimeRole, CreationTimeRole, AccessTimeRole, PermissionsRole, OwnerRole,
GroupRole, TypeRole, DestinationRole, PathRole, DeletionTimeRole,
// User visible roles available with Baloo:
- CommentRole, TagsRole, RatingRole, WidthRole, HeightRole, ImageDateTimeRole, OrientationRole,
+ CommentRole, TagsRole, RatingRole, DimensionsRole, WidthRole, HeightRole, ImageDateTimeRole, OrientationRole,
WordCountRole, TitleRole, LineCountRole, ArtistRole, GenreRole, AlbumRole, DurationRole, TrackRole, ReleaseYearRole,
BitrateRole, OriginUrlRole, AspectRatioRole, FrameRateRole,
// Non-visible roles:
#include <QCollator>
#include <QDebug>
+#include <QSize>
#include <QTime>
namespace {
rangeBegin = rangeEnd;
}
+ if (roles.contains("dimensions")) {
+ bool widthOk = false;
+ bool heightOk = false;
+
+ const int width = propMap.value(KFileMetaData::Property::Width).toInt(&widthOk);
+ const int height = propMap.value(KFileMetaData::Property::Height).toInt(&heightOk);
+
+ if (widthOk && heightOk && width >= 0 && height >= 0) {
+ values.insert("dimensions", QSize(width, height));
+ }
+ }
+
KFileMetaData::UserMetaData::Attributes attributes;
if (roles.contains("tags")) {
attributes |= KFileMetaData::UserMetaData::Tags;
for (const auto& role : propertyRoleMap()) {
m_roles.insert(role);
}
+ m_roles.insert("dimensions");
// Display roles provided by UserMetaData
m_roles.insert(QByteArrayLiteral("tags"));