Changed Backbone::addDictionary to take CommmonDictInterface as a parametr
[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 public Q_SLOTS:
58     //! stops all current searches
59     void stopSearching();
60
61     //! search for a word translation
62     void search(QString word);
63
64     //! sets active dictionaries
65     void selectedDictionaries(QList<CommonDictInterface* >);
66
67     //! adds new dictionary
68     void addDictionary(CommonDictInterface* dict);
69
70
71     //! stops all current activity and kill plugins - be ready to exit
72     void quit();
73
74     //! \return maximum number of word that plugin could find
75     int searchLimit();
76
77     // TODO void removeDictionary(CommonDictInterface* dict);
78     // TODO addToBookmark(Translation*);
79     // TODO removeFromBookmark(Translation*);
80
81 Q_SIGNALS:
82     //! emmited when backbone is ready to close - after getting stop signal it
83     //!     should kill all threads and so on
84     void closeOk();
85
86     //! emitted when there are search result ready to fetch
87     void ready();
88
89 private:
90     QHash<CommonDictInterface*, bool> dicts;
91     QList<CommonDictInterface*> plugins;
92     QHash<QString, Translation*> resultv;
93     int searchLimitv;
94
95 };
96
97 #endif // BACKBONE_H