projects
/
dorian
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add tool bar on Symbian. Fix some orientation change bugs.
[dorian]
/
search.h
diff --git
a/search.h
b/search.h
index
47e5b1a
..
4908ac6
100644
(file)
--- a/
search.h
+++ b/
search.h
@@
-7,11
+7,16
@@
#include <QImage>
#include <QList>
#include <QImage>
#include <QList>
+class QNetworkAccessManager;
+class QNetworkReply;
+
+/** Search for books, display and download results. */
class Search: public QObject
{
Q_OBJECT
public:
class Search: public QObject
{
Q_OBJECT
public:
+ /** Search query. */
struct Query
{
QString title;
struct Query
{
QString title;
@@
-19,6
+24,7
@@
public:
QStringList languages;
};
QStringList languages;
};
+ /** Search result. */
struct Result
{
QString id;
struct Result
{
QString id;
@@
-27,6
+33,17
@@
public:
QStringList authors;
QString language;
QImage cover;
QStringList authors;
QString language;
QImage cover;
+ bool operator ==(const Result &other) const {
+ return (source == other.source) && (id == other.id);
+ }
+ };
+
+ /** Download status. */
+ enum
+ {
+ Ok,
+ DownloadError,
+ FileError,
};
static Search *instance();
};
static Search *instance();
@@
-38,15
+55,25
@@
signals:
void endSearch();
void beginDownload(int totalBlocks);
void downloading(int blocks);
void endSearch();
void beginDownload(int totalBlocks);
void downloading(int blocks);
- void endDownload();
+ void endDownload(int status, const Search::Result &result,
+ const QString &fileName);
public slots:
void start(const Query &query);
QList<Result> results();
public slots:
void start(const Query &query);
QList<Result> results();
- bool download(const Result &result, const QString &fileName);
+ void download(const Result &result, const QString &fileName);
+ void finished();
+ void downloadFinished();
-protected:
+private:
explicit Search();
explicit Search();
+ QNetworkAccessManager *manager;
+ QNetworkAccessManager *downloadManager;
+ QNetworkReply *reply;
+ QNetworkReply *downloadReply;
+ QList<Result> searchResults;
+ Search::Result downloadResult;
+ QString downloadFileName;
};
#endif // SEARCH_H
};
#endif // SEARCH_H