Refactoring

This commit is contained in:
Jonas Kvinge
2024-10-22 18:12:33 +02:00
parent dfcf715291
commit 8da2b9cd94
623 changed files with 9071 additions and 5126 deletions

View File

@@ -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));
}

View File

@@ -23,8 +23,6 @@
#ifndef FILTERPARSER_H
#define FILTERPARSER_H
#include "config.h"
#include <QString>
class FilterTree;

View 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_;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View File

@@ -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"

View 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;

View 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

View 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);
}

View 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

View 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;
}

View 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

View 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;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View 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_;
}

View 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

View File

@@ -23,6 +23,8 @@
#include "filtertree.h"
#include "core/song.h"
using namespace Qt::Literals::StringLiterals;
FilterTree::FilterTree() = default;

View File

@@ -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

View 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); });
}

View 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

View 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));
}

View 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

View 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;
}

View 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

View 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);
}

View 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

View 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); });
}

View 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

View 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;
}

View 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