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