change comment's and fix bug (xslt transform)
[mdictionary] / src / include / 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 plugins \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 to store some additional info in
37   plugin Settings.
38
39   It's important for plugin to store all information given to it in Settings.*/
40 class Settings {
41   public:
42     Settings() {}
43     ~Settings() {}
44     Settings(const Settings* set) {
45         _settings = QHash<QString, QString>(set->_settings);
46     }
47
48     /*!
49         \returns value fo a given key
50         \param key name of a given setting
51         \return value of a given setting
52     */
53     QString value(const QString key) const {
54         if(!_settings.contains(key)) {
55             return QString();
56         }
57         return _settings[key];
58     }
59
60     /*! sets key to a value
61         \param key name of a given setting
62         \param value value of a given setting
63     */
64     void setValue(const QString key, const QString value) {
65         _settings.insert(key, value);
66     }
67
68     //! \returns list of keys (QList<QString>)
69     QList<QString> keys() const {
70         return _settings.keys();
71     }
72
73 private:
74     //! keeps the settings
75     QHash<QString, QString> _settings;
76 };
77
78 #endif // SETTINGS_H