*******************************************************************************/
-//Created by Bartosz Szatkowski
+/*! \file settings.h
+\brief Settings object for plugins \see Settings
+
+\author Bartosz Szatkowski <bulislaw@linux.com>
+*/
+
+#ifndef SETTINGS_H
+#define SETTINGS_H
+
#include <QString>
-#include "CommonDictInterface.h"
+#include <QHash>
+#include <QDebug>
+/*! Plugins or dictionaries may need to keep some of configuration between
+ sessions, moreover Backbone or GUI may want to store some additional info in
+ plugin Settings.
+
+ It's important for plugin to store all information given to it in Settings.*/
class Settings {
public:
- QString value(const QString) const = 0;
- void setValue(const QString, const QString) = 0;
- CommonDictInterface type() const = 0;
- void setType(const CommonDictInterface) = 0;
-}
+ Settings(){}
+ Settings(const Settings* set) {
+ _settings = QHash<QString, QString>(set->_settings);
+ }
+ ~Settings(){}
+
+ /*! \returns value fo given key
+ \param key
+ */
+ QString value(const QString key) const {
+ if(!_settings.contains(key)) {
+ return QString();
+ }
+ return _settings[key];
+ }
+
+ //! sets key to value
+ void setValue(const QString key, const QString value) {
+ _settings.insert(key, value);
+ }
+
+ QList<QString> keys() const {
+ return _settings.keys();
+ }
+
+private:
+ QHash<QString, QString> _settings;
+};
+
+#endif // SETTINGS_H