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