Append a "Hz", "bpm", "kbps" etc. suffix to bit rate, sample rate and BPM columns in the playlist

This commit is contained in:
David Sansome 2010-06-10 17:04:40 +00:00
parent 6eea954fb1
commit 07ba35ff6d
28 changed files with 172 additions and 10 deletions

View File

@ -30,32 +30,40 @@
const int PlaylistDelegateBase::kMinHeight = 19;
PlaylistDelegateBase::PlaylistDelegateBase(QTreeView* view)
PlaylistDelegateBase::PlaylistDelegateBase(QTreeView* view, const QString& suffix)
: QStyledItemDelegate(view),
view_(view)
view_(view),
suffix_(suffix)
{
}
QString PlaylistDelegateBase::displayText(const QVariant& value, const QLocale&) const {
QString text;
switch (value.type()) {
case QVariant::Int: {
int v = value.toInt();
if (v <= 0)
return QString::null;
return QString::number(v);
if (v > 0)
text = QString::number(v);
break;
}
case QMetaType::Float:
case QVariant::Double: {
double v = value.toDouble();
if (v <= 0)
return QString::null;
return QString::number(v);
if (v > 0)
text = QString::number(v);
break;
}
default:
return value.toString();
text = value.toString();
break;
}
if (!text.isNull() && !suffix_.isNull())
text += " " + suffix_;
return text;
}
QSize PlaylistDelegateBase::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const {

View File

@ -28,7 +28,7 @@
class PlaylistDelegateBase : public QStyledItemDelegate {
Q_OBJECT
public:
PlaylistDelegateBase(QTreeView* view);
PlaylistDelegateBase(QTreeView* view, const QString& suffix = QString());
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
QString displayText(const QVariant& value, const QLocale& locale) const;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
@ -43,6 +43,7 @@ class PlaylistDelegateBase : public QStyledItemDelegate {
protected:
QTreeView* view_;
QString suffix_;
};
class LengthItemDelegate : public PlaylistDelegateBase {

View File

@ -81,6 +81,9 @@ void PlaylistView::SetItemDelegates(LibraryBackend* backend) {
setItemDelegateForColumn(Playlist::Column_Filetype, new FileTypeItemDelegate(this));
setItemDelegateForColumn(Playlist::Column_DateCreated, new DateItemDelegate(this));
setItemDelegateForColumn(Playlist::Column_DateModified, new DateItemDelegate(this));
setItemDelegateForColumn(Playlist::Column_BPM, new PlaylistDelegateBase(this, tr("bpm")));
setItemDelegateForColumn(Playlist::Column_Samplerate, new PlaylistDelegateBase(this, ("Hz")));
setItemDelegateForColumn(Playlist::Column_Bitrate, new PlaylistDelegateBase(this, tr("kbps")));
}
void PlaylistView::SetPlaylist(Playlist *playlist) {

View File

@ -326,6 +326,12 @@ msgstr "أزِل %n أغاني\\أغنية"
msgid "move songs"
msgstr "انقل الأغاني"
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""

View File

@ -327,6 +327,12 @@ msgstr "Odeber %n skladeb"
msgid "move songs"
msgstr "Přesuň skladby"
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""

View File

@ -329,6 +329,12 @@ msgstr "fjern %n sange"
msgid "move songs"
msgstr "flyt sange"
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""

View File

@ -327,6 +327,12 @@ msgstr "%n Stücke entfernen"
msgid "move songs"
msgstr "Stücke verschieben"
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr "%1 Wiedergabelisten (%2)"

View File

@ -330,6 +330,12 @@ msgstr "αφαίρεση %n τραγουδιών"
msgid "move songs"
msgstr "μετακίνηση τραγουδιών"
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr "%1 λίστες αναπαραγωγής (%2)"

View File

@ -327,6 +327,12 @@ msgstr "remove %n songs"
msgid "move songs"
msgstr "move songs"
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr "%1 playlists (%2)"

View File

@ -326,6 +326,12 @@ msgstr ""
msgid "move songs"
msgstr ""
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""

View File

@ -329,6 +329,12 @@ msgstr "remover %n pistas"
msgid "move songs"
msgstr "mover pistas"
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr "%1 listas de reproducción (%2)"

View File

@ -326,6 +326,12 @@ msgstr ""
msgid "move songs"
msgstr ""
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""

View File

@ -327,6 +327,12 @@ msgstr ""
msgid "move songs"
msgstr "déplacer les chansons"
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""

View File

@ -326,6 +326,12 @@ msgstr ""
msgid "move songs"
msgstr ""
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""

View File

@ -329,6 +329,12 @@ msgstr "rimuovi %n brani"
msgid "move songs"
msgstr "sposta brani"
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr "%1 scalette (%2)"

View File

@ -326,6 +326,12 @@ msgstr ""
msgid "move songs"
msgstr ""
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""

View File

@ -326,6 +326,12 @@ msgstr ""
msgid "move songs"
msgstr ""
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""

View File

@ -326,6 +326,12 @@ msgstr ""
msgid "move songs"
msgstr ""
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""

View File

@ -327,6 +327,12 @@ msgstr ""
msgid "move songs"
msgstr ""
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""

View File

@ -328,6 +328,12 @@ msgstr "remover %n canções"
msgid "move songs"
msgstr "mover canções"
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr "%1 listas de reprodução (%2)"

View File

@ -328,6 +328,12 @@ msgstr "Remover %n músicas"
msgid "move songs"
msgstr "mover músicas"
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr "%1 listas de reprodução (%2)"

View File

@ -326,6 +326,12 @@ msgstr ""
msgid "move songs"
msgstr ""
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""

View File

@ -327,6 +327,12 @@ msgstr "удалить %n композиций"
msgid "move songs"
msgstr "переместить композиции"
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr "%1 списков воспроизведения (%2)"

View File

@ -328,6 +328,12 @@ msgstr "odstrániť %n piesní"
msgid "move songs"
msgstr "presunúť piesne"
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr "%1 playlisty (%2)"

View File

@ -326,6 +326,12 @@ msgstr "Ta bort %n songer"
msgid "move songs"
msgstr "Flytta songer"
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""

View File

@ -326,6 +326,12 @@ msgstr ""
msgid "move songs"
msgstr ""
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""

View File

@ -326,6 +326,12 @@ msgstr ""
msgid "move songs"
msgstr ""
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""

View File

@ -326,6 +326,12 @@ msgstr ""
msgid "move songs"
msgstr ""
msgid "bpm"
msgstr ""
msgid "kbps"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""