Notes in bookmarks.
[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 /** Search for books, display and download results. */
11 class Search: public QObject
12 {
13     Q_OBJECT
14
15 public:
16     struct Query
17     {
18         QString title;
19         QString author;
20         QStringList languages;
21     };
22
23     struct Result
24     {
25         QString id;
26         QString source;
27         QString title;
28         QStringList authors;
29         QString language;
30         QImage cover;
31     };
32
33     static Search *instance();
34     static void close();
35
36 signals:
37     void beginSearch();
38     void searching();
39     void endSearch();
40     void beginDownload(int totalBlocks);
41     void downloading(int blocks);
42     void endDownload();
43
44 public slots:
45     void start(const Query &query);
46     QList<Result> results();
47     bool download(const Result &result, const QString &fileName);
48
49 protected:
50     explicit Search();
51 };
52
53 #endif // SEARCH_H