2010-03-24 00:11:46 +01:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
|
|
|
|
Clementine 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.
|
|
|
|
|
|
|
|
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
#ifndef LIBRARYQUERY_H
|
|
|
|
#define LIBRARYQUERY_H
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <QSqlQuery>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QVariantList>
|
|
|
|
|
2010-01-15 22:43:57 +01:00
|
|
|
class Song;
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
struct QueryOptions {
|
|
|
|
QueryOptions() : max_age(-1) {}
|
|
|
|
|
2010-01-15 22:43:57 +01:00
|
|
|
bool Matches(const Song& song) const;
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
QString filter;
|
|
|
|
int max_age;
|
|
|
|
};
|
|
|
|
|
|
|
|
class LibraryQuery {
|
|
|
|
public:
|
|
|
|
LibraryQuery();
|
|
|
|
LibraryQuery(const QueryOptions& options);
|
|
|
|
|
|
|
|
void SetColumnSpec(const QString& spec) { column_spec_ = spec; }
|
2010-02-28 19:04:50 +01:00
|
|
|
void SetOrderBy(const QString& order_by) { order_by_ = order_by; }
|
2009-12-24 20:16:07 +01:00
|
|
|
void AddWhere(const QString& column, const QVariant& value);
|
2010-02-27 21:12:22 +01:00
|
|
|
void AddCompilationRequirement(bool compilation);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
|
|
|
QSqlQuery Query(QSqlDatabase db) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString column_spec_;
|
2010-02-28 19:04:50 +01:00
|
|
|
QString order_by_;
|
2009-12-24 20:16:07 +01:00
|
|
|
QStringList where_clauses_;
|
|
|
|
QVariantList bound_values_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LIBRARYQUERY_H
|