Index: sources/storage/Settings.h =================================================================== diff -u -r54c4136d95375116e6daf23b7d4179159cf13d0c -rfec49d1a8016d25cedff4cf2fefb4c4cd1c7c259 --- sources/storage/Settings.h (.../Settings.h) (revision 54c4136d95375116e6daf23b7d4179159cf13d0c) +++ sources/storage/Settings.h (.../Settings.h) (revision fec49d1a8016d25cedff4cf2fefb4c4cd1c7c259) @@ -30,14 +30,21 @@ namespace Storage { // TODO - IMPORTANT: this MVC needs to change to configurations in oppose to Settings. -// It named settings because it suppose to be like QSettings, -// but since we have settings it is mixing up with that and is very confusing. +// It named settings because it suppose to be like QSettings, +// but since we have settings it is mixing up with that and is very confusing. +// FIXME- IMPORTANT: This set of Settings (MVC) design is not correct: +// - the data structure should change in Model from column based (keys, values) to tree/map based +// - the singleton should be the controller not the Model, to protect the model usage, and avoid the shared memory issues. +// - the model class should be private class, or an object defined in this class, not a global class. class Settings { // Settings - const char *_settingsExt = "conf"; - const char *_settingsFormat = "%1/%2.%3"; + const char *_config_attribute_tag = "#--"; + const char *_duplicate_key_on = "duplicate_key_on"; + const char *_duplicate_key_off = "duplicate_key_off"; + const char *_settingsExt = "conf"; + const char *_settingsFormat = "%1/%2.%3"; struct Detail { QString category; QString location; @@ -52,11 +59,40 @@ bool isValid(const QString &vSettingFile); + QString fileName(const QString &vCategory); + + void update(); + public: Settings() {} int read(); + int save(const QString &vCategory, const QString &vGroup, const QString &vKey, const QString &vValue); + enum Category_Enum { + eInstructions , + eConfigurationsDataList , // TODO: the category for this conf is not used. may need to be merged into the Settings, but since it is list, It needs a little more thought. + eAlarms , + eMessagesUnhandled , + eSettingsSystem , + }; + + static QString category(Category_Enum vCategory) { + switch (vCategory) { // NOTE: don't use default + case eInstructions : return Storage::Settings_Category_Instructions ; + case eConfigurationsDataList : return Storage::Settings_Category_ConfigurationsDataList ; + case eAlarms : return Storage::Settings_Category_Alarms ; + case eMessagesUnhandled : return Storage::Settings_Category_MessagesUnhandled ; + case eSettingsSystem : return Storage::Settings_Category_SettingsSystem ; + } + return ""; + } + + static bool isCategoryInstructions (const QString &vCategory) { return vCategory == category(eInstructions ); } + static bool isCategoryConfigurationsDataList (const QString &vCategory) { return vCategory == category(eConfigurationsDataList ); } + static bool isCategoryAlarms (const QString &vCategory) { return vCategory == category(eAlarms ); } + static bool isCategoryMessagesUnhandled (const QString &vCategory) { return vCategory == category(eMessagesUnhandled ); } + static bool isCategorySettingsSystem (const QString &vCategory) { return vCategory == category(eSettingsSystem ); } }; }