removeAccents refactorized out to the AccentsNormalizer class
[mdictionary] / trunk / src / includes / settings.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 /*! /file settings.h
23 \brief Settings object for pluggins \see Settings
24
25 \author Bartosz Szatkowski <bulislaw@linux.com>
26 */
27
28 #ifndef SETTINGS_H
29 #define SETTINGS_H
30
31 #include <QString>
32 #include <QHash>
33 #include <QDebug>
34
35 /*! Plugins or dictionaries may need to keep some of configuration between
36   sessions, moreover Backbone or GUI may want store some additional info in
37   plugin Settings.
38
39   Its important for plugin to store all information given it in Settings.*/
40 class Settings {
41   public:
42     Settings(){}
43     Settings(const Settings* set) {
44         _settings = QHash<QString, QString>(set->_settings);
45     }
46     ~Settings(){}
47
48     /*! \returns value fo given key
49          \param key
50     */
51     QString value(const QString key) const {
52         if(!_settings.contains(key)) {
53             return QString();
54         }
55         return _settings[key];
56     }
57
58     //! sets key to value
59     void setValue(const QString key, const QString value) {
60         _settings.insert(key, value);
61     }
62
63     QList<QString> keys() const {
64         return _settings.keys();
65     }
66
67 private:
68     QHash<QString, QString> _settings;
69 };
70
71 #endif // SETTINGS_H