diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 4aed2c8219774f5d797760606b8489a92ddc5163 (patch) | |
tree | 3f8c130f7d269626bf6a9447407ef6c35954426a /kcontrol/konqhtml/policies.h | |
download | tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kcontrol/konqhtml/policies.h')
-rw-r--r-- | kcontrol/konqhtml/policies.h | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/kcontrol/konqhtml/policies.h b/kcontrol/konqhtml/policies.h new file mode 100644 index 000000000..b5643c0bd --- /dev/null +++ b/kcontrol/konqhtml/policies.h @@ -0,0 +1,134 @@ +/* + Copyright (c) 2002 Leo Savernik <[email protected]> + Derived from jsopt.h, code copied from there is copyrighted to its + respective owners. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +*/ + +#ifndef __POLICIES_H__ +#define __POLICIES_H__ + +#include <qstring.h> + +class KConfig; + +// special value for inheriting a global policy +#define INHERIT_POLICY 32767 + +/** + * @short Contains the basic policies and methods for their manipulation. + * + * This class provides access to the basic policies that are common + * to all features. + * + * @author Leo Savernik + */ +class Policies { +public: + /** + * constructor + * @param config configuration to initialize this instance from + * @param group config group to use if this instance contains the global + * policies (global == true) + * @param global true if this instance contains the global policy settings, + * false if it contains policies specific to a domain. + * @param domain name of the domain this instance is used to configure the + * policies for (case insensitive, ignored if global == true) + * @param prefix prefix to use for configuration keys. The domain-specific + * policies use of the format "<feature>." (note the trailing dot). + * Global policies have no prefix, it is ignored if global == true. + * @param feature_key key of the "feature enabled" policy. The final + * key the policy is stored under will be prefix + featureKey. + */ + Policies(KConfig* config, const QString &group, bool global, + const QString &domain, const QString &prefix, + const QString &feature_key); + + virtual ~Policies(); + + /** + * Returns true if this is the global policies object + */ + bool isGlobal() const { + return is_global; + } + + /** sets a new domain for this policy + * @param domain domain name, will be converted to lowercase + */ + void setDomain(const QString &domain); + + /** + * Returns whether the "feature enabled" policy is inherited. + */ + bool isFeatureEnabledPolicyInherited() const { + return feature_enabled == INHERIT_POLICY; + } + /** inherits "feature enabled" policy */ + void inheritFeatureEnabledPolicy() { + feature_enabled = INHERIT_POLICY; + } + /** + * Returns whether this feature is enabled. + * + * This will return an illegal value if isFeatureEnabledPolicyInherited + * is true. + */ + bool isFeatureEnabled() const { + return (bool)feature_enabled; + } + /** + * Enables/disables this feature + * @param on true will enable it, false disable it + */ + void setFeatureEnabled(int on) { + feature_enabled = on; + } + + /** + * (re)loads settings from configuration file given in the constructor. + * + * Implicitely sets the group given in the constructor. Don't forget to + * call this method from derived methods. + */ + virtual void load(); + /** + * saves current settings to the configuration file given in the constructor + * + * Implicitely sets the group given in the constructor. Don't forget to + * call this method from derived methods. + */ + virtual void save(); + /** + * restores the default settings + */ + virtual void defaults(); + +protected: + // true or false or INHERIT_POLICY + unsigned int feature_enabled; + + bool is_global; + KConfig *config; + QString groupname; + QString domain; + QString prefix; + QString feature_key; +}; + +#endif // __POLICIES_H__ + |