Changeset View
Changeset View
Standalone View
Standalone View
src/kitemviews/private/kbaloorolesprovider.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 50 | { | |||
---|---|---|---|---|---|
51 | return m_roles; | 51 | return m_roles; | ||
52 | } | 52 | } | ||
53 | 53 | | |||
54 | QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& file, | 54 | QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& file, | ||
55 | const QSet<QByteArray>& roles) const | 55 | const QSet<QByteArray>& roles) const | ||
56 | { | 56 | { | ||
57 | QHash<QByteArray, QVariant> values; | 57 | QHash<QByteArray, QVariant> values; | ||
58 | 58 | | |||
59 | int width = -1; | | |||
60 | int height = -1; | | |||
61 | | ||||
62 | QMapIterator<KFileMetaData::Property::Property, QVariant> it(file.properties()); | 59 | QMapIterator<KFileMetaData::Property::Property, QVariant> it(file.properties()); | ||
63 | while (it.hasNext()) { | 60 | while (it.hasNext()) { | ||
64 | it.next(); | 61 | it.next(); | ||
65 | 62 | | |||
66 | const KFileMetaData::PropertyInfo pi(it.key()); | 63 | const KFileMetaData::PropertyInfo pi(it.key()); | ||
67 | const QString property = pi.name(); | 64 | const QString property = pi.name(); | ||
68 | const QByteArray role = roleForProperty(property); | 65 | const QByteArray role = roleForProperty(property); | ||
69 | if (role.isEmpty() || !roles.contains(role)) { | 66 | if (role.isEmpty() || !roles.contains(role)) { | ||
70 | continue; | 67 | continue; | ||
71 | } | 68 | } | ||
72 | 69 | | |||
73 | const QVariant value = it.value(); | 70 | const QVariant value = it.value(); | ||
74 | 71 | | |||
75 | if (role == "imageSize") { | 72 | if (role == "orientation") { | ||
76 | // Merge the two properties for width and height | | |||
77 | // as one string into the "imageSize" role | | |||
78 | if (property == QLatin1String("width")) { | | |||
79 | width = value.toInt(); | | |||
80 | } | | |||
81 | else if (property == QLatin1String("height")) { | | |||
82 | height = value.toInt(); | | |||
83 | } | | |||
84 | | ||||
85 | if (width >= 0 && height >= 0) { | | |||
86 | QString widthAndHeight = QString::number(width); | | |||
87 | widthAndHeight += QLatin1String(" x "); | | |||
88 | widthAndHeight += QString::number(height); | | |||
89 | values.insert(role, widthAndHeight); | | |||
90 | } | | |||
91 | } else if (role == "orientation") { | | |||
92 | const QString orientation = orientationFromValue(value.toInt()); | 73 | const QString orientation = orientationFromValue(value.toInt()); | ||
93 | values.insert(role, orientation); | 74 | values.insert(role, orientation); | ||
94 | } else if (role == "duration") { | 75 | } else if (role == "duration") { | ||
95 | const QString duration = durationFromValue(value.toInt()); | 76 | const QString duration = durationFromValue(value.toInt()); | ||
96 | values.insert(role, duration); | 77 | values.insert(role, duration); | ||
97 | } else if (role == "bitrate") { | 78 | } else if (role == "bitrate") { | ||
98 | const QString bitrate = bitrateFromValue(value.toInt()); | 79 | const QString bitrate = bitrateFromValue(value.toInt()); | ||
99 | values.insert(role, bitrate); | 80 | values.insert(role, bitrate); | ||
Show All 30 Lines | |||||
130 | { | 111 | { | ||
131 | struct PropertyInfo | 112 | struct PropertyInfo | ||
132 | { | 113 | { | ||
133 | const char* const property; | 114 | const char* const property; | ||
134 | const char* const role; | 115 | const char* const role; | ||
135 | }; | 116 | }; | ||
136 | 117 | | |||
137 | // Mapping from the URIs to the KFileItemModel roles. Note that this must not be | 118 | // Mapping from the URIs to the KFileItemModel roles. Note that this must not be | ||
138 | // a 1:1 mapping: One role may contain several URI-values (e.g. the URIs for height and | 119 | // a 1:1 mapping: One role may contain several URI-values | ||
139 | // width of an image are mapped to the role "imageSize") | | |||
140 | static const PropertyInfo propertyInfoList[] = { | 120 | static const PropertyInfo propertyInfoList[] = { | ||
141 | { "rating", "rating" }, | 121 | { "rating", "rating" }, | ||
142 | { "tag", "tags" }, | 122 | { "tag", "tags" }, | ||
143 | { "comment", "comment" }, | 123 | { "comment", "comment" }, | ||
144 | { "title", "title" }, | 124 | { "title", "title" }, | ||
145 | { "wordCount", "wordCount" }, | 125 | { "wordCount", "wordCount" }, | ||
146 | { "lineCount", "lineCount" }, | 126 | { "lineCount", "lineCount" }, | ||
147 | { "width", "imageSize" }, | 127 | { "width", "width" }, | ||
148 | { "height", "imageSize" }, | 128 | { "height", "height" }, | ||
149 | { "imageDateTime", "imageDateTime"}, | 129 | { "imageDateTime", "imageDateTime"}, | ||
150 | { "nexif.orientation", "orientation", }, | 130 | { "nexif.orientation", "orientation", }, | ||
151 | { "artist", "artist" }, | 131 | { "artist", "artist" }, | ||
152 | { "genre", "genre" }, | 132 | { "genre", "genre" }, | ||
153 | { "album", "album" }, | 133 | { "album", "album" }, | ||
154 | { "duration", "duration" }, | 134 | { "duration", "duration" }, | ||
155 | { "bitRate", "bitrate" }, | 135 | { "bitRate", "bitrate" }, | ||
156 | { "releaseYear", "releaseYear" }, | 136 | { "releaseYear", "releaseYear" }, | ||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |