1 | /* |
---|
2 | * BCAccountLoadManager.h |
---|
3 | * |
---|
4 | * Created on: Aug 30, 2009 |
---|
5 | * Author: saemy |
---|
6 | */ |
---|
7 | |
---|
8 | #ifndef BCACCOUNTLOADMANAGER_H_ |
---|
9 | #define BCACCOUNTLOADMANAGER_H_ |
---|
10 | |
---|
11 | #include <QMap> |
---|
12 | #include <QSet> |
---|
13 | |
---|
14 | #include <iaccount.h> |
---|
15 | #include <stdexceptions.h> |
---|
16 | |
---|
17 | #include "BCAccountLoadThread.h" |
---|
18 | |
---|
19 | class BCAccountLoadManager : public QObject { |
---|
20 | Q_OBJECT |
---|
21 | |
---|
22 | public: |
---|
23 | static BCAccountLoadManager* instance(); |
---|
24 | |
---|
25 | virtual void loadAccount(IAccount* account); |
---|
26 | virtual bool isAccountLoading(IAccount* account); |
---|
27 | virtual void cancelAccountLoading(IAccount* account); |
---|
28 | virtual AccountLoadState getLoadStateOfAccount(IAccount* account); |
---|
29 | |
---|
30 | virtual void loadAccounts(const QSet<IAccount*>& accounts); |
---|
31 | |
---|
32 | signals: |
---|
33 | void accountLoadStateChanged(IAccount* account, AccountLoadState state); |
---|
34 | void accountLoaded(IAccount* account); |
---|
35 | void accountLoadingFinished(IAccount* account, AccountLoadState state); |
---|
36 | void accountLoadingFailed(IAccount* account, EException* exception); |
---|
37 | |
---|
38 | protected: |
---|
39 | BCAccountLoadManager(){} |
---|
40 | virtual ~BCAccountLoadManager(); |
---|
41 | |
---|
42 | virtual BCAccountLoadThread* getAccountLoadThread(IAccount* account); |
---|
43 | |
---|
44 | protected slots: |
---|
45 | void accountLoadThreadLoadStateChanged(IAccount* account, AccountLoadState state); |
---|
46 | void accountLoadThreadLoaded(IAccount* account); |
---|
47 | void accountLoadThreadLoadingFinished(IAccount* account, AccountLoadState state); |
---|
48 | void accountLoadThreadLoadingFailed(IAccount* account, EException* exception); |
---|
49 | |
---|
50 | |
---|
51 | private: |
---|
52 | static BCAccountLoadManager* instance_; |
---|
53 | |
---|
54 | QMap<IAccount*, BCAccountLoadThread*> accountLoadThreads_; |
---|
55 | }; |
---|
56 | //Q_DECLARE_METATYPE(BCAccountLoadManager); |
---|
57 | |
---|
58 | #endif /* BCACCOUNTLOADMANAGER_H_ */ |
---|