Refactoring
This commit is contained in:
@@ -20,12 +20,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "filterparser.h"
|
||||
#include "filtertree.h"
|
||||
#include "filtertreenop.h"
|
||||
#include "filtertreeand.h"
|
||||
#include "filtertreeor.h"
|
||||
#include "filtertreenot.h"
|
||||
#include "filtertreeterm.h"
|
||||
#include "filtertreecolumnterm.h"
|
||||
#include "filterparsersearchcomparators.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
@@ -52,9 +55,9 @@ void FilterParser::advance() {
|
||||
FilterTree *FilterParser::parseOrGroup() {
|
||||
|
||||
advance();
|
||||
if (iter_ == end_) return new NopFilter;
|
||||
if (iter_ == end_) return new FilterTreeNop;
|
||||
|
||||
OrFilter *group = new OrFilter;
|
||||
FilterTreeOr *group = new FilterTreeOr;
|
||||
group->add(parseAndGroup());
|
||||
advance();
|
||||
while (checkOr()) {
|
||||
@@ -69,9 +72,9 @@ FilterTree *FilterParser::parseOrGroup() {
|
||||
FilterTree *FilterParser::parseAndGroup() {
|
||||
|
||||
advance();
|
||||
if (iter_ == end_) return new NopFilter;
|
||||
if (iter_ == end_) return new FilterTreeNop;
|
||||
|
||||
AndFilter *group = new AndFilter();
|
||||
FilterTreeAnd *group = new FilterTreeAnd();
|
||||
do {
|
||||
group->add(parseSearchExpression());
|
||||
advance();
|
||||
@@ -150,7 +153,7 @@ bool FilterParser::checkOr(const bool step_over) {
|
||||
FilterTree *FilterParser::parseSearchExpression() {
|
||||
|
||||
advance();
|
||||
if (iter_ == end_) return new NopFilter;
|
||||
if (iter_ == end_) return new FilterTreeNop;
|
||||
if (*iter_ == u'(') {
|
||||
++iter_;
|
||||
advance();
|
||||
@@ -166,7 +169,7 @@ FilterTree *FilterParser::parseSearchExpression() {
|
||||
else if (*iter_ == u'-') {
|
||||
++iter_;
|
||||
FilterTree *tree = parseSearchExpression();
|
||||
if (tree->type() != FilterTree::FilterType::Nop) return new NotFilter(tree);
|
||||
if (tree->type() != FilterTree::FilterType::Nop) return new FilterTreeNot(tree);
|
||||
return tree;
|
||||
}
|
||||
else {
|
||||
@@ -232,7 +235,7 @@ FilterTree *FilterParser::parseSearchTerm() {
|
||||
FilterTree *FilterParser::createSearchTermTreeNode(const QString &column, const QString &prefix, const QString &value) const {
|
||||
|
||||
if (value.isEmpty() && prefix != u'=') {
|
||||
return new NopFilter;
|
||||
return new FilterTreeNop;
|
||||
}
|
||||
|
||||
FilterParserSearchTermComparator *cmp = nullptr;
|
||||
@@ -360,10 +363,10 @@ FilterTree *FilterParser::createSearchTermTreeNode(const QString &column, const
|
||||
}
|
||||
|
||||
if (cmp) {
|
||||
return new FilterColumnTerm(column, cmp);
|
||||
return new FilterTreeColumnTerm(column, cmp);
|
||||
}
|
||||
|
||||
return new FilterTerm(new FilterParserTextContainsComparator(value));
|
||||
return new FilterTreeTerm(new FilterParserTextContainsComparator(value));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
#ifndef FILTERPARSER_H
|
||||
#define FILTERPARSER_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
class FilterTree;
|
||||
|
||||
26
src/filterparser/filterparserfloateqcomparator.cpp
Normal file
26
src/filterparser/filterparserfloateqcomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparserfloateqcomparator.h"
|
||||
|
||||
FilterParserFloatEqComparator::FilterParserFloatEqComparator(const float search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserFloatEqComparator::Matches(const QVariant &value) const {
|
||||
return value.toFloat() == search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparserfloateqcomparator.h
Normal file
36
src/filterparser/filterparserfloateqcomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERFLOATEQCOMPARATOR_H
|
||||
#define FILTERPARSERFLOATEQCOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserFloatEqComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserFloatEqComparator(const float search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
float search_term_;
|
||||
Q_DISABLE_COPY(FilterParserFloatEqComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERFLOATEQCOMPARATOR_H
|
||||
26
src/filterparser/filterparserfloatgecomparator.cpp
Normal file
26
src/filterparser/filterparserfloatgecomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparserfloatgecomparator.h"
|
||||
|
||||
FilterParserFloatGeComparator::FilterParserFloatGeComparator(const float search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserFloatGeComparator::Matches(const QVariant &value) const {
|
||||
return value.toFloat() >= search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparserfloatgecomparator.h
Normal file
36
src/filterparser/filterparserfloatgecomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERFLOATGECOMPARATOR_H
|
||||
#define FILTERPARSERFLOATGECOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserFloatGeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserFloatGeComparator(const float search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
float search_term_;
|
||||
Q_DISABLE_COPY(FilterParserFloatGeComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERFLOATGECOMPARATOR_H
|
||||
26
src/filterparser/filterparserfloatgtcomparator.cpp
Normal file
26
src/filterparser/filterparserfloatgtcomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparserfloatgtcomparator.h"
|
||||
|
||||
FilterParserFloatGtComparator::FilterParserFloatGtComparator(const float search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserFloatGtComparator::Matches(const QVariant &value) const {
|
||||
return value.toFloat() > search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparserfloatgtcomparator.h
Normal file
36
src/filterparser/filterparserfloatgtcomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERFLOATGTCOMPARATOR_H
|
||||
#define FILTERPARSERFLOATGTCOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserFloatGtComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserFloatGtComparator(const float search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
float search_term_;
|
||||
Q_DISABLE_COPY(FilterParserFloatGtComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERFLOATGTCOMPARATOR_H
|
||||
26
src/filterparser/filterparserfloatlecomparator.cpp
Normal file
26
src/filterparser/filterparserfloatlecomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparserfloatlecomparator.h"
|
||||
|
||||
FilterParserFloatLeComparator::FilterParserFloatLeComparator(const float search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserFloatLeComparator::Matches(const QVariant &value) const {
|
||||
return value.toFloat() <= search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparserfloatlecomparator.h
Normal file
36
src/filterparser/filterparserfloatlecomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERFLOATLECOMPARATOR_H
|
||||
#define FILTERPARSERFLOATLECOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserFloatLeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserFloatLeComparator(const float search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
float search_term_;
|
||||
Q_DISABLE_COPY(FilterParserFloatLeComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERFLOATLECOMPARATOR_H
|
||||
26
src/filterparser/filterparserfloatltcomparator.cpp
Normal file
26
src/filterparser/filterparserfloatltcomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparserfloatltcomparator.h"
|
||||
|
||||
FilterParserFloatLtComparator::FilterParserFloatLtComparator(const float search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserFloatLtComparator::Matches(const QVariant &value) const {
|
||||
return value.toFloat() < search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparserfloatltcomparator.h
Normal file
36
src/filterparser/filterparserfloatltcomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERFLOATLTCOMPARATOR_H
|
||||
#define FILTERPARSERFLOATLTCOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserFloatLtComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserFloatLtComparator(const float search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
float search_term_;
|
||||
Q_DISABLE_COPY(FilterParserFloatLtComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERFLOATLTCOMPARATOR_H
|
||||
26
src/filterparser/filterparserfloatnecomparator.cpp
Normal file
26
src/filterparser/filterparserfloatnecomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparserfloatnecomparator.h"
|
||||
|
||||
FilterParserFloatNeComparator::FilterParserFloatNeComparator(const float value) : search_term_(value) {}
|
||||
|
||||
bool FilterParserFloatNeComparator::Matches(const QVariant &value) const {
|
||||
return value.toFloat() != search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparserfloatnecomparator.h
Normal file
36
src/filterparser/filterparserfloatnecomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERFLOATNECOMPARATOR_H
|
||||
#define FILTERPARSERFLOATNECOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserFloatNeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserFloatNeComparator(const float value);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
float search_term_;
|
||||
Q_DISABLE_COPY(FilterParserFloatNeComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERFLOATNECOMPARATOR_H
|
||||
26
src/filterparser/filterparserint64eqcomparator.cpp
Normal file
26
src/filterparser/filterparserint64eqcomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparserint64eqcomparator.h"
|
||||
|
||||
FilterParserInt64EqComparator::FilterParserInt64EqComparator(const qint64 search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserInt64EqComparator::Matches(const QVariant &value) const {
|
||||
return value.toLongLong() == search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparserint64eqcomparator.h
Normal file
36
src/filterparser/filterparserint64eqcomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERINT64EQCOMPARATOR_H
|
||||
#define FILTERPARSERINT64EQCOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserInt64EqComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserInt64EqComparator(const qint64 search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
qint64 search_term_;
|
||||
Q_DISABLE_COPY(FilterParserInt64EqComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERINT64EQCOMPARATOR_H
|
||||
26
src/filterparser/filterparserint64gecomparator.cpp
Normal file
26
src/filterparser/filterparserint64gecomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparserint64gecomparator.h"
|
||||
|
||||
FilterParserInt64GeComparator::FilterParserInt64GeComparator(const qint64 search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserInt64GeComparator::Matches(const QVariant &value) const {
|
||||
return value.toLongLong() >= search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparserint64gecomparator.h
Normal file
36
src/filterparser/filterparserint64gecomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERINT64GECOMPARATOR_H
|
||||
#define FILTERPARSERINT64GECOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserInt64GeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserInt64GeComparator(const qint64 search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
qint64 search_term_;
|
||||
Q_DISABLE_COPY(FilterParserInt64GeComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERINT64GECOMPARATOR_H
|
||||
26
src/filterparser/filterparserint64gtcomparator.cpp
Normal file
26
src/filterparser/filterparserint64gtcomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparserint64gtcomparator.h"
|
||||
|
||||
FilterParserInt64GtComparator::FilterParserInt64GtComparator(const qint64 search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserInt64GtComparator::Matches(const QVariant &value) const {
|
||||
return value.toLongLong() > search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparserint64gtcomparator.h
Normal file
36
src/filterparser/filterparserint64gtcomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERINT64GTCOMPARATOR_H
|
||||
#define FILTERPARSERINT64GTCOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserInt64GtComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserInt64GtComparator(const qint64 search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
qint64 search_term_;
|
||||
Q_DISABLE_COPY(FilterParserInt64GtComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERINT64GTCOMPARATOR_H
|
||||
26
src/filterparser/filterparserint64lecomparator.cpp
Normal file
26
src/filterparser/filterparserint64lecomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparserint64lecomparator.h"
|
||||
|
||||
FilterParserInt64LeComparator::FilterParserInt64LeComparator(const qint64 search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserInt64LeComparator::Matches(const QVariant &value) const {
|
||||
return value.toLongLong() <= search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparserint64lecomparator.h
Normal file
36
src/filterparser/filterparserint64lecomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERINT64LECOMPARATOR_H
|
||||
#define FILTERPARSERINT64LECOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserInt64LeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserInt64LeComparator(const qint64 search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
qint64 search_term_;
|
||||
Q_DISABLE_COPY(FilterParserInt64LeComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERINT64LECOMPARATOR_H
|
||||
26
src/filterparser/filterparserint64ltcomparator.cpp
Normal file
26
src/filterparser/filterparserint64ltcomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparserint64ltcomparator.h"
|
||||
|
||||
FilterParserInt64LtComparator::FilterParserInt64LtComparator(const qint64 search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserInt64LtComparator::Matches(const QVariant &value) const {
|
||||
return value.toLongLong() < search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparserint64ltcomparator.h
Normal file
36
src/filterparser/filterparserint64ltcomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERINT64LTCOMPARATOR_H
|
||||
#define FILTERPARSERINT64LTCOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserInt64LtComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserInt64LtComparator(const qint64 search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
qint64 search_term_;
|
||||
Q_DISABLE_COPY(FilterParserInt64LtComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERINT64LTCOMPARATOR_H
|
||||
26
src/filterparser/filterparserint64necomparator.cpp
Normal file
26
src/filterparser/filterparserint64necomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparserint64necomparator.h"
|
||||
|
||||
FilterParserInt64NeComparator::FilterParserInt64NeComparator(const qint64 search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserInt64NeComparator::Matches(const QVariant &value) const {
|
||||
return value.toLongLong() != search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparserint64necomparator.h
Normal file
36
src/filterparser/filterparserint64necomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERINT64NECOMPARATOR_H
|
||||
#define FILTERPARSERINT64NECOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserInt64NeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserInt64NeComparator(const qint64 search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
qint64 search_term_;
|
||||
Q_DISABLE_COPY(FilterParserInt64NeComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERINT64NECOMPARATOR_H
|
||||
26
src/filterparser/filterparserinteqcomparator.cpp
Normal file
26
src/filterparser/filterparserinteqcomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparserinteqcomparator.h"
|
||||
|
||||
FilterParserIntEqComparator::FilterParserIntEqComparator(const int search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserIntEqComparator::Matches(const QVariant &value) const {
|
||||
return value.toInt() == search_term_;
|
||||
}
|
||||
37
src/filterparser/filterparserinteqcomparator.h
Normal file
37
src/filterparser/filterparserinteqcomparator.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERINTEQCOMPARATOR_H
|
||||
#define FILTERPARSERINTEQCOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserIntEqComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserIntEqComparator(const int search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
int search_term_;
|
||||
Q_DISABLE_COPY(FilterParserIntEqComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERINTEQCOMPARATOR_H
|
||||
|
||||
26
src/filterparser/filterparserintgecomparator.cpp
Normal file
26
src/filterparser/filterparserintgecomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparserintgecomparator.h"
|
||||
|
||||
FilterParserIntGeComparator::FilterParserIntGeComparator(const int search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserIntGeComparator::Matches(const QVariant &value) const {
|
||||
return value.toInt() >= search_term_;
|
||||
}
|
||||
37
src/filterparser/filterparserintgecomparator.h
Normal file
37
src/filterparser/filterparserintgecomparator.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERINTGECOMPARATOR_H
|
||||
#define FILTERPARSERINTGECOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserIntGeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserIntGeComparator(const int search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
int search_term_;
|
||||
Q_DISABLE_COPY(FilterParserIntGeComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERINTGECOMPARATOR_H
|
||||
|
||||
26
src/filterparser/filterparserintgtcomparator.cpp
Normal file
26
src/filterparser/filterparserintgtcomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparserintgtcomparator.h"
|
||||
|
||||
FilterParserIntGtComparator::FilterParserIntGtComparator(const int search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserIntGtComparator::Matches(const QVariant &value) const {
|
||||
return value.toInt() > search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparserintgtcomparator.h
Normal file
36
src/filterparser/filterparserintgtcomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERINTGTCOMPARATOR_H
|
||||
#define FILTERPARSERINTGTCOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserIntGtComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserIntGtComparator(const int search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
int search_term_;
|
||||
Q_DISABLE_COPY(FilterParserIntGtComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERINTGTCOMPARATOR_H
|
||||
26
src/filterparser/filterparserintlecomparator.cpp
Normal file
26
src/filterparser/filterparserintlecomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparserintlecomparator.h"
|
||||
|
||||
FilterParserIntLeComparator::FilterParserIntLeComparator(const int search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserIntLeComparator::Matches(const QVariant &value) const {
|
||||
return value.toInt() <= search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparserintlecomparator.h
Normal file
36
src/filterparser/filterparserintlecomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERINTLECOMPARATOR_H
|
||||
#define FILTERPARSERINTLECOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserIntLeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserIntLeComparator(const int search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
int search_term_;
|
||||
Q_DISABLE_COPY(FilterParserIntLeComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERINTLECOMPARATOR_H
|
||||
26
src/filterparser/filterparserintltcomparator.cpp
Normal file
26
src/filterparser/filterparserintltcomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparserintltcomparator.h"
|
||||
|
||||
FilterParserIntLtComparator::FilterParserIntLtComparator(const int search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserIntLtComparator::Matches(const QVariant &value) const {
|
||||
return value.toInt() < search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparserintltcomparator.h
Normal file
36
src/filterparser/filterparserintltcomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERINTLTCOMPARATOR_H
|
||||
#define FILTERPARSERINTLTCOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserIntLtComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserIntLtComparator(const int search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
int search_term_;
|
||||
Q_DISABLE_COPY(FilterParserIntLtComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERINTLTCOMPARATOR_H
|
||||
26
src/filterparser/filterparserintnecomparator.cpp
Normal file
26
src/filterparser/filterparserintnecomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparserintnecomparator.h"
|
||||
|
||||
FilterParserIntNeComparator::FilterParserIntNeComparator(const int search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserIntNeComparator::Matches(const QVariant &value) const {
|
||||
return value.toInt() != search_term_;
|
||||
}
|
||||
37
src/filterparser/filterparserintnecomparator.h
Normal file
37
src/filterparser/filterparserintnecomparator.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERINTNECOMPARATOR_H
|
||||
#define FILTERPARSERINTNECOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserIntNeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserIntNeComparator(const int search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
int search_term_;
|
||||
Q_DISABLE_COPY(FilterParserIntNeComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERINTNECOMPARATOR_H
|
||||
|
||||
@@ -1,314 +1,28 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2012, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERSEARCHCOMPARATORS_H
|
||||
#define FILTERPARSERSEARCHCOMPARATORS_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
#include <QScopedPointer>
|
||||
|
||||
class FilterParserSearchTermComparator {
|
||||
public:
|
||||
FilterParserSearchTermComparator() = default;
|
||||
virtual ~FilterParserSearchTermComparator() = default;
|
||||
virtual bool Matches(const QVariant &value) const = 0;
|
||||
private:
|
||||
Q_DISABLE_COPY(FilterParserSearchTermComparator)
|
||||
};
|
||||
|
||||
// "compares" by checking if the field contains the search term
|
||||
class FilterParserTextContainsComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserTextContainsComparator(const QString &search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.metaType().id() == QMetaType::QString && value.toString().contains(search_term_, Qt::CaseInsensitive);
|
||||
}
|
||||
private:
|
||||
QString search_term_;
|
||||
|
||||
Q_DISABLE_COPY(FilterParserTextContainsComparator)
|
||||
};
|
||||
|
||||
class FilterParserTextEqComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserTextEqComparator(const QString &search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return search_term_.compare(value.toString(), Qt::CaseInsensitive) == 0;
|
||||
}
|
||||
private:
|
||||
QString search_term_;
|
||||
};
|
||||
|
||||
class FilterParserTextNeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserTextNeComparator(const QString &search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return search_term_.compare(value.toString(), Qt::CaseInsensitive) != 0;
|
||||
}
|
||||
private:
|
||||
QString search_term_;
|
||||
};
|
||||
|
||||
class FilterParserIntEqComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserIntEqComparator(const int search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toInt() == search_term_;
|
||||
}
|
||||
private:
|
||||
int search_term_;
|
||||
};
|
||||
|
||||
class FilterParserIntNeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserIntNeComparator(const int search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toInt() != search_term_;
|
||||
}
|
||||
private:
|
||||
int search_term_;
|
||||
};
|
||||
|
||||
class FilterParserIntGtComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserIntGtComparator(const int search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toInt() > search_term_;
|
||||
}
|
||||
private:
|
||||
int search_term_;
|
||||
};
|
||||
|
||||
class FilterParserIntGeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserIntGeComparator(const int search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toInt() >= search_term_;
|
||||
}
|
||||
private:
|
||||
int search_term_;
|
||||
};
|
||||
|
||||
class FilterParserIntLtComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserIntLtComparator(const int search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toInt() < search_term_;
|
||||
}
|
||||
private:
|
||||
int search_term_;
|
||||
};
|
||||
|
||||
class FilterParserIntLeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserIntLeComparator(const int search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toInt() <= search_term_;
|
||||
}
|
||||
private:
|
||||
int search_term_;
|
||||
};
|
||||
|
||||
class FilterParserUIntEqComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserUIntEqComparator(const uint search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toUInt() == search_term_;
|
||||
}
|
||||
private:
|
||||
uint search_term_;
|
||||
};
|
||||
|
||||
class FilterParserUIntNeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserUIntNeComparator(const uint search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toUInt() != search_term_;
|
||||
}
|
||||
private:
|
||||
uint search_term_;
|
||||
};
|
||||
|
||||
class FilterParserUIntGtComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserUIntGtComparator(const uint search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toUInt() > search_term_;
|
||||
}
|
||||
private:
|
||||
uint search_term_;
|
||||
};
|
||||
|
||||
class FilterParserUIntGeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserUIntGeComparator(const uint search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toUInt() >= search_term_;
|
||||
}
|
||||
private:
|
||||
uint search_term_;
|
||||
};
|
||||
|
||||
class FilterParserUIntLtComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserUIntLtComparator(const uint search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toUInt() < search_term_;
|
||||
}
|
||||
private:
|
||||
uint search_term_;
|
||||
};
|
||||
|
||||
class FilterParserUIntLeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserUIntLeComparator(const uint search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toUInt() <= search_term_;
|
||||
}
|
||||
private:
|
||||
uint search_term_;
|
||||
};
|
||||
|
||||
class FilterParserInt64EqComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserInt64EqComparator(const qint64 search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toLongLong() == search_term_;
|
||||
}
|
||||
private:
|
||||
qint64 search_term_;
|
||||
};
|
||||
|
||||
class FilterParserInt64NeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserInt64NeComparator(const qint64 search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toLongLong() != search_term_;
|
||||
}
|
||||
private:
|
||||
qint64 search_term_;
|
||||
};
|
||||
|
||||
class FilterParserInt64GtComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserInt64GtComparator(const qint64 search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toLongLong() > search_term_;
|
||||
}
|
||||
private:
|
||||
qint64 search_term_;
|
||||
};
|
||||
|
||||
class FilterParserInt64GeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserInt64GeComparator(const qint64 search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toLongLong() >= search_term_;
|
||||
}
|
||||
private:
|
||||
qint64 search_term_;
|
||||
};
|
||||
|
||||
class FilterParserInt64LtComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserInt64LtComparator(const qint64 search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toLongLong() < search_term_;
|
||||
}
|
||||
private:
|
||||
qint64 search_term_;
|
||||
};
|
||||
|
||||
class FilterParserInt64LeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserInt64LeComparator(const qint64 search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toLongLong() <= search_term_;
|
||||
}
|
||||
private:
|
||||
qint64 search_term_;
|
||||
};
|
||||
|
||||
// Float Comparators are for the rating
|
||||
class FilterParserFloatEqComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserFloatEqComparator(const float search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toFloat() == search_term_;
|
||||
}
|
||||
private:
|
||||
float search_term_;
|
||||
};
|
||||
|
||||
class FilterParserFloatNeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserFloatNeComparator(const float value) : search_term_(value) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toFloat() != search_term_;
|
||||
}
|
||||
private:
|
||||
float search_term_;
|
||||
};
|
||||
|
||||
class FilterParserFloatGtComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserFloatGtComparator(const float search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toFloat() > search_term_;
|
||||
}
|
||||
private:
|
||||
float search_term_;
|
||||
};
|
||||
|
||||
class FilterParserFloatGeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserFloatGeComparator(const float search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toFloat() >= search_term_;
|
||||
}
|
||||
private:
|
||||
float search_term_;
|
||||
};
|
||||
|
||||
class FilterParserFloatLtComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserFloatLtComparator(const float search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toFloat() < search_term_;
|
||||
}
|
||||
private:
|
||||
float search_term_;
|
||||
};
|
||||
|
||||
class FilterParserFloatLeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserFloatLeComparator(const float search_term) : search_term_(search_term) {}
|
||||
bool Matches(const QVariant &value) const override {
|
||||
return value.toFloat() <= search_term_;
|
||||
}
|
||||
private:
|
||||
float search_term_;
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERSEARCHCOMPARATORS_H
|
||||
#include "filterparserfloateqcomparator.h"
|
||||
#include "filterparserfloatgecomparator.h"
|
||||
#include "filterparserfloatgtcomparator.h"
|
||||
#include "filterparserfloatlecomparator.h"
|
||||
#include "filterparserfloatltcomparator.h"
|
||||
#include "filterparserfloatnecomparator.h"
|
||||
#include "filterparserint64eqcomparator.h"
|
||||
#include "filterparserint64gecomparator.h"
|
||||
#include "filterparserint64gtcomparator.h"
|
||||
#include "filterparserint64lecomparator.h"
|
||||
#include "filterparserint64ltcomparator.h"
|
||||
#include "filterparserint64necomparator.h"
|
||||
#include "filterparserinteqcomparator.h"
|
||||
#include "filterparserintgecomparator.h"
|
||||
#include "filterparserintgtcomparator.h"
|
||||
#include "filterparserintlecomparator.h"
|
||||
#include "filterparserintltcomparator.h"
|
||||
#include "filterparserintnecomparator.h"
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
#include "filterparsertextcontainscomparator.h"
|
||||
#include "filterparsertexteqcomparator.h"
|
||||
#include "filterparsertextnecomparator.h"
|
||||
#include "filterparseruinteqcomparator.h"
|
||||
#include "filterparseruintgecomparator.h"
|
||||
#include "filterparseruintgtcomparator.h"
|
||||
#include "filterparseruintlecomparator.h"
|
||||
#include "filterparseruintltcomparator.h"
|
||||
#include "filterparseruintnecomparator.h"
|
||||
|
||||
24
src/filterparser/filterparsersearchtermcomparator.cpp
Normal file
24
src/filterparser/filterparsersearchtermcomparator.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
FilterParserSearchTermComparator::FilterParserSearchTermComparator() = default;
|
||||
|
||||
FilterParserSearchTermComparator::~FilterParserSearchTermComparator() = default;
|
||||
34
src/filterparser/filterparsersearchtermcomparator.h
Normal file
34
src/filterparser/filterparsersearchtermcomparator.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERSEARCHTERMCOMPARATOR_H
|
||||
#define FILTERPARSERSEARCHTERMCOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
class FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserSearchTermComparator();
|
||||
virtual ~FilterParserSearchTermComparator();
|
||||
virtual bool Matches(const QVariant &value) const = 0;
|
||||
private:
|
||||
Q_DISABLE_COPY(FilterParserSearchTermComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERSEARCHTERMCOMPARATOR_H
|
||||
26
src/filterparser/filterparsertextcontainscomparator.cpp
Normal file
26
src/filterparser/filterparsertextcontainscomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparsertextcontainscomparator.h"
|
||||
|
||||
FilterParserTextContainsComparator::FilterParserTextContainsComparator(const QString &search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserTextContainsComparator::Matches(const QVariant &value) const {
|
||||
return value.metaType().id() == QMetaType::QString && value.toString().contains(search_term_, Qt::CaseInsensitive);
|
||||
}
|
||||
36
src/filterparser/filterparsertextcontainscomparator.h
Normal file
36
src/filterparser/filterparsertextcontainscomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERTEXTCONTAINSCOMPARATOR_H
|
||||
#define FILTERPARSERTEXTCONTAINSCOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserTextContainsComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserTextContainsComparator(const QString &search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
QString search_term_;
|
||||
Q_DISABLE_COPY(FilterParserTextContainsComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERTEXTCONTAINSCOMPARATOR_H
|
||||
26
src/filterparser/filterparsertexteqcomparator.cpp
Normal file
26
src/filterparser/filterparsertexteqcomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparsertexteqcomparator.h"
|
||||
|
||||
FilterParserTextEqComparator::FilterParserTextEqComparator(const QString &search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserTextEqComparator::Matches(const QVariant &value) const {
|
||||
return search_term_.compare(value.toString(), Qt::CaseInsensitive) == 0;
|
||||
}
|
||||
37
src/filterparser/filterparsertexteqcomparator.h
Normal file
37
src/filterparser/filterparsertexteqcomparator.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERTEXTEQCOMPARATOR_H
|
||||
#define FILTERPARSERTEXTEQCOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserTextEqComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserTextEqComparator(const QString &search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
QString search_term_;
|
||||
Q_DISABLE_COPY(FilterParserTextEqComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERTEXTEQCOMPARATOR_H
|
||||
26
src/filterparser/filterparsertextnecomparator.cpp
Normal file
26
src/filterparser/filterparsertextnecomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparsertextnecomparator.h"
|
||||
|
||||
FilterParserTextNeComparator::FilterParserTextNeComparator(const QString &search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserTextNeComparator::Matches(const QVariant &value) const {
|
||||
return search_term_.compare(value.toString(), Qt::CaseInsensitive) != 0;
|
||||
}
|
||||
37
src/filterparser/filterparsertextnecomparator.h
Normal file
37
src/filterparser/filterparsertextnecomparator.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERTEXTNECOMPARATOR_H
|
||||
#define FILTERPARSERTEXTNECOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserTextNeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserTextNeComparator(const QString &search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
QString search_term_;
|
||||
Q_DISABLE_COPY(FilterParserTextNeComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERTEXTNECOMPARATOR_H
|
||||
26
src/filterparser/filterparseruinteqcomparator.cpp
Normal file
26
src/filterparser/filterparseruinteqcomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparseruinteqcomparator.h"
|
||||
|
||||
FilterParserUIntEqComparator::FilterParserUIntEqComparator(const uint search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserUIntEqComparator::Matches(const QVariant &value) const {
|
||||
return value.toUInt() == search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparseruinteqcomparator.h
Normal file
36
src/filterparser/filterparseruinteqcomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERUINTEQCOMPARATOR_H
|
||||
#define FILTERPARSERUINTEQCOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserUIntEqComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserUIntEqComparator(const uint search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
uint search_term_;
|
||||
Q_DISABLE_COPY(FilterParserUIntEqComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERUINTEQCOMPARATOR_H
|
||||
26
src/filterparser/filterparseruintgecomparator.cpp
Normal file
26
src/filterparser/filterparseruintgecomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparseruintgecomparator.h"
|
||||
|
||||
FilterParserUIntGeComparator::FilterParserUIntGeComparator(const uint search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserUIntGeComparator::Matches(const QVariant &value) const {
|
||||
return value.toUInt() >= search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparseruintgecomparator.h
Normal file
36
src/filterparser/filterparseruintgecomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERUINTGECOMPARATOR_H
|
||||
#define FILTERPARSERUINTGECOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserUIntGeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserUIntGeComparator(const uint search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
uint search_term_;
|
||||
Q_DISABLE_COPY(FilterParserUIntGeComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERUINTGECOMPARATOR_H
|
||||
26
src/filterparser/filterparseruintgtcomparator.cpp
Normal file
26
src/filterparser/filterparseruintgtcomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparseruintgtcomparator.h"
|
||||
|
||||
FilterParserUIntGtComparator::FilterParserUIntGtComparator(const uint search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserUIntGtComparator::Matches(const QVariant &value) const {
|
||||
return value.toUInt() > search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparseruintgtcomparator.h
Normal file
36
src/filterparser/filterparseruintgtcomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERUINTGTCOMPARATOR_H
|
||||
#define FILTERPARSERUINTGTCOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserUIntGtComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserUIntGtComparator(const uint search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
uint search_term_;
|
||||
Q_DISABLE_COPY(FilterParserUIntGtComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERUINTGTCOMPARATOR_H
|
||||
26
src/filterparser/filterparseruintlecomparator.cpp
Normal file
26
src/filterparser/filterparseruintlecomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparseruintlecomparator.h"
|
||||
|
||||
FilterParserUIntLeComparator::FilterParserUIntLeComparator(const uint search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserUIntLeComparator::Matches(const QVariant &value) const {
|
||||
return value.toUInt() <= search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparseruintlecomparator.h
Normal file
36
src/filterparser/filterparseruintlecomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERUINTLECOMPARATOR_H
|
||||
#define FILTERPARSERUINTLECOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserUIntLeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserUIntLeComparator(const uint search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
uint search_term_;
|
||||
Q_DISABLE_COPY(FilterParserUIntLeComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERUINTLECOMPARATOR_H
|
||||
26
src/filterparser/filterparseruintltcomparator.cpp
Normal file
26
src/filterparser/filterparseruintltcomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparseruintltcomparator.h"
|
||||
|
||||
FilterParserUIntLtComparator::FilterParserUIntLtComparator(const uint search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserUIntLtComparator::Matches(const QVariant &value) const {
|
||||
return value.toUInt() < search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparseruintltcomparator.h
Normal file
36
src/filterparser/filterparseruintltcomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERUINTLTCOMPARATOR_H
|
||||
#define FILTERPARSERUINTLTCOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserUIntLtComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserUIntLtComparator(const uint search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
uint search_term_;
|
||||
Q_DISABLE_COPY(FilterParserUIntLtComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERUINTLTCOMPARATOR_H
|
||||
26
src/filterparser/filterparseruintnecomparator.cpp
Normal file
26
src/filterparser/filterparseruintnecomparator.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filterparseruintnecomparator.h"
|
||||
|
||||
FilterParserUIntNeComparator::FilterParserUIntNeComparator(const uint search_term) : search_term_(search_term) {}
|
||||
|
||||
bool FilterParserUIntNeComparator::Matches(const QVariant &value) const {
|
||||
return value.toUInt() != search_term_;
|
||||
}
|
||||
36
src/filterparser/filterparseruintnecomparator.h
Normal file
36
src/filterparser/filterparseruintnecomparator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERPARSERUINTNECOMPARATOR_H
|
||||
#define FILTERPARSERUINTNECOMPARATOR_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
class FilterParserUIntNeComparator : public FilterParserSearchTermComparator {
|
||||
public:
|
||||
explicit FilterParserUIntNeComparator(const uint search_term);
|
||||
bool Matches(const QVariant &value) const override;
|
||||
private:
|
||||
uint search_term_;
|
||||
Q_DISABLE_COPY(FilterParserUIntNeComparator)
|
||||
};
|
||||
|
||||
#endif // FILTERPARSERUINTNECOMPARATOR_H
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
#include "filtertree.h"
|
||||
|
||||
#include "core/song.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
FilterTree::FilterTree() = default;
|
||||
|
||||
@@ -22,15 +22,9 @@
|
||||
#ifndef FILTERTREE_H
|
||||
#define FILTERTREE_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include "core/song.h"
|
||||
#include "filterparsersearchcomparators.h"
|
||||
|
||||
class FilterTree {
|
||||
public:
|
||||
@@ -57,99 +51,4 @@ class FilterTree {
|
||||
Q_DISABLE_COPY(FilterTree)
|
||||
};
|
||||
|
||||
// Trivial filter that accepts *anything*
|
||||
class NopFilter : public FilterTree {
|
||||
public:
|
||||
FilterType type() const override { return FilterType::Nop; }
|
||||
bool accept(const Song &song) const override { Q_UNUSED(song); return true; }
|
||||
};
|
||||
|
||||
// Filter that applies a SearchTermComparator to all fields
|
||||
class FilterTerm : public FilterTree {
|
||||
public:
|
||||
explicit FilterTerm(FilterParserSearchTermComparator *comparator) : cmp_(comparator) {}
|
||||
|
||||
FilterType type() const override { return FilterType::Term; }
|
||||
|
||||
bool accept(const Song &song) const override {
|
||||
|
||||
if (cmp_->Matches(song.PrettyTitle())) return true;
|
||||
if (cmp_->Matches(song.album())) return true;
|
||||
if (cmp_->Matches(song.artist())) return true;
|
||||
if (cmp_->Matches(song.albumartist())) return true;
|
||||
if (cmp_->Matches(song.composer())) return true;
|
||||
if (cmp_->Matches(song.performer())) return true;
|
||||
if (cmp_->Matches(song.grouping())) return true;
|
||||
if (cmp_->Matches(song.genre())) return true;
|
||||
if (cmp_->Matches(song.comment())) return true;
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
QScopedPointer<FilterParserSearchTermComparator> cmp_;
|
||||
};
|
||||
|
||||
class FilterColumnTerm : public FilterTree {
|
||||
public:
|
||||
explicit FilterColumnTerm(const QString &column, FilterParserSearchTermComparator *comparator) : column_(column), cmp_(comparator) {}
|
||||
|
||||
FilterType type() const override { return FilterType::Column; }
|
||||
|
||||
bool accept(const Song &song) const override {
|
||||
return cmp_->Matches(DataFromColumn(column_, song));
|
||||
}
|
||||
|
||||
private:
|
||||
const QString column_;
|
||||
QScopedPointer<FilterParserSearchTermComparator> cmp_;
|
||||
};
|
||||
|
||||
class NotFilter : public FilterTree {
|
||||
public:
|
||||
explicit NotFilter(const FilterTree *inv) : child_(inv) {}
|
||||
|
||||
FilterType type() const override { return FilterType::Not; }
|
||||
|
||||
bool accept(const Song &song) const override {
|
||||
return !child_->accept(song);
|
||||
}
|
||||
|
||||
private:
|
||||
QScopedPointer<const FilterTree> child_;
|
||||
};
|
||||
|
||||
class OrFilter : public FilterTree {
|
||||
public:
|
||||
~OrFilter() override { qDeleteAll(children_); }
|
||||
|
||||
FilterType type() const override { return FilterType::Or; }
|
||||
|
||||
virtual void add(FilterTree *child) { children_.append(child); }
|
||||
|
||||
bool accept(const Song &song) const override {
|
||||
return std::any_of(children_.begin(), children_.end(), [song](FilterTree *child) { return child->accept(song); });
|
||||
}
|
||||
|
||||
private:
|
||||
QList<FilterTree*> children_;
|
||||
};
|
||||
|
||||
class AndFilter : public FilterTree {
|
||||
public:
|
||||
~AndFilter() override { qDeleteAll(children_); }
|
||||
|
||||
FilterType type() const override { return FilterType::And; }
|
||||
|
||||
virtual void add(FilterTree *child) { children_.append(child); }
|
||||
|
||||
bool accept(const Song &song) const override {
|
||||
return !std::any_of(children_.begin(), children_.end(), [song](FilterTree *child) { return !child->accept(song); });
|
||||
}
|
||||
|
||||
private:
|
||||
QList<FilterTree*> children_;
|
||||
};
|
||||
|
||||
#endif // FILTERTREE_H
|
||||
|
||||
34
src/filterparser/filtertreeand.cpp
Normal file
34
src/filterparser/filtertreeand.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2012, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filtertreeand.h"
|
||||
|
||||
FilterTreeAnd::FilterTreeAnd() = default;
|
||||
|
||||
FilterTreeAnd::~FilterTreeAnd() {
|
||||
qDeleteAll(children_);
|
||||
}
|
||||
|
||||
void FilterTreeAnd::add(FilterTree *child) { children_.append(child); }
|
||||
|
||||
bool FilterTreeAnd::accept(const Song &song) const {
|
||||
return !std::any_of(children_.begin(), children_.end(), [song](FilterTree *child) { return !child->accept(song); });
|
||||
}
|
||||
46
src/filterparser/filtertreeand.h
Normal file
46
src/filterparser/filtertreeand.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2012, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERTREEAND_H
|
||||
#define FILTERTREEAND_H
|
||||
|
||||
#include <QList>
|
||||
|
||||
#include "filtertree.h"
|
||||
|
||||
#include "core/song.h"
|
||||
|
||||
class FilterTreeAnd : public FilterTree {
|
||||
public:
|
||||
explicit FilterTreeAnd();
|
||||
~FilterTreeAnd() override;
|
||||
|
||||
FilterType type() const override { return FilterType::And; }
|
||||
virtual void add(FilterTree *child);
|
||||
bool accept(const Song &song) const override;
|
||||
|
||||
private:
|
||||
QList<FilterTree*> children_;
|
||||
|
||||
Q_DISABLE_COPY(FilterTreeAnd)
|
||||
};
|
||||
|
||||
#endif // FILTERTREEAND_H
|
||||
31
src/filterparser/filtertreecolumnterm.cpp
Normal file
31
src/filterparser/filtertreecolumnterm.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2012, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "filtertreecolumnterm.h"
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
FilterTreeColumnTerm::FilterTreeColumnTerm(const QString &column, FilterParserSearchTermComparator *comparator) : column_(column), cmp_(comparator) {}
|
||||
|
||||
bool FilterTreeColumnTerm::accept(const Song &song) const {
|
||||
return cmp_->Matches(DataFromColumn(column_, song));
|
||||
}
|
||||
48
src/filterparser/filtertreecolumnterm.h
Normal file
48
src/filterparser/filtertreecolumnterm.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2012, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERTREECOLUMNTERM_H
|
||||
#define FILTERTREECOLUMNTERM_H
|
||||
|
||||
#include <QString>
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include "filtertree.h"
|
||||
|
||||
#include "core/song.h"
|
||||
|
||||
class FilterParserSearchTermComparator;
|
||||
|
||||
class FilterTreeColumnTerm : public FilterTree {
|
||||
public:
|
||||
explicit FilterTreeColumnTerm(const QString &column, FilterParserSearchTermComparator *comparator);
|
||||
|
||||
FilterType type() const override { return FilterType::Column; }
|
||||
bool accept(const Song &song) const override;
|
||||
|
||||
private:
|
||||
const QString column_;
|
||||
QScopedPointer<FilterParserSearchTermComparator> cmp_;
|
||||
|
||||
Q_DISABLE_COPY(FilterTreeColumnTerm)
|
||||
};
|
||||
|
||||
#endif // FILTERTREECOLUMNTERM_H
|
||||
29
src/filterparser/filtertreenop.cpp
Normal file
29
src/filterparser/filtertreenop.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2012, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filtertreenop.h"
|
||||
|
||||
FilterTreeNop::FilterTreeNop() = default;
|
||||
|
||||
bool FilterTreeNop::accept(const Song &song) const {
|
||||
Q_UNUSED(song);
|
||||
return true;
|
||||
}
|
||||
38
src/filterparser/filtertreenop.h
Normal file
38
src/filterparser/filtertreenop.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2012, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERTREENOP_H
|
||||
#define FILTERTREENOP_H
|
||||
|
||||
#include "filtertree.h"
|
||||
|
||||
#include "core/song.h"
|
||||
|
||||
// Trivial filter that accepts *anything*
|
||||
class FilterTreeNop : public FilterTree {
|
||||
public:
|
||||
explicit FilterTreeNop();
|
||||
FilterType type() const override { return FilterType::Nop; }
|
||||
bool accept(const Song &song) const override;
|
||||
Q_DISABLE_COPY(FilterTreeNop)
|
||||
};
|
||||
|
||||
#endif // FILTERTREENOP_H
|
||||
30
src/filterparser/filtertreenot.cpp
Normal file
30
src/filterparser/filtertreenot.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2012, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "filtertreenot.h"
|
||||
|
||||
FilterTreeNot::FilterTreeNot(const FilterTree *inv) : child_(inv) {}
|
||||
|
||||
bool FilterTreeNot::accept(const Song &song) const {
|
||||
return !child_->accept(song);
|
||||
}
|
||||
44
src/filterparser/filtertreenot.h
Normal file
44
src/filterparser/filtertreenot.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2012, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERTREENOT_H
|
||||
#define FILTERTREENOT_H
|
||||
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include "filtertree.h"
|
||||
|
||||
#include "core/song.h"
|
||||
|
||||
class FilterTreeNot : public FilterTree {
|
||||
public:
|
||||
explicit FilterTreeNot(const FilterTree *inv);
|
||||
|
||||
FilterType type() const override { return FilterType::Not; }
|
||||
bool accept(const Song &song) const override;
|
||||
|
||||
private:
|
||||
QScopedPointer<const FilterTree> child_;
|
||||
|
||||
Q_DISABLE_COPY(FilterTreeNot)
|
||||
};
|
||||
|
||||
#endif // FILTERTREENOT_H
|
||||
38
src/filterparser/filtertreeor.cpp
Normal file
38
src/filterparser/filtertreeor.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2012, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "filtertreeor.h"
|
||||
|
||||
FilterTreeOr::FilterTreeOr() = default;
|
||||
|
||||
FilterTreeOr::~FilterTreeOr() {
|
||||
qDeleteAll(children_);
|
||||
}
|
||||
|
||||
void FilterTreeOr::add(FilterTree *child) {
|
||||
children_.append(child);
|
||||
}
|
||||
|
||||
bool FilterTreeOr::accept(const Song &song) const {
|
||||
return std::any_of(children_.begin(), children_.end(), [song](FilterTree *child) { return child->accept(song); });
|
||||
}
|
||||
46
src/filterparser/filtertreeor.h
Normal file
46
src/filterparser/filtertreeor.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2012, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERTREEOR_H
|
||||
#define FILTERTREEOR_H
|
||||
|
||||
#include <QList>
|
||||
|
||||
#include "filtertree.h"
|
||||
|
||||
#include "core/song.h"
|
||||
|
||||
class FilterTreeOr : public FilterTree {
|
||||
public:
|
||||
explicit FilterTreeOr();
|
||||
~FilterTreeOr() override;
|
||||
|
||||
FilterType type() const override { return FilterType::Or; }
|
||||
virtual void add(FilterTree *child);
|
||||
bool accept(const Song &song) const override;
|
||||
|
||||
private:
|
||||
QList<FilterTree*> children_;
|
||||
|
||||
Q_DISABLE_COPY(FilterTreeOr)
|
||||
};
|
||||
|
||||
#endif // FILTERTREEOR_H
|
||||
41
src/filterparser/filtertreeterm.cpp
Normal file
41
src/filterparser/filtertreeterm.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2012, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "filtertreeterm.h"
|
||||
#include "filterparsersearchtermcomparator.h"
|
||||
|
||||
FilterTreeTerm::FilterTreeTerm(FilterParserSearchTermComparator *comparator) : cmp_(comparator) {}
|
||||
|
||||
bool FilterTreeTerm::accept(const Song &song) const {
|
||||
|
||||
if (cmp_->Matches(song.PrettyTitle())) return true;
|
||||
if (cmp_->Matches(song.album())) return true;
|
||||
if (cmp_->Matches(song.artist())) return true;
|
||||
if (cmp_->Matches(song.albumartist())) return true;
|
||||
if (cmp_->Matches(song.composer())) return true;
|
||||
if (cmp_->Matches(song.performer())) return true;
|
||||
if (cmp_->Matches(song.grouping())) return true;
|
||||
if (cmp_->Matches(song.genre())) return true;
|
||||
if (cmp_->Matches(song.comment())) return true;
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
47
src/filterparser/filtertreeterm.h
Normal file
47
src/filterparser/filtertreeterm.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2012, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILTERTREETERM_H
|
||||
#define FILTERTREETERM_H
|
||||
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include "filtertree.h"
|
||||
|
||||
#include "core/song.h"
|
||||
|
||||
class FilterParserSearchTermComparator;
|
||||
|
||||
// Filter that applies a SearchTermComparator to all fields
|
||||
class FilterTreeTerm : public FilterTree {
|
||||
public:
|
||||
explicit FilterTreeTerm(FilterParserSearchTermComparator *comparator);
|
||||
|
||||
FilterType type() const override { return FilterType::Term; }
|
||||
bool accept(const Song &song) const override;
|
||||
|
||||
private:
|
||||
QScopedPointer<FilterParserSearchTermComparator> cmp_;
|
||||
|
||||
Q_DISABLE_COPY(FilterTreeTerm)
|
||||
};
|
||||
|
||||
#endif // FILTERTREETERM_H
|
||||
Reference in New Issue
Block a user