committed by
Craig Drummond
parent
7173373094
commit
ecae49c24e
@@ -349,20 +349,45 @@ static bool songsSortArAl(const Song &a, const Song &b)
|
||||
// return a.lastModified>b.lastModified;
|
||||
//}
|
||||
|
||||
static QStringList prefixesToIngore=QStringList() << QLatin1String("The");
|
||||
|
||||
QStringList LibraryDb::ignorePrefixes()
|
||||
{
|
||||
return prefixesToIngore;
|
||||
}
|
||||
|
||||
void LibraryDb::setIgnorePrefixes(const QStringList &prefixes)
|
||||
{
|
||||
prefixesToIngore=prefixes;
|
||||
}
|
||||
|
||||
static QString ignorePrefix(const QString &str)
|
||||
{
|
||||
foreach (const QString &p, prefixesToIngore) {
|
||||
if (str.startsWith(p+QLatin1Char(' '))) {
|
||||
return str.mid(p.length()+1);
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
static QString sortString(const QString &str)
|
||||
{
|
||||
QString sort=ignorePrefix(str);
|
||||
|
||||
if (sort.isEmpty()) {
|
||||
sort=str;
|
||||
}
|
||||
sort=sort.remove('.');
|
||||
return sort==str ? QString() : sort;
|
||||
}
|
||||
|
||||
static QString artistSort(const Song &s)
|
||||
{
|
||||
if (!s.artistSortString().isEmpty()) {
|
||||
return s.artistSortString();
|
||||
}
|
||||
const QString &albumArtist=s.albumArtist();
|
||||
QString sort;
|
||||
if (albumArtist.startsWith("The ")) {
|
||||
sort=albumArtist.mid(4);
|
||||
} else {
|
||||
sort=albumArtist;
|
||||
}
|
||||
sort=sort.remove('.');
|
||||
return sort==albumArtist ? QString() : sort;
|
||||
return sortString(s.albumArtist());
|
||||
}
|
||||
|
||||
static QString albumSort(const Song &s)
|
||||
@@ -370,14 +395,7 @@ static QString albumSort(const Song &s)
|
||||
if (!s.albumSort().isEmpty()) {
|
||||
return s.albumSort();
|
||||
}
|
||||
QString sort;
|
||||
if (s.album.startsWith("The ")) {
|
||||
sort=s.album.mid(4);
|
||||
} else {
|
||||
sort=s.album;
|
||||
}
|
||||
sort=sort.remove('.');
|
||||
return sort==s.album ? QString() : sort;
|
||||
return sortString(s.album);
|
||||
}
|
||||
|
||||
// Code taken from Clementine's LibraryQuery
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
|
||||
class QSqlDatabase;
|
||||
class QSqlQuery;
|
||||
class QSettings;
|
||||
|
||||
class LibraryDb : public QObject
|
||||
{
|
||||
@@ -108,6 +107,9 @@ public:
|
||||
int lastModified;
|
||||
};
|
||||
|
||||
static QStringList ignorePrefixes();
|
||||
static void setIgnorePrefixes(const QStringList &prefixes);
|
||||
|
||||
LibraryDb(QObject *p, const QString &name);
|
||||
~LibraryDb();
|
||||
|
||||
|
||||
@@ -211,6 +211,7 @@ InterfaceSettings::InterfaceSettings(QWidget *p)
|
||||
|
||||
void InterfaceSettings::load()
|
||||
{
|
||||
ignorePrefixes->setText(Settings::self()->ignorePrefixes().join(QString(Song::constGenreSep)));
|
||||
composerGenres->setText(QStringList(Settings::self()->composerGenres().toList()).join(QString(Song::constGenreSep)));
|
||||
singleTracksFolder->setText(Settings::self()->singleTracksFolder());
|
||||
#ifdef ENABLE_DEVICES_SUPPORT
|
||||
@@ -284,6 +285,7 @@ void InterfaceSettings::load()
|
||||
|
||||
void InterfaceSettings::save()
|
||||
{
|
||||
Settings::self()->saveIgnorePrefixes(ignorePrefixes->text().trimmed().split(Song::constGenreSep));
|
||||
Settings::self()->saveComposerGenres(composerGenres->text().trimmed().split(Song::constGenreSep).toSet());
|
||||
Settings::self()->saveSingleTracksFolder(singleTracksFolder->text().trimmed());
|
||||
#ifdef ENABLE_DEVICES_SUPPORT
|
||||
|
||||
@@ -475,6 +475,32 @@
|
||||
<string>Tweaks</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2p">
|
||||
<property name="title">
|
||||
<string>Artist && Album Sorting</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2p">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelp">
|
||||
<property name="text">
|
||||
<string>Enter a (comma separated) list of prefixes to ignore when sorting artist and albums. e.g. if set to 'The' then 'The Beatles' would be sorted by 'Beatles'</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="LineEdit" name="ignorePrefixes">
|
||||
<property name="placeholderText">
|
||||
<string>Enter comma separated list of prefixes...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
|
||||
@@ -1415,6 +1415,7 @@ void MainWindow::readSettings()
|
||||
CurrentCover::self()->setEnabled(Settings::self()->showPopups() || 0!=Settings::self()->playQueueBackground() || Settings::self()->showCoverWidget());
|
||||
#endif
|
||||
checkMpdDir();
|
||||
LibraryDb::setIgnorePrefixes(Settings::self()->ignorePrefixes());
|
||||
Covers::self()->readConfig();
|
||||
HttpServer::self()->readConfig();
|
||||
#ifdef ENABLE_DEVICES_SUPPORT
|
||||
|
||||
@@ -777,6 +777,11 @@ bool Settings::retinaSupport()
|
||||
return cfg.get("retinaSupport", false);
|
||||
}
|
||||
|
||||
QStringList Settings::ignorePrefixes()
|
||||
{
|
||||
return cfg.get("ignorePrefixes", LibraryDb::ignorePrefixes());
|
||||
}
|
||||
|
||||
void Settings::removeConnectionDetails(const QString &v)
|
||||
{
|
||||
if (v==currentConnection()) {
|
||||
@@ -1262,6 +1267,11 @@ void Settings::saveRetinaSupport(bool v)
|
||||
cfg.set("retinaSupport", v);
|
||||
}
|
||||
|
||||
void Settings::saveIgnorePrefixes(const QStringList &v)
|
||||
{
|
||||
cfg.set("ignorePrefixes", v);
|
||||
}
|
||||
|
||||
void Settings::save()
|
||||
{
|
||||
if (AP_NotConfigured!=state) {
|
||||
|
||||
@@ -163,6 +163,7 @@ public:
|
||||
bool showRatingWidget();
|
||||
bool infoTooltips();
|
||||
bool retinaSupport();
|
||||
QStringList ignorePrefixes();
|
||||
|
||||
void removeConnectionDetails(const QString &v);
|
||||
void saveConnectionDetails(const MPDConnectionDetails &v);
|
||||
@@ -261,6 +262,7 @@ public:
|
||||
void saveShowRatingWidget(bool v);
|
||||
void saveInfoTooltips(bool v);
|
||||
void saveRetinaSupport(bool v);
|
||||
void saveIgnorePrefixes(const QStringList &v);
|
||||
void save();
|
||||
void clearVersion();
|
||||
#if defined ENABLE_KDE_SUPPORT && defined ENABLE_KWALLET
|
||||
|
||||
Reference in New Issue
Block a user