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 17106e8..c134e96 100644
--- a/kaddressbook/kaddressbookview.h
+++ b/kaddressbook/kaddressbookview.h
@@ -1,296 +1,298 @@
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;
69 virtual void scrollDOWN() = 0;
68 70
69 /** 71 /**
70 Called whenever this view should read the config. This can be used 72 Called whenever this view should read the config. This can be used
71 as a sign that the config has changed, therefore the view should 73 as a sign that the config has changed, therefore the view should
72 assume the worst and rebuild itself if necessary. For example, 74 assume the worst and rebuild itself if necessary. For example,
73 in a table view this method may be called when the user adds or 75 in a table view this method may be called when the user adds or
74 removes columns from the view. 76 removes columns from the view.
75 77
76 If overloaded in the subclass, do not forget to call super class's 78 If overloaded in the subclass, do not forget to call super class's
77 method. 79 method.
78 80
79 @param config The KConfig object to read from. The group will already 81 @param config The KConfig object to read from. The group will already
80 be set, so do not change the group. 82 be set, so do not change the group.
81 */ 83 */
82 virtual void readConfig( KConfig *config ); 84 virtual void readConfig( KConfig *config );
83 85
84 /** 86 /**
85 Called whenever this view should write the config. The view should not 87 Called whenever this view should write the config. The view should not
86 write out information handled by the application, such as which fields 88 write out information handled by the application, such as which fields
87 are visible. The view should only write out information specific 89 are visible. The view should only write out information specific
88 to itself (i.e.: All information in the ViewConfigWidget) 90 to itself (i.e.: All information in the ViewConfigWidget)
89 91
90 If overloaded in the subclass, do not forget to call the super class's 92 If overloaded in the subclass, do not forget to call the super class's
91 method. 93 method.
92 94
93 @param config The KConfig object to read from. The group will already 95 @param config The KConfig object to read from. The group will already
94 be set, so do not change the group. 96 be set, so do not change the group.
95 */ 97 */
96 virtual void writeConfig( KConfig *config ); 98 virtual void writeConfig( KConfig *config );
97 99
98 /** 100 /**
99 Returns a QString with all the selected email addresses concatenated 101 Returns a QString with all the selected email addresses concatenated
100 together with a ',' seperator. 102 together with a ',' seperator.
101 */ 103 */
102 virtual QString selectedEmails(); 104 virtual QString selectedEmails();
103 105
104 /** 106 /**
105 Return the type of the view: Icon, Table, etc. Please make sure that 107 Return the type of the view: Icon, Table, etc. Please make sure that
106 this is the same value that ViewWrapper::type() will return for your 108 this is the same value that ViewWrapper::type() will return for your
107 view. 109 view.
108 */ 110 */
109 virtual QString type() const = 0; 111 virtual QString type() const = 0;
110 112
111 /** 113 /**
112 Returns a list of the fields that should be displayed. The list 114 Returns a list of the fields that should be displayed. The list
113 is composed of the fields proper names (ie: Home Address), so 115 is composed of the fields proper names (ie: Home Address), so
114 the view may need to translate them in order to get the 116 the view may need to translate them in order to get the
115 value from the addressee. 117 value from the addressee.
116 118
117 This list is generated from the config file, so it is advisable to call 119 This list is generated from the config file, so it is advisable to call
118 this method whenever a readConfig() is called in order to get the newest 120 this method whenever a readConfig() is called in order to get the newest
119 list of fields. 121 list of fields.
120 */ 122 */
121 KABC::Field::List fields() const; 123 KABC::Field::List fields() const;
122 124
123 /** 125 /**
124 Sets the active filter. This filter will be used for filtering 126 Sets the active filter. This filter will be used for filtering
125 the list of addressees to display. The view will <b>not</b> 127 the list of addressees to display. The view will <b>not</b>
126 automatically refresh itself, so in most cases you will want to call 128 automatically refresh itself, so in most cases you will want to call
127 KAddressBookView::refresh() after this method. 129 KAddressBookView::refresh() after this method.
128 */ 130 */
129 void setFilter( const Filter& ); 131 void setFilter( const Filter& );
130 132
131 /** 133 /**
132 @return The default filter type selection. If the selection 134 @return The default filter type selection. If the selection
133 is SpecificFilter, the name of the filter can be retrieved with 135 is SpecificFilter, the name of the filter can be retrieved with
134 defaultFilterName() 136 defaultFilterName()
135 */ 137 */
136 DefaultFilterType defaultFilterType() const; 138 DefaultFilterType defaultFilterType() const;
137 139
138 /** 140 /**
139 @return The name of the default filter. This string is 141 @return The name of the default filter. This string is
140 only valid if defaultFilterType() is returning SpecificFilter. 142 only valid if defaultFilterType() is returning SpecificFilter.
141 */ 143 */
142 const QString &defaultFilterName() const; 144 const QString &defaultFilterName() const;
143 145
144 /** 146 /**
145 @return The address book. 147 @return The address book.
146 */ 148 */
147 KABC::AddressBook *addressBook() const; 149 KABC::AddressBook *addressBook() const;
148 150
149 public slots: 151 public slots:
150 /** 152 /**
151 Must be overloaded in subclasses to refresh the view. 153 Must be overloaded in subclasses to refresh the view.
152 Refreshing includes updating the view to ensure that only items 154 Refreshing includes updating the view to ensure that only items
153 in the document are visible. If <i>uid</i> is valid, only the 155 in the document are visible. If <i>uid</i> is valid, only the
154 addressee with uid needs to be refreshed. This is an optimization 156 addressee with uid needs to be refreshed. This is an optimization
155 only. 157 only.
156 */ 158 */
157 virtual void refresh( QString uid = QString::null ) = 0; 159 virtual void refresh( QString uid = QString::null ) = 0;
158 160
159 /** 161 /**
160 This method must be overloaded in subclasses. Select (highlight) 162 This method must be overloaded in subclasses. Select (highlight)
161 the addressee matching <i>uid</i>. If uid 163 the addressee matching <i>uid</i>. If uid
162 is equal to QString::null, then all addressees should be selected. 164 is equal to QString::null, then all addressees should be selected.
163 */ 165 */
164#ifndef KAB_EMBEDDED 166#ifndef KAB_EMBEDDED
165//MOC_SKIP_BEGIN 167//MOC_SKIP_BEGIN
166 virtual void setSelected( QString uid = QString::null, bool selected = true ) = 0; 168 virtual void setSelected( QString uid = QString::null, bool selected = true ) = 0;
167//MOC_SKIP_END 169//MOC_SKIP_END
168#else //KAB_EMBEDDED 170#else //KAB_EMBEDDED
169 //US my moc can not handle the default parameters. Is this a problem ??? 171 //US my moc can not handle the default parameters. Is this a problem ???
170 virtual void setSelected( QString uid, bool selected) = 0; 172 virtual void setSelected( QString uid, bool selected) = 0;
171#endif //KAB_EMBEDDED 173#endif //KAB_EMBEDDED
172 174
173 signals: 175 signals:
174 /** 176 /**
175 This signal should be emitted by a subclass whenever an addressee 177 This signal should be emitted by a subclass whenever an addressee
176 is modified. 178 is modified.
177 */ 179 */
178 void modified(); 180 void modified();
179 181
180 /** 182 /**
181 This signal should be emitted by a subclass whenever an addressee 183 This signal should be emitted by a subclass whenever an addressee
182 is selected. Selected means that the addressee was given the focus. 184 is selected. Selected means that the addressee was given the focus.
183 Some widgets may call this 'highlighted'. The view is responsible for 185 Some widgets may call this 'highlighted'. The view is responsible for
184 emitting this signal multiple times if multiple items are selected, 186 emitting this signal multiple times if multiple items are selected,
185 with the last item selected being the last emit. 187 with the last item selected being the last emit.
186 188
187 @param uid The uid of the selected addressee. 189 @param uid The uid of the selected addressee.
188 190
189 @see KListView 191 @see KListView
190 */ 192 */
191 void selected( const QString &uid ); 193 void selected( const QString &uid );
192 void deleteRequest(); 194 void deleteRequest();
193 /** 195 /**
194 This signal should be emitted by a subclass whenever an addressee 196 This signal should be emitted by a subclass whenever an addressee
195 is executed. This is defined by the KDE system wide config, but it 197 is executed. This is defined by the KDE system wide config, but it
196 either means single or doubleclicked. 198 either means single or doubleclicked.
197 199
198 @param ui The uid of the selected addressee 200 @param ui The uid of the selected addressee
199 201
200 @see KListView 202 @see KListView
201 */ 203 */
202 void executed( const QString &uid ); 204 void executed( const QString &uid );
203 205
204 /** 206 /**
205 This signal is emitted whenever a user attempts to start a drag 207 This signal is emitted whenever a user attempts to start a drag
206 in the view. The slot connected to this signal would usually want 208 in the view. The slot connected to this signal would usually want
207 to create a QDragObject. 209 to create a QDragObject.
208 */ 210 */
209 void startDrag(); 211 void startDrag();
210 212
211 /** 213 /**
212 This signal is emitted whenever the user drops something on the 214 This signal is emitted whenever the user drops something on the
213 view. The individual view should handle checking if the item is 215 view. The individual view should handle checking if the item is
214 droppable (ie: if it is a vcard). 216 droppable (ie: if it is a vcard).
215 */ 217 */
216 void dropped( QDropEvent* ); 218 void dropped( QDropEvent* );
217 219
218 protected: 220 protected:
219 /** 221 /**
220 Returns a list of the addressees that should be displayed. This method 222 Returns a list of the addressees that should be displayed. This method
221 should always be used by the subclass to get a list of addressees. This 223 should always be used by the subclass to get a list of addressees. This
222 method internally takes many factors into account, including the current 224 method internally takes many factors into account, including the current
223 filter. 225 filter.
224 */ 226 */
225 KABC::Addressee::List addressees(); 227 KABC::Addressee::List addressees();
226 228
227 /** 229 /**
228 This method returns the widget that should be used as the parent for 230 This method returns the widget that should be used as the parent for
229 all view components. By using this widget as the parent and not 231 all view components. By using this widget as the parent and not
230 'this', the view subclass has the option of placing other widgets 232 'this', the view subclass has the option of placing other widgets
231 around the view (ie: search fields, etc). Do not delete this widget! 233 around the view (ie: search fields, etc). Do not delete this widget!
232 */ 234 */
233 QWidget *viewWidget(); 235 QWidget *viewWidget();
234 236
235 private: 237 private:
236 void initGUI(); 238 void initGUI();
237 239
238 DefaultFilterType mDefaultFilterType; 240 DefaultFilterType mDefaultFilterType;
239 Filter mFilter; 241 Filter mFilter;
240 QString mDefaultFilterName; 242 QString mDefaultFilterName;
241 KABC::AddressBook *mAddressBook; 243 KABC::AddressBook *mAddressBook;
242 KABC::Field::List mFieldList; 244 KABC::Field::List mFieldList;
243 245
244 QWidget *mViewWidget; 246 QWidget *mViewWidget;
245}; 247};
246 248
247#ifndef KAB_EMBEDDED 249#ifndef KAB_EMBEDDED
248//MOC_SKIP_BEGIN 250//MOC_SKIP_BEGIN
249class ViewFactory : public KLibFactory 251class ViewFactory : public KLibFactory
250//MOC_SKIP_END 252//MOC_SKIP_END
251#else //KAB_EMBEDDED 253#else //KAB_EMBEDDED
252class ViewFactory 254class ViewFactory
253#endif //KAB_EMBEDDED 255#endif //KAB_EMBEDDED
254{ 256{
255 257
256 public: 258 public:
257 virtual KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, 259 virtual KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent,
258 const char *name = 0 ) = 0; 260 const char *name = 0 ) = 0;
259 261
260 /** 262 /**
261 @return The type of the view. This is normally a small one word 263 @return The type of the view. This is normally a small one word
262 string (ie: Table, Icon, Tree, etc). 264 string (ie: Table, Icon, Tree, etc).
263 */ 265 */
264 virtual QString type() const = 0; 266 virtual QString type() const = 0;
265 267
266 /** 268 /**
267 @return The description of the view. This should be a 3 to 269 @return The description of the view. This should be a 3 to
268 4 line string (don't actually use return characters in the string) 270 4 line string (don't actually use return characters in the string)
269 describing the features offered by the view. 271 describing the features offered by the view.
270 */ 272 */
271 virtual QString description() const = 0; 273 virtual QString description() const = 0;
272 274
273 /** 275 /**
274 Creates a config dialog for the view type. The default 276 Creates a config dialog for the view type. The default
275 implementation will return a ViewConfigDialog. This default 277 implementation will return a ViewConfigDialog. This default
276 dialog will allow the user to set the visible fields only. If 278 dialog will allow the user to set the visible fields only. If
277 you need more config options (as most views will), this method 279 you need more config options (as most views will), this method
278 can be overloaded to return your sublcass of ViewConfigDialog. 280 can be overloaded to return your sublcass of ViewConfigDialog.
279 If this method is over loaded the base classes method should 281 If this method is over loaded the base classes method should
280 <B>not</B> be called. 282 <B>not</B> be called.
281 */ 283 */
282 virtual ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, 284 virtual ViewConfigureWidget *configureWidget( KABC::AddressBook *ab,
283 QWidget *parent, 285 QWidget *parent,
284 const char *name = 0 ); 286 const char *name = 0 );
285 287
286 protected: 288 protected:
287 virtual QObject* createObject( QObject*, const char*, const char*, 289 virtual QObject* createObject( QObject*, const char*, const char*,
288 const QStringList & ) 290 const QStringList & )
289 { 291 {
290 return 0; 292 return 0;
291 } 293 }
292 294
293}; 295};
294 296
295 297
296#endif 298#endif