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; }
|
|
|
|
void AddWhere(const QString& column, const QVariant& value);
|
|
|
|
|
|
|
|
QSqlQuery Query(QSqlDatabase db) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString column_spec_;
|
|
|
|
QStringList where_clauses_;
|
|
|
|
QVariantList bound_values_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LIBRARYQUERY_H
|