Diffstat (limited to 'kaddressbook/kaddressbookview.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/kaddressbookview.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/kaddressbook/kaddressbookview.h b/kaddressbook/kaddressbookview.h index 8646136..8f31910 100644 --- a/kaddressbook/kaddressbookview.h +++ b/kaddressbook/kaddressbookview.h | |||
@@ -1,88 +1,94 @@ | |||
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 | #ifdef DESKTOP_VERSION | ||
42 | #include <qpaintdevicemetrics.h> | ||
43 | #include <qprinter.h> | ||
44 | #include <qpainter.h> | ||
45 | #endif | ||
46 | |||
41 | namespace KABC { class AddressBook; } | 47 | namespace KABC { class AddressBook; } |
42 | 48 | ||
43 | /** | 49 | /** |
44 | Base class for all views in kaddressbook. This class implements | 50 | Base class for all views in kaddressbook. This class implements |
45 | all the common methods needed to provide a view to the user. | 51 | all the common methods needed to provide a view to the user. |
46 | 52 | ||
47 | To implement a specific view (table, card, etc), just inherit from | 53 | To implement a specific view (table, card, etc), just inherit from |
48 | this class and implement all the pure virtuals. | 54 | this class and implement all the pure virtuals. |
49 | 55 | ||
50 | @author Mike Pilone <mpilone@slac.com> | 56 | @author Mike Pilone <mpilone@slac.com> |
51 | */ | 57 | */ |
52 | class KAddressBookView : public QWidget | 58 | class KAddressBookView : public QWidget |
53 | { | 59 | { |
54 | Q_OBJECT | 60 | Q_OBJECT |
55 | 61 | ||
56 | public: | 62 | public: |
57 | enum DefaultFilterType { None = 0, Active = 1, Specific = 2 }; | 63 | enum DefaultFilterType { None = 0, Active = 1, Specific = 2 }; |
58 | 64 | ||
59 | KAddressBookView( KABC::AddressBook *ab, QWidget *parent, const char *name ); | 65 | KAddressBookView( KABC::AddressBook *ab, QWidget *parent, const char *name ); |
60 | virtual ~KAddressBookView(); | 66 | virtual ~KAddressBookView(); |
61 | 67 | ||
62 | /** | 68 | /** |
63 | Must be overloaded in subclasses. Should return a list of | 69 | Must be overloaded in subclasses. Should return a list of |
64 | all the uids of selected contacts. | 70 | all the uids of selected contacts. |
65 | */ | 71 | */ |
66 | virtual QStringList selectedUids() = 0; | 72 | virtual QStringList selectedUids() = 0; |
67 | virtual void doSearch( const QString& s ,KABC::Field *field ) = 0; | 73 | virtual void doSearch( const QString& s ,KABC::Field *field ) = 0; |
68 | virtual void scrollUP() = 0; | 74 | virtual void scrollUP() = 0; |
69 | virtual void scrollDOWN() = 0; | 75 | virtual void scrollDOWN() = 0; |
70 | virtual void setFocusAV() = 0; | 76 | virtual void setFocusAV() = 0; |
71 | 77 | ||
72 | /** | 78 | /** |
73 | Called whenever this view should read the config. This can be used | 79 | 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 | 80 | as a sign that the config has changed, therefore the view should |
75 | assume the worst and rebuild itself if necessary. For example, | 81 | 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 | 82 | in a table view this method may be called when the user adds or |
77 | removes columns from the view. | 83 | removes columns from the view. |
78 | 84 | ||
79 | If overloaded in the subclass, do not forget to call super class's | 85 | If overloaded in the subclass, do not forget to call super class's |
80 | method. | 86 | method. |
81 | 87 | ||
82 | @param config The KConfig object to read from. The group will already | 88 | @param config The KConfig object to read from. The group will already |
83 | be set, so do not change the group. | 89 | be set, so do not change the group. |
84 | */ | 90 | */ |
85 | virtual void readConfig( KConfig *config ); | 91 | virtual void readConfig( KConfig *config ); |
86 | 92 | ||
87 | /** | 93 | /** |
88 | Called whenever this view should write the config. The view should not | 94 | Called whenever this view should write the config. The view should not |
@@ -105,122 +111,125 @@ class KAddressBookView : public QWidget | |||
105 | virtual QString selectedEmails(); | 111 | virtual QString selectedEmails(); |
106 | 112 | ||
107 | /** | 113 | /** |
108 | Return the type of the view: Icon, Table, etc. Please make sure that | 114 | 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 | 115 | this is the same value that ViewWrapper::type() will return for your |
110 | view. | 116 | view. |
111 | */ | 117 | */ |
112 | virtual QString type() const = 0; | 118 | virtual QString type() const = 0; |
113 | 119 | ||
114 | /** | 120 | /** |
115 | Returns a list of the fields that should be displayed. The list | 121 | Returns a list of the fields that should be displayed. The list |
116 | is composed of the fields proper names (ie: Home Address), so | 122 | is composed of the fields proper names (ie: Home Address), so |
117 | the view may need to translate them in order to get the | 123 | the view may need to translate them in order to get the |
118 | value from the addressee. | 124 | value from the addressee. |
119 | 125 | ||
120 | This list is generated from the config file, so it is advisable to call | 126 | 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 | 127 | this method whenever a readConfig() is called in order to get the newest |
122 | list of fields. | 128 | list of fields. |
123 | */ | 129 | */ |
124 | KABC::Field::List fields() const; | 130 | KABC::Field::List fields() const; |
125 | 131 | ||
126 | KABC::Field::List allFields() const; | 132 | KABC::Field::List allFields() const; |
127 | 133 | ||
128 | /** | 134 | /** |
129 | Sets the active filter. This filter will be used for filtering | 135 | Sets the active filter. This filter will be used for filtering |
130 | the list of addressees to display. The view will <b>not</b> | 136 | the list of addressees to display. The view will <b>not</b> |
131 | automatically refresh itself, so in most cases you will want to call | 137 | automatically refresh itself, so in most cases you will want to call |
132 | KAddressBookView::refresh() after this method. | 138 | KAddressBookView::refresh() after this method. |
133 | */ | 139 | */ |
134 | void setFilter( const Filter& ); | 140 | void setFilter( const Filter& ); |
135 | 141 | ||
136 | /** | 142 | /** |
137 | @return The default filter type selection. If the selection | 143 | @return The default filter type selection. If the selection |
138 | is SpecificFilter, the name of the filter can be retrieved with | 144 | is SpecificFilter, the name of the filter can be retrieved with |
139 | defaultFilterName() | 145 | defaultFilterName() |
140 | */ | 146 | */ |
141 | DefaultFilterType defaultFilterType() const; | 147 | DefaultFilterType defaultFilterType() const; |
142 | 148 | ||
143 | /** | 149 | /** |
144 | @return The name of the default filter. This string is | 150 | @return The name of the default filter. This string is |
145 | only valid if defaultFilterType() is returning SpecificFilter. | 151 | only valid if defaultFilterType() is returning SpecificFilter. |
146 | */ | 152 | */ |
147 | const QString &defaultFilterName() const; | 153 | const QString &defaultFilterName() const; |
148 | 154 | ||
149 | /** | 155 | /** |
150 | @return The address book. | 156 | @return The address book. |
151 | */ | 157 | */ |
152 | KABC::AddressBook *addressBook() const; | 158 | KABC::AddressBook *addressBook() const; |
159 | void printMyView() { emit printView() ;} | ||
153 | 160 | ||
154 | public slots: | 161 | public slots: |
155 | /** | 162 | /** |
156 | Must be overloaded in subclasses to refresh the view. | 163 | Must be overloaded in subclasses to refresh the view. |
157 | Refreshing includes updating the view to ensure that only items | 164 | Refreshing includes updating the view to ensure that only items |
158 | in the document are visible. If <i>uid</i> is valid, only the | 165 | in the document are visible. If <i>uid</i> is valid, only the |
159 | addressee with uid needs to be refreshed. This is an optimization | 166 | addressee with uid needs to be refreshed. This is an optimization |
160 | only. | 167 | only. |
161 | */ | 168 | */ |
162 | virtual void refresh( QString uid = QString::null ) = 0; | 169 | virtual void refresh( QString uid = QString::null ) = 0; |
163 | 170 | ||
164 | /** | 171 | /** |
165 | This method must be overloaded in subclasses. Select (highlight) | 172 | This method must be overloaded in subclasses. Select (highlight) |
166 | the addressee matching <i>uid</i>. If uid | 173 | the addressee matching <i>uid</i>. If uid |
167 | is equal to QString::null, then all addressees should be selected. | 174 | is equal to QString::null, then all addressees should be selected. |
168 | */ | 175 | */ |
169 | #ifndef KAB_EMBEDDED | 176 | #ifndef KAB_EMBEDDED |
170 | //MOC_SKIP_BEGIN | 177 | //MOC_SKIP_BEGIN |
171 | virtual void setSelected( QString uid = QString::null, bool selected = true ) = 0; | 178 | virtual void setSelected( QString uid = QString::null, bool selected = true ) = 0; |
172 | //MOC_SKIP_END | 179 | //MOC_SKIP_END |
173 | #else //KAB_EMBEDDED | 180 | #else //KAB_EMBEDDED |
174 | //US my moc can not handle the default parameters. Is this a problem ??? | 181 | //US my moc can not handle the default parameters. Is this a problem ??? |
175 | virtual void setSelected( QString uid, bool selected) = 0; | 182 | virtual void setSelected( QString uid, bool selected) = 0; |
176 | #endif //KAB_EMBEDDED | 183 | #endif //KAB_EMBEDDED |
177 | 184 | ||
178 | signals: | 185 | signals: |
186 | |||
187 | void printView(); | ||
179 | /** | 188 | /** |
180 | This signal should be emitted by a subclass whenever an addressee | 189 | This signal should be emitted by a subclass whenever an addressee |
181 | is modified. | 190 | is modified. |
182 | */ | 191 | */ |
183 | void modified(); | 192 | void modified(); |
184 | 193 | ||
185 | /** | 194 | /** |
186 | This signal should be emitted by a subclass whenever an addressee | 195 | This signal should be emitted by a subclass whenever an addressee |
187 | is selected. Selected means that the addressee was given the focus. | 196 | is selected. Selected means that the addressee was given the focus. |
188 | Some widgets may call this 'highlighted'. The view is responsible for | 197 | Some widgets may call this 'highlighted'. The view is responsible for |
189 | emitting this signal multiple times if multiple items are selected, | 198 | emitting this signal multiple times if multiple items are selected, |
190 | with the last item selected being the last emit. | 199 | with the last item selected being the last emit. |
191 | 200 | ||
192 | @param uid The uid of the selected addressee. | 201 | @param uid The uid of the selected addressee. |
193 | 202 | ||
194 | @see KListView | 203 | @see KListView |
195 | */ | 204 | */ |
196 | void selected( const QString &uid ); | 205 | void selected( const QString &uid ); |
197 | void deleteRequest(); | 206 | void deleteRequest(); |
198 | /** | 207 | /** |
199 | This signal should be emitted by a subclass whenever an addressee | 208 | This signal should be emitted by a subclass whenever an addressee |
200 | is executed. This is defined by the KDE system wide config, but it | 209 | is executed. This is defined by the KDE system wide config, but it |
201 | either means single or doubleclicked. | 210 | either means single or doubleclicked. |
202 | 211 | ||
203 | @param ui The uid of the selected addressee | 212 | @param ui The uid of the selected addressee |
204 | 213 | ||
205 | @see KListView | 214 | @see KListView |
206 | */ | 215 | */ |
207 | void executed( const QString &uid ); | 216 | void executed( const QString &uid ); |
208 | 217 | ||
209 | /** | 218 | /** |
210 | This signal is emitted whenever a user attempts to start a drag | 219 | This signal is emitted whenever a user attempts to start a drag |
211 | in the view. The slot connected to this signal would usually want | 220 | in the view. The slot connected to this signal would usually want |
212 | to create a QDragObject. | 221 | to create a QDragObject. |
213 | */ | 222 | */ |
214 | void startDrag(); | 223 | void startDrag(); |
215 | 224 | ||
216 | /** | 225 | /** |
217 | This signal is emitted whenever the user drops something on the | 226 | This signal is emitted whenever the user drops something on the |
218 | view. The individual view should handle checking if the item is | 227 | view. The individual view should handle checking if the item is |
219 | droppable (ie: if it is a vcard). | 228 | droppable (ie: if it is a vcard). |
220 | */ | 229 | */ |
221 | void dropped( QDropEvent* ); | 230 | void dropped( QDropEvent* ); |
222 | 231 | ||
223 | protected: | 232 | protected: |
224 | /** | 233 | /** |
225 | Returns a list of the addressees that should be displayed. This method | 234 | Returns a list of the addressees that should be displayed. This method |
226 | should always be used by the subclass to get a list of addressees. This | 235 | should always be used by the subclass to get a list of addressees. This |