*******************************************************************************/
-//Created by Bartosz Szatkowski
+/*! /file settings.h
+\brief Settings object for pluggins \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 store some additional info in
+ plugin Settings.
-//! Plugin specific configuration
+ Its important for plugin to store all information given it in Settings.*/
class Settings {
public:
- //! \retrun value fo given key
- //! \param key
- virtual QString value(const QString key) const = 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
- virtual void setValue(const QString key, const QString value) = 0;
+ void setValue(const QString key, const QString value) {
+ _settings.insert(key, value);
+ }
- //! \return dict CommonDictInterface
- virtual CommonDictInterface* type() const = 0;
+ QList<QString> keys() const {
+ return _settings.keys();
+ }
- //! sets settings type to given dictionary
- virtual void setType(const CommonDictInterface*) = 0;
+private:
+ QHash<QString, QString> _settings;
};
-#endif
+#endif // SETTINGS_H