add more spacing
[personal-kdebase.git] / apps / konqueror / settings / konqhtml / policies.h
blob19ba6f9067f60ff65f643fedf862637a99e24563
1 /*
2 Copyright (c) 2002 Leo Savernik <l.savernik@aon.at>
3 Derived from jsopt.h, code copied from there is copyrighted to its
4 respective owners.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #ifndef __POLICIES_H__
23 #define __POLICIES_H__
26 #include <ksharedconfig.h>
28 // special value for inheriting a global policy
29 #define INHERIT_POLICY 32767
31 /**
32 * @short Contains the basic policies and methods for their manipulation.
34 * This class provides access to the basic policies that are common
35 * to all features.
37 * @author Leo Savernik
39 class Policies {
40 public:
41 /**
42 * constructor
43 * @param config configuration to initialize this instance from
44 * @param group config group to use if this instance contains the global
45 * policies (global == true)
46 * @param global true if this instance contains the global policy settings,
47 * false if it contains policies specific to a domain.
48 * @param domain name of the domain this instance is used to configure the
49 * policies for (case insensitive, ignored if global == true)
50 * @param prefix prefix to use for configuration keys. The domain-specific
51 * policies use of the format "&lt;feature&gt;." (note the trailing dot).
52 * Global policies have no prefix, it is ignored if global == true.
53 * @param feature_key key of the "feature enabled" policy. The final
54 * key the policy is stored under will be prefix + featureKey.
56 Policies(KSharedConfig::Ptr config, const QString &group, bool global,
57 const QString &domain, const QString &prefix,
58 const QString &feature_key);
60 virtual ~Policies();
62 /**
63 * Returns true if this is the global policies object
65 bool isGlobal() const {
66 return is_global;
69 /** sets a new domain for this policy
70 * @param domain domain name, will be converted to lowercase
72 void setDomain(const QString &domain);
74 /**
75 * Returns whether the "feature enabled" policy is inherited.
77 bool isFeatureEnabledPolicyInherited() const {
78 return feature_enabled == INHERIT_POLICY;
80 /** inherits "feature enabled" policy */
81 void inheritFeatureEnabledPolicy() {
82 feature_enabled = INHERIT_POLICY;
84 /**
85 * Returns whether this feature is enabled.
87 * This will return an illegal value if isFeatureEnabledPolicyInherited
88 * is true.
90 bool isFeatureEnabled() const {
91 return (bool)feature_enabled;
93 /**
94 * Enables/disables this feature
95 * @param on true will enable it, false disable it
97 void setFeatureEnabled(int on) {
98 feature_enabled = on;
102 * (re)loads settings from configuration file given in the constructor.
104 * Implicitely sets the group given in the constructor. Don't forget to
105 * call this method from derived methods.
107 virtual void load();
109 * saves current settings to the configuration file given in the constructor
111 * Implicitely sets the group given in the constructor. Don't forget to
112 * call this method from derived methods.
114 virtual void save();
116 * restores the default settings
118 virtual void defaults();
120 protected:
121 // true or false or INHERIT_POLICY
122 unsigned int feature_enabled;
124 bool is_global;
125 KSharedConfig::Ptr config;
126 QString groupname;
127 QString domain;
128 QString prefix;
129 QString feature_key;
132 #endif // __POLICIES_H__