Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / apps / konqueror / settings / konqhtml / domainlistview.h
blob25dac0b4ffd97d738c8f29773376a9db0c08fea0
1 /*
2 Copyright (c) 2002 Leo Savernik <l.savernik@aon.at>
3 Derived from jsopts.h and javaopts.h, code copied from there is
4 copyrighted to its 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 __DOMAINLISTVIEW_H__
23 #define __DOMAINLISTVIEW_H__
25 #include <QtGui/QGroupBox>
26 #include <QtCore/QMap>
28 #include <kconfig.h>
29 #include <ksharedconfig.h>
31 class Q3ListViewItem;
32 class QPushButton;
33 class QStringList;
35 class K3ListView;
37 class Policies;
38 class PolicyDialog;
40 /**
41 * @short Provides a list view of domains which policies are attached to.
43 * This class resembles a list view of domain names and some buttons to
44 * manipulate it. You should use this widget if you need to manage domains
45 * whose policies are described by (derivatives of) Policies objects.
47 * The contained widgets can be accessed by respective getters for
48 * fine-tuning/customizing them afterwards.
50 * To use this class you have to derive your own and implement most
51 * (all) of the protected methods. You need these to customize this widget
52 * for its special purpose.
54 * @author Leo Savernik
56 class DomainListView : public QGroupBox {
57 Q_OBJECT
58 public:
59 /** Enumerates the available buttons.
61 enum PushButton {
62 AddButton, ChangeButton, DeleteButton, ImportButton, ExportButton
65 /**
66 * constructor
67 * @param config configuration to read from and to write to
68 * @param title title to be used for enclosing group box
69 * @param parent parent widget
70 * @param name internal name for debugging
72 DomainListView(KSharedConfig::Ptr config,const QString &title,QWidget *parent );
74 virtual ~DomainListView();
76 /**
77 * clears the list view.
79 // void clear();
81 /**
82 * returns the list view displaying the domains
84 K3ListView *listView() const { return domainSpecificLV; }
86 /**
87 * returns the add push-button.
89 * Note: The add button already contains a default "what's this" text.
91 QPushButton *addButton() const { return addDomainPB; }
93 /**
94 * returns the change push-button.
96 * Note: The change button already contains a default "what's this" text.
98 QPushButton *changeButton() const { return changeDomainPB; }
101 * returns the delete push-button.
103 * Note: The delete button already contains a default "what's this" text.
105 QPushButton *deleteButton() const { return deleteDomainPB; }
108 * returns the import push-button.
110 QPushButton *importButton() const { return importDomainPB; }
113 * returns the export push-button.
115 QPushButton *exportButton() const { return exportDomainPB; }
118 * Initializes the list view with the given list of domains as well
119 * as the domain policy map.
121 * This method may be called multiple times on a DomainListView instance.
123 * @param domainList given list of domains
125 void initialize(const QStringList &domainList);
128 * saves the current state of all domains to the configuration object.
129 * @param group the group the information is to be saved under
130 * @param domainListKey the name of the key which the list of domains
131 * is stored under.
133 void save(const QString &group, const QString &domainListKey);
136 Q_SIGNALS:
138 * indicates that a configuration has been changed within this list view.
139 * @param state true if changed, false if not
141 void changed(bool state);
143 protected:
145 * factory method for creating a new domain-specific policies object.
147 * Example:
148 * <pre>
149 * JavaPolicies *JavaDomainListView::createPolicies() {
150 * return new JavaPolicies(m_pConfig,m_groupname,false);
152 * </pre>
154 virtual Policies *createPolicies() = 0;
157 * factory method for copying a policies object.
159 * Derived classes must interpret the given object as the same type
160 * as those created by createPolicies and return a copy of this very type.
162 * Example:
163 * <pre>
164 * JavaPolicies *JavaDomainListView::copyPolicies(Policies *pol) {
165 * return new JavaPolicies(*static_cast<JavaPolicies *>(pol));
167 * </pre>
168 * @param pol policies object to be copied
170 virtual Policies *copyPolicies(Policies *pol) = 0;
173 * allows derived classes to customize the policy dialog.
175 * The default implementation does nothing.
176 * @param trigger triggered by which button
177 * @param pDlg reference to policy dialog
178 * @param copy policies object this dialog is used for changing. Derived
179 * classes can safely cast the @p copy object to the same type they
180 * returned in their createPolicies implementation.
182 virtual void setupPolicyDlg(PushButton trigger,PolicyDialog &pDlg,
183 Policies *copy);
185 private Q_SLOTS:
186 void addPressed();
187 void changePressed();
188 void deletePressed();
189 void importPressed();
190 void exportPressed();
191 void updateButton();
193 protected:
195 KSharedConfig::Ptr config;
197 K3ListView *domainSpecificLV;
199 QPushButton* addDomainPB;
200 QPushButton* changeDomainPB;
201 QPushButton* deleteDomainPB;
202 QPushButton* importDomainPB;
203 QPushButton* exportDomainPB;
205 typedef QMap<Q3ListViewItem*, Policies *> DomainPolicyMap;
206 DomainPolicyMap domainPolicies;
209 #endif // __DOMAINLISTVIEW_H__