Merge pull request #4034 from GitAnt/master
Implemented the sort by bitrate option
This commit is contained in:
commit
9be999cf18
|
@ -8,6 +8,7 @@
|
|||
*.dll
|
||||
*.exe
|
||||
*.pyd
|
||||
build/
|
||||
3rdparty/libprojectm/config.inp
|
||||
3rdparty/libprojectm/libprojectM.pc
|
||||
CMakeLists.txt.user
|
||||
|
|
|
@ -145,8 +145,14 @@ QStandardItem* GlobalSearchModel::BuildContainers(
|
|||
sort_text = display_text;
|
||||
break;
|
||||
|
||||
case LibraryModel::GroupBy_Bitrate:
|
||||
display_text = QString(s.bitrate(), 1);
|
||||
sort_text = display_text;
|
||||
break;
|
||||
|
||||
case LibraryModel::GroupBy_None:
|
||||
return parent;
|
||||
|
||||
}
|
||||
|
||||
// Find a container for this level
|
||||
|
|
|
@ -36,8 +36,9 @@ GroupByDialog::GroupByDialog(QWidget *parent)
|
|||
mapping_.insert(Mapping(LibraryModel::GroupBy_Genre, 6));
|
||||
mapping_.insert(Mapping(LibraryModel::GroupBy_Year, 7));
|
||||
mapping_.insert(Mapping(LibraryModel::GroupBy_YearAlbum, 8));
|
||||
mapping_.insert(Mapping(LibraryModel::GroupBy_Performer, 9));
|
||||
mapping_.insert(Mapping(LibraryModel::GroupBy_Grouping, 10));
|
||||
mapping_.insert(Mapping(LibraryModel::GroupBy_Bitrate, 9));
|
||||
mapping_.insert(Mapping(LibraryModel::GroupBy_Performer, 10));
|
||||
mapping_.insert(Mapping(LibraryModel::GroupBy_Grouping, 11));
|
||||
|
||||
connect(ui_->button_box->button(QDialogButtonBox::Reset), SIGNAL(clicked()),
|
||||
SLOT(Reset()));
|
||||
|
|
|
@ -88,6 +88,11 @@
|
|||
<string>Year - Album</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bitrate</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
|
@ -144,6 +149,11 @@
|
|||
<string>Year - Album</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bitrate</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
|
@ -200,6 +210,11 @@
|
|||
<string>Year - Album</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bitrate</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -190,6 +190,7 @@ void LibraryModel::SongsDiscovered(const SongList& songs) {
|
|||
case GroupBy_YearAlbum:
|
||||
key = PrettyYearAlbum(qMax(0, song.year()), song.album()); break;
|
||||
case GroupBy_FileType: key = song.filetype(); break;
|
||||
case GroupBy_Bitrate: key = song.bitrate(); break;
|
||||
case GroupBy_None:
|
||||
qLog(Error) << "GroupBy_None";
|
||||
break;
|
||||
|
@ -280,6 +281,9 @@ QString LibraryModel::DividerKey(GroupBy type, LibraryItem* item) const {
|
|||
case GroupBy_YearAlbum:
|
||||
return SortTextForYear(item->metadata.year());
|
||||
|
||||
case GroupBy_Bitrate:
|
||||
return SortTextForBitrate(item->metadata.bitrate());
|
||||
|
||||
case GroupBy_None:
|
||||
return QString();
|
||||
}
|
||||
|
@ -313,6 +317,11 @@ QString LibraryModel::DividerDisplayText(GroupBy type, const QString& key) const
|
|||
return tr("Unknown");
|
||||
return QString::number(key.toInt()); // To remove leading 0s
|
||||
|
||||
case GroupBy_Bitrate:
|
||||
if (key == "000")
|
||||
return tr("Unknown");
|
||||
return QString::number(key.toInt()); // To remove leading 0s
|
||||
|
||||
case GroupBy_None:
|
||||
// fallthrough
|
||||
;
|
||||
|
@ -739,6 +748,9 @@ void LibraryModel::InitQuery(GroupBy type, LibraryQuery* q) {
|
|||
case GroupBy_AlbumArtist:
|
||||
q->SetColumnSpec("DISTINCT effective_albumartist");
|
||||
break;
|
||||
case GroupBy_Bitrate:
|
||||
q->SetColumnSpec("DISTINCT bitrate");
|
||||
break;
|
||||
case GroupBy_None:
|
||||
q->SetColumnSpec("%songs_table.ROWID, " + Song::kColumnSpec);
|
||||
break;
|
||||
|
@ -796,6 +808,9 @@ void LibraryModel::FilterQuery(GroupBy type, LibraryItem* item, LibraryQuery* q)
|
|||
case GroupBy_FileType:
|
||||
q->AddWhere("filetype", item->metadata.filetype());
|
||||
break;
|
||||
case GroupBy_Bitrate:
|
||||
q->AddWhere("bitrate", item->key);
|
||||
break;
|
||||
case GroupBy_None:
|
||||
qLog(Error) << "Unknown GroupBy type" << type << "used in filter";
|
||||
break;
|
||||
|
@ -825,6 +840,7 @@ LibraryItem* LibraryModel::ItemFromQuery(GroupBy type,
|
|||
int container_level) {
|
||||
LibraryItem* item = InitItem(type, signal, parent, container_level);
|
||||
int year = 0;
|
||||
int bitrate = 0;
|
||||
|
||||
switch (type) {
|
||||
case GroupBy_Artist:
|
||||
|
@ -863,6 +879,12 @@ LibraryItem* LibraryModel::ItemFromQuery(GroupBy type,
|
|||
item->key = item->metadata.TextForFiletype();
|
||||
break;
|
||||
|
||||
case GroupBy_Bitrate:
|
||||
bitrate = qMax(0, row.value(0).toInt());
|
||||
item->key = QString::number(bitrate);
|
||||
item->sort_text = SortTextForBitrate(bitrate) + " ";
|
||||
break;
|
||||
|
||||
case GroupBy_None:
|
||||
item->metadata.InitFromQuery(row, true);
|
||||
item->key = item->metadata.title();
|
||||
|
@ -881,6 +903,7 @@ LibraryItem* LibraryModel::ItemFromSong(GroupBy type,
|
|||
int container_level) {
|
||||
LibraryItem* item = InitItem(type, signal, parent, container_level);
|
||||
int year = 0;
|
||||
int bitrate = 0;
|
||||
|
||||
switch (type) {
|
||||
case GroupBy_Artist:
|
||||
|
@ -918,6 +941,12 @@ LibraryItem* LibraryModel::ItemFromSong(GroupBy type,
|
|||
item->key = s.TextForFiletype();
|
||||
break;
|
||||
|
||||
case GroupBy_Bitrate:
|
||||
bitrate = qMax(0, s.bitrate());
|
||||
item->key = QString::number(bitrate);
|
||||
item->sort_text = SortTextForBitrate(bitrate) + " ";
|
||||
break;
|
||||
|
||||
case GroupBy_None:
|
||||
item->metadata = s;
|
||||
item->key = s.title();
|
||||
|
@ -1004,6 +1033,12 @@ QString LibraryModel::SortTextForYear(int year) {
|
|||
return QString("0").repeated(qMax(0, 4 - str.length())) + str;
|
||||
}
|
||||
|
||||
QString LibraryModel::SortTextForBitrate(int bitrate) {
|
||||
QString str = QString::number(bitrate);
|
||||
return QString("0").repeated(qMax(0, 3 - str.length())) + str;
|
||||
}
|
||||
|
||||
|
||||
QString LibraryModel::SortTextForSong(const Song& song) {
|
||||
QString ret = QString::number(qMax(0, song.disc()) * 1000 + qMax(0, song.track()));
|
||||
ret.prepend(QString("0").repeated(6 - ret.length()));
|
||||
|
|
|
@ -82,6 +82,7 @@ class LibraryModel : public SimpleTreeModel<LibraryItem> {
|
|||
GroupBy_FileType = 8,
|
||||
GroupBy_Performer = 9,
|
||||
GroupBy_Grouping = 10,
|
||||
GroupBy_Bitrate = 11,
|
||||
};
|
||||
|
||||
struct Grouping {
|
||||
|
@ -159,6 +160,7 @@ class LibraryModel : public SimpleTreeModel<LibraryItem> {
|
|||
static QString SortText(QString text);
|
||||
static QString SortTextForArtist(QString artist);
|
||||
static QString SortTextForYear(int year);
|
||||
static QString SortTextForBitrate(int bitrate);
|
||||
static QString SortTextForSong(const Song& song);
|
||||
|
||||
signals:
|
||||
|
|
Loading…
Reference in New Issue