David's comments
This commit is contained in:
parent
0182829223
commit
d109b70898
@ -589,7 +589,7 @@ void LibraryModel::BeginReset() {
|
||||
}
|
||||
|
||||
// Smart playlists?
|
||||
if (show_smart_playlists_ && query_options_.get_filter().isEmpty())
|
||||
if (show_smart_playlists_ && query_options_.filter().isEmpty())
|
||||
CreateSmartPlaylists();
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@
|
||||
#include <QSqlError>
|
||||
|
||||
QueryOptions::QueryOptions()
|
||||
: max_age(-1),
|
||||
query_mode(QueryMode_All)
|
||||
: max_age_(-1),
|
||||
query_mode_(QueryMode_All)
|
||||
{
|
||||
}
|
||||
|
||||
@ -33,14 +33,14 @@ LibraryQuery::LibraryQuery(const QueryOptions& options)
|
||||
: join_with_fts_(false),
|
||||
limit_(-1)
|
||||
{
|
||||
if (!options.get_filter().isEmpty()) {
|
||||
if (!options.filter().isEmpty()) {
|
||||
// We need to munge the filter text a little bit to get it to work as
|
||||
// expected with sqlite's FTS3:
|
||||
// 1) Append * to all tokens.
|
||||
// 2) Prefix "fts" to column names.
|
||||
|
||||
// Split on whitespace
|
||||
QStringList tokens(options.get_filter().split(QRegExp("\\s+")));
|
||||
QStringList tokens(options.filter().split(QRegExp("\\s+")));
|
||||
QString query;
|
||||
foreach (QString token, tokens) {
|
||||
token.remove('(');
|
||||
@ -57,8 +57,8 @@ LibraryQuery::LibraryQuery(const QueryOptions& options)
|
||||
join_with_fts_ = true;
|
||||
}
|
||||
|
||||
if (options.get_max_age() != -1) {
|
||||
int cutoff = QDateTime::currentDateTime().toTime_t() - options.get_max_age();
|
||||
if (options.max_age() != -1) {
|
||||
int cutoff = QDateTime::currentDateTime().toTime_t() - options.max_age();
|
||||
|
||||
where_clauses_ << "ctime > ?";
|
||||
bound_values_ << cutoff;
|
||||
@ -71,9 +71,9 @@ LibraryQuery::LibraryQuery(const QueryOptions& options)
|
||||
// consistent - this way filtering is available only in the All mode.
|
||||
// remember though that when you fix the Duplicates + FTS cooperation, enable the
|
||||
// filtering in both Duplicates and Untagged modes.
|
||||
duplicates_only_ = options.get_query_mode() == QueryOptions::QueryMode_Duplicates;
|
||||
duplicates_only_ = options.query_mode() == QueryOptions::QueryMode_Duplicates;
|
||||
|
||||
if (options.get_query_mode() == QueryOptions::QueryMode_Untagged) {
|
||||
if (options.query_mode() == QueryOptions::QueryMode_Untagged) {
|
||||
where_clauses_ << "(artist = '' OR album = '' OR title ='')";
|
||||
}
|
||||
}
|
||||
@ -159,16 +159,16 @@ QVariant LibraryQuery::Value(int column) const {
|
||||
}
|
||||
|
||||
bool QueryOptions::Matches(const Song& song) const {
|
||||
if (max_age != -1) {
|
||||
const uint cutoff = QDateTime::currentDateTime().toTime_t() - max_age;
|
||||
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);
|
||||
if (!filter_.isNull()) {
|
||||
return song.artist().contains(filter_, Qt::CaseInsensitive) ||
|
||||
song.album().contains(filter_, Qt::CaseInsensitive) ||
|
||||
song.title().contains(filter_, Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -48,25 +48,25 @@ struct QueryOptions {
|
||||
|
||||
bool Matches(const Song& song) const;
|
||||
|
||||
QString get_filter() const { return filter; }
|
||||
QString filter() const { return filter_; }
|
||||
void set_filter(const QString& filter) {
|
||||
this->filter = filter;
|
||||
this->query_mode = QueryMode_All;
|
||||
this->filter_ = filter;
|
||||
this->query_mode_ = QueryMode_All;
|
||||
}
|
||||
|
||||
int get_max_age() const { return max_age; }
|
||||
void set_max_age(int max_age) { this->max_age = max_age; }
|
||||
int max_age() const { return max_age_; }
|
||||
void set_max_age(int max_age) { this->max_age_ = max_age; }
|
||||
|
||||
QueryMode get_query_mode() const { return query_mode; }
|
||||
QueryMode query_mode() const { return query_mode_; }
|
||||
void set_query_mode(QueryMode query_mode) {
|
||||
this->query_mode = query_mode;
|
||||
this->filter = QString();
|
||||
this->query_mode_ = query_mode;
|
||||
this->filter_ = QString();
|
||||
}
|
||||
|
||||
private:
|
||||
QString filter;
|
||||
int max_age;
|
||||
QueryMode query_mode;
|
||||
QString filter_;
|
||||
int max_age_;
|
||||
QueryMode query_mode_;
|
||||
};
|
||||
|
||||
class LibraryQuery {
|
||||
|
Loading…
x
Reference in New Issue
Block a user