Documents > BPS V2 C++ API
bpssettings.h
Go to the documentation of this file.
00001 
00004 #ifndef BPSSETTINGS_H
00005 #define BPSSETTINGS_H
00006 
00007 #include <QObject>
00008 #include <QStringList>
00009 #include "bps.h"
00010 
00011 class BpsDatastore;
00012 
00016 class BPSCORE_EXPORT BpsSettings : public QObject
00017 {
00018     Q_OBJECT
00019     Q_FLAGS(Scopes)
00020     BPS_PRIVATE(BpsSettings)
00021 
00022 public:
00023 
00030     enum Scope {
00035         NoScope             = 0x00000000,
00036 
00041         LocalUserScope      = 0x00000001,
00042 
00049         LocalInstallScope   = 0x00000002,
00050 
00055         LocalSystemScope    = 0x00000004,
00056 
00061         CentralUserScope    = 0x00000010,
00062 
00067         CentralSystemScope  = 0x00000020,
00068 
00073         LocalScopes         = LocalUserScope | LocalInstallScope | LocalSystemScope,
00074 
00079         CentralScopes       = CentralUserScope | CentralSystemScope,
00080 
00085         AllScopes           = LocalScopes | CentralScopes
00086 
00087     };
00088 
00089     Q_DECLARE_FLAGS(Scopes, Scope)
00090 
00091     
00099     BpsSettings(
00100         BpsDatastore* aDatastore, 
00101         Scope aScope = BpsSettings::LocalUserScope, 
00102         QObject* aParent = 0);
00103 
00110     BpsSettings(
00111         Scope aScope = BpsSettings::LocalUserScope, 
00112         QObject* aParent = 0);
00113 
00114     virtual ~BpsSettings();
00115 
00119     Scope scope() const;
00120 
00130     Scope groupScope(const QString& aName, Scopes aSearchedScopes = (Scopes)AllScopes) const;
00131 
00136     void setScope(Scope aScope);
00137 
00143     QString root() const;
00144 
00150     void setRoot(const QString& aRoot);
00151 
00156     void open(const QString& aPath);
00157 
00161     void close();
00162 
00167     void closeAll();
00168 
00173     QStringList groups() const; 
00174 
00181     bool groupExists(const QString& aGroup) const;
00182 
00187     QStringList keys() const;
00188 
00195     bool keyExists(const QString& aKey) const;
00196 
00203     QVariant value(const QString& aKey, const QVariant& aDefValue = QVariant()) const;
00204 
00214     QStringList allGroups(Scopes aSearchedScopes = (Scopes)AllScopes) const;
00215 
00225     QStringList allKeys(Scopes aSearchedScopes = (Scopes)AllScopes) const;
00226 
00238     QVariant findValue(
00239         const QString& aKey, 
00240         const QVariant& aDefValue = QVariant(),
00241         Scopes aSearchedScopes = (Scopes)AllScopes) const;
00242 
00248     void setValue(const QString& aKey, const QVariant& aValue); 
00249 
00254     void removeKey(const QString& aKey);
00255 
00261     void removeGroup(const QString& aName);
00262 
00272     QVariantMap valueMap(Scopes aSearchedScopes = (Scopes)AllScopes) const;
00273 
00278     void setValueMap(const QVariantMap& aMap);
00279 
00280 }; // BpsSettings
00281 
00282 Q_DECLARE_OPERATORS_FOR_FLAGS(BpsSettings::Scopes)
00283 
00284 #endif // BPSSETTINGS_H