-rw-r--r-- | kaddressbook/kaddressbookview.cpp | 20 | ||||
-rw-r--r-- | kaddressbook/kaddressbookview.h | 2 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 6 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.cpp | 6 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 6 |
5 files changed, 23 insertions, 17 deletions
diff --git a/kaddressbook/kaddressbookview.cpp b/kaddressbook/kaddressbookview.cpp index 424d52a..09859c2 100644 --- a/kaddressbook/kaddressbookview.cpp +++ b/kaddressbook/kaddressbookview.cpp | |||
@@ -1,119 +1,135 @@ | |||
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 KAB_EMBEDDED | 24 | #ifndef KAB_EMBEDDED |
25 | #include <qapplication.h> | 25 | #include <qapplication.h> |
26 | 26 | ||
27 | #include <kabc/distributionlistdialog.h> | 27 | #include <kabc/distributionlistdialog.h> |
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <klocale.h> | 29 | #include <klocale.h> |
30 | 30 | ||
31 | #include "viewmanager.h" | 31 | #include "viewmanager.h" |
32 | 32 | ||
33 | #endif //KAB_EMBEDDED | 33 | #endif //KAB_EMBEDDED |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | 35 | ||
36 | #include <kabc/distributionlistdialog.h> | 36 | #include <kabc/distributionlistdialog.h> |
37 | #include <kabc/addressbook.h> | 37 | #include <kabc/addressbook.h> |
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | 39 | ||
40 | #include "kaddressbookview.h" | 40 | #include "kaddressbookview.h" |
41 | 41 | ||
42 | KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent, | 42 | KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent, |
43 | const char *name ) | 43 | const char *name ) |
44 | : QWidget( parent, name ), mAddressBook( ab ), mFieldList() | 44 | : QWidget( parent, name ), mAddressBook( ab ), mFieldList() |
45 | { | 45 | { |
46 | 46 | ||
47 | initGUI(); | 47 | initGUI(); |
48 | } | 48 | } |
49 | 49 | ||
50 | KAddressBookView::~KAddressBookView() | 50 | KAddressBookView::~KAddressBookView() |
51 | { | 51 | { |
52 | kdDebug(5720) << "KAddressBookView::~KAddressBookView: destroying - " | 52 | |
53 | << name() << endl; | ||
54 | } | 53 | } |
55 | 54 | ||
55 | QRegExp KAddressBookView::getRegExp( const QString s ) | ||
56 | { | ||
57 | QRegExp re; | ||
58 | |||
59 | if ( s.length() == 3 && s.mid(1,1) == "-" ) { | ||
60 | QString pattern = "^[" + s.lower() +"]"; | ||
61 | re.setCaseSensitive(false); | ||
62 | re.setPattern( pattern ); | ||
63 | } else { | ||
64 | QString pattern = s.lower()+"*"; | ||
65 | re.setWildcard(true); // most people understand these better. | ||
66 | re.setCaseSensitive(false); | ||
67 | re.setPattern( pattern ); | ||
68 | } | ||
69 | return re; | ||
70 | } | ||
71 | |||
56 | void KAddressBookView::readConfig( KConfig *config ) | 72 | void KAddressBookView::readConfig( KConfig *config ) |
57 | { | 73 | { |
58 | mFieldList = KABC::Field::restoreFields( config, "KABCFields" ); | 74 | mFieldList = KABC::Field::restoreFields( config, "KABCFields" ); |
59 | 75 | ||
60 | if ( mFieldList.isEmpty() ) | 76 | if ( mFieldList.isEmpty() ) |
61 | mFieldList = KABC::Field::defaultFields(); | 77 | mFieldList = KABC::Field::defaultFields(); |
62 | 78 | ||
63 | mDefaultFilterType = (DefaultFilterType)config->readNumEntry( "DefaultFilterType", 1 ); | 79 | mDefaultFilterType = (DefaultFilterType)config->readNumEntry( "DefaultFilterType", 1 ); |
64 | mDefaultFilterName = config->readEntry( "DefaultFilterName", QString::null ); | 80 | mDefaultFilterName = config->readEntry( "DefaultFilterName", QString::null ); |
65 | } | 81 | } |
66 | 82 | ||
67 | void KAddressBookView::writeConfig( KConfig* ) | 83 | void KAddressBookView::writeConfig( KConfig* ) |
68 | { | 84 | { |
69 | // Most of writing the config is handled by the ConfigureViewDialog | 85 | // Most of writing the config is handled by the ConfigureViewDialog |
70 | } | 86 | } |
71 | 87 | ||
72 | QString KAddressBookView::selectedEmails() | 88 | QString KAddressBookView::selectedEmails() |
73 | { | 89 | { |
74 | bool first = true; | 90 | bool first = true; |
75 | QString emailAddrs; | 91 | QString emailAddrs; |
76 | QStringList uidList = selectedUids(); | 92 | QStringList uidList = selectedUids(); |
77 | KABC::Addressee addr; | 93 | KABC::Addressee addr; |
78 | QString email; | 94 | QString email; |
79 | 95 | ||
80 | QStringList::Iterator it; | 96 | QStringList::Iterator it; |
81 | for ( it = uidList.begin(); it != uidList.end(); ++it ) { | 97 | for ( it = uidList.begin(); it != uidList.end(); ++it ) { |
82 | addr = mAddressBook->findByUid( *it ); | 98 | addr = mAddressBook->findByUid( *it ); |
83 | 99 | ||
84 | if ( !addr.isEmpty() ) { | 100 | if ( !addr.isEmpty() ) { |
85 | QString m = QString::null; | 101 | QString m = QString::null; |
86 | 102 | ||
87 | if ( addr.emails().count() > 1 ) | 103 | if ( addr.emails().count() > 1 ) |
88 | m = KABC::EmailSelector::getEmail( addr.emails(), addr.preferredEmail(), this ); | 104 | m = KABC::EmailSelector::getEmail( addr.emails(), addr.preferredEmail(), this ); |
89 | 105 | ||
90 | email = addr.fullEmail( m ); | 106 | email = addr.fullEmail( m ); |
91 | 107 | ||
92 | if ( !first ) | 108 | if ( !first ) |
93 | emailAddrs += ", "; | 109 | emailAddrs += ", "; |
94 | else | 110 | else |
95 | first = false; | 111 | first = false; |
96 | 112 | ||
97 | emailAddrs += email; | 113 | emailAddrs += email; |
98 | } | 114 | } |
99 | } | 115 | } |
100 | 116 | ||
101 | return emailAddrs; | 117 | return emailAddrs; |
102 | } | 118 | } |
103 | 119 | ||
104 | KABC::Addressee::List KAddressBookView::addressees() | 120 | KABC::Addressee::List KAddressBookView::addressees() |
105 | { | 121 | { |
106 | KABC::Addressee::List addresseeList; | 122 | KABC::Addressee::List addresseeList; |
107 | 123 | ||
108 | KABC::AddressBook::Iterator it; | 124 | KABC::AddressBook::Iterator it; |
109 | for (it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 125 | for (it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
110 | if ( mFilter.filterAddressee( *it ) ) | 126 | if ( mFilter.filterAddressee( *it ) ) |
111 | addresseeList.append( *it ); | 127 | addresseeList.append( *it ); |
112 | } | 128 | } |
113 | 129 | ||
114 | return addresseeList; | 130 | return addresseeList; |
115 | } | 131 | } |
116 | 132 | ||
117 | void KAddressBookView::initGUI() | 133 | void KAddressBookView::initGUI() |
118 | { | 134 | { |
119 | // Create the layout | 135 | // Create the layout |
diff --git a/kaddressbook/kaddressbookview.h b/kaddressbook/kaddressbookview.h index 8f31910..6bbb9c2 100644 --- a/kaddressbook/kaddressbookview.h +++ b/kaddressbook/kaddressbookview.h | |||
@@ -1,100 +1,101 @@ | |||
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. |
@@ -184,127 +185,128 @@ class KAddressBookView : public QWidget | |||
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 |
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index 9d8c5ce..2b40909 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp | |||
@@ -239,133 +239,129 @@ void KAddressBookCardView::readConfig(KConfig *config) | |||
239 | } | 239 | } |
240 | else | 240 | else |
241 | { | 241 | { |
242 | // needed if turned off during a session. | 242 | // needed if turned off during a session. |
243 | mCardView->viewport()->setPalette( mCardView->palette() ); | 243 | mCardView->viewport()->setPalette( mCardView->palette() ); |
244 | } | 244 | } |
245 | 245 | ||
246 | //custom fonts? | 246 | //custom fonts? |
247 | QFont f( font() ); | 247 | QFont f( font() ); |
248 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 248 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
249 | { | 249 | { |
250 | mCardView->setFont( config->readFontEntry( "TextFont", &f) ); | 250 | mCardView->setFont( config->readFontEntry( "TextFont", &f) ); |
251 | f.setBold( true ); | 251 | f.setBold( true ); |
252 | mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 252 | mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
253 | } | 253 | } |
254 | else | 254 | else |
255 | { | 255 | { |
256 | mCardView->setFont( f ); | 256 | mCardView->setFont( f ); |
257 | f.setBold( true ); | 257 | f.setBold( true ); |
258 | mCardView->setHeaderFont( f ); | 258 | mCardView->setHeaderFont( f ); |
259 | } | 259 | } |
260 | 260 | ||
261 | mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); | 261 | mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); |
262 | mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", | 262 | mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", |
263 | true)); | 263 | true)); |
264 | mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); | 264 | mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); |
265 | mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); | 265 | mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); |
266 | 266 | ||
267 | mCardView->setShowEmptyFields( mShowEmptyFields ); | 267 | mCardView->setShowEmptyFields( mShowEmptyFields ); |
268 | 268 | ||
269 | mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); | 269 | mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); |
270 | mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); | 270 | mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); |
271 | mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); | 271 | mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); |
272 | mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); | 272 | mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); |
273 | 273 | ||
274 | #if 0 | 274 | #if 0 |
275 | // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven | 275 | // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven |
276 | disconnect(mCardView, SIGNAL(executed(CardViewItem *)), | 276 | disconnect(mCardView, SIGNAL(executed(CardViewItem *)), |
277 | this, SLOT(addresseeExecuted(CardViewItem *))); | 277 | this, SLOT(addresseeExecuted(CardViewItem *))); |
278 | 278 | ||
279 | if (KABPrefs::instance()->mHonorSingleClick) | 279 | if (KABPrefs::instance()->mHonorSingleClick) |
280 | connect(mCardView, SIGNAL(executed(CardViewItem *)), | 280 | connect(mCardView, SIGNAL(executed(CardViewItem *)), |
281 | this, SLOT(addresseeExecuted(CardViewItem *))); | 281 | this, SLOT(addresseeExecuted(CardViewItem *))); |
282 | else | 282 | else |
283 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), | 283 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), |
284 | this, SLOT(addresseeExecuted(CardViewItem *))); | 284 | this, SLOT(addresseeExecuted(CardViewItem *))); |
285 | #endif | 285 | #endif |
286 | 286 | ||
287 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), | 287 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), |
288 | this, SLOT(addresseeExecuted(CardViewItem *))); | 288 | this, SLOT(addresseeExecuted(CardViewItem *))); |
289 | } | 289 | } |
290 | 290 | ||
291 | void KAddressBookCardView::writeConfig( KConfig *config ) | 291 | void KAddressBookCardView::writeConfig( KConfig *config ) |
292 | { | 292 | { |
293 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); | 293 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); |
294 | KAddressBookView::writeConfig( config ); | 294 | KAddressBookView::writeConfig( config ); |
295 | } | 295 | } |
296 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) | 296 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) |
297 | { | 297 | { |
298 | mCardView->clear(); | 298 | mCardView->clear(); |
299 | if ( s.isEmpty() || s == "*" ) { | 299 | if ( s.isEmpty() || s == "*" ) { |
300 | refresh(); | 300 | refresh(); |
301 | return; | 301 | return; |
302 | } | 302 | } |
303 | QString pattern = s.lower()+"*"; | 303 | QRegExp re = getRegExp( s ); |
304 | QRegExp re; | ||
305 | re.setWildcard(true); // most people understand these better. | ||
306 | re.setCaseSensitive(false); | ||
307 | re.setPattern( pattern ); | ||
308 | if (!re.isValid()) | 304 | if (!re.isValid()) |
309 | return; | 305 | return; |
310 | mCardView->viewport()->setUpdatesEnabled( false ); | 306 | mCardView->viewport()->setUpdatesEnabled( false ); |
311 | KABC::Addressee::List addresseeList = addressees(); | 307 | KABC::Addressee::List addresseeList = addressees(); |
312 | KABC::Addressee::List::Iterator it; | 308 | KABC::Addressee::List::Iterator it; |
313 | if ( field ) { | 309 | if ( field ) { |
314 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 310 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
315 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 311 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
316 | continue; | 312 | continue; |
317 | #if QT_VERSION >= 0x030000 | 313 | #if QT_VERSION >= 0x030000 |
318 | if (re.search(field->value( *it ).lower()) != -1) | 314 | if (re.search(field->value( *it ).lower()) != -1) |
319 | #else | 315 | #else |
320 | if (re.match(field->value( *it ).lower()) != -1) | 316 | if (re.match(field->value( *it ).lower()) != -1) |
321 | #endif | 317 | #endif |
322 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | 318 | new AddresseeCardViewItem(fields(), mShowEmptyFields, |
323 | addressBook(), *it, mCardView); | 319 | addressBook(), *it, mCardView); |
324 | 320 | ||
325 | } | 321 | } |
326 | } else { | 322 | } else { |
327 | KABC::Field::List fieldList = allFields(); | 323 | KABC::Field::List fieldList = allFields(); |
328 | KABC::Field::List::ConstIterator fieldIt; | 324 | KABC::Field::List::ConstIterator fieldIt; |
329 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 325 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
330 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 326 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
331 | continue; | 327 | continue; |
332 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 328 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
333 | #if QT_VERSION >= 0x030000 | 329 | #if QT_VERSION >= 0x030000 |
334 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 330 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
335 | #else | 331 | #else |
336 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 332 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
337 | #endif | 333 | #endif |
338 | { | 334 | { |
339 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | 335 | new AddresseeCardViewItem(fields(), mShowEmptyFields, |
340 | addressBook(), *it, mCardView); | 336 | addressBook(), *it, mCardView); |
341 | break; | 337 | break; |
342 | } | 338 | } |
343 | } | 339 | } |
344 | } | 340 | } |
345 | } | 341 | } |
346 | mCardView->viewport()->setUpdatesEnabled( true ); | 342 | mCardView->viewport()->setUpdatesEnabled( true ); |
347 | mCardView->viewport()->update(); | 343 | mCardView->viewport()->update(); |
348 | if ( mCardView->firstItem() ) { | 344 | if ( mCardView->firstItem() ) { |
349 | mCardView->setCurrentItem ( mCardView->firstItem() ); | 345 | mCardView->setCurrentItem ( mCardView->firstItem() ); |
350 | mCardView->setSelected ( mCardView->firstItem() , true ); | 346 | mCardView->setSelected ( mCardView->firstItem() , true ); |
351 | } | 347 | } |
352 | else | 348 | else |
353 | emit selected(QString::null); | 349 | emit selected(QString::null); |
354 | } | 350 | } |
355 | QStringList KAddressBookCardView::selectedUids() | 351 | QStringList KAddressBookCardView::selectedUids() |
356 | { | 352 | { |
357 | QStringList uidList; | 353 | QStringList uidList; |
358 | CardViewItem *item; | 354 | CardViewItem *item; |
359 | AddresseeCardViewItem *aItem; | 355 | AddresseeCardViewItem *aItem; |
360 | 356 | ||
361 | for (item = mCardView->firstItem(); item; item = item->nextItem()) | 357 | for (item = mCardView->firstItem(); item; item = item->nextItem()) |
362 | { | 358 | { |
363 | if (item->isSelected()) | 359 | if (item->isSelected()) |
364 | { | 360 | { |
365 | #ifndef KAB_EMBEDDED | 361 | #ifndef KAB_EMBEDDED |
366 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 362 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
367 | #else //KAB_EMBEDDED | 363 | #else //KAB_EMBEDDED |
368 | aItem = (AddresseeCardViewItem*)(item); | 364 | aItem = (AddresseeCardViewItem*)(item); |
369 | #endif //KAB_EMBEDDED | 365 | #endif //KAB_EMBEDDED |
370 | if (aItem) | 366 | if (aItem) |
371 | uidList << aItem->addressee().uid(); | 367 | uidList << aItem->addressee().uid(); |
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp index fb53215..3bdfd1a 100644 --- a/kaddressbook/views/kaddressbookiconview.cpp +++ b/kaddressbook/views/kaddressbookiconview.cpp | |||
@@ -198,133 +198,129 @@ KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, | |||
198 | //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), | 198 | //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), |
199 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); | 199 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); |
200 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 200 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
201 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 201 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
202 | 202 | ||
203 | connect(mIconView, SIGNAL(selectionChanged()), | 203 | connect(mIconView, SIGNAL(selectionChanged()), |
204 | this, SLOT(addresseeSelected())); | 204 | this, SLOT(addresseeSelected())); |
205 | connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), | 205 | connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), |
206 | this, SIGNAL(dropped(QDropEvent*))); | 206 | this, SIGNAL(dropped(QDropEvent*))); |
207 | connect(mIconView, SIGNAL(startAddresseeDrag()), | 207 | connect(mIconView, SIGNAL(startAddresseeDrag()), |
208 | this, SIGNAL(startDrag())); | 208 | this, SIGNAL(startDrag())); |
209 | } | 209 | } |
210 | 210 | ||
211 | KAddressBookIconView::~KAddressBookIconView() | 211 | KAddressBookIconView::~KAddressBookIconView() |
212 | { | 212 | { |
213 | } | 213 | } |
214 | void KAddressBookIconView::setFocusAV() | 214 | void KAddressBookIconView::setFocusAV() |
215 | { | 215 | { |
216 | if ( mIconView ) | 216 | if ( mIconView ) |
217 | mIconView->setFocus(); | 217 | mIconView->setFocus(); |
218 | } | 218 | } |
219 | 219 | ||
220 | 220 | ||
221 | void KAddressBookIconView::scrollUP() | 221 | void KAddressBookIconView::scrollUP() |
222 | { | 222 | { |
223 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); | 223 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); |
224 | QApplication::postEvent( mIconView, ev ); | 224 | QApplication::postEvent( mIconView, ev ); |
225 | } | 225 | } |
226 | void KAddressBookIconView::scrollDOWN() | 226 | void KAddressBookIconView::scrollDOWN() |
227 | { | 227 | { |
228 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); | 228 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); |
229 | QApplication::postEvent( mIconView, ev ); | 229 | QApplication::postEvent( mIconView, ev ); |
230 | } | 230 | } |
231 | void KAddressBookIconView::readConfig(KConfig *config) | 231 | void KAddressBookIconView::readConfig(KConfig *config) |
232 | { | 232 | { |
233 | KAddressBookView::readConfig(config); | 233 | KAddressBookView::readConfig(config); |
234 | 234 | ||
235 | //US method executed is part of KIconView | 235 | //US method executed is part of KIconView |
236 | //US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), | 236 | //US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), |
237 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); | 237 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); |
238 | disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 238 | disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
239 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 239 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
240 | 240 | ||
241 | //US method executed is part of KIconView. Use selectionChanged instead | 241 | //US method executed is part of KIconView. Use selectionChanged instead |
242 | /*US | 242 | /*US |
243 | if (KABPrefs::instance()->mHonorSingleClick) | 243 | if (KABPrefs::instance()->mHonorSingleClick) |
244 | connect(mIconView, SIGNAL(executed(QIconViewItem *)), | 244 | connect(mIconView, SIGNAL(executed(QIconViewItem *)), |
245 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 245 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
246 | else | 246 | else |
247 | connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), | 247 | connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), |
248 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 248 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
249 | */ | 249 | */ |
250 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 250 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
251 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 251 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
252 | 252 | ||
253 | } | 253 | } |
254 | void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) | 254 | void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) |
255 | { | 255 | { |
256 | mIconView->clear(); | 256 | mIconView->clear(); |
257 | mIconList.clear(); | 257 | mIconList.clear(); |
258 | if ( s.isEmpty() || s == "*" ) { | 258 | if ( s.isEmpty() || s == "*" ) { |
259 | refresh(); | 259 | refresh(); |
260 | return; | 260 | return; |
261 | } | 261 | } |
262 | QString pattern = s.lower()+"*"; | 262 | QRegExp re = getRegExp( s ); |
263 | QRegExp re; | ||
264 | re.setWildcard(true); // most people understand these better. | ||
265 | re.setCaseSensitive(false); | ||
266 | re.setPattern( pattern ); | ||
267 | if (!re.isValid()) | 263 | if (!re.isValid()) |
268 | return; | 264 | return; |
269 | KABC::Addressee::List addresseeList = addressees(); | 265 | KABC::Addressee::List addresseeList = addressees(); |
270 | KABC::Addressee::List::Iterator it; | 266 | KABC::Addressee::List::Iterator it; |
271 | if ( field ) { | 267 | if ( field ) { |
272 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 268 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
273 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 269 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
274 | continue; | 270 | continue; |
275 | #if QT_VERSION >= 0x030000 | 271 | #if QT_VERSION >= 0x030000 |
276 | if (re.search(field->value( *it ).lower()) != -1) | 272 | if (re.search(field->value( *it ).lower()) != -1) |
277 | #else | 273 | #else |
278 | if (re.match(field->value( *it ).lower()) != -1) | 274 | if (re.match(field->value( *it ).lower()) != -1) |
279 | #endif | 275 | #endif |
280 | mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); | 276 | mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); |
281 | 277 | ||
282 | 278 | ||
283 | } | 279 | } |
284 | } else { | 280 | } else { |
285 | KABC::Field::List fieldList = allFields(); | 281 | KABC::Field::List fieldList = allFields(); |
286 | KABC::Field::List::ConstIterator fieldIt; | 282 | KABC::Field::List::ConstIterator fieldIt; |
287 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 283 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
288 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 284 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
289 | continue; | 285 | continue; |
290 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 286 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
291 | #if QT_VERSION >= 0x030000 | 287 | #if QT_VERSION >= 0x030000 |
292 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 288 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
293 | #else | 289 | #else |
294 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 290 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
295 | #endif | 291 | #endif |
296 | { | 292 | { |
297 | mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); | 293 | mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); |
298 | break; | 294 | break; |
299 | } | 295 | } |
300 | } | 296 | } |
301 | } | 297 | } |
302 | } | 298 | } |
303 | mIconView->arrangeItemsInGrid( true ); | 299 | mIconView->arrangeItemsInGrid( true ); |
304 | if ( mIconView->firstItem() ) { | 300 | if ( mIconView->firstItem() ) { |
305 | mIconView->setCurrentItem ( mIconView->firstItem() ); | 301 | mIconView->setCurrentItem ( mIconView->firstItem() ); |
306 | mIconView->setSelected ( mIconView->firstItem() , true ); | 302 | mIconView->setSelected ( mIconView->firstItem() , true ); |
307 | } | 303 | } |
308 | else | 304 | else |
309 | emit selected(QString::null); | 305 | emit selected(QString::null); |
310 | } | 306 | } |
311 | QStringList KAddressBookIconView::selectedUids() | 307 | QStringList KAddressBookIconView::selectedUids() |
312 | { | 308 | { |
313 | QStringList uidList; | 309 | QStringList uidList; |
314 | QIconViewItem *item; | 310 | QIconViewItem *item; |
315 | AddresseeIconViewItem *aItem; | 311 | AddresseeIconViewItem *aItem; |
316 | 312 | ||
317 | for (item = mIconView->firstItem(); item; item = item->nextItem()) | 313 | for (item = mIconView->firstItem(); item; item = item->nextItem()) |
318 | { | 314 | { |
319 | if (item->isSelected()) | 315 | if (item->isSelected()) |
320 | { | 316 | { |
321 | #ifndef KAB_EMBEDDED | 317 | #ifndef KAB_EMBEDDED |
322 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 318 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
323 | #else //KAB_EMBEDDED | 319 | #else //KAB_EMBEDDED |
324 | aItem = (AddresseeIconViewItem*)(item); | 320 | aItem = (AddresseeIconViewItem*)(item); |
325 | #endif //KAB_EMBEDDED | 321 | #endif //KAB_EMBEDDED |
326 | if (aItem) | 322 | if (aItem) |
327 | uidList << aItem->addressee().uid(); | 323 | uidList << aItem->addressee().uid(); |
328 | } | 324 | } |
329 | } | 325 | } |
330 | 326 | ||
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index b73ceaa..f4b008c 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp | |||
@@ -82,133 +82,129 @@ void KAddressBookTableView::reconstructListView() | |||
82 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 82 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
83 | this, SLOT(addresseeExecuted(QListViewItem*))); | 83 | this, SLOT(addresseeExecuted(QListViewItem*))); |
84 | 84 | ||
85 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 85 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
86 | SIGNAL(dropped(QDropEvent*))); | 86 | SIGNAL(dropped(QDropEvent*))); |
87 | delete mListView; | 87 | delete mListView; |
88 | } | 88 | } |
89 | 89 | ||
90 | mListView = new ContactListView( this, addressBook(), viewWidget() ); | 90 | mListView = new ContactListView( this, addressBook(), viewWidget() ); |
91 | 91 | ||
92 | connect(this, SIGNAL(printView()), | 92 | connect(this, SIGNAL(printView()), |
93 | mListView , SLOT(printMe())); | 93 | mListView , SLOT(printMe())); |
94 | //US set singleClick manually, because it is no global configparameter in embedded space | 94 | //US set singleClick manually, because it is no global configparameter in embedded space |
95 | mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); | 95 | mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); |
96 | 96 | ||
97 | // Add the columns | 97 | // Add the columns |
98 | KABC::Field::List fieldList = fields(); | 98 | KABC::Field::List fieldList = fields(); |
99 | KABC::Field::List::ConstIterator it; | 99 | KABC::Field::List::ConstIterator it; |
100 | 100 | ||
101 | int c = 0; | 101 | int c = 0; |
102 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { | 102 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { |
103 | mListView->addColumn( (*it)->label() ); | 103 | mListView->addColumn( (*it)->label() ); |
104 | mListView->setColumnWidthMode(c++, QListView::Manual); | 104 | mListView->setColumnWidthMode(c++, QListView::Manual); |
105 | //US | 105 | //US |
106 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); | 106 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); |
107 | } | 107 | } |
108 | 108 | ||
109 | connect(mListView, SIGNAL(selectionChanged()), | 109 | connect(mListView, SIGNAL(selectionChanged()), |
110 | this, SLOT(addresseeSelected())); | 110 | this, SLOT(addresseeSelected())); |
111 | connect(mListView, SIGNAL(startAddresseeDrag()), this, | 111 | connect(mListView, SIGNAL(startAddresseeDrag()), this, |
112 | SIGNAL(startDrag())); | 112 | SIGNAL(startDrag())); |
113 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 113 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
114 | SIGNAL(dropped(QDropEvent*))); | 114 | SIGNAL(dropped(QDropEvent*))); |
115 | 115 | ||
116 | if (KABPrefs::instance()->mHonorSingleClick) { | 116 | if (KABPrefs::instance()->mHonorSingleClick) { |
117 | // qDebug("KAddressBookTableView::reconstructListView single"); | 117 | // qDebug("KAddressBookTableView::reconstructListView single"); |
118 | connect(mListView, SIGNAL(executed(QListViewItem*)), | 118 | connect(mListView, SIGNAL(executed(QListViewItem*)), |
119 | this, SLOT(addresseeExecuted(QListViewItem*))); | 119 | this, SLOT(addresseeExecuted(QListViewItem*))); |
120 | } else { | 120 | } else { |
121 | // qDebug("KAddressBookTableView::reconstructListView double"); | 121 | // qDebug("KAddressBookTableView::reconstructListView double"); |
122 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 122 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
123 | this, SLOT(addresseeExecuted(QListViewItem*))); | 123 | this, SLOT(addresseeExecuted(QListViewItem*))); |
124 | } | 124 | } |
125 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 125 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
126 | this, SLOT(addresseeExecuted(QListViewItem*))); | 126 | this, SLOT(addresseeExecuted(QListViewItem*))); |
127 | connect(mListView, SIGNAL(signalDelete()), | 127 | connect(mListView, SIGNAL(signalDelete()), |
128 | this, SLOT(addresseeDeleted())); | 128 | this, SLOT(addresseeDeleted())); |
129 | 129 | ||
130 | //US performceimprovement. Refresh is done from the outside | 130 | //US performceimprovement. Refresh is done from the outside |
131 | //US refresh(); | 131 | //US refresh(); |
132 | 132 | ||
133 | mListView->setSorting( 0, true ); | 133 | mListView->setSorting( 0, true ); |
134 | mainLayout->addWidget( mListView ); | 134 | mainLayout->addWidget( mListView ); |
135 | mainLayout->activate(); | 135 | mainLayout->activate(); |
136 | mListView->show(); | 136 | mListView->show(); |
137 | } | 137 | } |
138 | 138 | ||
139 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | 139 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) |
140 | { | 140 | { |
141 | mListView->clear(); | 141 | mListView->clear(); |
142 | if ( s.isEmpty() || s == "*" ) { | 142 | if ( s.isEmpty() || s == "*" ) { |
143 | refresh(); | 143 | refresh(); |
144 | return; | 144 | return; |
145 | } | 145 | } |
146 | QString pattern = s.lower()+"*"; | 146 | QRegExp re = getRegExp( s ); |
147 | QRegExp re; | ||
148 | re.setWildcard(true); // most people understand these better. | ||
149 | re.setCaseSensitive(false); | ||
150 | re.setPattern( pattern ); | ||
151 | if (!re.isValid()) | 147 | if (!re.isValid()) |
152 | return; | 148 | return; |
153 | KABC::Addressee::List addresseeList = addressees(); | 149 | KABC::Addressee::List addresseeList = addressees(); |
154 | KABC::Addressee::List::Iterator it; | 150 | KABC::Addressee::List::Iterator it; |
155 | if ( field ) { | 151 | if ( field ) { |
156 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 152 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
157 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 153 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
158 | continue; | 154 | continue; |
159 | #if QT_VERSION >= 0x030000 | 155 | #if QT_VERSION >= 0x030000 |
160 | if (re.search(field->value( *it ).lower()) == 0) | 156 | if (re.search(field->value( *it ).lower()) == 0) |
161 | #else | 157 | #else |
162 | if (re.match(field->value( *it ).lower()) != -1) | 158 | if (re.match(field->value( *it ).lower()) != -1) |
163 | #endif | 159 | #endif |
164 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 160 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
165 | 161 | ||
166 | } | 162 | } |
167 | } else { | 163 | } else { |
168 | KABC::Field::List fieldList = allFields(); | 164 | KABC::Field::List fieldList = allFields(); |
169 | KABC::Field::List::ConstIterator fieldIt; | 165 | KABC::Field::List::ConstIterator fieldIt; |
170 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 166 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
171 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 167 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
172 | continue; | 168 | continue; |
173 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 169 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
174 | #if QT_VERSION >= 0x030000 | 170 | #if QT_VERSION >= 0x030000 |
175 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 171 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
176 | #else | 172 | #else |
177 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 173 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
178 | #endif | 174 | #endif |
179 | { | 175 | { |
180 | //qDebug("match %s %s %s", pattern.latin1(), (*fieldIt)->value( *it ).latin1(), (*fieldIt)->label().latin1() ); | 176 | //qDebug("match %s %s %s", pattern.latin1(), (*fieldIt)->value( *it ).latin1(), (*fieldIt)->label().latin1() ); |
181 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 177 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
182 | break; | 178 | break; |
183 | } | 179 | } |
184 | } | 180 | } |
185 | } | 181 | } |
186 | } | 182 | } |
187 | // Sometimes the background pixmap gets messed up when we add lots | 183 | // Sometimes the background pixmap gets messed up when we add lots |
188 | // of items. | 184 | // of items. |
189 | mListView->repaint(); | 185 | mListView->repaint(); |
190 | if ( mListView->firstChild() ) { | 186 | if ( mListView->firstChild() ) { |
191 | mListView->setCurrentItem ( mListView->firstChild() ); | 187 | mListView->setCurrentItem ( mListView->firstChild() ); |
192 | mListView->setSelected ( mListView->firstChild(), true ); | 188 | mListView->setSelected ( mListView->firstChild(), true ); |
193 | } | 189 | } |
194 | else | 190 | else |
195 | emit selected(QString::null); | 191 | emit selected(QString::null); |
196 | 192 | ||
197 | } | 193 | } |
198 | void KAddressBookTableView::writeConfig(KConfig *config) | 194 | void KAddressBookTableView::writeConfig(KConfig *config) |
199 | { | 195 | { |
200 | KAddressBookView::writeConfig(config); | 196 | KAddressBookView::writeConfig(config); |
201 | 197 | ||
202 | mListView->saveLayout(config, config->group()); | 198 | mListView->saveLayout(config, config->group()); |
203 | } | 199 | } |
204 | 200 | ||
205 | void KAddressBookTableView::readConfig(KConfig *config) | 201 | void KAddressBookTableView::readConfig(KConfig *config) |
206 | { | 202 | { |
207 | KAddressBookView::readConfig( config ); | 203 | KAddressBookView::readConfig( config ); |
208 | // The config could have changed the fields, so we need to reconstruct | 204 | // The config could have changed the fields, so we need to reconstruct |
209 | // the listview. | 205 | // the listview. |
210 | reconstructListView(); | 206 | reconstructListView(); |
211 | 207 | ||
212 | // costum colors? | 208 | // costum colors? |
213 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 209 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
214 | { | 210 | { |