1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef ONLINETVSHOWDATABASE_H
#define ONLINETVSHOWDATABASE_H
#include "nwutils.h"
#include "tvshow.h"
#include "curlresult.h"
#include <QDir>
#include "onlinecredentials.h"
class Library;
namespace OnlineTvShowDatabase {
enum UpdateFilter {
ufNone = 0,
ufSynopsis = 1 << 1,
ufTitle = 1 << 2,
ufRelations = 1 << 3,
ufAiringDates = 1 << 4,
ufSynonyms = 1 << 5,
ufRemoteId = 1 << 6,
ufImage = 1 << 7,
ufAll = ((unsigned int)-1)
};
class Entry {
public:
Entry();
virtual ~Entry();
void updateShow(TvShow& show, const Library& library, const QString identifierKey, UpdateFilter filter = OnlineTvShowDatabase::ufAll) const;
virtual int getRemoteId() const = 0;
virtual void updateSynopsis(TvShow& show) const = 0;
virtual void updateTitle(TvShow& show) const = 0;
virtual void updateRemoteId(TvShow& show) const = 0;
virtual void updateRelations(TvShow& show) const = 0;
virtual void updateAiringDates(TvShow& show) const = 0;
virtual QStringList getSynonyms() const = 0;
virtual void updateImage(TvShow& show, QDir libraryDir) const = 0;
};
class SearchResult {
public:
SearchResult(QString searchedQuery = QString());
virtual ~SearchResult();
// TODO make this true const again fucking shit
virtual Entry* bestEntry() = 0;
const QString searchedQuery;
QList<Entry*> entries;
};
class Client : public QObject {
Q_OBJECT
public:
Client(OnlineCredentials& credentials, OnlineCredentials::TimeLock& lock, QObject* parent = NULL);
SearchResult* findShow(TvShow& show);
virtual const QString identifierKey() const = 0;
virtual UpdateFilter getFilter() { return UpdateFilter::ufRemoteId; }
const OnlineCredentials& credentials;
protected:
virtual SearchResult* search(QString anime) = 0;
OnlineCredentials::TimeLock& lock;
};
}
#endif // ONLINETVSHOWDATABASE_H