Some fixes to connection manager.
[jenirok] / src / common / dastelefonbuch.h
1 #ifndef DASTELEFONBUCH_H
2 #define DASTELEFONBUCH_H
3
4 #include <QtCore/QList>
5 #include <QtCore/QSet>
6 #include <QtCore/QVector>
7 #include <QtCore/QByteArray>
8 #include "source.h"
9
10 class DasTelefonbuch : public Source
11 {
12 public:
13     DasTelefonbuch(QObject* parent = 0);
14     ~DasTelefonbuch();
15     virtual void abort();
16     virtual void search(Source::SearchDetails const& details);
17
18 private:
19
20     struct SearchData
21     {
22         QSet<int> searchIds;
23         Source::SearchDetails details;
24         QVector<Source::Result> results;
25         int currentPage;
26         int totalSearches;
27         int finishedSearches;
28     };
29
30     void addNumbers(SearchData* searchData, QString const& data, int index);
31     void addOnlyNumber(SearchData* searchData, QString const& data, int index);
32     bool formatResult(QString& name, QString& number, QString& street, QString& city, Source::Result& result);
33     void emitRequestFinished(SearchData* data, bool error, int index);
34     int sendQuery(Source::SearchDetails const& details, int page = 1);
35     virtual void getSearchTypes(QList<SearchType>& types) const;
36
37     QList<SearchData*> pendingSearches_;
38
39     Q_DISABLE_COPY(DasTelefonbuch);
40     virtual void handleHttpData(int id, QByteArray const& data);
41     virtual void handleHttpError(int id);
42 };
43
44 #endif // DASTELEFONBUCH_H