diff options
Diffstat (limited to 'src/kitemviews')
| -rw-r--r-- | src/kitemviews/kfileitemmodel.cpp | 9 | ||||
| -rw-r--r-- | src/kitemviews/kfileitemmodel.h | 4 | ||||
| -rw-r--r-- | src/kitemviews/private/kbaloorolesprovider.cpp | 15 | ||||
| -rw-r--r-- | src/kitemviews/private/kbaloorolesprovider.h | 6 |
4 files changed, 31 insertions, 3 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index b725d9507..8f89b89df 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -636,7 +636,11 @@ void KFileItemModel::expandParentDirectories(const QUrl &url) // does not care whether the parent-URL has already been // expanded. QUrl urlToExpand = m_dirLister->url(); - const QStringList subDirs = url.path().mid(pos).split(QDir::separator()); + + // first subdir can be empty, if m_dirLister->url().path() does not end with '/' + // this happens if baseUrl is not root but a home directory, see FoldersPanel, + // so using QString::SkipEmptyParts + const QStringList subDirs = url.path().mid(pos).split(QDir::separator(), QString::SkipEmptyParts); for (int i = 0; i < subDirs.count() - 1; ++i) { urlToExpand.setPath(urlToExpand.path() + '/' + subDirs.at(i)); m_urlsToExpand.insert(urlToExpand); @@ -2307,9 +2311,12 @@ const KFileItemModel::RoleInfoMap* KFileItemModel::rolesInfoMap(int& count) { "imageSize", ImageSizeRole, I18N_NOOP2_NOSTRIP("@label", "Image Size"), I18N_NOOP2_NOSTRIP("@label", "Image"), true, true }, { "orientation", OrientationRole, I18N_NOOP2_NOSTRIP("@label", "Orientation"), I18N_NOOP2_NOSTRIP("@label", "Image"), true, true }, { "artist", ArtistRole, I18N_NOOP2_NOSTRIP("@label", "Artist"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, + { "genre", GenreRole, I18N_NOOP2_NOSTRIP("@label", "Genre"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, { "album", AlbumRole, I18N_NOOP2_NOSTRIP("@label", "Album"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, { "duration", DurationRole, I18N_NOOP2_NOSTRIP("@label", "Duration"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, + { "bitrate", BitrateRole, I18N_NOOP2_NOSTRIP("@label", "Bitrate"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, { "track", TrackRole, I18N_NOOP2_NOSTRIP("@label", "Track"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, + { "releaseYear", ReleaseYearRole, I18N_NOOP2_NOSTRIP("@label", "Release Year"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, { "path", PathRole, I18N_NOOP2_NOSTRIP("@label", "Path"), I18N_NOOP2_NOSTRIP("@label", "Other"), false, false }, { "deletiontime",DeletionTimeRole,I18N_NOOP2_NOSTRIP("@label", "Deletion Time"), I18N_NOOP2_NOSTRIP("@label", "Other"), false, false }, { "destination", DestinationRole, I18N_NOOP2_NOSTRIP("@label", "Link Destination"), I18N_NOOP2_NOSTRIP("@label", "Other"), false, false }, diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h index ef902775f..5dbeb32b2 100644 --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -286,8 +286,8 @@ private: GroupRole, TypeRole, DestinationRole, PathRole, DeletionTimeRole, // User visible roles available with Baloo: CommentRole, TagsRole, RatingRole, ImageSizeRole, OrientationRole, - WordCountRole, TitleRole, LineCountRole, ArtistRole, AlbumRole, DurationRole, TrackRole, - OriginUrlRole, + WordCountRole, TitleRole, LineCountRole, ArtistRole, GenreRole, AlbumRole, DurationRole, TrackRole, ReleaseYearRole, + BitrateRole, OriginUrlRole, // Non-visible roles: IsDirRole, IsLinkRole, IsHiddenRole, IsExpandedRole, IsExpandableRole, ExpandedParentsCountRole, // Mandatory last entry: diff --git a/src/kitemviews/private/kbaloorolesprovider.cpp b/src/kitemviews/private/kbaloorolesprovider.cpp index d6c15afcd..314c2f06b 100644 --- a/src/kitemviews/private/kbaloorolesprovider.cpp +++ b/src/kitemviews/private/kbaloorolesprovider.cpp @@ -26,6 +26,7 @@ #include <Baloo/File> #include <KFileMetaData/PropertyInfo> #include <KFileMetaData/UserMetaData> +#include <KFormat> #include <QTime> #include <QMap> @@ -95,6 +96,9 @@ QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& f } else if (role == "duration") { const QString duration = durationFromValue(value.toInt()); values.insert(role, duration); + } else if (role == "bitrate") { + const QString bitrate = bitrateFromValue(value.toInt()); + values.insert(role, bitrate); } else { values.insert(role, value.toString()); } @@ -146,8 +150,11 @@ KBalooRolesProvider::KBalooRolesProvider() : { "height", "imageSize" }, { "nexif.orientation", "orientation", }, { "artist", "artist" }, + { "genre", "genre" }, { "album", "album" }, { "duration", "duration" }, + { "bitRate", "bitrate" }, + { "releaseYear", "releaseYear" }, { "trackNumber", "track" }, { "originUrl", "originUrl" } }; @@ -192,3 +199,11 @@ QString KBalooRolesProvider::durationFromValue(int value) const return duration.toString(QStringLiteral("hh:mm:ss")); } + +QString KBalooRolesProvider::bitrateFromValue(int value) const +{ + KFormat form; + QString bitrate = i18nc("@label bitrate (per second)", "%1/s", form.formatByteSize(value, 1, KFormat::MetricBinaryDialect)); + return bitrate; +} + diff --git a/src/kitemviews/private/kbaloorolesprovider.h b/src/kitemviews/private/kbaloorolesprovider.h index 65b59793c..6fef98ede 100644 --- a/src/kitemviews/private/kbaloorolesprovider.h +++ b/src/kitemviews/private/kbaloorolesprovider.h @@ -79,6 +79,12 @@ private: */ QString durationFromValue(int value) const; + /** + * @return Bitrate in the format N kB/s for the value given + * in b/s. + */ + QString bitrateFromValue(int value) const; + private: QSet<QByteArray> m_roles; QHash<QString, QByteArray> m_roleForProperty; |
