47e5b1a27f946189322586af1efa6d0c3552b989
[dorian] / search.h
1 #ifndef SEARCH_H
2 #define SEARCH_H
3
4 #include <QObject>
5 #include <QString>
6 #include <QStringList>
7 #include <QImage>
8 #include <QList>
9
10 class Search: public QObject
11 {
12     Q_OBJECT
13
14 public:
15     struct Query
16     {
17         QString title;
18         QString author;
19         QStringList languages;
20     };
21
22     struct Result
23     {
24         QString id;
25         QString source;
26         QString title;
27         QStringList authors;
28         QString language;
29         QImage cover;
30     };
31
32     static Search *instance();
33     static void close();
34
35 signals:
36     void beginSearch();
37     void searching();
38     void endSearch();
39     void beginDownload(int totalBlocks);
40     void downloading(int blocks);
41     void endDownload();
42
43 public slots:
44     void start(const Query &query);
45     QList<Result> results();
46     bool download(const Result &result, const QString &fileName);
47
48 protected:
49     explicit Search();
50 };
51
52 #endif // SEARCH_H