mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-15 10:48:33 +01:00
Obey the filter when updating songs in the database/library.
This commit is contained in:
parent
70613f5299
commit
07ef49f380
@ -80,6 +80,9 @@ void Library::Initialise() {
|
||||
|
||||
void Library::SongsDiscovered(const SongList& songs) {
|
||||
foreach (const Song& song, songs) {
|
||||
if (!query_options_.Matches(song))
|
||||
continue;
|
||||
|
||||
LibraryItem* artist = NULL;
|
||||
LibraryItem* album = NULL;
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "libraryquery.h"
|
||||
#include "song.h"
|
||||
|
||||
#include <QtDebug>
|
||||
#include <QDateTime>
|
||||
@ -54,3 +55,19 @@ QSqlQuery LibraryQuery::Query(QSqlDatabase db) const {
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
bool QueryOptions::Matches(const Song& song) const {
|
||||
if (max_age != -1) {
|
||||
const uint cutoff = QDateTime::currentDateTime().toTime_t() - max_age;
|
||||
if (song.ctime() <= cutoff)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!filter.isNull()) {
|
||||
return song.artist().contains(filter, Qt::CaseInsensitive) ||
|
||||
song.album().contains(filter, Qt::CaseInsensitive) ||
|
||||
song.title().contains(filter, Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -7,9 +7,13 @@
|
||||
#include <QStringList>
|
||||
#include <QVariantList>
|
||||
|
||||
class Song;
|
||||
|
||||
struct QueryOptions {
|
||||
QueryOptions() : max_age(-1) {}
|
||||
|
||||
bool Matches(const Song& song) const;
|
||||
|
||||
QString filter;
|
||||
int max_age;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user