Test suit expanded (added few tests and mocks)
[mdictionary] / trunk / src / base / backbone / backbone.h
1 /*******************************************************************************
2
3     This file is part of mDictionary.
4
5     mDictionary is free software: you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation, either version 3 of the License, or
8     (at your option) any later version.
9
10     mDictionary is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
17
18     Copyright 2010 Comarch S.A.
19
20 *******************************************************************************/
21
22 // Created by Bartosz Szatkowski
23
24 #ifndef BACKBONE_H
25 #define BACKBONE_H
26
27 #include <QObject>
28 #include <QList>
29 #include <QHash>
30 #include "../../includes/CommonDictInterface.h"
31 #include "../../includes/settings.h"
32 #include "../../includes/translation.h"
33
34
35 //! Inner part of dictionary - glues together GUI and plugins
36 class Backbone : public QObject
37 {
38     Q_OBJECT
39
40 public:
41     Backbone(QObject *parent = 0);
42     ~Backbone();
43     Backbone(const Backbone& b);
44
45     //! \return all loadded dictionaries with activity state flag
46     QHash<CommonDictInterface*, bool> getDictionaries();
47
48     //! \return all loadded plugins
49     QList<CommonDictInterface*> getPlugins();
50
51     //! \return history of performed searches
52     QList<QString> getHistory(); //TODO implementation needed (in future)
53
54     //! \return return search fesult
55     QHash<QString, Translation*> result();
56
57     //! \return maximum number of word that plugin could find
58     int searchLimit() const;
59
60 public Q_SLOTS:
61     //! stops all current searches
62     void stopSearching();
63
64     //! search for a word translation
65     void search(QString word);
66
67     //! sets active dictionaries
68     void selectedDictionaries(QList<CommonDictInterface* >);
69
70     //! adds new dictionary
71     void addDictionary(CommonDictInterface* dict);
72
73
74     //! stops all current activity and kill plugins - be ready to exit
75     void quit();
76
77
78     //! Fired when dictionary call finalTranslation(..) with translation ready
79     void translation(QList<Translation*>);
80
81     // TODO void removeDictionary(CommonDictInterface* dict);
82     // TODO addToBookmark(Translation*);
83     // TODO removeFromBookmark(Translation*);
84
85 Q_SIGNALS:
86     //! emmited when backbone is ready to close - after getting stop signal it
87     //!     should kill all threads and so on
88     void closeOk();
89
90     //! emitted when there are search result ready to fetch
91     void ready();
92
93
94
95 private:
96     QHash<CommonDictInterface*, bool> dicts;
97     QList<CommonDictInterface*> plugins;
98     QHash<QString, Translation*> resultv;
99     int searchLimitv;
100
101 };
102
103 #endif // BACKBONE_H