Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/library/searchquery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,11 @@ BpmFilterNode::BpmFilterNode(QString& argument, bool fuzzy, bool negate)
return;
}

if (argument == QStringLiteral("locked")) {
m_matchMode = MatchMode::Locked;
return;
}

QRegularExpressionMatch opMatch = kNumericOperatorRegex.match(argument);
if (opMatch.hasMatch()) {
if (fuzzy) {
Expand Down Expand Up @@ -688,6 +693,10 @@ BpmFilterNode::BpmFilterNode(QString& argument, bool fuzzy, bool negate)
}

bool BpmFilterNode::match(const TrackPointer& pTrack) const {
if (m_matchMode == MatchMode::Locked) {
return pTrack->isBpmLocked();
}

double value = pTrack->getBpm();

switch (m_matchMode) {
Expand Down Expand Up @@ -728,8 +737,11 @@ bool BpmFilterNode::match(const TrackPointer& pTrack) const {

QString BpmFilterNode::toSql() const {
switch (m_matchMode) {
case MatchMode::Locked: {
return QStringLiteral("%1 IS 1").arg(LIBRARYTABLE_BPM_LOCK);
}
case MatchMode::Null: {
return QString("bpm IS 0");
return QStringLiteral("bpm IS 0");
}
case MatchMode::Explicit: {
return QStringLiteral("bpm >= %1 AND bpm < %2")
Expand All @@ -756,10 +768,10 @@ QString BpmFilterNode::toSql() const {
return concatSqlClauses(searchClauses, "OR");
}
case MatchMode::Operator: {
return QString("bpm %1 %2").arg(m_operator, QString::number(m_bpm));
return QStringLiteral("bpm %1 %2").arg(m_operator, QString::number(m_bpm));
}
default: // MatchMode::Invalid
return QString("bpm IS NULL");
return QStringLiteral("bpm IS NULL");
}
}

Expand Down
1 change: 1 addition & 0 deletions src/library/searchquery.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ class BpmFilterNode : public QueryNode {
HalveDouble, // bpm:120
HalveDoubleStrict, // bpm:120.0
Operator, // bpm:<=120
Locked, // bpm:locked
};

// Allows WSearchRelatedTracksMenu to construct the QAction title
Expand Down