summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kaddressbookview.h
Unidiff
Diffstat (limited to 'kaddressbook/kaddressbookview.h') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kaddressbookview.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/kaddressbook/kaddressbookview.h b/kaddressbook/kaddressbookview.h
index 2e91cbc..8646136 100644
--- a/kaddressbook/kaddressbookview.h
+++ b/kaddressbook/kaddressbookview.h
@@ -1,299 +1,301 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KADDRESSBOOKVIEW_H 24#ifndef KADDRESSBOOKVIEW_H
25#define KADDRESSBOOKVIEW_H 25#define KADDRESSBOOKVIEW_H
26 26
27#ifndef KAB_EMBEDDED 27#ifndef KAB_EMBEDDED
28#include <klibloader.h> 28#include <klibloader.h>
29#endif //KAB_EMBEDDED 29#endif //KAB_EMBEDDED
30 30
31class KConfig; 31class KConfig;
32class QDropEvent; 32class QDropEvent;
33 33
34#include <qstringlist.h> 34#include <qstringlist.h>
35#include <kabc/field.h> 35#include <kabc/field.h>
36#include <qwidget.h> 36#include <qwidget.h>
37 37
38#include "viewconfigurewidget.h" 38#include "viewconfigurewidget.h"
39#include "filter.h" 39#include "filter.h"
40 40
41namespace KABC { class AddressBook; } 41namespace KABC { class AddressBook; }
42 42
43/** 43/**
44 Base class for all views in kaddressbook. This class implements 44 Base class for all views in kaddressbook. This class implements
45 all the common methods needed to provide a view to the user. 45 all the common methods needed to provide a view to the user.
46 46
47 To implement a specific view (table, card, etc), just inherit from 47 To implement a specific view (table, card, etc), just inherit from
48 this class and implement all the pure virtuals. 48 this class and implement all the pure virtuals.
49 49
50 @author Mike Pilone <mpilone@slac.com> 50 @author Mike Pilone <mpilone@slac.com>
51 */ 51 */
52class KAddressBookView : public QWidget 52class KAddressBookView : public QWidget
53{ 53{
54 Q_OBJECT 54 Q_OBJECT
55 55
56 public: 56 public:
57 enum DefaultFilterType { None = 0, Active = 1, Specific = 2 }; 57 enum DefaultFilterType { None = 0, Active = 1, Specific = 2 };
58 58
59 KAddressBookView( KABC::AddressBook *ab, QWidget *parent, const char *name ); 59 KAddressBookView( KABC::AddressBook *ab, QWidget *parent, const char *name );
60 virtual ~KAddressBookView(); 60 virtual ~KAddressBookView();
61 61
62 /** 62 /**
63 Must be overloaded in subclasses. Should return a list of 63 Must be overloaded in subclasses. Should return a list of
64 all the uids of selected contacts. 64 all the uids of selected contacts.
65 */ 65 */
66 virtual QStringList selectedUids() = 0; 66 virtual QStringList selectedUids() = 0;
67 virtual void doSearch( const QString& s ,KABC::Field *field ) = 0; 67 virtual void doSearch( const QString& s ,KABC::Field *field ) = 0;
68 virtual void scrollUP() = 0; 68 virtual void scrollUP() = 0;
69 virtual void scrollDOWN() = 0; 69 virtual void scrollDOWN() = 0;
70 virtual void setFocusAV() = 0; 70 virtual void setFocusAV() = 0;
71 71
72 /** 72 /**
73 Called whenever this view should read the config. This can be used 73 Called whenever this view should read the config. This can be used
74 as a sign that the config has changed, therefore the view should 74 as a sign that the config has changed, therefore the view should
75 assume the worst and rebuild itself if necessary. For example, 75 assume the worst and rebuild itself if necessary. For example,
76 in a table view this method may be called when the user adds or 76 in a table view this method may be called when the user adds or
77 removes columns from the view. 77 removes columns from the view.
78 78
79 If overloaded in the subclass, do not forget to call super class's 79 If overloaded in the subclass, do not forget to call super class's
80 method. 80 method.
81 81
82 @param config The KConfig object to read from. The group will already 82 @param config The KConfig object to read from. The group will already
83 be set, so do not change the group. 83 be set, so do not change the group.
84 */ 84 */
85 virtual void readConfig( KConfig *config ); 85 virtual void readConfig( KConfig *config );
86 86
87 /** 87 /**
88 Called whenever this view should write the config. The view should not 88 Called whenever this view should write the config. The view should not
89 write out information handled by the application, such as which fields 89 write out information handled by the application, such as which fields
90 are visible. The view should only write out information specific 90 are visible. The view should only write out information specific
91 to itself (i.e.: All information in the ViewConfigWidget) 91 to itself (i.e.: All information in the ViewConfigWidget)
92 92
93 If overloaded in the subclass, do not forget to call the super class's 93 If overloaded in the subclass, do not forget to call the super class's
94 method. 94 method.
95 95
96 @param config The KConfig object to read from. The group will already 96 @param config The KConfig object to read from. The group will already
97 be set, so do not change the group. 97 be set, so do not change the group.
98 */ 98 */
99 virtual void writeConfig( KConfig *config ); 99 virtual void writeConfig( KConfig *config );
100 100
101 /** 101 /**
102 Returns a QString with all the selected email addresses concatenated 102 Returns a QString with all the selected email addresses concatenated
103 together with a ',' seperator. 103 together with a ',' seperator.
104 */ 104 */
105 virtual QString selectedEmails(); 105 virtual QString selectedEmails();
106 106
107 /** 107 /**
108 Return the type of the view: Icon, Table, etc. Please make sure that 108 Return the type of the view: Icon, Table, etc. Please make sure that
109 this is the same value that ViewWrapper::type() will return for your 109 this is the same value that ViewWrapper::type() will return for your
110 view. 110 view.
111 */ 111 */
112 virtual QString type() const = 0; 112 virtual QString type() const = 0;
113 113
114 /** 114 /**
115 Returns a list of the fields that should be displayed. The list 115 Returns a list of the fields that should be displayed. The list
116 is composed of the fields proper names (ie: Home Address), so 116 is composed of the fields proper names (ie: Home Address), so
117 the view may need to translate them in order to get the 117 the view may need to translate them in order to get the
118 value from the addressee. 118 value from the addressee.
119 119
120 This list is generated from the config file, so it is advisable to call 120 This list is generated from the config file, so it is advisable to call
121 this method whenever a readConfig() is called in order to get the newest 121 this method whenever a readConfig() is called in order to get the newest
122 list of fields. 122 list of fields.
123 */ 123 */
124 KABC::Field::List fields() const; 124 KABC::Field::List fields() const;
125
126 KABC::Field::List allFields() const;
125 127
126 /** 128 /**
127 Sets the active filter. This filter will be used for filtering 129 Sets the active filter. This filter will be used for filtering
128 the list of addressees to display. The view will <b>not</b> 130 the list of addressees to display. The view will <b>not</b>
129 automatically refresh itself, so in most cases you will want to call 131 automatically refresh itself, so in most cases you will want to call
130 KAddressBookView::refresh() after this method. 132 KAddressBookView::refresh() after this method.
131 */ 133 */
132 void setFilter( const Filter& ); 134 void setFilter( const Filter& );
133 135
134 /** 136 /**
135 @return The default filter type selection. If the selection 137 @return The default filter type selection. If the selection
136 is SpecificFilter, the name of the filter can be retrieved with 138 is SpecificFilter, the name of the filter can be retrieved with
137 defaultFilterName() 139 defaultFilterName()
138 */ 140 */
139 DefaultFilterType defaultFilterType() const; 141 DefaultFilterType defaultFilterType() const;
140 142
141 /** 143 /**
142 @return The name of the default filter. This string is 144 @return The name of the default filter. This string is
143 only valid if defaultFilterType() is returning SpecificFilter. 145 only valid if defaultFilterType() is returning SpecificFilter.
144 */ 146 */
145 const QString &defaultFilterName() const; 147 const QString &defaultFilterName() const;
146 148
147 /** 149 /**
148 @return The address book. 150 @return The address book.
149 */ 151 */
150 KABC::AddressBook *addressBook() const; 152 KABC::AddressBook *addressBook() const;
151 153
152 public slots: 154 public slots:
153 /** 155 /**
154 Must be overloaded in subclasses to refresh the view. 156 Must be overloaded in subclasses to refresh the view.
155 Refreshing includes updating the view to ensure that only items 157 Refreshing includes updating the view to ensure that only items
156 in the document are visible. If <i>uid</i> is valid, only the 158 in the document are visible. If <i>uid</i> is valid, only the
157 addressee with uid needs to be refreshed. This is an optimization 159 addressee with uid needs to be refreshed. This is an optimization
158 only. 160 only.
159 */ 161 */
160 virtual void refresh( QString uid = QString::null ) = 0; 162 virtual void refresh( QString uid = QString::null ) = 0;
161 163
162 /** 164 /**
163 This method must be overloaded in subclasses. Select (highlight) 165 This method must be overloaded in subclasses. Select (highlight)
164 the addressee matching <i>uid</i>. If uid 166 the addressee matching <i>uid</i>. If uid
165 is equal to QString::null, then all addressees should be selected. 167 is equal to QString::null, then all addressees should be selected.
166 */ 168 */
167#ifndef KAB_EMBEDDED 169#ifndef KAB_EMBEDDED
168//MOC_SKIP_BEGIN 170//MOC_SKIP_BEGIN
169 virtual void setSelected( QString uid = QString::null, bool selected = true ) = 0; 171 virtual void setSelected( QString uid = QString::null, bool selected = true ) = 0;
170//MOC_SKIP_END 172//MOC_SKIP_END
171#else //KAB_EMBEDDED 173#else //KAB_EMBEDDED
172 //US my moc can not handle the default parameters. Is this a problem ??? 174 //US my moc can not handle the default parameters. Is this a problem ???
173 virtual void setSelected( QString uid, bool selected) = 0; 175 virtual void setSelected( QString uid, bool selected) = 0;
174#endif //KAB_EMBEDDED 176#endif //KAB_EMBEDDED
175 177
176 signals: 178 signals:
177 /** 179 /**
178 This signal should be emitted by a subclass whenever an addressee 180 This signal should be emitted by a subclass whenever an addressee
179 is modified. 181 is modified.
180 */ 182 */
181 void modified(); 183 void modified();
182 184
183 /** 185 /**
184 This signal should be emitted by a subclass whenever an addressee 186 This signal should be emitted by a subclass whenever an addressee
185 is selected. Selected means that the addressee was given the focus. 187 is selected. Selected means that the addressee was given the focus.
186 Some widgets may call this 'highlighted'. The view is responsible for 188 Some widgets may call this 'highlighted'. The view is responsible for
187 emitting this signal multiple times if multiple items are selected, 189 emitting this signal multiple times if multiple items are selected,
188 with the last item selected being the last emit. 190 with the last item selected being the last emit.
189 191
190 @param uid The uid of the selected addressee. 192 @param uid The uid of the selected addressee.
191 193
192 @see KListView 194 @see KListView
193 */ 195 */
194 void selected( const QString &uid ); 196 void selected( const QString &uid );
195 void deleteRequest(); 197 void deleteRequest();
196 /** 198 /**
197 This signal should be emitted by a subclass whenever an addressee 199 This signal should be emitted by a subclass whenever an addressee
198 is executed. This is defined by the KDE system wide config, but it 200 is executed. This is defined by the KDE system wide config, but it
199 either means single or doubleclicked. 201 either means single or doubleclicked.
200 202
201 @param ui The uid of the selected addressee 203 @param ui The uid of the selected addressee
202 204
203 @see KListView 205 @see KListView
204 */ 206 */
205 void executed( const QString &uid ); 207 void executed( const QString &uid );
206 208
207 /** 209 /**
208 This signal is emitted whenever a user attempts to start a drag 210 This signal is emitted whenever a user attempts to start a drag
209 in the view. The slot connected to this signal would usually want 211 in the view. The slot connected to this signal would usually want
210 to create a QDragObject. 212 to create a QDragObject.
211 */ 213 */
212 void startDrag(); 214 void startDrag();
213 215
214 /** 216 /**
215 This signal is emitted whenever the user drops something on the 217 This signal is emitted whenever the user drops something on the
216 view. The individual view should handle checking if the item is 218 view. The individual view should handle checking if the item is
217 droppable (ie: if it is a vcard). 219 droppable (ie: if it is a vcard).
218 */ 220 */
219 void dropped( QDropEvent* ); 221 void dropped( QDropEvent* );
220 222
221 protected: 223 protected:
222 /** 224 /**
223 Returns a list of the addressees that should be displayed. This method 225 Returns a list of the addressees that should be displayed. This method
224 should always be used by the subclass to get a list of addressees. This 226 should always be used by the subclass to get a list of addressees. This
225 method internally takes many factors into account, including the current 227 method internally takes many factors into account, including the current
226 filter. 228 filter.
227 */ 229 */
228 KABC::Addressee::List addressees(); 230 KABC::Addressee::List addressees();
229 231
230 /** 232 /**
231 This method returns the widget that should be used as the parent for 233 This method returns the widget that should be used as the parent for
232 all view components. By using this widget as the parent and not 234 all view components. By using this widget as the parent and not
233 'this', the view subclass has the option of placing other widgets 235 'this', the view subclass has the option of placing other widgets
234 around the view (ie: search fields, etc). Do not delete this widget! 236 around the view (ie: search fields, etc). Do not delete this widget!
235 */ 237 */
236 QWidget *viewWidget(); 238 QWidget *viewWidget();
237 239
238 private: 240 private:
239 void initGUI(); 241 void initGUI();
240 242
241 DefaultFilterType mDefaultFilterType; 243 DefaultFilterType mDefaultFilterType;
242 Filter mFilter; 244 Filter mFilter;
243 QString mDefaultFilterName; 245 QString mDefaultFilterName;
244 KABC::AddressBook *mAddressBook; 246 KABC::AddressBook *mAddressBook;
245 KABC::Field::List mFieldList; 247 KABC::Field::List mFieldList;
246 248
247 QWidget *mViewWidget; 249 QWidget *mViewWidget;
248}; 250};
249 251
250#ifndef KAB_EMBEDDED 252#ifndef KAB_EMBEDDED
251//MOC_SKIP_BEGIN 253//MOC_SKIP_BEGIN
252class ViewFactory : public KLibFactory 254class ViewFactory : public KLibFactory
253//MOC_SKIP_END 255//MOC_SKIP_END
254#else //KAB_EMBEDDED 256#else //KAB_EMBEDDED
255class ViewFactory 257class ViewFactory
256#endif //KAB_EMBEDDED 258#endif //KAB_EMBEDDED
257{ 259{
258 260
259 public: 261 public:
260 virtual KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, 262 virtual KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent,
261 const char *name = 0 ) = 0; 263 const char *name = 0 ) = 0;
262 264
263 /** 265 /**
264 @return The type of the view. This is normally a small one word 266 @return The type of the view. This is normally a small one word
265 string (ie: Table, Icon, Tree, etc). 267 string (ie: Table, Icon, Tree, etc).
266 */ 268 */
267 virtual QString type() const = 0; 269 virtual QString type() const = 0;
268 270
269 /** 271 /**
270 @return The description of the view. This should be a 3 to 272 @return The description of the view. This should be a 3 to
271 4 line string (don't actually use return characters in the string) 273 4 line string (don't actually use return characters in the string)
272 describing the features offered by the view. 274 describing the features offered by the view.
273 */ 275 */
274 virtual QString description() const = 0; 276 virtual QString description() const = 0;
275 277
276 /** 278 /**
277 Creates a config dialog for the view type. The default 279 Creates a config dialog for the view type. The default
278 implementation will return a ViewConfigDialog. This default 280 implementation will return a ViewConfigDialog. This default
279 dialog will allow the user to set the visible fields only. If 281 dialog will allow the user to set the visible fields only. If
280 you need more config options (as most views will), this method 282 you need more config options (as most views will), this method
281 can be overloaded to return your sublcass of ViewConfigDialog. 283 can be overloaded to return your sublcass of ViewConfigDialog.
282 If this method is over loaded the base classes method should 284 If this method is over loaded the base classes method should
283 <B>not</B> be called. 285 <B>not</B> be called.
284 */ 286 */
285 virtual ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, 287 virtual ViewConfigureWidget *configureWidget( KABC::AddressBook *ab,
286 QWidget *parent, 288 QWidget *parent,
287 const char *name = 0 ); 289 const char *name = 0 );
288 290
289 protected: 291 protected:
290 virtual QObject* createObject( QObject*, const char*, const char*, 292 virtual QObject* createObject( QObject*, const char*, const char*,
291 const QStringList & ) 293 const QStringList & )
292 { 294 {
293 return 0; 295 return 0;
294 } 296 }
295 297
296}; 298};
297 299
298 300
299#endif 301#endif