author | zautrix <zautrix> | 2005-01-17 12:18:59 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-17 12:18:59 (UTC) |
commit | 6b166ece0a576e9be9c71a61fab5424d75a9301f (patch) (unidiff) | |
tree | b88bf3e82cafc0ac279eb46b8ebc61f112083032 | |
parent | 376ffdba71ab4d7d7988229f38678394a54e5576 (diff) | |
download | kdepimpi-6b166ece0a576e9be9c71a61fab5424d75a9301f.zip kdepimpi-6b166ece0a576e9be9c71a61fab5424d75a9301f.tar.gz kdepimpi-6b166ece0a576e9be9c71a61fab5424d75a9301f.tar.bz2 |
many AB fixes
-rw-r--r-- | kabc/addressbook.cpp | 9 | ||||
-rw-r--r-- | kabc/addressee.cpp | 8 | ||||
-rw-r--r-- | kabc/secrecy.h | 2 | ||||
-rw-r--r-- | kabc/vcard/VCardv.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/filter.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/filter.h | 2 | ||||
-rw-r--r-- | kaddressbook/filtereditdialog.cpp | 1 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 16 | ||||
-rw-r--r-- | kaddressbook/kaddressbookmain.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/viewmanager.cpp | 3 |
10 files changed, 30 insertions, 17 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 8487ff3..4de7da2 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -1,1259 +1,1266 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library 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 GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | /*US | 28 | /*US |
29 | 29 | ||
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | #include <kapplication.h> | 34 | #include <kapplication.h> |
35 | #include <kinstance.h> | 35 | #include <kinstance.h> |
36 | #include <kstandarddirs.h> | 36 | #include <kstandarddirs.h> |
37 | 37 | ||
38 | #include "errorhandler.h" | 38 | #include "errorhandler.h" |
39 | */ | 39 | */ |
40 | #include <qptrlist.h> | 40 | #include <qptrlist.h> |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | 44 | ||
45 | #include <kglobal.h> | 45 | #include <kglobal.h> |
46 | #include <klocale.h> | 46 | #include <klocale.h> |
47 | #include <kmessagebox.h> | 47 | #include <kmessagebox.h> |
48 | #include <kdebug.h> | 48 | #include <kdebug.h> |
49 | #include <libkcal/syncdefines.h> | 49 | #include <libkcal/syncdefines.h> |
50 | #include <libkdepim/phoneaccess.h> | 50 | #include <libkdepim/phoneaccess.h> |
51 | #include "addressbook.h" | 51 | #include "addressbook.h" |
52 | #include "resource.h" | 52 | #include "resource.h" |
53 | #include "vcardconverter.h" | 53 | #include "vcardconverter.h" |
54 | #include "vcardparser/vcardtool.h" | 54 | #include "vcardparser/vcardtool.h" |
55 | 55 | ||
56 | //US #include "addressbook.moc" | 56 | //US #include "addressbook.moc" |
57 | 57 | ||
58 | using namespace KABC; | 58 | using namespace KABC; |
59 | 59 | ||
60 | struct AddressBook::AddressBookData | 60 | struct AddressBook::AddressBookData |
61 | { | 61 | { |
62 | Addressee::List mAddressees; | 62 | Addressee::List mAddressees; |
63 | Addressee::List mRemovedAddressees; | 63 | Addressee::List mRemovedAddressees; |
64 | Field::List mAllFields; | 64 | Field::List mAllFields; |
65 | KConfig *mConfig; | 65 | KConfig *mConfig; |
66 | KRES::Manager<Resource> *mManager; | 66 | KRES::Manager<Resource> *mManager; |
67 | //US ErrorHandler *mErrorHandler; | 67 | //US ErrorHandler *mErrorHandler; |
68 | }; | 68 | }; |
69 | 69 | ||
70 | struct AddressBook::Iterator::IteratorData | 70 | struct AddressBook::Iterator::IteratorData |
71 | { | 71 | { |
72 | Addressee::List::Iterator mIt; | 72 | Addressee::List::Iterator mIt; |
73 | }; | 73 | }; |
74 | 74 | ||
75 | struct AddressBook::ConstIterator::ConstIteratorData | 75 | struct AddressBook::ConstIterator::ConstIteratorData |
76 | { | 76 | { |
77 | Addressee::List::ConstIterator mIt; | 77 | Addressee::List::ConstIterator mIt; |
78 | }; | 78 | }; |
79 | 79 | ||
80 | AddressBook::Iterator::Iterator() | 80 | AddressBook::Iterator::Iterator() |
81 | { | 81 | { |
82 | d = new IteratorData; | 82 | d = new IteratorData; |
83 | } | 83 | } |
84 | 84 | ||
85 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) | 85 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) |
86 | { | 86 | { |
87 | d = new IteratorData; | 87 | d = new IteratorData; |
88 | d->mIt = i.d->mIt; | 88 | d->mIt = i.d->mIt; |
89 | } | 89 | } |
90 | 90 | ||
91 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) | 91 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) |
92 | { | 92 | { |
93 | if( this == &i ) return *this; // guard against self assignment | 93 | if( this == &i ) return *this; // guard against self assignment |
94 | delete d; // delete the old data the Iterator was completely constructed before | 94 | delete d; // delete the old data the Iterator was completely constructed before |
95 | d = new IteratorData; | 95 | d = new IteratorData; |
96 | d->mIt = i.d->mIt; | 96 | d->mIt = i.d->mIt; |
97 | return *this; | 97 | return *this; |
98 | } | 98 | } |
99 | 99 | ||
100 | AddressBook::Iterator::~Iterator() | 100 | AddressBook::Iterator::~Iterator() |
101 | { | 101 | { |
102 | delete d; | 102 | delete d; |
103 | } | 103 | } |
104 | 104 | ||
105 | const Addressee &AddressBook::Iterator::operator*() const | 105 | const Addressee &AddressBook::Iterator::operator*() const |
106 | { | 106 | { |
107 | return *(d->mIt); | 107 | return *(d->mIt); |
108 | } | 108 | } |
109 | 109 | ||
110 | Addressee &AddressBook::Iterator::operator*() | 110 | Addressee &AddressBook::Iterator::operator*() |
111 | { | 111 | { |
112 | return *(d->mIt); | 112 | return *(d->mIt); |
113 | } | 113 | } |
114 | 114 | ||
115 | Addressee *AddressBook::Iterator::operator->() | 115 | Addressee *AddressBook::Iterator::operator->() |
116 | { | 116 | { |
117 | return &(*(d->mIt)); | 117 | return &(*(d->mIt)); |
118 | } | 118 | } |
119 | 119 | ||
120 | AddressBook::Iterator &AddressBook::Iterator::operator++() | 120 | AddressBook::Iterator &AddressBook::Iterator::operator++() |
121 | { | 121 | { |
122 | (d->mIt)++; | 122 | (d->mIt)++; |
123 | return *this; | 123 | return *this; |
124 | } | 124 | } |
125 | 125 | ||
126 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) | 126 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) |
127 | { | 127 | { |
128 | (d->mIt)++; | 128 | (d->mIt)++; |
129 | return *this; | 129 | return *this; |
130 | } | 130 | } |
131 | 131 | ||
132 | AddressBook::Iterator &AddressBook::Iterator::operator--() | 132 | AddressBook::Iterator &AddressBook::Iterator::operator--() |
133 | { | 133 | { |
134 | (d->mIt)--; | 134 | (d->mIt)--; |
135 | return *this; | 135 | return *this; |
136 | } | 136 | } |
137 | 137 | ||
138 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) | 138 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) |
139 | { | 139 | { |
140 | (d->mIt)--; | 140 | (d->mIt)--; |
141 | return *this; | 141 | return *this; |
142 | } | 142 | } |
143 | 143 | ||
144 | bool AddressBook::Iterator::operator==( const Iterator &it ) | 144 | bool AddressBook::Iterator::operator==( const Iterator &it ) |
145 | { | 145 | { |
146 | return ( d->mIt == it.d->mIt ); | 146 | return ( d->mIt == it.d->mIt ); |
147 | } | 147 | } |
148 | 148 | ||
149 | bool AddressBook::Iterator::operator!=( const Iterator &it ) | 149 | bool AddressBook::Iterator::operator!=( const Iterator &it ) |
150 | { | 150 | { |
151 | return ( d->mIt != it.d->mIt ); | 151 | return ( d->mIt != it.d->mIt ); |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | AddressBook::ConstIterator::ConstIterator() | 155 | AddressBook::ConstIterator::ConstIterator() |
156 | { | 156 | { |
157 | d = new ConstIteratorData; | 157 | d = new ConstIteratorData; |
158 | } | 158 | } |
159 | 159 | ||
160 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) | 160 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) |
161 | { | 161 | { |
162 | d = new ConstIteratorData; | 162 | d = new ConstIteratorData; |
163 | d->mIt = i.d->mIt; | 163 | d->mIt = i.d->mIt; |
164 | } | 164 | } |
165 | 165 | ||
166 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) | 166 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) |
167 | { | 167 | { |
168 | if( this == &i ) return *this; // guard for self assignment | 168 | if( this == &i ) return *this; // guard for self assignment |
169 | delete d; // delete the old data because the Iterator was really constructed before | 169 | delete d; // delete the old data because the Iterator was really constructed before |
170 | d = new ConstIteratorData; | 170 | d = new ConstIteratorData; |
171 | d->mIt = i.d->mIt; | 171 | d->mIt = i.d->mIt; |
172 | return *this; | 172 | return *this; |
173 | } | 173 | } |
174 | 174 | ||
175 | AddressBook::ConstIterator::~ConstIterator() | 175 | AddressBook::ConstIterator::~ConstIterator() |
176 | { | 176 | { |
177 | delete d; | 177 | delete d; |
178 | } | 178 | } |
179 | 179 | ||
180 | const Addressee &AddressBook::ConstIterator::operator*() const | 180 | const Addressee &AddressBook::ConstIterator::operator*() const |
181 | { | 181 | { |
182 | return *(d->mIt); | 182 | return *(d->mIt); |
183 | } | 183 | } |
184 | 184 | ||
185 | const Addressee* AddressBook::ConstIterator::operator->() const | 185 | const Addressee* AddressBook::ConstIterator::operator->() const |
186 | { | 186 | { |
187 | return &(*(d->mIt)); | 187 | return &(*(d->mIt)); |
188 | } | 188 | } |
189 | 189 | ||
190 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() | 190 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() |
191 | { | 191 | { |
192 | (d->mIt)++; | 192 | (d->mIt)++; |
193 | return *this; | 193 | return *this; |
194 | } | 194 | } |
195 | 195 | ||
196 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) | 196 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) |
197 | { | 197 | { |
198 | (d->mIt)++; | 198 | (d->mIt)++; |
199 | return *this; | 199 | return *this; |
200 | } | 200 | } |
201 | 201 | ||
202 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() | 202 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() |
203 | { | 203 | { |
204 | (d->mIt)--; | 204 | (d->mIt)--; |
205 | return *this; | 205 | return *this; |
206 | } | 206 | } |
207 | 207 | ||
208 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | 208 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) |
209 | { | 209 | { |
210 | (d->mIt)--; | 210 | (d->mIt)--; |
211 | return *this; | 211 | return *this; |
212 | } | 212 | } |
213 | 213 | ||
214 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 214 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
215 | { | 215 | { |
216 | return ( d->mIt == it.d->mIt ); | 216 | return ( d->mIt == it.d->mIt ); |
217 | } | 217 | } |
218 | 218 | ||
219 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 219 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
220 | { | 220 | { |
221 | return ( d->mIt != it.d->mIt ); | 221 | return ( d->mIt != it.d->mIt ); |
222 | } | 222 | } |
223 | 223 | ||
224 | 224 | ||
225 | AddressBook::AddressBook() | 225 | AddressBook::AddressBook() |
226 | { | 226 | { |
227 | init(0, "contact"); | 227 | init(0, "contact"); |
228 | } | 228 | } |
229 | 229 | ||
230 | AddressBook::AddressBook( const QString &config ) | 230 | AddressBook::AddressBook( const QString &config ) |
231 | { | 231 | { |
232 | init(config, "contact"); | 232 | init(config, "contact"); |
233 | } | 233 | } |
234 | 234 | ||
235 | AddressBook::AddressBook( const QString &config, const QString &family ) | 235 | AddressBook::AddressBook( const QString &config, const QString &family ) |
236 | { | 236 | { |
237 | init(config, family); | 237 | init(config, family); |
238 | 238 | ||
239 | } | 239 | } |
240 | 240 | ||
241 | // the default family is "contact" | 241 | // the default family is "contact" |
242 | void AddressBook::init(const QString &config, const QString &family ) | 242 | void AddressBook::init(const QString &config, const QString &family ) |
243 | { | 243 | { |
244 | blockLSEchange = false; | 244 | blockLSEchange = false; |
245 | d = new AddressBookData; | 245 | d = new AddressBookData; |
246 | QString fami = family; | 246 | QString fami = family; |
247 | if (config != 0) { | 247 | if (config != 0) { |
248 | if ( family == "syncContact" ) { | 248 | if ( family == "syncContact" ) { |
249 | qDebug("creating sync config "); | 249 | qDebug("creating sync config "); |
250 | fami = "contact"; | 250 | fami = "contact"; |
251 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); | 251 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); |
252 | con->setGroup( "General" ); | 252 | con->setGroup( "General" ); |
253 | con->writeEntry( "ResourceKeys", QString("sync") ); | 253 | con->writeEntry( "ResourceKeys", QString("sync") ); |
254 | con->writeEntry( "Standard", QString("sync") ); | 254 | con->writeEntry( "Standard", QString("sync") ); |
255 | con->setGroup( "Resource_sync" ); | 255 | con->setGroup( "Resource_sync" ); |
256 | con->writeEntry( "FileName", config ); | 256 | con->writeEntry( "FileName", config ); |
257 | con->writeEntry( "FileFormat", QString("vcard") ); | 257 | con->writeEntry( "FileFormat", QString("vcard") ); |
258 | con->writeEntry( "ResourceIdentifier", QString("sync") ); | 258 | con->writeEntry( "ResourceIdentifier", QString("sync") ); |
259 | con->writeEntry( "ResourceName", QString("sync_res") ); | 259 | con->writeEntry( "ResourceName", QString("sync_res") ); |
260 | if ( config.right(4) == ".xml" ) | 260 | if ( config.right(4) == ".xml" ) |
261 | con->writeEntry( "ResourceType", QString("qtopia") ); | 261 | con->writeEntry( "ResourceType", QString("qtopia") ); |
262 | else if ( config == "sharp" ) { | 262 | else if ( config == "sharp" ) { |
263 | con->writeEntry( "ResourceType", QString("sharp") ); | 263 | con->writeEntry( "ResourceType", QString("sharp") ); |
264 | } else { | 264 | } else { |
265 | con->writeEntry( "ResourceType", QString("file") ); | 265 | con->writeEntry( "ResourceType", QString("file") ); |
266 | } | 266 | } |
267 | //con->sync(); | 267 | //con->sync(); |
268 | d->mConfig = con; | 268 | d->mConfig = con; |
269 | } | 269 | } |
270 | else | 270 | else |
271 | d->mConfig = new KConfig( locateLocal("config", config) ); | 271 | d->mConfig = new KConfig( locateLocal("config", config) ); |
272 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 272 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
273 | } | 273 | } |
274 | else { | 274 | else { |
275 | d->mConfig = 0; | 275 | d->mConfig = 0; |
276 | // qDebug("AddressBook::init 1 config=0"); | 276 | // qDebug("AddressBook::init 1 config=0"); |
277 | } | 277 | } |
278 | 278 | ||
279 | //US d->mErrorHandler = 0; | 279 | //US d->mErrorHandler = 0; |
280 | d->mManager = new KRES::Manager<Resource>( fami ); | 280 | d->mManager = new KRES::Manager<Resource>( fami ); |
281 | d->mManager->readConfig( d->mConfig ); | 281 | d->mManager->readConfig( d->mConfig ); |
282 | if ( family == "syncContact" ) { | 282 | if ( family == "syncContact" ) { |
283 | KRES::Manager<Resource> *manager = d->mManager; | 283 | KRES::Manager<Resource> *manager = d->mManager; |
284 | KRES::Manager<Resource>::ActiveIterator it; | 284 | KRES::Manager<Resource>::ActiveIterator it; |
285 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 285 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
286 | (*it)->setAddressBook( this ); | 286 | (*it)->setAddressBook( this ); |
287 | if ( !(*it)->open() ) | 287 | if ( !(*it)->open() ) |
288 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 288 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
289 | } | 289 | } |
290 | Resource *res = standardResource(); | 290 | Resource *res = standardResource(); |
291 | if ( !res ) { | 291 | if ( !res ) { |
292 | qDebug("ERROR: no standard resource"); | 292 | qDebug("ERROR: no standard resource"); |
293 | res = manager->createResource( "file" ); | 293 | res = manager->createResource( "file" ); |
294 | if ( res ) | 294 | if ( res ) |
295 | { | 295 | { |
296 | addResource( res ); | 296 | addResource( res ); |
297 | } | 297 | } |
298 | else | 298 | else |
299 | qDebug(" No resource available!!!"); | 299 | qDebug(" No resource available!!!"); |
300 | } | 300 | } |
301 | setStandardResource( res ); | 301 | setStandardResource( res ); |
302 | manager->writeConfig(); | 302 | manager->writeConfig(); |
303 | } | 303 | } |
304 | addCustomField( i18n( "Department" ), KABC::Field::Organization, | 304 | addCustomField( i18n( "Department" ), KABC::Field::Organization, |
305 | "X-Department", "KADDRESSBOOK" ); | 305 | "X-Department", "KADDRESSBOOK" ); |
306 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 306 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
307 | "X-Profession", "KADDRESSBOOK" ); | 307 | "X-Profession", "KADDRESSBOOK" ); |
308 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 308 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
309 | "X-AssistantsName", "KADDRESSBOOK" ); | 309 | "X-AssistantsName", "KADDRESSBOOK" ); |
310 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 310 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
311 | "X-ManagersName", "KADDRESSBOOK" ); | 311 | "X-ManagersName", "KADDRESSBOOK" ); |
312 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 312 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
313 | "X-SpousesName", "KADDRESSBOOK" ); | 313 | "X-SpousesName", "KADDRESSBOOK" ); |
314 | addCustomField( i18n( "Office" ), KABC::Field::Personal, | 314 | addCustomField( i18n( "Office" ), KABC::Field::Personal, |
315 | "X-Office", "KADDRESSBOOK" ); | 315 | "X-Office", "KADDRESSBOOK" ); |
316 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 316 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
317 | "X-IMAddress", "KADDRESSBOOK" ); | 317 | "X-IMAddress", "KADDRESSBOOK" ); |
318 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 318 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
319 | "X-Anniversary", "KADDRESSBOOK" ); | 319 | "X-Anniversary", "KADDRESSBOOK" ); |
320 | 320 | ||
321 | //US added this field to become compatible with Opie/qtopia addressbook | 321 | //US added this field to become compatible with Opie/qtopia addressbook |
322 | // values can be "female" or "male" or "". An empty field represents undefined. | 322 | // values can be "female" or "male" or "". An empty field represents undefined. |
323 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 323 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
324 | "X-Gender", "KADDRESSBOOK" ); | 324 | "X-Gender", "KADDRESSBOOK" ); |
325 | addCustomField( i18n( "Children" ), KABC::Field::Personal, | 325 | addCustomField( i18n( "Children" ), KABC::Field::Personal, |
326 | "X-Children", "KADDRESSBOOK" ); | 326 | "X-Children", "KADDRESSBOOK" ); |
327 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 327 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
328 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 328 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
329 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, | 329 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, |
330 | "X-ExternalID", "KADDRESSBOOK" ); | 330 | "X-ExternalID", "KADDRESSBOOK" ); |
331 | } | 331 | } |
332 | 332 | ||
333 | AddressBook::~AddressBook() | 333 | AddressBook::~AddressBook() |
334 | { | 334 | { |
335 | delete d->mConfig; d->mConfig = 0; | 335 | delete d->mConfig; d->mConfig = 0; |
336 | delete d->mManager; d->mManager = 0; | 336 | delete d->mManager; d->mManager = 0; |
337 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 337 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
338 | delete d; d = 0; | 338 | delete d; d = 0; |
339 | } | 339 | } |
340 | 340 | ||
341 | bool AddressBook::load() | 341 | bool AddressBook::load() |
342 | { | 342 | { |
343 | 343 | ||
344 | clear(); | 344 | clear(); |
345 | KRES::Manager<Resource>::ActiveIterator it; | 345 | KRES::Manager<Resource>::ActiveIterator it; |
346 | bool ok = true; | 346 | bool ok = true; |
347 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 347 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
348 | if ( !(*it)->load() ) { | 348 | if ( !(*it)->load() ) { |
349 | qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 349 | qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
350 | ok = false; | 350 | ok = false; |
351 | } else { | 351 | } else { |
352 | qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) ); | 352 | qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) ); |
353 | } | 353 | } |
354 | // mark all addressees as unchanged | 354 | // mark all addressees as unchanged |
355 | Addressee::List::Iterator addrIt; | 355 | Addressee::List::Iterator addrIt; |
356 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { | 356 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { |
357 | (*addrIt).setChanged( false ); | 357 | (*addrIt).setChanged( false ); |
358 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); | 358 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); |
359 | if ( !id.isEmpty() ) { | 359 | if ( !id.isEmpty() ) { |
360 | //qDebug("setId aa %s ", id.latin1()); | 360 | //qDebug("setId aa %s ", id.latin1()); |
361 | (*addrIt).setIDStr(id ); | 361 | (*addrIt).setIDStr(id ); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | blockLSEchange = true; | 364 | blockLSEchange = true; |
365 | return ok; | 365 | return ok; |
366 | } | 366 | } |
367 | 367 | ||
368 | bool AddressBook::save( Ticket *ticket ) | 368 | bool AddressBook::save( Ticket *ticket ) |
369 | { | 369 | { |
370 | kdDebug(5700) << "AddressBook::save()"<< endl; | 370 | kdDebug(5700) << "AddressBook::save()"<< endl; |
371 | 371 | ||
372 | if ( ticket->resource() ) { | 372 | if ( ticket->resource() ) { |
373 | deleteRemovedAddressees(); | 373 | deleteRemovedAddressees(); |
374 | return ticket->resource()->save( ticket ); | 374 | return ticket->resource()->save( ticket ); |
375 | } | 375 | } |
376 | 376 | ||
377 | return false; | 377 | return false; |
378 | } | 378 | } |
379 | // exports all Addressees, which are syncable | 379 | // exports all Addressees, which are syncable |
380 | void AddressBook::export2File( QString fileName ) | 380 | void AddressBook::export2File( QString fileName ) |
381 | { | 381 | { |
382 | 382 | ||
383 | QFile outFile( fileName ); | 383 | QFile outFile( fileName ); |
384 | if ( !outFile.open( IO_WriteOnly ) ) { | 384 | if ( !outFile.open( IO_WriteOnly ) ) { |
385 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 385 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
386 | KMessageBox::error( 0, text.arg( fileName ) ); | 386 | KMessageBox::error( 0, text.arg( fileName ) ); |
387 | return ; | 387 | return ; |
388 | } | 388 | } |
389 | QTextStream t( &outFile ); | 389 | QTextStream t( &outFile ); |
390 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 390 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
391 | Iterator it; | 391 | Iterator it; |
392 | KABC::VCardConverter::Version version; | 392 | KABC::VCardConverter::Version version; |
393 | version = KABC::VCardConverter::v3_0; | 393 | version = KABC::VCardConverter::v3_0; |
394 | for ( it = begin(); it != end(); ++it ) { | 394 | for ( it = begin(); it != end(); ++it ) { |
395 | if ( (*it).resource() && (*it).resource()->includeInSync() ) { | 395 | if ( (*it).resource() && (*it).resource()->includeInSync() ) { |
396 | if ( !(*it).IDStr().isEmpty() ) { | 396 | if ( !(*it).IDStr().isEmpty() ) { |
397 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); | 397 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); |
398 | } | 398 | } |
399 | KABC::VCardConverter converter; | 399 | KABC::VCardConverter converter; |
400 | QString vcard; | 400 | QString vcard; |
401 | //Resource *resource() const; | 401 | //Resource *resource() const; |
402 | converter.addresseeToVCard( *it, vcard, version ); | 402 | converter.addresseeToVCard( *it, vcard, version ); |
403 | t << vcard << "\r\n"; | 403 | t << vcard << "\r\n"; |
404 | } | 404 | } |
405 | } | 405 | } |
406 | t << "\r\n\r\n"; | 406 | t << "\r\n\r\n"; |
407 | outFile.close(); | 407 | outFile.close(); |
408 | } | 408 | } |
409 | // if QStringList uids is empty, all are exported | 409 | // if QStringList uids is empty, all are exported |
410 | bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) | 410 | bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) |
411 | { | 411 | { |
412 | KABC::VCardConverter converter; | 412 | KABC::VCardConverter converter; |
413 | QString datastream; | 413 | QString datastream; |
414 | Iterator it; | 414 | Iterator it; |
415 | bool all = uids.isEmpty(); | 415 | bool all = uids.isEmpty(); |
416 | for ( it = begin(); it != end(); ++it ) { | 416 | for ( it = begin(); it != end(); ++it ) { |
417 | // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 417 | // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
418 | if ( ! all ) { | 418 | if ( ! all ) { |
419 | if ( ! ( uids.contains((*it).uid() ) )) | 419 | if ( ! ( uids.contains((*it).uid() ) )) |
420 | continue; | 420 | continue; |
421 | } | 421 | } |
422 | KABC::Addressee a = ( *it ); | 422 | KABC::Addressee a = ( *it ); |
423 | if ( a.isEmpty() ) | 423 | if ( a.isEmpty() ) |
424 | continue; | 424 | continue; |
425 | if ( all && a.resource() && !a.resource()->includeInSync() ) | 425 | if ( all && a.resource() && !a.resource()->includeInSync() ) |
426 | continue; | 426 | continue; |
427 | a.simplifyEmails(); | 427 | a.simplifyEmails(); |
428 | a.simplifyPhoneNumbers(); | 428 | a.simplifyPhoneNumbers(); |
429 | a.simplifyPhoneNumberTypes(); | 429 | a.simplifyPhoneNumberTypes(); |
430 | a.simplifyAddresses(); | 430 | a.simplifyAddresses(); |
431 | 431 | ||
432 | QString vcard; | 432 | QString vcard; |
433 | QString vcardnew; | 433 | QString vcardnew; |
434 | converter.addresseeToVCard( a, vcard ); | 434 | converter.addresseeToVCard( a, vcard ); |
435 | int start = 0; | 435 | int start = 0; |
436 | int next; | 436 | int next; |
437 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 437 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
438 | int semi = vcard.find(";", next); | 438 | int semi = vcard.find(";", next); |
439 | int dopp = vcard.find(":", next); | 439 | int dopp = vcard.find(":", next); |
440 | int sep; | 440 | int sep; |
441 | if ( semi < dopp && semi >= 0 ) | 441 | if ( semi < dopp && semi >= 0 ) |
442 | sep = semi ; | 442 | sep = semi ; |
443 | else | 443 | else |
444 | sep = dopp; | 444 | sep = dopp; |
445 | vcardnew +=vcard.mid( start, next - start); | 445 | vcardnew +=vcard.mid( start, next - start); |
446 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); | 446 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); |
447 | start = sep; | 447 | start = sep; |
448 | } | 448 | } |
449 | vcardnew += vcard.mid( start,vcard.length() ); | 449 | vcardnew += vcard.mid( start,vcard.length() ); |
450 | vcard = ""; | 450 | vcard = ""; |
451 | start = 0; | 451 | start = 0; |
452 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { | 452 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { |
453 | int sep = vcardnew.find(":", next); | 453 | int sep = vcardnew.find(":", next); |
454 | vcard +=vcardnew.mid( start, next - start+3); | 454 | vcard +=vcardnew.mid( start, next - start+3); |
455 | start = sep; | 455 | start = sep; |
456 | } | 456 | } |
457 | vcard += vcardnew.mid( start,vcardnew.length() ); | 457 | vcard += vcardnew.mid( start,vcardnew.length() ); |
458 | vcard.replace ( QRegExp(";;;") , "" ); | 458 | vcard.replace ( QRegExp(";;;") , "" ); |
459 | vcard.replace ( QRegExp(";;") , "" ); | 459 | vcard.replace ( QRegExp(";;") , "" ); |
460 | datastream += vcard; | 460 | datastream += vcard; |
461 | 461 | ||
462 | } | 462 | } |
463 | 463 | ||
464 | QFile outFile(fileName); | 464 | QFile outFile(fileName); |
465 | if ( outFile.open(IO_WriteOnly) ) { | 465 | if ( outFile.open(IO_WriteOnly) ) { |
466 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 466 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
467 | QTextStream t( &outFile ); // use a text stream | 467 | QTextStream t( &outFile ); // use a text stream |
468 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 468 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
469 | t <<datastream; | 469 | t <<datastream; |
470 | t << "\r\n\r\n"; | 470 | t << "\r\n\r\n"; |
471 | outFile.close(); | 471 | outFile.close(); |
472 | 472 | ||
473 | } else { | 473 | } else { |
474 | qDebug("Error open temp file "); | 474 | qDebug("Error open temp file "); |
475 | return false; | 475 | return false; |
476 | } | 476 | } |
477 | return true; | 477 | return true; |
478 | 478 | ||
479 | } | 479 | } |
480 | int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) | 480 | int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) |
481 | { | 481 | { |
482 | 482 | ||
483 | if ( removeOld ) | 483 | if ( removeOld ) |
484 | setUntagged( true ); | 484 | setUntagged( true ); |
485 | KABC::Addressee::List list; | 485 | KABC::Addressee::List list; |
486 | QFile file( fileName ); | 486 | QFile file( fileName ); |
487 | file.open( IO_ReadOnly ); | 487 | file.open( IO_ReadOnly ); |
488 | QByteArray rawData = file.readAll(); | 488 | QByteArray rawData = file.readAll(); |
489 | file.close(); | 489 | file.close(); |
490 | QString data; | 490 | QString data; |
491 | if ( replaceLabel ) { | 491 | if ( replaceLabel ) { |
492 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); | 492 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); |
493 | data.replace ( QRegExp("LABEL") , "ADR" ); | 493 | data.replace ( QRegExp("LABEL") , "ADR" ); |
494 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); | 494 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); |
495 | } else | 495 | } else |
496 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 496 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
497 | KABC::VCardTool tool; | 497 | KABC::VCardTool tool; |
498 | list = tool.parseVCards( data ); | 498 | list = tool.parseVCards( data ); |
499 | KABC::Addressee::List::Iterator it; | 499 | KABC::Addressee::List::Iterator it; |
500 | for ( it = list.begin(); it != list.end(); ++it ) { | 500 | for ( it = list.begin(); it != list.end(); ++it ) { |
501 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); | 501 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); |
502 | if ( !id.isEmpty() ) | 502 | if ( !id.isEmpty() ) |
503 | (*it).setIDStr(id ); | 503 | (*it).setIDStr(id ); |
504 | (*it).setResource( 0 ); | 504 | (*it).setResource( 0 ); |
505 | if ( replaceLabel ) | 505 | if ( replaceLabel ) |
506 | (*it).removeVoice(); | 506 | (*it).removeVoice(); |
507 | if ( removeOld ) | 507 | if ( removeOld ) |
508 | (*it).setTagged( true ); | 508 | (*it).setTagged( true ); |
509 | insertAddressee( (*it), false, true ); | 509 | insertAddressee( (*it), false, true ); |
510 | } | 510 | } |
511 | if ( removeOld ) | 511 | if ( removeOld ) |
512 | removeUntagged(); | 512 | removeUntagged(); |
513 | return list.count(); | 513 | return list.count(); |
514 | } | 514 | } |
515 | void AddressBook::setUntagged(bool setNonSyncTagged) // = false) | 515 | void AddressBook::setUntagged(bool setNonSyncTagged) // = false) |
516 | { | 516 | { |
517 | Iterator ait; | 517 | Iterator ait; |
518 | for ( ait = begin(); ait != end(); ++ait ) { | 518 | for ( ait = begin(); ait != end(); ++ait ) { |
519 | if ( setNonSyncTagged ) { | 519 | if ( setNonSyncTagged ) { |
520 | if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { | 520 | if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { |
521 | (*ait).setTagged( true ); | 521 | (*ait).setTagged( true ); |
522 | } else | 522 | } else |
523 | (*ait).setTagged( false ); | 523 | (*ait).setTagged( false ); |
524 | } else | 524 | } else |
525 | (*ait).setTagged( false ); | 525 | (*ait).setTagged( false ); |
526 | } | 526 | } |
527 | } | 527 | } |
528 | void AddressBook::removeUntagged() | 528 | void AddressBook::removeUntagged() |
529 | { | 529 | { |
530 | Iterator ait; | 530 | Iterator ait; |
531 | bool todelete = false; | 531 | bool todelete = false; |
532 | Iterator todel; | 532 | Iterator todel; |
533 | for ( ait = begin(); ait != end(); ++ait ) { | 533 | for ( ait = begin(); ait != end(); ++ait ) { |
534 | if ( todelete ) | 534 | if ( todelete ) |
535 | removeAddressee( todel ); | 535 | removeAddressee( todel ); |
536 | if (!(*ait).tagged()) { | 536 | if (!(*ait).tagged()) { |
537 | todelete = true; | 537 | todelete = true; |
538 | todel = ait; | 538 | todel = ait; |
539 | } else | 539 | } else |
540 | todelete = false; | 540 | todelete = false; |
541 | } | 541 | } |
542 | if ( todelete ) | 542 | if ( todelete ) |
543 | removeAddressee( todel ); | 543 | removeAddressee( todel ); |
544 | deleteRemovedAddressees(); | 544 | deleteRemovedAddressees(); |
545 | } | 545 | } |
546 | void AddressBook::smplifyAddressees() | 546 | void AddressBook::smplifyAddressees() |
547 | { | 547 | { |
548 | Iterator ait; | 548 | Iterator ait; |
549 | for ( ait = begin(); ait != end(); ++ait ) { | 549 | for ( ait = begin(); ait != end(); ++ait ) { |
550 | (*ait).simplifyEmails(); | 550 | (*ait).simplifyEmails(); |
551 | (*ait).simplifyPhoneNumbers(); | 551 | (*ait).simplifyPhoneNumbers(); |
552 | (*ait).simplifyPhoneNumberTypes(); | 552 | (*ait).simplifyPhoneNumberTypes(); |
553 | (*ait).simplifyAddresses(); | 553 | (*ait).simplifyAddresses(); |
554 | } | 554 | } |
555 | } | 555 | } |
556 | void AddressBook::removeSyncInfo( QString syncProfile) | 556 | void AddressBook::removeSyncInfo( QString syncProfile) |
557 | { | 557 | { |
558 | Iterator ait; | 558 | Iterator ait; |
559 | for ( ait = begin(); ait != end(); ++ait ) { | 559 | for ( ait = begin(); ait != end(); ++ait ) { |
560 | (*ait).removeID( syncProfile ); | 560 | (*ait).removeID( syncProfile ); |
561 | } | 561 | } |
562 | if ( syncProfile.isEmpty() ) { | 562 | if ( syncProfile.isEmpty() ) { |
563 | Iterator it = begin(); | 563 | Iterator it = begin(); |
564 | Iterator it2 ; | 564 | Iterator it2 ; |
565 | while ( it != end() ) { | 565 | while ( it != end() ) { |
566 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 566 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
567 | it2 = it; | 567 | it2 = it; |
568 | //qDebug("removing %s ",(*it).uid().latin1() ); | 568 | //qDebug("removing %s ",(*it).uid().latin1() ); |
569 | ++it; | 569 | ++it; |
570 | removeAddressee( it2 ); | 570 | removeAddressee( it2 ); |
571 | } else { | 571 | } else { |
572 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 572 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
573 | ++it; | 573 | ++it; |
574 | } | 574 | } |
575 | } | 575 | } |
576 | } else { | 576 | } else { |
577 | Addressee lse; | 577 | Addressee lse; |
578 | lse = findByUid( "last-syncAddressee-"+ syncProfile ); | 578 | lse = findByUid( "last-syncAddressee-"+ syncProfile ); |
579 | if ( ! lse.isEmpty() ) | 579 | if ( ! lse.isEmpty() ) |
580 | removeAddressee( lse ); | 580 | removeAddressee( lse ); |
581 | } | 581 | } |
582 | 582 | ||
583 | } | 583 | } |
584 | void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) | 584 | void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) |
585 | { | 585 | { |
586 | Iterator ait; | 586 | Iterator ait; |
587 | for ( ait = begin(); ait != end(); ++ait ) { | 587 | for ( ait = begin(); ait != end(); ++ait ) { |
588 | QString id = (*ait).IDStr(); | 588 | QString id = (*ait).IDStr(); |
589 | (*ait).setIDStr( ":"); | 589 | (*ait).setIDStr( ":"); |
590 | (*ait).setExternalUID( id ); | 590 | (*ait).setExternalUID( id ); |
591 | (*ait).setOriginalExternalUID( id ); | 591 | (*ait).setOriginalExternalUID( id ); |
592 | if ( isPreSync ) | 592 | if ( isPreSync ) |
593 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 593 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
594 | else { | 594 | else { |
595 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 595 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
596 | (*ait).setID( currentSyncDevice,id ); | 596 | (*ait).setID( currentSyncDevice,id ); |
597 | 597 | ||
598 | } | 598 | } |
599 | } | 599 | } |
600 | } | 600 | } |
601 | void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) | 601 | void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) |
602 | { | 602 | { |
603 | 603 | ||
604 | setUntagged(); | 604 | setUntagged(); |
605 | KABC::Addressee::List list; | 605 | KABC::Addressee::List list; |
606 | QFile file( fileName ); | 606 | QFile file( fileName ); |
607 | file.open( IO_ReadOnly ); | 607 | file.open( IO_ReadOnly ); |
608 | QByteArray rawData = file.readAll(); | 608 | QByteArray rawData = file.readAll(); |
609 | file.close(); | 609 | file.close(); |
610 | QString data; | 610 | QString data; |
611 | 611 | ||
612 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 612 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
613 | KABC::VCardTool tool; | 613 | KABC::VCardTool tool; |
614 | list = tool.parseVCards( data ); | 614 | list = tool.parseVCards( data ); |
615 | KABC::Addressee::List::Iterator it; | 615 | KABC::Addressee::List::Iterator it; |
616 | for ( it = list.begin(); it != list.end(); ++it ) { | 616 | for ( it = list.begin(); it != list.end(); ++it ) { |
617 | Iterator ait; | 617 | Iterator ait; |
618 | for ( ait = begin(); ait != end(); ++ait ) { | 618 | for ( ait = begin(); ait != end(); ++ait ) { |
619 | if ( !(*ait).tagged() ) { | 619 | if ( !(*ait).tagged() ) { |
620 | if ( (*ait).containsAdr(*it)) { | 620 | if ( (*ait).containsAdr(*it)) { |
621 | (*ait).setTagged(true); | 621 | (*ait).setTagged(true); |
622 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); | 622 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); |
623 | (*it).setIDStr( ":"); | 623 | (*it).setIDStr( ":"); |
624 | (*it).setID( currentSyncDevice,id ); | 624 | (*it).setID( currentSyncDevice,id ); |
625 | (*it).setExternalUID( id ); | 625 | (*it).setExternalUID( id ); |
626 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 626 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
627 | (*it).setUid( ( (*ait).uid() )); | 627 | (*it).setUid( ( (*ait).uid() )); |
628 | break; | 628 | break; |
629 | } | 629 | } |
630 | } | 630 | } |
631 | 631 | ||
632 | } | 632 | } |
633 | if ( ait == end() ) | 633 | if ( ait == end() ) |
634 | qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); | 634 | qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); |
635 | } | 635 | } |
636 | clear(); | 636 | clear(); |
637 | for ( it = list.begin(); it != list.end(); ++it ) { | 637 | for ( it = list.begin(); it != list.end(); ++it ) { |
638 | insertAddressee( (*it) ); | 638 | insertAddressee( (*it) ); |
639 | } | 639 | } |
640 | } | 640 | } |
641 | 641 | ||
642 | bool AddressBook::saveABphone( QString fileName ) | 642 | bool AddressBook::saveABphone( QString fileName ) |
643 | { | 643 | { |
644 | //smplifyAddressees(); | 644 | //smplifyAddressees(); |
645 | qDebug("saveABphone:: saving AB... "); | 645 | qDebug("saveABphone:: saving AB... "); |
646 | if ( ! export2PhoneFormat( QStringList() ,fileName ) ) | 646 | if ( ! export2PhoneFormat( QStringList() ,fileName ) ) |
647 | return false; | 647 | return false; |
648 | qDebug("saveABphone:: writing to phone... "); | 648 | qDebug("saveABphone:: writing to phone... "); |
649 | if ( !PhoneAccess::writeToPhone( fileName) ) { | 649 | if ( !PhoneAccess::writeToPhone( fileName) ) { |
650 | return false; | 650 | return false; |
651 | } | 651 | } |
652 | qDebug("saveABphone:: re-reading from phone... "); | 652 | qDebug("saveABphone:: re-reading from phone... "); |
653 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 653 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
654 | return false; | 654 | return false; |
655 | } | 655 | } |
656 | return true; | 656 | return true; |
657 | } | 657 | } |
658 | bool AddressBook::saveAB() | 658 | bool AddressBook::saveAB() |
659 | { | 659 | { |
660 | bool ok = true; | 660 | bool ok = true; |
661 | 661 | ||
662 | deleteRemovedAddressees(); | 662 | deleteRemovedAddressees(); |
663 | Iterator ait; | 663 | Iterator ait; |
664 | for ( ait = begin(); ait != end(); ++ait ) { | 664 | for ( ait = begin(); ait != end(); ++ait ) { |
665 | if ( !(*ait).IDStr().isEmpty() ) { | 665 | if ( !(*ait).IDStr().isEmpty() ) { |
666 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | 666 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); |
667 | } | 667 | } |
668 | } | 668 | } |
669 | KRES::Manager<Resource>::ActiveIterator it; | 669 | KRES::Manager<Resource>::ActiveIterator it; |
670 | KRES::Manager<Resource> *manager = d->mManager; | 670 | KRES::Manager<Resource> *manager = d->mManager; |
671 | qDebug("SaveAB::saving..." ); | 671 | qDebug("SaveAB::saving..." ); |
672 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 672 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
673 | qDebug("SaveAB::checking resource..." ); | 673 | qDebug("SaveAB::checking resource..." ); |
674 | if ( (*it)->readOnly() ) | 674 | if ( (*it)->readOnly() ) |
675 | qDebug("resource is readonly." ); | 675 | qDebug("resource is readonly." ); |
676 | if ( (*it)->isOpen() ) | 676 | if ( (*it)->isOpen() ) |
677 | qDebug("resource is open" ); | 677 | qDebug("resource is open" ); |
678 | 678 | ||
679 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 679 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
680 | Ticket *ticket = requestSaveTicket( *it ); | 680 | Ticket *ticket = requestSaveTicket( *it ); |
681 | qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 681 | qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
682 | if ( !ticket ) { | 682 | if ( !ticket ) { |
683 | qDebug( i18n( "Unable to save to resource '%1'. It is locked." ) | 683 | qDebug( i18n( "Unable to save to resource '%1'. It is locked." ) |
684 | .arg( (*it)->resourceName() ) ); | 684 | .arg( (*it)->resourceName() ) ); |
685 | return false; | 685 | return false; |
686 | } | 686 | } |
687 | 687 | ||
688 | //if ( !save( ticket ) ) | 688 | //if ( !save( ticket ) ) |
689 | if ( ticket->resource() ) { | 689 | if ( ticket->resource() ) { |
690 | QString name = ticket->resource()->resourceName(); | 690 | QString name = ticket->resource()->resourceName(); |
691 | if ( ! ticket->resource()->save( ticket ) ) | 691 | if ( ! ticket->resource()->save( ticket ) ) |
692 | ok = false; | 692 | ok = false; |
693 | else | 693 | else |
694 | qDebug("StdAddressBook::resource saved '%s'", name.latin1() ); | 694 | qDebug("StdAddressBook::resource saved '%s'", name.latin1() ); |
695 | 695 | ||
696 | } else | 696 | } else |
697 | ok = false; | 697 | ok = false; |
698 | 698 | ||
699 | } | 699 | } |
700 | } | 700 | } |
701 | return ok; | 701 | return ok; |
702 | } | 702 | } |
703 | 703 | ||
704 | AddressBook::Iterator AddressBook::begin() | 704 | AddressBook::Iterator AddressBook::begin() |
705 | { | 705 | { |
706 | Iterator it = Iterator(); | 706 | Iterator it = Iterator(); |
707 | it.d->mIt = d->mAddressees.begin(); | 707 | it.d->mIt = d->mAddressees.begin(); |
708 | return it; | 708 | return it; |
709 | } | 709 | } |
710 | 710 | ||
711 | AddressBook::ConstIterator AddressBook::begin() const | 711 | AddressBook::ConstIterator AddressBook::begin() const |
712 | { | 712 | { |
713 | ConstIterator it = ConstIterator(); | 713 | ConstIterator it = ConstIterator(); |
714 | it.d->mIt = d->mAddressees.begin(); | 714 | it.d->mIt = d->mAddressees.begin(); |
715 | return it; | 715 | return it; |
716 | } | 716 | } |
717 | 717 | ||
718 | AddressBook::Iterator AddressBook::end() | 718 | AddressBook::Iterator AddressBook::end() |
719 | { | 719 | { |
720 | Iterator it = Iterator(); | 720 | Iterator it = Iterator(); |
721 | it.d->mIt = d->mAddressees.end(); | 721 | it.d->mIt = d->mAddressees.end(); |
722 | return it; | 722 | return it; |
723 | } | 723 | } |
724 | 724 | ||
725 | AddressBook::ConstIterator AddressBook::end() const | 725 | AddressBook::ConstIterator AddressBook::end() const |
726 | { | 726 | { |
727 | ConstIterator it = ConstIterator(); | 727 | ConstIterator it = ConstIterator(); |
728 | it.d->mIt = d->mAddressees.end(); | 728 | it.d->mIt = d->mAddressees.end(); |
729 | return it; | 729 | return it; |
730 | } | 730 | } |
731 | 731 | ||
732 | void AddressBook::clear() | 732 | void AddressBook::clear() |
733 | { | 733 | { |
734 | d->mAddressees.clear(); | 734 | d->mAddressees.clear(); |
735 | } | 735 | } |
736 | 736 | ||
737 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 737 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
738 | { | 738 | { |
739 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 739 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
740 | 740 | ||
741 | if ( !resource ) | 741 | if ( !resource ) |
742 | { | 742 | { |
743 | qDebug("AddressBook::requestSaveTicket no resource" ); | 743 | qDebug("AddressBook::requestSaveTicket no resource" ); |
744 | resource = standardResource(); | 744 | resource = standardResource(); |
745 | } | 745 | } |
746 | 746 | ||
747 | KRES::Manager<Resource>::ActiveIterator it; | 747 | KRES::Manager<Resource>::ActiveIterator it; |
748 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 748 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
749 | if ( (*it) == resource ) { | 749 | if ( (*it) == resource ) { |
750 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 750 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
751 | return 0; | 751 | return 0; |
752 | else | 752 | else |
753 | return (*it)->requestSaveTicket(); | 753 | return (*it)->requestSaveTicket(); |
754 | } | 754 | } |
755 | } | 755 | } |
756 | 756 | ||
757 | return 0; | 757 | return 0; |
758 | } | 758 | } |
759 | //void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); | 759 | //void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); |
760 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) | 760 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) |
761 | { | 761 | { |
762 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { | 762 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { |
763 | //qDebug("block insert "); | 763 | //qDebug("block insert "); |
764 | return; | 764 | return; |
765 | } | 765 | } |
766 | //qDebug("inserting.... %s ",a.uid().latin1() ); | 766 | //qDebug("inserting.... %s ",a.uid().latin1() ); |
767 | bool found = false; | 767 | bool found = false; |
768 | Addressee::List::Iterator it; | 768 | Addressee::List::Iterator it; |
769 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 769 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
770 | if ( a.uid() == (*it).uid() ) { | 770 | if ( a.uid() == (*it).uid() ) { |
771 | 771 | ||
772 | bool changed = false; | 772 | bool changed = false; |
773 | Addressee addr = a; | 773 | Addressee addr = a; |
774 | if ( addr != (*it) ) | 774 | if ( addr != (*it) ) |
775 | changed = true; | 775 | changed = true; |
776 | 776 | ||
777 | if ( takeResource ) { | 777 | if ( takeResource ) { |
778 | Resource * res = (*it).resource(); | 778 | Resource * res = (*it).resource(); |
779 | (*it) = a; | 779 | (*it) = a; |
780 | (*it).setResource( res ); | 780 | (*it).setResource( res ); |
781 | } else { | 781 | } else { |
782 | (*it) = a; | 782 | (*it) = a; |
783 | if ( (*it).resource() == 0 ) | 783 | if ( (*it).resource() == 0 ) |
784 | (*it).setResource( standardResource() ); | 784 | (*it).setResource( standardResource() ); |
785 | } | 785 | } |
786 | if ( changed ) { | 786 | if ( changed ) { |
787 | if ( setRev ) { | 787 | if ( setRev ) { |
788 | (*it).setRevision( QDateTime::currentDateTime() ); | 788 | (*it).setRevision( QDateTime::currentDateTime() ); |
789 | } | 789 | } |
790 | (*it).setChanged( true ); | 790 | (*it).setChanged( true ); |
791 | } | 791 | } |
792 | 792 | ||
793 | found = true; | 793 | found = true; |
794 | } else { | 794 | } else { |
795 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 795 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
796 | QString name = (*it).uid().mid( 19 ); | 796 | QString name = (*it).uid().mid( 19 ); |
797 | Addressee b = a; | 797 | Addressee b = a; |
798 | QString id = b.getID( name ); | 798 | QString id = b.getID( name ); |
799 | if ( ! id.isEmpty() ) { | 799 | if ( ! id.isEmpty() ) { |
800 | QString des = (*it).note(); | 800 | QString des = (*it).note(); |
801 | int startN; | 801 | int startN; |
802 | if( (startN = des.find( id ) ) >= 0 ) { | 802 | if( (startN = des.find( id ) ) >= 0 ) { |
803 | int endN = des.find( ",", startN+1 ); | 803 | int endN = des.find( ",", startN+1 ); |
804 | des = des.left( startN ) + des.mid( endN+1 ); | 804 | des = des.left( startN ) + des.mid( endN+1 ); |
805 | (*it).setNote( des ); | 805 | (*it).setNote( des ); |
806 | } | 806 | } |
807 | } | 807 | } |
808 | } | 808 | } |
809 | } | 809 | } |
810 | } | 810 | } |
811 | if ( found ) | 811 | if ( found ) |
812 | return; | 812 | return; |
813 | 813 | ||
814 | d->mAddressees.append( a ); | 814 | d->mAddressees.append( a ); |
815 | Addressee& addr = d->mAddressees.last(); | 815 | Addressee& addr = d->mAddressees.last(); |
816 | if ( addr.resource() == 0 ) | 816 | if ( addr.resource() == 0 ) |
817 | addr.setResource( standardResource() ); | 817 | addr.setResource( standardResource() ); |
818 | addr.setChanged( true ); | 818 | addr.setChanged( true ); |
819 | } | 819 | } |
820 | 820 | ||
821 | void AddressBook::removeAddressee( const Addressee &a ) | 821 | void AddressBook::removeAddressee( const Addressee &a ) |
822 | { | 822 | { |
823 | Iterator it; | 823 | Iterator it; |
824 | Iterator it2; | 824 | Iterator it2; |
825 | bool found = false; | 825 | bool found = false; |
826 | for ( it = begin(); it != end(); ++it ) { | 826 | for ( it = begin(); it != end(); ++it ) { |
827 | if ( a.uid() == (*it).uid() ) { | 827 | if ( a.uid() == (*it).uid() ) { |
828 | found = true; | 828 | found = true; |
829 | it2 = it; | 829 | it2 = it; |
830 | } else { | 830 | } else { |
831 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 831 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
832 | QString name = (*it).uid().mid( 19 ); | 832 | QString name = (*it).uid().mid( 19 ); |
833 | Addressee b = a; | 833 | Addressee b = a; |
834 | QString id = b.getID( name ); | 834 | QString id = b.getID( name ); |
835 | if ( ! id.isEmpty() ) { | 835 | if ( ! id.isEmpty() ) { |
836 | QString des = (*it).note(); | 836 | QString des = (*it).note(); |
837 | if( des.find( id ) < 0 ) { | 837 | if( des.find( id ) < 0 ) { |
838 | des += id + ","; | 838 | des += id + ","; |
839 | (*it).setNote( des ); | 839 | (*it).setNote( des ); |
840 | } | 840 | } |
841 | } | 841 | } |
842 | } | 842 | } |
843 | 843 | ||
844 | } | 844 | } |
845 | } | 845 | } |
846 | 846 | ||
847 | if ( found ) | 847 | if ( found ) |
848 | removeAddressee( it2 ); | 848 | removeAddressee( it2 ); |
849 | 849 | ||
850 | } | 850 | } |
851 | 851 | ||
852 | void AddressBook::removeSyncAddressees( bool removeDeleted ) | 852 | void AddressBook::removeSyncAddressees( bool removeDeleted ) |
853 | { | 853 | { |
854 | Iterator it = begin(); | 854 | Iterator it = begin(); |
855 | Iterator it2 ; | 855 | Iterator it2 ; |
856 | QDateTime dt ( QDate( 2003,1,1) ); | 856 | QDateTime dt ( QDate( 2003,1,1) ); |
857 | while ( it != end() ) { | 857 | while ( it != end() ) { |
858 | (*it).setRevision( dt ); | 858 | (*it).setRevision( dt ); |
859 | if (( *it).IDStr() != "changed" ) { | 859 | if (( *it).IDStr() != "changed" ) { |
860 | // "changed" is used for tagging changed addressees when syncing with KDE or OL | 860 | // "changed" is used for tagging changed addressees when syncing with KDE or OL |
861 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 861 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
862 | (*it).setIDStr(":"); | 862 | (*it).setIDStr(":"); |
863 | } | 863 | } |
864 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | 864 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { |
865 | it2 = it; | 865 | it2 = it; |
866 | //qDebug("removing %s ",(*it).uid().latin1() ); | 866 | //qDebug("removing %s ",(*it).uid().latin1() ); |
867 | ++it; | 867 | ++it; |
868 | removeAddressee( it2 ); | 868 | removeAddressee( it2 ); |
869 | } else { | 869 | } else { |
870 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 870 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
871 | if ( removeDeleted ) { | 871 | if ( removeDeleted ) { |
872 | // we have no postprocessing in the resource, we have to do it here | 872 | // we have no postprocessing in the resource, we have to do it here |
873 | // we have to compute csum for all, because it could be the first sync | 873 | // we have to compute csum for all, because it could be the first sync |
874 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 874 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
875 | } | 875 | } |
876 | ++it; | 876 | ++it; |
877 | } | 877 | } |
878 | } | 878 | } |
879 | deleteRemovedAddressees(); | 879 | deleteRemovedAddressees(); |
880 | } | 880 | } |
881 | 881 | ||
882 | void AddressBook::removeAddressee( const Iterator &it ) | 882 | void AddressBook::removeAddressee( const Iterator &it ) |
883 | { | 883 | { |
884 | d->mRemovedAddressees.append( (*it) ); | 884 | d->mRemovedAddressees.append( (*it) ); |
885 | d->mAddressees.remove( it.d->mIt ); | 885 | d->mAddressees.remove( it.d->mIt ); |
886 | } | 886 | } |
887 | 887 | ||
888 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 888 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
889 | { | 889 | { |
890 | Iterator it; | 890 | Iterator it; |
891 | for ( it = begin(); it != end(); ++it ) { | 891 | for ( it = begin(); it != end(); ++it ) { |
892 | if ( a.uid() == (*it).uid() ) { | 892 | if ( a.uid() == (*it).uid() ) { |
893 | return it; | 893 | return it; |
894 | } | 894 | } |
895 | } | 895 | } |
896 | return end(); | 896 | return end(); |
897 | } | 897 | } |
898 | 898 | ||
899 | Addressee AddressBook::findByUid( const QString &uid ) | 899 | Addressee AddressBook::findByUid( const QString &uid ) |
900 | { | 900 | { |
901 | Iterator it; | 901 | Iterator it; |
902 | for ( it = begin(); it != end(); ++it ) { | 902 | for ( it = begin(); it != end(); ++it ) { |
903 | if ( uid == (*it).uid() ) { | 903 | if ( uid == (*it).uid() ) { |
904 | return *it; | 904 | return *it; |
905 | } | 905 | } |
906 | } | 906 | } |
907 | return Addressee(); | 907 | return Addressee(); |
908 | } | 908 | } |
909 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) | 909 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) |
910 | { | 910 | { |
911 | //qDebug("AddressBook::preExternSync "); | 911 | //qDebug("AddressBook::preExternSync "); |
912 | AddressBook::Iterator it; | 912 | AddressBook::Iterator it; |
913 | for ( it = begin(); it != end(); ++it ) { | 913 | for ( it = begin(); it != end(); ++it ) { |
914 | (*it).setID( csd, (*it).externalUID() ); | 914 | (*it).setID( csd, (*it).externalUID() ); |
915 | (*it).computeCsum( csd ); | 915 | (*it).computeCsum( csd ); |
916 | } | 916 | } |
917 | mergeAB( aBook ,csd, isSubset ); | 917 | mergeAB( aBook ,csd, isSubset ); |
918 | } | 918 | } |
919 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) | 919 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) |
920 | { | 920 | { |
921 | //qDebug("AddressBook::postExternSync "); | 921 | //qDebug("AddressBook::postExternSync "); |
922 | AddressBook::Iterator it; | 922 | AddressBook::Iterator it; |
923 | int foundEmpty = 0; | ||
923 | for ( it = begin(); it != end(); ++it ) { | 924 | for ( it = begin(); it != end(); ++it ) { |
924 | //qDebug("check uid %s ", (*it).uid().latin1() ); | 925 | //qDebug("check uid %s ", (*it).uid().latin1() ); |
925 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 926 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
926 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || | 927 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || |
927 | (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { | 928 | (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { |
928 | Addressee ad = aBook->findByUid( ( (*it).uid() )); | 929 | Addressee ad = aBook->findByUid( ( (*it).uid() )); |
929 | if ( ad.isEmpty() ) { | 930 | if ( ad.isEmpty() ) { |
930 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); | 931 | ++foundEmpty; |
932 | //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1()); | ||
933 | //qDebug("-- formatted name %s ",(*it).formattedName().latin1() ); | ||
931 | } else { | 934 | } else { |
932 | (*it).setIDStr(":"); | 935 | (*it).setIDStr(":"); |
933 | if ( setID ) { | 936 | if ( setID ) { |
934 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) | 937 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) |
935 | ad.setID( csd, (*it).externalUID() ); | 938 | ad.setID( csd, (*it).externalUID() ); |
936 | } else | 939 | } else |
937 | ad.setID( csd, (*it).uid() ); | 940 | ad.setID( csd, (*it).uid() ); |
938 | (*it).computeCsum( csd ); | 941 | (*it).computeCsum( csd ); |
939 | ad.setCsum( csd, (*it).getCsum( csd ) ); | 942 | ad.setCsum( csd, (*it).getCsum( csd ) ); |
940 | //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); | 943 | //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); |
941 | aBook->insertAddressee( ad , false); | 944 | aBook->insertAddressee( ad , false); |
942 | } | 945 | } |
943 | } | 946 | } |
944 | } | 947 | } |
948 | if ( foundEmpty ) { | ||
949 | qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty ); | ||
950 | } | ||
951 | |||
945 | } | 952 | } |
946 | 953 | ||
947 | bool AddressBook::containsExternalUid( const QString& uid ) | 954 | bool AddressBook::containsExternalUid( const QString& uid ) |
948 | { | 955 | { |
949 | Iterator it; | 956 | Iterator it; |
950 | for ( it = begin(); it != end(); ++it ) { | 957 | for ( it = begin(); it != end(); ++it ) { |
951 | if ( uid == (*it).externalUID( ) ) | 958 | if ( uid == (*it).externalUID( ) ) |
952 | return true; | 959 | return true; |
953 | } | 960 | } |
954 | return false; | 961 | return false; |
955 | } | 962 | } |
956 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) | 963 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) |
957 | { | 964 | { |
958 | Iterator it; | 965 | Iterator it; |
959 | for ( it = begin(); it != end(); ++it ) { | 966 | for ( it = begin(); it != end(); ++it ) { |
960 | if ( uid == (*it).getID( profile ) ) | 967 | if ( uid == (*it).getID( profile ) ) |
961 | return (*it); | 968 | return (*it); |
962 | } | 969 | } |
963 | return Addressee(); | 970 | return Addressee(); |
964 | } | 971 | } |
965 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) | 972 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) |
966 | { | 973 | { |
967 | Iterator it; | 974 | Iterator it; |
968 | Addressee ad; | 975 | Addressee ad; |
969 | for ( it = begin(); it != end(); ++it ) { | 976 | for ( it = begin(); it != end(); ++it ) { |
970 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); | 977 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); |
971 | if ( !ad.isEmpty() ) { | 978 | if ( !ad.isEmpty() ) { |
972 | (*it).mergeContact( ad ,isSubset); | 979 | (*it).mergeContact( ad ,isSubset); |
973 | } | 980 | } |
974 | } | 981 | } |
975 | #if 0 | 982 | #if 0 |
976 | // test only | 983 | // test only |
977 | for ( it = begin(); it != end(); ++it ) { | 984 | for ( it = begin(); it != end(); ++it ) { |
978 | 985 | ||
979 | qDebug("uid %s ", (*it).uid().latin1()); | 986 | qDebug("uid %s ", (*it).uid().latin1()); |
980 | } | 987 | } |
981 | #endif | 988 | #endif |
982 | } | 989 | } |
983 | 990 | ||
984 | #if 0 | 991 | #if 0 |
985 | Addressee::List AddressBook::getExternLastSyncAddressees() | 992 | Addressee::List AddressBook::getExternLastSyncAddressees() |
986 | { | 993 | { |
987 | Addressee::List results; | 994 | Addressee::List results; |
988 | 995 | ||
989 | Iterator it; | 996 | Iterator it; |
990 | for ( it = begin(); it != end(); ++it ) { | 997 | for ( it = begin(); it != end(); ++it ) { |
991 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { | 998 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { |
992 | if ( (*it).familyName().left(4) == "!E: " ) | 999 | if ( (*it).familyName().left(4) == "!E: " ) |
993 | results.append( *it ); | 1000 | results.append( *it ); |
994 | } | 1001 | } |
995 | } | 1002 | } |
996 | 1003 | ||
997 | return results; | 1004 | return results; |
998 | } | 1005 | } |
999 | #endif | 1006 | #endif |
1000 | void AddressBook::resetTempSyncStat() | 1007 | void AddressBook::resetTempSyncStat() |
1001 | { | 1008 | { |
1002 | Iterator it; | 1009 | Iterator it; |
1003 | for ( it = begin(); it != end(); ++it ) { | 1010 | for ( it = begin(); it != end(); ++it ) { |
1004 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | 1011 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); |
1005 | } | 1012 | } |
1006 | 1013 | ||
1007 | } | 1014 | } |
1008 | 1015 | ||
1009 | QStringList AddressBook:: uidList() | 1016 | QStringList AddressBook:: uidList() |
1010 | { | 1017 | { |
1011 | QStringList results; | 1018 | QStringList results; |
1012 | Iterator it; | 1019 | Iterator it; |
1013 | for ( it = begin(); it != end(); ++it ) { | 1020 | for ( it = begin(); it != end(); ++it ) { |
1014 | results.append( (*it).uid() ); | 1021 | results.append( (*it).uid() ); |
1015 | } | 1022 | } |
1016 | return results; | 1023 | return results; |
1017 | } | 1024 | } |
1018 | 1025 | ||
1019 | 1026 | ||
1020 | Addressee::List AddressBook::allAddressees() | 1027 | Addressee::List AddressBook::allAddressees() |
1021 | { | 1028 | { |
1022 | return d->mAddressees; | 1029 | return d->mAddressees; |
1023 | 1030 | ||
1024 | } | 1031 | } |
1025 | 1032 | ||
1026 | Addressee::List AddressBook::findByName( const QString &name ) | 1033 | Addressee::List AddressBook::findByName( const QString &name ) |
1027 | { | 1034 | { |
1028 | Addressee::List results; | 1035 | Addressee::List results; |
1029 | 1036 | ||
1030 | Iterator it; | 1037 | Iterator it; |
1031 | for ( it = begin(); it != end(); ++it ) { | 1038 | for ( it = begin(); it != end(); ++it ) { |
1032 | if ( name == (*it).realName() ) { | 1039 | if ( name == (*it).realName() ) { |
1033 | results.append( *it ); | 1040 | results.append( *it ); |
1034 | } | 1041 | } |
1035 | } | 1042 | } |
1036 | 1043 | ||
1037 | return results; | 1044 | return results; |
1038 | } | 1045 | } |
1039 | 1046 | ||
1040 | Addressee::List AddressBook::findByEmail( const QString &email ) | 1047 | Addressee::List AddressBook::findByEmail( const QString &email ) |
1041 | { | 1048 | { |
1042 | Addressee::List results; | 1049 | Addressee::List results; |
1043 | QStringList mailList; | 1050 | QStringList mailList; |
1044 | 1051 | ||
1045 | Iterator it; | 1052 | Iterator it; |
1046 | for ( it = begin(); it != end(); ++it ) { | 1053 | for ( it = begin(); it != end(); ++it ) { |
1047 | mailList = (*it).emails(); | 1054 | mailList = (*it).emails(); |
1048 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { | 1055 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { |
1049 | if ( email == (*ite) ) { | 1056 | if ( email == (*ite) ) { |
1050 | results.append( *it ); | 1057 | results.append( *it ); |
1051 | } | 1058 | } |
1052 | } | 1059 | } |
1053 | } | 1060 | } |
1054 | 1061 | ||
1055 | return results; | 1062 | return results; |
1056 | } | 1063 | } |
1057 | 1064 | ||
1058 | Addressee::List AddressBook::findByCategory( const QString &category ) | 1065 | Addressee::List AddressBook::findByCategory( const QString &category ) |
1059 | { | 1066 | { |
1060 | Addressee::List results; | 1067 | Addressee::List results; |
1061 | 1068 | ||
1062 | Iterator it; | 1069 | Iterator it; |
1063 | for ( it = begin(); it != end(); ++it ) { | 1070 | for ( it = begin(); it != end(); ++it ) { |
1064 | if ( (*it).hasCategory( category) ) { | 1071 | if ( (*it).hasCategory( category) ) { |
1065 | results.append( *it ); | 1072 | results.append( *it ); |
1066 | } | 1073 | } |
1067 | } | 1074 | } |
1068 | 1075 | ||
1069 | return results; | 1076 | return results; |
1070 | } | 1077 | } |
1071 | 1078 | ||
1072 | void AddressBook::dump() const | 1079 | void AddressBook::dump() const |
1073 | { | 1080 | { |
1074 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; | 1081 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; |
1075 | 1082 | ||
1076 | ConstIterator it; | 1083 | ConstIterator it; |
1077 | for( it = begin(); it != end(); ++it ) { | 1084 | for( it = begin(); it != end(); ++it ) { |
1078 | (*it).dump(); | 1085 | (*it).dump(); |
1079 | } | 1086 | } |
1080 | 1087 | ||
1081 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; | 1088 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; |
1082 | } | 1089 | } |
1083 | 1090 | ||
1084 | QString AddressBook::identifier() | 1091 | QString AddressBook::identifier() |
1085 | { | 1092 | { |
1086 | QStringList identifier; | 1093 | QStringList identifier; |
1087 | 1094 | ||
1088 | 1095 | ||
1089 | KRES::Manager<Resource>::ActiveIterator it; | 1096 | KRES::Manager<Resource>::ActiveIterator it; |
1090 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 1097 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
1091 | if ( !(*it)->identifier().isEmpty() ) | 1098 | if ( !(*it)->identifier().isEmpty() ) |
1092 | identifier.append( (*it)->identifier() ); | 1099 | identifier.append( (*it)->identifier() ); |
1093 | } | 1100 | } |
1094 | 1101 | ||
1095 | return identifier.join( ":" ); | 1102 | return identifier.join( ":" ); |
1096 | } | 1103 | } |
1097 | 1104 | ||
1098 | Field::List AddressBook::fields( int category ) | 1105 | Field::List AddressBook::fields( int category ) |
1099 | { | 1106 | { |
1100 | if ( d->mAllFields.isEmpty() ) { | 1107 | if ( d->mAllFields.isEmpty() ) { |
1101 | d->mAllFields = Field::allFields(); | 1108 | d->mAllFields = Field::allFields(); |
1102 | } | 1109 | } |
1103 | 1110 | ||
1104 | if ( category == Field::All ) return d->mAllFields; | 1111 | if ( category == Field::All ) return d->mAllFields; |
1105 | 1112 | ||
1106 | Field::List result; | 1113 | Field::List result; |
1107 | Field::List::ConstIterator it; | 1114 | Field::List::ConstIterator it; |
1108 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { | 1115 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { |
1109 | if ( (*it)->category() & category ) result.append( *it ); | 1116 | if ( (*it)->category() & category ) result.append( *it ); |
1110 | } | 1117 | } |
1111 | 1118 | ||
1112 | return result; | 1119 | return result; |
1113 | } | 1120 | } |
1114 | 1121 | ||
1115 | bool AddressBook::addCustomField( const QString &label, int category, | 1122 | bool AddressBook::addCustomField( const QString &label, int category, |
1116 | const QString &key, const QString &app ) | 1123 | const QString &key, const QString &app ) |
1117 | { | 1124 | { |
1118 | if ( d->mAllFields.isEmpty() ) { | 1125 | if ( d->mAllFields.isEmpty() ) { |
1119 | d->mAllFields = Field::allFields(); | 1126 | d->mAllFields = Field::allFields(); |
1120 | } | 1127 | } |
1121 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; | 1128 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; |
1122 | QString a = app.isNull() ? KGlobal::getAppName() : app; | 1129 | QString a = app.isNull() ? KGlobal::getAppName() : app; |
1123 | 1130 | ||
1124 | QString k = key.isNull() ? label : key; | 1131 | QString k = key.isNull() ? label : key; |
1125 | 1132 | ||
1126 | Field *field = Field::createCustomField( label, category, k, a ); | 1133 | Field *field = Field::createCustomField( label, category, k, a ); |
1127 | 1134 | ||
1128 | if ( !field ) return false; | 1135 | if ( !field ) return false; |
1129 | 1136 | ||
1130 | d->mAllFields.append( field ); | 1137 | d->mAllFields.append( field ); |
1131 | 1138 | ||
1132 | return true; | 1139 | return true; |
1133 | } | 1140 | } |
1134 | 1141 | ||
1135 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) | 1142 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) |
1136 | { | 1143 | { |
1137 | if (!ab.d) return s; | 1144 | if (!ab.d) return s; |
1138 | 1145 | ||
1139 | return s << ab.d->mAddressees; | 1146 | return s << ab.d->mAddressees; |
1140 | } | 1147 | } |
1141 | 1148 | ||
1142 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) | 1149 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) |
1143 | { | 1150 | { |
1144 | if (!ab.d) return s; | 1151 | if (!ab.d) return s; |
1145 | 1152 | ||
1146 | s >> ab.d->mAddressees; | 1153 | s >> ab.d->mAddressees; |
1147 | 1154 | ||
1148 | return s; | 1155 | return s; |
1149 | } | 1156 | } |
1150 | 1157 | ||
1151 | bool AddressBook::addResource( Resource *resource ) | 1158 | bool AddressBook::addResource( Resource *resource ) |
1152 | { | 1159 | { |
1153 | if ( !resource->open() ) { | 1160 | if ( !resource->open() ) { |
1154 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; | 1161 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; |
1155 | return false; | 1162 | return false; |
1156 | } | 1163 | } |
1157 | 1164 | ||
1158 | resource->setAddressBook( this ); | 1165 | resource->setAddressBook( this ); |
1159 | 1166 | ||
1160 | d->mManager->add( resource ); | 1167 | d->mManager->add( resource ); |
1161 | return true; | 1168 | return true; |
1162 | } | 1169 | } |
1163 | void AddressBook::removeResources() | 1170 | void AddressBook::removeResources() |
1164 | { | 1171 | { |
1165 | //remove all possible resources. This should cleanup the configfile. | 1172 | //remove all possible resources. This should cleanup the configfile. |
1166 | QPtrList<KABC::Resource> mResources = resources(); | 1173 | QPtrList<KABC::Resource> mResources = resources(); |
1167 | 1174 | ||
1168 | QPtrListIterator<KABC::Resource> it(mResources); | 1175 | QPtrListIterator<KABC::Resource> it(mResources); |
1169 | for ( ; it.current(); ++it ) { | 1176 | for ( ; it.current(); ++it ) { |
1170 | KABC::Resource *res = it.current(); | 1177 | KABC::Resource *res = it.current(); |
1171 | removeResource(res); | 1178 | removeResource(res); |
1172 | } | 1179 | } |
1173 | } | 1180 | } |
1174 | 1181 | ||
1175 | bool AddressBook::removeResource( Resource *resource ) | 1182 | bool AddressBook::removeResource( Resource *resource ) |
1176 | { | 1183 | { |
1177 | resource->close(); | 1184 | resource->close(); |
1178 | 1185 | ||
1179 | if ( resource == standardResource() ) | 1186 | if ( resource == standardResource() ) |
1180 | d->mManager->setStandardResource( 0 ); | 1187 | d->mManager->setStandardResource( 0 ); |
1181 | 1188 | ||
1182 | resource->setAddressBook( 0 ); | 1189 | resource->setAddressBook( 0 ); |
1183 | 1190 | ||
1184 | d->mManager->remove( resource ); | 1191 | d->mManager->remove( resource ); |
1185 | return true; | 1192 | return true; |
1186 | } | 1193 | } |
1187 | 1194 | ||
1188 | QPtrList<Resource> AddressBook::resources() | 1195 | QPtrList<Resource> AddressBook::resources() |
1189 | { | 1196 | { |
1190 | QPtrList<Resource> list; | 1197 | QPtrList<Resource> list; |
1191 | 1198 | ||
1192 | // qDebug("AddressBook::resources() 1"); | 1199 | // qDebug("AddressBook::resources() 1"); |
1193 | 1200 | ||
1194 | KRES::Manager<Resource>::ActiveIterator it; | 1201 | KRES::Manager<Resource>::ActiveIterator it; |
1195 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 1202 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
1196 | list.append( *it ); | 1203 | list.append( *it ); |
1197 | 1204 | ||
1198 | return list; | 1205 | return list; |
1199 | } | 1206 | } |
1200 | 1207 | ||
1201 | /*US | 1208 | /*US |
1202 | void AddressBook::setErrorHandler( ErrorHandler *handler ) | 1209 | void AddressBook::setErrorHandler( ErrorHandler *handler ) |
1203 | { | 1210 | { |
1204 | delete d->mErrorHandler; | 1211 | delete d->mErrorHandler; |
1205 | d->mErrorHandler = handler; | 1212 | d->mErrorHandler = handler; |
1206 | } | 1213 | } |
1207 | */ | 1214 | */ |
1208 | 1215 | ||
1209 | void AddressBook::error( const QString& msg ) | 1216 | void AddressBook::error( const QString& msg ) |
1210 | { | 1217 | { |
1211 | /*US | 1218 | /*US |
1212 | if ( !d->mErrorHandler ) // create default error handler | 1219 | if ( !d->mErrorHandler ) // create default error handler |
1213 | d->mErrorHandler = new ConsoleErrorHandler; | 1220 | d->mErrorHandler = new ConsoleErrorHandler; |
1214 | 1221 | ||
1215 | if ( d->mErrorHandler ) | 1222 | if ( d->mErrorHandler ) |
1216 | d->mErrorHandler->error( msg ); | 1223 | d->mErrorHandler->error( msg ); |
1217 | else | 1224 | else |
1218 | kdError(5700) << "no error handler defined" << endl; | 1225 | kdError(5700) << "no error handler defined" << endl; |
1219 | */ | 1226 | */ |
1220 | kdDebug(5700) << "msg" << endl; | 1227 | kdDebug(5700) << "msg" << endl; |
1221 | qDebug(msg); | 1228 | qDebug(msg); |
1222 | } | 1229 | } |
1223 | 1230 | ||
1224 | void AddressBook::deleteRemovedAddressees() | 1231 | void AddressBook::deleteRemovedAddressees() |
1225 | { | 1232 | { |
1226 | Addressee::List::Iterator it; | 1233 | Addressee::List::Iterator it; |
1227 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { | 1234 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { |
1228 | Resource *resource = (*it).resource(); | 1235 | Resource *resource = (*it).resource(); |
1229 | if ( resource && !resource->readOnly() && resource->isOpen() ) | 1236 | if ( resource && !resource->readOnly() && resource->isOpen() ) |
1230 | resource->removeAddressee( *it ); | 1237 | resource->removeAddressee( *it ); |
1231 | } | 1238 | } |
1232 | 1239 | ||
1233 | d->mRemovedAddressees.clear(); | 1240 | d->mRemovedAddressees.clear(); |
1234 | } | 1241 | } |
1235 | 1242 | ||
1236 | void AddressBook::setStandardResource( Resource *resource ) | 1243 | void AddressBook::setStandardResource( Resource *resource ) |
1237 | { | 1244 | { |
1238 | // qDebug("AddressBook::setStandardResource 1"); | 1245 | // qDebug("AddressBook::setStandardResource 1"); |
1239 | d->mManager->setStandardResource( resource ); | 1246 | d->mManager->setStandardResource( resource ); |
1240 | } | 1247 | } |
1241 | 1248 | ||
1242 | Resource *AddressBook::standardResource() | 1249 | Resource *AddressBook::standardResource() |
1243 | { | 1250 | { |
1244 | return d->mManager->standardResource(); | 1251 | return d->mManager->standardResource(); |
1245 | } | 1252 | } |
1246 | 1253 | ||
1247 | KRES::Manager<Resource> *AddressBook::resourceManager() | 1254 | KRES::Manager<Resource> *AddressBook::resourceManager() |
1248 | { | 1255 | { |
1249 | return d->mManager; | 1256 | return d->mManager; |
1250 | } | 1257 | } |
1251 | 1258 | ||
1252 | void AddressBook::cleanUp() | 1259 | void AddressBook::cleanUp() |
1253 | { | 1260 | { |
1254 | KRES::Manager<Resource>::ActiveIterator it; | 1261 | KRES::Manager<Resource>::ActiveIterator it; |
1255 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 1262 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
1256 | if ( !(*it)->readOnly() && (*it)->isOpen() ) | 1263 | if ( !(*it)->readOnly() && (*it)->isOpen() ) |
1257 | (*it)->cleanUp(); | 1264 | (*it)->cleanUp(); |
1258 | } | 1265 | } |
1259 | } | 1266 | } |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 568dfc4..d60cd6b 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,2139 +1,2141 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | 30 | ||
31 | #include <ksharedptr.h> | 31 | #include <ksharedptr.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kidmanager.h> | 35 | #include <kidmanager.h> |
36 | //US | 36 | //US |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | 38 | #include <libkcal/syncdefines.h> |
39 | 39 | ||
40 | //US #include "resource.h" | 40 | //US #include "resource.h" |
41 | #include "addressee.h" | 41 | #include "addressee.h" |
42 | 42 | ||
43 | using namespace KABC; | 43 | using namespace KABC; |
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | static bool matchBinaryPatternA( int value, int pattern ); | 46 | static bool matchBinaryPatternA( int value, int pattern ); |
47 | static bool matchBinaryPatternP( int value, int pattern ); | 47 | static bool matchBinaryPatternP( int value, int pattern ); |
48 | 48 | ||
49 | struct Addressee::AddresseeData : public KShared | 49 | struct Addressee::AddresseeData : public KShared |
50 | { | 50 | { |
51 | QString uid; | 51 | QString uid; |
52 | QString name; | 52 | QString name; |
53 | QString formattedName; | 53 | QString formattedName; |
54 | QString familyName; | 54 | QString familyName; |
55 | QString givenName; | 55 | QString givenName; |
56 | QString additionalName; | 56 | QString additionalName; |
57 | QString prefix; | 57 | QString prefix; |
58 | QString suffix; | 58 | QString suffix; |
59 | QString nickName; | 59 | QString nickName; |
60 | QDateTime birthday; | 60 | QDateTime birthday; |
61 | QString mailer; | 61 | QString mailer; |
62 | TimeZone timeZone; | 62 | TimeZone timeZone; |
63 | Geo geo; | 63 | Geo geo; |
64 | QString title; | 64 | QString title; |
65 | QString role; | 65 | QString role; |
66 | QString organization; | 66 | QString organization; |
67 | QString note; | 67 | QString note; |
68 | QString productId; | 68 | QString productId; |
69 | QDateTime revision; | 69 | QDateTime revision; |
70 | QString sortString; | 70 | QString sortString; |
71 | QString externalUID; | 71 | QString externalUID; |
72 | QString originalExternalUID; | 72 | QString originalExternalUID; |
73 | KURL url; | 73 | KURL url; |
74 | Secrecy secrecy; | 74 | Secrecy secrecy; |
75 | Picture logo; | 75 | Picture logo; |
76 | Picture photo; | 76 | Picture photo; |
77 | Sound sound; | 77 | Sound sound; |
78 | Agent agent; | 78 | Agent agent; |
79 | QString mExternalId; | 79 | QString mExternalId; |
80 | PhoneNumber::List phoneNumbers; | 80 | PhoneNumber::List phoneNumbers; |
81 | Address::List addresses; | 81 | Address::List addresses; |
82 | Key::List keys; | 82 | Key::List keys; |
83 | QStringList emails; | 83 | QStringList emails; |
84 | QStringList categories; | 84 | QStringList categories; |
85 | QStringList custom; | 85 | QStringList custom; |
86 | int mTempSyncStat; | 86 | int mTempSyncStat; |
87 | Resource *resource; | 87 | Resource *resource; |
88 | 88 | ||
89 | bool empty :1; | 89 | bool empty :1; |
90 | bool changed :1; | 90 | bool changed :1; |
91 | bool tagged :1; | 91 | bool tagged :1; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | Addressee::Addressee() | 94 | Addressee::Addressee() |
95 | { | 95 | { |
96 | mData = new AddresseeData; | 96 | mData = new AddresseeData; |
97 | mData->empty = true; | 97 | mData->empty = true; |
98 | mData->changed = false; | 98 | mData->changed = false; |
99 | mData->resource = 0; | 99 | mData->resource = 0; |
100 | mData->mExternalId = ":"; | 100 | mData->mExternalId = ":"; |
101 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 101 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
103 | } | 103 | } |
104 | 104 | ||
105 | Addressee::~Addressee() | 105 | Addressee::~Addressee() |
106 | { | 106 | { |
107 | } | 107 | } |
108 | 108 | ||
109 | Addressee::Addressee( const Addressee &a ) | 109 | Addressee::Addressee( const Addressee &a ) |
110 | { | 110 | { |
111 | mData = a.mData; | 111 | mData = a.mData; |
112 | } | 112 | } |
113 | 113 | ||
114 | Addressee &Addressee::operator=( const Addressee &a ) | 114 | Addressee &Addressee::operator=( const Addressee &a ) |
115 | { | 115 | { |
116 | mData = a.mData; | 116 | mData = a.mData; |
117 | return (*this); | 117 | return (*this); |
118 | } | 118 | } |
119 | 119 | ||
120 | Addressee Addressee::copy() | 120 | Addressee Addressee::copy() |
121 | { | 121 | { |
122 | Addressee a; | 122 | Addressee a; |
123 | *(a.mData) = *mData; | 123 | *(a.mData) = *mData; |
124 | return a; | 124 | return a; |
125 | } | 125 | } |
126 | 126 | ||
127 | void Addressee::detach() | 127 | void Addressee::detach() |
128 | { | 128 | { |
129 | if ( mData.count() == 1 ) return; | 129 | if ( mData.count() == 1 ) return; |
130 | *this = copy(); | 130 | *this = copy(); |
131 | } | 131 | } |
132 | 132 | ||
133 | bool Addressee::operator==( const Addressee &a ) const | 133 | bool Addressee::operator==( const Addressee &a ) const |
134 | { | 134 | { |
135 | if ( uid() != a.uid() ) return false; | 135 | if ( uid() != a.uid() ) return false; |
136 | if ( mData->name != a.mData->name ) return false; | 136 | if ( mData->name != a.mData->name ) return false; |
137 | if ( mData->formattedName != a.mData->formattedName ) return false; | 137 | if ( mData->formattedName != a.mData->formattedName ) return false; |
138 | if ( mData->familyName != a.mData->familyName ) return false; | 138 | if ( mData->familyName != a.mData->familyName ) return false; |
139 | if ( mData->givenName != a.mData->givenName ) return false; | 139 | if ( mData->givenName != a.mData->givenName ) return false; |
140 | if ( mData->additionalName != a.mData->additionalName ) return false; | 140 | if ( mData->additionalName != a.mData->additionalName ) return false; |
141 | if ( mData->prefix != a.mData->prefix ) return false; | 141 | if ( mData->prefix != a.mData->prefix ) return false; |
142 | if ( mData->suffix != a.mData->suffix ) return false; | 142 | if ( mData->suffix != a.mData->suffix ) return false; |
143 | if ( mData->nickName != a.mData->nickName ) return false; | 143 | if ( mData->nickName != a.mData->nickName ) return false; |
144 | if ( mData->birthday != a.mData->birthday ) return false; | 144 | if ( mData->birthday != a.mData->birthday ) return false; |
145 | if ( mData->mailer != a.mData->mailer ) return false; | 145 | if ( mData->mailer != a.mData->mailer ) return false; |
146 | if ( mData->timeZone != a.mData->timeZone ) return false; | 146 | if ( mData->timeZone != a.mData->timeZone ) return false; |
147 | if ( mData->geo != a.mData->geo ) return false; | 147 | if ( mData->geo != a.mData->geo ) return false; |
148 | if ( mData->title != a.mData->title ) return false; | 148 | if ( mData->title != a.mData->title ) return false; |
149 | if ( mData->role != a.mData->role ) return false; | 149 | if ( mData->role != a.mData->role ) return false; |
150 | if ( mData->organization != a.mData->organization ) return false; | 150 | if ( mData->organization != a.mData->organization ) return false; |
151 | if ( mData->note != a.mData->note ) return false; | 151 | if ( mData->note != a.mData->note ) return false; |
152 | if ( mData->productId != a.mData->productId ) return false; | 152 | if ( mData->productId != a.mData->productId ) return false; |
153 | //if ( mData->revision != a.mData->revision ) return false; | 153 | //if ( mData->revision != a.mData->revision ) return false; |
154 | if ( mData->sortString != a.mData->sortString ) return false; | 154 | if ( mData->sortString != a.mData->sortString ) return false; |
155 | if ( mData->secrecy != a.mData->secrecy ) return false; | 155 | if ( mData->secrecy != a.mData->secrecy ) return false; |
156 | if ( mData->logo != a.mData->logo ) return false; | 156 | if ( mData->logo != a.mData->logo ) return false; |
157 | if ( mData->photo != a.mData->photo ) return false; | 157 | if ( mData->photo != a.mData->photo ) return false; |
158 | if ( mData->sound != a.mData->sound ) return false; | 158 | if ( mData->sound != a.mData->sound ) return false; |
159 | if ( mData->agent != a.mData->agent ) return false; | 159 | if ( mData->agent != a.mData->agent ) return false; |
160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
161 | ( mData->url != a.mData->url ) ) return false; | 161 | ( mData->url != a.mData->url ) ) return false; |
162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
163 | if ( mData->addresses != a.mData->addresses ) return false; | 163 | if ( mData->addresses != a.mData->addresses ) return false; |
164 | if ( mData->keys != a.mData->keys ) return false; | 164 | if ( mData->keys != a.mData->keys ) return false; |
165 | if ( mData->emails != a.mData->emails ) return false; | 165 | if ( mData->emails != a.mData->emails ) return false; |
166 | if ( mData->categories != a.mData->categories ) return false; | 166 | if ( mData->categories != a.mData->categories ) return false; |
167 | if ( mData->custom != a.mData->custom ) return false; | 167 | if ( mData->custom != a.mData->custom ) return false; |
168 | 168 | ||
169 | return true; | 169 | return true; |
170 | } | 170 | } |
171 | 171 | ||
172 | bool Addressee::operator!=( const Addressee &a ) const | 172 | bool Addressee::operator!=( const Addressee &a ) const |
173 | { | 173 | { |
174 | return !( a == *this ); | 174 | return !( a == *this ); |
175 | } | 175 | } |
176 | 176 | ||
177 | bool Addressee::isEmpty() const | 177 | bool Addressee::isEmpty() const |
178 | { | 178 | { |
179 | return mData->empty; | 179 | return mData->empty; |
180 | } | 180 | } |
181 | ulong Addressee::getCsum4List( const QStringList & attList) | 181 | ulong Addressee::getCsum4List( const QStringList & attList) |
182 | { | 182 | { |
183 | int max = attList.count(); | 183 | int max = attList.count(); |
184 | ulong cSum = 0; | 184 | ulong cSum = 0; |
185 | int j,k,i; | 185 | int j,k,i; |
186 | int add; | 186 | int add; |
187 | for ( i = 0; i < max ; ++i ) { | 187 | for ( i = 0; i < max ; ++i ) { |
188 | QString s = attList[i]; | 188 | QString s = attList[i]; |
189 | if ( ! s.isEmpty() ){ | 189 | if ( ! s.isEmpty() ){ |
190 | j = s.length(); | 190 | j = s.length(); |
191 | for ( k = 0; k < j; ++k ) { | 191 | for ( k = 0; k < j; ++k ) { |
192 | int mul = k +1; | 192 | int mul = k +1; |
193 | add = s[k].unicode (); | 193 | add = s[k].unicode (); |
194 | if ( k < 16 ) | 194 | if ( k < 16 ) |
195 | mul = mul * mul; | 195 | mul = mul * mul; |
196 | int ii = i+1; | 196 | int ii = i+1; |
197 | add = add * mul *ii*ii*ii; | 197 | add = add * mul *ii*ii*ii; |
198 | cSum += add; | 198 | cSum += add; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | } | 202 | } |
203 | //QString dump = attList.join(","); | 203 | //QString dump = attList.join(","); |
204 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 204 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
205 | 205 | ||
206 | return cSum; | 206 | return cSum; |
207 | 207 | ||
208 | } | 208 | } |
209 | void Addressee::computeCsum(const QString &dev) | 209 | void Addressee::computeCsum(const QString &dev) |
210 | { | 210 | { |
211 | QStringList l; | 211 | QStringList l; |
212 | //if ( !mData->name.isEmpty() ) l.append(mData->name); | 212 | //if ( !mData->name.isEmpty() ) l.append(mData->name); |
213 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 213 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
216 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); | 216 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); |
217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
231 | // if ( !mData->logo.isEmpty() ) l.append( ); | 231 | // if ( !mData->logo.isEmpty() ) l.append( ); |
232 | //if ( !mData->photo.isEmpty() ) l.append( ); | 232 | //if ( !mData->photo.isEmpty() ) l.append( ); |
233 | //if ( !mData->sound.isEmpty() ) l.append( ); | 233 | //if ( !mData->sound.isEmpty() ) l.append( ); |
234 | //if ( !mData->agent.isEmpty() ) l.append( ); | 234 | //if ( !mData->agent.isEmpty() ) l.append( ); |
235 | if ( mData->url.isValid() ) | 235 | if ( mData->url.isValid() ) |
236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); |
237 | KABC::PhoneNumber::List phoneNumbers; | 237 | KABC::PhoneNumber::List phoneNumbers; |
238 | KABC::PhoneNumber::List::Iterator phoneIter; | 238 | KABC::PhoneNumber::List::Iterator phoneIter; |
239 | 239 | ||
240 | QStringList t; | 240 | QStringList t; |
241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
242 | ++phoneIter ) | 242 | ++phoneIter ) |
243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
244 | t.sort(); | 244 | t.sort(); |
245 | uint iii; | 245 | uint iii; |
246 | for ( iii = 0; iii < t.count(); ++iii) | 246 | for ( iii = 0; iii < t.count(); ++iii) |
247 | l.append( t[iii] ); | 247 | l.append( t[iii] ); |
248 | t = mData->emails; | 248 | t = mData->emails; |
249 | t.sort(); | 249 | t.sort(); |
250 | for ( iii = 0; iii < t.count(); ++iii) | 250 | for ( iii = 0; iii < t.count(); ++iii) |
251 | l.append( t[iii] ); | 251 | l.append( t[iii] ); |
252 | t = mData->categories; | 252 | t = mData->categories; |
253 | t.sort(); | 253 | t.sort(); |
254 | for ( iii = 0; iii < t.count(); ++iii) | 254 | for ( iii = 0; iii < t.count(); ++iii) |
255 | l.append( t[iii] ); | 255 | l.append( t[iii] ); |
256 | t = mData->custom; | 256 | t = mData->custom; |
257 | t.sort(); | 257 | t.sort(); |
258 | for ( iii = 0; iii < t.count(); ++iii) | 258 | for ( iii = 0; iii < t.count(); ++iii) |
259 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { | 259 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { |
260 | int find = t[iii].find (':')+1; | 260 | int find = t[iii].find (':')+1; |
261 | //qDebug("lennnn %d %d ", find, t[iii].length()); | 261 | //qDebug("lennnn %d %d ", find, t[iii].length()); |
262 | if ( find < t[iii].length()) | 262 | if ( find < t[iii].length()) |
263 | l.append( t[iii] ); | 263 | l.append( t[iii] ); |
264 | 264 | ||
265 | } | 265 | } |
266 | KABC::Address::List::Iterator addressIter; | 266 | KABC::Address::List::Iterator addressIter; |
267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
268 | ++addressIter ) { | 268 | ++addressIter ) { |
269 | t = (*addressIter).asList(); | 269 | t = (*addressIter).asList(); |
270 | t.sort(); | 270 | t.sort(); |
271 | for ( iii = 0; iii < t.count(); ++iii) | 271 | for ( iii = 0; iii < t.count(); ++iii) |
272 | l.append( t[iii] ); | 272 | l.append( t[iii] ); |
273 | } | 273 | } |
274 | uint cs = getCsum4List(l); | 274 | uint cs = getCsum4List(l); |
275 | |||
275 | #if 0 | 276 | #if 0 |
276 | for ( iii = 0; iii < l.count(); ++iii) | 277 | for ( iii = 0; iii < l.count(); ++iii) |
277 | qDebug("%d***%s***",iii,l[iii].latin1()); | 278 | qDebug("%d***%s***",iii,l[iii].latin1()); |
278 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 279 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
279 | #endif | 280 | #endif |
281 | |||
280 | setCsum( dev, QString::number (cs )); | 282 | setCsum( dev, QString::number (cs )); |
281 | } | 283 | } |
282 | 284 | ||
283 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 285 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
284 | { | 286 | { |
285 | 287 | ||
286 | detach(); | 288 | detach(); |
287 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 289 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
288 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 290 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
289 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 291 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
290 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 292 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
291 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 293 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
292 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 294 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
293 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 295 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
294 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 296 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
295 | if ( !mData->birthday.isValid() ) | 297 | if ( !mData->birthday.isValid() ) |
296 | if ( ad.mData->birthday.isValid()) | 298 | if ( ad.mData->birthday.isValid()) |
297 | mData->birthday = ad.mData->birthday; | 299 | mData->birthday = ad.mData->birthday; |
298 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 300 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
299 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 301 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
300 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 302 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
301 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 303 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
302 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 304 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
303 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 305 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
304 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 306 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
305 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 307 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
306 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 308 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
307 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 309 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
308 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 310 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
309 | QStringList t; | 311 | QStringList t; |
310 | QStringList tAD; | 312 | QStringList tAD; |
311 | uint iii; | 313 | uint iii; |
312 | 314 | ||
313 | // ********** phone numbers | 315 | // ********** phone numbers |
314 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 316 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
315 | PhoneNumber::List::Iterator phoneItAD; | 317 | PhoneNumber::List::Iterator phoneItAD; |
316 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 318 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
317 | bool found = false; | 319 | bool found = false; |
318 | PhoneNumber::List::Iterator it; | 320 | PhoneNumber::List::Iterator it; |
319 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 321 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
320 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 322 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
321 | found = true; | 323 | found = true; |
322 | (*it).setType( ( *phoneItAD ).type() ); | 324 | (*it).setType( ( *phoneItAD ).type() ); |
323 | (*it).setNumber( ( *phoneItAD ).number() ); | 325 | (*it).setNumber( ( *phoneItAD ).number() ); |
324 | break; | 326 | break; |
325 | } | 327 | } |
326 | } | 328 | } |
327 | // if ( isSubSet && ! found ) | 329 | // if ( isSubSet && ! found ) |
328 | if ( ! found ) // LR try this one... | 330 | if ( ! found ) // LR try this one... |
329 | mData->phoneNumbers.append( *phoneItAD ); | 331 | mData->phoneNumbers.append( *phoneItAD ); |
330 | } | 332 | } |
331 | if ( isSubSet ) { | 333 | if ( isSubSet ) { |
332 | // ************* emails; | 334 | // ************* emails; |
333 | t = mData->emails; | 335 | t = mData->emails; |
334 | tAD = ad.mData->emails; | 336 | tAD = ad.mData->emails; |
335 | for ( iii = 0; iii < tAD.count(); ++iii) | 337 | for ( iii = 0; iii < tAD.count(); ++iii) |
336 | if ( !t.contains(tAD[iii] ) ) | 338 | if ( !t.contains(tAD[iii] ) ) |
337 | mData->emails.append( tAD[iii] ); | 339 | mData->emails.append( tAD[iii] ); |
338 | } | 340 | } |
339 | 341 | ||
340 | // ************* categories; | 342 | // ************* categories; |
341 | t = mData->categories; | 343 | t = mData->categories; |
342 | tAD = ad.mData->categories; | 344 | tAD = ad.mData->categories; |
343 | for ( iii = 0; iii < tAD.count(); ++iii) | 345 | for ( iii = 0; iii < tAD.count(); ++iii) |
344 | if ( !t.contains(tAD[iii] ) ) | 346 | if ( !t.contains(tAD[iii] ) ) |
345 | mData->categories.append( tAD[iii] ); | 347 | mData->categories.append( tAD[iii] ); |
346 | QStringList::ConstIterator it; | 348 | QStringList::ConstIterator it; |
347 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 349 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
348 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 350 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
349 | bool found = false; | 351 | bool found = false; |
350 | QStringList::ConstIterator itL; | 352 | QStringList::ConstIterator itL; |
351 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { | 353 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { |
352 | if ( (*itL).startsWith( qualifiedName ) ) { | 354 | if ( (*itL).startsWith( qualifiedName ) ) { |
353 | found = true; | 355 | found = true; |
354 | break; | 356 | break; |
355 | } | 357 | } |
356 | } | 358 | } |
357 | if ( ! found ) { | 359 | if ( ! found ) { |
358 | mData->custom.append( *it ); | 360 | mData->custom.append( *it ); |
359 | } | 361 | } |
360 | } | 362 | } |
361 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | 363 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; |
362 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | 364 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; |
363 | if ( !mData->sound.isIntern() ) { | 365 | if ( !mData->sound.isIntern() ) { |
364 | if ( mData->sound.url().isEmpty() ) { | 366 | if ( mData->sound.url().isEmpty() ) { |
365 | mData->sound = ad.mData->sound; | 367 | mData->sound = ad.mData->sound; |
366 | } | 368 | } |
367 | } | 369 | } |
368 | if ( !mData->agent.isIntern() ) { | 370 | if ( !mData->agent.isIntern() ) { |
369 | if ( mData->agent.url().isEmpty() ) { | 371 | if ( mData->agent.url().isEmpty() ) { |
370 | mData->agent = ad.mData->agent; | 372 | mData->agent = ad.mData->agent; |
371 | } | 373 | } |
372 | } | 374 | } |
373 | { | 375 | { |
374 | Key::List::Iterator itA; | 376 | Key::List::Iterator itA; |
375 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | 377 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { |
376 | bool found = false; | 378 | bool found = false; |
377 | Key::List::Iterator it; | 379 | Key::List::Iterator it; |
378 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 380 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
379 | if ( (*it) == (*itA)) { | 381 | if ( (*it) == (*itA)) { |
380 | found = true; | 382 | found = true; |
381 | break; | 383 | break; |
382 | 384 | ||
383 | } | 385 | } |
384 | } | 386 | } |
385 | if ( ! found ) { | 387 | if ( ! found ) { |
386 | mData->keys.append( *itA ); | 388 | mData->keys.append( *itA ); |
387 | } | 389 | } |
388 | } | 390 | } |
389 | } | 391 | } |
390 | KABC::Address::List::Iterator addressIterA; | 392 | KABC::Address::List::Iterator addressIterA; |
391 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { | 393 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { |
392 | bool found = false; | 394 | bool found = false; |
393 | KABC::Address::List::Iterator addressIter; | 395 | KABC::Address::List::Iterator addressIter; |
394 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 396 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
395 | ++addressIter ) { | 397 | ++addressIter ) { |
396 | if ( (*addressIter) == (*addressIterA)) { | 398 | if ( (*addressIter) == (*addressIterA)) { |
397 | found = true; | 399 | found = true; |
398 | (*addressIter).setType( (*addressIterA).type() ); | 400 | (*addressIter).setType( (*addressIterA).type() ); |
399 | break; | 401 | break; |
400 | } | 402 | } |
401 | 403 | ||
402 | } | 404 | } |
403 | if ( isSubSet && ! found ) { | 405 | if ( isSubSet && ! found ) { |
404 | mData->addresses.append( *addressIterA ); | 406 | mData->addresses.append( *addressIterA ); |
405 | } | 407 | } |
406 | } | 408 | } |
407 | //qDebug("merge contact %s ", ad.uid().latin1()); | 409 | //qDebug("merge contact %s ", ad.uid().latin1()); |
408 | setUid( ad.uid() ); | 410 | setUid( ad.uid() ); |
409 | setRevision( ad.revision() ); | 411 | setRevision( ad.revision() ); |
410 | } | 412 | } |
411 | 413 | ||
412 | bool Addressee::removeVoice() | 414 | bool Addressee::removeVoice() |
413 | { | 415 | { |
414 | PhoneNumber::List phoneN = phoneNumbers(); | 416 | PhoneNumber::List phoneN = phoneNumbers(); |
415 | PhoneNumber::List::Iterator phoneIt; | 417 | PhoneNumber::List::Iterator phoneIt; |
416 | bool found = false; | 418 | bool found = false; |
417 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 419 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
418 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 420 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
419 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 421 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
420 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 422 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
421 | insertPhoneNumber( (*phoneIt) ); | 423 | insertPhoneNumber( (*phoneIt) ); |
422 | found = true; | 424 | found = true; |
423 | } | 425 | } |
424 | } | 426 | } |
425 | 427 | ||
426 | } | 428 | } |
427 | return found; | 429 | return found; |
428 | } | 430 | } |
429 | 431 | ||
430 | bool Addressee::containsAdr(const Addressee& ad ) | 432 | bool Addressee::containsAdr(const Addressee& ad ) |
431 | { | 433 | { |
432 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; | 434 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; |
433 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; | 435 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; |
434 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; | 436 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; |
435 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; | 437 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; |
436 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; | 438 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; |
437 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; | 439 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; |
438 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; | 440 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; |
439 | 441 | ||
440 | // compare phone numbers | 442 | // compare phone numbers |
441 | PhoneNumber::List phoneN = ad.phoneNumbers(); | 443 | PhoneNumber::List phoneN = ad.phoneNumbers(); |
442 | PhoneNumber::List::Iterator phoneIt; | 444 | PhoneNumber::List::Iterator phoneIt; |
443 | bool found = false; | 445 | bool found = false; |
444 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 446 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
445 | bool found = false; | 447 | bool found = false; |
446 | PhoneNumber::List phoneL = ad.phoneNumbers(); | 448 | PhoneNumber::List phoneL = ad.phoneNumbers(); |
447 | PhoneNumber::List::Iterator phoneItL; | 449 | PhoneNumber::List::Iterator phoneItL; |
448 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { | 450 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { |
449 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { | 451 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { |
450 | found = true; | 452 | found = true; |
451 | break; | 453 | break; |
452 | } | 454 | } |
453 | } | 455 | } |
454 | if ( ! found ) | 456 | if ( ! found ) |
455 | return false; | 457 | return false; |
456 | } | 458 | } |
457 | return true; | 459 | return true; |
458 | 460 | ||
459 | } | 461 | } |
460 | void Addressee::simplifyAddresses() | 462 | void Addressee::simplifyAddresses() |
461 | { | 463 | { |
462 | 464 | ||
463 | 465 | ||
464 | Address::List list; | 466 | Address::List list; |
465 | Address::List::Iterator it; | 467 | Address::List::Iterator it; |
466 | Address::List::Iterator it2; | 468 | Address::List::Iterator it2; |
467 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 469 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
468 | it2 = it; | 470 | it2 = it; |
469 | ++it2; | 471 | ++it2; |
470 | for( ; it2 != mData->addresses.end(); ++it2 ) { | 472 | for( ; it2 != mData->addresses.end(); ++it2 ) { |
471 | if ( (*it) == (*it2) ) { | 473 | if ( (*it) == (*it2) ) { |
472 | list.append( *it ); | 474 | list.append( *it ); |
473 | break; | 475 | break; |
474 | } | 476 | } |
475 | } | 477 | } |
476 | } | 478 | } |
477 | for( it = list.begin(); it != list.end(); ++it ) { | 479 | for( it = list.begin(); it != list.end(); ++it ) { |
478 | removeAddress( (*it) ); | 480 | removeAddress( (*it) ); |
479 | } | 481 | } |
480 | 482 | ||
481 | list.clear(); | 483 | list.clear(); |
482 | int max = 2; | 484 | int max = 2; |
483 | if ( mData->url.isValid() ) | 485 | if ( mData->url.isValid() ) |
484 | max = 1; | 486 | max = 1; |
485 | if ( mData->addresses.count() <= max ) return ; | 487 | if ( mData->addresses.count() <= max ) return ; |
486 | int count = 0; | 488 | int count = 0; |
487 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 489 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
488 | if ( count >= max ) | 490 | if ( count >= max ) |
489 | list.append( *it ); | 491 | list.append( *it ); |
490 | ++count; | 492 | ++count; |
491 | } | 493 | } |
492 | for( it = list.begin(); it != list.end(); ++it ) { | 494 | for( it = list.begin(); it != list.end(); ++it ) { |
493 | removeAddress( (*it) ); | 495 | removeAddress( (*it) ); |
494 | } | 496 | } |
495 | } | 497 | } |
496 | 498 | ||
497 | // removes all emails but the first | 499 | // removes all emails but the first |
498 | // needed by phone sync | 500 | // needed by phone sync |
499 | void Addressee::simplifyEmails() | 501 | void Addressee::simplifyEmails() |
500 | { | 502 | { |
501 | if ( mData->emails.count() == 0 ) return ; | 503 | if ( mData->emails.count() == 0 ) return ; |
502 | QString email = mData->emails.first(); | 504 | QString email = mData->emails.first(); |
503 | detach(); | 505 | detach(); |
504 | mData->emails.clear(); | 506 | mData->emails.clear(); |
505 | mData->emails.append( email ); | 507 | mData->emails.append( email ); |
506 | } | 508 | } |
507 | 509 | ||
508 | void Addressee::simplifyPhoneNumbers() | 510 | void Addressee::simplifyPhoneNumbers() |
509 | { | 511 | { |
510 | int max = 4; | 512 | int max = 4; |
511 | int inList = mData->phoneNumbers.count(); | 513 | int inList = mData->phoneNumbers.count(); |
512 | KABC::PhoneNumber::List removeNumbers; | 514 | KABC::PhoneNumber::List removeNumbers; |
513 | KABC::PhoneNumber::List::Iterator phoneIter; | 515 | KABC::PhoneNumber::List::Iterator phoneIter; |
514 | if ( inList > max ) { | 516 | if ( inList > max ) { |
515 | // delete non-preferred numbers | 517 | // delete non-preferred numbers |
516 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 518 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
517 | ++phoneIter ) { | 519 | ++phoneIter ) { |
518 | if ( inList > max ) { | 520 | if ( inList > max ) { |
519 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { | 521 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { |
520 | removeNumbers.append( ( *phoneIter ) ); | 522 | removeNumbers.append( ( *phoneIter ) ); |
521 | --inList; | 523 | --inList; |
522 | } | 524 | } |
523 | } else | 525 | } else |
524 | break; | 526 | break; |
525 | } | 527 | } |
526 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 528 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
527 | ++phoneIter ) { | 529 | ++phoneIter ) { |
528 | removePhoneNumber(( *phoneIter )); | 530 | removePhoneNumber(( *phoneIter )); |
529 | } | 531 | } |
530 | // delete preferred numbers | 532 | // delete preferred numbers |
531 | if ( inList > max ) { | 533 | if ( inList > max ) { |
532 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 534 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
533 | ++phoneIter ) { | 535 | ++phoneIter ) { |
534 | if ( inList > max ) { | 536 | if ( inList > max ) { |
535 | removeNumbers.append( ( *phoneIter ) ); | 537 | removeNumbers.append( ( *phoneIter ) ); |
536 | --inList; | 538 | --inList; |
537 | } else | 539 | } else |
538 | break; | 540 | break; |
539 | } | 541 | } |
540 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 542 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
541 | ++phoneIter ) { | 543 | ++phoneIter ) { |
542 | removePhoneNumber(( *phoneIter )); | 544 | removePhoneNumber(( *phoneIter )); |
543 | } | 545 | } |
544 | } | 546 | } |
545 | } | 547 | } |
546 | // remove non-numeric characters | 548 | // remove non-numeric characters |
547 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 549 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
548 | ++phoneIter ) { | 550 | ++phoneIter ) { |
549 | if ( ! ( *phoneIter ).simplifyNumber() ) | 551 | if ( ! ( *phoneIter ).simplifyNumber() ) |
550 | removeNumbers.append( ( *phoneIter ) ); | 552 | removeNumbers.append( ( *phoneIter ) ); |
551 | } | 553 | } |
552 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 554 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
553 | ++phoneIter ) { | 555 | ++phoneIter ) { |
554 | removePhoneNumber(( *phoneIter )); | 556 | removePhoneNumber(( *phoneIter )); |
555 | } | 557 | } |
556 | } | 558 | } |
557 | void Addressee::simplifyPhoneNumberTypes() | 559 | void Addressee::simplifyPhoneNumberTypes() |
558 | { | 560 | { |
559 | KABC::PhoneNumber::List::Iterator phoneIter; | 561 | KABC::PhoneNumber::List::Iterator phoneIter; |
560 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 562 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
561 | ++phoneIter ) | 563 | ++phoneIter ) |
562 | ( *phoneIter ).simplifyType(); | 564 | ( *phoneIter ).simplifyType(); |
563 | } | 565 | } |
564 | void Addressee::removeID(const QString &prof) | 566 | void Addressee::removeID(const QString &prof) |
565 | { | 567 | { |
566 | detach(); | 568 | detach(); |
567 | if ( prof.isEmpty() ) | 569 | if ( prof.isEmpty() ) |
568 | mData->mExternalId = ":"; | 570 | mData->mExternalId = ":"; |
569 | else | 571 | else |
570 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 572 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
571 | 573 | ||
572 | } | 574 | } |
573 | void Addressee::setID( const QString & prof , const QString & id ) | 575 | void Addressee::setID( const QString & prof , const QString & id ) |
574 | { | 576 | { |
575 | detach(); | 577 | detach(); |
576 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 578 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
577 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 579 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
578 | } | 580 | } |
579 | void Addressee::setTempSyncStat( int id ) | 581 | void Addressee::setTempSyncStat( int id ) |
580 | { | 582 | { |
581 | if ( mData->mTempSyncStat == id ) return; | 583 | if ( mData->mTempSyncStat == id ) return; |
582 | detach(); | 584 | detach(); |
583 | mData->mTempSyncStat = id; | 585 | mData->mTempSyncStat = id; |
584 | } | 586 | } |
585 | int Addressee::tempSyncStat() const | 587 | int Addressee::tempSyncStat() const |
586 | { | 588 | { |
587 | return mData->mTempSyncStat; | 589 | return mData->mTempSyncStat; |
588 | } | 590 | } |
589 | 591 | ||
590 | QString Addressee::getID( const QString & prof) | 592 | QString Addressee::getID( const QString & prof) |
591 | { | 593 | { |
592 | return KIdManager::getId ( mData->mExternalId, prof ); | 594 | return KIdManager::getId ( mData->mExternalId, prof ); |
593 | } | 595 | } |
594 | 596 | ||
595 | void Addressee::setCsum( const QString & prof , const QString & id ) | 597 | void Addressee::setCsum( const QString & prof , const QString & id ) |
596 | { | 598 | { |
597 | detach(); | 599 | detach(); |
598 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 600 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
599 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 601 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
600 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 602 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
601 | } | 603 | } |
602 | 604 | ||
603 | QString Addressee::getCsum( const QString & prof) | 605 | QString Addressee::getCsum( const QString & prof) |
604 | { | 606 | { |
605 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 607 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
606 | } | 608 | } |
607 | 609 | ||
608 | void Addressee::setIDStr( const QString & s ) | 610 | void Addressee::setIDStr( const QString & s ) |
609 | { | 611 | { |
610 | detach(); | 612 | detach(); |
611 | mData->mExternalId = s; | 613 | mData->mExternalId = s; |
612 | } | 614 | } |
613 | 615 | ||
614 | QString Addressee::IDStr() const | 616 | QString Addressee::IDStr() const |
615 | { | 617 | { |
616 | return mData->mExternalId; | 618 | return mData->mExternalId; |
617 | } | 619 | } |
618 | 620 | ||
619 | void Addressee::setExternalUID( const QString &id ) | 621 | void Addressee::setExternalUID( const QString &id ) |
620 | { | 622 | { |
621 | if ( id == mData->externalUID ) return; | 623 | if ( id == mData->externalUID ) return; |
622 | detach(); | 624 | detach(); |
623 | mData->empty = false; | 625 | mData->empty = false; |
624 | mData->externalUID = id; | 626 | mData->externalUID = id; |
625 | } | 627 | } |
626 | 628 | ||
627 | QString Addressee::externalUID() const | 629 | QString Addressee::externalUID() const |
628 | { | 630 | { |
629 | return mData->externalUID; | 631 | return mData->externalUID; |
630 | } | 632 | } |
631 | void Addressee::setOriginalExternalUID( const QString &id ) | 633 | void Addressee::setOriginalExternalUID( const QString &id ) |
632 | { | 634 | { |
633 | if ( id == mData->originalExternalUID ) return; | 635 | if ( id == mData->originalExternalUID ) return; |
634 | detach(); | 636 | detach(); |
635 | mData->empty = false; | 637 | mData->empty = false; |
636 | //qDebug("*******Set orig uid %s ", id.latin1()); | 638 | //qDebug("*******Set orig uid %s ", id.latin1()); |
637 | mData->originalExternalUID = id; | 639 | mData->originalExternalUID = id; |
638 | } | 640 | } |
639 | 641 | ||
640 | QString Addressee::originalExternalUID() const | 642 | QString Addressee::originalExternalUID() const |
641 | { | 643 | { |
642 | return mData->originalExternalUID; | 644 | return mData->originalExternalUID; |
643 | } | 645 | } |
644 | 646 | ||
645 | void Addressee::setUid( const QString &id ) | 647 | void Addressee::setUid( const QString &id ) |
646 | { | 648 | { |
647 | if ( id == mData->uid ) return; | 649 | if ( id == mData->uid ) return; |
648 | detach(); | 650 | detach(); |
649 | //qDebug("****setuid %s ", id.latin1()); | 651 | //qDebug("****setuid %s ", id.latin1()); |
650 | mData->empty = false; | 652 | mData->empty = false; |
651 | mData->uid = id; | 653 | mData->uid = id; |
652 | } | 654 | } |
653 | 655 | ||
654 | QString Addressee::uid() const | 656 | QString Addressee::uid() const |
655 | { | 657 | { |
656 | if ( mData->uid.isEmpty() ) | 658 | if ( mData->uid.isEmpty() ) |
657 | mData->uid = KApplication::randomString( 10 ); | 659 | mData->uid = KApplication::randomString( 10 ); |
658 | 660 | ||
659 | return mData->uid; | 661 | return mData->uid; |
660 | } | 662 | } |
661 | 663 | ||
662 | QString Addressee::uidLabel() | 664 | QString Addressee::uidLabel() |
663 | { | 665 | { |
664 | return i18n("Unique Identifier"); | 666 | return i18n("Unique Identifier"); |
665 | } | 667 | } |
666 | 668 | ||
667 | void Addressee::setName( const QString &name ) | 669 | void Addressee::setName( const QString &name ) |
668 | { | 670 | { |
669 | if ( name == mData->name ) return; | 671 | if ( name == mData->name ) return; |
670 | detach(); | 672 | detach(); |
671 | mData->empty = false; | 673 | mData->empty = false; |
672 | mData->name = name; | 674 | mData->name = name; |
673 | } | 675 | } |
674 | 676 | ||
675 | QString Addressee::name() const | 677 | QString Addressee::name() const |
676 | { | 678 | { |
677 | return mData->name; | 679 | return mData->name; |
678 | } | 680 | } |
679 | 681 | ||
680 | QString Addressee::nameLabel() | 682 | QString Addressee::nameLabel() |
681 | { | 683 | { |
682 | return i18n("Name"); | 684 | return i18n("Name"); |
683 | } | 685 | } |
684 | 686 | ||
685 | 687 | ||
686 | void Addressee::setFormattedName( const QString &formattedName ) | 688 | void Addressee::setFormattedName( const QString &formattedName ) |
687 | { | 689 | { |
688 | if ( formattedName == mData->formattedName ) return; | 690 | if ( formattedName == mData->formattedName ) return; |
689 | detach(); | 691 | detach(); |
690 | mData->empty = false; | 692 | mData->empty = false; |
691 | mData->formattedName = formattedName; | 693 | mData->formattedName = formattedName; |
692 | } | 694 | } |
693 | 695 | ||
694 | QString Addressee::formattedName() const | 696 | QString Addressee::formattedName() const |
695 | { | 697 | { |
696 | return mData->formattedName; | 698 | return mData->formattedName; |
697 | } | 699 | } |
698 | 700 | ||
699 | QString Addressee::formattedNameLabel() | 701 | QString Addressee::formattedNameLabel() |
700 | { | 702 | { |
701 | return i18n("Formatted Name"); | 703 | return i18n("Formatted Name"); |
702 | } | 704 | } |
703 | 705 | ||
704 | 706 | ||
705 | void Addressee::setFamilyName( const QString &familyName ) | 707 | void Addressee::setFamilyName( const QString &familyName ) |
706 | { | 708 | { |
707 | if ( familyName == mData->familyName ) return; | 709 | if ( familyName == mData->familyName ) return; |
708 | detach(); | 710 | detach(); |
709 | mData->empty = false; | 711 | mData->empty = false; |
710 | mData->familyName = familyName; | 712 | mData->familyName = familyName; |
711 | } | 713 | } |
712 | 714 | ||
713 | QString Addressee::familyName() const | 715 | QString Addressee::familyName() const |
714 | { | 716 | { |
715 | return mData->familyName; | 717 | return mData->familyName; |
716 | } | 718 | } |
717 | 719 | ||
718 | QString Addressee::familyNameLabel() | 720 | QString Addressee::familyNameLabel() |
719 | { | 721 | { |
720 | return i18n("Family Name"); | 722 | return i18n("Family Name"); |
721 | } | 723 | } |
722 | 724 | ||
723 | 725 | ||
724 | void Addressee::setGivenName( const QString &givenName ) | 726 | void Addressee::setGivenName( const QString &givenName ) |
725 | { | 727 | { |
726 | if ( givenName == mData->givenName ) return; | 728 | if ( givenName == mData->givenName ) return; |
727 | detach(); | 729 | detach(); |
728 | mData->empty = false; | 730 | mData->empty = false; |
729 | mData->givenName = givenName; | 731 | mData->givenName = givenName; |
730 | } | 732 | } |
731 | 733 | ||
732 | QString Addressee::givenName() const | 734 | QString Addressee::givenName() const |
733 | { | 735 | { |
734 | return mData->givenName; | 736 | return mData->givenName; |
735 | } | 737 | } |
736 | 738 | ||
737 | QString Addressee::givenNameLabel() | 739 | QString Addressee::givenNameLabel() |
738 | { | 740 | { |
739 | return i18n("Given Name"); | 741 | return i18n("Given Name"); |
740 | } | 742 | } |
741 | 743 | ||
742 | 744 | ||
743 | void Addressee::setAdditionalName( const QString &additionalName ) | 745 | void Addressee::setAdditionalName( const QString &additionalName ) |
744 | { | 746 | { |
745 | if ( additionalName == mData->additionalName ) return; | 747 | if ( additionalName == mData->additionalName ) return; |
746 | detach(); | 748 | detach(); |
747 | mData->empty = false; | 749 | mData->empty = false; |
748 | mData->additionalName = additionalName; | 750 | mData->additionalName = additionalName; |
749 | } | 751 | } |
750 | 752 | ||
751 | QString Addressee::additionalName() const | 753 | QString Addressee::additionalName() const |
752 | { | 754 | { |
753 | return mData->additionalName; | 755 | return mData->additionalName; |
754 | } | 756 | } |
755 | 757 | ||
756 | QString Addressee::additionalNameLabel() | 758 | QString Addressee::additionalNameLabel() |
757 | { | 759 | { |
758 | return i18n("Additional Names"); | 760 | return i18n("Additional Names"); |
759 | } | 761 | } |
760 | 762 | ||
761 | 763 | ||
762 | void Addressee::setPrefix( const QString &prefix ) | 764 | void Addressee::setPrefix( const QString &prefix ) |
763 | { | 765 | { |
764 | if ( prefix == mData->prefix ) return; | 766 | if ( prefix == mData->prefix ) return; |
765 | detach(); | 767 | detach(); |
766 | mData->empty = false; | 768 | mData->empty = false; |
767 | mData->prefix = prefix; | 769 | mData->prefix = prefix; |
768 | } | 770 | } |
769 | 771 | ||
770 | QString Addressee::prefix() const | 772 | QString Addressee::prefix() const |
771 | { | 773 | { |
772 | return mData->prefix; | 774 | return mData->prefix; |
773 | } | 775 | } |
774 | 776 | ||
775 | QString Addressee::prefixLabel() | 777 | QString Addressee::prefixLabel() |
776 | { | 778 | { |
777 | return i18n("Honorific Prefixes"); | 779 | return i18n("Honorific Prefixes"); |
778 | } | 780 | } |
779 | 781 | ||
780 | 782 | ||
781 | void Addressee::setSuffix( const QString &suffix ) | 783 | void Addressee::setSuffix( const QString &suffix ) |
782 | { | 784 | { |
783 | if ( suffix == mData->suffix ) return; | 785 | if ( suffix == mData->suffix ) return; |
784 | detach(); | 786 | detach(); |
785 | mData->empty = false; | 787 | mData->empty = false; |
786 | mData->suffix = suffix; | 788 | mData->suffix = suffix; |
787 | } | 789 | } |
788 | 790 | ||
789 | QString Addressee::suffix() const | 791 | QString Addressee::suffix() const |
790 | { | 792 | { |
791 | return mData->suffix; | 793 | return mData->suffix; |
792 | } | 794 | } |
793 | 795 | ||
794 | QString Addressee::suffixLabel() | 796 | QString Addressee::suffixLabel() |
795 | { | 797 | { |
796 | return i18n("Honorific Suffixes"); | 798 | return i18n("Honorific Suffixes"); |
797 | } | 799 | } |
798 | 800 | ||
799 | 801 | ||
800 | void Addressee::setNickName( const QString &nickName ) | 802 | void Addressee::setNickName( const QString &nickName ) |
801 | { | 803 | { |
802 | if ( nickName == mData->nickName ) return; | 804 | if ( nickName == mData->nickName ) return; |
803 | detach(); | 805 | detach(); |
804 | mData->empty = false; | 806 | mData->empty = false; |
805 | mData->nickName = nickName; | 807 | mData->nickName = nickName; |
806 | } | 808 | } |
807 | 809 | ||
808 | QString Addressee::nickName() const | 810 | QString Addressee::nickName() const |
809 | { | 811 | { |
810 | return mData->nickName; | 812 | return mData->nickName; |
811 | } | 813 | } |
812 | 814 | ||
813 | QString Addressee::nickNameLabel() | 815 | QString Addressee::nickNameLabel() |
814 | { | 816 | { |
815 | return i18n("Nick Name"); | 817 | return i18n("Nick Name"); |
816 | } | 818 | } |
817 | 819 | ||
818 | 820 | ||
819 | void Addressee::setBirthday( const QDateTime &birthday ) | 821 | void Addressee::setBirthday( const QDateTime &birthday ) |
820 | { | 822 | { |
821 | if ( birthday == mData->birthday ) return; | 823 | if ( birthday == mData->birthday ) return; |
822 | detach(); | 824 | detach(); |
823 | mData->empty = false; | 825 | mData->empty = false; |
824 | mData->birthday = birthday; | 826 | mData->birthday = birthday; |
825 | } | 827 | } |
826 | 828 | ||
827 | QDateTime Addressee::birthday() const | 829 | QDateTime Addressee::birthday() const |
828 | { | 830 | { |
829 | return mData->birthday; | 831 | return mData->birthday; |
830 | } | 832 | } |
831 | 833 | ||
832 | QString Addressee::birthdayLabel() | 834 | QString Addressee::birthdayLabel() |
833 | { | 835 | { |
834 | return i18n("Birthday"); | 836 | return i18n("Birthday"); |
835 | } | 837 | } |
836 | 838 | ||
837 | 839 | ||
838 | QString Addressee::homeAddressStreetLabel() | 840 | QString Addressee::homeAddressStreetLabel() |
839 | { | 841 | { |
840 | return i18n("Home Address Street"); | 842 | return i18n("Home Address Street"); |
841 | } | 843 | } |
842 | 844 | ||
843 | 845 | ||
844 | QString Addressee::homeAddressLocalityLabel() | 846 | QString Addressee::homeAddressLocalityLabel() |
845 | { | 847 | { |
846 | return i18n("Home Address Locality"); | 848 | return i18n("Home Address Locality"); |
847 | } | 849 | } |
848 | 850 | ||
849 | 851 | ||
850 | QString Addressee::homeAddressRegionLabel() | 852 | QString Addressee::homeAddressRegionLabel() |
851 | { | 853 | { |
852 | return i18n("Home Address Region"); | 854 | return i18n("Home Address Region"); |
853 | } | 855 | } |
854 | 856 | ||
855 | 857 | ||
856 | QString Addressee::homeAddressPostalCodeLabel() | 858 | QString Addressee::homeAddressPostalCodeLabel() |
857 | { | 859 | { |
858 | return i18n("Home Address Postal Code"); | 860 | return i18n("Home Address Postal Code"); |
859 | } | 861 | } |
860 | 862 | ||
861 | 863 | ||
862 | QString Addressee::homeAddressCountryLabel() | 864 | QString Addressee::homeAddressCountryLabel() |
863 | { | 865 | { |
864 | return i18n("Home Address Country"); | 866 | return i18n("Home Address Country"); |
865 | } | 867 | } |
866 | 868 | ||
867 | 869 | ||
868 | QString Addressee::homeAddressLabelLabel() | 870 | QString Addressee::homeAddressLabelLabel() |
869 | { | 871 | { |
870 | return i18n("Home Address Label"); | 872 | return i18n("Home Address Label"); |
871 | } | 873 | } |
872 | 874 | ||
873 | 875 | ||
874 | QString Addressee::businessAddressStreetLabel() | 876 | QString Addressee::businessAddressStreetLabel() |
875 | { | 877 | { |
876 | return i18n("Business Address Street"); | 878 | return i18n("Business Address Street"); |
877 | } | 879 | } |
878 | 880 | ||
879 | 881 | ||
880 | QString Addressee::businessAddressLocalityLabel() | 882 | QString Addressee::businessAddressLocalityLabel() |
881 | { | 883 | { |
882 | return i18n("Business Address Locality"); | 884 | return i18n("Business Address Locality"); |
883 | } | 885 | } |
884 | 886 | ||
885 | 887 | ||
886 | QString Addressee::businessAddressRegionLabel() | 888 | QString Addressee::businessAddressRegionLabel() |
887 | { | 889 | { |
888 | return i18n("Business Address Region"); | 890 | return i18n("Business Address Region"); |
889 | } | 891 | } |
890 | 892 | ||
891 | 893 | ||
892 | QString Addressee::businessAddressPostalCodeLabel() | 894 | QString Addressee::businessAddressPostalCodeLabel() |
893 | { | 895 | { |
894 | return i18n("Business Address Postal Code"); | 896 | return i18n("Business Address Postal Code"); |
895 | } | 897 | } |
896 | 898 | ||
897 | 899 | ||
898 | QString Addressee::businessAddressCountryLabel() | 900 | QString Addressee::businessAddressCountryLabel() |
899 | { | 901 | { |
900 | return i18n("Business Address Country"); | 902 | return i18n("Business Address Country"); |
901 | } | 903 | } |
902 | 904 | ||
903 | 905 | ||
904 | QString Addressee::businessAddressLabelLabel() | 906 | QString Addressee::businessAddressLabelLabel() |
905 | { | 907 | { |
906 | return i18n("Business Address Label"); | 908 | return i18n("Business Address Label"); |
907 | } | 909 | } |
908 | 910 | ||
909 | 911 | ||
910 | QString Addressee::homePhoneLabel() | 912 | QString Addressee::homePhoneLabel() |
911 | { | 913 | { |
912 | return i18n("Home Phone"); | 914 | return i18n("Home Phone"); |
913 | } | 915 | } |
914 | 916 | ||
915 | 917 | ||
916 | QString Addressee::businessPhoneLabel() | 918 | QString Addressee::businessPhoneLabel() |
917 | { | 919 | { |
918 | return i18n("Business Phone"); | 920 | return i18n("Business Phone"); |
919 | } | 921 | } |
920 | 922 | ||
921 | 923 | ||
922 | QString Addressee::mobilePhoneLabel() | 924 | QString Addressee::mobilePhoneLabel() |
923 | { | 925 | { |
924 | return i18n("Mobile Phone"); | 926 | return i18n("Mobile Phone"); |
925 | } | 927 | } |
926 | 928 | ||
927 | 929 | ||
928 | QString Addressee::homeFaxLabel() | 930 | QString Addressee::homeFaxLabel() |
929 | { | 931 | { |
930 | return i18n("Home Fax"); | 932 | return i18n("Home Fax"); |
931 | } | 933 | } |
932 | 934 | ||
933 | 935 | ||
934 | QString Addressee::businessFaxLabel() | 936 | QString Addressee::businessFaxLabel() |
935 | { | 937 | { |
936 | return i18n("Business Fax"); | 938 | return i18n("Business Fax"); |
937 | } | 939 | } |
938 | 940 | ||
939 | 941 | ||
940 | QString Addressee::carPhoneLabel() | 942 | QString Addressee::carPhoneLabel() |
941 | { | 943 | { |
942 | return i18n("Car Phone"); | 944 | return i18n("Car Phone"); |
943 | } | 945 | } |
944 | 946 | ||
945 | 947 | ||
946 | QString Addressee::isdnLabel() | 948 | QString Addressee::isdnLabel() |
947 | { | 949 | { |
948 | return i18n("ISDN"); | 950 | return i18n("ISDN"); |
949 | } | 951 | } |
950 | 952 | ||
951 | 953 | ||
952 | QString Addressee::pagerLabel() | 954 | QString Addressee::pagerLabel() |
953 | { | 955 | { |
954 | return i18n("Pager"); | 956 | return i18n("Pager"); |
955 | } | 957 | } |
956 | 958 | ||
957 | QString Addressee::sipLabel() | 959 | QString Addressee::sipLabel() |
958 | { | 960 | { |
959 | return i18n("SIP"); | 961 | return i18n("SIP"); |
960 | } | 962 | } |
961 | 963 | ||
962 | QString Addressee::emailLabel() | 964 | QString Addressee::emailLabel() |
963 | { | 965 | { |
964 | return i18n("Email Address"); | 966 | return i18n("Email Address"); |
965 | } | 967 | } |
966 | 968 | ||
967 | 969 | ||
968 | void Addressee::setMailer( const QString &mailer ) | 970 | void Addressee::setMailer( const QString &mailer ) |
969 | { | 971 | { |
970 | if ( mailer == mData->mailer ) return; | 972 | if ( mailer == mData->mailer ) return; |
971 | detach(); | 973 | detach(); |
972 | mData->empty = false; | 974 | mData->empty = false; |
973 | mData->mailer = mailer; | 975 | mData->mailer = mailer; |
974 | } | 976 | } |
975 | 977 | ||
976 | QString Addressee::mailer() const | 978 | QString Addressee::mailer() const |
977 | { | 979 | { |
978 | return mData->mailer; | 980 | return mData->mailer; |
979 | } | 981 | } |
980 | 982 | ||
981 | QString Addressee::mailerLabel() | 983 | QString Addressee::mailerLabel() |
982 | { | 984 | { |
983 | return i18n("Mail Client"); | 985 | return i18n("Mail Client"); |
984 | } | 986 | } |
985 | 987 | ||
986 | 988 | ||
987 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 989 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
988 | { | 990 | { |
989 | if ( timeZone == mData->timeZone ) return; | 991 | if ( timeZone == mData->timeZone ) return; |
990 | detach(); | 992 | detach(); |
991 | mData->empty = false; | 993 | mData->empty = false; |
992 | mData->timeZone = timeZone; | 994 | mData->timeZone = timeZone; |
993 | } | 995 | } |
994 | 996 | ||
995 | TimeZone Addressee::timeZone() const | 997 | TimeZone Addressee::timeZone() const |
996 | { | 998 | { |
997 | return mData->timeZone; | 999 | return mData->timeZone; |
998 | } | 1000 | } |
999 | 1001 | ||
1000 | QString Addressee::timeZoneLabel() | 1002 | QString Addressee::timeZoneLabel() |
1001 | { | 1003 | { |
1002 | return i18n("Time Zone"); | 1004 | return i18n("Time Zone"); |
1003 | } | 1005 | } |
1004 | 1006 | ||
1005 | 1007 | ||
1006 | void Addressee::setGeo( const Geo &geo ) | 1008 | void Addressee::setGeo( const Geo &geo ) |
1007 | { | 1009 | { |
1008 | if ( geo == mData->geo ) return; | 1010 | if ( geo == mData->geo ) return; |
1009 | detach(); | 1011 | detach(); |
1010 | mData->empty = false; | 1012 | mData->empty = false; |
1011 | mData->geo = geo; | 1013 | mData->geo = geo; |
1012 | } | 1014 | } |
1013 | 1015 | ||
1014 | Geo Addressee::geo() const | 1016 | Geo Addressee::geo() const |
1015 | { | 1017 | { |
1016 | return mData->geo; | 1018 | return mData->geo; |
1017 | } | 1019 | } |
1018 | 1020 | ||
1019 | QString Addressee::geoLabel() | 1021 | QString Addressee::geoLabel() |
1020 | { | 1022 | { |
1021 | return i18n("Geographic Position"); | 1023 | return i18n("Geographic Position"); |
1022 | } | 1024 | } |
1023 | 1025 | ||
1024 | 1026 | ||
1025 | void Addressee::setTitle( const QString &title ) | 1027 | void Addressee::setTitle( const QString &title ) |
1026 | { | 1028 | { |
1027 | if ( title == mData->title ) return; | 1029 | if ( title == mData->title ) return; |
1028 | detach(); | 1030 | detach(); |
1029 | mData->empty = false; | 1031 | mData->empty = false; |
1030 | mData->title = title; | 1032 | mData->title = title; |
1031 | } | 1033 | } |
1032 | 1034 | ||
1033 | QString Addressee::title() const | 1035 | QString Addressee::title() const |
1034 | { | 1036 | { |
1035 | return mData->title; | 1037 | return mData->title; |
1036 | } | 1038 | } |
1037 | 1039 | ||
1038 | QString Addressee::titleLabel() | 1040 | QString Addressee::titleLabel() |
1039 | { | 1041 | { |
1040 | return i18n("Title"); | 1042 | return i18n("Title"); |
1041 | } | 1043 | } |
1042 | 1044 | ||
1043 | 1045 | ||
1044 | void Addressee::setRole( const QString &role ) | 1046 | void Addressee::setRole( const QString &role ) |
1045 | { | 1047 | { |
1046 | if ( role == mData->role ) return; | 1048 | if ( role == mData->role ) return; |
1047 | detach(); | 1049 | detach(); |
1048 | mData->empty = false; | 1050 | mData->empty = false; |
1049 | mData->role = role; | 1051 | mData->role = role; |
1050 | } | 1052 | } |
1051 | 1053 | ||
1052 | QString Addressee::role() const | 1054 | QString Addressee::role() const |
1053 | { | 1055 | { |
1054 | return mData->role; | 1056 | return mData->role; |
1055 | } | 1057 | } |
1056 | 1058 | ||
1057 | QString Addressee::roleLabel() | 1059 | QString Addressee::roleLabel() |
1058 | { | 1060 | { |
1059 | return i18n("Role"); | 1061 | return i18n("Role"); |
1060 | } | 1062 | } |
1061 | 1063 | ||
1062 | 1064 | ||
1063 | void Addressee::setOrganization( const QString &organization ) | 1065 | void Addressee::setOrganization( const QString &organization ) |
1064 | { | 1066 | { |
1065 | if ( organization == mData->organization ) return; | 1067 | if ( organization == mData->organization ) return; |
1066 | detach(); | 1068 | detach(); |
1067 | mData->empty = false; | 1069 | mData->empty = false; |
1068 | mData->organization = organization; | 1070 | mData->organization = organization; |
1069 | } | 1071 | } |
1070 | 1072 | ||
1071 | QString Addressee::organization() const | 1073 | QString Addressee::organization() const |
1072 | { | 1074 | { |
1073 | return mData->organization; | 1075 | return mData->organization; |
1074 | } | 1076 | } |
1075 | 1077 | ||
1076 | QString Addressee::organizationLabel() | 1078 | QString Addressee::organizationLabel() |
1077 | { | 1079 | { |
1078 | return i18n("Organization"); | 1080 | return i18n("Organization"); |
1079 | } | 1081 | } |
1080 | 1082 | ||
1081 | 1083 | ||
1082 | void Addressee::setNote( const QString ¬e ) | 1084 | void Addressee::setNote( const QString ¬e ) |
1083 | { | 1085 | { |
1084 | if ( note == mData->note ) return; | 1086 | if ( note == mData->note ) return; |
1085 | detach(); | 1087 | detach(); |
1086 | mData->empty = false; | 1088 | mData->empty = false; |
1087 | mData->note = note; | 1089 | mData->note = note; |
1088 | } | 1090 | } |
1089 | 1091 | ||
1090 | QString Addressee::note() const | 1092 | QString Addressee::note() const |
1091 | { | 1093 | { |
1092 | return mData->note; | 1094 | return mData->note; |
1093 | } | 1095 | } |
1094 | 1096 | ||
1095 | QString Addressee::noteLabel() | 1097 | QString Addressee::noteLabel() |
1096 | { | 1098 | { |
1097 | return i18n("Note"); | 1099 | return i18n("Note"); |
1098 | } | 1100 | } |
1099 | 1101 | ||
1100 | 1102 | ||
1101 | void Addressee::setProductId( const QString &productId ) | 1103 | void Addressee::setProductId( const QString &productId ) |
1102 | { | 1104 | { |
1103 | if ( productId == mData->productId ) return; | 1105 | if ( productId == mData->productId ) return; |
1104 | detach(); | 1106 | detach(); |
1105 | mData->empty = false; | 1107 | mData->empty = false; |
1106 | mData->productId = productId; | 1108 | mData->productId = productId; |
1107 | } | 1109 | } |
1108 | 1110 | ||
1109 | QString Addressee::productId() const | 1111 | QString Addressee::productId() const |
1110 | { | 1112 | { |
1111 | return mData->productId; | 1113 | return mData->productId; |
1112 | } | 1114 | } |
1113 | 1115 | ||
1114 | QString Addressee::productIdLabel() | 1116 | QString Addressee::productIdLabel() |
1115 | { | 1117 | { |
1116 | return i18n("Product Identifier"); | 1118 | return i18n("Product Identifier"); |
1117 | } | 1119 | } |
1118 | 1120 | ||
1119 | 1121 | ||
1120 | void Addressee::setRevision( const QDateTime &revision ) | 1122 | void Addressee::setRevision( const QDateTime &revision ) |
1121 | { | 1123 | { |
1122 | if ( revision == mData->revision ) return; | 1124 | if ( revision == mData->revision ) return; |
1123 | detach(); | 1125 | detach(); |
1124 | mData->empty = false; | 1126 | mData->empty = false; |
1125 | mData->revision = QDateTime( revision.date(), | 1127 | mData->revision = QDateTime( revision.date(), |
1126 | QTime (revision.time().hour(), | 1128 | QTime (revision.time().hour(), |
1127 | revision.time().minute(), | 1129 | revision.time().minute(), |
1128 | revision.time().second())); | 1130 | revision.time().second())); |
1129 | } | 1131 | } |
1130 | 1132 | ||
1131 | QDateTime Addressee::revision() const | 1133 | QDateTime Addressee::revision() const |
1132 | { | 1134 | { |
1133 | return mData->revision; | 1135 | return mData->revision; |
1134 | } | 1136 | } |
1135 | 1137 | ||
1136 | QString Addressee::revisionLabel() | 1138 | QString Addressee::revisionLabel() |
1137 | { | 1139 | { |
1138 | return i18n("Revision Date"); | 1140 | return i18n("Revision Date"); |
1139 | } | 1141 | } |
1140 | 1142 | ||
1141 | 1143 | ||
1142 | void Addressee::setSortString( const QString &sortString ) | 1144 | void Addressee::setSortString( const QString &sortString ) |
1143 | { | 1145 | { |
1144 | if ( sortString == mData->sortString ) return; | 1146 | if ( sortString == mData->sortString ) return; |
1145 | detach(); | 1147 | detach(); |
1146 | mData->empty = false; | 1148 | mData->empty = false; |
1147 | mData->sortString = sortString; | 1149 | mData->sortString = sortString; |
1148 | } | 1150 | } |
1149 | 1151 | ||
1150 | QString Addressee::sortString() const | 1152 | QString Addressee::sortString() const |
1151 | { | 1153 | { |
1152 | return mData->sortString; | 1154 | return mData->sortString; |
1153 | } | 1155 | } |
1154 | 1156 | ||
1155 | QString Addressee::sortStringLabel() | 1157 | QString Addressee::sortStringLabel() |
1156 | { | 1158 | { |
1157 | return i18n("Sort String"); | 1159 | return i18n("Sort String"); |
1158 | } | 1160 | } |
1159 | 1161 | ||
1160 | 1162 | ||
1161 | void Addressee::setUrl( const KURL &url ) | 1163 | void Addressee::setUrl( const KURL &url ) |
1162 | { | 1164 | { |
1163 | if ( url == mData->url ) return; | 1165 | if ( url == mData->url ) return; |
1164 | detach(); | 1166 | detach(); |
1165 | mData->empty = false; | 1167 | mData->empty = false; |
1166 | mData->url = url; | 1168 | mData->url = url; |
1167 | } | 1169 | } |
1168 | 1170 | ||
1169 | KURL Addressee::url() const | 1171 | KURL Addressee::url() const |
1170 | { | 1172 | { |
1171 | return mData->url; | 1173 | return mData->url; |
1172 | } | 1174 | } |
1173 | 1175 | ||
1174 | QString Addressee::urlLabel() | 1176 | QString Addressee::urlLabel() |
1175 | { | 1177 | { |
1176 | return i18n("URL"); | 1178 | return i18n("URL"); |
1177 | } | 1179 | } |
1178 | 1180 | ||
1179 | 1181 | ||
1180 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 1182 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
1181 | { | 1183 | { |
1182 | if ( secrecy == mData->secrecy ) return; | 1184 | if ( secrecy == mData->secrecy ) return; |
1183 | detach(); | 1185 | detach(); |
1184 | mData->empty = false; | 1186 | mData->empty = false; |
1185 | mData->secrecy = secrecy; | 1187 | mData->secrecy = secrecy; |
1186 | } | 1188 | } |
1187 | 1189 | ||
1188 | Secrecy Addressee::secrecy() const | 1190 | Secrecy Addressee::secrecy() const |
1189 | { | 1191 | { |
1190 | return mData->secrecy; | 1192 | return mData->secrecy; |
1191 | } | 1193 | } |
1192 | 1194 | ||
1193 | QString Addressee::secrecyLabel() | 1195 | QString Addressee::secrecyLabel() |
1194 | { | 1196 | { |
1195 | return i18n("Security Class"); | 1197 | return i18n("Security Class"); |
1196 | } | 1198 | } |
1197 | 1199 | ||
1198 | 1200 | ||
1199 | void Addressee::setLogo( const Picture &logo ) | 1201 | void Addressee::setLogo( const Picture &logo ) |
1200 | { | 1202 | { |
1201 | if ( logo == mData->logo ) return; | 1203 | if ( logo == mData->logo ) return; |
1202 | detach(); | 1204 | detach(); |
1203 | mData->empty = false; | 1205 | mData->empty = false; |
1204 | mData->logo = logo; | 1206 | mData->logo = logo; |
1205 | } | 1207 | } |
1206 | 1208 | ||
1207 | Picture Addressee::logo() const | 1209 | Picture Addressee::logo() const |
1208 | { | 1210 | { |
1209 | return mData->logo; | 1211 | return mData->logo; |
1210 | } | 1212 | } |
1211 | 1213 | ||
1212 | QString Addressee::logoLabel() | 1214 | QString Addressee::logoLabel() |
1213 | { | 1215 | { |
1214 | return i18n("Logo"); | 1216 | return i18n("Logo"); |
1215 | } | 1217 | } |
1216 | 1218 | ||
1217 | 1219 | ||
1218 | void Addressee::setPhoto( const Picture &photo ) | 1220 | void Addressee::setPhoto( const Picture &photo ) |
1219 | { | 1221 | { |
1220 | if ( photo == mData->photo ) return; | 1222 | if ( photo == mData->photo ) return; |
1221 | detach(); | 1223 | detach(); |
1222 | mData->empty = false; | 1224 | mData->empty = false; |
1223 | mData->photo = photo; | 1225 | mData->photo = photo; |
1224 | } | 1226 | } |
1225 | 1227 | ||
1226 | Picture Addressee::photo() const | 1228 | Picture Addressee::photo() const |
1227 | { | 1229 | { |
1228 | return mData->photo; | 1230 | return mData->photo; |
1229 | } | 1231 | } |
1230 | 1232 | ||
1231 | QString Addressee::photoLabel() | 1233 | QString Addressee::photoLabel() |
1232 | { | 1234 | { |
1233 | return i18n("Photo"); | 1235 | return i18n("Photo"); |
1234 | } | 1236 | } |
1235 | 1237 | ||
1236 | 1238 | ||
1237 | void Addressee::setSound( const Sound &sound ) | 1239 | void Addressee::setSound( const Sound &sound ) |
1238 | { | 1240 | { |
1239 | if ( sound == mData->sound ) return; | 1241 | if ( sound == mData->sound ) return; |
1240 | detach(); | 1242 | detach(); |
1241 | mData->empty = false; | 1243 | mData->empty = false; |
1242 | mData->sound = sound; | 1244 | mData->sound = sound; |
1243 | } | 1245 | } |
1244 | 1246 | ||
1245 | Sound Addressee::sound() const | 1247 | Sound Addressee::sound() const |
1246 | { | 1248 | { |
1247 | return mData->sound; | 1249 | return mData->sound; |
1248 | } | 1250 | } |
1249 | 1251 | ||
1250 | QString Addressee::soundLabel() | 1252 | QString Addressee::soundLabel() |
1251 | { | 1253 | { |
1252 | return i18n("Sound"); | 1254 | return i18n("Sound"); |
1253 | } | 1255 | } |
1254 | 1256 | ||
1255 | 1257 | ||
1256 | void Addressee::setAgent( const Agent &agent ) | 1258 | void Addressee::setAgent( const Agent &agent ) |
1257 | { | 1259 | { |
1258 | if ( agent == mData->agent ) return; | 1260 | if ( agent == mData->agent ) return; |
1259 | detach(); | 1261 | detach(); |
1260 | mData->empty = false; | 1262 | mData->empty = false; |
1261 | mData->agent = agent; | 1263 | mData->agent = agent; |
1262 | } | 1264 | } |
1263 | 1265 | ||
1264 | Agent Addressee::agent() const | 1266 | Agent Addressee::agent() const |
1265 | { | 1267 | { |
1266 | return mData->agent; | 1268 | return mData->agent; |
1267 | } | 1269 | } |
1268 | 1270 | ||
1269 | QString Addressee::agentLabel() | 1271 | QString Addressee::agentLabel() |
1270 | { | 1272 | { |
1271 | return i18n("Agent"); | 1273 | return i18n("Agent"); |
1272 | } | 1274 | } |
1273 | 1275 | ||
1274 | 1276 | ||
1275 | 1277 | ||
1276 | void Addressee::setNameFromString( const QString &str ) | 1278 | void Addressee::setNameFromString( const QString &str ) |
1277 | { | 1279 | { |
1278 | setFormattedName( str ); | 1280 | setFormattedName( str ); |
1279 | setName( str ); | 1281 | setName( str ); |
1280 | 1282 | ||
1281 | static bool first = true; | 1283 | static bool first = true; |
1282 | static QStringList titles; | 1284 | static QStringList titles; |
1283 | static QStringList suffixes; | 1285 | static QStringList suffixes; |
1284 | static QStringList prefixes; | 1286 | static QStringList prefixes; |
1285 | 1287 | ||
1286 | if ( first ) { | 1288 | if ( first ) { |
1287 | first = false; | 1289 | first = false; |
1288 | titles += i18n( "Dr." ); | 1290 | titles += i18n( "Dr." ); |
1289 | titles += i18n( "Miss" ); | 1291 | titles += i18n( "Miss" ); |
1290 | titles += i18n( "Mr." ); | 1292 | titles += i18n( "Mr." ); |
1291 | titles += i18n( "Mrs." ); | 1293 | titles += i18n( "Mrs." ); |
1292 | titles += i18n( "Ms." ); | 1294 | titles += i18n( "Ms." ); |
1293 | titles += i18n( "Prof." ); | 1295 | titles += i18n( "Prof." ); |
1294 | 1296 | ||
1295 | suffixes += i18n( "I" ); | 1297 | suffixes += i18n( "I" ); |
1296 | suffixes += i18n( "II" ); | 1298 | suffixes += i18n( "II" ); |
1297 | suffixes += i18n( "III" ); | 1299 | suffixes += i18n( "III" ); |
1298 | suffixes += i18n( "Jr." ); | 1300 | suffixes += i18n( "Jr." ); |
1299 | suffixes += i18n( "Sr." ); | 1301 | suffixes += i18n( "Sr." ); |
1300 | 1302 | ||
1301 | prefixes += "van"; | 1303 | prefixes += "van"; |
1302 | prefixes += "von"; | 1304 | prefixes += "von"; |
1303 | prefixes += "de"; | 1305 | prefixes += "de"; |
1304 | 1306 | ||
1305 | KConfig config( locateLocal( "config", "kabcrc") ); | 1307 | KConfig config( locateLocal( "config", "kabcrc") ); |
1306 | config.setGroup( "General" ); | 1308 | config.setGroup( "General" ); |
1307 | titles += config.readListEntry( "Prefixes" ); | 1309 | titles += config.readListEntry( "Prefixes" ); |
1308 | titles.remove( "" ); | 1310 | titles.remove( "" ); |
1309 | prefixes += config.readListEntry( "Inclusions" ); | 1311 | prefixes += config.readListEntry( "Inclusions" ); |
1310 | prefixes.remove( "" ); | 1312 | prefixes.remove( "" ); |
1311 | suffixes += config.readListEntry( "Suffixes" ); | 1313 | suffixes += config.readListEntry( "Suffixes" ); |
1312 | suffixes.remove( "" ); | 1314 | suffixes.remove( "" ); |
1313 | } | 1315 | } |
1314 | 1316 | ||
1315 | // clear all name parts | 1317 | // clear all name parts |
1316 | setPrefix( "" ); | 1318 | setPrefix( "" ); |
1317 | setGivenName( "" ); | 1319 | setGivenName( "" ); |
1318 | setAdditionalName( "" ); | 1320 | setAdditionalName( "" ); |
1319 | setFamilyName( "" ); | 1321 | setFamilyName( "" ); |
1320 | setSuffix( "" ); | 1322 | setSuffix( "" ); |
1321 | 1323 | ||
1322 | if ( str.isEmpty() ) | 1324 | if ( str.isEmpty() ) |
1323 | return; | 1325 | return; |
1324 | 1326 | ||
1325 | int i = str.find(','); | 1327 | int i = str.find(','); |
1326 | if( i < 0 ) { | 1328 | if( i < 0 ) { |
1327 | QStringList parts = QStringList::split( " ", str ); | 1329 | QStringList parts = QStringList::split( " ", str ); |
1328 | int leftOffset = 0; | 1330 | int leftOffset = 0; |
1329 | int rightOffset = parts.count() - 1; | 1331 | int rightOffset = parts.count() - 1; |
1330 | 1332 | ||
1331 | QString suffix; | 1333 | QString suffix; |
1332 | while ( rightOffset >= 0 ) { | 1334 | while ( rightOffset >= 0 ) { |
1333 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1335 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1334 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1336 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1335 | rightOffset--; | 1337 | rightOffset--; |
1336 | } else | 1338 | } else |
1337 | break; | 1339 | break; |
1338 | } | 1340 | } |
1339 | setSuffix( suffix ); | 1341 | setSuffix( suffix ); |
1340 | 1342 | ||
1341 | if ( rightOffset < 0 ) | 1343 | if ( rightOffset < 0 ) |
1342 | return; | 1344 | return; |
1343 | 1345 | ||
1344 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1346 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1345 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1347 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1346 | rightOffset--; | 1348 | rightOffset--; |
1347 | } else | 1349 | } else |
1348 | setFamilyName( parts[ rightOffset ] ); | 1350 | setFamilyName( parts[ rightOffset ] ); |
1349 | 1351 | ||
1350 | QString prefix; | 1352 | QString prefix; |
1351 | while ( leftOffset < rightOffset ) { | 1353 | while ( leftOffset < rightOffset ) { |
1352 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1354 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1353 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1355 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1354 | leftOffset++; | 1356 | leftOffset++; |
1355 | } else | 1357 | } else |
1356 | break; | 1358 | break; |
1357 | } | 1359 | } |
1358 | setPrefix( prefix ); | 1360 | setPrefix( prefix ); |
1359 | 1361 | ||
1360 | if ( leftOffset < rightOffset ) { | 1362 | if ( leftOffset < rightOffset ) { |
1361 | setGivenName( parts[ leftOffset ] ); | 1363 | setGivenName( parts[ leftOffset ] ); |
1362 | leftOffset++; | 1364 | leftOffset++; |
1363 | } | 1365 | } |
1364 | 1366 | ||
1365 | QString additionalName; | 1367 | QString additionalName; |
1366 | while ( leftOffset < rightOffset ) { | 1368 | while ( leftOffset < rightOffset ) { |
1367 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1369 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1368 | leftOffset++; | 1370 | leftOffset++; |
1369 | } | 1371 | } |
1370 | setAdditionalName( additionalName ); | 1372 | setAdditionalName( additionalName ); |
1371 | } else { | 1373 | } else { |
1372 | QString part1 = str.left( i ); | 1374 | QString part1 = str.left( i ); |
1373 | QString part2 = str.mid( i + 1 ); | 1375 | QString part2 = str.mid( i + 1 ); |
1374 | 1376 | ||
1375 | QStringList parts = QStringList::split( " ", part1 ); | 1377 | QStringList parts = QStringList::split( " ", part1 ); |
1376 | int leftOffset = 0; | 1378 | int leftOffset = 0; |
1377 | int rightOffset = parts.count() - 1; | 1379 | int rightOffset = parts.count() - 1; |
1378 | 1380 | ||
1379 | QString suffix; | 1381 | QString suffix; |
1380 | while ( rightOffset >= 0 ) { | 1382 | while ( rightOffset >= 0 ) { |
1381 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1383 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1382 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1384 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1383 | rightOffset--; | 1385 | rightOffset--; |
1384 | } else | 1386 | } else |
1385 | break; | 1387 | break; |
1386 | } | 1388 | } |
1387 | setSuffix( suffix ); | 1389 | setSuffix( suffix ); |
1388 | 1390 | ||
1389 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1391 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1390 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1392 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1391 | rightOffset--; | 1393 | rightOffset--; |
1392 | } else | 1394 | } else |
1393 | setFamilyName( parts[ rightOffset ] ); | 1395 | setFamilyName( parts[ rightOffset ] ); |
1394 | 1396 | ||
1395 | QString prefix; | 1397 | QString prefix; |
1396 | while ( leftOffset < rightOffset ) { | 1398 | while ( leftOffset < rightOffset ) { |
1397 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1399 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1398 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1400 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1399 | leftOffset++; | 1401 | leftOffset++; |
1400 | } else | 1402 | } else |
1401 | break; | 1403 | break; |
1402 | } | 1404 | } |
1403 | 1405 | ||
1404 | parts = QStringList::split( " ", part2 ); | 1406 | parts = QStringList::split( " ", part2 ); |
1405 | 1407 | ||
1406 | leftOffset = 0; | 1408 | leftOffset = 0; |
1407 | rightOffset = parts.count(); | 1409 | rightOffset = parts.count(); |
1408 | 1410 | ||
1409 | while ( leftOffset < rightOffset ) { | 1411 | while ( leftOffset < rightOffset ) { |
1410 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1412 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1411 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1413 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1412 | leftOffset++; | 1414 | leftOffset++; |
1413 | } else | 1415 | } else |
1414 | break; | 1416 | break; |
1415 | } | 1417 | } |
1416 | setPrefix( prefix ); | 1418 | setPrefix( prefix ); |
1417 | 1419 | ||
1418 | if ( leftOffset < rightOffset ) { | 1420 | if ( leftOffset < rightOffset ) { |
1419 | setGivenName( parts[ leftOffset ] ); | 1421 | setGivenName( parts[ leftOffset ] ); |
1420 | leftOffset++; | 1422 | leftOffset++; |
1421 | } | 1423 | } |
1422 | 1424 | ||
1423 | QString additionalName; | 1425 | QString additionalName; |
1424 | while ( leftOffset < rightOffset ) { | 1426 | while ( leftOffset < rightOffset ) { |
1425 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1427 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1426 | leftOffset++; | 1428 | leftOffset++; |
1427 | } | 1429 | } |
1428 | setAdditionalName( additionalName ); | 1430 | setAdditionalName( additionalName ); |
1429 | } | 1431 | } |
1430 | } | 1432 | } |
1431 | 1433 | ||
1432 | QString Addressee::realName() const | 1434 | QString Addressee::realName() const |
1433 | { | 1435 | { |
1434 | if ( !formattedName().isEmpty() ) | 1436 | if ( !formattedName().isEmpty() ) |
1435 | return formattedName(); | 1437 | return formattedName(); |
1436 | 1438 | ||
1437 | QString n = assembledName(); | 1439 | QString n = assembledName(); |
1438 | 1440 | ||
1439 | if ( n.isEmpty() ) | 1441 | if ( n.isEmpty() ) |
1440 | n = name(); | 1442 | n = name(); |
1441 | 1443 | ||
1442 | return n; | 1444 | return n; |
1443 | } | 1445 | } |
1444 | 1446 | ||
1445 | QString Addressee::assembledName() const | 1447 | QString Addressee::assembledName() const |
1446 | { | 1448 | { |
1447 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1449 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1448 | familyName() + " " + suffix(); | 1450 | familyName() + " " + suffix(); |
1449 | 1451 | ||
1450 | return name.simplifyWhiteSpace(); | 1452 | return name.simplifyWhiteSpace(); |
1451 | } | 1453 | } |
1452 | 1454 | ||
1453 | QString Addressee::fullEmail( const QString &email ) const | 1455 | QString Addressee::fullEmail( const QString &email ) const |
1454 | { | 1456 | { |
1455 | QString e; | 1457 | QString e; |
1456 | if ( email.isNull() ) { | 1458 | if ( email.isNull() ) { |
1457 | e = preferredEmail(); | 1459 | e = preferredEmail(); |
1458 | } else { | 1460 | } else { |
1459 | e = email; | 1461 | e = email; |
1460 | } | 1462 | } |
1461 | if ( e.isEmpty() ) return QString::null; | 1463 | if ( e.isEmpty() ) return QString::null; |
1462 | 1464 | ||
1463 | QString text; | 1465 | QString text; |
1464 | if ( realName().isEmpty() ) | 1466 | if ( realName().isEmpty() ) |
1465 | text = e; | 1467 | text = e; |
1466 | else | 1468 | else |
1467 | text = assembledName() + " <" + e + ">"; | 1469 | text = assembledName() + " <" + e + ">"; |
1468 | 1470 | ||
1469 | return text; | 1471 | return text; |
1470 | } | 1472 | } |
1471 | 1473 | ||
1472 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1474 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1473 | { | 1475 | { |
1474 | detach(); | 1476 | detach(); |
1475 | 1477 | ||
1476 | QStringList::Iterator it = mData->emails.find( email ); | 1478 | QStringList::Iterator it = mData->emails.find( email ); |
1477 | 1479 | ||
1478 | if ( it != mData->emails.end() ) { | 1480 | if ( it != mData->emails.end() ) { |
1479 | if ( !preferred || it == mData->emails.begin() ) return; | 1481 | if ( !preferred || it == mData->emails.begin() ) return; |
1480 | mData->emails.remove( it ); | 1482 | mData->emails.remove( it ); |
1481 | mData->emails.prepend( email ); | 1483 | mData->emails.prepend( email ); |
1482 | } else { | 1484 | } else { |
1483 | if ( preferred ) { | 1485 | if ( preferred ) { |
1484 | mData->emails.prepend( email ); | 1486 | mData->emails.prepend( email ); |
1485 | } else { | 1487 | } else { |
1486 | mData->emails.append( email ); | 1488 | mData->emails.append( email ); |
1487 | } | 1489 | } |
1488 | } | 1490 | } |
1489 | } | 1491 | } |
1490 | 1492 | ||
1491 | void Addressee::removeEmail( const QString &email ) | 1493 | void Addressee::removeEmail( const QString &email ) |
1492 | { | 1494 | { |
1493 | detach(); | 1495 | detach(); |
1494 | 1496 | ||
1495 | QStringList::Iterator it = mData->emails.find( email ); | 1497 | QStringList::Iterator it = mData->emails.find( email ); |
1496 | if ( it == mData->emails.end() ) return; | 1498 | if ( it == mData->emails.end() ) return; |
1497 | 1499 | ||
1498 | mData->emails.remove( it ); | 1500 | mData->emails.remove( it ); |
1499 | } | 1501 | } |
1500 | 1502 | ||
1501 | QString Addressee::preferredEmail() const | 1503 | QString Addressee::preferredEmail() const |
1502 | { | 1504 | { |
1503 | if ( mData->emails.count() == 0 ) return QString::null; | 1505 | if ( mData->emails.count() == 0 ) return QString::null; |
1504 | else return mData->emails.first(); | 1506 | else return mData->emails.first(); |
1505 | } | 1507 | } |
1506 | 1508 | ||
1507 | QStringList Addressee::emails() const | 1509 | QStringList Addressee::emails() const |
1508 | { | 1510 | { |
1509 | return mData->emails; | 1511 | return mData->emails; |
1510 | } | 1512 | } |
1511 | void Addressee::setEmails( const QStringList& emails ) { | 1513 | void Addressee::setEmails( const QStringList& emails ) { |
1512 | detach(); | 1514 | detach(); |
1513 | mData->emails = emails; | 1515 | mData->emails = emails; |
1514 | } | 1516 | } |
1515 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1517 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1516 | { | 1518 | { |
1517 | detach(); | 1519 | detach(); |
1518 | mData->empty = false; | 1520 | mData->empty = false; |
1519 | 1521 | ||
1520 | PhoneNumber::List::Iterator it; | 1522 | PhoneNumber::List::Iterator it; |
1521 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1523 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1522 | if ( (*it).id() == phoneNumber.id() ) { | 1524 | if ( (*it).id() == phoneNumber.id() ) { |
1523 | *it = phoneNumber; | 1525 | *it = phoneNumber; |
1524 | return; | 1526 | return; |
1525 | } | 1527 | } |
1526 | } | 1528 | } |
1527 | mData->phoneNumbers.append( phoneNumber ); | 1529 | mData->phoneNumbers.append( phoneNumber ); |
1528 | } | 1530 | } |
1529 | 1531 | ||
1530 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1532 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1531 | { | 1533 | { |
1532 | detach(); | 1534 | detach(); |
1533 | 1535 | ||
1534 | PhoneNumber::List::Iterator it; | 1536 | PhoneNumber::List::Iterator it; |
1535 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1537 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1536 | if ( (*it).id() == phoneNumber.id() ) { | 1538 | if ( (*it).id() == phoneNumber.id() ) { |
1537 | mData->phoneNumbers.remove( it ); | 1539 | mData->phoneNumbers.remove( it ); |
1538 | return; | 1540 | return; |
1539 | } | 1541 | } |
1540 | } | 1542 | } |
1541 | } | 1543 | } |
1542 | 1544 | ||
1543 | PhoneNumber Addressee::phoneNumber( int type ) const | 1545 | PhoneNumber Addressee::phoneNumber( int type ) const |
1544 | { | 1546 | { |
1545 | PhoneNumber phoneNumber( "", type ); | 1547 | PhoneNumber phoneNumber( "", type ); |
1546 | PhoneNumber::List::ConstIterator it; | 1548 | PhoneNumber::List::ConstIterator it; |
1547 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1549 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1548 | if ( matchBinaryPatternP( (*it).type(), type ) ) { | 1550 | if ( matchBinaryPatternP( (*it).type(), type ) ) { |
1549 | if ( (*it).type() & PhoneNumber::Pref ) | 1551 | if ( (*it).type() & PhoneNumber::Pref ) |
1550 | return (*it); | 1552 | return (*it); |
1551 | else if ( phoneNumber.number().isEmpty() ) | 1553 | else if ( phoneNumber.number().isEmpty() ) |
1552 | phoneNumber = (*it); | 1554 | phoneNumber = (*it); |
1553 | } | 1555 | } |
1554 | } | 1556 | } |
1555 | 1557 | ||
1556 | return phoneNumber; | 1558 | return phoneNumber; |
1557 | } | 1559 | } |
1558 | 1560 | ||
1559 | PhoneNumber::List Addressee::phoneNumbers() const | 1561 | PhoneNumber::List Addressee::phoneNumbers() const |
1560 | { | 1562 | { |
1561 | return mData->phoneNumbers; | 1563 | return mData->phoneNumbers; |
1562 | } | 1564 | } |
1563 | 1565 | ||
1564 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1566 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1565 | { | 1567 | { |
1566 | PhoneNumber::List list; | 1568 | PhoneNumber::List list; |
1567 | 1569 | ||
1568 | PhoneNumber::List::ConstIterator it; | 1570 | PhoneNumber::List::ConstIterator it; |
1569 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1571 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1570 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1572 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1571 | list.append( *it ); | 1573 | list.append( *it ); |
1572 | } | 1574 | } |
1573 | } | 1575 | } |
1574 | return list; | 1576 | return list; |
1575 | } | 1577 | } |
1576 | 1578 | ||
1577 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1579 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1578 | { | 1580 | { |
1579 | PhoneNumber::List::ConstIterator it; | 1581 | PhoneNumber::List::ConstIterator it; |
1580 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1582 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1581 | if ( (*it).id() == id ) { | 1583 | if ( (*it).id() == id ) { |
1582 | return *it; | 1584 | return *it; |
1583 | } | 1585 | } |
1584 | } | 1586 | } |
1585 | return PhoneNumber(); | 1587 | return PhoneNumber(); |
1586 | } | 1588 | } |
1587 | 1589 | ||
1588 | void Addressee::insertKey( const Key &key ) | 1590 | void Addressee::insertKey( const Key &key ) |
1589 | { | 1591 | { |
1590 | detach(); | 1592 | detach(); |
1591 | mData->empty = false; | 1593 | mData->empty = false; |
1592 | 1594 | ||
1593 | Key::List::Iterator it; | 1595 | Key::List::Iterator it; |
1594 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1596 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1595 | if ( (*it).id() == key.id() ) { | 1597 | if ( (*it).id() == key.id() ) { |
1596 | *it = key; | 1598 | *it = key; |
1597 | return; | 1599 | return; |
1598 | } | 1600 | } |
1599 | } | 1601 | } |
1600 | mData->keys.append( key ); | 1602 | mData->keys.append( key ); |
1601 | } | 1603 | } |
1602 | 1604 | ||
1603 | void Addressee::removeKey( const Key &key ) | 1605 | void Addressee::removeKey( const Key &key ) |
1604 | { | 1606 | { |
1605 | detach(); | 1607 | detach(); |
1606 | 1608 | ||
1607 | Key::List::Iterator it; | 1609 | Key::List::Iterator it; |
1608 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1610 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1609 | if ( (*it).id() == key.id() ) { | 1611 | if ( (*it).id() == key.id() ) { |
1610 | mData->keys.remove( key ); | 1612 | mData->keys.remove( key ); |
1611 | return; | 1613 | return; |
1612 | } | 1614 | } |
1613 | } | 1615 | } |
1614 | } | 1616 | } |
1615 | 1617 | ||
1616 | Key Addressee::key( int type, QString customTypeString ) const | 1618 | Key Addressee::key( int type, QString customTypeString ) const |
1617 | { | 1619 | { |
1618 | Key::List::ConstIterator it; | 1620 | Key::List::ConstIterator it; |
1619 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1621 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1620 | if ( (*it).type() == type ) { | 1622 | if ( (*it).type() == type ) { |
1621 | if ( type == Key::Custom ) { | 1623 | if ( type == Key::Custom ) { |
1622 | if ( customTypeString.isEmpty() ) { | 1624 | if ( customTypeString.isEmpty() ) { |
1623 | return *it; | 1625 | return *it; |
1624 | } else { | 1626 | } else { |
1625 | if ( (*it).customTypeString() == customTypeString ) | 1627 | if ( (*it).customTypeString() == customTypeString ) |
1626 | return (*it); | 1628 | return (*it); |
1627 | } | 1629 | } |
1628 | } else { | 1630 | } else { |
1629 | return *it; | 1631 | return *it; |
1630 | } | 1632 | } |
1631 | } | 1633 | } |
1632 | } | 1634 | } |
1633 | return Key( QString(), type ); | 1635 | return Key( QString(), type ); |
1634 | } | 1636 | } |
1635 | void Addressee::setKeys( const Key::List& list ) { | 1637 | void Addressee::setKeys( const Key::List& list ) { |
1636 | detach(); | 1638 | detach(); |
1637 | mData->keys = list; | 1639 | mData->keys = list; |
1638 | } | 1640 | } |
1639 | 1641 | ||
1640 | Key::List Addressee::keys() const | 1642 | Key::List Addressee::keys() const |
1641 | { | 1643 | { |
1642 | return mData->keys; | 1644 | return mData->keys; |
1643 | } | 1645 | } |
1644 | 1646 | ||
1645 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1647 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1646 | { | 1648 | { |
1647 | Key::List list; | 1649 | Key::List list; |
1648 | 1650 | ||
1649 | Key::List::ConstIterator it; | 1651 | Key::List::ConstIterator it; |
1650 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1652 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1651 | if ( (*it).type() == type ) { | 1653 | if ( (*it).type() == type ) { |
1652 | if ( type == Key::Custom ) { | 1654 | if ( type == Key::Custom ) { |
1653 | if ( customTypeString.isEmpty() ) { | 1655 | if ( customTypeString.isEmpty() ) { |
1654 | list.append(*it); | 1656 | list.append(*it); |
1655 | } else { | 1657 | } else { |
1656 | if ( (*it).customTypeString() == customTypeString ) | 1658 | if ( (*it).customTypeString() == customTypeString ) |
1657 | list.append(*it); | 1659 | list.append(*it); |
1658 | } | 1660 | } |
1659 | } else { | 1661 | } else { |
1660 | list.append(*it); | 1662 | list.append(*it); |
1661 | } | 1663 | } |
1662 | } | 1664 | } |
1663 | } | 1665 | } |
1664 | return list; | 1666 | return list; |
1665 | } | 1667 | } |
1666 | 1668 | ||
1667 | Key Addressee::findKey( const QString &id ) const | 1669 | Key Addressee::findKey( const QString &id ) const |
1668 | { | 1670 | { |
1669 | Key::List::ConstIterator it; | 1671 | Key::List::ConstIterator it; |
1670 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1672 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1671 | if ( (*it).id() == id ) { | 1673 | if ( (*it).id() == id ) { |
1672 | return *it; | 1674 | return *it; |
1673 | } | 1675 | } |
1674 | } | 1676 | } |
1675 | return Key(); | 1677 | return Key(); |
1676 | } | 1678 | } |
1677 | 1679 | ||
1678 | QString Addressee::asString() const | 1680 | QString Addressee::asString() const |
1679 | { | 1681 | { |
1680 | return "Smith, agent Smith..."; | 1682 | return "Smith, agent Smith..."; |
1681 | } | 1683 | } |
1682 | 1684 | ||
1683 | void Addressee::dump() const | 1685 | void Addressee::dump() const |
1684 | { | 1686 | { |
1685 | return; | 1687 | return; |
1686 | #if 0 | 1688 | #if 0 |
1687 | kdDebug(5700) << "Addressee {" << endl; | 1689 | kdDebug(5700) << "Addressee {" << endl; |
1688 | 1690 | ||
1689 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1691 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1690 | 1692 | ||
1691 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1693 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1692 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1694 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1693 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1695 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1694 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1696 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1695 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1697 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1696 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1698 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1697 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1699 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1698 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1700 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1699 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1701 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1700 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1702 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1701 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1703 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1702 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1704 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1703 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1705 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1704 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1706 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1705 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1707 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1706 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1708 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1707 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1709 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1708 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1710 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1709 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1711 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1710 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1712 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1711 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1713 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1712 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1714 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1713 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1715 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1714 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1716 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1715 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1717 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1716 | 1718 | ||
1717 | kdDebug(5700) << " Emails {" << endl; | 1719 | kdDebug(5700) << " Emails {" << endl; |
1718 | QStringList e = emails(); | 1720 | QStringList e = emails(); |
1719 | QStringList::ConstIterator it; | 1721 | QStringList::ConstIterator it; |
1720 | for( it = e.begin(); it != e.end(); ++it ) { | 1722 | for( it = e.begin(); it != e.end(); ++it ) { |
1721 | kdDebug(5700) << " " << (*it) << endl; | 1723 | kdDebug(5700) << " " << (*it) << endl; |
1722 | } | 1724 | } |
1723 | kdDebug(5700) << " }" << endl; | 1725 | kdDebug(5700) << " }" << endl; |
1724 | 1726 | ||
1725 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1727 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1726 | PhoneNumber::List p = phoneNumbers(); | 1728 | PhoneNumber::List p = phoneNumbers(); |
1727 | PhoneNumber::List::ConstIterator it2; | 1729 | PhoneNumber::List::ConstIterator it2; |
1728 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1730 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1729 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1731 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1730 | } | 1732 | } |
1731 | kdDebug(5700) << " }" << endl; | 1733 | kdDebug(5700) << " }" << endl; |
1732 | 1734 | ||
1733 | Address::List a = addresses(); | 1735 | Address::List a = addresses(); |
1734 | Address::List::ConstIterator it3; | 1736 | Address::List::ConstIterator it3; |
1735 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1737 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1736 | (*it3).dump(); | 1738 | (*it3).dump(); |
1737 | } | 1739 | } |
1738 | 1740 | ||
1739 | kdDebug(5700) << " Keys {" << endl; | 1741 | kdDebug(5700) << " Keys {" << endl; |
1740 | Key::List k = keys(); | 1742 | Key::List k = keys(); |
1741 | Key::List::ConstIterator it4; | 1743 | Key::List::ConstIterator it4; |
1742 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1744 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1743 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1745 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1744 | " Key: " << (*it4).textData() << | 1746 | " Key: " << (*it4).textData() << |
1745 | " CustomString: " << (*it4).customTypeString() << endl; | 1747 | " CustomString: " << (*it4).customTypeString() << endl; |
1746 | } | 1748 | } |
1747 | kdDebug(5700) << " }" << endl; | 1749 | kdDebug(5700) << " }" << endl; |
1748 | 1750 | ||
1749 | kdDebug(5700) << "}" << endl; | 1751 | kdDebug(5700) << "}" << endl; |
1750 | #endif | 1752 | #endif |
1751 | } | 1753 | } |
1752 | 1754 | ||
1753 | 1755 | ||
1754 | void Addressee::insertAddress( const Address &address ) | 1756 | void Addressee::insertAddress( const Address &address ) |
1755 | { | 1757 | { |
1756 | detach(); | 1758 | detach(); |
1757 | mData->empty = false; | 1759 | mData->empty = false; |
1758 | 1760 | ||
1759 | Address::List::Iterator it; | 1761 | Address::List::Iterator it; |
1760 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1762 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1761 | if ( (*it).id() == address.id() ) { | 1763 | if ( (*it).id() == address.id() ) { |
1762 | *it = address; | 1764 | *it = address; |
1763 | return; | 1765 | return; |
1764 | } | 1766 | } |
1765 | } | 1767 | } |
1766 | mData->addresses.append( address ); | 1768 | mData->addresses.append( address ); |
1767 | } | 1769 | } |
1768 | 1770 | ||
1769 | void Addressee::removeAddress( const Address &address ) | 1771 | void Addressee::removeAddress( const Address &address ) |
1770 | { | 1772 | { |
1771 | detach(); | 1773 | detach(); |
1772 | 1774 | ||
1773 | Address::List::Iterator it; | 1775 | Address::List::Iterator it; |
1774 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1776 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1775 | if ( (*it).id() == address.id() ) { | 1777 | if ( (*it).id() == address.id() ) { |
1776 | mData->addresses.remove( it ); | 1778 | mData->addresses.remove( it ); |
1777 | return; | 1779 | return; |
1778 | } | 1780 | } |
1779 | } | 1781 | } |
1780 | } | 1782 | } |
1781 | 1783 | ||
1782 | Address Addressee::address( int type ) const | 1784 | Address Addressee::address( int type ) const |
1783 | { | 1785 | { |
1784 | Address address( type ); | 1786 | Address address( type ); |
1785 | Address::List::ConstIterator it; | 1787 | Address::List::ConstIterator it; |
1786 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1788 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1787 | if ( matchBinaryPatternA( (*it).type(), type ) ) { | 1789 | if ( matchBinaryPatternA( (*it).type(), type ) ) { |
1788 | if ( (*it).type() & Address::Pref ) | 1790 | if ( (*it).type() & Address::Pref ) |
1789 | return (*it); | 1791 | return (*it); |
1790 | else if ( address.isEmpty() ) | 1792 | else if ( address.isEmpty() ) |
1791 | address = (*it); | 1793 | address = (*it); |
1792 | } | 1794 | } |
1793 | } | 1795 | } |
1794 | 1796 | ||
1795 | return address; | 1797 | return address; |
1796 | } | 1798 | } |
1797 | 1799 | ||
1798 | Address::List Addressee::addresses() const | 1800 | Address::List Addressee::addresses() const |
1799 | { | 1801 | { |
1800 | return mData->addresses; | 1802 | return mData->addresses; |
1801 | } | 1803 | } |
1802 | 1804 | ||
1803 | Address::List Addressee::addresses( int type ) const | 1805 | Address::List Addressee::addresses( int type ) const |
1804 | { | 1806 | { |
1805 | Address::List list; | 1807 | Address::List list; |
1806 | 1808 | ||
1807 | Address::List::ConstIterator it; | 1809 | Address::List::ConstIterator it; |
1808 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1810 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1809 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1811 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1810 | list.append( *it ); | 1812 | list.append( *it ); |
1811 | } | 1813 | } |
1812 | } | 1814 | } |
1813 | 1815 | ||
1814 | return list; | 1816 | return list; |
1815 | } | 1817 | } |
1816 | 1818 | ||
1817 | Address Addressee::findAddress( const QString &id ) const | 1819 | Address Addressee::findAddress( const QString &id ) const |
1818 | { | 1820 | { |
1819 | Address::List::ConstIterator it; | 1821 | Address::List::ConstIterator it; |
1820 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1822 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1821 | if ( (*it).id() == id ) { | 1823 | if ( (*it).id() == id ) { |
1822 | return *it; | 1824 | return *it; |
1823 | } | 1825 | } |
1824 | } | 1826 | } |
1825 | return Address(); | 1827 | return Address(); |
1826 | } | 1828 | } |
1827 | 1829 | ||
1828 | void Addressee::insertCategory( const QString &c ) | 1830 | void Addressee::insertCategory( const QString &c ) |
1829 | { | 1831 | { |
1830 | detach(); | 1832 | detach(); |
1831 | mData->empty = false; | 1833 | mData->empty = false; |
1832 | 1834 | ||
1833 | if ( mData->categories.contains( c ) ) return; | 1835 | if ( mData->categories.contains( c ) ) return; |
1834 | 1836 | ||
1835 | mData->categories.append( c ); | 1837 | mData->categories.append( c ); |
1836 | } | 1838 | } |
1837 | 1839 | ||
1838 | void Addressee::removeCategory( const QString &c ) | 1840 | void Addressee::removeCategory( const QString &c ) |
1839 | { | 1841 | { |
1840 | detach(); | 1842 | detach(); |
1841 | 1843 | ||
1842 | QStringList::Iterator it = mData->categories.find( c ); | 1844 | QStringList::Iterator it = mData->categories.find( c ); |
1843 | if ( it == mData->categories.end() ) return; | 1845 | if ( it == mData->categories.end() ) return; |
1844 | 1846 | ||
1845 | mData->categories.remove( it ); | 1847 | mData->categories.remove( it ); |
1846 | } | 1848 | } |
1847 | 1849 | ||
1848 | bool Addressee::hasCategory( const QString &c ) const | 1850 | bool Addressee::hasCategory( const QString &c ) const |
1849 | { | 1851 | { |
1850 | return ( mData->categories.contains( c ) ); | 1852 | return ( mData->categories.contains( c ) ); |
1851 | } | 1853 | } |
1852 | 1854 | ||
1853 | void Addressee::setCategories( const QStringList &c ) | 1855 | void Addressee::setCategories( const QStringList &c ) |
1854 | { | 1856 | { |
1855 | detach(); | 1857 | detach(); |
1856 | mData->empty = false; | 1858 | mData->empty = false; |
1857 | 1859 | ||
1858 | mData->categories = c; | 1860 | mData->categories = c; |
1859 | } | 1861 | } |
1860 | 1862 | ||
1861 | QStringList Addressee::categories() const | 1863 | QStringList Addressee::categories() const |
1862 | { | 1864 | { |
1863 | return mData->categories; | 1865 | return mData->categories; |
1864 | } | 1866 | } |
1865 | 1867 | ||
1866 | void Addressee::insertCustom( const QString &app, const QString &name, | 1868 | void Addressee::insertCustom( const QString &app, const QString &name, |
1867 | const QString &value ) | 1869 | const QString &value ) |
1868 | { | 1870 | { |
1869 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1871 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1870 | 1872 | ||
1871 | detach(); | 1873 | detach(); |
1872 | mData->empty = false; | 1874 | mData->empty = false; |
1873 | 1875 | ||
1874 | QString qualifiedName = app + "-" + name + ":"; | 1876 | QString qualifiedName = app + "-" + name + ":"; |
1875 | 1877 | ||
1876 | QStringList::Iterator it; | 1878 | QStringList::Iterator it; |
1877 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1879 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1878 | if ( (*it).startsWith( qualifiedName ) ) { | 1880 | if ( (*it).startsWith( qualifiedName ) ) { |
1879 | (*it) = qualifiedName + value; | 1881 | (*it) = qualifiedName + value; |
1880 | return; | 1882 | return; |
1881 | } | 1883 | } |
1882 | } | 1884 | } |
1883 | mData->custom.append( qualifiedName + value ); | 1885 | mData->custom.append( qualifiedName + value ); |
1884 | } | 1886 | } |
1885 | 1887 | ||
1886 | void Addressee::removeCustom( const QString &app, const QString &name) | 1888 | void Addressee::removeCustom( const QString &app, const QString &name) |
1887 | { | 1889 | { |
1888 | detach(); | 1890 | detach(); |
1889 | 1891 | ||
1890 | QString qualifiedName = app + "-" + name + ":"; | 1892 | QString qualifiedName = app + "-" + name + ":"; |
1891 | 1893 | ||
1892 | QStringList::Iterator it; | 1894 | QStringList::Iterator it; |
1893 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1895 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1894 | if ( (*it).startsWith( qualifiedName ) ) { | 1896 | if ( (*it).startsWith( qualifiedName ) ) { |
1895 | mData->custom.remove( it ); | 1897 | mData->custom.remove( it ); |
1896 | return; | 1898 | return; |
1897 | } | 1899 | } |
1898 | } | 1900 | } |
1899 | } | 1901 | } |
1900 | 1902 | ||
1901 | QString Addressee::custom( const QString &app, const QString &name ) const | 1903 | QString Addressee::custom( const QString &app, const QString &name ) const |
1902 | { | 1904 | { |
1903 | QString qualifiedName = app + "-" + name + ":"; | 1905 | QString qualifiedName = app + "-" + name + ":"; |
1904 | QString value; | 1906 | QString value; |
1905 | 1907 | ||
1906 | QStringList::ConstIterator it; | 1908 | QStringList::ConstIterator it; |
1907 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1909 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1908 | if ( (*it).startsWith( qualifiedName ) ) { | 1910 | if ( (*it).startsWith( qualifiedName ) ) { |
1909 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1911 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1910 | break; | 1912 | break; |
1911 | } | 1913 | } |
1912 | } | 1914 | } |
1913 | 1915 | ||
1914 | return value; | 1916 | return value; |
1915 | } | 1917 | } |
1916 | 1918 | ||
1917 | void Addressee::setCustoms( const QStringList &l ) | 1919 | void Addressee::setCustoms( const QStringList &l ) |
1918 | { | 1920 | { |
1919 | detach(); | 1921 | detach(); |
1920 | mData->empty = false; | 1922 | mData->empty = false; |
1921 | 1923 | ||
1922 | mData->custom = l; | 1924 | mData->custom = l; |
1923 | } | 1925 | } |
1924 | 1926 | ||
1925 | QStringList Addressee::customs() const | 1927 | QStringList Addressee::customs() const |
1926 | { | 1928 | { |
1927 | return mData->custom; | 1929 | return mData->custom; |
1928 | } | 1930 | } |
1929 | 1931 | ||
1930 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1932 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1931 | QString &email) | 1933 | QString &email) |
1932 | { | 1934 | { |
1933 | int startPos, endPos, len; | 1935 | int startPos, endPos, len; |
1934 | QString partA, partB, result; | 1936 | QString partA, partB, result; |
1935 | char endCh = '>'; | 1937 | char endCh = '>'; |
1936 | 1938 | ||
1937 | startPos = rawEmail.find('<'); | 1939 | startPos = rawEmail.find('<'); |
1938 | if (startPos < 0) | 1940 | if (startPos < 0) |
1939 | { | 1941 | { |
1940 | startPos = rawEmail.find('('); | 1942 | startPos = rawEmail.find('('); |
1941 | endCh = ')'; | 1943 | endCh = ')'; |
1942 | } | 1944 | } |
1943 | if (startPos < 0) | 1945 | if (startPos < 0) |
1944 | { | 1946 | { |
1945 | // We couldn't find any separators, so we assume the whole string | 1947 | // We couldn't find any separators, so we assume the whole string |
1946 | // is the email address | 1948 | // is the email address |
1947 | email = rawEmail; | 1949 | email = rawEmail; |
1948 | fullName = ""; | 1950 | fullName = ""; |
1949 | } | 1951 | } |
1950 | else | 1952 | else |
1951 | { | 1953 | { |
1952 | // We have a start position, try to find an end | 1954 | // We have a start position, try to find an end |
1953 | endPos = rawEmail.find(endCh, startPos+1); | 1955 | endPos = rawEmail.find(endCh, startPos+1); |
1954 | 1956 | ||
1955 | if (endPos < 0) | 1957 | if (endPos < 0) |
1956 | { | 1958 | { |
1957 | // We couldn't find the end of the email address. We can only | 1959 | // We couldn't find the end of the email address. We can only |
1958 | // assume the entire string is the email address. | 1960 | // assume the entire string is the email address. |
1959 | email = rawEmail; | 1961 | email = rawEmail; |
1960 | fullName = ""; | 1962 | fullName = ""; |
1961 | } | 1963 | } |
1962 | else | 1964 | else |
1963 | { | 1965 | { |
1964 | // We have a start and end to the email address | 1966 | // We have a start and end to the email address |
1965 | 1967 | ||
1966 | // Grab the name part | 1968 | // Grab the name part |
1967 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 1969 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
1968 | 1970 | ||
1969 | // grab the email part | 1971 | // grab the email part |
1970 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 1972 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
1971 | 1973 | ||
1972 | // Check that we do not have any extra characters on the end of the | 1974 | // Check that we do not have any extra characters on the end of the |
1973 | // strings | 1975 | // strings |
1974 | len = fullName.length(); | 1976 | len = fullName.length(); |
1975 | if (fullName[0]=='"' && fullName[len-1]=='"') | 1977 | if (fullName[0]=='"' && fullName[len-1]=='"') |
1976 | fullName = fullName.mid(1, len-2); | 1978 | fullName = fullName.mid(1, len-2); |
1977 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 1979 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
1978 | fullName = fullName.mid(1, len-2); | 1980 | fullName = fullName.mid(1, len-2); |
1979 | else if (fullName[0]=='(' && fullName[len-1]==')') | 1981 | else if (fullName[0]=='(' && fullName[len-1]==')') |
1980 | fullName = fullName.mid(1, len-2); | 1982 | fullName = fullName.mid(1, len-2); |
1981 | } | 1983 | } |
1982 | } | 1984 | } |
1983 | } | 1985 | } |
1984 | 1986 | ||
1985 | void Addressee::setResource( Resource *resource ) | 1987 | void Addressee::setResource( Resource *resource ) |
1986 | { | 1988 | { |
1987 | detach(); | 1989 | detach(); |
1988 | mData->resource = resource; | 1990 | mData->resource = resource; |
1989 | } | 1991 | } |
1990 | 1992 | ||
1991 | Resource *Addressee::resource() const | 1993 | Resource *Addressee::resource() const |
1992 | { | 1994 | { |
1993 | return mData->resource; | 1995 | return mData->resource; |
1994 | } | 1996 | } |
1995 | 1997 | ||
1996 | //US | 1998 | //US |
1997 | QString Addressee::resourceLabel() | 1999 | QString Addressee::resourceLabel() |
1998 | { | 2000 | { |
1999 | return i18n("Resource"); | 2001 | return i18n("Resource"); |
2000 | } | 2002 | } |
2001 | QString Addressee::categoryLabel() | 2003 | QString Addressee::categoryLabel() |
2002 | { | 2004 | { |
2003 | return i18n("Category"); | 2005 | return i18n("Category"); |
2004 | } | 2006 | } |
2005 | 2007 | ||
2006 | void Addressee::setChanged( bool value ) | 2008 | void Addressee::setChanged( bool value ) |
2007 | { | 2009 | { |
2008 | detach(); | 2010 | detach(); |
2009 | mData->changed = value; | 2011 | mData->changed = value; |
2010 | } | 2012 | } |
2011 | 2013 | ||
2012 | bool Addressee::changed() const | 2014 | bool Addressee::changed() const |
2013 | { | 2015 | { |
2014 | return mData->changed; | 2016 | return mData->changed; |
2015 | } | 2017 | } |
2016 | 2018 | ||
2017 | void Addressee::setTagged( bool value ) | 2019 | void Addressee::setTagged( bool value ) |
2018 | { | 2020 | { |
2019 | detach(); | 2021 | detach(); |
2020 | mData->tagged = value; | 2022 | mData->tagged = value; |
2021 | } | 2023 | } |
2022 | 2024 | ||
2023 | bool Addressee::tagged() const | 2025 | bool Addressee::tagged() const |
2024 | { | 2026 | { |
2025 | return mData->tagged; | 2027 | return mData->tagged; |
2026 | } | 2028 | } |
2027 | 2029 | ||
2028 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 2030 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
2029 | { | 2031 | { |
2030 | if (!a.mData) return s; | 2032 | if (!a.mData) return s; |
2031 | 2033 | ||
2032 | s << a.uid(); | 2034 | s << a.uid(); |
2033 | 2035 | ||
2034 | s << a.mData->name; | 2036 | s << a.mData->name; |
2035 | s << a.mData->formattedName; | 2037 | s << a.mData->formattedName; |
2036 | s << a.mData->familyName; | 2038 | s << a.mData->familyName; |
2037 | s << a.mData->givenName; | 2039 | s << a.mData->givenName; |
2038 | s << a.mData->additionalName; | 2040 | s << a.mData->additionalName; |
2039 | s << a.mData->prefix; | 2041 | s << a.mData->prefix; |
2040 | s << a.mData->suffix; | 2042 | s << a.mData->suffix; |
2041 | s << a.mData->nickName; | 2043 | s << a.mData->nickName; |
2042 | s << a.mData->birthday; | 2044 | s << a.mData->birthday; |
2043 | s << a.mData->mailer; | 2045 | s << a.mData->mailer; |
2044 | s << a.mData->timeZone; | 2046 | s << a.mData->timeZone; |
2045 | s << a.mData->geo; | 2047 | s << a.mData->geo; |
2046 | s << a.mData->title; | 2048 | s << a.mData->title; |
2047 | s << a.mData->role; | 2049 | s << a.mData->role; |
2048 | s << a.mData->organization; | 2050 | s << a.mData->organization; |
2049 | s << a.mData->note; | 2051 | s << a.mData->note; |
2050 | s << a.mData->productId; | 2052 | s << a.mData->productId; |
2051 | s << a.mData->revision; | 2053 | s << a.mData->revision; |
2052 | s << a.mData->sortString; | 2054 | s << a.mData->sortString; |
2053 | s << a.mData->url; | 2055 | s << a.mData->url; |
2054 | s << a.mData->secrecy; | 2056 | s << a.mData->secrecy; |
2055 | s << a.mData->logo; | 2057 | s << a.mData->logo; |
2056 | s << a.mData->photo; | 2058 | s << a.mData->photo; |
2057 | s << a.mData->sound; | 2059 | s << a.mData->sound; |
2058 | s << a.mData->agent; | 2060 | s << a.mData->agent; |
2059 | s << a.mData->phoneNumbers; | 2061 | s << a.mData->phoneNumbers; |
2060 | s << a.mData->addresses; | 2062 | s << a.mData->addresses; |
2061 | s << a.mData->emails; | 2063 | s << a.mData->emails; |
2062 | s << a.mData->categories; | 2064 | s << a.mData->categories; |
2063 | s << a.mData->custom; | 2065 | s << a.mData->custom; |
2064 | s << a.mData->keys; | 2066 | s << a.mData->keys; |
2065 | return s; | 2067 | return s; |
2066 | } | 2068 | } |
2067 | 2069 | ||
2068 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 2070 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
2069 | { | 2071 | { |
2070 | if (!a.mData) return s; | 2072 | if (!a.mData) return s; |
2071 | 2073 | ||
2072 | s >> a.mData->uid; | 2074 | s >> a.mData->uid; |
2073 | 2075 | ||
2074 | s >> a.mData->name; | 2076 | s >> a.mData->name; |
2075 | s >> a.mData->formattedName; | 2077 | s >> a.mData->formattedName; |
2076 | s >> a.mData->familyName; | 2078 | s >> a.mData->familyName; |
2077 | s >> a.mData->givenName; | 2079 | s >> a.mData->givenName; |
2078 | s >> a.mData->additionalName; | 2080 | s >> a.mData->additionalName; |
2079 | s >> a.mData->prefix; | 2081 | s >> a.mData->prefix; |
2080 | s >> a.mData->suffix; | 2082 | s >> a.mData->suffix; |
2081 | s >> a.mData->nickName; | 2083 | s >> a.mData->nickName; |
2082 | s >> a.mData->birthday; | 2084 | s >> a.mData->birthday; |
2083 | s >> a.mData->mailer; | 2085 | s >> a.mData->mailer; |
2084 | s >> a.mData->timeZone; | 2086 | s >> a.mData->timeZone; |
2085 | s >> a.mData->geo; | 2087 | s >> a.mData->geo; |
2086 | s >> a.mData->title; | 2088 | s >> a.mData->title; |
2087 | s >> a.mData->role; | 2089 | s >> a.mData->role; |
2088 | s >> a.mData->organization; | 2090 | s >> a.mData->organization; |
2089 | s >> a.mData->note; | 2091 | s >> a.mData->note; |
2090 | s >> a.mData->productId; | 2092 | s >> a.mData->productId; |
2091 | s >> a.mData->revision; | 2093 | s >> a.mData->revision; |
2092 | s >> a.mData->sortString; | 2094 | s >> a.mData->sortString; |
2093 | s >> a.mData->url; | 2095 | s >> a.mData->url; |
2094 | s >> a.mData->secrecy; | 2096 | s >> a.mData->secrecy; |
2095 | s >> a.mData->logo; | 2097 | s >> a.mData->logo; |
2096 | s >> a.mData->photo; | 2098 | s >> a.mData->photo; |
2097 | s >> a.mData->sound; | 2099 | s >> a.mData->sound; |
2098 | s >> a.mData->agent; | 2100 | s >> a.mData->agent; |
2099 | s >> a.mData->phoneNumbers; | 2101 | s >> a.mData->phoneNumbers; |
2100 | s >> a.mData->addresses; | 2102 | s >> a.mData->addresses; |
2101 | s >> a.mData->emails; | 2103 | s >> a.mData->emails; |
2102 | s >> a.mData->categories; | 2104 | s >> a.mData->categories; |
2103 | s >> a.mData->custom; | 2105 | s >> a.mData->custom; |
2104 | s >> a.mData->keys; | 2106 | s >> a.mData->keys; |
2105 | 2107 | ||
2106 | a.mData->empty = false; | 2108 | a.mData->empty = false; |
2107 | 2109 | ||
2108 | return s; | 2110 | return s; |
2109 | } | 2111 | } |
2110 | bool matchBinaryPattern( int value, int pattern ) | 2112 | bool matchBinaryPattern( int value, int pattern ) |
2111 | { | 2113 | { |
2112 | /** | 2114 | /** |
2113 | We want to match all telephonnumbers/addresses which have the bits in the | 2115 | We want to match all telephonnumbers/addresses which have the bits in the |
2114 | pattern set. More are allowed. | 2116 | pattern set. More are allowed. |
2115 | if pattern == 0 we have a special handling, then we want only those with | 2117 | if pattern == 0 we have a special handling, then we want only those with |
2116 | exactly no bit set. | 2118 | exactly no bit set. |
2117 | */ | 2119 | */ |
2118 | if ( pattern == 0 ) | 2120 | if ( pattern == 0 ) |
2119 | return ( value == 0 ); | 2121 | return ( value == 0 ); |
2120 | else | 2122 | else |
2121 | return ( pattern == ( pattern & value ) ); | 2123 | return ( pattern == ( pattern & value ) ); |
2122 | } | 2124 | } |
2123 | 2125 | ||
2124 | bool matchBinaryPatternP( int value, int pattern ) | 2126 | bool matchBinaryPatternP( int value, int pattern ) |
2125 | { | 2127 | { |
2126 | 2128 | ||
2127 | if ( pattern == 0 ) | 2129 | if ( pattern == 0 ) |
2128 | return ( value == 0 ); | 2130 | return ( value == 0 ); |
2129 | else | 2131 | else |
2130 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); | 2132 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); |
2131 | } | 2133 | } |
2132 | bool matchBinaryPatternA( int value, int pattern ) | 2134 | bool matchBinaryPatternA( int value, int pattern ) |
2133 | { | 2135 | { |
2134 | 2136 | ||
2135 | if ( pattern == 0 ) | 2137 | if ( pattern == 0 ) |
2136 | return ( value == 0 ); | 2138 | return ( value == 0 ); |
2137 | else | 2139 | else |
2138 | return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); | 2140 | return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); |
2139 | } | 2141 | } |
diff --git a/kabc/secrecy.h b/kabc/secrecy.h index 8f2f736..b2ff565 100644 --- a/kabc/secrecy.h +++ b/kabc/secrecy.h | |||
@@ -1,102 +1,102 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library 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 GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef KABC_SECRECY_H | 28 | #ifndef KABC_SECRECY_H |
29 | #define KABC_SECRECY_H | 29 | #define KABC_SECRECY_H |
30 | 30 | ||
31 | #include <qvaluelist.h> | 31 | #include <qvaluelist.h> |
32 | 32 | ||
33 | namespace KABC { | 33 | namespace KABC { |
34 | 34 | ||
35 | class Secrecy | 35 | class Secrecy |
36 | { | 36 | { |
37 | friend QDataStream &operator<<( QDataStream &, const Secrecy & ); | 37 | friend QDataStream &operator<<( QDataStream &, const Secrecy & ); |
38 | friend QDataStream &operator>>( QDataStream &, Secrecy & ); | 38 | friend QDataStream &operator>>( QDataStream &, Secrecy & ); |
39 | 39 | ||
40 | public: | 40 | public: |
41 | typedef QValueList<int> TypeList; | 41 | typedef QValueList<int> TypeList; |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * Secrecy types | 44 | * Secrecy types |
45 | * | 45 | * |
46 | * @li Public - for public access | 46 | * @li Public - for public access |
47 | * @li Private - only private access | 47 | * @li Private - only private access |
48 | * @li Confidential - access for confidential persons | 48 | * @li Confidential - access for confidential persons |
49 | */ | 49 | */ |
50 | enum Types { | 50 | enum Types { |
51 | Public, | 51 | Public, |
52 | Private, | 52 | Private, |
53 | Confidential, | 53 | Confidential, |
54 | Invalid | 54 | Invalid |
55 | }; | 55 | }; |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Constructor. | 58 | * Constructor. |
59 | * | 59 | * |
60 | * @param type The secrecy type, @see Types. | 60 | * @param type The secrecy type, @see Types. |
61 | */ | 61 | */ |
62 | Secrecy( int type = Invalid ); | 62 | Secrecy( int type = Public ); |
63 | 63 | ||
64 | bool operator==( const Secrecy & ) const; | 64 | bool operator==( const Secrecy & ) const; |
65 | bool operator!=( const Secrecy & ) const; | 65 | bool operator!=( const Secrecy & ) const; |
66 | 66 | ||
67 | /** | 67 | /** |
68 | Returns if the Secrecy object has a valid value. | 68 | Returns if the Secrecy object has a valid value. |
69 | */ | 69 | */ |
70 | bool isValid() const; | 70 | bool isValid() const; |
71 | 71 | ||
72 | /** | 72 | /** |
73 | * Sets the type, @see Types. | 73 | * Sets the type, @see Types. |
74 | */ | 74 | */ |
75 | void setType( int type ); | 75 | void setType( int type ); |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * Returns the type, @see Types. | 78 | * Returns the type, @see Types. |
79 | */ | 79 | */ |
80 | int type() const; | 80 | int type() const; |
81 | 81 | ||
82 | /** | 82 | /** |
83 | * Returns a list of all available secrecy types. | 83 | * Returns a list of all available secrecy types. |
84 | */ | 84 | */ |
85 | static TypeList typeList(); | 85 | static TypeList typeList(); |
86 | 86 | ||
87 | /** | 87 | /** |
88 | * Returns a translated label for a given secrecy type. | 88 | * Returns a translated label for a given secrecy type. |
89 | */ | 89 | */ |
90 | static QString typeLabel( int type ); | 90 | static QString typeLabel( int type ); |
91 | 91 | ||
92 | /** | 92 | /** |
93 | * For debug. | 93 | * For debug. |
94 | */ | 94 | */ |
95 | QString asString() const; | 95 | QString asString() const; |
96 | 96 | ||
97 | private: | 97 | private: |
98 | int mType; | 98 | int mType; |
99 | }; | 99 | }; |
100 | 100 | ||
101 | } | 101 | } |
102 | #endif | 102 | #endif |
diff --git a/kabc/vcard/VCardv.cpp b/kabc/vcard/VCardv.cpp index 1166aac..bad2ef1 100644 --- a/kabc/vcard/VCardv.cpp +++ b/kabc/vcard/VCardv.cpp | |||
@@ -1,294 +1,294 @@ | |||
1 | /* | 1 | /* |
2 | libvcard - vCard parsing library for vCard version 3.0 | 2 | libvcard - vCard parsing library for vCard version 3.0 |
3 | 3 | ||
4 | Copyright (C) 1998 Rik Hemsley rik@kde.org | 4 | Copyright (C) 1998 Rik Hemsley rik@kde.org |
5 | 5 | ||
6 | Permission is hereby granted, free of charge, to any person obtaining a copy | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | of this software and associated documentation files (the "Software"), to | 7 | of this software and associated documentation files (the "Software"), to |
8 | deal in the Software without restriction, including without limitation the | 8 | deal in the Software without restriction, including without limitation the |
9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | 9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
10 | sell copies of the Software, and to permit persons to whom the Software is | 10 | sell copies of the Software, and to permit persons to whom the Software is |
11 | furnished to do so, subject to the following conditions: | 11 | furnished to do so, subject to the following conditions: |
12 | 12 | ||
13 | The above copyright notice and this permission notice shall be included in | 13 | The above copyright notice and this permission notice shall be included in |
14 | all copies or substantial portions of the Software. | 14 | all copies or substantial portions of the Software. |
15 | 15 | ||
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | 19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | 20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qcstring.h> | 24 | #include <qcstring.h> |
25 | #include <qstrlist.h> | 25 | #include <qstrlist.h> |
26 | #include <qstringlist.h> | 26 | #include <qstringlist.h> |
27 | #include <qstring.h> | 27 | #include <qstring.h> |
28 | #include <qvaluelist.h> | 28 | #include <qvaluelist.h> |
29 | 29 | ||
30 | #include <VCardEntity.h> | 30 | #include <VCardEntity.h> |
31 | #include <VCardVCard.h> | 31 | #include <VCardVCard.h> |
32 | #include <VCardContentLine.h> | 32 | #include <VCardContentLine.h> |
33 | #include <VCardRToken.h> | 33 | #include <VCardRToken.h> |
34 | 34 | ||
35 | #include <VCardDefines.h> | 35 | #include <VCardDefines.h> |
36 | 36 | ||
37 | using namespace VCARD; | 37 | using namespace VCARD; |
38 | 38 | ||
39 | VCard::VCard() | 39 | VCard::VCard() |
40 | :Entity() | 40 | :Entity() |
41 | { | 41 | { |
42 | contentLineList_.setAutoDelete( TRUE ); | 42 | contentLineList_.setAutoDelete( TRUE ); |
43 | } | 43 | } |
44 | 44 | ||
45 | VCard::VCard(const VCard & x) | 45 | VCard::VCard(const VCard & x) |
46 | :Entity(x), | 46 | :Entity(x), |
47 | group_(x.group_) | 47 | group_(x.group_) |
48 | { | 48 | { |
49 | contentLineList_.setAutoDelete( TRUE ); | 49 | contentLineList_.setAutoDelete( TRUE ); |
50 | 50 | ||
51 | QPtrListIterator<ContentLine> it(x.contentLineList_); | 51 | QPtrListIterator<ContentLine> it(x.contentLineList_); |
52 | for (; it.current(); ++it) { | 52 | for (; it.current(); ++it) { |
53 | ContentLine * c = new ContentLine(*it.current()); | 53 | ContentLine * c = new ContentLine(*it.current()); |
54 | contentLineList_.append(c); | 54 | contentLineList_.append(c); |
55 | } | 55 | } |
56 | 56 | ||
57 | } | 57 | } |
58 | 58 | ||
59 | VCard::VCard(const QCString & s) | 59 | VCard::VCard(const QCString & s) |
60 | :Entity(s) | 60 | :Entity(s) |
61 | { | 61 | { |
62 | contentLineList_.setAutoDelete( TRUE ); | 62 | contentLineList_.setAutoDelete( TRUE ); |
63 | } | 63 | } |
64 | 64 | ||
65 | VCard & | 65 | VCard & |
66 | VCard::operator = (VCard & x) | 66 | VCard::operator = (VCard & x) |
67 | { | 67 | { |
68 | if (*this == x) return *this; | 68 | if (*this == x) return *this; |
69 | 69 | ||
70 | group_ = x.group(); | 70 | group_ = x.group(); |
71 | QPtrListIterator<ContentLine> it(x.contentLineList_); | 71 | QPtrListIterator<ContentLine> it(x.contentLineList_); |
72 | for (; it.current(); ++it) { | 72 | for (; it.current(); ++it) { |
73 | ContentLine * c = new ContentLine(*it.current()); | 73 | ContentLine * c = new ContentLine(*it.current()); |
74 | contentLineList_.append(c); | 74 | contentLineList_.append(c); |
75 | } | 75 | } |
76 | 76 | ||
77 | Entity::operator = (x); | 77 | Entity::operator = (x); |
78 | return *this; | 78 | return *this; |
79 | } | 79 | } |
80 | 80 | ||
81 | VCard & | 81 | VCard & |
82 | VCard::operator = (const QCString & s) | 82 | VCard::operator = (const QCString & s) |
83 | { | 83 | { |
84 | Entity::operator = (s); | 84 | Entity::operator = (s); |
85 | return *this; | 85 | return *this; |
86 | } | 86 | } |
87 | 87 | ||
88 | bool | 88 | bool |
89 | VCard::operator == (VCard & x) | 89 | VCard::operator == (VCard & x) |
90 | { | 90 | { |
91 | x.parse(); | 91 | x.parse(); |
92 | return false; | 92 | return false; |
93 | } | 93 | } |
94 | 94 | ||
95 | VCard::~VCard() | 95 | VCard::~VCard() |
96 | { | 96 | { |
97 | } | 97 | } |
98 | 98 | ||
99 | void | 99 | void |
100 | VCard::_parse() | 100 | VCard::_parse() |
101 | { | 101 | { |
102 | 102 | ||
103 | QStringList l; | 103 | QStringList l; |
104 | QStrList sl; | 104 | QStrList sl; |
105 | 105 | ||
106 | RTokenise(strRep_, "\r\n", sl); | 106 | RTokenise(strRep_, "\r\n", sl); |
107 | 107 | ||
108 | if (sl.count() < 3) { // Invalid VCARD ! | 108 | if (sl.count() < 3) { // Invalid VCARD ! |
109 | //qDebug("invalid vcard "); | 109 | //qDebug("invalid vcard "); |
110 | return; | 110 | return; |
111 | } | 111 | } |
112 | l = QStringList::fromStrList( sl ); | 112 | l = QStringList::fromStrList( sl ); |
113 | // Get the first line | 113 | // Get the first line |
114 | QString beginLine = l[0].stripWhiteSpace(); | 114 | QString beginLine = l[0].stripWhiteSpace(); |
115 | 115 | ||
116 | // Remove extra blank lines | 116 | // Remove extra blank lines |
117 | while (l.last().isEmpty()) | 117 | while (l.last().isEmpty()) |
118 | l.remove(l.last()); | 118 | l.remove(l.last()); |
119 | 119 | ||
120 | // Now we know this is the last line | 120 | // Now we know this is the last line |
121 | QString endLine = l.last(); | 121 | QString endLine = l.last(); |
122 | 122 | ||
123 | // Trash the first and last lines as we have seen them. | 123 | // Trash the first and last lines as we have seen them. |
124 | l.remove(l.begin()); | 124 | l.remove(l.begin()); |
125 | l.remove(l.last()); | 125 | l.remove(l.last()); |
126 | 126 | ||
127 | /////////////////////////////////////////////////////////////// | 127 | /////////////////////////////////////////////////////////////// |
128 | // FIRST LINE | 128 | // FIRST LINE |
129 | 129 | ||
130 | int split = beginLine.find(':'); | 130 | int split = beginLine.find(':'); |
131 | 131 | ||
132 | if (split == -1) { // invalid, no BEGIN | 132 | if (split == -1) { // invalid, no BEGIN |
133 | vDebug("No split"); | 133 | vDebug("No split"); |
134 | return; | 134 | return; |
135 | } | 135 | } |
136 | 136 | ||
137 | QString firstPart(beginLine.left(split)); | 137 | QString firstPart(beginLine.left(split)); |
138 | QString valuePart(beginLine.mid(split + 1)); | 138 | QString valuePart(beginLine.mid(split + 1)); |
139 | 139 | ||
140 | split = firstPart.find('.'); | 140 | split = firstPart.find('.'); |
141 | 141 | ||
142 | if (split != -1) { | 142 | if (split != -1) { |
143 | group_ = firstPart.left(split); | 143 | group_ = firstPart.left(split); |
144 | firstPart= firstPart.right(firstPart.length() - split - 1); | 144 | firstPart= firstPart.right(firstPart.length() - split - 1); |
145 | } | 145 | } |
146 | 146 | ||
147 | if (firstPart.left(5) != "BEGIN" ) { // No BEGIN ! | 147 | if (firstPart.left(5) != "BEGIN" ) { // No BEGIN ! |
148 | qDebug("no BEGIN in vcard "); | 148 | qDebug("no BEGIN in vcard "); |
149 | return; | 149 | return; |
150 | } | 150 | } |
151 | 151 | ||
152 | if (valuePart.left(5) != "VCARD") { // Not a vcard ! | 152 | if (valuePart.left(5) != "VCARD") { // Not a vcard ! |
153 | qDebug("not a VCARD "); | 153 | qDebug("not a VCARD "); |
154 | return; | 154 | return; |
155 | } | 155 | } |
156 | 156 | ||
157 | /////////////////////////////////////////////////////////////// | 157 | /////////////////////////////////////////////////////////////// |
158 | // CONTENT LINES | 158 | // CONTENT LINES |
159 | // | 159 | // |
160 | vDebug("Content lines"); | 160 | vDebug("Content lines"); |
161 | 161 | ||
162 | // Handle folded lines. | 162 | // Handle folded lines. |
163 | 163 | ||
164 | QStringList refolded; | 164 | QStringList refolded; |
165 | 165 | ||
166 | 166 | ||
167 | QStringList::Iterator it = l.begin(); | 167 | QStringList::Iterator it = l.begin(); |
168 | 168 | ||
169 | QString cur; | 169 | QString cur; |
170 | 170 | ||
171 | for (; it != l.end(); ++it) { | 171 | for (; it != l.end(); ++it) { |
172 | cur = (*it); | 172 | cur = (*it); |
173 | ++it; | 173 | ++it; |
174 | while ( it!= l.end() && (*it).at(0) == ' '&& (*it).length()!= 1) { | 174 | while ( it!= l.end() && (*it).at(0) == ' '&& (*it).length()!= 1) { |
175 | cur += (*it) ; | 175 | cur += (*it).mid(1) ; |
176 | ++it; | 176 | ++it; |
177 | } | 177 | } |
178 | --it; | 178 | --it; |
179 | refolded.append(cur); | 179 | refolded.append(cur); |
180 | } | 180 | } |
181 | QStringList::Iterator it2 = refolded.begin(); | 181 | QStringList::Iterator it2 = refolded.begin(); |
182 | for (; it2 != refolded.end(); ++it2) { | 182 | for (; it2 != refolded.end(); ++it2) { |
183 | ContentLine * cl = new ContentLine(QCString((*it2).latin1())); | 183 | ContentLine * cl = new ContentLine(QCString((*it2).latin1())); |
184 | cl->parse(); | 184 | cl->parse(); |
185 | if (cl->value() == 0) | 185 | if (cl->value() == 0) |
186 | { | 186 | { |
187 | qDebug("Content line could not be parsed. Discarded: %s", (*it2).latin1()); | 187 | qDebug("Content line could not be parsed. Discarded: %s", (*it2).latin1()); |
188 | delete cl; | 188 | delete cl; |
189 | } | 189 | } |
190 | else | 190 | else |
191 | contentLineList_.append(cl); | 191 | contentLineList_.append(cl); |
192 | } | 192 | } |
193 | 193 | ||
194 | /////////////////////////////////////////////////////////////// | 194 | /////////////////////////////////////////////////////////////// |
195 | // LAST LINE | 195 | // LAST LINE |
196 | 196 | ||
197 | 197 | ||
198 | // LR: sorry, but the remaining code in this method makes no sense | 198 | // LR: sorry, but the remaining code in this method makes no sense |
199 | 199 | ||
200 | #if 0 | 200 | #if 0 |
201 | split = endLine.find(':'); | 201 | split = endLine.find(':'); |
202 | 202 | ||
203 | if (split == -1) // invalid, no END | 203 | if (split == -1) // invalid, no END |
204 | return; | 204 | return; |
205 | 205 | ||
206 | firstPart = endLine.left(split); | 206 | firstPart = endLine.left(split); |
207 | valuePart = endLine.right(firstPart.length() - split - 1); | 207 | valuePart = endLine.right(firstPart.length() - split - 1); |
208 | 208 | ||
209 | split = firstPart.find('.'); | 209 | split = firstPart.find('.'); |
210 | 210 | ||
211 | if (split != -1) { | 211 | if (split != -1) { |
212 | group_ = firstPart.left(split); | 212 | group_ = firstPart.left(split); |
213 | firstPart= firstPart.right(firstPart.length() - split - 1); | 213 | firstPart= firstPart.right(firstPart.length() - split - 1); |
214 | } | 214 | } |
215 | 215 | ||
216 | if (qstricmp(firstPart, "END") != 0) // No END ! | 216 | if (qstricmp(firstPart, "END") != 0) // No END ! |
217 | return; | 217 | return; |
218 | 218 | ||
219 | if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard ! | 219 | if (qstricmp(valuePart, "VCARD") != 0) // Not a vcard ! |
220 | return; | 220 | return; |
221 | #endif | 221 | #endif |
222 | } | 222 | } |
223 | 223 | ||
224 | void | 224 | void |
225 | VCard::_assemble() | 225 | VCard::_assemble() |
226 | { | 226 | { |
227 | vDebug("Assembling vcard"); | 227 | vDebug("Assembling vcard"); |
228 | strRep_ = "BEGIN:VCARD\r\n"; | 228 | strRep_ = "BEGIN:VCARD\r\n"; |
229 | strRep_ += "VERSION:3.0\r\n"; | 229 | strRep_ += "VERSION:3.0\r\n"; |
230 | 230 | ||
231 | QPtrListIterator<ContentLine> it(contentLineList_); | 231 | QPtrListIterator<ContentLine> it(contentLineList_); |
232 | 232 | ||
233 | for (; it.current(); ++it) | 233 | for (; it.current(); ++it) |
234 | strRep_ += it.current()->asString() + "\r\n"; | 234 | strRep_ += it.current()->asString() + "\r\n"; |
235 | 235 | ||
236 | strRep_ += "END:VCARD\r\n"; | 236 | strRep_ += "END:VCARD\r\n"; |
237 | } | 237 | } |
238 | 238 | ||
239 | bool | 239 | bool |
240 | VCard::has(EntityType t) | 240 | VCard::has(EntityType t) |
241 | { | 241 | { |
242 | parse(); | 242 | parse(); |
243 | return contentLine(t) == 0 ? false : true; | 243 | return contentLine(t) == 0 ? false : true; |
244 | } | 244 | } |
245 | 245 | ||
246 | bool | 246 | bool |
247 | VCard::has(const QCString & s) | 247 | VCard::has(const QCString & s) |
248 | { | 248 | { |
249 | parse(); | 249 | parse(); |
250 | return contentLine(s) == 0 ? false : true; | 250 | return contentLine(s) == 0 ? false : true; |
251 | } | 251 | } |
252 | 252 | ||
253 | void | 253 | void |
254 | VCard::add(const ContentLine & cl) | 254 | VCard::add(const ContentLine & cl) |
255 | { | 255 | { |
256 | parse(); | 256 | parse(); |
257 | ContentLine * c = new ContentLine(cl); | 257 | ContentLine * c = new ContentLine(cl); |
258 | contentLineList_.append(c); | 258 | contentLineList_.append(c); |
259 | } | 259 | } |
260 | 260 | ||
261 | void | 261 | void |
262 | VCard::add(const QCString & s) | 262 | VCard::add(const QCString & s) |
263 | { | 263 | { |
264 | parse(); | 264 | parse(); |
265 | ContentLine * c = new ContentLine(s); | 265 | ContentLine * c = new ContentLine(s); |
266 | contentLineList_.append(c); | 266 | contentLineList_.append(c); |
267 | } | 267 | } |
268 | 268 | ||
269 | ContentLine * | 269 | ContentLine * |
270 | VCard::contentLine(EntityType t) | 270 | VCard::contentLine(EntityType t) |
271 | { | 271 | { |
272 | parse(); | 272 | parse(); |
273 | QPtrListIterator<ContentLine> it(contentLineList_); | 273 | QPtrListIterator<ContentLine> it(contentLineList_); |
274 | 274 | ||
275 | for (; it.current(); ++it) | 275 | for (; it.current(); ++it) |
276 | if (it.current()->entityType() == t) | 276 | if (it.current()->entityType() == t) |
277 | return it.current(); | 277 | return it.current(); |
278 | 278 | ||
279 | return 0; | 279 | return 0; |
280 | } | 280 | } |
281 | 281 | ||
282 | ContentLine * | 282 | ContentLine * |
283 | VCard::contentLine(const QCString & s) | 283 | VCard::contentLine(const QCString & s) |
284 | { | 284 | { |
285 | parse(); | 285 | parse(); |
286 | QPtrListIterator<ContentLine> it(contentLineList_); | 286 | QPtrListIterator<ContentLine> it(contentLineList_); |
287 | 287 | ||
288 | for (; it.current(); ++it) | 288 | for (; it.current(); ++it) |
289 | if (it.current()->entityType() == EntityNameToEntityType(s)) | 289 | if (it.current()->entityType() == EntityNameToEntityType(s)) |
290 | return it.current(); | 290 | return it.current(); |
291 | 291 | ||
292 | return 0; | 292 | return 0; |
293 | } | 293 | } |
294 | 294 | ||
diff --git a/kaddressbook/filter.cpp b/kaddressbook/filter.cpp index 9cb4c2d..7a869fa 100644 --- a/kaddressbook/filter.cpp +++ b/kaddressbook/filter.cpp | |||
@@ -1,228 +1,228 @@ | |||
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 | #include <kconfig.h> | 24 | #include <kconfig.h> |
25 | #include <kconfigbase.h> | 25 | #include <kconfigbase.h> |
26 | #include <kdebug.h> | 26 | #include <kdebug.h> |
27 | 27 | ||
28 | #include "kabprefs.h" | 28 | #include "kabprefs.h" |
29 | 29 | ||
30 | #include "filter.h" | 30 | #include "filter.h" |
31 | #include <secrecy.h> | 31 | #include <secrecy.h> |
32 | 32 | ||
33 | Filter::Filter() | 33 | Filter::Filter() |
34 | : mName( QString::null ), mMatchRule( Matching ), mEnabled( true ), | 34 | : mName( QString::null ), mMatchRule( Matching ), mEnabled( true ), |
35 | mInternal( false ) | 35 | mInternal( false ) |
36 | { | 36 | { |
37 | mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; | 37 | mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; |
38 | } | 38 | } |
39 | 39 | ||
40 | Filter::Filter( const QString &name ) | 40 | Filter::Filter( const QString &name ) |
41 | : mName( name ), mMatchRule( Matching ), mEnabled( true ), | 41 | : mName( name ), mMatchRule( Matching ), mEnabled( true ), |
42 | mInternal( false ) | 42 | mInternal( false ) |
43 | { | 43 | { |
44 | mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; | 44 | mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; |
45 | } | 45 | } |
46 | 46 | ||
47 | Filter::~Filter() | 47 | Filter::~Filter() |
48 | { | 48 | { |
49 | } | 49 | } |
50 | 50 | ||
51 | void Filter::setName( const QString &name ) | 51 | void Filter::setName( const QString &name ) |
52 | { | 52 | { |
53 | mName = name; | 53 | mName = name; |
54 | } | 54 | } |
55 | 55 | ||
56 | const QString &Filter::name() const | 56 | const QString &Filter::name() const |
57 | { | 57 | { |
58 | return mName; | 58 | return mName; |
59 | } | 59 | } |
60 | 60 | ||
61 | bool Filter::isInternal() const | 61 | bool Filter::isInternal() const |
62 | { | 62 | { |
63 | return mInternal; | 63 | return mInternal; |
64 | } | 64 | } |
65 | 65 | ||
66 | void Filter::apply( KABC::Addressee::List &addresseeList ) | 66 | void Filter::apply( KABC::Addressee::List &addresseeList ) |
67 | { | 67 | { |
68 | KABC::Addressee::List::Iterator iter; | 68 | KABC::Addressee::List::Iterator iter; |
69 | for ( iter = addresseeList.begin(); iter != addresseeList.end(); ) { | 69 | for ( iter = addresseeList.begin(); iter != addresseeList.end(); ) { |
70 | if ( filterAddressee( *iter ) ) | 70 | if ( filterAddressee( *iter ) ) |
71 | ++iter; | 71 | ++iter; |
72 | else | 72 | else |
73 | { | 73 | { |
74 | #ifndef KAB_EMBEDDED | 74 | #ifndef KAB_EMBEDDED |
75 | iter = addresseeList.erase( iter ); | 75 | iter = addresseeList.erase( iter ); |
76 | #else //KAB_EMBEDDED | 76 | #else //KAB_EMBEDDED |
77 | iter = addresseeList.remove( iter ); | 77 | iter = addresseeList.remove( iter ); |
78 | #endif //KAB_EMBEDDED | 78 | #endif //KAB_EMBEDDED |
79 | } | 79 | } |
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | bool Filter::filterAddressee( const KABC::Addressee &a ) | 83 | bool Filter::filterAddressee( const KABC::Addressee &a ) |
84 | { | 84 | { |
85 | switch ( a.secrecy().type()) { | 85 | switch ( a.secrecy().type()) { |
86 | case KABC::Secrecy::Public: | 86 | case KABC::Secrecy::Public: |
87 | if (! (mCriteria & ShowPublic )) | 87 | if (! (mCriteria & ShowPublic )) |
88 | return false; | 88 | return false; |
89 | break; | 89 | break; |
90 | case KABC::Secrecy::Private: | 90 | case KABC::Secrecy::Private: |
91 | if (! (mCriteria & ShowPrivate )) | 91 | if (! (mCriteria & ShowPrivate )) |
92 | return false; | 92 | return false; |
93 | break; | 93 | break; |
94 | case KABC::Secrecy::Confidential: | 94 | case KABC::Secrecy::Confidential: |
95 | if (! (mCriteria & ShowConfidential )) | 95 | if (! (mCriteria & ShowConfidential )) |
96 | return false; | 96 | return false; |
97 | break; | 97 | break; |
98 | default: | 98 | default: |
99 | return false; | 99 | return false; |
100 | break; | 100 | break; |
101 | } | 101 | } |
102 | QStringList::Iterator iter; | 102 | QStringList::Iterator iter; |
103 | iter = mCategoryList.begin(); | 103 | iter = mCategoryList.begin(); |
104 | // empty filter always matches | 104 | // empty filter always matches |
105 | 105 | ||
106 | if ( iter == mCategoryList.end() ) | 106 | if ( iter == mCategoryList.end() ) |
107 | return true; | 107 | return true; |
108 | 108 | ||
109 | for ( ; iter != mCategoryList.end(); ++iter ) { | 109 | for ( ; iter != mCategoryList.end(); ++iter ) { |
110 | if ( a.hasCategory( *iter ) ) | 110 | if ( a.hasCategory( *iter ) ) |
111 | return ( mMatchRule == Matching ); | 111 | return ( mMatchRule == Matching ); |
112 | } | 112 | } |
113 | 113 | ||
114 | return !( mMatchRule == Matching ); | 114 | return !( mMatchRule == Matching ); |
115 | } | 115 | } |
116 | 116 | ||
117 | void Filter::setEnabled( bool on ) | 117 | void Filter::setEnabled( bool on ) |
118 | { | 118 | { |
119 | mEnabled = on; | 119 | mEnabled = on; |
120 | } | 120 | } |
121 | 121 | ||
122 | bool Filter::isEnabled() const | 122 | bool Filter::isEnabled() const |
123 | { | 123 | { |
124 | return mEnabled; | 124 | return mEnabled; |
125 | } | 125 | } |
126 | 126 | ||
127 | void Filter::setCategories( const QStringList &list ) | 127 | void Filter::setCategories( const QStringList &list ) |
128 | { | 128 | { |
129 | mCategoryList = list; | 129 | mCategoryList = list; |
130 | } | 130 | } |
131 | 131 | ||
132 | const QStringList &Filter::categories() const | 132 | const QStringList &Filter::categories() const |
133 | { | 133 | { |
134 | return mCategoryList; | 134 | return mCategoryList; |
135 | } | 135 | } |
136 | 136 | ||
137 | void Filter::save( KConfig *config ) | 137 | void Filter::save( KConfig *config ) |
138 | { | 138 | { |
139 | config->writeEntry( "Name", mName ); | 139 | config->writeEntry( "Name", mName ); |
140 | config->writeEntry( "Enabled", mEnabled ); | 140 | config->writeEntry( "Enabled", mEnabled ); |
141 | config->writeEntry( "Categories", mCategoryList ); | 141 | config->writeEntry( "Categories", mCategoryList ); |
142 | config->writeEntry( "MatchRule", (int)mMatchRule ); | 142 | config->writeEntry( "MatchRule", (int)mMatchRule ); |
143 | config->writeEntry( "Criteria", (int)mCriteria ); | 143 | config->writeEntry( "Criteria", (int)mCriteria ); |
144 | } | 144 | } |
145 | 145 | ||
146 | void Filter::restore( KConfig *config ) | 146 | void Filter::restore( KConfig *config ) |
147 | { | 147 | { |
148 | mName = config->readEntry( "Name", "<internal error>" ); | 148 | mName = config->readEntry( "Name", "<internal error>" ); |
149 | mEnabled = config->readBoolEntry( "Enabled", true ); | 149 | mEnabled = config->readBoolEntry( "Enabled", true ); |
150 | mCategoryList = config->readListEntry( "Categories" ); | 150 | mCategoryList = config->readListEntry( "Categories" ); |
151 | mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching ); | 151 | mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching ); |
152 | mCriteria = config->readNumEntry( "Criteria", (ShowPublic | ShowPrivate| ShowConfidential) ); | 152 | mCriteria = config->readNumEntry( "Criteria", (ShowPublic | ShowPrivate| ShowConfidential ) ); |
153 | } | 153 | } |
154 | 154 | ||
155 | void Filter::save( KConfig *config, QString baseGroup, Filter::List &list ) | 155 | void Filter::save( KConfig *config, QString baseGroup, Filter::List &list ) |
156 | { | 156 | { |
157 | { | 157 | { |
158 | KConfigGroupSaver s( config, baseGroup ); | 158 | KConfigGroupSaver s( config, baseGroup ); |
159 | 159 | ||
160 | // remove the old filters | 160 | // remove the old filters |
161 | uint count = config->readNumEntry( "Count" ); | 161 | uint count = config->readNumEntry( "Count" ); |
162 | /* // memory access violation here | 162 | /* // memory access violation here |
163 | for ( uint i = 0; i < count; ++i ) | 163 | for ( uint i = 0; i < count; ++i ) |
164 | config->deleteGroup( QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); | 164 | config->deleteGroup( QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); |
165 | */ | 165 | */ |
166 | } | 166 | } |
167 | 167 | ||
168 | int index = 0; | 168 | int index = 0; |
169 | Filter::List::Iterator iter; | 169 | Filter::List::Iterator iter; |
170 | for ( iter = list.begin(); iter != list.end(); ++iter ) { | 170 | for ( iter = list.begin(); iter != list.end(); ++iter ) { |
171 | if ( !(*iter).mInternal ) { | 171 | if ( !(*iter).mInternal ) { |
172 | KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( index ) ); | 172 | KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( index ) ); |
173 | 173 | ||
174 | (*iter).save( config ); | 174 | (*iter).save( config ); |
175 | index++; | 175 | index++; |
176 | } | 176 | } |
177 | } | 177 | } |
178 | 178 | ||
179 | KConfigGroupSaver s( config, baseGroup ); | 179 | KConfigGroupSaver s( config, baseGroup ); |
180 | 180 | ||
181 | config->writeEntry( "Count", index ); | 181 | config->writeEntry( "Count", index ); |
182 | 182 | ||
183 | } | 183 | } |
184 | 184 | ||
185 | Filter::List Filter::restore( KConfig *config, QString baseGroup ) | 185 | Filter::List Filter::restore( KConfig *config, QString baseGroup ) |
186 | { | 186 | { |
187 | Filter::List list; | 187 | Filter::List list; |
188 | int count = 0; | 188 | int count = 0; |
189 | Filter f; | 189 | Filter f; |
190 | 190 | ||
191 | { | 191 | { |
192 | KConfigGroupSaver s( config, baseGroup ); | 192 | KConfigGroupSaver s( config, baseGroup ); |
193 | count = config->readNumEntry( "Count", 0 ); | 193 | count = config->readNumEntry( "Count", 0 ); |
194 | } | 194 | } |
195 | 195 | ||
196 | for ( int i = 0; i < count; i++ ) { | 196 | for ( int i = 0; i < count; i++ ) { |
197 | { | 197 | { |
198 | KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); | 198 | KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); |
199 | f.restore( config ); | 199 | f.restore( config ); |
200 | } | 200 | } |
201 | 201 | ||
202 | list.append( f ); | 202 | list.append( f ); |
203 | } | 203 | } |
204 | 204 | ||
205 | if ( list.isEmpty()) { | 205 | if ( list.isEmpty()) { |
206 | QStringList cats = KABPrefs::instance()->mCustomCategories; | 206 | QStringList cats = KABPrefs::instance()->mCustomCategories; |
207 | for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { | 207 | for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { |
208 | Filter filter; | 208 | Filter filter; |
209 | filter.mName = *it; | 209 | filter.mName = *it; |
210 | filter.mEnabled = true; | 210 | filter.mEnabled = true; |
211 | filter.mCategoryList = *it; | 211 | filter.mCategoryList = *it; |
212 | filter.mMatchRule = Matching; | 212 | filter.mMatchRule = Matching; |
213 | filter.mInternal = true; | 213 | filter.mInternal = true; |
214 | list.append( filter ); | 214 | list.append( filter ); |
215 | } | 215 | } |
216 | } | 216 | } |
217 | return list; | 217 | return list; |
218 | } | 218 | } |
219 | 219 | ||
220 | void Filter::setMatchRule( MatchRule rule ) | 220 | void Filter::setMatchRule( MatchRule rule ) |
221 | { | 221 | { |
222 | mMatchRule = rule; | 222 | mMatchRule = rule; |
223 | } | 223 | } |
224 | 224 | ||
225 | Filter::MatchRule Filter::matchRule() const | 225 | Filter::MatchRule Filter::matchRule() const |
226 | { | 226 | { |
227 | return mMatchRule; | 227 | return mMatchRule; |
228 | } | 228 | } |
diff --git a/kaddressbook/filter.h b/kaddressbook/filter.h index 26870d7..93f1352 100644 --- a/kaddressbook/filter.h +++ b/kaddressbook/filter.h | |||
@@ -1,157 +1,157 @@ | |||
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 FILTER_H | 24 | #ifndef FILTER_H |
25 | #define FILTER_H | 25 | #define FILTER_H |
26 | 26 | ||
27 | #include <qstring.h> | 27 | #include <qstring.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <qvaluelist.h> | 29 | #include <qvaluelist.h> |
30 | 30 | ||
31 | #include <kabc/addressee.h> | 31 | #include <kabc/addressee.h> |
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | 33 | ||
34 | /** | 34 | /** |
35 | Filter for AddressBook related objects (Addressees) | 35 | Filter for AddressBook related objects (Addressees) |
36 | 36 | ||
37 | @todo This class should be switched to use shared data. | 37 | @todo This class should be switched to use shared data. |
38 | */ | 38 | */ |
39 | class Filter | 39 | class Filter |
40 | { | 40 | { |
41 | public: | 41 | public: |
42 | enum { ShowPublic = 1, ShowPrivate = 2, ShowConfidential = 4}; | 42 | enum { ShowPublic = 1, ShowPrivate = 2, ShowConfidential = 4 }; |
43 | void setCriteria(int c) { mCriteria = c ;} | 43 | void setCriteria(int c) { mCriteria = c ;} |
44 | int criteria() const { return mCriteria;} | 44 | int criteria() const { return mCriteria;} |
45 | typedef QValueList<Filter> List; | 45 | typedef QValueList<Filter> List; |
46 | 46 | ||
47 | enum MatchRule { Matching = 0, NotMatching = 1 }; | 47 | enum MatchRule { Matching = 0, NotMatching = 1 }; |
48 | 48 | ||
49 | Filter(); | 49 | Filter(); |
50 | Filter( const QString& name ); | 50 | Filter( const QString& name ); |
51 | ~Filter(); | 51 | ~Filter(); |
52 | 52 | ||
53 | /** | 53 | /** |
54 | Set the name of the filter. | 54 | Set the name of the filter. |
55 | */ | 55 | */ |
56 | void setName( const QString &name ); | 56 | void setName( const QString &name ); |
57 | 57 | ||
58 | /** | 58 | /** |
59 | @return The name of the filter. | 59 | @return The name of the filter. |
60 | */ | 60 | */ |
61 | const QString &name() const; | 61 | const QString &name() const; |
62 | 62 | ||
63 | /** | 63 | /** |
64 | @return Whether the filter is an internal one. | 64 | @return Whether the filter is an internal one. |
65 | */ | 65 | */ |
66 | bool isInternal() const; | 66 | bool isInternal() const; |
67 | 67 | ||
68 | /** | 68 | /** |
69 | Apply the filter to the addressee list. All addressees not passing | 69 | Apply the filter to the addressee list. All addressees not passing |
70 | the filter criterias will be removed from the list. | 70 | the filter criterias will be removed from the list. |
71 | 71 | ||
72 | If the MatchRule is NotMatch, then all the addressees matching the | 72 | If the MatchRule is NotMatch, then all the addressees matching the |
73 | filter will be removed from the list. | 73 | filter will be removed from the list. |
74 | */ | 74 | */ |
75 | void apply( KABC::Addressee::List &addresseeList ); | 75 | void apply( KABC::Addressee::List &addresseeList ); |
76 | 76 | ||
77 | /** | 77 | /** |
78 | Apply the filter to the addressee. | 78 | Apply the filter to the addressee. |
79 | 79 | ||
80 | @return True if the addressee passes the criteria, false otherwise. | 80 | @return True if the addressee passes the criteria, false otherwise. |
81 | The return values are opposite if the MatchRule is NotMatch. | 81 | The return values are opposite if the MatchRule is NotMatch. |
82 | */ | 82 | */ |
83 | bool filterAddressee( const KABC::Addressee &a ); | 83 | bool filterAddressee( const KABC::Addressee &a ); |
84 | 84 | ||
85 | /** | 85 | /** |
86 | Enable or disable the filter | 86 | Enable or disable the filter |
87 | */ | 87 | */ |
88 | void setEnabled( bool on ); | 88 | void setEnabled( bool on ); |
89 | 89 | ||
90 | /** | 90 | /** |
91 | @return True if this filter is enabled, false otherwise. | 91 | @return True if this filter is enabled, false otherwise. |
92 | */ | 92 | */ |
93 | bool isEnabled() const; | 93 | bool isEnabled() const; |
94 | 94 | ||
95 | /** | 95 | /** |
96 | Set the list of categories. This list is used to filter addressees. | 96 | Set the list of categories. This list is used to filter addressees. |
97 | */ | 97 | */ |
98 | void setCategories( const QStringList &list ); | 98 | void setCategories( const QStringList &list ); |
99 | 99 | ||
100 | /** | 100 | /** |
101 | @return The list of categories. | 101 | @return The list of categories. |
102 | */ | 102 | */ |
103 | const QStringList &categories() const; | 103 | const QStringList &categories() const; |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Saves the filter to the config file. The group should already be set. | 106 | Saves the filter to the config file. The group should already be set. |
107 | */ | 107 | */ |
108 | void save( KConfig *config ); | 108 | void save( KConfig *config ); |
109 | 109 | ||
110 | /** | 110 | /** |
111 | Loads the filter from the config file. The group should already be set. | 111 | Loads the filter from the config file. The group should already be set. |
112 | */ | 112 | */ |
113 | void restore( KConfig *config ); | 113 | void restore( KConfig *config ); |
114 | 114 | ||
115 | /** | 115 | /** |
116 | Saves a list of filters to the config file. | 116 | Saves a list of filters to the config file. |
117 | 117 | ||
118 | @param config The config file to use | 118 | @param config The config file to use |
119 | @param baseGroup The base groupname to use. The number of filters | 119 | @param baseGroup The base groupname to use. The number of filters |
120 | will be written to this group, then a _1, _2, etc | 120 | will be written to this group, then a _1, _2, etc |
121 | will be append for each filter saved. | 121 | will be append for each filter saved. |
122 | @param list The list of filters to be saved. | 122 | @param list The list of filters to be saved. |
123 | */ | 123 | */ |
124 | static void save( KConfig *config, QString baseGroup, Filter::List &list ); | 124 | static void save( KConfig *config, QString baseGroup, Filter::List &list ); |
125 | 125 | ||
126 | /** | 126 | /** |
127 | Restores a list of filters from a config file. | 127 | Restores a list of filters from a config file. |
128 | 128 | ||
129 | @param config The config file to read from. | 129 | @param config The config file to read from. |
130 | @param baseGroup The base group name to be used to find the filters | 130 | @param baseGroup The base group name to be used to find the filters |
131 | 131 | ||
132 | @return The list of filters. | 132 | @return The list of filters. |
133 | */ | 133 | */ |
134 | static Filter::List restore( KConfig *config, QString baseGroup ); | 134 | static Filter::List restore( KConfig *config, QString baseGroup ); |
135 | 135 | ||
136 | /** | 136 | /** |
137 | Sets the filter rule. If the rule is Filter::Matching (default), | 137 | Sets the filter rule. If the rule is Filter::Matching (default), |
138 | then the filter will return true on items that match the filter. | 138 | then the filter will return true on items that match the filter. |
139 | If the rule is Filter::NotMatching, then the filter will return | 139 | If the rule is Filter::NotMatching, then the filter will return |
140 | true on items that do not match the filter. | 140 | true on items that do not match the filter. |
141 | */ | 141 | */ |
142 | void setMatchRule( MatchRule rule ); | 142 | void setMatchRule( MatchRule rule ); |
143 | 143 | ||
144 | /** @return The current match rule. | 144 | /** @return The current match rule. |
145 | */ | 145 | */ |
146 | MatchRule matchRule() const; | 146 | MatchRule matchRule() const; |
147 | 147 | ||
148 | private: | 148 | private: |
149 | int mCriteria; | 149 | int mCriteria; |
150 | QString mName; | 150 | QString mName; |
151 | QStringList mCategoryList; | 151 | QStringList mCategoryList; |
152 | MatchRule mMatchRule; | 152 | MatchRule mMatchRule; |
153 | bool mEnabled; | 153 | bool mEnabled; |
154 | bool mInternal; | 154 | bool mInternal; |
155 | }; | 155 | }; |
156 | 156 | ||
157 | #endif | 157 | #endif |
diff --git a/kaddressbook/filtereditdialog.cpp b/kaddressbook/filtereditdialog.cpp index 987f234..1194406 100644 --- a/kaddressbook/filtereditdialog.cpp +++ b/kaddressbook/filtereditdialog.cpp | |||
@@ -1,316 +1,315 @@ | |||
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 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <qbuttongroup.h> | 31 | #include <qbuttongroup.h> |
32 | #include <qhbox.h> | 32 | #include <qhbox.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qradiobutton.h> | 36 | #include <qradiobutton.h> |
37 | #include <qcheckbox.h> | 37 | #include <qcheckbox.h> |
38 | #include <qregexp.h> | 38 | #include <qregexp.h> |
39 | #include <qstring.h> | 39 | #include <qstring.h> |
40 | #include <qtoolbutton.h> | 40 | #include <qtoolbutton.h> |
41 | #include <qtooltip.h> | 41 | #include <qtooltip.h> |
42 | #include <qwidget.h> | 42 | #include <qwidget.h> |
43 | 43 | ||
44 | #include <kapplication.h> | 44 | #include <kapplication.h> |
45 | #include <kbuttonbox.h> | 45 | #include <kbuttonbox.h> |
46 | #include <kdebug.h> | 46 | #include <kdebug.h> |
47 | #include <kiconloader.h> | 47 | #include <kiconloader.h> |
48 | #include <klineedit.h> | 48 | #include <klineedit.h> |
49 | #include <klistbox.h> | 49 | #include <klistbox.h> |
50 | #include <klistview.h> | 50 | #include <klistview.h> |
51 | #include <klocale.h> | 51 | #include <klocale.h> |
52 | #include <kglobal.h> | 52 | #include <kglobal.h> |
53 | 53 | ||
54 | #include "kabprefs.h" | 54 | #include "kabprefs.h" |
55 | #include "filtereditdialog.h" | 55 | #include "filtereditdialog.h" |
56 | 56 | ||
57 | FilterEditDialog::FilterEditDialog( QWidget *parent, const char *name ) | 57 | FilterEditDialog::FilterEditDialog( QWidget *parent, const char *name ) |
58 | : KDialogBase( Plain, i18n( "Edit Address Book Filter" ), | 58 | : KDialogBase( Plain, i18n( "Edit Address Book Filter" ), |
59 | Help | Ok | Cancel, Ok, parent, name, /*US false*/ true, true ) | 59 | Help | Ok | Cancel, Ok, parent, name, /*US false*/ true, true ) |
60 | { | 60 | { |
61 | initGUI(); | 61 | initGUI(); |
62 | 62 | ||
63 | QStringList cats = KABPrefs::instance()->mCustomCategories; | 63 | QStringList cats = KABPrefs::instance()->mCustomCategories; |
64 | 64 | ||
65 | QStringList::Iterator iter; | 65 | QStringList::Iterator iter; |
66 | for ( iter = cats.begin(); iter != cats.end(); ++iter ) | 66 | for ( iter = cats.begin(); iter != cats.end(); ++iter ) |
67 | mCategoriesView->insertItem( new QCheckListItem( mCategoriesView, (*iter), QCheckListItem::CheckBox ) ); | 67 | mCategoriesView->insertItem( new QCheckListItem( mCategoriesView, (*iter), QCheckListItem::CheckBox ) ); |
68 | filterNameTextChanged( mNameEdit->text() ); | 68 | filterNameTextChanged( mNameEdit->text() ); |
69 | } | 69 | } |
70 | 70 | ||
71 | FilterEditDialog::~FilterEditDialog() | 71 | FilterEditDialog::~FilterEditDialog() |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | void FilterEditDialog::setFilter( const Filter &filter ) | 75 | void FilterEditDialog::setFilter( const Filter &filter ) |
76 | { | 76 | { |
77 | mNameEdit->setText( filter.name() ); | 77 | mNameEdit->setText( filter.name() ); |
78 | 78 | ||
79 | QStringList categories = filter.categories(); | 79 | QStringList categories = filter.categories(); |
80 | QListViewItem *item = mCategoriesView->firstChild(); | 80 | QListViewItem *item = mCategoriesView->firstChild(); |
81 | while ( item != 0 ) { | 81 | while ( item != 0 ) { |
82 | if ( categories.contains( item->text( 0 ) ) ) { | 82 | if ( categories.contains( item->text( 0 ) ) ) { |
83 | QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); | 83 | QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); |
84 | checkItem->setOn( true ); | 84 | checkItem->setOn( true ); |
85 | } | 85 | } |
86 | 86 | ||
87 | item = item->nextSibling(); | 87 | item = item->nextSibling(); |
88 | } | 88 | } |
89 | 89 | ||
90 | if ( filter.matchRule() == Filter::Matching ) | 90 | if ( filter.matchRule() == Filter::Matching ) |
91 | mMatchRuleGroup->setButton( 0 ); | 91 | mMatchRuleGroup->setButton( 0 ); |
92 | else | 92 | else |
93 | mMatchRuleGroup->setButton( 1 ); | 93 | mMatchRuleGroup->setButton( 1 ); |
94 | 94 | ||
95 | int c = filter.criteria() ; | 95 | int c = filter.criteria() ; |
96 | mPublic->setChecked(c &Filter::ShowPublic); | 96 | mPublic->setChecked(c &Filter::ShowPublic); |
97 | mPrivate->setChecked(c & Filter::ShowPrivate); | 97 | mPrivate->setChecked(c & Filter::ShowPrivate); |
98 | mConfidential->setChecked(c & Filter::ShowConfidential); | 98 | mConfidential->setChecked(c & Filter::ShowConfidential); |
99 | |||
100 | } | 99 | } |
101 | 100 | ||
102 | Filter FilterEditDialog::filter() | 101 | Filter FilterEditDialog::filter() |
103 | { | 102 | { |
104 | Filter filter; | 103 | Filter filter; |
105 | 104 | ||
106 | filter.setName( mNameEdit->text() ); | 105 | filter.setName( mNameEdit->text() ); |
107 | 106 | ||
108 | QStringList categories; | 107 | QStringList categories; |
109 | QListViewItem *item = mCategoriesView->firstChild(); | 108 | QListViewItem *item = mCategoriesView->firstChild(); |
110 | while ( item != 0 ) { | 109 | while ( item != 0 ) { |
111 | QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); | 110 | QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); |
112 | if ( checkItem->isOn() ) | 111 | if ( checkItem->isOn() ) |
113 | categories.append( item->text( 0 ) ); | 112 | categories.append( item->text( 0 ) ); |
114 | 113 | ||
115 | item = item->nextSibling(); | 114 | item = item->nextSibling(); |
116 | } | 115 | } |
117 | filter.setCategories( categories ); | 116 | filter.setCategories( categories ); |
118 | 117 | ||
119 | if ( mMatchRuleGroup->find( 0 )->isOn() ) | 118 | if ( mMatchRuleGroup->find( 0 )->isOn() ) |
120 | filter.setMatchRule( Filter::Matching ); | 119 | filter.setMatchRule( Filter::Matching ); |
121 | else | 120 | else |
122 | filter.setMatchRule( Filter::NotMatching ); | 121 | filter.setMatchRule( Filter::NotMatching ); |
123 | 122 | ||
124 | int c = 0; | 123 | int c = 0; |
125 | if (mPublic->isChecked()) c |= Filter::ShowPublic; | 124 | if (mPublic->isChecked()) c |= Filter::ShowPublic; |
126 | if (mPrivate->isChecked()) c |= Filter::ShowPrivate; | 125 | if (mPrivate->isChecked()) c |= Filter::ShowPrivate; |
127 | if (mConfidential->isChecked()) c |= Filter::ShowConfidential; | 126 | if (mConfidential->isChecked()) c |= Filter::ShowConfidential; |
128 | filter.setCriteria( c ) ; | 127 | filter.setCriteria( c ) ; |
129 | 128 | ||
130 | return filter; | 129 | return filter; |
131 | } | 130 | } |
132 | 131 | ||
133 | void FilterEditDialog::initGUI() | 132 | void FilterEditDialog::initGUI() |
134 | { | 133 | { |
135 | #ifndef KAB_EMBEDDED | 134 | #ifndef KAB_EMBEDDED |
136 | resize( 490, 300 ); | 135 | resize( 490, 300 ); |
137 | #else //KAB_EMBEDDED | 136 | #else //KAB_EMBEDDED |
138 | resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300)); | 137 | resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300)); |
139 | #endif //KAB_EMBEDDED | 138 | #endif //KAB_EMBEDDED |
140 | 139 | ||
141 | 140 | ||
142 | QWidget *page = plainPage(); | 141 | QWidget *page = plainPage(); |
143 | QLabel *label; | 142 | QLabel *label; |
144 | 143 | ||
145 | QGridLayout *topLayout = new QGridLayout( page, 3, 2, 0, spacingHint() ); | 144 | QGridLayout *topLayout = new QGridLayout( page, 3, 2, 0, spacingHint() ); |
146 | 145 | ||
147 | label = new QLabel( i18n( "Name" ), page ); | 146 | label = new QLabel( i18n( "Name" ), page ); |
148 | mNameEdit = new KLineEdit( page ); | 147 | mNameEdit = new KLineEdit( page ); |
149 | mNameEdit->setFocus(); | 148 | mNameEdit->setFocus(); |
150 | topLayout->addWidget( label, 0, 0 ); | 149 | topLayout->addWidget( label, 0, 0 ); |
151 | topLayout->addWidget( mNameEdit, 0, 1 ); | 150 | topLayout->addWidget( mNameEdit, 0, 1 ); |
152 | connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), | 151 | connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), |
153 | SLOT( filterNameTextChanged( const QString&) ) ); | 152 | SLOT( filterNameTextChanged( const QString&) ) ); |
154 | 153 | ||
155 | mCategoriesView = new KListView( page ); | 154 | mCategoriesView = new KListView( page ); |
156 | mCategoriesView->addColumn( i18n( "Categories" ) ); | 155 | mCategoriesView->addColumn( i18n( "Categories" ) ); |
157 | topLayout->addMultiCellWidget( mCategoriesView, 1, 1, 0, 1 ); | 156 | topLayout->addMultiCellWidget( mCategoriesView, 1, 1, 0, 1 ); |
158 | 157 | ||
159 | mMatchRuleGroup = new QHButtonGroup( i18n( "Category rule" ), page ); | 158 | mMatchRuleGroup = new QHButtonGroup( i18n( "Category rule" ), page ); |
160 | mMatchRuleGroup->setExclusive( true ); | 159 | mMatchRuleGroup->setExclusive( true ); |
161 | QRadioButton *radio = new QRadioButton( i18n( "Include categories" ), mMatchRuleGroup ); | 160 | QRadioButton *radio = new QRadioButton( i18n( "Include categories" ), mMatchRuleGroup ); |
162 | radio->setChecked( true ); | 161 | radio->setChecked( true ); |
163 | //mMatchRuleGroup->insert( radio ); | 162 | //mMatchRuleGroup->insert( radio ); |
164 | radio = new QRadioButton( i18n( "Exclude categories" ), mMatchRuleGroup ); | 163 | radio = new QRadioButton( i18n( "Exclude categories" ), mMatchRuleGroup ); |
165 | //mMatchRuleGroup->insert( radio ); | 164 | //mMatchRuleGroup->insert( radio ); |
166 | topLayout->addMultiCellWidget( mMatchRuleGroup, 2, 2, 0, 1 ); | 165 | topLayout->addMultiCellWidget( mMatchRuleGroup, 2, 2, 0, 1 ); |
167 | 166 | ||
168 | QHButtonGroup * mMatchPPCGroup = new QHButtonGroup(i18n( "Include contacts, that are:" ), page ); | 167 | QHButtonGroup * mMatchPPCGroup = new QHButtonGroup(i18n( "Include contacts, that are:" ), page ); |
169 | mPublic = new QCheckBox( i18n( "public" ), mMatchPPCGroup ); | 168 | mPublic = new QCheckBox( i18n( "public" ), mMatchPPCGroup ); |
170 | mPrivate = new QCheckBox( i18n( "private" ), mMatchPPCGroup ); | 169 | mPrivate = new QCheckBox( i18n( "private" ), mMatchPPCGroup ); |
171 | mConfidential = new QCheckBox( i18n( "confidential" ), mMatchPPCGroup ); | 170 | mConfidential = new QCheckBox( i18n( "confidential" ), mMatchPPCGroup ); |
172 | mPublic->setChecked( true ); | 171 | mPublic->setChecked( true ); |
173 | mPrivate->setChecked( true ); | 172 | mPrivate->setChecked( true ); |
174 | mConfidential->setChecked( true ); | 173 | mConfidential->setChecked( true ); |
175 | topLayout->addMultiCellWidget( mMatchPPCGroup, 3, 3, 0, 1 ); | 174 | topLayout->addMultiCellWidget( mMatchPPCGroup, 3, 3, 0, 1 ); |
176 | 175 | ||
177 | } | 176 | } |
178 | 177 | ||
179 | void FilterEditDialog::filterNameTextChanged( const QString &text ) | 178 | void FilterEditDialog::filterNameTextChanged( const QString &text ) |
180 | { | 179 | { |
181 | enableButtonOK( !text.isEmpty() ); | 180 | enableButtonOK( !text.isEmpty() ); |
182 | } | 181 | } |
183 | 182 | ||
184 | void FilterEditDialog::slotHelp() | 183 | void FilterEditDialog::slotHelp() |
185 | { | 184 | { |
186 | #ifndef KAB_EMBEDDED | 185 | #ifndef KAB_EMBEDDED |
187 | kapp->invokeHelp( "using-filters" ); | 186 | kapp->invokeHelp( "using-filters" ); |
188 | #endif //KAB_EMBEDDED | 187 | #endif //KAB_EMBEDDED |
189 | } | 188 | } |
190 | 189 | ||
191 | FilterDialog::FilterDialog( QWidget *parent, const char *name ) | 190 | FilterDialog::FilterDialog( QWidget *parent, const char *name ) |
192 | : KDialogBase( Plain, i18n( "Edit Address Book Filters" ), | 191 | : KDialogBase( Plain, i18n( "Edit Address Book Filters" ), |
193 | Ok | Cancel, Ok, parent, name, /*US false*/true, true ) | 192 | Ok | Cancel, Ok, parent, name, /*US false*/true, true ) |
194 | { | 193 | { |
195 | initGUI(); | 194 | initGUI(); |
196 | } | 195 | } |
197 | 196 | ||
198 | FilterDialog::~FilterDialog() | 197 | FilterDialog::~FilterDialog() |
199 | { | 198 | { |
200 | } | 199 | } |
201 | 200 | ||
202 | void FilterDialog::setFilters( const Filter::List &list ) | 201 | void FilterDialog::setFilters( const Filter::List &list ) |
203 | { | 202 | { |
204 | mFilterList.clear(); | 203 | mFilterList.clear(); |
205 | mInternalFilterList.clear(); | 204 | mInternalFilterList.clear(); |
206 | 205 | ||
207 | Filter::List::ConstIterator it; | 206 | Filter::List::ConstIterator it; |
208 | for ( it = list.begin(); it != list.end(); ++it ) { | 207 | for ( it = list.begin(); it != list.end(); ++it ) { |
209 | if ( (*it).isInternal() ) | 208 | if ( (*it).isInternal() ) |
210 | mInternalFilterList.append( *it ); | 209 | mInternalFilterList.append( *it ); |
211 | else | 210 | else |
212 | mFilterList.append( *it ); | 211 | mFilterList.append( *it ); |
213 | } | 212 | } |
214 | 213 | ||
215 | refresh(); | 214 | refresh(); |
216 | } | 215 | } |
217 | 216 | ||
218 | Filter::List FilterDialog::filters() const | 217 | Filter::List FilterDialog::filters() const |
219 | { | 218 | { |
220 | Filter::List list = mFilterList + mInternalFilterList; | 219 | Filter::List list = mFilterList + mInternalFilterList; |
221 | return list; | 220 | return list; |
222 | } | 221 | } |
223 | 222 | ||
224 | void FilterDialog::add() | 223 | void FilterDialog::add() |
225 | { | 224 | { |
226 | #ifndef KAB_EMBEDDED | 225 | #ifndef KAB_EMBEDDED |
227 | FilterEditDialog dlg( this ); | 226 | FilterEditDialog dlg( this ); |
228 | #else //KAB_EMBEDDED | 227 | #else //KAB_EMBEDDED |
229 | FilterEditDialog dlg( this->parentWidget() ); | 228 | FilterEditDialog dlg( this->parentWidget() ); |
230 | #endif //KAB_EMBEDDED | 229 | #endif //KAB_EMBEDDED |
231 | 230 | ||
232 | if ( dlg.exec() ) | 231 | if ( dlg.exec() ) |
233 | mFilterList.append( dlg.filter() ); | 232 | mFilterList.append( dlg.filter() ); |
234 | 233 | ||
235 | refresh(); | 234 | refresh(); |
236 | 235 | ||
237 | mFilterListBox->setCurrentItem( mFilterListBox->count() - 1 ); | 236 | mFilterListBox->setCurrentItem( mFilterListBox->count() - 1 ); |
238 | } | 237 | } |
239 | 238 | ||
240 | void FilterDialog::edit() | 239 | void FilterDialog::edit() |
241 | { | 240 | { |
242 | FilterEditDialog dlg( this ); | 241 | FilterEditDialog dlg( this ); |
243 | 242 | ||
244 | uint pos = mFilterListBox->currentItem(); | 243 | uint pos = mFilterListBox->currentItem(); |
245 | 244 | ||
246 | dlg.setFilter( mFilterList[ pos ] ); | 245 | dlg.setFilter( mFilterList[ pos ] ); |
247 | 246 | ||
248 | if ( dlg.exec() ) { | 247 | if ( dlg.exec() ) { |
249 | mFilterList.remove( mFilterList.at( pos ) ); | 248 | mFilterList.remove( mFilterList.at( pos ) ); |
250 | mFilterList.insert( mFilterList.at( pos ), dlg.filter() ); | 249 | mFilterList.insert( mFilterList.at( pos ), dlg.filter() ); |
251 | } | 250 | } |
252 | 251 | ||
253 | refresh(); | 252 | refresh(); |
254 | 253 | ||
255 | mFilterListBox->setCurrentItem( pos ); | 254 | mFilterListBox->setCurrentItem( pos ); |
256 | } | 255 | } |
257 | 256 | ||
258 | void FilterDialog::remove() | 257 | void FilterDialog::remove() |
259 | { | 258 | { |
260 | mFilterList.remove( mFilterList.at( mFilterListBox->currentItem() ) ); | 259 | mFilterList.remove( mFilterList.at( mFilterListBox->currentItem() ) ); |
261 | 260 | ||
262 | selectionChanged( 0 ); | 261 | selectionChanged( 0 ); |
263 | 262 | ||
264 | refresh(); | 263 | refresh(); |
265 | } | 264 | } |
266 | 265 | ||
267 | void FilterDialog::refresh() | 266 | void FilterDialog::refresh() |
268 | { | 267 | { |
269 | mFilterListBox->clear(); | 268 | mFilterListBox->clear(); |
270 | 269 | ||
271 | Filter::List::Iterator iter; | 270 | Filter::List::Iterator iter; |
272 | for ( iter = mFilterList.begin(); iter != mFilterList.end(); ++iter ) | 271 | for ( iter = mFilterList.begin(); iter != mFilterList.end(); ++iter ) |
273 | mFilterListBox->insertItem( (*iter).name() ); | 272 | mFilterListBox->insertItem( (*iter).name() ); |
274 | } | 273 | } |
275 | 274 | ||
276 | void FilterDialog::selectionChanged( QListBoxItem *item ) | 275 | void FilterDialog::selectionChanged( QListBoxItem *item ) |
277 | { | 276 | { |
278 | bool state = ( item != 0 ); | 277 | bool state = ( item != 0 ); |
279 | 278 | ||
280 | mEditButton->setEnabled( state ); | 279 | mEditButton->setEnabled( state ); |
281 | mRemoveButton->setEnabled( state ); | 280 | mRemoveButton->setEnabled( state ); |
282 | } | 281 | } |
283 | 282 | ||
284 | void FilterDialog::initGUI() | 283 | void FilterDialog::initGUI() |
285 | { | 284 | { |
286 | #ifndef KAB_EMBEDDED | 285 | #ifndef KAB_EMBEDDED |
287 | resize( 330, 200 ); | 286 | resize( 330, 200 ); |
288 | #else //KAB_EMBEDDED | 287 | #else //KAB_EMBEDDED |
289 | resize( KMIN(KGlobal::getDesktopWidth()-10, 330), KMIN(KGlobal::getDesktopHeight()-50, 200)); | 288 | resize( KMIN(KGlobal::getDesktopWidth()-10, 330), KMIN(KGlobal::getDesktopHeight()-50, 200)); |
290 | #endif //KAB_EMBEDDED | 289 | #endif //KAB_EMBEDDED |
291 | 290 | ||
292 | QWidget *page = plainPage(); | 291 | QWidget *page = plainPage(); |
293 | 292 | ||
294 | QGridLayout *topLayout = new QGridLayout( page, 1, 2, 0, spacingHint() ); | 293 | QGridLayout *topLayout = new QGridLayout( page, 1, 2, 0, spacingHint() ); |
295 | 294 | ||
296 | mFilterListBox = new KListBox( page ); | 295 | mFilterListBox = new KListBox( page ); |
297 | topLayout->addWidget( mFilterListBox, 0, 0 ); | 296 | topLayout->addWidget( mFilterListBox, 0, 0 ); |
298 | connect( mFilterListBox, SIGNAL( selectionChanged( QListBoxItem * ) ), | 297 | connect( mFilterListBox, SIGNAL( selectionChanged( QListBoxItem * ) ), |
299 | SLOT( selectionChanged( QListBoxItem * ) ) ); | 298 | SLOT( selectionChanged( QListBoxItem * ) ) ); |
300 | connect( mFilterListBox, SIGNAL( doubleClicked ( QListBoxItem * ) ), | 299 | connect( mFilterListBox, SIGNAL( doubleClicked ( QListBoxItem * ) ), |
301 | SLOT( edit() ) ); | 300 | SLOT( edit() ) ); |
302 | 301 | ||
303 | KButtonBox *buttonBox = new KButtonBox( page, Vertical ); | 302 | KButtonBox *buttonBox = new KButtonBox( page, Vertical ); |
304 | buttonBox->addButton( i18n( "&Add..." ), this, SLOT( add() ) ); | 303 | buttonBox->addButton( i18n( "&Add..." ), this, SLOT( add() ) ); |
305 | mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( edit() ) ); | 304 | mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( edit() ) ); |
306 | mEditButton->setEnabled( false ); | 305 | mEditButton->setEnabled( false ); |
307 | mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( remove() ) ); | 306 | mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( remove() ) ); |
308 | mRemoveButton->setEnabled( false ); | 307 | mRemoveButton->setEnabled( false ); |
309 | 308 | ||
310 | buttonBox->layout(); | 309 | buttonBox->layout(); |
311 | topLayout->addWidget( buttonBox, 0, 1 ); | 310 | topLayout->addWidget( buttonBox, 0, 1 ); |
312 | } | 311 | } |
313 | 312 | ||
314 | #ifndef KAB_EMBEDDED | 313 | #ifndef KAB_EMBEDDED |
315 | #include "filtereditdialog.moc" | 314 | #include "filtereditdialog.moc" |
316 | #endif //KAB_EMBEDDED | 315 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index e61f65f..aa04631 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,3265 +1,3271 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
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 | /*s | 24 | /*s |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "kabcore.h" | 31 | #include "kabcore.h" |
32 | 32 | ||
33 | #include <stdaddressbook.h> | 33 | #include <stdaddressbook.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kfiledialog.h> | 35 | #include <kfiledialog.h> |
36 | #include <qtimer.h> | 36 | #include <qtimer.h> |
37 | #include <qlabel.h> | 37 | #include <qlabel.h> |
38 | #include <qregexp.h> | 38 | #include <qregexp.h> |
39 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
40 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qprogressbar.h> | 42 | #include <qprogressbar.h> |
43 | #include <libkdepim/phoneaccess.h> | 43 | #include <libkdepim/phoneaccess.h> |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | #include <qclipboard.h> | 46 | #include <qclipboard.h> |
47 | #include <qdir.h> | 47 | #include <qdir.h> |
48 | #include <qfile.h> | 48 | #include <qfile.h> |
49 | #include <qapplicaton.h> | 49 | #include <qapplicaton.h> |
50 | #include <qprogressbar.h> | 50 | #include <qprogressbar.h> |
51 | #include <qlayout.h> | 51 | #include <qlayout.h> |
52 | #include <qregexp.h> | 52 | #include <qregexp.h> |
53 | #include <qvbox.h> | 53 | #include <qvbox.h> |
54 | #include <kabc/addresseelist.h> | 54 | #include <kabc/addresseelist.h> |
55 | #include <kabc/errorhandler.h> | 55 | #include <kabc/errorhandler.h> |
56 | #include <kabc/resource.h> | 56 | #include <kabc/resource.h> |
57 | #include <kabc/vcardconverter.h> | 57 | #include <kabc/vcardconverter.h> |
58 | #include <kapplication.h> | 58 | #include <kapplication.h> |
59 | #include <kactionclasses.h> | 59 | #include <kactionclasses.h> |
60 | #include <kcmultidialog.h> | 60 | #include <kcmultidialog.h> |
61 | #include <kdebug.h> | 61 | #include <kdebug.h> |
62 | #include <kdeversion.h> | 62 | #include <kdeversion.h> |
63 | #include <kkeydialog.h> | 63 | #include <kkeydialog.h> |
64 | #include <kmessagebox.h> | 64 | #include <kmessagebox.h> |
65 | #include <kprinter.h> | 65 | #include <kprinter.h> |
66 | #include <kprotocolinfo.h> | 66 | #include <kprotocolinfo.h> |
67 | #include <kresources/selectdialog.h> | 67 | #include <kresources/selectdialog.h> |
68 | #include <kstandarddirs.h> | 68 | #include <kstandarddirs.h> |
69 | #include <ktempfile.h> | 69 | #include <ktempfile.h> |
70 | #include <kxmlguiclient.h> | 70 | #include <kxmlguiclient.h> |
71 | #include <kaboutdata.h> | 71 | #include <kaboutdata.h> |
72 | #include <libkdepim/categoryselectdialog.h> | 72 | #include <libkdepim/categoryselectdialog.h> |
73 | 73 | ||
74 | #include "addresseeutil.h" | 74 | #include "addresseeutil.h" |
75 | #include "addresseeeditordialog.h" | 75 | #include "addresseeeditordialog.h" |
76 | #include "extensionmanager.h" | 76 | #include "extensionmanager.h" |
77 | #include "kstdaction.h" | 77 | #include "kstdaction.h" |
78 | #include "kaddressbookservice.h" | 78 | #include "kaddressbookservice.h" |
79 | #include "ldapsearchdialog.h" | 79 | #include "ldapsearchdialog.h" |
80 | #include "printing/printingwizard.h" | 80 | #include "printing/printingwizard.h" |
81 | #else // KAB_EMBEDDED | 81 | #else // KAB_EMBEDDED |
82 | 82 | ||
83 | #include <kapplication.h> | 83 | #include <kapplication.h> |
84 | #include "KDGanttMinimizeSplitter.h" | 84 | #include "KDGanttMinimizeSplitter.h" |
85 | #include "kaddressbookmain.h" | 85 | #include "kaddressbookmain.h" |
86 | #include "kactioncollection.h" | 86 | #include "kactioncollection.h" |
87 | #include "addresseedialog.h" | 87 | #include "addresseedialog.h" |
88 | //US | 88 | //US |
89 | #include <addresseeview.h> | 89 | #include <addresseeview.h> |
90 | 90 | ||
91 | #include <qapp.h> | 91 | #include <qapp.h> |
92 | #include <qmenubar.h> | 92 | #include <qmenubar.h> |
93 | //#include <qtoolbar.h> | 93 | //#include <qtoolbar.h> |
94 | #include <qmessagebox.h> | 94 | #include <qmessagebox.h> |
95 | #include <kdebug.h> | 95 | #include <kdebug.h> |
96 | #include <kiconloader.h> // needed for SmallIcon | 96 | #include <kiconloader.h> // needed for SmallIcon |
97 | #include <kresources/kcmkresources.h> | 97 | #include <kresources/kcmkresources.h> |
98 | #include <ktoolbar.h> | 98 | #include <ktoolbar.h> |
99 | 99 | ||
100 | 100 | ||
101 | //#include <qlabel.h> | 101 | //#include <qlabel.h> |
102 | 102 | ||
103 | 103 | ||
104 | #ifndef DESKTOP_VERSION | 104 | #ifndef DESKTOP_VERSION |
105 | #include <qpe/ir.h> | 105 | #include <qpe/ir.h> |
106 | #include <qpe/qpemenubar.h> | 106 | #include <qpe/qpemenubar.h> |
107 | #include <qtopia/qcopenvelope_qws.h> | 107 | #include <qtopia/qcopenvelope_qws.h> |
108 | #else | 108 | #else |
109 | 109 | ||
110 | #include <qmenubar.h> | 110 | #include <qmenubar.h> |
111 | #endif | 111 | #endif |
112 | 112 | ||
113 | #endif // KAB_EMBEDDED | 113 | #endif // KAB_EMBEDDED |
114 | #include "kcmconfigs/kcmkabconfig.h" | 114 | #include "kcmconfigs/kcmkabconfig.h" |
115 | #include "kcmconfigs/kcmkdepimconfig.h" | 115 | #include "kcmconfigs/kcmkdepimconfig.h" |
116 | #include "kpimglobalprefs.h" | 116 | #include "kpimglobalprefs.h" |
117 | #include "externalapphandler.h" | 117 | #include "externalapphandler.h" |
118 | #include "xxportselectdialog.h" | 118 | #include "xxportselectdialog.h" |
119 | 119 | ||
120 | 120 | ||
121 | #include <kresources/selectdialog.h> | 121 | #include <kresources/selectdialog.h> |
122 | #include <kmessagebox.h> | 122 | #include <kmessagebox.h> |
123 | 123 | ||
124 | #include <picture.h> | 124 | #include <picture.h> |
125 | #include <resource.h> | 125 | #include <resource.h> |
126 | 126 | ||
127 | //US#include <qsplitter.h> | 127 | //US#include <qsplitter.h> |
128 | #include <qmap.h> | 128 | #include <qmap.h> |
129 | #include <qdir.h> | 129 | #include <qdir.h> |
130 | #include <qfile.h> | 130 | #include <qfile.h> |
131 | #include <qvbox.h> | 131 | #include <qvbox.h> |
132 | #include <qlayout.h> | 132 | #include <qlayout.h> |
133 | #include <qclipboard.h> | 133 | #include <qclipboard.h> |
134 | #include <qtextstream.h> | 134 | #include <qtextstream.h> |
135 | #include <qradiobutton.h> | 135 | #include <qradiobutton.h> |
136 | #include <qbuttongroup.h> | 136 | #include <qbuttongroup.h> |
137 | 137 | ||
138 | #include <libkdepim/categoryselectdialog.h> | 138 | #include <libkdepim/categoryselectdialog.h> |
139 | #include <libkdepim/categoryeditdialog.h> | 139 | #include <libkdepim/categoryeditdialog.h> |
140 | #include <kabc/vcardconverter.h> | 140 | #include <kabc/vcardconverter.h> |
141 | 141 | ||
142 | 142 | ||
143 | #include "addresseeutil.h" | 143 | #include "addresseeutil.h" |
144 | #include "undocmds.h" | 144 | #include "undocmds.h" |
145 | #include "addresseeeditordialog.h" | 145 | #include "addresseeeditordialog.h" |
146 | #include "viewmanager.h" | 146 | #include "viewmanager.h" |
147 | #include "details/detailsviewcontainer.h" | 147 | #include "details/detailsviewcontainer.h" |
148 | #include "kabprefs.h" | 148 | #include "kabprefs.h" |
149 | #include "xxportmanager.h" | 149 | #include "xxportmanager.h" |
150 | #include "incsearchwidget.h" | 150 | #include "incsearchwidget.h" |
151 | #include "jumpbuttonbar.h" | 151 | #include "jumpbuttonbar.h" |
152 | #include "extensionmanager.h" | 152 | #include "extensionmanager.h" |
153 | #include "addresseeconfig.h" | 153 | #include "addresseeconfig.h" |
154 | #include "nameeditdialog.h" | 154 | #include "nameeditdialog.h" |
155 | #include <kcmultidialog.h> | 155 | #include <kcmultidialog.h> |
156 | 156 | ||
157 | #ifdef _WIN32_ | 157 | #ifdef _WIN32_ |
158 | 158 | ||
159 | #include "kaimportoldialog.h" | 159 | #include "kaimportoldialog.h" |
160 | #else | 160 | #else |
161 | #include <unistd.h> | 161 | #include <unistd.h> |
162 | #endif | 162 | #endif |
163 | // sync includes | 163 | // sync includes |
164 | #include <libkdepim/ksyncprofile.h> | 164 | #include <libkdepim/ksyncprofile.h> |
165 | #include <libkdepim/ksyncprefsdialog.h> | 165 | #include <libkdepim/ksyncprefsdialog.h> |
166 | 166 | ||
167 | 167 | ||
168 | class KABCatPrefs : public QDialog | 168 | class KABCatPrefs : public QDialog |
169 | { | 169 | { |
170 | public: | 170 | public: |
171 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : | 171 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : |
172 | QDialog( parent, name, true ) | 172 | QDialog( parent, name, true ) |
173 | { | 173 | { |
174 | setCaption( i18n("Manage new Categories") ); | 174 | setCaption( i18n("Manage new Categories") ); |
175 | QVBoxLayout* lay = new QVBoxLayout( this ); | 175 | QVBoxLayout* lay = new QVBoxLayout( this ); |
176 | lay->setSpacing( 3 ); | 176 | lay->setSpacing( 3 ); |
177 | lay->setMargin( 3 ); | 177 | lay->setMargin( 3 ); |
178 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 178 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
179 | lay->addWidget( lab ); | 179 | lay->addWidget( lab ); |
180 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 180 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
181 | lay->addWidget( format ); | 181 | lay->addWidget( format ); |
182 | format->setExclusive ( true ) ; | 182 | format->setExclusive ( true ) ; |
183 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 183 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
184 | new QRadioButton(i18n("Remove from addressees"), format ); | 184 | new QRadioButton(i18n("Remove from addressees"), format ); |
185 | addCatBut->setChecked( true ); | 185 | addCatBut->setChecked( true ); |
186 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 186 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
187 | lay->addWidget( ok ); | 187 | lay->addWidget( ok ); |
188 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 188 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
189 | lay->addWidget( cancel ); | 189 | lay->addWidget( cancel ); |
190 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 190 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
191 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 191 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
192 | resize( 200, 200 ); | 192 | resize( 200, 200 ); |
193 | } | 193 | } |
194 | 194 | ||
195 | bool addCat() { return addCatBut->isChecked(); } | 195 | bool addCat() { return addCatBut->isChecked(); } |
196 | private: | 196 | private: |
197 | QRadioButton* addCatBut; | 197 | QRadioButton* addCatBut; |
198 | }; | 198 | }; |
199 | 199 | ||
200 | class KABFormatPrefs : public QDialog | 200 | class KABFormatPrefs : public QDialog |
201 | { | 201 | { |
202 | public: | 202 | public: |
203 | KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : | 203 | KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : |
204 | QDialog( parent, name, true ) | 204 | QDialog( parent, name, true ) |
205 | { | 205 | { |
206 | setCaption( i18n("Set formatted name") ); | 206 | setCaption( i18n("Set formatted name") ); |
207 | QVBoxLayout* lay = new QVBoxLayout( this ); | 207 | QVBoxLayout* lay = new QVBoxLayout( this ); |
208 | lay->setSpacing( 3 ); | 208 | lay->setSpacing( 3 ); |
209 | lay->setMargin( 3 ); | 209 | lay->setMargin( 3 ); |
210 | QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); | 210 | QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); |
211 | lay->addWidget( lab ); | 211 | lay->addWidget( lab ); |
212 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); | 212 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); |
213 | lay->addWidget( format ); | 213 | lay->addWidget( format ); |
214 | format->setExclusive ( true ) ; | 214 | format->setExclusive ( true ) ; |
215 | simple = new QRadioButton(i18n("Simple: James Bond"), format ); | 215 | simple = new QRadioButton(i18n("Simple: James Bond"), format ); |
216 | full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); | 216 | full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); |
217 | reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); | 217 | reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); |
218 | company = new QRadioButton(i18n("Organization: MI6"), format ); | 218 | company = new QRadioButton(i18n("Organization: MI6"), format ); |
219 | simple->setChecked( true ); | 219 | simple->setChecked( true ); |
220 | setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); | 220 | setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); |
221 | lay->addWidget( setCompany ); | 221 | lay->addWidget( setCompany ); |
222 | QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); | 222 | QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); |
223 | lay->addWidget( ok ); | 223 | lay->addWidget( ok ); |
224 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 224 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
225 | lay->addWidget( cancel ); | 225 | lay->addWidget( cancel ); |
226 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 226 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
227 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 227 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
228 | resize( 200, 200 ); | 228 | resize( 200, 200 ); |
229 | } | 229 | } |
230 | public: | 230 | public: |
231 | QRadioButton* simple, *full, *reverse, *company; | 231 | QRadioButton* simple, *full, *reverse, *company; |
232 | QCheckBox* setCompany; | 232 | QCheckBox* setCompany; |
233 | }; | 233 | }; |
234 | 234 | ||
235 | 235 | ||
236 | 236 | ||
237 | class KAex2phonePrefs : public QDialog | 237 | class KAex2phonePrefs : public QDialog |
238 | { | 238 | { |
239 | public: | 239 | public: |
240 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 240 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
241 | QDialog( parent, name, true ) | 241 | QDialog( parent, name, true ) |
242 | { | 242 | { |
243 | setCaption( i18n("Export to phone options") ); | 243 | setCaption( i18n("Export to phone options") ); |
244 | QVBoxLayout* lay = new QVBoxLayout( this ); | 244 | QVBoxLayout* lay = new QVBoxLayout( this ); |
245 | lay->setSpacing( 3 ); | 245 | lay->setSpacing( 3 ); |
246 | lay->setMargin( 3 ); | 246 | lay->setMargin( 3 ); |
247 | QLabel *lab; | 247 | QLabel *lab; |
248 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 248 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
249 | lab->setAlignment (AlignHCenter ); | 249 | lab->setAlignment (AlignHCenter ); |
250 | QHBox* temphb; | 250 | QHBox* temphb; |
251 | temphb = new QHBox( this ); | 251 | temphb = new QHBox( this ); |
252 | new QLabel( i18n("I/O device: "), temphb ); | 252 | new QLabel( i18n("I/O device: "), temphb ); |
253 | mPhoneDevice = new QLineEdit( temphb); | 253 | mPhoneDevice = new QLineEdit( temphb); |
254 | lay->addWidget( temphb ); | 254 | lay->addWidget( temphb ); |
255 | temphb = new QHBox( this ); | 255 | temphb = new QHBox( this ); |
256 | new QLabel( i18n("Connection: "), temphb ); | 256 | new QLabel( i18n("Connection: "), temphb ); |
257 | mPhoneConnection = new QLineEdit( temphb); | 257 | mPhoneConnection = new QLineEdit( temphb); |
258 | lay->addWidget( temphb ); | 258 | lay->addWidget( temphb ); |
259 | temphb = new QHBox( this ); | 259 | temphb = new QHBox( this ); |
260 | new QLabel( i18n("Model(opt.): "), temphb ); | 260 | new QLabel( i18n("Model(opt.): "), temphb ); |
261 | mPhoneModel = new QLineEdit( temphb); | 261 | mPhoneModel = new QLineEdit( temphb); |
262 | lay->addWidget( temphb ); | 262 | lay->addWidget( temphb ); |
263 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); | 263 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); |
264 | // lay->addWidget( mWriteToSim ); | 264 | // lay->addWidget( mWriteToSim ); |
265 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); | 265 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); |
266 | lab->setAlignment (AlignHCenter ); | 266 | lab->setAlignment (AlignHCenter); |
267 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 267 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
268 | lay->addWidget( ok ); | 268 | lay->addWidget( ok ); |
269 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 269 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
270 | lay->addWidget( cancel ); | 270 | lay->addWidget( cancel ); |
271 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 271 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
272 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 272 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
273 | resize( 220, 240 ); | 273 | resize( 220, 240 ); |
274 | 274 | ||
275 | } | 275 | } |
276 | 276 | ||
277 | public: | 277 | public: |
278 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 278 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
279 | QCheckBox* mWriteToSim; | 279 | QCheckBox* mWriteToSim; |
280 | }; | 280 | }; |
281 | 281 | ||
282 | 282 | ||
283 | bool pasteWithNewUid = true; | 283 | bool pasteWithNewUid = true; |
284 | 284 | ||
285 | #ifdef KAB_EMBEDDED | 285 | #ifdef KAB_EMBEDDED |
286 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 286 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
287 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 287 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
288 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 288 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
289 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 289 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
290 | #else //KAB_EMBEDDED | 290 | #else //KAB_EMBEDDED |
291 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 291 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
292 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 292 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
293 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 293 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
294 | mReadWrite( readWrite ), mModified( false ) | 294 | mReadWrite( readWrite ), mModified( false ) |
295 | #endif //KAB_EMBEDDED | 295 | #endif //KAB_EMBEDDED |
296 | { | 296 | { |
297 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 297 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
298 | // syncManager->setBlockSave(false); | 298 | // syncManager->setBlockSave(false); |
299 | mMiniSplitter = 0; | 299 | mMiniSplitter = 0; |
300 | mExtensionBarSplitter = 0; | 300 | mExtensionBarSplitter = 0; |
301 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 301 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
302 | mAddressBook = KABC::StdAddressBook::self(); | 302 | mAddressBook = KABC::StdAddressBook::self(); |
303 | KABC::StdAddressBook::setAutomaticSave( false ); | 303 | KABC::StdAddressBook::setAutomaticSave( false ); |
304 | 304 | ||
305 | #ifndef KAB_EMBEDDED | 305 | #ifndef KAB_EMBEDDED |
306 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 306 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
307 | #endif //KAB_EMBEDDED | 307 | #endif //KAB_EMBEDDED |
308 | 308 | ||
309 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 309 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
310 | SLOT( addressBookChanged() ) ); | 310 | SLOT( addressBookChanged() ) ); |
311 | 311 | ||
312 | #if 0 | 312 | #if 0 |
313 | // LP moved to addressbook init method | 313 | // LP moved to addressbook init method |
314 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 314 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
315 | "X-Department", "KADDRESSBOOK" ); | 315 | "X-Department", "KADDRESSBOOK" ); |
316 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 316 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
317 | "X-Profession", "KADDRESSBOOK" ); | 317 | "X-Profession", "KADDRESSBOOK" ); |
318 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 318 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
319 | "X-AssistantsName", "KADDRESSBOOK" ); | 319 | "X-AssistantsName", "KADDRESSBOOK" ); |
320 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 320 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
321 | "X-ManagersName", "KADDRESSBOOK" ); | 321 | "X-ManagersName", "KADDRESSBOOK" ); |
322 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 322 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
323 | "X-SpousesName", "KADDRESSBOOK" ); | 323 | "X-SpousesName", "KADDRESSBOOK" ); |
324 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 324 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
325 | "X-Office", "KADDRESSBOOK" ); | 325 | "X-Office", "KADDRESSBOOK" ); |
326 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 326 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
327 | "X-IMAddress", "KADDRESSBOOK" ); | 327 | "X-IMAddress", "KADDRESSBOOK" ); |
328 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 328 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
329 | "X-Anniversary", "KADDRESSBOOK" ); | 329 | "X-Anniversary", "KADDRESSBOOK" ); |
330 | 330 | ||
331 | //US added this field to become compatible with Opie/qtopia addressbook | 331 | //US added this field to become compatible with Opie/qtopia addressbook |
332 | // values can be "female" or "male" or "". An empty field represents undefined. | 332 | // values can be "female" or "male" or "". An empty field represents undefined. |
333 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 333 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
334 | "X-Gender", "KADDRESSBOOK" ); | 334 | "X-Gender", "KADDRESSBOOK" ); |
335 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 335 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
336 | "X-Children", "KADDRESSBOOK" ); | 336 | "X-Children", "KADDRESSBOOK" ); |
337 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 337 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
338 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 338 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
339 | #endif | 339 | #endif |
340 | initGUI(); | 340 | initGUI(); |
341 | 341 | ||
342 | mIncSearchWidget->setFocus(); | 342 | mIncSearchWidget->setFocus(); |
343 | 343 | ||
344 | 344 | ||
345 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 345 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
346 | SLOT( setContactSelected( const QString& ) ) ); | 346 | SLOT( setContactSelected( const QString& ) ) ); |
347 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 347 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
348 | SLOT( executeContact( const QString& ) ) ); | 348 | SLOT( executeContact( const QString& ) ) ); |
349 | 349 | ||
350 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 350 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
351 | SLOT( deleteContacts( ) ) ); | 351 | SLOT( deleteContacts( ) ) ); |
352 | connect( mViewManager, SIGNAL( modified() ), | 352 | connect( mViewManager, SIGNAL( modified() ), |
353 | SLOT( setModified() ) ); | 353 | SLOT( setModified() ) ); |
354 | 354 | ||
355 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 355 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
356 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 356 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
357 | 357 | ||
358 | connect( mXXPortManager, SIGNAL( modified() ), | 358 | connect( mXXPortManager, SIGNAL( modified() ), |
359 | SLOT( setModified() ) ); | 359 | SLOT( setModified() ) ); |
360 | 360 | ||
361 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 361 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
362 | SLOT( incrementalSearch( const QString& ) ) ); | 362 | SLOT( incrementalSearch( const QString& ) ) ); |
363 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 363 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
364 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 364 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
365 | 365 | ||
366 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 366 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
367 | SLOT( sendMail( const QString& ) ) ); | 367 | SLOT( sendMail( const QString& ) ) ); |
368 | 368 | ||
369 | 369 | ||
370 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 370 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
371 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 371 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
372 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 372 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
373 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); | 373 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); |
374 | 374 | ||
375 | 375 | ||
376 | #ifndef KAB_EMBEDDED | 376 | #ifndef KAB_EMBEDDED |
377 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 377 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
378 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 378 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
379 | 379 | ||
380 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 380 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
381 | SLOT( browse( const QString& ) ) ); | 381 | SLOT( browse( const QString& ) ) ); |
382 | 382 | ||
383 | 383 | ||
384 | mAddressBookService = new KAddressBookService( this ); | 384 | mAddressBookService = new KAddressBookService( this ); |
385 | 385 | ||
386 | #endif //KAB_EMBEDDED | 386 | #endif //KAB_EMBEDDED |
387 | 387 | ||
388 | mMessageTimer = new QTimer( this ); | 388 | mMessageTimer = new QTimer( this ); |
389 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); | 389 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); |
390 | mEditorDialog = 0; | 390 | mEditorDialog = 0; |
391 | createAddresseeEditorDialog( this ); | 391 | createAddresseeEditorDialog( this ); |
392 | setModified( false ); | 392 | setModified( false ); |
393 | mBRdisabled = false; | 393 | mBRdisabled = false; |
394 | #ifndef DESKTOP_VERSION | 394 | #ifndef DESKTOP_VERSION |
395 | infrared = 0; | 395 | infrared = 0; |
396 | #endif | 396 | #endif |
397 | //toggleBeamReceive( ); | 397 | //toggleBeamReceive( ); |
398 | //mMainWindow->toolBar()->show(); | 398 | //mMainWindow->toolBar()->show(); |
399 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi | 399 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi |
400 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); | 400 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); |
401 | } | 401 | } |
402 | 402 | ||
403 | void KABCore::updateToolBar() | 403 | void KABCore::updateToolBar() |
404 | { | 404 | { |
405 | static int iii = 0; | 405 | static int iii = 0; |
406 | ++iii; | 406 | ++iii; |
407 | mMainWindow->toolBar()->repaintMe(); | 407 | mMainWindow->toolBar()->repaintMe(); |
408 | if ( iii < 5 ) | 408 | if ( iii < 5 ) |
409 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); | 409 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); |
410 | } | 410 | } |
411 | KABCore::~KABCore() | 411 | KABCore::~KABCore() |
412 | { | 412 | { |
413 | // save(); | 413 | // save(); |
414 | //saveSettings(); | 414 | //saveSettings(); |
415 | //KABPrefs::instance()->writeConfig(); | 415 | //KABPrefs::instance()->writeConfig(); |
416 | delete AddresseeConfig::instance(); | 416 | delete AddresseeConfig::instance(); |
417 | mAddressBook = 0; | 417 | mAddressBook = 0; |
418 | KABC::StdAddressBook::close(); | 418 | KABC::StdAddressBook::close(); |
419 | 419 | ||
420 | delete syncManager; | 420 | delete syncManager; |
421 | #ifndef DESKTOP_VERSION | 421 | #ifndef DESKTOP_VERSION |
422 | if ( infrared ) | 422 | if ( infrared ) |
423 | delete infrared; | 423 | delete infrared; |
424 | #endif | 424 | #endif |
425 | } | 425 | } |
426 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) | 426 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) |
427 | { | 427 | { |
428 | qDebug("KA: QCOP message received: %s ", cmsg.data() ); | 428 | qDebug("KA: QCOP message received: %s ", cmsg.data() ); |
429 | if ( cmsg == "setDocument(QString)" ) { | 429 | if ( cmsg == "setDocument(QString)" ) { |
430 | QDataStream stream( data, IO_ReadOnly ); | 430 | QDataStream stream( data, IO_ReadOnly ); |
431 | QString fileName; | 431 | QString fileName; |
432 | stream >> fileName; | 432 | stream >> fileName; |
433 | recieve( fileName ); | 433 | recieve( fileName ); |
434 | return; | 434 | return; |
435 | } | 435 | } |
436 | } | 436 | } |
437 | void KABCore::toggleBeamReceive( ) | 437 | void KABCore::toggleBeamReceive( ) |
438 | { | 438 | { |
439 | if ( mBRdisabled ) | 439 | if ( mBRdisabled ) |
440 | return; | 440 | return; |
441 | #ifndef DESKTOP_VERSION | 441 | #ifndef DESKTOP_VERSION |
442 | if ( infrared ) { | 442 | if ( infrared ) { |
443 | qDebug("AB disable BeamReceive "); | 443 | qDebug("AB disable BeamReceive "); |
444 | delete infrared; | 444 | delete infrared; |
445 | infrared = 0; | 445 | infrared = 0; |
446 | mActionBR->setChecked(false); | 446 | mActionBR->setChecked(false); |
447 | return; | 447 | return; |
448 | } | 448 | } |
449 | qDebug("AB enable BeamReceive "); | 449 | qDebug("AB enable BeamReceive "); |
450 | mActionBR->setChecked(true); | 450 | mActionBR->setChecked(true); |
451 | 451 | ||
452 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; | 452 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; |
453 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); | 453 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); |
454 | #endif | 454 | #endif |
455 | } | 455 | } |
456 | 456 | ||
457 | 457 | ||
458 | void KABCore::disableBR(bool b) | 458 | void KABCore::disableBR(bool b) |
459 | { | 459 | { |
460 | #ifndef DESKTOP_VERSION | 460 | #ifndef DESKTOP_VERSION |
461 | if ( b ) { | 461 | if ( b ) { |
462 | if ( infrared ) { | 462 | if ( infrared ) { |
463 | toggleBeamReceive( ); | 463 | toggleBeamReceive( ); |
464 | } | 464 | } |
465 | mBRdisabled = true; | 465 | mBRdisabled = true; |
466 | } else { | 466 | } else { |
467 | if ( mBRdisabled ) { | 467 | if ( mBRdisabled ) { |
468 | mBRdisabled = false; | 468 | mBRdisabled = false; |
469 | //toggleBeamReceive( ); | 469 | //toggleBeamReceive( ); |
470 | } | 470 | } |
471 | } | 471 | } |
472 | #endif | 472 | #endif |
473 | 473 | ||
474 | } | 474 | } |
475 | void KABCore::recieve( QString fn ) | 475 | void KABCore::recieve( QString fn ) |
476 | { | 476 | { |
477 | //qDebug("KABCore::recieve "); | 477 | //qDebug("KABCore::recieve "); |
478 | int count = mAddressBook->importFromFile( fn, true ); | 478 | int count = mAddressBook->importFromFile( fn, true ); |
479 | if ( count ) | 479 | if ( count ) |
480 | setModified( true ); | 480 | setModified( true ); |
481 | mViewManager->refreshView(); | 481 | mViewManager->refreshView(); |
482 | message(i18n("%1 contact(s) received!").arg( count )); | 482 | message(i18n("%1 contact(s) received!").arg( count )); |
483 | topLevelWidget()->showMaximized(); | 483 | topLevelWidget()->showMaximized(); |
484 | topLevelWidget()->raise(); | 484 | topLevelWidget()->raise(); |
485 | } | 485 | } |
486 | void KABCore::restoreSettings() | 486 | void KABCore::restoreSettings() |
487 | { | 487 | { |
488 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 488 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
489 | 489 | ||
490 | bool state; | 490 | bool state; |
491 | 491 | ||
492 | if (mMultipleViewsAtOnce) | 492 | if (mMultipleViewsAtOnce) |
493 | state = KABPrefs::instance()->mDetailsPageVisible; | 493 | state = KABPrefs::instance()->mDetailsPageVisible; |
494 | else | 494 | else |
495 | state = false; | 495 | state = false; |
496 | 496 | ||
497 | mActionDetails->setChecked( state ); | 497 | mActionDetails->setChecked( state ); |
498 | setDetailsVisible( state ); | 498 | setDetailsVisible( state ); |
499 | 499 | ||
500 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 500 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
501 | 501 | ||
502 | mActionJumpBar->setChecked( state ); | 502 | mActionJumpBar->setChecked( state ); |
503 | setJumpButtonBarVisible( state ); | 503 | setJumpButtonBarVisible( state ); |
504 | /*US | 504 | /*US |
505 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 505 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
506 | if ( splitterSize.count() == 0 ) { | 506 | if ( splitterSize.count() == 0 ) { |
507 | splitterSize.append( width() / 2 ); | 507 | splitterSize.append( width() / 2 ); |
508 | splitterSize.append( width() / 2 ); | 508 | splitterSize.append( width() / 2 ); |
509 | } | 509 | } |
510 | mMiniSplitter->setSizes( splitterSize ); | 510 | mMiniSplitter->setSizes( splitterSize ); |
511 | if ( mExtensionBarSplitter ) { | 511 | if ( mExtensionBarSplitter ) { |
512 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 512 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
513 | if ( splitterSize.count() == 0 ) { | 513 | if ( splitterSize.count() == 0 ) { |
514 | splitterSize.append( width() / 2 ); | 514 | splitterSize.append( width() / 2 ); |
515 | splitterSize.append( width() / 2 ); | 515 | splitterSize.append( width() / 2 ); |
516 | } | 516 | } |
517 | mExtensionBarSplitter->setSizes( splitterSize ); | 517 | mExtensionBarSplitter->setSizes( splitterSize ); |
518 | 518 | ||
519 | } | 519 | } |
520 | */ | 520 | */ |
521 | mViewManager->restoreSettings(); | 521 | mViewManager->restoreSettings(); |
522 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 522 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
523 | mExtensionManager->restoreSettings(); | 523 | mExtensionManager->restoreSettings(); |
524 | #ifdef DESKTOP_VERSION | 524 | #ifdef DESKTOP_VERSION |
525 | int wid = width(); | 525 | int wid = width(); |
526 | if ( wid < 10 ) | 526 | if ( wid < 10 ) |
527 | wid = 400; | 527 | wid = 400; |
528 | #else | 528 | #else |
529 | int wid = QApplication::desktop()->width(); | 529 | int wid = QApplication::desktop()->width(); |
530 | if ( wid < 640 ) | 530 | if ( wid < 640 ) |
531 | wid = QApplication::desktop()->height(); | 531 | wid = QApplication::desktop()->height(); |
532 | #endif | 532 | #endif |
533 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 533 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
534 | if ( true /*splitterSize.count() == 0*/ ) { | 534 | if ( true /*splitterSize.count() == 0*/ ) { |
535 | splitterSize.append( wid / 2 ); | 535 | splitterSize.append( wid / 2 ); |
536 | splitterSize.append( wid / 2 ); | 536 | splitterSize.append( wid / 2 ); |
537 | } | 537 | } |
538 | mMiniSplitter->setSizes( splitterSize ); | 538 | mMiniSplitter->setSizes( splitterSize ); |
539 | if ( mExtensionBarSplitter ) { | 539 | if ( mExtensionBarSplitter ) { |
540 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 540 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
541 | if ( true /*splitterSize.count() == 0*/ ) { | 541 | if ( true /*splitterSize.count() == 0*/ ) { |
542 | splitterSize.append( wid / 2 ); | 542 | splitterSize.append( wid / 2 ); |
543 | splitterSize.append( wid / 2 ); | 543 | splitterSize.append( wid / 2 ); |
544 | } | 544 | } |
545 | mExtensionBarSplitter->setSizes( splitterSize ); | 545 | mExtensionBarSplitter->setSizes( splitterSize ); |
546 | 546 | ||
547 | } | 547 | } |
548 | 548 | ||
549 | 549 | ||
550 | } | 550 | } |
551 | 551 | ||
552 | void KABCore::saveSettings() | 552 | void KABCore::saveSettings() |
553 | { | 553 | { |
554 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 554 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
555 | if ( mExtensionBarSplitter ) | 555 | if ( mExtensionBarSplitter ) |
556 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 556 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
557 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 557 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
558 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 558 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
559 | #ifndef KAB_EMBEDDED | 559 | #ifndef KAB_EMBEDDED |
560 | 560 | ||
561 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 561 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
562 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 562 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
563 | #endif //KAB_EMBEDDED | 563 | #endif //KAB_EMBEDDED |
564 | mExtensionManager->saveSettings(); | 564 | mExtensionManager->saveSettings(); |
565 | mViewManager->saveSettings(); | 565 | mViewManager->saveSettings(); |
566 | 566 | ||
567 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 567 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
568 | KABPrefs::instance()->writeConfig(); | ||
569 | qDebug("KABPrefs::instance()->writeConfig() "); | ||
568 | } | 570 | } |
569 | 571 | ||
570 | KABC::AddressBook *KABCore::addressBook() const | 572 | KABC::AddressBook *KABCore::addressBook() const |
571 | { | 573 | { |
572 | return mAddressBook; | 574 | return mAddressBook; |
573 | } | 575 | } |
574 | 576 | ||
575 | KConfig *KABCore::config() | 577 | KConfig *KABCore::config() |
576 | { | 578 | { |
577 | #ifndef KAB_EMBEDDED | 579 | #ifndef KAB_EMBEDDED |
578 | return KABPrefs::instance()->config(); | 580 | return KABPrefs::instance()->config(); |
579 | #else //KAB_EMBEDDED | 581 | #else //KAB_EMBEDDED |
580 | return KABPrefs::instance()->getConfig(); | 582 | return KABPrefs::instance()->getConfig(); |
581 | #endif //KAB_EMBEDDED | 583 | #endif //KAB_EMBEDDED |
582 | } | 584 | } |
583 | 585 | ||
584 | KActionCollection *KABCore::actionCollection() const | 586 | KActionCollection *KABCore::actionCollection() const |
585 | { | 587 | { |
586 | return mGUIClient->actionCollection(); | 588 | return mGUIClient->actionCollection(); |
587 | } | 589 | } |
588 | 590 | ||
589 | KABC::Field *KABCore::currentSearchField() const | 591 | KABC::Field *KABCore::currentSearchField() const |
590 | { | 592 | { |
591 | if (mIncSearchWidget) | 593 | if (mIncSearchWidget) |
592 | return mIncSearchWidget->currentField(); | 594 | return mIncSearchWidget->currentField(); |
593 | else | 595 | else |
594 | return 0; | 596 | return 0; |
595 | } | 597 | } |
596 | 598 | ||
597 | QStringList KABCore::selectedUIDs() const | 599 | QStringList KABCore::selectedUIDs() const |
598 | { | 600 | { |
599 | return mViewManager->selectedUids(); | 601 | return mViewManager->selectedUids(); |
600 | } | 602 | } |
601 | 603 | ||
602 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 604 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
603 | { | 605 | { |
604 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 606 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
605 | 607 | ||
606 | QPtrList<KRES::Resource> kresResources; | 608 | QPtrList<KRES::Resource> kresResources; |
607 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 609 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
608 | KABC::Resource *resource; | 610 | KABC::Resource *resource; |
609 | while ( ( resource = resIt.current() ) != 0 ) { | 611 | while ( ( resource = resIt.current() ) != 0 ) { |
610 | ++resIt; | 612 | ++resIt; |
611 | if ( !resource->readOnly() ) { | 613 | if ( !resource->readOnly() ) { |
612 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 614 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
613 | if ( res ) | 615 | if ( res ) |
614 | kresResources.append( res ); | 616 | kresResources.append( res ); |
615 | } | 617 | } |
616 | } | 618 | } |
617 | 619 | ||
618 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 620 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
619 | return static_cast<KABC::Resource*>( res ); | 621 | return static_cast<KABC::Resource*>( res ); |
620 | } | 622 | } |
621 | 623 | ||
622 | #ifndef KAB_EMBEDDED | 624 | #ifndef KAB_EMBEDDED |
623 | KAboutData *KABCore::createAboutData() | 625 | KAboutData *KABCore::createAboutData() |
624 | #else //KAB_EMBEDDED | 626 | #else //KAB_EMBEDDED |
625 | void KABCore::createAboutData() | 627 | void KABCore::createAboutData() |
626 | #endif //KAB_EMBEDDED | 628 | #endif //KAB_EMBEDDED |
627 | { | 629 | { |
628 | #ifndef KAB_EMBEDDED | 630 | #ifndef KAB_EMBEDDED |
629 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 631 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
630 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 632 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
631 | KAboutData::License_GPL_V2, | 633 | KAboutData::License_GPL_V2, |
632 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 634 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
633 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 635 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
634 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 636 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
635 | about->addAuthor( "Cornelius Schumacher", | 637 | about->addAuthor( "Cornelius Schumacher", |
636 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 638 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
637 | "schumacher@kde.org" ); | 639 | "schumacher@kde.org" ); |
638 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 640 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
639 | "mpilone@slac.com" ); | 641 | "mpilone@slac.com" ); |
640 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 642 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
641 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 643 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
642 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 644 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
643 | "michel@klaralvdalens-datakonsult.se" ); | 645 | "michel@klaralvdalens-datakonsult.se" ); |
644 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 646 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
645 | "hansen@kde.org" ); | 647 | "hansen@kde.org" ); |
646 | 648 | ||
647 | return about; | 649 | return about; |
648 | #endif //KAB_EMBEDDED | 650 | #endif //KAB_EMBEDDED |
649 | 651 | ||
650 | QString version; | 652 | QString version; |
651 | #include <../version> | 653 | #include <../version> |
652 | QMessageBox::about( this, "About KAddressbook/Pi", | 654 | QMessageBox::about( this, "About KAddressbook/Pi", |
653 | "KAddressbook/Platform-independent\n" | 655 | "KAddressbook/Platform-independent\n" |
654 | "(KA/Pi) " +version + " - " + | 656 | "(KA/Pi) " +version + " - " + |
655 | #ifdef DESKTOP_VERSION | 657 | #ifdef DESKTOP_VERSION |
656 | "Desktop Edition\n" | 658 | "Desktop Edition\n" |
657 | #else | 659 | #else |
658 | "PDA-Edition\n" | 660 | "PDA-Edition\n" |
659 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 661 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
660 | #endif | 662 | #endif |
661 | 663 | ||
662 | "(c) 2004 Ulf Schenk\n" | 664 | "(c) 2004 Ulf Schenk\n" |
663 | "(c) 2004 Lutz Rogowski\n" | 665 | "(c) 2004 Lutz Rogowski\n" |
664 | "(c) 1997-2003, The KDE PIM Team\n" | 666 | "(c) 1997-2003, The KDE PIM Team\n" |
665 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 667 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
666 | "Don Sanders Original author\n" | 668 | "Don Sanders Original author\n" |
667 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 669 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
668 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 670 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
669 | "Greg Stern DCOP interface\n" | 671 | "Greg Stern DCOP interface\n" |
670 | "Mark Westcot Contact pinning\n" | 672 | "Mark Westcot Contact pinning\n" |
671 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 673 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
672 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 674 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
673 | #ifdef _WIN32_ | 675 | #ifdef _WIN32_ |
674 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 676 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
675 | #endif | 677 | #endif |
676 | ); | 678 | ); |
677 | } | 679 | } |
678 | 680 | ||
679 | void KABCore::setContactSelected( const QString &uid ) | 681 | void KABCore::setContactSelected( const QString &uid ) |
680 | { | 682 | { |
681 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 683 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
682 | if ( !mDetails->isHidden() ) | 684 | if ( !mDetails->isHidden() ) |
683 | mDetails->setAddressee( addr ); | 685 | mDetails->setAddressee( addr ); |
684 | 686 | ||
685 | if ( !addr.isEmpty() ) { | 687 | if ( !addr.isEmpty() ) { |
686 | emit contactSelected( addr.formattedName() ); | 688 | emit contactSelected( addr.formattedName() ); |
687 | KABC::Picture pic = addr.photo(); | 689 | KABC::Picture pic = addr.photo(); |
688 | if ( pic.isIntern() ) { | 690 | if ( pic.isIntern() ) { |
689 | //US emit contactSelected( pic.data() ); | 691 | //US emit contactSelected( pic.data() ); |
690 | //US instead use: | 692 | //US instead use: |
691 | QPixmap px; | 693 | QPixmap px; |
692 | if (pic.data().isNull() != true) | 694 | if (pic.data().isNull() != true) |
693 | { | 695 | { |
694 | px.convertFromImage(pic.data()); | 696 | px.convertFromImage(pic.data()); |
695 | } | 697 | } |
696 | 698 | ||
697 | emit contactSelected( px ); | 699 | emit contactSelected( px ); |
698 | } | 700 | } |
699 | } | 701 | } |
700 | 702 | ||
701 | 703 | ||
702 | mExtensionManager->setSelectionChanged(); | 704 | mExtensionManager->setSelectionChanged(); |
703 | 705 | ||
704 | // update the actions | 706 | // update the actions |
705 | bool selected = !uid.isEmpty(); | 707 | bool selected = !uid.isEmpty(); |
706 | 708 | ||
707 | if ( mReadWrite ) { | 709 | if ( mReadWrite ) { |
708 | mActionCut->setEnabled( selected ); | 710 | mActionCut->setEnabled( selected ); |
709 | mActionPaste->setEnabled( selected ); | 711 | mActionPaste->setEnabled( selected ); |
710 | } | 712 | } |
711 | 713 | ||
712 | mActionCopy->setEnabled( selected ); | 714 | mActionCopy->setEnabled( selected ); |
713 | mActionDelete->setEnabled( selected ); | 715 | mActionDelete->setEnabled( selected ); |
714 | mActionEditAddressee->setEnabled( selected ); | 716 | mActionEditAddressee->setEnabled( selected ); |
715 | mActionMail->setEnabled( selected ); | 717 | mActionMail->setEnabled( selected ); |
716 | mActionMailVCard->setEnabled( selected ); | 718 | mActionMailVCard->setEnabled( selected ); |
717 | //if (mActionBeam) | 719 | //if (mActionBeam) |
718 | //mActionBeam->setEnabled( selected ); | 720 | //mActionBeam->setEnabled( selected ); |
719 | mActionWhoAmI->setEnabled( selected ); | 721 | mActionWhoAmI->setEnabled( selected ); |
720 | } | 722 | } |
721 | 723 | ||
722 | void KABCore::sendMail() | 724 | void KABCore::sendMail() |
723 | { | 725 | { |
724 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 726 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
725 | } | 727 | } |
726 | 728 | ||
727 | void KABCore::sendMail( const QString& emaillist ) | 729 | void KABCore::sendMail( const QString& emaillist ) |
728 | { | 730 | { |
729 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 731 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
730 | if (emaillist.contains(",") > 0) | 732 | if (emaillist.contains(",") > 0) |
731 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 733 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
732 | else | 734 | else |
733 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 735 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
734 | } | 736 | } |
735 | 737 | ||
736 | 738 | ||
737 | 739 | ||
738 | void KABCore::mailVCard() | 740 | void KABCore::mailVCard() |
739 | { | 741 | { |
740 | QStringList uids = mViewManager->selectedUids(); | 742 | QStringList uids = mViewManager->selectedUids(); |
741 | if ( !uids.isEmpty() ) | 743 | if ( !uids.isEmpty() ) |
742 | mailVCard( uids ); | 744 | mailVCard( uids ); |
743 | } | 745 | } |
744 | 746 | ||
745 | void KABCore::mailVCard( const QStringList& uids ) | 747 | void KABCore::mailVCard( const QStringList& uids ) |
746 | { | 748 | { |
747 | QStringList urls; | 749 | QStringList urls; |
748 | 750 | ||
749 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 751 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
750 | 752 | ||
751 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 753 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
752 | 754 | ||
753 | 755 | ||
754 | 756 | ||
755 | QDir().mkdir( dirName, true ); | 757 | QDir().mkdir( dirName, true ); |
756 | 758 | ||
757 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 759 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
758 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 760 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
759 | 761 | ||
760 | if ( a.isEmpty() ) | 762 | if ( a.isEmpty() ) |
761 | continue; | 763 | continue; |
762 | 764 | ||
763 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 765 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
764 | 766 | ||
765 | QString fileName = dirName + "/" + name; | 767 | QString fileName = dirName + "/" + name; |
766 | 768 | ||
767 | QFile outFile(fileName); | 769 | QFile outFile(fileName); |
768 | 770 | ||
769 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 771 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
770 | KABC::VCardConverter converter; | 772 | KABC::VCardConverter converter; |
771 | QString vcard; | 773 | QString vcard; |
772 | 774 | ||
773 | converter.addresseeToVCard( a, vcard ); | 775 | converter.addresseeToVCard( a, vcard ); |
774 | 776 | ||
775 | QTextStream t( &outFile ); // use a text stream | 777 | QTextStream t( &outFile ); // use a text stream |
776 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 778 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
777 | t << vcard; | 779 | t << vcard; |
778 | 780 | ||
779 | outFile.close(); | 781 | outFile.close(); |
780 | 782 | ||
781 | urls.append( fileName ); | 783 | urls.append( fileName ); |
782 | } | 784 | } |
783 | } | 785 | } |
784 | 786 | ||
785 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 787 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
786 | 788 | ||
787 | 789 | ||
788 | /*US | 790 | /*US |
789 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 791 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
790 | QString::null, // subject | 792 | QString::null, // subject |
791 | QString::null, // body | 793 | QString::null, // body |
792 | QString::null, | 794 | QString::null, |
793 | urls ); // attachments | 795 | urls ); // attachments |
794 | */ | 796 | */ |
795 | 797 | ||
796 | } | 798 | } |
797 | 799 | ||
798 | /** | 800 | /** |
799 | Beams the "WhoAmI contact. | 801 | Beams the "WhoAmI contact. |
800 | */ | 802 | */ |
801 | void KABCore::beamMySelf() | 803 | void KABCore::beamMySelf() |
802 | { | 804 | { |
803 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 805 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
804 | if (!a.isEmpty()) | 806 | if (!a.isEmpty()) |
805 | { | 807 | { |
806 | QStringList uids; | 808 | QStringList uids; |
807 | uids << a.uid(); | 809 | uids << a.uid(); |
808 | 810 | ||
809 | beamVCard(uids); | 811 | beamVCard(uids); |
810 | } else { | 812 | } else { |
811 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 813 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
812 | 814 | ||
813 | 815 | ||
814 | } | 816 | } |
815 | } | 817 | } |
816 | void KABCore::updateMainWindow() | 818 | void KABCore::updateMainWindow() |
817 | { | 819 | { |
818 | 820 | ||
819 | mMainWindow->showMaximized(); | 821 | mMainWindow->showMaximized(); |
820 | mMainWindow->update(); | 822 | mMainWindow->update(); |
821 | } | 823 | } |
822 | void KABCore::resizeEvent(QResizeEvent* e ) | 824 | void KABCore::resizeEvent(QResizeEvent* e ) |
823 | { | 825 | { |
824 | if ( !mMiniSplitter ) | 826 | if ( !mMiniSplitter ) |
825 | return; | 827 | return; |
826 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); | 828 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); |
827 | if ( QApplication::desktop()->width() >= 480 ) { | 829 | if ( QApplication::desktop()->width() >= 480 ) { |
828 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 | 830 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 |
829 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { | 831 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { |
830 | mMiniSplitter->setOrientation( Qt::Horizontal); | 832 | mMiniSplitter->setOrientation( Qt::Horizontal); |
831 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 833 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
832 | if ( QApplication::desktop()->width() <= 640 ) { | 834 | if ( QApplication::desktop()->width() <= 640 ) { |
833 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 835 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
834 | mViewManager->getFilterAction()->setComboWidth( 150 ); | 836 | mViewManager->getFilterAction()->setComboWidth( 150 ); |
835 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 837 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
836 | } | 838 | } |
837 | } | 839 | } |
838 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 | 840 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 |
839 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { | 841 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { |
840 | mMiniSplitter->setOrientation( Qt::Vertical ); | 842 | mMiniSplitter->setOrientation( Qt::Vertical ); |
841 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 843 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
842 | if ( QApplication::desktop()->width() <= 640 ) { | 844 | if ( QApplication::desktop()->width() <= 640 ) { |
843 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 845 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
844 | mMainWindow->showMinimized(); | 846 | mMainWindow->showMinimized(); |
845 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 847 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
846 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 848 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
847 | } | 849 | } |
848 | } | 850 | } |
849 | } | 851 | } |
850 | } | 852 | } |
851 | 853 | ||
852 | } | 854 | } |
853 | void KABCore::export2phone() | 855 | void KABCore::export2phone() |
854 | { | 856 | { |
855 | 857 | ||
856 | QStringList uids; | 858 | QStringList uids; |
857 | XXPortSelectDialog dlg( this, false, this ); | 859 | XXPortSelectDialog dlg( this, false, this ); |
858 | if ( dlg.exec() ) | 860 | if ( dlg.exec() ) |
859 | uids = dlg.uids(); | 861 | uids = dlg.uids(); |
860 | else | 862 | else |
861 | return; | 863 | return; |
862 | if ( uids.isEmpty() ) | 864 | if ( uids.isEmpty() ) |
863 | return; | 865 | return; |
864 | // qDebug("count %d ", uids.count()); | 866 | // qDebug("count %d ", uids.count()); |
865 | 867 | ||
866 | KAex2phonePrefs ex2phone; | 868 | KAex2phonePrefs ex2phone; |
867 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 869 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
868 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 870 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
869 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 871 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
870 | 872 | ||
871 | if ( !ex2phone.exec() ) { | 873 | if ( !ex2phone.exec() ) { |
872 | return; | 874 | return; |
873 | } | 875 | } |
874 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 876 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
875 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 877 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
876 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 878 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
877 | 879 | ||
878 | 880 | ||
879 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 881 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
880 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 882 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
881 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 883 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
882 | 884 | ||
883 | QString fileName = getPhoneFile(); | 885 | QString fileName = getPhoneFile(); |
884 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 886 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
885 | return; | 887 | return; |
886 | 888 | ||
887 | message(i18n("Exporting to phone...")); | 889 | message(i18n("Exporting to phone...")); |
888 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 890 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
889 | 891 | ||
890 | } | 892 | } |
891 | QString KABCore::getPhoneFile() | 893 | QString KABCore::getPhoneFile() |
892 | { | 894 | { |
893 | #ifdef DESKTOP_VERSION | 895 | #ifdef DESKTOP_VERSION |
894 | return locateLocal("tmp", "phonefile.vcf"); | 896 | return locateLocal("tmp", "phonefile.vcf"); |
895 | #else | 897 | #else |
896 | return "/tmp/phonefile.vcf"; | 898 | return "/tmp/phonefile.vcf"; |
897 | #endif | 899 | #endif |
898 | 900 | ||
899 | } | 901 | } |
900 | void KABCore::writeToPhone( ) | 902 | void KABCore::writeToPhone( ) |
901 | { | 903 | { |
902 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 904 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
903 | message(i18n("Export to phone finished!")); | 905 | message(i18n("Export to phone finished!")); |
904 | else | 906 | else |
905 | qDebug(i18n("Error exporting to phone")); | 907 | qDebug(i18n("Error exporting to phone")); |
906 | } | 908 | } |
907 | void KABCore::beamVCard() | 909 | void KABCore::beamVCard() |
908 | { | 910 | { |
909 | QStringList uids; | 911 | QStringList uids; |
910 | XXPortSelectDialog dlg( this, false, this ); | 912 | XXPortSelectDialog dlg( this, false, this ); |
911 | if ( dlg.exec() ) | 913 | if ( dlg.exec() ) |
912 | uids = dlg.uids(); | 914 | uids = dlg.uids(); |
913 | else | 915 | else |
914 | return; | 916 | return; |
915 | if ( uids.isEmpty() ) | 917 | if ( uids.isEmpty() ) |
916 | return; | 918 | return; |
917 | beamVCard( uids ); | 919 | beamVCard( uids ); |
918 | } | 920 | } |
919 | 921 | ||
920 | 922 | ||
921 | void KABCore::beamVCard(const QStringList& uids) | 923 | void KABCore::beamVCard(const QStringList& uids) |
922 | { | 924 | { |
923 | 925 | ||
924 | // LR: we should use the /tmp dir on the Zaurus, | 926 | // LR: we should use the /tmp dir on the Zaurus, |
925 | // because: /tmp = RAM, (HOME)/kdepim = flash memory | 927 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
926 | 928 | ||
927 | #ifdef DESKTOP_VERSION | 929 | #ifdef DESKTOP_VERSION |
928 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | 930 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); |
929 | #else | 931 | #else |
930 | QString fileName = "/tmp/kapibeamfile.vcf"; | 932 | QString fileName = "/tmp/kapibeamfile.vcf"; |
931 | #endif | 933 | #endif |
932 | 934 | ||
933 | KABC::VCardConverter converter; | 935 | KABC::VCardConverter converter; |
934 | QString description; | 936 | QString description; |
935 | QString datastream; | 937 | QString datastream; |
936 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 938 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
937 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 939 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
938 | 940 | ||
939 | if ( a.isEmpty() ) | 941 | if ( a.isEmpty() ) |
940 | continue; | 942 | continue; |
941 | 943 | ||
942 | if (description.isEmpty()) | 944 | if (description.isEmpty()) |
943 | description = a.formattedName(); | 945 | description = a.formattedName(); |
944 | 946 | ||
945 | QString vcard; | 947 | QString vcard; |
946 | converter.addresseeToVCard( a, vcard ); | 948 | converter.addresseeToVCard( a, vcard ); |
947 | int start = 0; | 949 | int start = 0; |
948 | int next; | 950 | int next; |
949 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 951 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
950 | int semi = vcard.find(";", next); | 952 | int semi = vcard.find(";", next); |
951 | int dopp = vcard.find(":", next); | 953 | int dopp = vcard.find(":", next); |
952 | int sep; | 954 | int sep; |
953 | if ( semi < dopp && semi >= 0 ) | 955 | if ( semi < dopp && semi >= 0 ) |
954 | sep = semi ; | 956 | sep = semi ; |
955 | else | 957 | else |
956 | sep = dopp; | 958 | sep = dopp; |
957 | datastream +=vcard.mid( start, next - start); | 959 | datastream +=vcard.mid( start, next - start); |
958 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 960 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
959 | start = sep; | 961 | start = sep; |
960 | } | 962 | } |
961 | datastream += vcard.mid( start,vcard.length() ); | 963 | datastream += vcard.mid( start,vcard.length() ); |
962 | } | 964 | } |
963 | #ifndef DESKTOP_VERSION | 965 | #ifndef DESKTOP_VERSION |
964 | QFile outFile(fileName); | 966 | QFile outFile(fileName); |
965 | if ( outFile.open(IO_WriteOnly) ) { | 967 | if ( outFile.open(IO_WriteOnly) ) { |
966 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 968 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
967 | QTextStream t( &outFile ); // use a text stream | 969 | QTextStream t( &outFile ); // use a text stream |
968 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 970 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
969 | t.setEncoding( QTextStream::Latin1 ); | 971 | t.setEncoding( QTextStream::Latin1 ); |
970 | t <<datastream.latin1(); | 972 | t <<datastream.latin1(); |
971 | outFile.close(); | 973 | outFile.close(); |
972 | Ir *ir = new Ir( this ); | 974 | Ir *ir = new Ir( this ); |
973 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 975 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
974 | ir->send( fileName, description, "text/x-vCard" ); | 976 | ir->send( fileName, description, "text/x-vCard" ); |
975 | } else { | 977 | } else { |
976 | qDebug("Error open temp beam file "); | 978 | qDebug("Error open temp beam file "); |
977 | return; | 979 | return; |
978 | } | 980 | } |
979 | #endif | 981 | #endif |
980 | 982 | ||
981 | } | 983 | } |
982 | 984 | ||
983 | void KABCore::beamDone( Ir *ir ) | 985 | void KABCore::beamDone( Ir *ir ) |
984 | { | 986 | { |
985 | #ifndef DESKTOP_VERSION | 987 | #ifndef DESKTOP_VERSION |
986 | delete ir; | 988 | delete ir; |
987 | #endif | 989 | #endif |
988 | topLevelWidget()->raise(); | 990 | topLevelWidget()->raise(); |
989 | message( i18n("Beaming finished!") ); | 991 | message( i18n("Beaming finished!") ); |
990 | } | 992 | } |
991 | 993 | ||
992 | 994 | ||
993 | void KABCore::browse( const QString& url ) | 995 | void KABCore::browse( const QString& url ) |
994 | { | 996 | { |
995 | #ifndef KAB_EMBEDDED | 997 | #ifndef KAB_EMBEDDED |
996 | kapp->invokeBrowser( url ); | 998 | kapp->invokeBrowser( url ); |
997 | #else //KAB_EMBEDDED | 999 | #else //KAB_EMBEDDED |
998 | qDebug("KABCore::browse must be fixed"); | 1000 | qDebug("KABCore::browse must be fixed"); |
999 | #endif //KAB_EMBEDDED | 1001 | #endif //KAB_EMBEDDED |
1000 | } | 1002 | } |
1001 | 1003 | ||
1002 | void KABCore::selectAllContacts() | 1004 | void KABCore::selectAllContacts() |
1003 | { | 1005 | { |
1004 | mViewManager->setSelected( QString::null, true ); | 1006 | mViewManager->setSelected( QString::null, true ); |
1005 | } | 1007 | } |
1006 | 1008 | ||
1007 | void KABCore::deleteContacts() | 1009 | void KABCore::deleteContacts() |
1008 | { | 1010 | { |
1009 | QStringList uidList = mViewManager->selectedUids(); | 1011 | QStringList uidList = mViewManager->selectedUids(); |
1010 | deleteContacts( uidList ); | 1012 | deleteContacts( uidList ); |
1011 | } | 1013 | } |
1012 | 1014 | ||
1013 | void KABCore::deleteContacts( const QStringList &uids ) | 1015 | void KABCore::deleteContacts( const QStringList &uids ) |
1014 | { | 1016 | { |
1015 | if ( uids.count() > 0 ) { | 1017 | if ( uids.count() > 0 ) { |
1016 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 1018 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
1017 | UndoStack::instance()->push( command ); | 1019 | UndoStack::instance()->push( command ); |
1018 | RedoStack::instance()->clear(); | 1020 | RedoStack::instance()->clear(); |
1019 | 1021 | ||
1020 | // now if we deleted anything, refresh | 1022 | // now if we deleted anything, refresh |
1021 | setContactSelected( QString::null ); | 1023 | setContactSelected( QString::null ); |
1022 | setModified( true ); | 1024 | setModified( true ); |
1023 | } | 1025 | } |
1024 | } | 1026 | } |
1025 | 1027 | ||
1026 | void KABCore::copyContacts() | 1028 | void KABCore::copyContacts() |
1027 | { | 1029 | { |
1028 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1030 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1029 | 1031 | ||
1030 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 1032 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
1031 | 1033 | ||
1032 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 1034 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
1033 | 1035 | ||
1034 | QClipboard *cb = QApplication::clipboard(); | 1036 | QClipboard *cb = QApplication::clipboard(); |
1035 | cb->setText( clipText ); | 1037 | cb->setText( clipText ); |
1036 | } | 1038 | } |
1037 | 1039 | ||
1038 | void KABCore::cutContacts() | 1040 | void KABCore::cutContacts() |
1039 | { | 1041 | { |
1040 | QStringList uidList = mViewManager->selectedUids(); | 1042 | QStringList uidList = mViewManager->selectedUids(); |
1041 | 1043 | ||
1042 | //US if ( uidList.size() > 0 ) { | 1044 | //US if ( uidList.size() > 0 ) { |
1043 | if ( uidList.count() > 0 ) { | 1045 | if ( uidList.count() > 0 ) { |
1044 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 1046 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
1045 | UndoStack::instance()->push( command ); | 1047 | UndoStack::instance()->push( command ); |
1046 | RedoStack::instance()->clear(); | 1048 | RedoStack::instance()->clear(); |
1047 | 1049 | ||
1048 | setModified( true ); | 1050 | setModified( true ); |
1049 | } | 1051 | } |
1050 | } | 1052 | } |
1051 | 1053 | ||
1052 | void KABCore::pasteContacts() | 1054 | void KABCore::pasteContacts() |
1053 | { | 1055 | { |
1054 | QClipboard *cb = QApplication::clipboard(); | 1056 | QClipboard *cb = QApplication::clipboard(); |
1055 | 1057 | ||
1056 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 1058 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
1057 | 1059 | ||
1058 | pasteContacts( list ); | 1060 | pasteContacts( list ); |
1059 | } | 1061 | } |
1060 | 1062 | ||
1061 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 1063 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
1062 | { | 1064 | { |
1063 | KABC::Resource *resource = requestResource( this ); | 1065 | KABC::Resource *resource = requestResource( this ); |
1064 | KABC::Addressee::List::Iterator it; | 1066 | KABC::Addressee::List::Iterator it; |
1065 | for ( it = list.begin(); it != list.end(); ++it ) | 1067 | for ( it = list.begin(); it != list.end(); ++it ) |
1066 | (*it).setResource( resource ); | 1068 | (*it).setResource( resource ); |
1067 | 1069 | ||
1068 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 1070 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
1069 | UndoStack::instance()->push( command ); | 1071 | UndoStack::instance()->push( command ); |
1070 | RedoStack::instance()->clear(); | 1072 | RedoStack::instance()->clear(); |
1071 | 1073 | ||
1072 | setModified( true ); | 1074 | setModified( true ); |
1073 | } | 1075 | } |
1074 | 1076 | ||
1075 | void KABCore::setWhoAmI() | 1077 | void KABCore::setWhoAmI() |
1076 | { | 1078 | { |
1077 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1079 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1078 | 1080 | ||
1079 | if ( addrList.count() > 1 ) { | 1081 | if ( addrList.count() > 1 ) { |
1080 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 1082 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
1081 | return; | 1083 | return; |
1082 | } | 1084 | } |
1083 | 1085 | ||
1084 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 1086 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
1085 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 1087 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
1086 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 1088 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
1087 | } | 1089 | } |
1088 | void KABCore::editCategories() | 1090 | void KABCore::editCategories() |
1089 | { | 1091 | { |
1090 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); | 1092 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); |
1091 | dlg.exec(); | 1093 | dlg.exec(); |
1092 | } | 1094 | } |
1093 | void KABCore::setCategories() | 1095 | void KABCore::setCategories() |
1094 | { | 1096 | { |
1095 | 1097 | ||
1096 | QStringList uids; | 1098 | QStringList uids; |
1097 | XXPortSelectDialog dlgx( this, false, this ); | 1099 | XXPortSelectDialog dlgx( this, false, this ); |
1098 | if ( dlgx.exec() ) | 1100 | if ( dlgx.exec() ) |
1099 | uids = dlgx.uids(); | 1101 | uids = dlgx.uids(); |
1100 | else | 1102 | else |
1101 | return; | 1103 | return; |
1102 | if ( uids.isEmpty() ) | 1104 | if ( uids.isEmpty() ) |
1103 | return; | 1105 | return; |
1104 | // qDebug("count %d ", uids.count()); | 1106 | // qDebug("count %d ", uids.count()); |
1105 | 1107 | ||
1106 | 1108 | ||
1107 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 1109 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
1108 | if ( !dlg.exec() ) { | 1110 | if ( !dlg.exec() ) { |
1109 | message( i18n("Setting categories cancelled") ); | 1111 | message( i18n("Setting categories cancelled") ); |
1110 | return; | 1112 | return; |
1111 | } | 1113 | } |
1112 | bool merge = false; | 1114 | bool merge = false; |
1113 | QString msg = i18n( "Merge with existing categories?" ); | 1115 | QString msg = i18n( "Merge with existing categories?" ); |
1114 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 1116 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
1115 | merge = true; | 1117 | merge = true; |
1116 | 1118 | ||
1117 | message( i18n("Setting categories ... please wait!") ); | 1119 | message( i18n("Setting categories ... please wait!") ); |
1118 | QStringList categories = dlg.selectedCategories(); | 1120 | QStringList categories = dlg.selectedCategories(); |
1119 | 1121 | ||
1120 | //QStringList uids = mViewManager->selectedUids(); | 1122 | //QStringList uids = mViewManager->selectedUids(); |
1121 | QStringList::Iterator it; | 1123 | QStringList::Iterator it; |
1122 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 1124 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
1123 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 1125 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
1124 | if ( !addr.isEmpty() ) { | 1126 | if ( !addr.isEmpty() ) { |
1125 | if ( !merge ) | 1127 | if ( !merge ) |
1126 | addr.setCategories( categories ); | 1128 | addr.setCategories( categories ); |
1127 | else { | 1129 | else { |
1128 | QStringList addrCategories = addr.categories(); | 1130 | QStringList addrCategories = addr.categories(); |
1129 | QStringList::Iterator catIt; | 1131 | QStringList::Iterator catIt; |
1130 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 1132 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
1131 | if ( !addrCategories.contains( *catIt ) ) | 1133 | if ( !addrCategories.contains( *catIt ) ) |
1132 | addrCategories.append( *catIt ); | 1134 | addrCategories.append( *catIt ); |
1133 | } | 1135 | } |
1134 | addr.setCategories( addrCategories ); | 1136 | addr.setCategories( addrCategories ); |
1135 | } | 1137 | } |
1136 | mAddressBook->insertAddressee( addr ); | 1138 | mAddressBook->insertAddressee( addr ); |
1137 | } | 1139 | } |
1138 | } | 1140 | } |
1139 | 1141 | ||
1140 | if ( uids.count() > 0 ) | 1142 | if ( uids.count() > 0 ) |
1141 | setModified( true ); | 1143 | setModified( true ); |
1142 | message( i18n("Setting categories completed!") ); | 1144 | message( i18n("Setting categories completed!") ); |
1143 | } | 1145 | } |
1144 | 1146 | ||
1145 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1147 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1146 | { | 1148 | { |
1147 | mIncSearchWidget->setFields( fields ); | 1149 | mIncSearchWidget->setFields( fields ); |
1148 | } | 1150 | } |
1149 | 1151 | ||
1150 | void KABCore::incrementalSearch( const QString& text ) | 1152 | void KABCore::incrementalSearch( const QString& text ) |
1151 | { | 1153 | { |
1152 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1154 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1153 | } | 1155 | } |
1154 | 1156 | ||
1155 | void KABCore::setModified() | 1157 | void KABCore::setModified() |
1156 | { | 1158 | { |
1157 | setModified( true ); | 1159 | setModified( true ); |
1158 | } | 1160 | } |
1159 | 1161 | ||
1160 | void KABCore::setModifiedWOrefresh() | 1162 | void KABCore::setModifiedWOrefresh() |
1161 | { | 1163 | { |
1162 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1164 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1163 | mModified = true; | 1165 | mModified = true; |
1164 | mActionSave->setEnabled( mModified ); | 1166 | mActionSave->setEnabled( mModified ); |
1165 | 1167 | ||
1166 | 1168 | ||
1167 | } | 1169 | } |
1168 | void KABCore::setModified( bool modified ) | 1170 | void KABCore::setModified( bool modified ) |
1169 | { | 1171 | { |
1170 | mModified = modified; | 1172 | mModified = modified; |
1171 | mActionSave->setEnabled( mModified ); | 1173 | mActionSave->setEnabled( mModified ); |
1172 | 1174 | ||
1173 | if ( modified ) | 1175 | if ( modified ) |
1174 | mJumpButtonBar->recreateButtons(); | 1176 | mJumpButtonBar->recreateButtons(); |
1175 | 1177 | ||
1176 | mViewManager->refreshView(); | 1178 | mViewManager->refreshView(); |
1177 | 1179 | ||
1178 | } | 1180 | } |
1179 | 1181 | ||
1180 | bool KABCore::modified() const | 1182 | bool KABCore::modified() const |
1181 | { | 1183 | { |
1182 | return mModified; | 1184 | return mModified; |
1183 | } | 1185 | } |
1184 | 1186 | ||
1185 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1187 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1186 | { | 1188 | { |
1187 | addrModified( addr ); | 1189 | addrModified( addr ); |
1188 | } | 1190 | } |
1189 | 1191 | ||
1190 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) | 1192 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) |
1191 | { | 1193 | { |
1192 | 1194 | ||
1193 | Command *command = 0; | 1195 | Command *command = 0; |
1194 | QString uid; | 1196 | QString uid; |
1195 | 1197 | ||
1196 | // check if it exists already | 1198 | // check if it exists already |
1197 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1199 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1198 | if ( origAddr.isEmpty() ) | 1200 | if ( origAddr.isEmpty() ) |
1199 | command = new PwNewCommand( mAddressBook, addr ); | 1201 | command = new PwNewCommand( mAddressBook, addr ); |
1200 | else { | 1202 | else { |
1201 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1203 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1202 | uid = addr.uid(); | 1204 | uid = addr.uid(); |
1203 | } | 1205 | } |
1204 | 1206 | ||
1205 | UndoStack::instance()->push( command ); | 1207 | UndoStack::instance()->push( command ); |
1206 | RedoStack::instance()->clear(); | 1208 | RedoStack::instance()->clear(); |
1207 | if ( updateDetails ) | 1209 | if ( updateDetails ) |
1208 | mDetails->setAddressee( addr ); | 1210 | mDetails->setAddressee( addr ); |
1209 | setModified( true ); | 1211 | setModified( true ); |
1210 | } | 1212 | } |
1211 | 1213 | ||
1212 | void KABCore::newContact() | 1214 | void KABCore::newContact() |
1213 | { | 1215 | { |
1214 | 1216 | ||
1215 | 1217 | ||
1216 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1218 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1217 | 1219 | ||
1218 | QPtrList<KRES::Resource> kresResources; | 1220 | QPtrList<KRES::Resource> kresResources; |
1219 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1221 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1220 | KABC::Resource *resource; | 1222 | KABC::Resource *resource; |
1221 | while ( ( resource = it.current() ) != 0 ) { | 1223 | while ( ( resource = it.current() ) != 0 ) { |
1222 | ++it; | 1224 | ++it; |
1223 | if ( !resource->readOnly() ) { | 1225 | if ( !resource->readOnly() ) { |
1224 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1226 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1225 | if ( res ) | 1227 | if ( res ) |
1226 | kresResources.append( res ); | 1228 | kresResources.append( res ); |
1227 | } | 1229 | } |
1228 | } | 1230 | } |
1229 | 1231 | ||
1230 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1232 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1231 | resource = static_cast<KABC::Resource*>( res ); | 1233 | resource = static_cast<KABC::Resource*>( res ); |
1232 | 1234 | ||
1233 | if ( resource ) { | 1235 | if ( resource ) { |
1234 | KABC::Addressee addr; | 1236 | KABC::Addressee addr; |
1235 | addr.setResource( resource ); | 1237 | addr.setResource( resource ); |
1236 | mEditorDialog->setAddressee( addr ); | 1238 | mEditorDialog->setAddressee( addr ); |
1237 | KApplication::execDialog ( mEditorDialog ); | 1239 | KApplication::execDialog ( mEditorDialog ); |
1238 | 1240 | ||
1239 | } else | 1241 | } else |
1240 | return; | 1242 | return; |
1241 | 1243 | ||
1242 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1244 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1243 | 1245 | ||
1244 | 1246 | ||
1245 | } | 1247 | } |
1246 | 1248 | ||
1247 | void KABCore::addEmail( QString aStr ) | 1249 | void KABCore::addEmail( QString aStr ) |
1248 | { | 1250 | { |
1249 | #ifndef KAB_EMBEDDED | 1251 | #ifndef KAB_EMBEDDED |
1250 | QString fullName, email; | 1252 | QString fullName, email; |
1251 | 1253 | ||
1252 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1254 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1253 | 1255 | ||
1254 | // Try to lookup the addressee matching the email address | 1256 | // Try to lookup the addressee matching the email address |
1255 | bool found = false; | 1257 | bool found = false; |
1256 | QStringList emailList; | 1258 | QStringList emailList; |
1257 | KABC::AddressBook::Iterator it; | 1259 | KABC::AddressBook::Iterator it; |
1258 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1260 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1259 | emailList = (*it).emails(); | 1261 | emailList = (*it).emails(); |
1260 | if ( emailList.contains( email ) > 0 ) { | 1262 | if ( emailList.contains( email ) > 0 ) { |
1261 | found = true; | 1263 | found = true; |
1262 | (*it).setNameFromString( fullName ); | 1264 | (*it).setNameFromString( fullName ); |
1263 | editContact( (*it).uid() ); | 1265 | editContact( (*it).uid() ); |
1264 | } | 1266 | } |
1265 | } | 1267 | } |
1266 | 1268 | ||
1267 | if ( !found ) { | 1269 | if ( !found ) { |
1268 | KABC::Addressee addr; | 1270 | KABC::Addressee addr; |
1269 | addr.setNameFromString( fullName ); | 1271 | addr.setNameFromString( fullName ); |
1270 | addr.insertEmail( email, true ); | 1272 | addr.insertEmail( email, true ); |
1271 | 1273 | ||
1272 | mAddressBook->insertAddressee( addr ); | 1274 | mAddressBook->insertAddressee( addr ); |
1273 | mViewManager->refreshView( addr.uid() ); | 1275 | mViewManager->refreshView( addr.uid() ); |
1274 | editContact( addr.uid() ); | 1276 | editContact( addr.uid() ); |
1275 | } | 1277 | } |
1276 | #else //KAB_EMBEDDED | 1278 | #else //KAB_EMBEDDED |
1277 | qDebug("KABCore::addEmail finsih method"); | 1279 | qDebug("KABCore::addEmail finsih method"); |
1278 | #endif //KAB_EMBEDDED | 1280 | #endif //KAB_EMBEDDED |
1279 | } | 1281 | } |
1280 | 1282 | ||
1281 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1283 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1282 | { | 1284 | { |
1283 | mXXPortManager->importVCard( url, showPreview ); | 1285 | mXXPortManager->importVCard( url, showPreview ); |
1284 | } | 1286 | } |
1285 | void KABCore::importFromOL() | 1287 | void KABCore::importFromOL() |
1286 | { | 1288 | { |
1287 | #ifdef _WIN32_ | 1289 | #ifdef _WIN32_ |
1288 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1290 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1289 | idgl->exec(); | 1291 | idgl->exec(); |
1290 | KABC::Addressee::List list = idgl->getAddressList(); | 1292 | KABC::Addressee::List list = idgl->getAddressList(); |
1291 | if ( list.count() > 0 ) { | 1293 | if ( list.count() > 0 ) { |
1292 | KABC::Addressee::List listNew; | 1294 | KABC::Addressee::List listNew; |
1293 | KABC::Addressee::List listExisting; | 1295 | KABC::Addressee::List listExisting; |
1294 | KABC::Addressee::List::Iterator it; | 1296 | KABC::Addressee::List::Iterator it; |
1295 | KABC::AddressBook::Iterator iter; | 1297 | KABC::AddressBook::Iterator iter; |
1296 | for ( it = list.begin(); it != list.end(); ++it ) { | 1298 | for ( it = list.begin(); it != list.end(); ++it ) { |
1297 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1299 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1298 | listNew.append( (*it) ); | 1300 | listNew.append( (*it) ); |
1299 | else | 1301 | else |
1300 | listExisting.append( (*it) ); | 1302 | listExisting.append( (*it) ); |
1301 | } | 1303 | } |
1302 | if ( listExisting.count() > 0 ) | 1304 | if ( listExisting.count() > 0 ) |
1303 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1305 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1304 | if ( listNew.count() > 0 ) { | 1306 | if ( listNew.count() > 0 ) { |
1305 | pasteWithNewUid = false; | 1307 | pasteWithNewUid = false; |
1306 | pasteContacts( listNew ); | 1308 | pasteContacts( listNew ); |
1307 | pasteWithNewUid = true; | 1309 | pasteWithNewUid = true; |
1308 | } | 1310 | } |
1309 | } | 1311 | } |
1310 | delete idgl; | 1312 | delete idgl; |
1311 | #endif | 1313 | #endif |
1312 | } | 1314 | } |
1313 | 1315 | ||
1314 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1316 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1315 | { | 1317 | { |
1316 | mXXPortManager->importVCard( vCard, showPreview ); | 1318 | mXXPortManager->importVCard( vCard, showPreview ); |
1317 | } | 1319 | } |
1318 | 1320 | ||
1319 | //US added a second method without defaultparameter | 1321 | //US added a second method without defaultparameter |
1320 | void KABCore::editContact2() { | 1322 | void KABCore::editContact2() { |
1321 | editContact( QString::null ); | 1323 | editContact( QString::null ); |
1322 | } | 1324 | } |
1323 | 1325 | ||
1324 | void KABCore::editContact( const QString &uid ) | 1326 | void KABCore::editContact( const QString &uid ) |
1325 | { | 1327 | { |
1326 | 1328 | ||
1327 | if ( mExtensionManager->isQuickEditVisible() ) | 1329 | if ( mExtensionManager->isQuickEditVisible() ) |
1328 | return; | 1330 | return; |
1329 | 1331 | ||
1330 | // First, locate the contact entry | 1332 | // First, locate the contact entry |
1331 | QString localUID = uid; | 1333 | QString localUID = uid; |
1332 | if ( localUID.isNull() ) { | 1334 | if ( localUID.isNull() ) { |
1333 | QStringList uidList = mViewManager->selectedUids(); | 1335 | QStringList uidList = mViewManager->selectedUids(); |
1334 | if ( uidList.count() > 0 ) | 1336 | if ( uidList.count() > 0 ) |
1335 | localUID = *( uidList.at( 0 ) ); | 1337 | localUID = *( uidList.at( 0 ) ); |
1336 | } | 1338 | } |
1337 | 1339 | ||
1338 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1340 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1339 | if ( !addr.isEmpty() ) { | 1341 | if ( !addr.isEmpty() ) { |
1340 | mEditorDialog->setAddressee( addr ); | 1342 | mEditorDialog->setAddressee( addr ); |
1341 | KApplication::execDialog ( mEditorDialog ); | 1343 | KApplication::execDialog ( mEditorDialog ); |
1342 | } | 1344 | } |
1343 | } | 1345 | } |
1344 | 1346 | ||
1345 | /** | 1347 | /** |
1346 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1348 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1347 | the method will try to find a selected addressee in the view. | 1349 | the method will try to find a selected addressee in the view. |
1348 | */ | 1350 | */ |
1349 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1351 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1350 | { | 1352 | { |
1351 | if ( mMultipleViewsAtOnce ) | 1353 | if ( mMultipleViewsAtOnce ) |
1352 | { | 1354 | { |
1353 | editContact( uid ); | 1355 | editContact( uid ); |
1354 | } | 1356 | } |
1355 | else | 1357 | else |
1356 | { | 1358 | { |
1357 | setDetailsVisible( true ); | 1359 | setDetailsVisible( true ); |
1358 | mActionDetails->setChecked(true); | 1360 | mActionDetails->setChecked(true); |
1359 | } | 1361 | } |
1360 | 1362 | ||
1361 | } | 1363 | } |
1362 | 1364 | ||
1363 | void KABCore::save() | 1365 | void KABCore::save() |
1364 | { | 1366 | { |
1365 | if (syncManager->blockSave()) | 1367 | if (syncManager->blockSave()) |
1366 | return; | 1368 | return; |
1367 | if ( !mModified ) | 1369 | if ( !mModified ) |
1368 | return; | 1370 | return; |
1369 | 1371 | ||
1370 | syncManager->setBlockSave(true); | 1372 | syncManager->setBlockSave(true); |
1371 | QString text = i18n( "There was an error while attempting to save\n the " | 1373 | QString text = i18n( "There was an error while attempting to save\n the " |
1372 | "address book. Please check that some \nother application is " | 1374 | "address book. Please check that some \nother application is " |
1373 | "not using it. " ); | 1375 | "not using it. " ); |
1374 | message(i18n("Saving addressbook ... ")); | 1376 | message(i18n("Saving addressbook ... ")); |
1375 | #ifndef KAB_EMBEDDED | 1377 | #ifndef KAB_EMBEDDED |
1376 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1378 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1377 | if ( !b || !b->save() ) { | 1379 | if ( !b || !b->save() ) { |
1378 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1380 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1379 | } | 1381 | } |
1380 | #else //KAB_EMBEDDED | 1382 | #else //KAB_EMBEDDED |
1381 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1383 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1382 | if ( !b || !b->save() ) { | 1384 | if ( !b || !b->save() ) { |
1383 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1385 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1384 | } | 1386 | } |
1385 | #endif //KAB_EMBEDDED | 1387 | #endif //KAB_EMBEDDED |
1386 | 1388 | ||
1387 | message(i18n("Addressbook saved!")); | 1389 | message(i18n("Addressbook saved!")); |
1388 | setModified( false ); | 1390 | setModified( false ); |
1389 | syncManager->setBlockSave(false); | 1391 | syncManager->setBlockSave(false); |
1390 | } | 1392 | } |
1391 | 1393 | ||
1392 | 1394 | ||
1393 | void KABCore::undo() | 1395 | void KABCore::undo() |
1394 | { | 1396 | { |
1395 | UndoStack::instance()->undo(); | 1397 | UndoStack::instance()->undo(); |
1396 | 1398 | ||
1397 | // Refresh the view | 1399 | // Refresh the view |
1398 | mViewManager->refreshView(); | 1400 | mViewManager->refreshView(); |
1399 | } | 1401 | } |
1400 | 1402 | ||
1401 | void KABCore::redo() | 1403 | void KABCore::redo() |
1402 | { | 1404 | { |
1403 | RedoStack::instance()->redo(); | 1405 | RedoStack::instance()->redo(); |
1404 | 1406 | ||
1405 | // Refresh the view | 1407 | // Refresh the view |
1406 | mViewManager->refreshView(); | 1408 | mViewManager->refreshView(); |
1407 | } | 1409 | } |
1408 | 1410 | ||
1409 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1411 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1410 | { | 1412 | { |
1411 | if (mMultipleViewsAtOnce) | 1413 | if (mMultipleViewsAtOnce) |
1412 | { | 1414 | { |
1413 | if ( visible ) | 1415 | if ( visible ) |
1414 | mJumpButtonBar->show(); | 1416 | mJumpButtonBar->show(); |
1415 | else | 1417 | else |
1416 | mJumpButtonBar->hide(); | 1418 | mJumpButtonBar->hide(); |
1417 | } | 1419 | } |
1418 | else | 1420 | else |
1419 | { | 1421 | { |
1420 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1422 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1421 | if (mViewManager->isVisible()) | 1423 | if (mViewManager->isVisible()) |
1422 | { | 1424 | { |
1423 | if ( visible ) | 1425 | if ( visible ) |
1424 | mJumpButtonBar->show(); | 1426 | mJumpButtonBar->show(); |
1425 | else | 1427 | else |
1426 | mJumpButtonBar->hide(); | 1428 | mJumpButtonBar->hide(); |
1427 | } | 1429 | } |
1428 | else | 1430 | else |
1429 | { | 1431 | { |
1430 | mJumpButtonBar->hide(); | 1432 | mJumpButtonBar->hide(); |
1431 | } | 1433 | } |
1432 | } | 1434 | } |
1433 | } | 1435 | } |
1434 | 1436 | ||
1435 | 1437 | ||
1436 | void KABCore::setDetailsToState() | 1438 | void KABCore::setDetailsToState() |
1437 | { | 1439 | { |
1438 | setDetailsVisible( mActionDetails->isChecked() ); | 1440 | setDetailsVisible( mActionDetails->isChecked() ); |
1439 | } | 1441 | } |
1440 | void KABCore::setDetailsToggle() | 1442 | void KABCore::setDetailsToggle() |
1441 | { | 1443 | { |
1442 | mActionDetails->setChecked( !mActionDetails->isChecked() ); | 1444 | mActionDetails->setChecked( !mActionDetails->isChecked() ); |
1443 | setDetailsToState(); | 1445 | setDetailsToState(); |
1444 | } | 1446 | } |
1445 | 1447 | ||
1446 | 1448 | ||
1447 | 1449 | ||
1448 | void KABCore::setDetailsVisible( bool visible ) | 1450 | void KABCore::setDetailsVisible( bool visible ) |
1449 | { | 1451 | { |
1450 | if (visible && mDetails->isHidden()) | 1452 | if (visible && mDetails->isHidden()) |
1451 | { | 1453 | { |
1452 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1454 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1453 | if ( addrList.count() > 0 ) | 1455 | if ( addrList.count() > 0 ) |
1454 | mDetails->setAddressee( addrList[ 0 ] ); | 1456 | mDetails->setAddressee( addrList[ 0 ] ); |
1455 | } | 1457 | } |
1456 | 1458 | ||
1457 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1459 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1458 | // the listview and the detailview. We do that by changing the splitbar size. | 1460 | // the listview and the detailview. We do that by changing the splitbar size. |
1459 | if (mMultipleViewsAtOnce) | 1461 | if (mMultipleViewsAtOnce) |
1460 | { | 1462 | { |
1461 | if ( visible ) | 1463 | if ( visible ) |
1462 | mDetails->show(); | 1464 | mDetails->show(); |
1463 | else | 1465 | else |
1464 | mDetails->hide(); | 1466 | mDetails->hide(); |
1465 | } | 1467 | } |
1466 | else | 1468 | else |
1467 | { | 1469 | { |
1468 | if ( visible ) { | 1470 | if ( visible ) { |
1469 | mViewManager->hide(); | 1471 | mViewManager->hide(); |
1470 | mDetails->show(); | 1472 | mDetails->show(); |
1471 | mIncSearchWidget->setFocus(); | 1473 | mIncSearchWidget->setFocus(); |
1472 | } | 1474 | } |
1473 | else { | 1475 | else { |
1474 | mViewManager->show(); | 1476 | mViewManager->show(); |
1475 | mDetails->hide(); | 1477 | mDetails->hide(); |
1476 | mViewManager->setFocusAV(); | 1478 | mViewManager->setFocusAV(); |
1477 | } | 1479 | } |
1478 | setJumpButtonBarVisible( !visible ); | 1480 | setJumpButtonBarVisible( !visible ); |
1479 | } | 1481 | } |
1480 | 1482 | ||
1481 | } | 1483 | } |
1482 | 1484 | ||
1483 | void KABCore::extensionChanged( int id ) | 1485 | void KABCore::extensionChanged( int id ) |
1484 | { | 1486 | { |
1485 | //change the details view only for non desktop systems | 1487 | //change the details view only for non desktop systems |
1486 | #ifndef DESKTOP_VERSION | 1488 | #ifndef DESKTOP_VERSION |
1487 | 1489 | ||
1488 | if (id == 0) | 1490 | if (id == 0) |
1489 | { | 1491 | { |
1490 | //the user disabled the extension. | 1492 | //the user disabled the extension. |
1491 | 1493 | ||
1492 | if (mMultipleViewsAtOnce) | 1494 | if (mMultipleViewsAtOnce) |
1493 | { // enable detailsview again | 1495 | { // enable detailsview again |
1494 | setDetailsVisible( true ); | 1496 | setDetailsVisible( true ); |
1495 | mActionDetails->setChecked( true ); | 1497 | mActionDetails->setChecked( true ); |
1496 | } | 1498 | } |
1497 | else | 1499 | else |
1498 | { //go back to the listview | 1500 | { //go back to the listview |
1499 | setDetailsVisible( false ); | 1501 | setDetailsVisible( false ); |
1500 | mActionDetails->setChecked( false ); | 1502 | mActionDetails->setChecked( false ); |
1501 | mActionDetails->setEnabled(true); | 1503 | mActionDetails->setEnabled(true); |
1502 | } | 1504 | } |
1503 | 1505 | ||
1504 | } | 1506 | } |
1505 | else | 1507 | else |
1506 | { | 1508 | { |
1507 | //the user enabled the extension. | 1509 | //the user enabled the extension. |
1508 | setDetailsVisible( false ); | 1510 | setDetailsVisible( false ); |
1509 | mActionDetails->setChecked( false ); | 1511 | mActionDetails->setChecked( false ); |
1510 | 1512 | ||
1511 | if (!mMultipleViewsAtOnce) | 1513 | if (!mMultipleViewsAtOnce) |
1512 | { | 1514 | { |
1513 | mActionDetails->setEnabled(false); | 1515 | mActionDetails->setEnabled(false); |
1514 | } | 1516 | } |
1515 | 1517 | ||
1516 | mExtensionManager->setSelectionChanged(); | 1518 | mExtensionManager->setSelectionChanged(); |
1517 | 1519 | ||
1518 | } | 1520 | } |
1519 | 1521 | ||
1520 | #endif// DESKTOP_VERSION | 1522 | #endif// DESKTOP_VERSION |
1521 | 1523 | ||
1522 | } | 1524 | } |
1523 | 1525 | ||
1524 | 1526 | ||
1525 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1527 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1526 | { | 1528 | { |
1527 | 1529 | ||
1528 | if ( list.count() != 0 ) { | 1530 | if ( list.count() != 0 ) { |
1529 | KABC::Addressee::List::ConstIterator it; | 1531 | KABC::Addressee::List::ConstIterator it; |
1530 | for ( it = list.begin(); it != list.end(); ++it ) | 1532 | for ( it = list.begin(); it != list.end(); ++it ) |
1531 | mAddressBook->insertAddressee( *it ); | 1533 | mAddressBook->insertAddressee( *it ); |
1532 | if ( list.count() > 1 ) | 1534 | if ( list.count() > 1 ) |
1533 | setModified(); | 1535 | setModified(); |
1534 | else | 1536 | else |
1535 | setModifiedWOrefresh(); | 1537 | setModifiedWOrefresh(); |
1536 | } | 1538 | } |
1537 | if ( list.count() == 0 ) | 1539 | if ( list.count() == 0 ) |
1538 | mViewManager->refreshView(); | 1540 | mViewManager->refreshView(); |
1539 | else | 1541 | else |
1540 | mViewManager->refreshView( list[ 0 ].uid() ); | 1542 | mViewManager->refreshView( list[ 0 ].uid() ); |
1541 | 1543 | ||
1542 | 1544 | ||
1543 | 1545 | ||
1544 | } | 1546 | } |
1545 | 1547 | ||
1546 | QString KABCore::getNameByPhone( const QString &phone ) | 1548 | QString KABCore::getNameByPhone( const QString &phone ) |
1547 | { | 1549 | { |
1548 | #ifndef KAB_EMBEDDED | 1550 | #ifndef KAB_EMBEDDED |
1549 | QRegExp r( "[/*/-/ ]" ); | 1551 | QRegExp r( "[/*/-/ ]" ); |
1550 | QString localPhone( phone ); | 1552 | QString localPhone( phone ); |
1551 | 1553 | ||
1552 | bool found = false; | 1554 | bool found = false; |
1553 | QString ownerName = ""; | 1555 | QString ownerName = ""; |
1554 | KABC::AddressBook::Iterator iter; | 1556 | KABC::AddressBook::Iterator iter; |
1555 | KABC::PhoneNumber::List::Iterator phoneIter; | 1557 | KABC::PhoneNumber::List::Iterator phoneIter; |
1556 | KABC::PhoneNumber::List phoneList; | 1558 | KABC::PhoneNumber::List phoneList; |
1557 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1559 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1558 | phoneList = (*iter).phoneNumbers(); | 1560 | phoneList = (*iter).phoneNumbers(); |
1559 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1561 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1560 | ++phoneIter) { | 1562 | ++phoneIter) { |
1561 | // Get rid of separator chars so just the numbers are compared. | 1563 | // Get rid of separator chars so just the numbers are compared. |
1562 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1564 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1563 | ownerName = (*iter).formattedName(); | 1565 | ownerName = (*iter).formattedName(); |
1564 | found = true; | 1566 | found = true; |
1565 | } | 1567 | } |
1566 | } | 1568 | } |
1567 | } | 1569 | } |
1568 | 1570 | ||
1569 | return ownerName; | 1571 | return ownerName; |
1570 | #else //KAB_EMBEDDED | 1572 | #else //KAB_EMBEDDED |
1571 | qDebug("KABCore::getNameByPhone finsih method"); | 1573 | qDebug("KABCore::getNameByPhone finsih method"); |
1572 | return ""; | 1574 | return ""; |
1573 | #endif //KAB_EMBEDDED | 1575 | #endif //KAB_EMBEDDED |
1574 | 1576 | ||
1575 | } | 1577 | } |
1576 | 1578 | ||
1577 | void KABCore::openConfigDialog() | 1579 | void KABCore::openConfigDialog() |
1578 | { | 1580 | { |
1579 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1581 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1580 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1582 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1581 | ConfigureDialog->addModule(kabcfg ); | 1583 | ConfigureDialog->addModule(kabcfg ); |
1582 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1584 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1583 | ConfigureDialog->addModule(kdelibcfg ); | 1585 | ConfigureDialog->addModule(kdelibcfg ); |
1584 | 1586 | ||
1585 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1587 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1586 | this, SLOT( configurationChanged() ) ); | 1588 | this, SLOT( configurationChanged() ) ); |
1587 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1589 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1588 | this, SLOT( configurationChanged() ) ); | 1590 | this, SLOT( configurationChanged() ) ); |
1589 | saveSettings(); | 1591 | saveSettings(); |
1590 | #ifndef DESKTOP_VERSION | 1592 | #ifndef DESKTOP_VERSION |
1591 | ConfigureDialog->showMaximized(); | 1593 | ConfigureDialog->showMaximized(); |
1592 | #endif | 1594 | #endif |
1593 | if ( ConfigureDialog->exec() ) | 1595 | if ( ConfigureDialog->exec() ) |
1594 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1596 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1595 | delete ConfigureDialog; | 1597 | delete ConfigureDialog; |
1596 | } | 1598 | } |
1597 | 1599 | ||
1598 | void KABCore::openLDAPDialog() | 1600 | void KABCore::openLDAPDialog() |
1599 | { | 1601 | { |
1600 | #ifndef KAB_EMBEDDED | 1602 | #ifndef KAB_EMBEDDED |
1601 | if ( !mLdapSearchDialog ) { | 1603 | if ( !mLdapSearchDialog ) { |
1602 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1604 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1603 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1605 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1604 | SLOT( refreshView() ) ); | 1606 | SLOT( refreshView() ) ); |
1605 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1607 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1606 | SLOT( setModified() ) ); | 1608 | SLOT( setModified() ) ); |
1607 | } else | 1609 | } else |
1608 | mLdapSearchDialog->restoreSettings(); | 1610 | mLdapSearchDialog->restoreSettings(); |
1609 | 1611 | ||
1610 | if ( mLdapSearchDialog->isOK() ) | 1612 | if ( mLdapSearchDialog->isOK() ) |
1611 | mLdapSearchDialog->exec(); | 1613 | mLdapSearchDialog->exec(); |
1612 | #else //KAB_EMBEDDED | 1614 | #else //KAB_EMBEDDED |
1613 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1615 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1614 | #endif //KAB_EMBEDDED | 1616 | #endif //KAB_EMBEDDED |
1615 | } | 1617 | } |
1616 | 1618 | ||
1617 | void KABCore::print() | 1619 | void KABCore::print() |
1618 | { | 1620 | { |
1619 | #ifndef KAB_EMBEDDED | 1621 | #ifndef KAB_EMBEDDED |
1620 | KPrinter printer; | 1622 | KPrinter printer; |
1621 | if ( !printer.setup( this ) ) | 1623 | if ( !printer.setup( this ) ) |
1622 | return; | 1624 | return; |
1623 | 1625 | ||
1624 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1626 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1625 | mViewManager->selectedUids(), this ); | 1627 | mViewManager->selectedUids(), this ); |
1626 | 1628 | ||
1627 | wizard.exec(); | 1629 | wizard.exec(); |
1628 | #else //KAB_EMBEDDED | 1630 | #else //KAB_EMBEDDED |
1629 | qDebug("KABCore::print() finsih method"); | 1631 | qDebug("KABCore::print() finsih method"); |
1630 | #endif //KAB_EMBEDDED | 1632 | #endif //KAB_EMBEDDED |
1631 | 1633 | ||
1632 | } | 1634 | } |
1633 | 1635 | ||
1634 | 1636 | ||
1635 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1637 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1636 | { | 1638 | { |
1637 | if ( mGUIClient ) | 1639 | if ( mGUIClient ) |
1638 | mGUIClient->insertChildClient( client ); | 1640 | mGUIClient->insertChildClient( client ); |
1639 | else | 1641 | else |
1640 | KMessageBox::error( this, "no KXMLGUICLient"); | 1642 | KMessageBox::error( this, "no KXMLGUICLient"); |
1641 | } | 1643 | } |
1642 | 1644 | ||
1643 | 1645 | ||
1644 | void KABCore::configurationChanged() | 1646 | void KABCore::configurationChanged() |
1645 | { | 1647 | { |
1646 | mExtensionManager->reconfigure(); | 1648 | mExtensionManager->reconfigure(); |
1647 | } | 1649 | } |
1648 | 1650 | ||
1649 | void KABCore::addressBookChanged() | 1651 | void KABCore::addressBookChanged() |
1650 | { | 1652 | { |
1651 | /*US | 1653 | /*US |
1652 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1654 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1653 | while ( it.current() ) { | 1655 | while ( it.current() ) { |
1654 | if ( it.current()->dirty() ) { | 1656 | if ( it.current()->dirty() ) { |
1655 | QString text = i18n( "Data has been changed externally. Unsaved " | 1657 | QString text = i18n( "Data has been changed externally. Unsaved " |
1656 | "changes will be lost." ); | 1658 | "changes will be lost." ); |
1657 | KMessageBox::information( this, text ); | 1659 | KMessageBox::information( this, text ); |
1658 | } | 1660 | } |
1659 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1661 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1660 | ++it; | 1662 | ++it; |
1661 | } | 1663 | } |
1662 | */ | 1664 | */ |
1663 | if (mEditorDialog) | 1665 | if (mEditorDialog) |
1664 | { | 1666 | { |
1665 | if (mEditorDialog->dirty()) | 1667 | if (mEditorDialog->dirty()) |
1666 | { | 1668 | { |
1667 | QString text = i18n( "Data has been changed externally. Unsaved " | 1669 | QString text = i18n( "Data has been changed externally. Unsaved " |
1668 | "changes will be lost." ); | 1670 | "changes will be lost." ); |
1669 | KMessageBox::information( this, text ); | 1671 | KMessageBox::information( this, text ); |
1670 | } | 1672 | } |
1671 | QString currentuid = mEditorDialog->addressee().uid(); | 1673 | QString currentuid = mEditorDialog->addressee().uid(); |
1672 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1674 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1673 | } | 1675 | } |
1674 | mViewManager->refreshView(); | 1676 | mViewManager->refreshView(); |
1675 | 1677 | ||
1676 | 1678 | ||
1677 | } | 1679 | } |
1678 | 1680 | ||
1679 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1681 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1680 | const char *name ) | 1682 | const char *name ) |
1681 | { | 1683 | { |
1682 | 1684 | ||
1683 | if ( mEditorDialog == 0 ) { | 1685 | if ( mEditorDialog == 0 ) { |
1684 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1686 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1685 | name ? name : "editorDialog" ); | 1687 | name ? name : "editorDialog" ); |
1686 | 1688 | ||
1687 | 1689 | ||
1688 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1690 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1689 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1691 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1690 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1692 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1691 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1693 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1692 | } | 1694 | } |
1693 | 1695 | ||
1694 | return mEditorDialog; | 1696 | return mEditorDialog; |
1695 | } | 1697 | } |
1696 | 1698 | ||
1697 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1699 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1698 | { | 1700 | { |
1699 | //mEditorDict.remove( uid ); | 1701 | //mEditorDict.remove( uid ); |
1700 | } | 1702 | } |
1701 | 1703 | ||
1702 | void KABCore::initGUI() | 1704 | void KABCore::initGUI() |
1703 | { | 1705 | { |
1704 | #ifndef KAB_EMBEDDED | 1706 | #ifndef KAB_EMBEDDED |
1705 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1707 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1706 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1708 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1707 | 1709 | ||
1708 | mExtensionBarSplitter = new QSplitter( this ); | 1710 | mExtensionBarSplitter = new QSplitter( this ); |
1709 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1711 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1710 | 1712 | ||
1711 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1713 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1712 | 1714 | ||
1713 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1715 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1714 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1716 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1715 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1717 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1716 | SLOT( incrementalSearch( const QString& ) ) ); | 1718 | SLOT( incrementalSearch( const QString& ) ) ); |
1717 | 1719 | ||
1718 | mViewManager = new ViewManager( this, viewSpace ); | 1720 | mViewManager = new ViewManager( this, viewSpace ); |
1719 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1721 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1720 | 1722 | ||
1721 | mDetails = new ViewContainer( mDetailsSplitter ); | 1723 | mDetails = new ViewContainer( mDetailsSplitter ); |
1722 | 1724 | ||
1723 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1725 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1724 | 1726 | ||
1725 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1727 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1726 | 1728 | ||
1727 | topLayout->addWidget( mExtensionBarSplitter ); | 1729 | topLayout->addWidget( mExtensionBarSplitter ); |
1728 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1730 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1729 | topLayout->addWidget( mJumpButtonBar ); | 1731 | topLayout->addWidget( mJumpButtonBar ); |
1730 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1732 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1731 | 1733 | ||
1732 | mXXPortManager = new XXPortManager( this, this ); | 1734 | mXXPortManager = new XXPortManager( this, this ); |
1733 | 1735 | ||
1734 | #else //KAB_EMBEDDED | 1736 | #else //KAB_EMBEDDED |
1735 | //US initialize viewMenu before settingup viewmanager. | 1737 | //US initialize viewMenu before settingup viewmanager. |
1736 | // Viewmanager needs this menu to plugin submenues. | 1738 | // Viewmanager needs this menu to plugin submenues. |
1737 | viewMenu = new QPopupMenu( this ); | 1739 | viewMenu = new QPopupMenu( this ); |
1738 | settingsMenu = new QPopupMenu( this ); | 1740 | settingsMenu = new QPopupMenu( this ); |
1739 | //filterMenu = new QPopupMenu( this ); | 1741 | //filterMenu = new QPopupMenu( this ); |
1740 | ImportMenu = new QPopupMenu( this ); | 1742 | ImportMenu = new QPopupMenu( this ); |
1741 | ExportMenu = new QPopupMenu( this ); | 1743 | ExportMenu = new QPopupMenu( this ); |
1742 | syncMenu = new QPopupMenu( this ); | 1744 | syncMenu = new QPopupMenu( this ); |
1743 | changeMenu= new QPopupMenu( this ); | 1745 | changeMenu= new QPopupMenu( this ); |
1744 | beamMenu= new QPopupMenu( this ); | 1746 | beamMenu= new QPopupMenu( this ); |
1745 | 1747 | ||
1746 | //US since we have no splitter for the embedded system, setup | 1748 | //US since we have no splitter for the embedded system, setup |
1747 | // a layout with two frames. One left and one right. | 1749 | // a layout with two frames. One left and one right. |
1748 | 1750 | ||
1749 | QBoxLayout *topLayout; | 1751 | QBoxLayout *topLayout; |
1750 | 1752 | ||
1751 | // = new QHBoxLayout( this ); | 1753 | // = new QHBoxLayout( this ); |
1752 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1754 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1753 | 1755 | ||
1754 | // QWidget *mainBox = new QWidget( this ); | 1756 | // QWidget *mainBox = new QWidget( this ); |
1755 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1757 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1756 | 1758 | ||
1757 | #ifdef DESKTOP_VERSION | 1759 | #ifdef DESKTOP_VERSION |
1758 | topLayout = new QHBoxLayout( this ); | 1760 | topLayout = new QHBoxLayout( this ); |
1759 | 1761 | ||
1760 | 1762 | ||
1761 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1763 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1762 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1764 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1763 | 1765 | ||
1764 | topLayout->addWidget(mMiniSplitter ); | 1766 | topLayout->addWidget(mMiniSplitter ); |
1765 | 1767 | ||
1766 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1768 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1767 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1769 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1768 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1770 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1769 | mDetails = new ViewContainer( mMiniSplitter ); | 1771 | mDetails = new ViewContainer( mMiniSplitter ); |
1770 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1772 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1771 | #else | 1773 | #else |
1772 | if ( QApplication::desktop()->width() > 480 ) { | 1774 | if ( QApplication::desktop()->width() > 480 ) { |
1773 | topLayout = new QHBoxLayout( this ); | 1775 | topLayout = new QHBoxLayout( this ); |
1774 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1776 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1775 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1777 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1776 | } else { | 1778 | } else { |
1777 | 1779 | ||
1778 | topLayout = new QHBoxLayout( this ); | 1780 | topLayout = new QHBoxLayout( this ); |
1779 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1781 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1780 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1782 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1781 | } | 1783 | } |
1782 | 1784 | ||
1783 | topLayout->addWidget(mMiniSplitter ); | 1785 | topLayout->addWidget(mMiniSplitter ); |
1784 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1786 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1785 | mDetails = new ViewContainer( mMiniSplitter ); | 1787 | mDetails = new ViewContainer( mMiniSplitter ); |
1786 | 1788 | ||
1787 | 1789 | ||
1788 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1790 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1789 | #endif | 1791 | #endif |
1790 | //eh->hide(); | 1792 | //eh->hide(); |
1791 | // topLayout->addWidget(mExtensionManager ); | 1793 | // topLayout->addWidget(mExtensionManager ); |
1792 | 1794 | ||
1793 | 1795 | ||
1794 | /*US | 1796 | /*US |
1795 | #ifndef KAB_NOSPLITTER | 1797 | #ifndef KAB_NOSPLITTER |
1796 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1798 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1797 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1799 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1798 | topLayout->setSpacing( 10 ); | 1800 | topLayout->setSpacing( 10 ); |
1799 | 1801 | ||
1800 | mDetailsSplitter = new QSplitter( this ); | 1802 | mDetailsSplitter = new QSplitter( this ); |
1801 | 1803 | ||
1802 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1804 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1803 | 1805 | ||
1804 | mViewManager = new ViewManager( this, viewSpace ); | 1806 | mViewManager = new ViewManager( this, viewSpace ); |
1805 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1807 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1806 | 1808 | ||
1807 | mDetails = new ViewContainer( mDetailsSplitter ); | 1809 | mDetails = new ViewContainer( mDetailsSplitter ); |
1808 | 1810 | ||
1809 | topLayout->addWidget( mDetailsSplitter ); | 1811 | topLayout->addWidget( mDetailsSplitter ); |
1810 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1812 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1811 | #else //KAB_NOSPLITTER | 1813 | #else //KAB_NOSPLITTER |
1812 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1814 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1813 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1815 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1814 | topLayout->setSpacing( 10 ); | 1816 | topLayout->setSpacing( 10 ); |
1815 | 1817 | ||
1816 | // mDetailsSplitter = new QSplitter( this ); | 1818 | // mDetailsSplitter = new QSplitter( this ); |
1817 | 1819 | ||
1818 | QVBox *viewSpace = new QVBox( this ); | 1820 | QVBox *viewSpace = new QVBox( this ); |
1819 | 1821 | ||
1820 | mViewManager = new ViewManager( this, viewSpace ); | 1822 | mViewManager = new ViewManager( this, viewSpace ); |
1821 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1823 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1822 | 1824 | ||
1823 | mDetails = new ViewContainer( this ); | 1825 | mDetails = new ViewContainer( this ); |
1824 | 1826 | ||
1825 | topLayout->addWidget( viewSpace ); | 1827 | topLayout->addWidget( viewSpace ); |
1826 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1828 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1827 | topLayout->addWidget( mDetails ); | 1829 | topLayout->addWidget( mDetails ); |
1828 | #endif //KAB_NOSPLITTER | 1830 | #endif //KAB_NOSPLITTER |
1829 | */ | 1831 | */ |
1830 | 1832 | ||
1831 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1833 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1832 | syncManager->setBlockSave(false); | 1834 | syncManager->setBlockSave(false); |
1833 | 1835 | ||
1834 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1836 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1835 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1837 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1836 | QString sync_file = sentSyncFile(); | 1838 | QString sync_file = sentSyncFile(); |
1837 | qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); | 1839 | qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); |
1838 | syncManager->setDefaultFileName( sync_file ); | 1840 | syncManager->setDefaultFileName( sync_file ); |
1839 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1841 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1840 | 1842 | ||
1841 | #endif //KAB_EMBEDDED | 1843 | #endif //KAB_EMBEDDED |
1842 | initActions(); | 1844 | initActions(); |
1843 | 1845 | ||
1844 | #ifdef KAB_EMBEDDED | 1846 | #ifdef KAB_EMBEDDED |
1845 | addActionsManually(); | 1847 | addActionsManually(); |
1846 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1848 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1847 | mXXPortManager = new XXPortManager( this, this ); | 1849 | mXXPortManager = new XXPortManager( this, this ); |
1848 | 1850 | ||
1849 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1851 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1850 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1852 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1851 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1853 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1852 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1854 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1853 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1855 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1854 | // mIncSearchWidget->hide(); | 1856 | // mIncSearchWidget->hide(); |
1855 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1857 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1856 | SLOT( incrementalSearch( const QString& ) ) ); | 1858 | SLOT( incrementalSearch( const QString& ) ) ); |
1857 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1859 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1858 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1860 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1859 | 1861 | ||
1860 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1862 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1861 | 1863 | ||
1862 | topLayout->addWidget( mJumpButtonBar ); | 1864 | topLayout->addWidget( mJumpButtonBar ); |
1863 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1865 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1864 | 1866 | ||
1865 | // mMainWindow->getIconToolBar()->raise(); | 1867 | // mMainWindow->getIconToolBar()->raise(); |
1866 | 1868 | ||
1867 | #endif //KAB_EMBEDDED | 1869 | #endif //KAB_EMBEDDED |
1868 | 1870 | ||
1869 | } | 1871 | } |
1870 | void KABCore::initActions() | 1872 | void KABCore::initActions() |
1871 | { | 1873 | { |
1872 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1874 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1873 | 1875 | ||
1874 | #ifndef KAB_EMBEDDED | 1876 | #ifndef KAB_EMBEDDED |
1875 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1877 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1876 | SLOT( clipboardDataChanged() ) ); | 1878 | SLOT( clipboardDataChanged() ) ); |
1877 | #endif //KAB_EMBEDDED | 1879 | #endif //KAB_EMBEDDED |
1878 | 1880 | ||
1879 | // file menu | 1881 | // file menu |
1880 | 1882 | ||
1881 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1883 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1882 | //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1884 | //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1883 | mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, | 1885 | mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, |
1884 | SLOT( printView() ), actionCollection(), "kaddressbook_print" ); | 1886 | SLOT( printView() ), actionCollection(), "kaddressbook_print" ); |
1885 | 1887 | ||
1886 | 1888 | ||
1887 | mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, | 1889 | mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, |
1888 | SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); | 1890 | SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); |
1889 | 1891 | ||
1890 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1892 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1891 | SLOT( save() ), actionCollection(), "file_sync" ); | 1893 | SLOT( save() ), actionCollection(), "file_sync" ); |
1892 | 1894 | ||
1893 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1895 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1894 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1896 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1895 | 1897 | ||
1896 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1898 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1897 | this, SLOT( mailVCard() ), | 1899 | this, SLOT( mailVCard() ), |
1898 | actionCollection(), "file_mail_vcard"); | 1900 | actionCollection(), "file_mail_vcard"); |
1899 | 1901 | ||
1900 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, | 1902 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, |
1901 | SLOT( export2phone() ), actionCollection(), | 1903 | SLOT( export2phone() ), actionCollection(), |
1902 | "kaddressbook_ex2phone" ); | 1904 | "kaddressbook_ex2phone" ); |
1903 | 1905 | ||
1904 | mActionBeamVCard = 0; | 1906 | mActionBeamVCard = 0; |
1905 | mActionBeam = 0; | 1907 | mActionBeam = 0; |
1906 | 1908 | ||
1907 | #ifndef DESKTOP_VERSION | 1909 | #ifndef DESKTOP_VERSION |
1908 | if ( Ir::supported() ) { | 1910 | if ( Ir::supported() ) { |
1909 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, | 1911 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, |
1910 | SLOT( beamVCard() ), actionCollection(), | 1912 | SLOT( beamVCard() ), actionCollection(), |
1911 | "kaddressbook_beam_vcard" ); | 1913 | "kaddressbook_beam_vcard" ); |
1912 | 1914 | ||
1913 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1915 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1914 | SLOT( beamMySelf() ), actionCollection(), | 1916 | SLOT( beamMySelf() ), actionCollection(), |
1915 | "kaddressbook_beam_myself" ); | 1917 | "kaddressbook_beam_myself" ); |
1916 | } | 1918 | } |
1917 | #endif | 1919 | #endif |
1918 | 1920 | ||
1919 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1921 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1920 | this, SLOT( editContact2() ), | 1922 | this, SLOT( editContact2() ), |
1921 | actionCollection(), "file_properties" ); | 1923 | actionCollection(), "file_properties" ); |
1922 | 1924 | ||
1923 | #ifdef KAB_EMBEDDED | 1925 | #ifdef KAB_EMBEDDED |
1924 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1926 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1925 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1927 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1926 | mMainWindow, SLOT( exit() ), | 1928 | mMainWindow, SLOT( exit() ), |
1927 | actionCollection(), "quit" ); | 1929 | actionCollection(), "quit" ); |
1928 | #endif //KAB_EMBEDDED | 1930 | #endif //KAB_EMBEDDED |
1929 | 1931 | ||
1930 | // edit menu | 1932 | // edit menu |
1931 | if ( mIsPart ) { | 1933 | if ( mIsPart ) { |
1932 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1934 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1933 | SLOT( copyContacts() ), actionCollection(), | 1935 | SLOT( copyContacts() ), actionCollection(), |
1934 | "kaddressbook_copy" ); | 1936 | "kaddressbook_copy" ); |
1935 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1937 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1936 | SLOT( cutContacts() ), actionCollection(), | 1938 | SLOT( cutContacts() ), actionCollection(), |
1937 | "kaddressbook_cut" ); | 1939 | "kaddressbook_cut" ); |
1938 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1940 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1939 | SLOT( pasteContacts() ), actionCollection(), | 1941 | SLOT( pasteContacts() ), actionCollection(), |
1940 | "kaddressbook_paste" ); | 1942 | "kaddressbook_paste" ); |
1941 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1943 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1942 | SLOT( selectAllContacts() ), actionCollection(), | 1944 | SLOT( selectAllContacts() ), actionCollection(), |
1943 | "kaddressbook_select_all" ); | 1945 | "kaddressbook_select_all" ); |
1944 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1946 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1945 | SLOT( undo() ), actionCollection(), | 1947 | SLOT( undo() ), actionCollection(), |
1946 | "kaddressbook_undo" ); | 1948 | "kaddressbook_undo" ); |
1947 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1949 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1948 | this, SLOT( redo() ), actionCollection(), | 1950 | this, SLOT( redo() ), actionCollection(), |
1949 | "kaddressbook_redo" ); | 1951 | "kaddressbook_redo" ); |
1950 | } else { | 1952 | } else { |
1951 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1953 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1952 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1954 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1953 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1955 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1954 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1956 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1955 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1957 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1956 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1958 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1957 | } | 1959 | } |
1958 | 1960 | ||
1959 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1961 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1960 | Key_Delete, this, SLOT( deleteContacts() ), | 1962 | Key_Delete, this, SLOT( deleteContacts() ), |
1961 | actionCollection(), "edit_delete" ); | 1963 | actionCollection(), "edit_delete" ); |
1962 | 1964 | ||
1963 | mActionUndo->setEnabled( false ); | 1965 | mActionUndo->setEnabled( false ); |
1964 | mActionRedo->setEnabled( false ); | 1966 | mActionRedo->setEnabled( false ); |
1965 | 1967 | ||
1966 | // settings menu | 1968 | // settings menu |
1967 | #ifdef KAB_EMBEDDED | 1969 | #ifdef KAB_EMBEDDED |
1968 | //US special menuentry to configure the addressbook resources. On KDE | 1970 | //US special menuentry to configure the addressbook resources. On KDE |
1969 | // you do that through the control center !!! | 1971 | // you do that through the control center !!! |
1970 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1972 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1971 | SLOT( configureResources() ), actionCollection(), | 1973 | SLOT( configureResources() ), actionCollection(), |
1972 | "kaddressbook_configure_resources" ); | 1974 | "kaddressbook_configure_resources" ); |
1973 | #endif //KAB_EMBEDDED | 1975 | #endif //KAB_EMBEDDED |
1974 | 1976 | ||
1975 | if ( mIsPart ) { | 1977 | if ( mIsPart ) { |
1976 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1978 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1977 | SLOT( openConfigDialog() ), actionCollection(), | 1979 | SLOT( openConfigDialog() ), actionCollection(), |
1978 | "kaddressbook_configure" ); | 1980 | "kaddressbook_configure" ); |
1979 | 1981 | ||
1980 | //US not implemented yet | 1982 | //US not implemented yet |
1981 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1983 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1982 | // this, SLOT( configureKeyBindings() ), actionCollection(), | 1984 | // this, SLOT( configureKeyBindings() ), actionCollection(), |
1983 | // "kaddressbook_configure_shortcuts" ); | 1985 | // "kaddressbook_configure_shortcuts" ); |
1984 | #ifdef KAB_EMBEDDED | 1986 | #ifdef KAB_EMBEDDED |
1985 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1987 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1986 | mActionConfigureToolbars->setEnabled( false ); | 1988 | mActionConfigureToolbars->setEnabled( false ); |
1987 | #endif //KAB_EMBEDDED | 1989 | #endif //KAB_EMBEDDED |
1988 | 1990 | ||
1989 | } else { | 1991 | } else { |
1990 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1992 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1991 | 1993 | ||
1992 | //US not implemented yet | 1994 | //US not implemented yet |
1993 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1995 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1994 | } | 1996 | } |
1995 | 1997 | ||
1996 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1998 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1997 | actionCollection(), "options_show_jump_bar" ); | 1999 | actionCollection(), "options_show_jump_bar" ); |
1998 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 2000 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1999 | 2001 | ||
2000 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 2002 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
2001 | actionCollection(), "options_show_details" ); | 2003 | actionCollection(), "options_show_details" ); |
2002 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 2004 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
2003 | 2005 | ||
2004 | 2006 | ||
2005 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, | 2007 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
2006 | SLOT( toggleBeamReceive() ), actionCollection(), | 2008 | SLOT( toggleBeamReceive() ), actionCollection(), |
2007 | "kaddressbook_beam_rec" ); | 2009 | "kaddressbook_beam_rec" ); |
2008 | 2010 | ||
2009 | 2011 | ||
2010 | // misc | 2012 | // misc |
2011 | // only enable LDAP lookup if we can handle the protocol | 2013 | // only enable LDAP lookup if we can handle the protocol |
2012 | #ifndef KAB_EMBEDDED | 2014 | #ifndef KAB_EMBEDDED |
2013 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 2015 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
2014 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 2016 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
2015 | this, SLOT( openLDAPDialog() ), actionCollection(), | 2017 | this, SLOT( openLDAPDialog() ), actionCollection(), |
2016 | "ldap_lookup" ); | 2018 | "ldap_lookup" ); |
2017 | } | 2019 | } |
2018 | #else //KAB_EMBEDDED | 2020 | #else //KAB_EMBEDDED |
2019 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 2021 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
2020 | #endif //KAB_EMBEDDED | 2022 | #endif //KAB_EMBEDDED |
2021 | 2023 | ||
2022 | 2024 | ||
2023 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 2025 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
2024 | SLOT( setWhoAmI() ), actionCollection(), | 2026 | SLOT( setWhoAmI() ), actionCollection(), |
2025 | "set_personal" ); | 2027 | "set_personal" ); |
2026 | 2028 | ||
2027 | 2029 | ||
2028 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 2030 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
2029 | SLOT( setCategories() ), actionCollection(), | 2031 | SLOT( setCategories() ), actionCollection(), |
2030 | "edit_set_categories" ); | 2032 | "edit_set_categories" ); |
2031 | mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, | 2033 | mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, |
2032 | SLOT( editCategories() ), actionCollection(), | 2034 | SLOT( editCategories() ), actionCollection(), |
2033 | "edit__categories" ); | 2035 | "edit__categories" ); |
2034 | 2036 | ||
2035 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 2037 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
2036 | SLOT( removeVoice() ), actionCollection(), | 2038 | SLOT( removeVoice() ), actionCollection(), |
2037 | "remove_voice" ); | 2039 | "remove_voice" ); |
2038 | mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, | 2040 | mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, |
2039 | SLOT( setFormattedName() ), actionCollection(), | 2041 | SLOT( setFormattedName() ), actionCollection(), |
2040 | "set_formatted" ); | 2042 | "set_formatted" ); |
2041 | 2043 | ||
2042 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, | 2044 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, |
2043 | SLOT( manageCategories() ), actionCollection(), | 2045 | SLOT( manageCategories() ), actionCollection(), |
2044 | "remove_voice" ); | 2046 | "remove_voice" ); |
2045 | 2047 | ||
2046 | 2048 | ||
2047 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 2049 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
2048 | SLOT( importFromOL() ), actionCollection(), | 2050 | SLOT( importFromOL() ), actionCollection(), |
2049 | "import_OL" ); | 2051 | "import_OL" ); |
2050 | #ifdef KAB_EMBEDDED | 2052 | #ifdef KAB_EMBEDDED |
2051 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 2053 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
2052 | this, SLOT( showLicence() ), actionCollection(), | 2054 | this, SLOT( showLicence() ), actionCollection(), |
2053 | "licence_about_data" ); | 2055 | "licence_about_data" ); |
2054 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 2056 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
2055 | this, SLOT( faq() ), actionCollection(), | 2057 | this, SLOT( faq() ), actionCollection(), |
2056 | "faq_about_data" ); | 2058 | "faq_about_data" ); |
2057 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 2059 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
2058 | this, SLOT( whatsnew() ), actionCollection(), | 2060 | this, SLOT( whatsnew() ), actionCollection(), |
2059 | "wn" ); | 2061 | "wn" ); |
2060 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 2062 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
2061 | this, SLOT( synchowto() ), actionCollection(), | 2063 | this, SLOT( synchowto() ), actionCollection(), |
2062 | "sync" ); | 2064 | "sync" ); |
2063 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, | 2065 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, |
2064 | this, SLOT( kdesynchowto() ), actionCollection(), | 2066 | this, SLOT( kdesynchowto() ), actionCollection(), |
2065 | "kdesync" ); | 2067 | "kdesync" ); |
2066 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, | 2068 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, |
2067 | this, SLOT( multisynchowto() ), actionCollection(), | 2069 | this, SLOT( multisynchowto() ), actionCollection(), |
2068 | "multisync" ); | 2070 | "multisync" ); |
2069 | 2071 | ||
2070 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 2072 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
2071 | this, SLOT( createAboutData() ), actionCollection(), | 2073 | this, SLOT( createAboutData() ), actionCollection(), |
2072 | "kaddressbook_about_data" ); | 2074 | "kaddressbook_about_data" ); |
2073 | #endif //KAB_EMBEDDED | 2075 | #endif //KAB_EMBEDDED |
2074 | 2076 | ||
2075 | clipboardDataChanged(); | 2077 | clipboardDataChanged(); |
2076 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2078 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2077 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2079 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2078 | } | 2080 | } |
2079 | 2081 | ||
2080 | //US we need this function, to plug all actions into the correct menues. | 2082 | //US we need this function, to plug all actions into the correct menues. |
2081 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 2083 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
2082 | void KABCore::addActionsManually() | 2084 | void KABCore::addActionsManually() |
2083 | { | 2085 | { |
2084 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 2086 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
2085 | 2087 | ||
2086 | #ifdef KAB_EMBEDDED | 2088 | #ifdef KAB_EMBEDDED |
2087 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 2089 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
2088 | QPopupMenu *editMenu = new QPopupMenu( this ); | 2090 | QPopupMenu *editMenu = new QPopupMenu( this ); |
2089 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 2091 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
2090 | 2092 | ||
2091 | KToolBar* tb = mMainWindow->toolBar(); | 2093 | KToolBar* tb = mMainWindow->toolBar(); |
2092 | 2094 | ||
2093 | #ifndef DESKTOP_VERSION | 2095 | #ifndef DESKTOP_VERSION |
2094 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { | 2096 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { |
2095 | #endif | 2097 | #endif |
2096 | QMenuBar* mb = mMainWindow->menuBar(); | 2098 | QMenuBar* mb = mMainWindow->menuBar(); |
2097 | 2099 | ||
2098 | //US setup menubar. | 2100 | //US setup menubar. |
2099 | //Disable the following block if you do not want to have a menubar. | 2101 | //Disable the following block if you do not want to have a menubar. |
2100 | mb->insertItem( i18n("&File"), fileMenu ); | 2102 | mb->insertItem( i18n("&File"), fileMenu ); |
2101 | mb->insertItem( i18n("&Edit"), editMenu ); | 2103 | mb->insertItem( i18n("&Edit"), editMenu ); |
2102 | mb->insertItem( i18n("&View"), viewMenu ); | 2104 | mb->insertItem( i18n("&View"), viewMenu ); |
2103 | mb->insertItem( i18n("&Settings"), settingsMenu ); | 2105 | mb->insertItem( i18n("&Settings"), settingsMenu ); |
2104 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 2106 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
2105 | //mb->insertItem( i18n("&Change"), changeMenu ); | 2107 | //mb->insertItem( i18n("&Change"), changeMenu ); |
2106 | mb->insertItem( i18n("&Help"), helpMenu ); | 2108 | mb->insertItem( i18n("&Help"), helpMenu ); |
2107 | mIncSearchWidget = new IncSearchWidget( tb ); | 2109 | mIncSearchWidget = new IncSearchWidget( tb ); |
2108 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 2110 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
2109 | #ifndef DESKTOP_VERSION | 2111 | #ifndef DESKTOP_VERSION |
2110 | } else { | 2112 | } else { |
2111 | //US setup toolbar | 2113 | //US setup toolbar |
2112 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 2114 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
2113 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 2115 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
2114 | menuBarTB->insertItem( "ME", popupBarTB); | 2116 | menuBarTB->insertItem( "ME", popupBarTB); |
2115 | tb->insertWidget(-1, 0, menuBarTB); | 2117 | tb->insertWidget(-1, 0, menuBarTB); |
2116 | mIncSearchWidget = new IncSearchWidget( tb ); | 2118 | mIncSearchWidget = new IncSearchWidget( tb ); |
2117 | 2119 | ||
2118 | tb->enableMoving(false); | 2120 | tb->enableMoving(false); |
2119 | popupBarTB->insertItem( i18n("&File"), fileMenu ); | 2121 | popupBarTB->insertItem( i18n("&File"), fileMenu ); |
2120 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); | 2122 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); |
2121 | popupBarTB->insertItem( i18n("&View"), viewMenu ); | 2123 | popupBarTB->insertItem( i18n("&View"), viewMenu ); |
2122 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); | 2124 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); |
2123 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 2125 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
2124 | mViewManager->getFilterAction()->plug ( popupBarTB); | 2126 | mViewManager->getFilterAction()->plug ( popupBarTB); |
2125 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); | 2127 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); |
2126 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); | 2128 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); |
2127 | if (QApplication::desktop()->width() > 320 ) { | 2129 | if (QApplication::desktop()->width() > 320 ) { |
2128 | // mViewManager->getFilterAction()->plug ( tb); | 2130 | // mViewManager->getFilterAction()->plug ( tb); |
2129 | } | 2131 | } |
2130 | } | 2132 | } |
2131 | #endif | 2133 | #endif |
2132 | // mActionQuit->plug ( mMainWindow->toolBar()); | 2134 | // mActionQuit->plug ( mMainWindow->toolBar()); |
2133 | 2135 | ||
2134 | 2136 | ||
2135 | 2137 | ||
2136 | //US Now connect the actions with the menue entries. | 2138 | //US Now connect the actions with the menue entries. |
2137 | #ifdef DESKTOP_VERSION | 2139 | #ifdef DESKTOP_VERSION |
2138 | mActionPrint->plug( fileMenu ); | 2140 | mActionPrint->plug( fileMenu ); |
2139 | mActionPrintDetails->plug( fileMenu ); | 2141 | mActionPrintDetails->plug( fileMenu ); |
2140 | fileMenu->insertSeparator(); | 2142 | fileMenu->insertSeparator(); |
2141 | #endif | 2143 | #endif |
2142 | mActionMail->plug( fileMenu ); | 2144 | mActionMail->plug( fileMenu ); |
2143 | fileMenu->insertSeparator(); | 2145 | fileMenu->insertSeparator(); |
2144 | 2146 | ||
2145 | mActionNewContact->plug( fileMenu ); | 2147 | mActionNewContact->plug( fileMenu ); |
2146 | mActionNewContact->plug( tb ); | 2148 | mActionNewContact->plug( tb ); |
2147 | 2149 | ||
2148 | mActionEditAddressee->plug( fileMenu ); | 2150 | mActionEditAddressee->plug( fileMenu ); |
2149 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 2151 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
2150 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 2152 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
2151 | mActionEditAddressee->plug( tb ); | 2153 | mActionEditAddressee->plug( tb ); |
2152 | 2154 | ||
2153 | fileMenu->insertSeparator(); | 2155 | fileMenu->insertSeparator(); |
2154 | mActionSave->plug( fileMenu ); | 2156 | mActionSave->plug( fileMenu ); |
2155 | fileMenu->insertItem( "&Import", ImportMenu ); | 2157 | fileMenu->insertItem( "&Import", ImportMenu ); |
2156 | fileMenu->insertItem( "&Export", ExportMenu ); | 2158 | fileMenu->insertItem( "&Export", ExportMenu ); |
2157 | fileMenu->insertItem( i18n("&Change"), changeMenu ); | 2159 | fileMenu->insertItem( i18n("&Change"), changeMenu ); |
2158 | #ifndef DESKTOP_VERSION | 2160 | #ifndef DESKTOP_VERSION |
2159 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); | 2161 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); |
2160 | #endif | 2162 | #endif |
2161 | #if 0 | 2163 | #if 0 |
2162 | // PENDING fix MailVCard | 2164 | // PENDING fix MailVCard |
2163 | fileMenu->insertSeparator(); | 2165 | fileMenu->insertSeparator(); |
2164 | mActionMailVCard->plug( fileMenu ); | 2166 | mActionMailVCard->plug( fileMenu ); |
2165 | #endif | 2167 | #endif |
2166 | #ifndef DESKTOP_VERSION | 2168 | #ifndef DESKTOP_VERSION |
2167 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); | 2169 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); |
2168 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); | 2170 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); |
2169 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); | 2171 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); |
2170 | #endif | 2172 | #endif |
2171 | fileMenu->insertSeparator(); | 2173 | fileMenu->insertSeparator(); |
2172 | mActionQuit->plug( fileMenu ); | 2174 | mActionQuit->plug( fileMenu ); |
2173 | #ifdef _WIN32_ | 2175 | #ifdef _WIN32_ |
2174 | mActionImportOL->plug( ImportMenu ); | 2176 | mActionImportOL->plug( ImportMenu ); |
2175 | #endif | 2177 | #endif |
2176 | // edit menu | 2178 | // edit menu |
2177 | mActionUndo->plug( editMenu ); | 2179 | mActionUndo->plug( editMenu ); |
2178 | mActionRedo->plug( editMenu ); | 2180 | mActionRedo->plug( editMenu ); |
2179 | editMenu->insertSeparator(); | 2181 | editMenu->insertSeparator(); |
2180 | mActionCut->plug( editMenu ); | 2182 | mActionCut->plug( editMenu ); |
2181 | mActionCopy->plug( editMenu ); | 2183 | mActionCopy->plug( editMenu ); |
2182 | mActionPaste->plug( editMenu ); | 2184 | mActionPaste->plug( editMenu ); |
2183 | mActionDelete->plug( editMenu ); | 2185 | mActionDelete->plug( editMenu ); |
2184 | editMenu->insertSeparator(); | 2186 | editMenu->insertSeparator(); |
2185 | mActionSelectAll->plug( editMenu ); | 2187 | mActionSelectAll->plug( editMenu ); |
2186 | 2188 | ||
2187 | mActionSetFormattedName->plug( changeMenu ); | 2189 | mActionSetFormattedName->plug( changeMenu ); |
2188 | mActionRemoveVoice->plug( changeMenu ); | 2190 | mActionRemoveVoice->plug( changeMenu ); |
2189 | // settings menu | 2191 | // settings menu |
2190 | //US special menuentry to configure the addressbook resources. On KDE | 2192 | //US special menuentry to configure the addressbook resources. On KDE |
2191 | // you do that through the control center !!! | 2193 | // you do that through the control center !!! |
2192 | mActionConfigResources->plug( settingsMenu ); | 2194 | mActionConfigResources->plug( settingsMenu ); |
2193 | settingsMenu->insertSeparator(); | 2195 | settingsMenu->insertSeparator(); |
2194 | 2196 | ||
2195 | mActionConfigKAddressbook->plug( settingsMenu ); | 2197 | mActionConfigKAddressbook->plug( settingsMenu ); |
2196 | 2198 | ||
2197 | if ( mIsPart ) { | 2199 | if ( mIsPart ) { |
2198 | //US not implemented yet | 2200 | //US not implemented yet |
2199 | //mActionConfigShortcuts->plug( settingsMenu ); | 2201 | //mActionConfigShortcuts->plug( settingsMenu ); |
2200 | //mActionConfigureToolbars->plug( settingsMenu ); | 2202 | //mActionConfigureToolbars->plug( settingsMenu ); |
2201 | 2203 | ||
2202 | } else { | 2204 | } else { |
2203 | //US not implemented yet | 2205 | //US not implemented yet |
2204 | //mActionKeyBindings->plug( settingsMenu ); | 2206 | //mActionKeyBindings->plug( settingsMenu ); |
2205 | } | 2207 | } |
2206 | 2208 | ||
2207 | settingsMenu->insertSeparator(); | 2209 | settingsMenu->insertSeparator(); |
2208 | 2210 | ||
2209 | mActionJumpBar->plug( settingsMenu ); | 2211 | mActionJumpBar->plug( settingsMenu ); |
2210 | mActionDetails->plug( settingsMenu ); | 2212 | mActionDetails->plug( settingsMenu ); |
2211 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2213 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2212 | mActionDetails->plug( tb ); | 2214 | mActionDetails->plug( tb ); |
2213 | settingsMenu->insertSeparator(); | 2215 | settingsMenu->insertSeparator(); |
2214 | #ifndef DESKTOP_VERSION | 2216 | #ifndef DESKTOP_VERSION |
2215 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); | 2217 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); |
2216 | #endif | 2218 | #endif |
2217 | settingsMenu->insertSeparator(); | 2219 | settingsMenu->insertSeparator(); |
2218 | 2220 | ||
2219 | mActionWhoAmI->plug( settingsMenu ); | 2221 | mActionWhoAmI->plug( settingsMenu ); |
2220 | mActionEditCategories->plug( settingsMenu ); | 2222 | mActionEditCategories->plug( settingsMenu ); |
2221 | mActionEditCategories->plug( changeMenu ); | 2223 | mActionEditCategories->plug( changeMenu ); |
2222 | mActionCategories->plug( changeMenu ); | 2224 | mActionCategories->plug( changeMenu ); |
2223 | mActionManageCategories->plug( changeMenu ); | 2225 | mActionManageCategories->plug( changeMenu ); |
2224 | 2226 | ||
2225 | mActionCategories->plug( settingsMenu ); | 2227 | mActionCategories->plug( settingsMenu ); |
2226 | mActionManageCategories->plug( settingsMenu ); | 2228 | mActionManageCategories->plug( settingsMenu ); |
2227 | 2229 | ||
2228 | 2230 | ||
2229 | mActionWN->plug( helpMenu ); | 2231 | mActionWN->plug( helpMenu ); |
2230 | mActionSyncHowto->plug( helpMenu ); | 2232 | mActionSyncHowto->plug( helpMenu ); |
2231 | mActionKdeSyncHowto->plug( helpMenu ); | 2233 | mActionKdeSyncHowto->plug( helpMenu ); |
2232 | mActionMultiSyncHowto->plug( helpMenu ); | 2234 | mActionMultiSyncHowto->plug( helpMenu ); |
2233 | mActionFaq->plug( helpMenu ); | 2235 | mActionFaq->plug( helpMenu ); |
2234 | mActionLicence->plug( helpMenu ); | 2236 | mActionLicence->plug( helpMenu ); |
2235 | mActionAboutKAddressbook->plug( helpMenu ); | 2237 | mActionAboutKAddressbook->plug( helpMenu ); |
2236 | 2238 | ||
2237 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2239 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2238 | 2240 | ||
2239 | mActionSave->plug( tb ); | 2241 | mActionSave->plug( tb ); |
2240 | mViewManager->getFilterAction()->plug ( tb); | 2242 | mViewManager->getFilterAction()->plug ( tb); |
2241 | //LR hide filteraction on started in 480x640 | 2243 | //LR hide filteraction on started in 480x640 |
2242 | if (QApplication::desktop()->width() == 480 ) { | 2244 | if (QApplication::desktop()->width() == 480 ) { |
2243 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 2245 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
2244 | } | 2246 | } |
2245 | mActionUndo->plug( tb ); | 2247 | mActionUndo->plug( tb ); |
2246 | mActionDelete->plug( tb ); | 2248 | mActionDelete->plug( tb ); |
2247 | mActionRedo->plug( tb ); | 2249 | mActionRedo->plug( tb ); |
2248 | } else { | 2250 | } else { |
2249 | mActionSave->plug( tb ); | 2251 | mActionSave->plug( tb ); |
2250 | tb->enableMoving(false); | 2252 | tb->enableMoving(false); |
2251 | } | 2253 | } |
2252 | //mActionQuit->plug ( tb ); | 2254 | //mActionQuit->plug ( tb ); |
2253 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2255 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2254 | 2256 | ||
2255 | //US link the searchwidget first to this. | 2257 | //US link the searchwidget first to this. |
2256 | // The real linkage to the toolbar happens later. | 2258 | // The real linkage to the toolbar happens later. |
2257 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2259 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2258 | //US tb->insertItem( mIncSearchWidget ); | 2260 | //US tb->insertItem( mIncSearchWidget ); |
2259 | /*US | 2261 | /*US |
2260 | mIncSearchWidget = new IncSearchWidget( tb ); | 2262 | mIncSearchWidget = new IncSearchWidget( tb ); |
2261 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2263 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2262 | SLOT( incrementalSearch( const QString& ) ) ); | 2264 | SLOT( incrementalSearch( const QString& ) ) ); |
2263 | 2265 | ||
2264 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2266 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2265 | 2267 | ||
2266 | //US topLayout->addWidget( mJumpButtonBar ); | 2268 | //US topLayout->addWidget( mJumpButtonBar ); |
2267 | this->layout()->add( mJumpButtonBar ); | 2269 | this->layout()->add( mJumpButtonBar ); |
2268 | */ | 2270 | */ |
2269 | 2271 | ||
2270 | #endif //KAB_EMBEDDED | 2272 | #endif //KAB_EMBEDDED |
2271 | 2273 | ||
2272 | mActionExport2phone->plug( ExportMenu ); | 2274 | mActionExport2phone->plug( ExportMenu ); |
2273 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2275 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2274 | syncManager->fillSyncMenu(); | 2276 | syncManager->fillSyncMenu(); |
2275 | 2277 | ||
2276 | } | 2278 | } |
2277 | void KABCore::showLicence() | 2279 | void KABCore::showLicence() |
2278 | { | 2280 | { |
2279 | KApplication::showLicence(); | 2281 | KApplication::showLicence(); |
2280 | } | 2282 | } |
2281 | 2283 | ||
2282 | void KABCore::manageCategories( ) | 2284 | void KABCore::manageCategories( ) |
2283 | { | 2285 | { |
2284 | KABCatPrefs* cp = new KABCatPrefs(); | 2286 | KABCatPrefs* cp = new KABCatPrefs(); |
2285 | cp->show(); | 2287 | cp->show(); |
2286 | int w =cp->sizeHint().width() ; | 2288 | int w =cp->sizeHint().width() ; |
2287 | int h = cp->sizeHint().height() ; | 2289 | int h = cp->sizeHint().height() ; |
2288 | int dw = QApplication::desktop()->width(); | 2290 | int dw = QApplication::desktop()->width(); |
2289 | int dh = QApplication::desktop()->height(); | 2291 | int dh = QApplication::desktop()->height(); |
2290 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2292 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2291 | if ( !cp->exec() ) { | 2293 | if ( !cp->exec() ) { |
2292 | delete cp; | 2294 | delete cp; |
2293 | return; | 2295 | return; |
2294 | } | 2296 | } |
2295 | int count = 0; | 2297 | int count = 0; |
2296 | message( i18n("Please wait, processing categories...")); | 2298 | message( i18n("Please wait, processing categories...")); |
2297 | if ( cp->addCat() ) { | 2299 | if ( cp->addCat() ) { |
2298 | KABC::AddressBook::Iterator it; | 2300 | KABC::AddressBook::Iterator it; |
2299 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2301 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2300 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2302 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2301 | QStringList catIncList = (*it).categories(); | 2303 | QStringList catIncList = (*it).categories(); |
2302 | int i; | 2304 | int i; |
2303 | for( i = 0; i< catIncList.count(); ++i ) { | 2305 | for( i = 0; i< catIncList.count(); ++i ) { |
2304 | if ( !catList.contains (catIncList[i])) { | 2306 | if ( !catList.contains (catIncList[i])) { |
2305 | catList.append( catIncList[i] ); | 2307 | catList.append( catIncList[i] ); |
2306 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2308 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2307 | ++count; | 2309 | ++count; |
2308 | } | 2310 | } |
2309 | } | 2311 | } |
2310 | } | 2312 | } |
2311 | catList.sort(); | 2313 | catList.sort(); |
2312 | KABPrefs::instance()->mCustomCategories = catList; | 2314 | KABPrefs::instance()->mCustomCategories = catList; |
2313 | KABPrefs::instance()->writeConfig(); | 2315 | KABPrefs::instance()->writeConfig(); |
2314 | message(QString::number( count )+ i18n(" categories added to list! ")); | 2316 | message(QString::number( count )+ i18n(" categories added to list! ")); |
2315 | } else { | 2317 | } else { |
2316 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2318 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2317 | QStringList catIncList; | 2319 | QStringList catIncList; |
2318 | QStringList newCatList; | 2320 | QStringList newCatList; |
2319 | KABC::AddressBook::Iterator it; | 2321 | KABC::AddressBook::Iterator it; |
2320 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2322 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2321 | QStringList catIncList = (*it).categories(); | 2323 | QStringList catIncList = (*it).categories(); |
2322 | int i; | 2324 | int i; |
2323 | if ( catIncList.count() ) { | 2325 | if ( catIncList.count() ) { |
2324 | newCatList.clear(); | 2326 | newCatList.clear(); |
2325 | for( i = 0; i< catIncList.count(); ++i ) { | 2327 | for( i = 0; i< catIncList.count(); ++i ) { |
2326 | if ( catList.contains (catIncList[i])) { | 2328 | if ( catList.contains (catIncList[i])) { |
2327 | newCatList.append( catIncList[i] ); | 2329 | newCatList.append( catIncList[i] ); |
2328 | } | 2330 | } |
2329 | } | 2331 | } |
2330 | newCatList.sort(); | 2332 | newCatList.sort(); |
2331 | (*it).setCategories( newCatList ); | 2333 | (*it).setCategories( newCatList ); |
2332 | mAddressBook->insertAddressee( (*it) ); | 2334 | mAddressBook->insertAddressee( (*it) ); |
2333 | } | 2335 | } |
2334 | } | 2336 | } |
2335 | setModified( true ); | 2337 | setModified( true ); |
2336 | mViewManager->refreshView(); | 2338 | mViewManager->refreshView(); |
2337 | message( i18n("Removing categories done!")); | 2339 | message( i18n("Removing categories done!")); |
2338 | } | 2340 | } |
2339 | delete cp; | 2341 | delete cp; |
2340 | } | 2342 | } |
2341 | void KABCore::removeVoice() | 2343 | void KABCore::removeVoice() |
2342 | { | 2344 | { |
2343 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 2345 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
2344 | return; | 2346 | return; |
2345 | KABC::Addressee::List list; | 2347 | KABC::Addressee::List list; |
2346 | XXPortSelectDialog dlg( this, false, this ); | 2348 | XXPortSelectDialog dlg( this, false, this ); |
2347 | if ( dlg.exec() ) | 2349 | if ( dlg.exec() ) |
2348 | list = dlg.contacts(); | 2350 | list = dlg.contacts(); |
2349 | else | 2351 | else |
2350 | return; | 2352 | return; |
2351 | KABC::Addressee::List::Iterator it; | 2353 | KABC::Addressee::List::Iterator it; |
2352 | for ( it = list.begin(); it != list.end(); ++it ) { | 2354 | for ( it = list.begin(); it != list.end(); ++it ) { |
2353 | if ( (*it).removeVoice() ) | 2355 | if ( (*it).removeVoice() ) |
2354 | addrModified((*it), false ); | 2356 | addrModified((*it), false ); |
2355 | } | 2357 | } |
2356 | } | 2358 | } |
2357 | 2359 | ||
2358 | void KABCore::setFormattedName() | 2360 | void KABCore::setFormattedName() |
2359 | { | 2361 | { |
2360 | KABFormatPrefs setpref; | 2362 | KABFormatPrefs setpref; |
2361 | if ( !setpref.exec() ) { | 2363 | if ( !setpref.exec() ) { |
2362 | return; | 2364 | return; |
2363 | } | 2365 | } |
2364 | KABC::Addressee::List list; | 2366 | KABC::Addressee::List list; |
2365 | XXPortSelectDialog dlg( this, false, this ); | 2367 | XXPortSelectDialog dlg( this, false, this ); |
2366 | if ( dlg.exec() ) | 2368 | if ( dlg.exec() ) |
2367 | list = dlg.contacts(); | 2369 | list = dlg.contacts(); |
2368 | else | 2370 | else |
2369 | return; | 2371 | return; |
2370 | KABC::Addressee::List::Iterator it; | 2372 | KABC::Addressee::List::Iterator it; |
2371 | for ( it = list.begin(); it != list.end(); ++it ) { | 2373 | for ( it = list.begin(); it != list.end(); ++it ) { |
2372 | QString fName; | 2374 | QString fName; |
2373 | if ( setpref.simple->isChecked() ) | 2375 | if ( setpref.simple->isChecked() ) |
2374 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); | 2376 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); |
2375 | else if ( setpref.full->isChecked() ) | 2377 | else if ( setpref.full->isChecked() ) |
2376 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); | 2378 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); |
2377 | else if ( setpref.reverse->isChecked() ) | 2379 | else if ( setpref.reverse->isChecked() ) |
2378 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); | 2380 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); |
2379 | else | 2381 | else |
2380 | fName = (*it).organization(); | 2382 | fName = (*it).organization(); |
2381 | if ( setpref.setCompany->isChecked() ) | 2383 | if ( setpref.setCompany->isChecked() ) |
2382 | if ( fName.isEmpty() || fName =="," ) | 2384 | if ( fName.isEmpty() || fName =="," ) |
2383 | fName = (*it).organization(); | 2385 | fName = (*it).organization(); |
2384 | (*it).setFormattedName( fName ); | 2386 | (*it).setFormattedName( fName ); |
2385 | addrModified((*it),false ); | 2387 | addrModified((*it),false ); |
2386 | } | 2388 | } |
2387 | Addressee add; | 2389 | Addressee add; |
2388 | mDetails->setAddressee( add ); | 2390 | mDetails->setAddressee( add ); |
2389 | } | 2391 | } |
2390 | 2392 | ||
2391 | void KABCore::clipboardDataChanged() | 2393 | void KABCore::clipboardDataChanged() |
2392 | { | 2394 | { |
2393 | 2395 | ||
2394 | if ( mReadWrite ) | 2396 | if ( mReadWrite ) |
2395 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2397 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2396 | 2398 | ||
2397 | } | 2399 | } |
2398 | 2400 | ||
2399 | void KABCore::updateActionMenu() | 2401 | void KABCore::updateActionMenu() |
2400 | { | 2402 | { |
2401 | UndoStack *undo = UndoStack::instance(); | 2403 | UndoStack *undo = UndoStack::instance(); |
2402 | RedoStack *redo = RedoStack::instance(); | 2404 | RedoStack *redo = RedoStack::instance(); |
2403 | 2405 | ||
2404 | if ( undo->isEmpty() ) | 2406 | if ( undo->isEmpty() ) |
2405 | mActionUndo->setText( i18n( "Undo" ) ); | 2407 | mActionUndo->setText( i18n( "Undo" ) ); |
2406 | else | 2408 | else |
2407 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2409 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2408 | 2410 | ||
2409 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2411 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2410 | 2412 | ||
2411 | if ( !redo->top() ) | 2413 | if ( !redo->top() ) |
2412 | mActionRedo->setText( i18n( "Redo" ) ); | 2414 | mActionRedo->setText( i18n( "Redo" ) ); |
2413 | else | 2415 | else |
2414 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2416 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2415 | 2417 | ||
2416 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2418 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2417 | } | 2419 | } |
2418 | 2420 | ||
2419 | void KABCore::configureKeyBindings() | 2421 | void KABCore::configureKeyBindings() |
2420 | { | 2422 | { |
2421 | #ifndef KAB_EMBEDDED | 2423 | #ifndef KAB_EMBEDDED |
2422 | KKeyDialog::configure( actionCollection(), true ); | 2424 | KKeyDialog::configure( actionCollection(), true ); |
2423 | #else //KAB_EMBEDDED | 2425 | #else //KAB_EMBEDDED |
2424 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2426 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2425 | #endif //KAB_EMBEDDED | 2427 | #endif //KAB_EMBEDDED |
2426 | } | 2428 | } |
2427 | 2429 | ||
2428 | #ifdef KAB_EMBEDDED | 2430 | #ifdef KAB_EMBEDDED |
2429 | void KABCore::configureResources() | 2431 | void KABCore::configureResources() |
2430 | { | 2432 | { |
2431 | KRES::KCMKResources dlg( this, "" , 0 ); | 2433 | KRES::KCMKResources dlg( this, "" , 0 ); |
2432 | 2434 | ||
2433 | if ( !dlg.exec() ) | 2435 | if ( !dlg.exec() ) |
2434 | return; | 2436 | return; |
2435 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2437 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2436 | } | 2438 | } |
2437 | #endif //KAB_EMBEDDED | 2439 | #endif //KAB_EMBEDDED |
2438 | 2440 | ||
2439 | 2441 | ||
2440 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2442 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2441 | * for the attendees list of an event. | 2443 | * for the attendees list of an event. |
2442 | */ | 2444 | */ |
2443 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2445 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2444 | { | 2446 | { |
2445 | QStringList nameList; | 2447 | QStringList nameList; |
2446 | QStringList emailList; | 2448 | QStringList emailList; |
2447 | QStringList uidList; | 2449 | QStringList uidList; |
2448 | 2450 | ||
2449 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2451 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2450 | uint i=0; | 2452 | uint i=0; |
2451 | for (i=0; i < list.count(); i++) | 2453 | for (i=0; i < list.count(); i++) |
2452 | { | 2454 | { |
2453 | nameList.append(list[i].realName()); | 2455 | nameList.append(list[i].realName()); |
2454 | emailList.append(list[i].preferredEmail()); | 2456 | emailList.append(list[i].preferredEmail()); |
2455 | uidList.append(list[i].uid()); | 2457 | uidList.append(list[i].uid()); |
2456 | } | 2458 | } |
2457 | 2459 | ||
2458 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2460 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2459 | 2461 | ||
2460 | } | 2462 | } |
2461 | 2463 | ||
2462 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2464 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2463 | * to put them into the calendar. | 2465 | * to put them into the calendar. |
2464 | */ | 2466 | */ |
2465 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2467 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2466 | { | 2468 | { |
2467 | // qDebug("KABCore::requestForBirthdayList"); | 2469 | // qDebug("KABCore::requestForBirthdayList"); |
2468 | QStringList birthdayList; | 2470 | QStringList birthdayList; |
2469 | QStringList anniversaryList; | 2471 | QStringList anniversaryList; |
2470 | QStringList realNameList; | 2472 | QStringList realNameList; |
2471 | QStringList preferredEmailList; | 2473 | QStringList preferredEmailList; |
2472 | QStringList assembledNameList; | 2474 | QStringList assembledNameList; |
2473 | QStringList uidList; | 2475 | QStringList uidList; |
2474 | 2476 | ||
2475 | KABC::AddressBook::Iterator it; | 2477 | KABC::AddressBook::Iterator it; |
2476 | 2478 | ||
2477 | int count = 0; | 2479 | int count = 0; |
2478 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2480 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2479 | ++count; | 2481 | ++count; |
2480 | } | 2482 | } |
2481 | QProgressBar bar(count,0 ); | 2483 | QProgressBar bar(count,0 ); |
2482 | int w = 300; | 2484 | int w = 300; |
2483 | if ( QApplication::desktop()->width() < 320 ) | 2485 | if ( QApplication::desktop()->width() < 320 ) |
2484 | w = 220; | 2486 | w = 220; |
2485 | int h = bar.sizeHint().height() ; | 2487 | int h = bar.sizeHint().height() ; |
2486 | int dw = QApplication::desktop()->width(); | 2488 | int dw = QApplication::desktop()->width(); |
2487 | int dh = QApplication::desktop()->height(); | 2489 | int dh = QApplication::desktop()->height(); |
2488 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2490 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2489 | bar.show(); | 2491 | bar.show(); |
2490 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2492 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2491 | qApp->processEvents(); | 2493 | qApp->processEvents(); |
2492 | 2494 | ||
2493 | QDate bday; | 2495 | QDate bday; |
2494 | QString anni; | 2496 | QString anni; |
2495 | QString formattedbday; | 2497 | QString formattedbday; |
2496 | 2498 | ||
2497 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2499 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2498 | { | 2500 | { |
2499 | if ( ! bar.isVisible() ) | 2501 | if ( ! bar.isVisible() ) |
2500 | return; | 2502 | return; |
2501 | bar.setProgress( count++ ); | 2503 | bar.setProgress( count++ ); |
2502 | qApp->processEvents(); | 2504 | qApp->processEvents(); |
2503 | bday = (*it).birthday().date(); | 2505 | bday = (*it).birthday().date(); |
2504 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2506 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2505 | 2507 | ||
2506 | if ( bday.isValid() || !anni.isEmpty()) | 2508 | if ( bday.isValid() || !anni.isEmpty()) |
2507 | { | 2509 | { |
2508 | if (bday.isValid()) | 2510 | if (bday.isValid()) |
2509 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2511 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2510 | else | 2512 | else |
2511 | formattedbday = "NOTVALID"; | 2513 | formattedbday = "NOTVALID"; |
2512 | if (anni.isEmpty()) | 2514 | if (anni.isEmpty()) |
2513 | anni = "INVALID"; | 2515 | anni = "INVALID"; |
2514 | 2516 | ||
2515 | birthdayList.append(formattedbday); | 2517 | birthdayList.append(formattedbday); |
2516 | anniversaryList.append(anni); //should be ISODate | 2518 | anniversaryList.append(anni); //should be ISODate |
2517 | realNameList.append((*it).realName()); | 2519 | realNameList.append((*it).realName()); |
2518 | preferredEmailList.append((*it).preferredEmail()); | 2520 | preferredEmailList.append((*it).preferredEmail()); |
2519 | assembledNameList.append((*it).assembledName()); | 2521 | assembledNameList.append((*it).assembledName()); |
2520 | uidList.append((*it).uid()); | 2522 | uidList.append((*it).uid()); |
2521 | 2523 | ||
2522 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2524 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2523 | } | 2525 | } |
2524 | } | 2526 | } |
2525 | 2527 | ||
2526 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2528 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2527 | 2529 | ||
2528 | } | 2530 | } |
2529 | 2531 | ||
2530 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2532 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2531 | */ | 2533 | */ |
2532 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2534 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2533 | { | 2535 | { |
2534 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2536 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2535 | 2537 | ||
2536 | QString foundUid = QString::null; | 2538 | QString foundUid = QString::null; |
2537 | if ( ! uid.isEmpty() ) { | 2539 | if ( ! uid.isEmpty() ) { |
2538 | Addressee adrr = mAddressBook->findByUid( uid ); | 2540 | Addressee adrr = mAddressBook->findByUid( uid ); |
2539 | if ( !adrr.isEmpty() ) { | 2541 | if ( !adrr.isEmpty() ) { |
2540 | foundUid = uid; | 2542 | foundUid = uid; |
2541 | } | 2543 | } |
2542 | if ( email == "sendbacklist" ) { | 2544 | if ( email == "sendbacklist" ) { |
2543 | //qDebug("ssssssssssssssssssssssend "); | 2545 | //qDebug("ssssssssssssssssssssssend "); |
2544 | QStringList nameList; | 2546 | QStringList nameList; |
2545 | QStringList emailList; | 2547 | QStringList emailList; |
2546 | QStringList uidList; | 2548 | QStringList uidList; |
2547 | nameList.append(adrr.realName()); | 2549 | nameList.append(adrr.realName()); |
2548 | emailList = adrr.emails(); | 2550 | emailList = adrr.emails(); |
2549 | uidList.append( adrr.preferredEmail()); | 2551 | uidList.append( adrr.preferredEmail()); |
2550 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2552 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2551 | return; | 2553 | return; |
2552 | } | 2554 | } |
2553 | 2555 | ||
2554 | } | 2556 | } |
2555 | 2557 | ||
2556 | if ( email == "sendbacklist" ) | 2558 | if ( email == "sendbacklist" ) |
2557 | return; | 2559 | return; |
2558 | if (foundUid.isEmpty()) | 2560 | if (foundUid.isEmpty()) |
2559 | { | 2561 | { |
2560 | //find the uid of the person first | 2562 | //find the uid of the person first |
2561 | Addressee::List namelist; | 2563 | Addressee::List namelist; |
2562 | Addressee::List emaillist; | 2564 | Addressee::List emaillist; |
2563 | 2565 | ||
2564 | if (!name.isEmpty()) | 2566 | if (!name.isEmpty()) |
2565 | namelist = mAddressBook->findByName( name ); | 2567 | namelist = mAddressBook->findByName( name ); |
2566 | 2568 | ||
2567 | if (!email.isEmpty()) | 2569 | if (!email.isEmpty()) |
2568 | emaillist = mAddressBook->findByEmail( email ); | 2570 | emaillist = mAddressBook->findByEmail( email ); |
2569 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2571 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2570 | //check if we have a match in Namelist and Emaillist | 2572 | //check if we have a match in Namelist and Emaillist |
2571 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2573 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2572 | foundUid = emaillist[0].uid(); | 2574 | foundUid = emaillist[0].uid(); |
2573 | } | 2575 | } |
2574 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2576 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2575 | foundUid = namelist[0].uid(); | 2577 | foundUid = namelist[0].uid(); |
2576 | else | 2578 | else |
2577 | { | 2579 | { |
2578 | for (int i = 0; i < namelist.count(); i++) | 2580 | for (int i = 0; i < namelist.count(); i++) |
2579 | { | 2581 | { |
2580 | for (int j = 0; j < emaillist.count(); j++) | 2582 | for (int j = 0; j < emaillist.count(); j++) |
2581 | { | 2583 | { |
2582 | if (namelist[i] == emaillist[j]) | 2584 | if (namelist[i] == emaillist[j]) |
2583 | { | 2585 | { |
2584 | foundUid = namelist[i].uid(); | 2586 | foundUid = namelist[i].uid(); |
2585 | } | 2587 | } |
2586 | } | 2588 | } |
2587 | } | 2589 | } |
2588 | } | 2590 | } |
2589 | } | 2591 | } |
2590 | else | 2592 | else |
2591 | { | 2593 | { |
2592 | foundUid = uid; | 2594 | foundUid = uid; |
2593 | } | 2595 | } |
2594 | 2596 | ||
2595 | if (!foundUid.isEmpty()) | 2597 | if (!foundUid.isEmpty()) |
2596 | { | 2598 | { |
2597 | 2599 | ||
2598 | // raise Ka/Pi if it is in the background | 2600 | // raise Ka/Pi if it is in the background |
2599 | #ifndef DESKTOP_VERSION | 2601 | #ifndef DESKTOP_VERSION |
2600 | #ifndef KORG_NODCOP | 2602 | #ifndef KORG_NODCOP |
2601 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2603 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2602 | #endif | 2604 | #endif |
2603 | #endif | 2605 | #endif |
2604 | 2606 | ||
2605 | mMainWindow->showMaximized(); | 2607 | mMainWindow->showMaximized(); |
2606 | mMainWindow-> raise(); | 2608 | mMainWindow-> raise(); |
2607 | 2609 | ||
2608 | mViewManager->setSelected( "", false); | 2610 | mViewManager->setSelected( "", false); |
2609 | mViewManager->refreshView( "" ); | 2611 | mViewManager->refreshView( "" ); |
2610 | mViewManager->setSelected( foundUid, true ); | 2612 | mViewManager->setSelected( foundUid, true ); |
2611 | mViewManager->refreshView( foundUid ); | 2613 | mViewManager->refreshView( foundUid ); |
2612 | 2614 | ||
2613 | if ( !mMultipleViewsAtOnce ) | 2615 | if ( !mMultipleViewsAtOnce ) |
2614 | { | 2616 | { |
2615 | setDetailsVisible( true ); | 2617 | setDetailsVisible( true ); |
2616 | mActionDetails->setChecked(true); | 2618 | mActionDetails->setChecked(true); |
2617 | } | 2619 | } |
2618 | } | 2620 | } |
2619 | } | 2621 | } |
2620 | 2622 | ||
2621 | void KABCore::whatsnew() | 2623 | void KABCore::whatsnew() |
2622 | { | 2624 | { |
2623 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2625 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2624 | } | 2626 | } |
2625 | void KABCore::synchowto() | 2627 | void KABCore::synchowto() |
2626 | { | 2628 | { |
2627 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2629 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2628 | } | 2630 | } |
2629 | void KABCore::kdesynchowto() | 2631 | void KABCore::kdesynchowto() |
2630 | { | 2632 | { |
2631 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 2633 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
2632 | } | 2634 | } |
2633 | void KABCore::multisynchowto() | 2635 | void KABCore::multisynchowto() |
2634 | { | 2636 | { |
2635 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 2637 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
2636 | } | 2638 | } |
2637 | void KABCore::faq() | 2639 | void KABCore::faq() |
2638 | { | 2640 | { |
2639 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2641 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2640 | } | 2642 | } |
2641 | 2643 | ||
2642 | #include <libkcal/syncdefines.h> | 2644 | #include <libkcal/syncdefines.h> |
2643 | 2645 | ||
2644 | KABC::Addressee KABCore::getLastSyncAddressee() | 2646 | KABC::Addressee KABCore::getLastSyncAddressee() |
2645 | { | 2647 | { |
2646 | Addressee lse; | 2648 | Addressee lse; |
2647 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2649 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2648 | 2650 | ||
2649 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2651 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2650 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2652 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2651 | if (lse.isEmpty()) { | 2653 | if (lse.isEmpty()) { |
2652 | qDebug("Creating new last-syncAddressee "); | 2654 | qDebug("Creating new last-syncAddressee "); |
2653 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2655 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2654 | QString sum = ""; | 2656 | QString sum = ""; |
2655 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2657 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2656 | sum = "E: "; | 2658 | sum = "E: "; |
2657 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2659 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2658 | lse.setRevision( mLastAddressbookSync ); | 2660 | lse.setRevision( mLastAddressbookSync ); |
2659 | lse.setCategories( i18n("SyncEvent") ); | 2661 | lse.setCategories( i18n("SyncEvent") ); |
2660 | mAddressBook->insertAddressee( lse ); | 2662 | mAddressBook->insertAddressee( lse ); |
2661 | } | 2663 | } |
2662 | return lse; | 2664 | return lse; |
2663 | } | 2665 | } |
2664 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2666 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2665 | { | 2667 | { |
2666 | 2668 | ||
2667 | //void setZaurusId(int id); | 2669 | //void setZaurusId(int id); |
2668 | // int zaurusId() const; | 2670 | // int zaurusId() const; |
2669 | // void setZaurusUid(int id); | 2671 | // void setZaurusUid(int id); |
2670 | // int zaurusUid() const; | 2672 | // int zaurusUid() const; |
2671 | // void setZaurusStat(int id); | 2673 | // void setZaurusStat(int id); |
2672 | // int zaurusStat() const; | 2674 | // int zaurusStat() const; |
2673 | // 0 equal | 2675 | // 0 equal |
2674 | // 1 take local | 2676 | // 1 take local |
2675 | // 2 take remote | 2677 | // 2 take remote |
2676 | // 3 cancel | 2678 | // 3 cancel |
2677 | QDateTime lastSync = mLastAddressbookSync; | 2679 | QDateTime lastSync = mLastAddressbookSync; |
2678 | QDateTime localMod = local->revision(); | 2680 | QDateTime localMod = local->revision(); |
2679 | QDateTime remoteMod = remote->revision(); | 2681 | QDateTime remoteMod = remote->revision(); |
2680 | 2682 | ||
2681 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2683 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2682 | 2684 | ||
2683 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2685 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2684 | bool remCh, locCh; | 2686 | bool remCh, locCh; |
2685 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2687 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2686 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2688 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2687 | locCh = ( localMod > mLastAddressbookSync ); | 2689 | locCh = ( localMod > mLastAddressbookSync ); |
2690 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); | ||
2688 | if ( !remCh && ! locCh ) { | 2691 | if ( !remCh && ! locCh ) { |
2689 | //qDebug("both not changed "); | 2692 | //qDebug("both not changed "); |
2690 | lastSync = localMod.addDays(1); | 2693 | lastSync = localMod.addDays(1); |
2691 | if ( mode <= SYNC_PREF_ASK ) | 2694 | if ( mode <= SYNC_PREF_ASK ) |
2692 | return 0; | 2695 | return 0; |
2693 | } else { | 2696 | } else { |
2694 | if ( locCh ) { | 2697 | if ( locCh ) { |
2695 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2698 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2696 | lastSync = localMod.addDays( -1 ); | 2699 | lastSync = localMod.addDays( -1 ); |
2697 | if ( !remCh ) | 2700 | if ( !remCh ) |
2698 | remoteMod =( lastSync.addDays( -1 ) ); | 2701 | remoteMod =( lastSync.addDays( -1 ) ); |
2699 | } else { | 2702 | } else { |
2700 | //qDebug(" not loc changed "); | 2703 | //qDebug(" not loc changed "); |
2701 | lastSync = localMod.addDays( 1 ); | 2704 | lastSync = localMod.addDays( 1 ); |
2702 | if ( remCh ) { | 2705 | if ( remCh ) { |
2703 | //qDebug("rem changed "); | 2706 | //qDebug("rem changed "); |
2704 | remoteMod =( lastSync.addDays( 1 ) ); | 2707 | remoteMod =( lastSync.addDays( 1 ) ); |
2705 | } | 2708 | } |
2706 | 2709 | ||
2707 | } | 2710 | } |
2708 | } | 2711 | } |
2709 | full = true; | 2712 | full = true; |
2710 | if ( mode < SYNC_PREF_ASK ) | 2713 | if ( mode < SYNC_PREF_ASK ) |
2711 | mode = SYNC_PREF_ASK; | 2714 | mode = SYNC_PREF_ASK; |
2712 | } else { | 2715 | } else { |
2713 | if ( localMod == remoteMod ) | 2716 | if ( localMod == remoteMod ) |
2714 | return 0; | 2717 | return 0; |
2715 | 2718 | ||
2716 | } | 2719 | } |
2717 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); | 2720 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); |
2718 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); | 2721 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); |
2719 | //full = true; //debug only | 2722 | //full = true; //debug only |
2720 | if ( full ) { | 2723 | if ( full ) { |
2721 | bool equ = ( (*local) == (*remote) ); | 2724 | bool equ = ( (*local) == (*remote) ); |
2722 | if ( equ ) { | 2725 | if ( equ ) { |
2723 | //qDebug("equal "); | 2726 | //qDebug("equal "); |
2724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2727 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2725 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2728 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2726 | } | 2729 | } |
2727 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2730 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2728 | return 0; | 2731 | return 0; |
2729 | 2732 | ||
2730 | }//else //debug only | 2733 | }//else //debug only |
2731 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2734 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2732 | } | 2735 | } |
2733 | int result; | 2736 | int result; |
2734 | bool localIsNew; | 2737 | bool localIsNew; |
2735 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 2738 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
2736 | 2739 | ||
2737 | if ( full && mode < SYNC_PREF_NEWEST ) | 2740 | if ( full && mode < SYNC_PREF_NEWEST ) |
2738 | mode = SYNC_PREF_ASK; | 2741 | mode = SYNC_PREF_ASK; |
2739 | 2742 | ||
2740 | switch( mode ) { | 2743 | switch( mode ) { |
2741 | case SYNC_PREF_LOCAL: | 2744 | case SYNC_PREF_LOCAL: |
2742 | if ( lastSync > remoteMod ) | 2745 | if ( lastSync > remoteMod ) |
2743 | return 1; | 2746 | return 1; |
2744 | if ( lastSync > localMod ) | 2747 | if ( lastSync > localMod ) |
2745 | return 2; | 2748 | return 2; |
2746 | return 1; | 2749 | return 1; |
2747 | break; | 2750 | break; |
2748 | case SYNC_PREF_REMOTE: | 2751 | case SYNC_PREF_REMOTE: |
2749 | if ( lastSync > remoteMod ) | 2752 | if ( lastSync > remoteMod ) |
2750 | return 1; | 2753 | return 1; |
2751 | if ( lastSync > localMod ) | 2754 | if ( lastSync > localMod ) |
2752 | return 2; | 2755 | return 2; |
2753 | return 2; | 2756 | return 2; |
2754 | break; | 2757 | break; |
2755 | case SYNC_PREF_NEWEST: | 2758 | case SYNC_PREF_NEWEST: |
2756 | if ( localMod > remoteMod ) | 2759 | if ( localMod > remoteMod ) |
2757 | return 1; | 2760 | return 1; |
2758 | else | 2761 | else |
2759 | return 2; | 2762 | return 2; |
2760 | break; | 2763 | break; |
2761 | case SYNC_PREF_ASK: | 2764 | case SYNC_PREF_ASK: |
2762 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2765 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2763 | if ( lastSync > remoteMod ) | 2766 | if ( lastSync > remoteMod ) |
2764 | return 1; | 2767 | return 1; |
2765 | if ( lastSync > localMod ) | 2768 | if ( lastSync > localMod ) { |
2766 | return 2; | 2769 | return 2; |
2770 | } | ||
2767 | localIsNew = localMod >= remoteMod; | 2771 | localIsNew = localMod >= remoteMod; |
2768 | //qDebug("conflict! ************************************** "); | 2772 | //qDebug("conflict! ************************************** "); |
2769 | { | 2773 | { |
2770 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2774 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2771 | result = acd.executeD(localIsNew); | 2775 | result = acd.executeD(localIsNew); |
2772 | return result; | 2776 | return result; |
2773 | } | 2777 | } |
2774 | break; | 2778 | break; |
2775 | case SYNC_PREF_FORCE_LOCAL: | 2779 | case SYNC_PREF_FORCE_LOCAL: |
2776 | return 1; | 2780 | return 1; |
2777 | break; | 2781 | break; |
2778 | case SYNC_PREF_FORCE_REMOTE: | 2782 | case SYNC_PREF_FORCE_REMOTE: |
2779 | return 2; | 2783 | return 2; |
2780 | break; | 2784 | break; |
2781 | 2785 | ||
2782 | default: | 2786 | default: |
2783 | // SYNC_PREF_TAKE_BOTH not implemented | 2787 | // SYNC_PREF_TAKE_BOTH not implemented |
2784 | break; | 2788 | break; |
2785 | } | 2789 | } |
2786 | return 0; | 2790 | return 0; |
2787 | } | 2791 | } |
2788 | 2792 | ||
2789 | 2793 | ||
2790 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2794 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2791 | { | 2795 | { |
2792 | bool syncOK = true; | 2796 | bool syncOK = true; |
2793 | int addedAddressee = 0; | 2797 | int addedAddressee = 0; |
2794 | int addedAddresseeR = 0; | 2798 | int addedAddresseeR = 0; |
2795 | int deletedAddresseeR = 0; | 2799 | int deletedAddresseeR = 0; |
2796 | int deletedAddresseeL = 0; | 2800 | int deletedAddresseeL = 0; |
2797 | int changedLocal = 0; | 2801 | int changedLocal = 0; |
2798 | int changedRemote = 0; | 2802 | int changedRemote = 0; |
2799 | 2803 | ||
2800 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2804 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2801 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2805 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2802 | 2806 | ||
2803 | //QPtrList<Addressee> el = local->rawAddressees(); | 2807 | //QPtrList<Addressee> el = local->rawAddressees(); |
2804 | Addressee addresseeR; | 2808 | Addressee addresseeR; |
2805 | QString uid; | 2809 | QString uid; |
2806 | int take; | 2810 | int take; |
2807 | Addressee addresseeL; | 2811 | Addressee addresseeL; |
2808 | Addressee addresseeRSync; | 2812 | Addressee addresseeRSync; |
2809 | Addressee addresseeLSync; | 2813 | Addressee addresseeLSync; |
2810 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2814 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2811 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2815 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2812 | bool fullDateRange = false; | 2816 | bool fullDateRange = false; |
2813 | local->resetTempSyncStat(); | 2817 | local->resetTempSyncStat(); |
2814 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2818 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2815 | if ( syncManager->syncWithDesktop() ) { | 2819 | if ( syncManager->syncWithDesktop() ) { |
2816 | // remote->removeSyncInfo( QString());//remove all info | 2820 | // remote->removeSyncInfo( QString());//remove all info |
2817 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 2821 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
2818 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | 2822 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; |
2819 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | 2823 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); |
2820 | } else { | 2824 | } else { |
2821 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 2825 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
2822 | } | 2826 | } |
2823 | } | 2827 | } |
2824 | QDateTime modifiedCalendar = mLastAddressbookSync; | 2828 | QDateTime modifiedCalendar = mLastAddressbookSync; |
2825 | addresseeLSync = getLastSyncAddressee(); | 2829 | addresseeLSync = getLastSyncAddressee(); |
2826 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2830 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2827 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2831 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2828 | if ( !addresseeR.isEmpty() ) { | 2832 | if ( !addresseeR.isEmpty() ) { |
2829 | addresseeRSync = addresseeR; | 2833 | addresseeRSync = addresseeR; |
2830 | remote->removeAddressee(addresseeR ); | 2834 | remote->removeAddressee(addresseeR ); |
2831 | 2835 | ||
2832 | } else { | 2836 | } else { |
2833 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2837 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2834 | addresseeRSync = addresseeLSync ; | 2838 | addresseeRSync = addresseeLSync ; |
2835 | } else { | 2839 | } else { |
2836 | //qDebug("FULLDATE 1"); | 2840 | //qDebug("FULLDATE 1"); |
2837 | fullDateRange = true; | 2841 | fullDateRange = true; |
2838 | Addressee newAdd; | 2842 | Addressee newAdd; |
2839 | addresseeRSync = newAdd; | 2843 | addresseeRSync = newAdd; |
2840 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2844 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2841 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2845 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2842 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2846 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2843 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2847 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2844 | } | 2848 | } |
2845 | } | 2849 | } |
2846 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2850 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2847 | // qDebug("FULLDATE 2"); | 2851 | // qDebug("FULLDATE 2"); |
2848 | fullDateRange = true; | 2852 | fullDateRange = true; |
2849 | } | 2853 | } |
2850 | if ( ! fullDateRange ) { | 2854 | if ( ! fullDateRange ) { |
2851 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2855 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2852 | 2856 | ||
2853 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2857 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2854 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2858 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2855 | fullDateRange = true; | 2859 | fullDateRange = true; |
2856 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2860 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2857 | } | 2861 | } |
2858 | } | 2862 | } |
2859 | // fullDateRange = true; // debug only! | 2863 | // fullDateRange = true; // debug only! |
2860 | if ( fullDateRange ) | 2864 | if ( fullDateRange ) |
2861 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2865 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2862 | else | 2866 | else |
2863 | mLastAddressbookSync = addresseeLSync.revision(); | 2867 | mLastAddressbookSync = addresseeLSync.revision(); |
2864 | // for resyncing if own file has changed | 2868 | // for resyncing if own file has changed |
2865 | // PENDING fixme later when implemented | 2869 | // PENDING fixme later when implemented |
2866 | #if 0 | 2870 | #if 0 |
2867 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2871 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2868 | mLastAddressbookSync = loadedFileVersion; | 2872 | mLastAddressbookSync = loadedFileVersion; |
2869 | qDebug("setting mLastAddressbookSync "); | 2873 | qDebug("setting mLastAddressbookSync "); |
2870 | } | 2874 | } |
2871 | #endif | 2875 | #endif |
2872 | 2876 | ||
2873 | 2877 | ||
2874 | // ********** setting filters **************** | 2878 | // ********** setting filters **************** |
2875 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); | 2879 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); |
2876 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); | 2880 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); |
2877 | 2881 | ||
2878 | //qDebug("*************************** "); | 2882 | //qDebug("*************************** "); |
2879 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2883 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2880 | QStringList er = remote->uidList(); | 2884 | QStringList er = remote->uidList(); |
2881 | Addressee inR ;//= er.first(); | 2885 | Addressee inR ;//= er.first(); |
2882 | Addressee inL; | 2886 | Addressee inL; |
2883 | 2887 | ||
2884 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2888 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2885 | 2889 | ||
2886 | int modulo = (er.count()/10)+1; | 2890 | int modulo = (er.count()/10)+1; |
2887 | int incCounter = 0; | 2891 | int incCounter = 0; |
2888 | while ( incCounter < er.count()) { | 2892 | while ( incCounter < er.count()) { |
2889 | if (syncManager->isProgressBarCanceled()) | 2893 | if (syncManager->isProgressBarCanceled()) |
2890 | return false; | 2894 | return false; |
2891 | if ( incCounter % modulo == 0 ) | 2895 | if ( incCounter % modulo == 0 ) |
2892 | syncManager->showProgressBar(incCounter); | 2896 | syncManager->showProgressBar(incCounter); |
2893 | 2897 | ||
2894 | uid = er[ incCounter ]; | 2898 | uid = er[ incCounter ]; |
2895 | bool skipIncidence = false; | 2899 | bool skipIncidence = false; |
2896 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2900 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2897 | skipIncidence = true; | 2901 | skipIncidence = true; |
2898 | QString idS,OidS; | 2902 | QString idS,OidS; |
2899 | qApp->processEvents(); | 2903 | qApp->processEvents(); |
2900 | if ( !skipIncidence ) { | 2904 | if ( !skipIncidence ) { |
2901 | inL = local->findByUid( uid ); | 2905 | inL = local->findByUid( uid ); |
2902 | inR = remote->findByUid( uid ); | 2906 | inR = remote->findByUid( uid ); |
2903 | //inL.setResource( 0 ); | 2907 | //inL.setResource( 0 ); |
2904 | //inR.setResource( 0 ); | 2908 | //inR.setResource( 0 ); |
2905 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2909 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2906 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2910 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2907 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { | 2911 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { |
2908 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2912 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2909 | if ( take == 3 ) | 2913 | if ( take == 3 ) |
2910 | return false; | 2914 | return false; |
2911 | if ( take == 1 ) {// take local ********************** | 2915 | if ( take == 1 ) {// take local ********************** |
2912 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2916 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2913 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2917 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2914 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2918 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2915 | local->insertAddressee( inL, false ); | 2919 | local->insertAddressee( inL, false ); |
2916 | idS = inR.externalUID(); | 2920 | idS = inR.externalUID(); |
2917 | OidS = inR.originalExternalUID(); | 2921 | OidS = inR.originalExternalUID(); |
2918 | } | 2922 | } |
2919 | else | 2923 | else |
2920 | idS = inR.IDStr(); | 2924 | idS = inR.IDStr(); |
2921 | remote->removeAddressee( inR ); | 2925 | remote->removeAddressee( inR ); |
2922 | inR = inL; | 2926 | inR = inL; |
2923 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2927 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2924 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2928 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2925 | inR.setOriginalExternalUID( OidS ); | 2929 | inR.setOriginalExternalUID( OidS ); |
2926 | inR.setExternalUID( idS ); | 2930 | inR.setExternalUID( idS ); |
2927 | if ( syncManager->syncWithDesktop() ) { | 2931 | if ( syncManager->syncWithDesktop() ) { |
2928 | inR.setIDStr("changed" ); | 2932 | inR.setIDStr("changed" ); |
2929 | } | 2933 | } |
2930 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); | 2934 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); |
2931 | } else { | 2935 | } else { |
2932 | inR.setIDStr( idS ); | 2936 | inR.setIDStr( idS ); |
2933 | } | 2937 | } |
2934 | inR.setResource( 0 ); | 2938 | inR.setResource( 0 ); |
2935 | remote->insertAddressee( inR , false); | 2939 | remote->insertAddressee( inR , false); |
2936 | ++changedRemote; | 2940 | ++changedRemote; |
2937 | } else { // take == 2 take remote ********************** | 2941 | } else { // take == 2 take remote ********************** |
2938 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2942 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2939 | if ( inR.revision().date().year() < 2004 ) | 2943 | if ( inR.revision().date().year() < 2004 ) |
2940 | inR.setRevision( modifiedCalendar ); | 2944 | inR.setRevision( modifiedCalendar ); |
2941 | } | 2945 | } |
2942 | idS = inL.IDStr(); | 2946 | idS = inL.IDStr(); |
2943 | local->removeAddressee( inL ); | 2947 | local->removeAddressee( inL ); |
2944 | inL = inR; | 2948 | inL = inR; |
2945 | inL.setIDStr( idS ); | 2949 | inL.setIDStr( idS ); |
2946 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2950 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2947 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2951 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2948 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2952 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2949 | } | 2953 | } |
2950 | inL.setResource( 0 ); | 2954 | inL.setResource( 0 ); |
2951 | local->insertAddressee( inL , false ); | 2955 | local->insertAddressee( inL , false ); |
2952 | ++changedLocal; | 2956 | ++changedLocal; |
2953 | } | 2957 | } |
2954 | } | 2958 | } |
2955 | } | 2959 | } |
2956 | } else { // no conflict ********** add or delete remote | 2960 | } else { // no conflict ********** add or delete remote |
2957 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { | 2961 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { |
2958 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2962 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2959 | QString des = addresseeLSync.note(); | 2963 | QString des = addresseeLSync.note(); |
2960 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2964 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2961 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2965 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2962 | remote->insertAddressee( inR, false ); | 2966 | remote->insertAddressee( inR, false ); |
2963 | ++deletedAddresseeR; | 2967 | ++deletedAddresseeR; |
2964 | } else { | 2968 | } else { |
2965 | inR.setRevision( modifiedCalendar ); | 2969 | inR.setRevision( modifiedCalendar ); |
2966 | remote->insertAddressee( inR, false ); | 2970 | remote->insertAddressee( inR, false ); |
2967 | inL = inR; | 2971 | inL = inR; |
2968 | inL.setIDStr( ":" ); | 2972 | inL.setIDStr( ":" ); |
2969 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2973 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2970 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2974 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2971 | inL.setResource( 0 ); | 2975 | inL.setResource( 0 ); |
2972 | local->insertAddressee( inL , false); | 2976 | local->insertAddressee( inL , false); |
2973 | ++addedAddressee; | 2977 | ++addedAddressee; |
2974 | } | 2978 | } |
2975 | } else { | 2979 | } else { |
2976 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2980 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2977 | inR.setRevision( modifiedCalendar ); | 2981 | inR.setRevision( modifiedCalendar ); |
2978 | remote->insertAddressee( inR, false ); | 2982 | remote->insertAddressee( inR, false ); |
2979 | inR.setResource( 0 ); | 2983 | inR.setResource( 0 ); |
2980 | local->insertAddressee( inR, false ); | 2984 | local->insertAddressee( inR, false ); |
2981 | ++addedAddressee; | 2985 | ++addedAddressee; |
2982 | } else { | 2986 | } else { |
2983 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2987 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2984 | remote->removeAddressee( inR ); | 2988 | remote->removeAddressee( inR ); |
2985 | ++deletedAddresseeR; | 2989 | ++deletedAddresseeR; |
2986 | } | 2990 | } |
2987 | } | 2991 | } |
2988 | } | 2992 | } |
2989 | } | 2993 | } |
2990 | } | 2994 | } |
2991 | ++incCounter; | 2995 | ++incCounter; |
2992 | } | 2996 | } |
2993 | er.clear(); | 2997 | er.clear(); |
2994 | QStringList el = local->uidList(); | 2998 | QStringList el = local->uidList(); |
2995 | modulo = (el.count()/10)+1; | 2999 | modulo = (el.count()/10)+1; |
2996 | 3000 | ||
2997 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 3001 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2998 | incCounter = 0; | 3002 | incCounter = 0; |
2999 | while ( incCounter < el.count()) { | 3003 | while ( incCounter < el.count()) { |
3000 | qApp->processEvents(); | 3004 | qApp->processEvents(); |
3001 | if (syncManager->isProgressBarCanceled()) | 3005 | if (syncManager->isProgressBarCanceled()) |
3002 | return false; | 3006 | return false; |
3003 | if ( incCounter % modulo == 0 ) | 3007 | if ( incCounter % modulo == 0 ) |
3004 | syncManager->showProgressBar(incCounter); | 3008 | syncManager->showProgressBar(incCounter); |
3005 | uid = el[ incCounter ]; | 3009 | uid = el[ incCounter ]; |
3006 | bool skipIncidence = false; | 3010 | bool skipIncidence = false; |
3007 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 3011 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
3008 | skipIncidence = true; | 3012 | skipIncidence = true; |
3009 | if ( !filterOUT.name().isEmpty() && ! filterOUT.filterAddressee( inL ) ) | 3013 | if ( ! skipIncidence ) { |
3010 | skipIncidence = true; | ||
3011 | if ( !skipIncidence ) { | ||
3012 | inL = local->findByUid( uid ); | 3014 | inL = local->findByUid( uid ); |
3015 | if ( (!filterOUT.name().isEmpty()) && (! filterOUT.filterAddressee( inL ) ) ) | ||
3016 | skipIncidence = true; | ||
3017 | } | ||
3018 | if ( !skipIncidence ) { | ||
3013 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 3019 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
3014 | inR = remote->findByUid( uid ); | 3020 | inR = remote->findByUid( uid ); |
3015 | if ( inR.isEmpty() ) { // no conflict ********** add or delete local | 3021 | if ( inR.isEmpty() ) { // no conflict ********** add or delete local |
3016 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3022 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3017 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 3023 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
3018 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3024 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3019 | local->removeAddressee( inL ); | 3025 | local->removeAddressee( inL ); |
3020 | ++deletedAddresseeL; | 3026 | ++deletedAddresseeL; |
3021 | } else { | 3027 | } else { |
3022 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3028 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3023 | inL.removeID(mCurrentSyncDevice ); | 3029 | inL.removeID(mCurrentSyncDevice ); |
3024 | ++addedAddresseeR; | 3030 | ++addedAddresseeR; |
3025 | inL.setRevision( modifiedCalendar ); | 3031 | inL.setRevision( modifiedCalendar ); |
3026 | local->insertAddressee( inL, false ); | 3032 | local->insertAddressee( inL, false ); |
3027 | inR = inL; | 3033 | inR = inL; |
3028 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 3034 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
3029 | inR.setResource( 0 ); | 3035 | inR.setResource( 0 ); |
3030 | remote->insertAddressee( inR, false ); | 3036 | remote->insertAddressee( inR, false ); |
3031 | } | 3037 | } |
3032 | } | 3038 | } |
3033 | } else { | 3039 | } else { |
3034 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 3040 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
3035 | //qDebug("data %s ", inL.revision().toString().latin1()); | 3041 | //qDebug("data %s ", inL.revision().toString().latin1()); |
3036 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3042 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3037 | local->removeAddressee( inL ); | 3043 | local->removeAddressee( inL ); |
3038 | ++deletedAddresseeL; | 3044 | ++deletedAddresseeL; |
3039 | } else { | 3045 | } else { |
3040 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3046 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3041 | ++addedAddresseeR; | 3047 | ++addedAddresseeR; |
3042 | inL.setRevision( modifiedCalendar ); | 3048 | inL.setRevision( modifiedCalendar ); |
3043 | local->insertAddressee( inL, false ); | 3049 | local->insertAddressee( inL, false ); |
3044 | inR = inL; | 3050 | inR = inL; |
3045 | inR.setIDStr( ":" ); | 3051 | inR.setIDStr( ":" ); |
3046 | inR.setResource( 0 ); | 3052 | inR.setResource( 0 ); |
3047 | remote->insertAddressee( inR, false ); | 3053 | remote->insertAddressee( inR, false ); |
3048 | } | 3054 | } |
3049 | } | 3055 | } |
3050 | } | 3056 | } |
3051 | } | 3057 | } |
3052 | } | 3058 | } |
3053 | } | 3059 | } |
3054 | ++incCounter; | 3060 | ++incCounter; |
3055 | } | 3061 | } |
3056 | el.clear(); | 3062 | el.clear(); |
3057 | syncManager->hideProgressBar(); | 3063 | syncManager->hideProgressBar(); |
3058 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 3064 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
3059 | // get rid of micro seconds | 3065 | // get rid of micro seconds |
3060 | QTime t = mLastAddressbookSync.time(); | 3066 | QTime t = mLastAddressbookSync.time(); |
3061 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 3067 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
3062 | addresseeLSync.setRevision( mLastAddressbookSync ); | 3068 | addresseeLSync.setRevision( mLastAddressbookSync ); |
3063 | addresseeRSync.setRevision( mLastAddressbookSync ); | 3069 | addresseeRSync.setRevision( mLastAddressbookSync ); |
3064 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 3070 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
3065 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 3071 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
3066 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 3072 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
3067 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 3073 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
3068 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 3074 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
3069 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 3075 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
3070 | addresseeRSync.setNote( "" ) ; | 3076 | addresseeRSync.setNote( "" ) ; |
3071 | addresseeLSync.setNote( "" ); | 3077 | addresseeLSync.setNote( "" ); |
3072 | 3078 | ||
3073 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 3079 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
3074 | remote->insertAddressee( addresseeRSync, false ); | 3080 | remote->insertAddressee( addresseeRSync, false ); |
3075 | local->insertAddressee( addresseeLSync, false ); | 3081 | local->insertAddressee( addresseeLSync, false ); |
3076 | QString mes; | 3082 | QString mes; |
3077 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); | 3083 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); |
3078 | qDebug( mes ); | 3084 | qDebug( mes ); |
3079 | mes = i18n("Local addressbook changed!\n") +mes; | 3085 | mes = i18n("Local addressbook changed!\n") +mes; |
3080 | if ( syncManager->mShowSyncSummary ) { | 3086 | if ( syncManager->mShowSyncSummary ) { |
3081 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 3087 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
3082 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | 3088 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { |
3083 | qDebug("cancelled "); | 3089 | qDebug("cancelled "); |
3084 | return false; | 3090 | return false; |
3085 | } | 3091 | } |
3086 | } | 3092 | } |
3087 | return syncOK; | 3093 | return syncOK; |
3088 | } | 3094 | } |
3089 | 3095 | ||
3090 | 3096 | ||
3091 | //this is a overwritten callbackmethods from the syncinterface | 3097 | //this is a overwritten callbackmethods from the syncinterface |
3092 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 3098 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
3093 | { | 3099 | { |
3094 | 3100 | ||
3095 | //pending prepare addresseeview for output | 3101 | //pending prepare addresseeview for output |
3096 | //pending detect, if remote file has REV field. if not switch to external sync | 3102 | //pending detect, if remote file has REV field. if not switch to external sync |
3097 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 3103 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
3098 | if ( manager != syncManager ) | 3104 | if ( manager != syncManager ) |
3099 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); | 3105 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); |
3100 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3106 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3101 | 3107 | ||
3102 | AddressBook abLocal(filename,"syncContact"); | 3108 | AddressBook abLocal(filename,"syncContact"); |
3103 | bool syncOK = false; | 3109 | bool syncOK = false; |
3104 | if ( abLocal.load() ) { | 3110 | if ( abLocal.load() ) { |
3105 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 3111 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
3106 | bool external = false; | 3112 | bool external = false; |
3107 | bool isXML = false; | 3113 | bool isXML = false; |
3108 | if ( filename.right(4) == ".xml") { | 3114 | if ( filename.right(4) == ".xml") { |
3109 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3115 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3110 | isXML = true; | 3116 | isXML = true; |
3111 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3117 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3112 | } else { | 3118 | } else { |
3113 | external = !manager->mIsKapiFile; | 3119 | external = !manager->mIsKapiFile; |
3114 | if ( external ) { | 3120 | if ( external ) { |
3115 | qDebug("Setting vcf mode to external "); | 3121 | qDebug("Setting vcf mode to external "); |
3116 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3122 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3117 | AddressBook::Iterator it; | 3123 | AddressBook::Iterator it; |
3118 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3124 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3119 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 3125 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
3120 | (*it).computeCsum( mCurrentSyncDevice ); | 3126 | (*it).computeCsum( mCurrentSyncDevice ); |
3121 | } | 3127 | } |
3122 | } | 3128 | } |
3123 | } | 3129 | } |
3124 | //AddressBook::Iterator it; | 3130 | //AddressBook::Iterator it; |
3125 | //QStringList vcards; | 3131 | //QStringList vcards; |
3126 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3132 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3127 | // qDebug("Name %s ", (*it).familyName().latin1()); | 3133 | // qDebug("Name %s ", (*it).familyName().latin1()); |
3128 | //} | 3134 | //} |
3129 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 3135 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
3130 | if ( syncOK ) { | 3136 | if ( syncOK ) { |
3131 | if ( syncManager->mWriteBackFile ) | 3137 | if ( syncManager->mWriteBackFile ) |
3132 | { | 3138 | { |
3133 | if ( external ) | 3139 | if ( external ) |
3134 | abLocal.removeSyncAddressees( !isXML); | 3140 | abLocal.removeSyncAddressees( !isXML); |
3135 | qDebug("Saving remote AB "); | 3141 | qDebug("Saving remote AB "); |
3136 | if ( ! abLocal.saveAB()) | 3142 | if ( ! abLocal.saveAB()) |
3137 | qDebug("Error writing back AB to file "); | 3143 | qDebug("Error writing back AB to file "); |
3138 | if ( external ) { | 3144 | if ( external ) { |
3139 | // afterwrite processing | 3145 | // afterwrite processing |
3140 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 3146 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
3141 | } | 3147 | } |
3142 | } | 3148 | } |
3143 | } | 3149 | } |
3144 | setModified(); | 3150 | setModified(); |
3145 | 3151 | ||
3146 | } | 3152 | } |
3147 | abLocal.removeResources(); | 3153 | abLocal.removeResources(); |
3148 | if ( syncOK ) | 3154 | if ( syncOK ) |
3149 | mViewManager->refreshView(); | 3155 | mViewManager->refreshView(); |
3150 | return syncOK; | 3156 | return syncOK; |
3151 | 3157 | ||
3152 | } | 3158 | } |
3153 | void KABCore::removeSyncInfo( QString syncProfile) | 3159 | void KABCore::removeSyncInfo( QString syncProfile) |
3154 | { | 3160 | { |
3155 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 3161 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
3156 | mAddressBook->removeSyncInfo( syncProfile ); | 3162 | mAddressBook->removeSyncInfo( syncProfile ); |
3157 | setModified(); | 3163 | setModified(); |
3158 | } | 3164 | } |
3159 | 3165 | ||
3160 | 3166 | ||
3161 | //this is a overwritten callbackmethods from the syncinterface | 3167 | //this is a overwritten callbackmethods from the syncinterface |
3162 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 3168 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
3163 | { | 3169 | { |
3164 | if ( resource == "phone" ) | 3170 | if ( resource == "phone" ) |
3165 | return syncPhone(); | 3171 | return syncPhone(); |
3166 | disableBR( true ); | 3172 | disableBR( true ); |
3167 | if ( manager != syncManager ) | 3173 | if ( manager != syncManager ) |
3168 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); | 3174 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); |
3169 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3175 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3170 | 3176 | ||
3171 | AddressBook abLocal( resource,"syncContact"); | 3177 | AddressBook abLocal( resource,"syncContact"); |
3172 | bool syncOK = false; | 3178 | bool syncOK = false; |
3173 | if ( abLocal.load() ) { | 3179 | if ( abLocal.load() ) { |
3174 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3180 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3175 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3181 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3176 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 3182 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
3177 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3183 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3178 | if ( syncOK ) { | 3184 | if ( syncOK ) { |
3179 | if ( syncManager->mWriteBackFile ) { | 3185 | if ( syncManager->mWriteBackFile ) { |
3180 | abLocal.removeSyncAddressees( false ); | 3186 | abLocal.removeSyncAddressees( false ); |
3181 | abLocal.saveAB(); | 3187 | abLocal.saveAB(); |
3182 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3188 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3183 | } | 3189 | } |
3184 | } else | 3190 | } else |
3185 | message( i18n("Sync cancelled or failed.") ); | 3191 | message( i18n("Sync cancelled or failed.") ); |
3186 | setModified(); | 3192 | setModified(); |
3187 | } | 3193 | } |
3188 | abLocal.removeResources(); | 3194 | abLocal.removeResources(); |
3189 | if ( syncOK ) | 3195 | if ( syncOK ) |
3190 | mViewManager->refreshView(); | 3196 | mViewManager->refreshView(); |
3191 | disableBR( false ); | 3197 | disableBR( false ); |
3192 | return syncOK; | 3198 | return syncOK; |
3193 | 3199 | ||
3194 | } | 3200 | } |
3195 | void KABCore::message( QString m ) | 3201 | void KABCore::message( QString m ) |
3196 | { | 3202 | { |
3197 | topLevelWidget()->setCaption( m ); | 3203 | topLevelWidget()->setCaption( m ); |
3198 | mMessageTimer->start( 15000, true ); | 3204 | mMessageTimer->start( 15000, true ); |
3199 | } | 3205 | } |
3200 | bool KABCore::syncPhone() | 3206 | bool KABCore::syncPhone() |
3201 | { | 3207 | { |
3202 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3208 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3203 | QString fileName = getPhoneFile(); | 3209 | QString fileName = getPhoneFile(); |
3204 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 3210 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
3205 | message(i18n("Phone access failed!")); | 3211 | message(i18n("Phone access failed!")); |
3206 | return false; | 3212 | return false; |
3207 | } | 3213 | } |
3208 | AddressBook abLocal( fileName,"syncContact"); | 3214 | AddressBook abLocal( fileName,"syncContact"); |
3209 | bool syncOK = false; | 3215 | bool syncOK = false; |
3210 | { | 3216 | { |
3211 | abLocal.importFromFile( fileName ); | 3217 | abLocal.importFromFile( fileName ); |
3212 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3218 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3213 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3219 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3214 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 3220 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
3215 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3221 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3216 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3222 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3217 | if ( syncOK ) { | 3223 | if ( syncOK ) { |
3218 | if ( syncManager->mWriteBackFile ) { | 3224 | if ( syncManager->mWriteBackFile ) { |
3219 | abLocal.removeSyncAddressees( true ); | 3225 | abLocal.removeSyncAddressees( true ); |
3220 | abLocal.saveABphone( fileName ); | 3226 | abLocal.saveABphone( fileName ); |
3221 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 3227 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
3222 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 3228 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
3223 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3229 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3224 | } | 3230 | } |
3225 | } | 3231 | } |
3226 | setModified(); | 3232 | setModified(); |
3227 | } | 3233 | } |
3228 | abLocal.removeResources(); | 3234 | abLocal.removeResources(); |
3229 | if ( syncOK ) | 3235 | if ( syncOK ) |
3230 | mViewManager->refreshView(); | 3236 | mViewManager->refreshView(); |
3231 | return syncOK; | 3237 | return syncOK; |
3232 | } | 3238 | } |
3233 | void KABCore::getFile( bool success ) | 3239 | void KABCore::getFile( bool success ) |
3234 | { | 3240 | { |
3235 | if ( ! success ) { | 3241 | if ( ! success ) { |
3236 | message( i18n("Error receiving file. Nothing changed!") ); | 3242 | message( i18n("Error receiving file. Nothing changed!") ); |
3237 | return; | 3243 | return; |
3238 | } | 3244 | } |
3239 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 3245 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
3240 | if ( count ) | 3246 | if ( count ) |
3241 | setModified( true ); | 3247 | setModified( true ); |
3242 | message( i18n("Pi-Sync successful!") ); | 3248 | message( i18n("Pi-Sync successful!") ); |
3243 | mViewManager->refreshView(); | 3249 | mViewManager->refreshView(); |
3244 | } | 3250 | } |
3245 | void KABCore::syncFileRequest() | 3251 | void KABCore::syncFileRequest() |
3246 | { | 3252 | { |
3247 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | 3253 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { |
3248 | syncManager->slotSyncMenu( 999 ); | 3254 | syncManager->slotSyncMenu( 999 ); |
3249 | } | 3255 | } |
3250 | mAddressBook->export2File( sentSyncFile() ); | 3256 | mAddressBook->export2File( sentSyncFile() ); |
3251 | } | 3257 | } |
3252 | QString KABCore::sentSyncFile() | 3258 | QString KABCore::sentSyncFile() |
3253 | { | 3259 | { |
3254 | #ifdef DESKTOP_VERSION | 3260 | #ifdef DESKTOP_VERSION |
3255 | return locateLocal( "tmp", "copysyncab.vcf" ); | 3261 | return locateLocal( "tmp", "copysyncab.vcf" ); |
3256 | #else | 3262 | #else |
3257 | return QString( "/tmp/copysyncab.vcf" ); | 3263 | return QString( "/tmp/copysyncab.vcf" ); |
3258 | #endif | 3264 | #endif |
3259 | } | 3265 | } |
3260 | 3266 | ||
3261 | void KABCore::setCaptionBack() | 3267 | void KABCore::setCaptionBack() |
3262 | { | 3268 | { |
3263 | mMessageTimer->stop(); | 3269 | mMessageTimer->stop(); |
3264 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 3270 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
3265 | } | 3271 | } |
diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp index 2832257..519dc92 100644 --- a/kaddressbook/kaddressbookmain.cpp +++ b/kaddressbook/kaddressbookmain.cpp | |||
@@ -1,239 +1,239 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 1999 Don Sanders <dsanders@kde.org> | 3 | Copyright (c) 1999 Don Sanders <dsanders@kde.org> |
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 | #ifdef KAB_EMBEDDED | 24 | #ifdef KAB_EMBEDDED |
25 | #include "kabprefs.h" | 25 | #include "kabprefs.h" |
26 | #include <kglobal.h> | 26 | #include <kglobal.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qtoolbar.h> | 28 | #include <qtoolbar.h> |
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | #else //KAB_EMBEDDED | 30 | #else //KAB_EMBEDDED |
31 | #include <kedittoolbar.h> | 31 | #include <kedittoolbar.h> |
32 | #include <kkeydialog.h> | 32 | #include <kkeydialog.h> |
33 | #include <kmessagebox.h> | 33 | #include <kmessagebox.h> |
34 | #include <kstatusbar.h> | 34 | #include <kstatusbar.h> |
35 | #endif //KAB_EMBEDDED | 35 | #endif //KAB_EMBEDDED |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | 37 | ||
38 | #include "kabcore.h" | 38 | #include "kabcore.h" |
39 | #include "kaddressbookmain.h" | 39 | #include "kaddressbookmain.h" |
40 | #include "kactioncollection.h" | 40 | #include "kactioncollection.h" |
41 | 41 | ||
42 | #ifdef KAB_EMBEDDED | 42 | #ifdef KAB_EMBEDDED |
43 | KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "adrressbook" ) | 43 | KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "adrressbook" ) |
44 | #else //KAB_EMBEDDED | 44 | #else //KAB_EMBEDDED |
45 | //MOC_SKIP_BEGIN | 45 | //MOC_SKIP_BEGIN |
46 | KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 ) | 46 | KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 ) |
47 | //MOC_SKIP_END | 47 | //MOC_SKIP_END |
48 | #endif //KAB_EMBEDDED | 48 | #endif //KAB_EMBEDDED |
49 | { | 49 | { |
50 | setIcon(SmallIcon( "ka24" ) ); | 50 | setIcon(SmallIcon( "ka24" ) ); |
51 | #if 0 | 51 | #if 0 |
52 | //US for embedded systems, create the toolbar before we initiate KABCore. | 52 | //US for embedded systems, create the toolbar before we initiate KABCore. |
53 | // KABCore will fill the toolbar with menues and icons | 53 | // KABCore will fill the toolbar with menues and icons |
54 | QMainWindow::ToolBarDock tbd; | 54 | QMainWindow::ToolBarDock tbd; |
55 | tbd = Top; | 55 | tbd = Top; |
56 | iconToolBar = new QToolBar( this ); | 56 | iconToolBar = new QToolBar( this ); |
57 | addToolBar (iconToolBar , tbd ); | 57 | addToolBar (iconToolBar , tbd ); |
58 | iconToolBar->setHorizontalStretchable(true); | 58 | iconToolBar->setHorizontalStretchable(true); |
59 | //US iconToolBar->setWidth(300); | 59 | //US iconToolBar->setWidth(300); |
60 | #endif // 0 | 60 | #endif // 0 |
61 | 61 | ||
62 | mCore = new KABCore( this, true, this ); | 62 | mCore = new KABCore( this, true, this ); |
63 | 63 | ||
64 | #ifdef KAB_EMBEDDED | 64 | #ifdef KAB_EMBEDDED |
65 | setCaption( i18n( "KAddressbook/Pi" ) ); | 65 | setCaption( i18n( "KAddressbook/Pi" ) ); |
66 | #else //KAB_EMBEDDED | 66 | #else //KAB_EMBEDDED |
67 | setCaption( i18n( "Address Book Browser" ) ); | 67 | setCaption( i18n( "Address Book Browser" ) ); |
68 | #endif //KAB_EMBEDDED | 68 | #endif //KAB_EMBEDDED |
69 | 69 | ||
70 | //mCore->restoreSettings(); | 70 | //mCore->restoreSettings(); |
71 | 71 | ||
72 | initActions(); | 72 | initActions(); |
73 | 73 | ||
74 | setCentralWidget( mCore ); | 74 | setCentralWidget( mCore ); |
75 | 75 | ||
76 | //US statusBar()->show(); | 76 | //US statusBar()->show(); |
77 | 77 | ||
78 | #ifndef KAB_EMBEDDED | 78 | #ifndef KAB_EMBEDDED |
79 | setStandardToolBarMenuEnabled(true); | 79 | setStandardToolBarMenuEnabled(true); |
80 | 80 | ||
81 | createGUI( "kaddressbookui.rc", false ); | 81 | createGUI( "kaddressbookui.rc", false ); |
82 | 82 | ||
83 | 83 | ||
84 | #endif //KAB_EMBEDDED | 84 | #endif //KAB_EMBEDDED |
85 | setAutoSaveSettings(); | 85 | setAutoSaveSettings(); |
86 | qApp->processEvents(); | 86 | qApp->processEvents(); |
87 | mCore->restoreSettings(); | 87 | mCore->restoreSettings(); |
88 | } | 88 | } |
89 | 89 | ||
90 | KAddressBookMain::~KAddressBookMain() | 90 | KAddressBookMain::~KAddressBookMain() |
91 | { | 91 | { |
92 | // mCore->saveSettings(); | 92 | // mCore->saveSettings(); |
93 | } | 93 | } |
94 | 94 | ||
95 | void KAddressBookMain::showMinimized () | 95 | void KAddressBookMain::showMinimized () |
96 | { | 96 | { |
97 | QWidget::showMinimized () ; | 97 | QWidget::showMinimized () ; |
98 | } | 98 | } |
99 | void KAddressBookMain::addEmail( QString addr ) | 99 | void KAddressBookMain::addEmail( QString addr ) |
100 | { | 100 | { |
101 | mCore->addEmail( addr ); | 101 | mCore->addEmail( addr ); |
102 | } | 102 | } |
103 | 103 | ||
104 | #ifndef KAB_EMBEDDED | 104 | #ifndef KAB_EMBEDDED |
105 | ASYNC KAddressBookMain::showContactEditor( QString uid ) | 105 | ASYNC KAddressBookMain::showContactEditor( QString uid ) |
106 | { | 106 | { |
107 | mCore->editContact( uid ); | 107 | mCore->editContact( uid ); |
108 | } | 108 | } |
109 | #endif //KAB_EMBEDDED | 109 | #endif //KAB_EMBEDDED |
110 | void KAddressBookMain::newContact() | 110 | void KAddressBookMain::newContact() |
111 | { | 111 | { |
112 | mCore->newContact(); | 112 | mCore->newContact(); |
113 | } | 113 | } |
114 | 114 | ||
115 | QString KAddressBookMain::getNameByPhone( QString phone ) | 115 | QString KAddressBookMain::getNameByPhone( QString phone ) |
116 | { | 116 | { |
117 | return mCore->getNameByPhone( phone ); | 117 | return mCore->getNameByPhone( phone ); |
118 | } | 118 | } |
119 | 119 | ||
120 | void KAddressBookMain::save() | 120 | void KAddressBookMain::save() |
121 | { | 121 | { |
122 | mCore->save(); | 122 | mCore->save(); |
123 | } | 123 | } |
124 | 124 | ||
125 | void KAddressBookMain::exit() | 125 | void KAddressBookMain::exit() |
126 | { | 126 | { |
127 | close( ); | 127 | close( ); |
128 | } | 128 | } |
129 | 129 | ||
130 | void KAddressBookMain::saveProperties( KConfig* ) | 130 | void KAddressBookMain::saveProperties( KConfig* ) |
131 | { | 131 | { |
132 | } | 132 | } |
133 | 133 | ||
134 | void KAddressBookMain::readProperties( KConfig* ) | 134 | void KAddressBookMain::readProperties( KConfig* ) |
135 | { | 135 | { |
136 | } | 136 | } |
137 | 137 | ||
138 | void KAddressBookMain::initActions() | 138 | void KAddressBookMain::initActions() |
139 | { | 139 | { |
140 | #ifndef KAB_EMBEDDED | 140 | #ifndef KAB_EMBEDDED |
141 | KStdAction::quit( this, SLOT( close() ), actionCollection() ); | 141 | KStdAction::quit( this, SLOT( close() ), actionCollection() ); |
142 | KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() ); | 142 | KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() ); |
143 | #else //KAB_EMBEDDED | 143 | #else //KAB_EMBEDDED |
144 | //US: transfered the setup of the actions into KABCore | 144 | //US: transfered the setup of the actions into KABCore |
145 | #endif //KAB_EMBEDDED | 145 | #endif //KAB_EMBEDDED |
146 | 146 | ||
147 | 147 | ||
148 | } | 148 | } |
149 | 149 | ||
150 | //US new method to setup menues and toolbars on embedded systems | 150 | //US new method to setup menues and toolbars on embedded systems |
151 | #ifdef KAB_EMBEDDED | 151 | #ifdef KAB_EMBEDDED |
152 | /* | 152 | /* |
153 | QToolBar * KAddressBookMain::getIconToolBar() | 153 | QToolBar * KAddressBookMain::getIconToolBar() |
154 | { | 154 | { |
155 | return iconToolBar; | 155 | return iconToolBar; |
156 | } | 156 | } |
157 | */ | 157 | */ |
158 | 158 | ||
159 | void KAddressBookMain::createGUI() | 159 | void KAddressBookMain::createGUI() |
160 | { | 160 | { |
161 | 161 | ||
162 | 162 | ||
163 | 163 | ||
164 | } | 164 | } |
165 | #endif //KAB_EMBEDDED | 165 | #endif //KAB_EMBEDDED |
166 | 166 | ||
167 | void KAddressBookMain::configureToolbars() | 167 | void KAddressBookMain::configureToolbars() |
168 | { | 168 | { |
169 | #ifndef KAB_EMBEDDED | 169 | #ifndef KAB_EMBEDDED |
170 | saveMainWindowSettings( KGlobal::config(), "MainWindow" ); | 170 | saveMainWindowSettings( KGlobal::config(), "MainWindow" ); |
171 | 171 | ||
172 | KEditToolbar dlg( factory() ); | 172 | KEditToolbar dlg( factory() ); |
173 | connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) ); | 173 | connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) ); |
174 | 174 | ||
175 | dlg.exec(); | 175 | dlg.exec(); |
176 | #else //KAB_EMBEDDED | 176 | #else //KAB_EMBEDDED |
177 | qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" ); | 177 | qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" ); |
178 | #endif //KAB_EMBEDDED | 178 | #endif //KAB_EMBEDDED |
179 | } | 179 | } |
180 | 180 | ||
181 | void KAddressBookMain::slotNewToolbarConfig() | 181 | void KAddressBookMain::slotNewToolbarConfig() |
182 | { | 182 | { |
183 | #ifndef KAB_EMBEDDED | 183 | #ifndef KAB_EMBEDDED |
184 | applyMainWindowSettings( KGlobal::config(), "MainWindow" ); | 184 | applyMainWindowSettings( KGlobal::config(), "MainWindow" ); |
185 | #else //KAB_EMBEDDED | 185 | #else //KAB_EMBEDDED |
186 | qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" ); | 186 | qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" ); |
187 | #endif //KAB_EMBEDDED | 187 | #endif //KAB_EMBEDDED |
188 | } | 188 | } |
189 | 189 | ||
190 | void KAddressBookMain::configureKeys() | 190 | void KAddressBookMain::configureKeys() |
191 | { | 191 | { |
192 | #ifndef KAB_EMBEDDED | 192 | #ifndef KAB_EMBEDDED |
193 | KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this ); | 193 | KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this ); |
194 | #else //KAB_EMBEDDED | 194 | #else //KAB_EMBEDDED |
195 | qDebug("KAddressBookMain::configureKeys() not implemented by ulf" ); | 195 | qDebug("KAddressBookMain::configureKeys() not implemented by ulf" ); |
196 | #endif //KAB_EMBEDDED | 196 | #endif //KAB_EMBEDDED |
197 | } | 197 | } |
198 | 198 | ||
199 | void KAddressBookMain::closeEvent( QCloseEvent* ce ) | 199 | void KAddressBookMain::closeEvent( QCloseEvent* ce ) |
200 | { | 200 | { |
201 | bool mModified = mCore->modified(); | 201 | bool mModified = mCore->modified(); |
202 | bool mAskForQuit = KABPrefs::instance()->mAskForQuit; | 202 | bool mAskForQuit = KABPrefs::instance()->mAskForQuit; |
203 | 203 | ||
204 | QString mess = i18n( "Close KA/Pi?"); | 204 | QString mess = i18n( "Close KA/Pi?"); |
205 | if ( mModified == true ) | 205 | if ( mModified == true ) |
206 | mess += i18n( "\nChanges will be saved!"); | 206 | mess += i18n( "\nChanges will be saved!"); |
207 | else | 207 | else |
208 | mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!"); | 208 | mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!"); |
209 | 209 | ||
210 | bool mQuit = true; | 210 | bool mQuit = true; |
211 | 211 | ||
212 | 212 | ||
213 | if (mAskForQuit) | 213 | if (mAskForQuit) |
214 | { | 214 | { |
215 | 215 | ||
216 | int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 ); | 216 | int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 ); |
217 | if (res == 0) | 217 | if (res == 0) |
218 | mQuit = true; | 218 | mQuit = true; |
219 | else | 219 | else |
220 | mQuit = false; | 220 | mQuit = false; |
221 | } | 221 | } |
222 | 222 | ||
223 | if (mQuit == false) | 223 | if (mQuit == false) |
224 | return; | 224 | return; |
225 | 225 | ||
226 | if (mModified == true) | 226 | if (mModified == true) |
227 | { | 227 | { |
228 | save(); | 228 | save(); |
229 | mCore->saveSettings(); | 229 | mCore->saveSettings(); |
230 | KABPrefs::instance()->writeConfig(); | 230 | //KABPrefs::instance()->writeConfig(); |
231 | } | 231 | } |
232 | 232 | ||
233 | ce->accept(); | 233 | ce->accept(); |
234 | } | 234 | } |
235 | 235 | ||
236 | #ifndef KAB_EMBEDDED | 236 | #ifndef KAB_EMBEDDED |
237 | #include "kaddressbookmain.moc" | 237 | #include "kaddressbookmain.moc" |
238 | #endif //KAB_EMBEDDED | 238 | #endif //KAB_EMBEDDED |
239 | 239 | ||
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index 9c3a641..4be860e 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp | |||
@@ -1,735 +1,734 @@ | |||
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 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | 31 | ||
32 | #ifndef KAB_EMBEDDED | 32 | #ifndef KAB_EMBEDDED |
33 | #include <libkdepim/kvcarddrag.h> | 33 | #include <libkdepim/kvcarddrag.h> |
34 | #include <kabc/vcardconverter.h> | 34 | #include <kabc/vcardconverter.h> |
35 | #include <kconfig.h> | 35 | #include <kconfig.h> |
36 | #include <kdeversion.h> | 36 | #include <kdeversion.h> |
37 | #include <kiconloader.h> | 37 | #include <kiconloader.h> |
38 | #include <klocale.h> | 38 | #include <klocale.h> |
39 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
40 | #include <kmultipledrag.h> | 40 | #include <kmultipledrag.h> |
41 | #include <ktrader.h> | 41 | #include <ktrader.h> |
42 | #include <kurldrag.h> | 42 | #include <kurldrag.h> |
43 | 43 | ||
44 | #include "addresseeutil.h" | 44 | #include "addresseeutil.h" |
45 | #else //KAB_EMBEDDED | 45 | #else //KAB_EMBEDDED |
46 | #include "views/kaddressbookiconview.h" | 46 | #include "views/kaddressbookiconview.h" |
47 | #include "views/kaddressbooktableview.h" | 47 | #include "views/kaddressbooktableview.h" |
48 | #include "views/kaddressbookcardview.h" | 48 | #include "views/kaddressbookcardview.h" |
49 | #include "kaddressbookview.h" | 49 | #include "kaddressbookview.h" |
50 | 50 | ||
51 | #include <qaction.h> | 51 | #include <qaction.h> |
52 | #include <qmessagebox.h> | 52 | #include <qmessagebox.h> |
53 | #include <qpopupmenu.h> | 53 | #include <qpopupmenu.h> |
54 | #include <kconfigbase.h> | 54 | #include <kconfigbase.h> |
55 | 55 | ||
56 | #endif //KAB_EMBEDDED | 56 | #endif //KAB_EMBEDDED |
57 | 57 | ||
58 | 58 | ||
59 | #include <kdebug.h> | 59 | #include <kdebug.h> |
60 | #include <kactionclasses.h> | 60 | #include <kactionclasses.h> |
61 | 61 | ||
62 | #include <qlayout.h> | 62 | #include <qlayout.h> |
63 | #include <qapplication.h> | 63 | #include <qapplication.h> |
64 | #include <qwidgetstack.h> | 64 | #include <qwidgetstack.h> |
65 | 65 | ||
66 | #include <kabc/addressbook.h> | 66 | #include <kabc/addressbook.h> |
67 | #include "filtereditdialog.h" | 67 | #include "filtereditdialog.h" |
68 | #include "addviewdialog.h" | 68 | #include "addviewdialog.h" |
69 | #include "kabcore.h" | 69 | #include "kabcore.h" |
70 | #include "kabprefs.h" | 70 | #include "kabprefs.h" |
71 | #include "viewmanager.h" | 71 | #include "viewmanager.h" |
72 | 72 | ||
73 | ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) | 73 | ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) |
74 | : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) | 74 | : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) |
75 | { | 75 | { |
76 | initGUI(); | 76 | initGUI(); |
77 | initActions(); | 77 | initActions(); |
78 | 78 | ||
79 | mViewDict.setAutoDelete( true ); | 79 | mViewDict.setAutoDelete( true ); |
80 | 80 | ||
81 | createViewFactories(); | 81 | createViewFactories(); |
82 | } | 82 | } |
83 | 83 | ||
84 | ViewManager::~ViewManager() | 84 | ViewManager::~ViewManager() |
85 | { | 85 | { |
86 | unloadViews(); | 86 | unloadViews(); |
87 | mViewFactoryDict.clear(); | 87 | mViewFactoryDict.clear(); |
88 | } | 88 | } |
89 | void ViewManager::scrollUP() | 89 | void ViewManager::scrollUP() |
90 | { | 90 | { |
91 | if ( mActiveView ) | 91 | if ( mActiveView ) |
92 | mActiveView->scrollUP(); | 92 | mActiveView->scrollUP(); |
93 | } | 93 | } |
94 | void ViewManager::scrollDOWN() | 94 | void ViewManager::scrollDOWN() |
95 | { | 95 | { |
96 | if ( mActiveView ) | 96 | if ( mActiveView ) |
97 | mActiveView->scrollDOWN(); | 97 | mActiveView->scrollDOWN(); |
98 | } | 98 | } |
99 | void ViewManager::restoreSettings() | 99 | void ViewManager::restoreSettings() |
100 | { | 100 | { |
101 | mViewNameList = KABPrefs::instance()->mViewNames; | 101 | mViewNameList = KABPrefs::instance()->mViewNames; |
102 | QString activeViewName = KABPrefs::instance()->mCurrentView; | 102 | QString activeViewName = KABPrefs::instance()->mCurrentView; |
103 | 103 | ||
104 | mActionSelectView->setItems( mViewNameList ); | 104 | mActionSelectView->setItems( mViewNameList ); |
105 | 105 | ||
106 | // Filter | 106 | // Filter |
107 | mFilterList = Filter::restore( mCore->config(), "Filter" ); | 107 | mFilterList = Filter::restore( mCore->config(), "Filter" ); |
108 | mActionSelectFilter->setItems( filterNames() ); | 108 | mActionSelectFilter->setItems( filterNames() ); |
109 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); | 109 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); |
110 | int cw = 150; | 110 | int cw = 150; |
111 | if (QApplication::desktop()->width() == 480 ) | 111 | if (QApplication::desktop()->width() == 480 ) |
112 | cw = 0; | 112 | cw = 0; |
113 | mActionSelectFilter->setComboWidth( cw ); | 113 | mActionSelectFilter->setComboWidth( cw ); |
114 | // Tell the views to reread their config, since they may have | 114 | // Tell the views to reread their config, since they may have |
115 | // been modified by global settings | 115 | // been modified by global settings |
116 | QString _oldgroup = mCore->config()->group(); | 116 | QString _oldgroup = mCore->config()->group(); |
117 | 117 | ||
118 | QDictIterator<KAddressBookView> it( mViewDict ); | 118 | QDictIterator<KAddressBookView> it( mViewDict ); |
119 | for ( it.toFirst(); it.current(); ++it ) { | 119 | for ( it.toFirst(); it.current(); ++it ) { |
120 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 120 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
121 | it.current()->readConfig( mCore->config() ); | 121 | it.current()->readConfig( mCore->config() ); |
122 | } | 122 | } |
123 | setActiveView( activeViewName ); | 123 | setActiveView( activeViewName ); |
124 | 124 | ||
125 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 125 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
126 | } | 126 | } |
127 | 127 | ||
128 | void ViewManager::saveSettings() | 128 | void ViewManager::saveSettings() |
129 | { | 129 | { |
130 | QString _oldgroup = mCore->config()->group(); | 130 | QString _oldgroup = mCore->config()->group(); |
131 | 131 | ||
132 | QDictIterator<KAddressBookView> it( mViewDict ); | 132 | QDictIterator<KAddressBookView> it( mViewDict ); |
133 | for ( it.toFirst(); it.current(); ++it ) { | 133 | for ( it.toFirst(); it.current(); ++it ) { |
134 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 134 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
135 | #ifdef DESKTOP_VERSION | 135 | #ifdef DESKTOP_VERSION |
136 | (*it)->writeConfig( mCore->config() ); | 136 | (*it)->writeConfig( mCore->config() ); |
137 | #else | 137 | #else |
138 | (*it).writeConfig( mCore->config() ); | 138 | (*it).writeConfig( mCore->config() ); |
139 | #endif | 139 | #endif |
140 | } | 140 | } |
141 | 141 | ||
142 | Filter::save( mCore->config(), "Filter", mFilterList ); | 142 | Filter::save( mCore->config(), "Filter", mFilterList ); |
143 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); | 143 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); |
144 | 144 | ||
145 | // write the view name list | 145 | // write the view name list |
146 | KABPrefs::instance()->mViewNames = mViewNameList; | 146 | KABPrefs::instance()->mViewNames = mViewNameList; |
147 | KABPrefs::instance()->mCurrentView = mActiveView->caption(); | 147 | KABPrefs::instance()->mCurrentView = mActiveView->caption(); |
148 | 148 | ||
149 | } | 149 | } |
150 | 150 | ||
151 | QStringList ViewManager::selectedUids() const | 151 | QStringList ViewManager::selectedUids() const |
152 | { | 152 | { |
153 | if ( mActiveView ) | 153 | if ( mActiveView ) |
154 | return mActiveView->selectedUids(); | 154 | return mActiveView->selectedUids(); |
155 | else | 155 | else |
156 | return QStringList(); | 156 | return QStringList(); |
157 | } | 157 | } |
158 | 158 | ||
159 | QStringList ViewManager::selectedEmails() const | 159 | QStringList ViewManager::selectedEmails() const |
160 | { | 160 | { |
161 | if ( mActiveView ) | 161 | if ( mActiveView ) |
162 | return mActiveView->selectedEmails(); | 162 | return mActiveView->selectedEmails(); |
163 | else | 163 | else |
164 | return QStringList(); | 164 | return QStringList(); |
165 | } | 165 | } |
166 | 166 | ||
167 | KABC::Addressee::List ViewManager::selectedAddressees() const | 167 | KABC::Addressee::List ViewManager::selectedAddressees() const |
168 | { | 168 | { |
169 | KABC::Addressee::List list; | 169 | KABC::Addressee::List list; |
170 | if ( mActiveView ) { | 170 | if ( mActiveView ) { |
171 | QStringList uids = mActiveView->selectedUids(); | 171 | QStringList uids = mActiveView->selectedUids(); |
172 | QStringList::Iterator it; | 172 | QStringList::Iterator it; |
173 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 173 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
174 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); | 174 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); |
175 | if ( !addr.isEmpty() ) | 175 | if ( !addr.isEmpty() ) |
176 | list.append( addr ); | 176 | list.append( addr ); |
177 | } | 177 | } |
178 | } | 178 | } |
179 | 179 | ||
180 | return list; | 180 | return list; |
181 | } | 181 | } |
182 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 182 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
183 | void ViewManager::setSelected() | 183 | void ViewManager::setSelected() |
184 | { | 184 | { |
185 | setSelected( QString::null, true ); | 185 | setSelected( QString::null, true ); |
186 | } | 186 | } |
187 | 187 | ||
188 | void ViewManager::setSelected( const QString &uid, bool selected ) | 188 | void ViewManager::setSelected( const QString &uid, bool selected ) |
189 | { | 189 | { |
190 | if ( mActiveView ) | 190 | if ( mActiveView ) |
191 | mActiveView->setSelected( uid, selected ); | 191 | mActiveView->setSelected( uid, selected ); |
192 | } | 192 | } |
193 | 193 | ||
194 | void ViewManager::setListSelected(QStringList list) | 194 | void ViewManager::setListSelected(QStringList list) |
195 | { | 195 | { |
196 | int i, count = list.count(); | 196 | int i, count = list.count(); |
197 | for ( i = 0; i < count;++i ) | 197 | for ( i = 0; i < count;++i ) |
198 | setSelected( list[i], true ); | 198 | setSelected( list[i], true ); |
199 | 199 | ||
200 | } | 200 | } |
201 | void ViewManager::unloadViews() | 201 | void ViewManager::unloadViews() |
202 | { | 202 | { |
203 | mViewDict.clear(); | 203 | mViewDict.clear(); |
204 | mActiveView = 0; | 204 | mActiveView = 0; |
205 | } | 205 | } |
206 | 206 | ||
207 | void ViewManager::setActiveView( const QString &name ) | 207 | void ViewManager::setActiveView( const QString &name ) |
208 | { | 208 | { |
209 | KAddressBookView *view = 0; | 209 | KAddressBookView *view = 0; |
210 | 210 | ||
211 | // Check that this isn't the same as the current active view | 211 | // Check that this isn't the same as the current active view |
212 | if ( mActiveView && ( mActiveView->caption() == name ) ) | 212 | if ( mActiveView && ( mActiveView->caption() == name ) ) |
213 | return; | 213 | return; |
214 | 214 | ||
215 | // At this point we know the view that should be active is not | 215 | // At this point we know the view that should be active is not |
216 | // currently active. We will try to find the new on in the list. If | 216 | // currently active. We will try to find the new on in the list. If |
217 | // we can't find it, it means it hasn't been instantiated, so we will | 217 | // we can't find it, it means it hasn't been instantiated, so we will |
218 | // create it on demand. | 218 | // create it on demand. |
219 | 219 | ||
220 | view = mViewDict.find( name ); | 220 | view = mViewDict.find( name ); |
221 | 221 | ||
222 | // Check if we found the view. If we didn't, then we need to create it | 222 | // Check if we found the view. If we didn't, then we need to create it |
223 | if ( view == 0 ) { | 223 | if ( view == 0 ) { |
224 | KConfig *config = mCore->config(); | 224 | KConfig *config = mCore->config(); |
225 | 225 | ||
226 | KConfigGroupSaver saver( config, name ); | 226 | KConfigGroupSaver saver( config, name ); |
227 | 227 | ||
228 | QString type = config->readEntry( "Type", "Table" ); | 228 | QString type = config->readEntry( "Type", "Table" ); |
229 | 229 | ||
230 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; | 230 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; |
231 | 231 | ||
232 | ViewFactory *factory = mViewFactoryDict.find( type ); | 232 | ViewFactory *factory = mViewFactoryDict.find( type ); |
233 | if ( factory ) | 233 | if ( factory ) |
234 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); | 234 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); |
235 | 235 | ||
236 | if ( view ) { | 236 | if ( view ) { |
237 | view->setCaption( name ); | 237 | view->setCaption( name ); |
238 | mViewDict.insert( name, view ); | 238 | mViewDict.insert( name, view ); |
239 | //US my version needs an int as second parameter to addWidget | 239 | //US my version needs an int as second parameter to addWidget |
240 | mViewWidgetStack->addWidget( view, -1 ); | 240 | mViewWidgetStack->addWidget( view, -1 ); |
241 | view->readConfig( config ); | 241 | view->readConfig( config ); |
242 | 242 | ||
243 | // The manager just relays the signals | 243 | // The manager just relays the signals |
244 | connect( view, SIGNAL( selected( const QString& ) ), | 244 | connect( view, SIGNAL( selected( const QString& ) ), |
245 | SIGNAL( selected( const QString & ) ) ); | 245 | SIGNAL( selected( const QString & ) ) ); |
246 | connect( view, SIGNAL( executed( const QString& ) ), | 246 | connect( view, SIGNAL( executed( const QString& ) ), |
247 | SIGNAL( executed( const QString& ) ) ); | 247 | SIGNAL( executed( const QString& ) ) ); |
248 | 248 | ||
249 | connect( view, SIGNAL( deleteRequest( ) ), | 249 | connect( view, SIGNAL( deleteRequest( ) ), |
250 | SIGNAL( deleteRequest( ) ) ); | 250 | SIGNAL( deleteRequest( ) ) ); |
251 | 251 | ||
252 | connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); | 252 | connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); |
253 | connect( view, SIGNAL( dropped( QDropEvent* ) ), | 253 | connect( view, SIGNAL( dropped( QDropEvent* ) ), |
254 | SLOT( dropped( QDropEvent* ) ) ); | 254 | SLOT( dropped( QDropEvent* ) ) ); |
255 | connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); | 255 | connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); |
256 | } | 256 | } |
257 | } | 257 | } |
258 | 258 | ||
259 | // If we found or created the view, raise it and refresh it | 259 | // If we found or created the view, raise it and refresh it |
260 | if ( view ) { | 260 | if ( view ) { |
261 | mActiveView = view; | 261 | mActiveView = view; |
262 | mViewWidgetStack->raiseWidget( view ); | 262 | mViewWidgetStack->raiseWidget( view ); |
263 | // Set the proper filter in the view. By setting the combo | 263 | // Set the proper filter in the view. By setting the combo |
264 | // box, the activated slot will be called, which will push | 264 | // box, the activated slot will be called, which will push |
265 | // the filter to the view and refresh it. | 265 | // the filter to the view and refresh it. |
266 | 266 | ||
267 | if ( view->defaultFilterType() == KAddressBookView::None ) { | 267 | if ( view->defaultFilterType() == KAddressBookView::None ) { |
268 | 268 | ||
269 | mActionSelectFilter->setCurrentItem( 0 ); | 269 | mActionSelectFilter->setCurrentItem( 0 ); |
270 | setActiveFilter( 0 ); | 270 | setActiveFilter( 0 ); |
271 | } else if ( view->defaultFilterType() == KAddressBookView::Active ) { | 271 | } else if ( view->defaultFilterType() == KAddressBookView::Active ) { |
272 | setActiveFilter( mActionSelectFilter->currentItem() ); | 272 | setActiveFilter( mActionSelectFilter->currentItem() ); |
273 | } else { | 273 | } else { |
274 | uint pos = filterPosition( view->defaultFilterName() ); | 274 | uint pos = filterPosition( view->defaultFilterName() ); |
275 | mActionSelectFilter->setCurrentItem( pos ); | 275 | mActionSelectFilter->setCurrentItem( pos ); |
276 | setActiveFilter( pos ); | 276 | setActiveFilter( pos ); |
277 | } | 277 | } |
278 | //US qDebug("ViewManager::setActiveView 6" ); | 278 | //US qDebug("ViewManager::setActiveView 6" ); |
279 | 279 | ||
280 | // Update the inc search widget to show the fields in the new active | 280 | // Update the inc search widget to show the fields in the new active |
281 | // view. | 281 | // view. |
282 | mCore->setSearchFields( mActiveView->fields() ); | 282 | mCore->setSearchFields( mActiveView->fields() ); |
283 | 283 | ||
284 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() | 284 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
285 | //US mActiveView->refresh(); | 285 | //US mActiveView->refresh(); |
286 | 286 | mCore->saveSettings(); | |
287 | } | 287 | } |
288 | else | 288 | else |
289 | { | 289 | { |
290 | qDebug("ViewManager::setActiveView: unable to find view" ); | 290 | qDebug("ViewManager::setActiveView: unable to find view" ); |
291 | kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; | ||
292 | } | 291 | } |
293 | } | 292 | } |
294 | 293 | ||
295 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 294 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
296 | void ViewManager::refreshView() | 295 | void ViewManager::refreshView() |
297 | { | 296 | { |
298 | refreshView( QString::null ); | 297 | refreshView( QString::null ); |
299 | } | 298 | } |
300 | 299 | ||
301 | void ViewManager::refreshView( const QString &uid ) | 300 | void ViewManager::refreshView( const QString &uid ) |
302 | { | 301 | { |
303 | if ( mActiveView ) | 302 | if ( mActiveView ) |
304 | mActiveView->refresh( uid ); | 303 | mActiveView->refresh( uid ); |
305 | } | 304 | } |
306 | 305 | ||
307 | void ViewManager::setFocusAV() | 306 | void ViewManager::setFocusAV() |
308 | { | 307 | { |
309 | if ( mActiveView ) | 308 | if ( mActiveView ) |
310 | mActiveView->setFocusAV(); | 309 | mActiveView->setFocusAV(); |
311 | } | 310 | } |
312 | void ViewManager::editView() | 311 | void ViewManager::editView() |
313 | { | 312 | { |
314 | if ( !mActiveView ) | 313 | if ( !mActiveView ) |
315 | return; | 314 | return; |
316 | 315 | ||
317 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); | 316 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); |
318 | ViewConfigureWidget *wdg = 0; | 317 | ViewConfigureWidget *wdg = 0; |
319 | ViewConfigureDialog* dlg = 0; | 318 | ViewConfigureDialog* dlg = 0; |
320 | if ( factory ) { | 319 | if ( factory ) { |
321 | // Save the filters so the dialog has the latest set | 320 | // Save the filters so the dialog has the latest set |
322 | Filter::save( mCore->config(), "Filter", mFilterList ); | 321 | Filter::save( mCore->config(), "Filter", mFilterList ); |
323 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); | 322 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); |
324 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); | 323 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); |
325 | } else { | 324 | } else { |
326 | qDebug("ViewManager::editView()::cannot find viewfactory "); | 325 | qDebug("ViewManager::editView()::cannot find viewfactory "); |
327 | return; | 326 | return; |
328 | } | 327 | } |
329 | if ( wdg ) { | 328 | if ( wdg ) { |
330 | dlg->setWidget( wdg ); | 329 | dlg->setWidget( wdg ); |
331 | 330 | ||
332 | #ifndef DESKTOP_VERSION | 331 | #ifndef DESKTOP_VERSION |
333 | //dlg.setMaximumSize( 640, 480 ); | 332 | //dlg.setMaximumSize( 640, 480 ); |
334 | //dlg->setGeometry( 40,40, 400, 300); | 333 | //dlg->setGeometry( 40,40, 400, 300); |
335 | dlg->showMaximized(); | 334 | dlg->showMaximized(); |
336 | #endif | 335 | #endif |
337 | 336 | ||
338 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); | 337 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); |
339 | 338 | ||
340 | dlg->restoreSettings( mCore->config() ); | 339 | dlg->restoreSettings( mCore->config() ); |
341 | 340 | ||
342 | if ( dlg->exec() ) { | 341 | if ( dlg->exec() ) { |
343 | dlg->saveSettings( mCore->config() ); | 342 | dlg->saveSettings( mCore->config() ); |
344 | mActiveView->readConfig( mCore->config() ); | 343 | mActiveView->readConfig( mCore->config() ); |
345 | 344 | ||
346 | // Set the proper filter in the view. By setting the combo | 345 | // Set the proper filter in the view. By setting the combo |
347 | // box, the activated slot will be called, which will push | 346 | // box, the activated slot will be called, which will push |
348 | // the filter to the view and refresh it. | 347 | // the filter to the view and refresh it. |
349 | if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { | 348 | if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { |
350 | mActionSelectFilter->setCurrentItem( 0 ); | 349 | mActionSelectFilter->setCurrentItem( 0 ); |
351 | setActiveFilter( 0 ); | 350 | setActiveFilter( 0 ); |
352 | } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { | 351 | } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { |
353 | setActiveFilter( mActionSelectFilter->currentItem() ); | 352 | setActiveFilter( mActionSelectFilter->currentItem() ); |
354 | } else { | 353 | } else { |
355 | uint pos = filterPosition( mActiveView->defaultFilterName() ); | 354 | uint pos = filterPosition( mActiveView->defaultFilterName() ); |
356 | mActionSelectFilter->setCurrentItem( pos ); | 355 | mActionSelectFilter->setCurrentItem( pos ); |
357 | setActiveFilter( pos ); | 356 | setActiveFilter( pos ); |
358 | } | 357 | } |
359 | mCore->setSearchFields( mActiveView->fields() ); | 358 | mCore->setSearchFields( mActiveView->fields() ); |
360 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() | 359 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
361 | //US mActiveView->refresh(); | 360 | //US mActiveView->refresh(); |
362 | 361 | ||
363 | 362 | ||
364 | //US this is a bugfix, that we get notified if we change a views configuration | 363 | //US this is a bugfix, that we get notified if we change a views configuration |
365 | emit modified(); | 364 | emit modified(); |
366 | 365 | ||
367 | } | 366 | } |
368 | 367 | ||
369 | } | 368 | } |
370 | delete dlg; | 369 | delete dlg; |
371 | } | 370 | } |
372 | 371 | ||
373 | void ViewManager::deleteView() | 372 | void ViewManager::deleteView() |
374 | { | 373 | { |
375 | QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) | 374 | QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) |
376 | .arg( mActiveView->caption() ); | 375 | .arg( mActiveView->caption() ); |
377 | QString caption = i18n( "Confirm Delete" ); | 376 | QString caption = i18n( "Confirm Delete" ); |
378 | 377 | ||
379 | 378 | ||
380 | if (QMessageBox::information( this, caption, | 379 | if (QMessageBox::information( this, caption, |
381 | text, | 380 | text, |
382 | i18n("Yes!"), i18n("No"), 0, 0 ) == 0) | 381 | i18n("Yes!"), i18n("No"), 0, 0 ) == 0) |
383 | { | 382 | { |
384 | mViewNameList.remove( mActiveView->caption() ); | 383 | mViewNameList.remove( mActiveView->caption() ); |
385 | 384 | ||
386 | // remove the view from the config file | 385 | // remove the view from the config file |
387 | KConfig *config = mCore->config(); | 386 | KConfig *config = mCore->config(); |
388 | config->deleteGroup( mActiveView->caption() ); | 387 | config->deleteGroup( mActiveView->caption() ); |
389 | 388 | ||
390 | mViewDict.remove( mActiveView->caption() ); | 389 | mViewDict.remove( mActiveView->caption() ); |
391 | mActiveView = 0; | 390 | mActiveView = 0; |
392 | 391 | ||
393 | // we are in an invalid state now, but that should be fixed after | 392 | // we are in an invalid state now, but that should be fixed after |
394 | // we emit the signal | 393 | // we emit the signal |
395 | mActionSelectView->setItems( mViewNameList ); | 394 | mActionSelectView->setItems( mViewNameList ); |
396 | if ( mViewNameList.count() > 0 ) { | 395 | if ( mViewNameList.count() > 0 ) { |
397 | mActionSelectView->setCurrentItem( 0 ); | 396 | mActionSelectView->setCurrentItem( 0 ); |
398 | setActiveView( mViewNameList[ 0 ] ); | 397 | setActiveView( mViewNameList[ 0 ] ); |
399 | } | 398 | } |
400 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 399 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
401 | } | 400 | } |
402 | } | 401 | } |
403 | 402 | ||
404 | void ViewManager::addView() | 403 | void ViewManager::addView() |
405 | { | 404 | { |
406 | AddViewDialog dialog( &mViewFactoryDict, this ); | 405 | AddViewDialog dialog( &mViewFactoryDict, this ); |
407 | 406 | ||
408 | if ( dialog.exec() ) { | 407 | if ( dialog.exec() ) { |
409 | QString newName = dialog.viewName(); | 408 | QString newName = dialog.viewName(); |
410 | QString type = dialog.viewType(); | 409 | QString type = dialog.viewType(); |
411 | 410 | ||
412 | // Check for name conflicts | 411 | // Check for name conflicts |
413 | bool firstConflict = true; | 412 | bool firstConflict = true; |
414 | int numTries = 1; | 413 | int numTries = 1; |
415 | while ( mViewNameList.contains( newName ) > 0 ) { | 414 | while ( mViewNameList.contains( newName ) > 0 ) { |
416 | if ( !firstConflict ) { | 415 | if ( !firstConflict ) { |
417 | newName = newName.left( newName.length() - 4 ); | 416 | newName = newName.left( newName.length() - 4 ); |
418 | firstConflict = false; | 417 | firstConflict = false; |
419 | } | 418 | } |
420 | 419 | ||
421 | newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); | 420 | newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); |
422 | numTries++; | 421 | numTries++; |
423 | } | 422 | } |
424 | 423 | ||
425 | // Add the new one to the list | 424 | // Add the new one to the list |
426 | mViewNameList.append( newName ); | 425 | mViewNameList.append( newName ); |
427 | 426 | ||
428 | // write the view to the config file, | 427 | // write the view to the config file, |
429 | KConfig *config = mCore->config(); | 428 | KConfig *config = mCore->config(); |
430 | 429 | ||
431 | config->deleteGroup( newName ); | 430 | config->deleteGroup( newName ); |
432 | 431 | ||
433 | KConfigGroupSaver saver( config, newName ); | 432 | KConfigGroupSaver saver( config, newName ); |
434 | 433 | ||
435 | config->writeEntry( "Type", type ); | 434 | config->writeEntry( "Type", type ); |
436 | 435 | ||
437 | // try to set the active view | 436 | // try to set the active view |
438 | mActionSelectView->setItems( mViewNameList ); | 437 | mActionSelectView->setItems( mViewNameList ); |
439 | mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); | 438 | mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); |
440 | setActiveView( newName ); | 439 | setActiveView( newName ); |
441 | 440 | ||
442 | editView(); | 441 | editView(); |
443 | 442 | ||
444 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 443 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
445 | } | 444 | } |
446 | } | 445 | } |
447 | 446 | ||
448 | void ViewManager::createViewFactories() | 447 | void ViewManager::createViewFactories() |
449 | { | 448 | { |
450 | #ifndef KAB_EMBEDDED | 449 | #ifndef KAB_EMBEDDED |
451 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); | 450 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); |
452 | KTrader::OfferList::ConstIterator it; | 451 | KTrader::OfferList::ConstIterator it; |
453 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 452 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
454 | if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) | 453 | if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) |
455 | continue; | 454 | continue; |
456 | 455 | ||
457 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); | 456 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); |
458 | 457 | ||
459 | if ( !factory ) { | 458 | if ( !factory ) { |
460 | kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; | 459 | kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; |
461 | continue; | 460 | continue; |
462 | } | 461 | } |
463 | 462 | ||
464 | ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); | 463 | ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); |
465 | 464 | ||
466 | if ( !viewFactory ) { | 465 | if ( !viewFactory ) { |
467 | kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; | 466 | kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; |
468 | continue; | 467 | continue; |
469 | } | 468 | } |
470 | 469 | ||
471 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 470 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
472 | } | 471 | } |
473 | 472 | ||
474 | #else //KAB_EMBEDDED | 473 | #else //KAB_EMBEDDED |
475 | ViewFactory* viewFactory = new IconViewFactory(); | 474 | ViewFactory* viewFactory = new IconViewFactory(); |
476 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 475 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
477 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 476 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
478 | 477 | ||
479 | viewFactory = new TableViewFactory(); | 478 | viewFactory = new TableViewFactory(); |
480 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 479 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
481 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 480 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
482 | 481 | ||
483 | viewFactory = new CardViewFactory(); | 482 | viewFactory = new CardViewFactory(); |
484 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 483 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
485 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 484 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
486 | 485 | ||
487 | #endif //KAB_EMBEDDED | 486 | #endif //KAB_EMBEDDED |
488 | 487 | ||
489 | } | 488 | } |
490 | 489 | ||
491 | void ViewManager::dropped( QDropEvent *e ) | 490 | void ViewManager::dropped( QDropEvent *e ) |
492 | { | 491 | { |
493 | kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; | 492 | kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; |
494 | 493 | ||
495 | #ifndef KAB_EMBEDDED | 494 | #ifndef KAB_EMBEDDED |
496 | 495 | ||
497 | QString clipText, vcards; | 496 | QString clipText, vcards; |
498 | KURL::List urls; | 497 | KURL::List urls; |
499 | 498 | ||
500 | if ( KURLDrag::decode( e, urls) ) { | 499 | if ( KURLDrag::decode( e, urls) ) { |
501 | KURL::List::Iterator it = urls.begin(); | 500 | KURL::List::Iterator it = urls.begin(); |
502 | int c = urls.count(); | 501 | int c = urls.count(); |
503 | if ( c > 1 ) { | 502 | if ( c > 1 ) { |
504 | QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); | 503 | QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); |
505 | if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { | 504 | if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { |
506 | for ( ; it != urls.end(); ++it ) | 505 | for ( ; it != urls.end(); ++it ) |
507 | emit urlDropped( *it ); | 506 | emit urlDropped( *it ); |
508 | } | 507 | } |
509 | } else if ( c == 1 ) | 508 | } else if ( c == 1 ) |
510 | emit urlDropped( *it ); | 509 | emit urlDropped( *it ); |
511 | } else if ( KVCardDrag::decode( e, vcards ) ) { | 510 | } else if ( KVCardDrag::decode( e, vcards ) ) { |
512 | KABC::Addressee addr; | 511 | KABC::Addressee addr; |
513 | KABC::VCardConverter converter; | 512 | KABC::VCardConverter converter; |
514 | QStringList list = QStringList::split( "\r\n\r\n", vcards ); | 513 | QStringList list = QStringList::split( "\r\n\r\n", vcards ); |
515 | QStringList::Iterator it; | 514 | QStringList::Iterator it; |
516 | for ( it = list.begin(); it != list.end(); ++it ) { | 515 | for ( it = list.begin(); it != list.end(); ++it ) { |
517 | if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { | 516 | if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { |
518 | KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); | 517 | KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); |
519 | if ( a.isEmpty() ) { | 518 | if ( a.isEmpty() ) { |
520 | mCore->addressBook()->insertAddressee( addr ); | 519 | mCore->addressBook()->insertAddressee( addr ); |
521 | emit modified(); | 520 | emit modified(); |
522 | } | 521 | } |
523 | } | 522 | } |
524 | } | 523 | } |
525 | 524 | ||
526 | mActiveView->refresh(); | 525 | mActiveView->refresh(); |
527 | } | 526 | } |
528 | #else //KAB_EMBEDDED | 527 | #else //KAB_EMBEDDED |
529 | qDebug("ViewManager::dropped() has to be changed!!" ); | 528 | qDebug("ViewManager::dropped() has to be changed!!" ); |
530 | #endif //KAB_EMBEDDED | 529 | #endif //KAB_EMBEDDED |
531 | 530 | ||
532 | } | 531 | } |
533 | 532 | ||
534 | void ViewManager::startDrag() | 533 | void ViewManager::startDrag() |
535 | { | 534 | { |
536 | kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; | 535 | kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; |
537 | 536 | ||
538 | #ifndef KAB_EMBEDDED | 537 | #ifndef KAB_EMBEDDED |
539 | 538 | ||
540 | // Get the list of all the selected addressees | 539 | // Get the list of all the selected addressees |
541 | KABC::Addressee::List addrList; | 540 | KABC::Addressee::List addrList; |
542 | QStringList uidList = selectedUids(); | 541 | QStringList uidList = selectedUids(); |
543 | QStringList::Iterator iter; | 542 | QStringList::Iterator iter; |
544 | for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) | 543 | for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) |
545 | addrList.append( mCore->addressBook()->findByUid( *iter ) ); | 544 | addrList.append( mCore->addressBook()->findByUid( *iter ) ); |
546 | 545 | ||
547 | KMultipleDrag *drag = new KMultipleDrag( this ); | 546 | KMultipleDrag *drag = new KMultipleDrag( this ); |
548 | drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); | 547 | drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); |
549 | KABC::Addressee::List::Iterator it; | 548 | KABC::Addressee::List::Iterator it; |
550 | QStringList vcards; | 549 | QStringList vcards; |
551 | for ( it = addrList.begin(); it != addrList.end(); ++it ) { | 550 | for ( it = addrList.begin(); it != addrList.end(); ++it ) { |
552 | QString vcard = QString::null; | 551 | QString vcard = QString::null; |
553 | KABC::VCardConverter converter; | 552 | KABC::VCardConverter converter; |
554 | if ( converter.addresseeToVCard( *it, vcard ) ) | 553 | if ( converter.addresseeToVCard( *it, vcard ) ) |
555 | vcards.append( vcard ); | 554 | vcards.append( vcard ); |
556 | } | 555 | } |
557 | drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); | 556 | drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); |
558 | 557 | ||
559 | drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); | 558 | drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); |
560 | drag->dragCopy(); | 559 | drag->dragCopy(); |
561 | 560 | ||
562 | #else //KAB_EMBEDDED | 561 | #else //KAB_EMBEDDED |
563 | qDebug("ViewManager::startDrag() has to be changed!!" ); | 562 | qDebug("ViewManager::startDrag() has to be changed!!" ); |
564 | #endif //KAB_EMBEDDED | 563 | #endif //KAB_EMBEDDED |
565 | 564 | ||
566 | } | 565 | } |
567 | void ViewManager::doSearch( const QString& s,KABC::Field *field ) | 566 | void ViewManager::doSearch( const QString& s,KABC::Field *field ) |
568 | { | 567 | { |
569 | if ( mActiveView ) | 568 | if ( mActiveView ) |
570 | mActiveView->doSearch( s, field ); | 569 | mActiveView->doSearch( s, field ); |
571 | 570 | ||
572 | } | 571 | } |
573 | void ViewManager::setActiveFilter( int index ) | 572 | void ViewManager::setActiveFilter( int index ) |
574 | { | 573 | { |
575 | Filter currentFilter; | 574 | Filter currentFilter; |
576 | 575 | ||
577 | if ( ( index - 1 ) < 0 ) | 576 | if ( ( index - 1 ) < 0 ) |
578 | currentFilter = Filter(); | 577 | currentFilter = Filter(); |
579 | else | 578 | else |
580 | currentFilter = mFilterList[ index - 1 ]; | 579 | currentFilter = mFilterList[ index - 1 ]; |
581 | 580 | ||
582 | // Check if we have a view. Since the filter combo is created before | 581 | // Check if we have a view. Since the filter combo is created before |
583 | // the view, this slot could be called before there is a valid view. | 582 | // the view, this slot could be called before there is a valid view. |
584 | if ( mActiveView ) { | 583 | if ( mActiveView ) { |
585 | mActiveView->setFilter( currentFilter ); | 584 | mActiveView->setFilter( currentFilter ); |
586 | mActiveView->refresh(); | 585 | mActiveView->refresh(); |
587 | emit selected( QString::null ); | 586 | emit selected( QString::null ); |
588 | } | 587 | } |
589 | } | 588 | } |
590 | 589 | ||
591 | void ViewManager::configureFilters() | 590 | void ViewManager::configureFilters() |
592 | { | 591 | { |
593 | FilterDialog dlg( this ); | 592 | FilterDialog dlg( this ); |
594 | 593 | ||
595 | dlg.setFilters( mFilterList ); | 594 | dlg.setFilters( mFilterList ); |
596 | 595 | ||
597 | if ( dlg.exec() ) | 596 | if ( dlg.exec() ) |
598 | mFilterList = dlg.filters(); | 597 | mFilterList = dlg.filters(); |
599 | 598 | ||
600 | uint pos = mActionSelectFilter->currentItem(); | 599 | uint pos = mActionSelectFilter->currentItem(); |
601 | mActionSelectFilter->setItems( filterNames() ); | 600 | mActionSelectFilter->setItems( filterNames() ); |
602 | mActionSelectFilter->setCurrentItem( pos ); | 601 | mActionSelectFilter->setCurrentItem( pos ); |
603 | setActiveFilter( pos ); | 602 | setActiveFilter( pos ); |
604 | int cw = 150; | 603 | int cw = 150; |
605 | if (QApplication::desktop()->width() == 480 ) | 604 | if (QApplication::desktop()->width() == 480 ) |
606 | cw = 0; | 605 | cw = 0; |
607 | mActionSelectFilter->setComboWidth( cw ); | 606 | mActionSelectFilter->setComboWidth( cw ); |
608 | saveSettings(); | 607 | saveSettings(); |
609 | } | 608 | } |
610 | 609 | ||
611 | QStringList ViewManager::filterNames() const | 610 | QStringList ViewManager::filterNames() const |
612 | { | 611 | { |
613 | QStringList names( i18n( "No Filter" ) ); | 612 | QStringList names( i18n( "No Filter" ) ); |
614 | 613 | ||
615 | Filter::List::ConstIterator it; | 614 | Filter::List::ConstIterator it; |
616 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) | 615 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) |
617 | names.append( (*it).name() ); | 616 | names.append( (*it).name() ); |
618 | 617 | ||
619 | return names; | 618 | return names; |
620 | } | 619 | } |
621 | Filter ViewManager::getFilterByName( const QString &name ) const | 620 | Filter ViewManager::getFilterByName( const QString &name ) const |
622 | { | 621 | { |
623 | Filter::List::ConstIterator it; | 622 | Filter::List::ConstIterator it; |
624 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) | 623 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) |
625 | if ( name == (*it).name() ) | 624 | if ( name == (*it).name() ) |
626 | return (*it); | 625 | return (*it); |
627 | 626 | ||
628 | return Filter(); | 627 | return Filter(); |
629 | } | 628 | } |
630 | 629 | ||
631 | int ViewManager::filterPosition( const QString &name ) const | 630 | int ViewManager::filterPosition( const QString &name ) const |
632 | { | 631 | { |
633 | int pos = 0; | 632 | int pos = 0; |
634 | 633 | ||
635 | Filter::List::ConstIterator it; | 634 | Filter::List::ConstIterator it; |
636 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) | 635 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) |
637 | if ( name == (*it).name() ) | 636 | if ( name == (*it).name() ) |
638 | return pos + 1; | 637 | return pos + 1; |
639 | 638 | ||
640 | return 0; | 639 | return 0; |
641 | } | 640 | } |
642 | 641 | ||
643 | void ViewManager::initActions() | 642 | void ViewManager::initActions() |
644 | { | 643 | { |
645 | //US <ActionList name="view_loadedviews"/> | 644 | //US <ActionList name="view_loadedviews"/> |
646 | //US <Separator/> | 645 | //US <Separator/> |
647 | 646 | ||
648 | #ifdef KAB_EMBEDDED | 647 | #ifdef KAB_EMBEDDED |
649 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); | 648 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); |
650 | QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); | 649 | QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); |
651 | QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); | 650 | QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); |
652 | #endif //KAB_EMBEDDED | 651 | #endif //KAB_EMBEDDED |
653 | 652 | ||
654 | mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); | 653 | mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); |
655 | #if KDE_VERSION >= 309 | 654 | #if KDE_VERSION >= 309 |
656 | mActionSelectView->setMenuAccelsEnabled( false ); | 655 | mActionSelectView->setMenuAccelsEnabled( false ); |
657 | #endif | 656 | #endif |
658 | connect( mActionSelectView, SIGNAL( activated( const QString& ) ), | 657 | connect( mActionSelectView, SIGNAL( activated( const QString& ) ), |
659 | SLOT( setActiveView( const QString& ) ) ); | 658 | SLOT( setActiveView( const QString& ) ) ); |
660 | 659 | ||
661 | 660 | ||
662 | #ifdef KAB_EMBEDDED | 661 | #ifdef KAB_EMBEDDED |
663 | mActionSelectView->plug(viewmenu); | 662 | mActionSelectView->plug(viewmenu); |
664 | viewmenu->insertSeparator(); | 663 | viewmenu->insertSeparator(); |
665 | #endif //KAB_EMBEDDED | 664 | #endif //KAB_EMBEDDED |
666 | 665 | ||
667 | KAction *action; | 666 | KAction *action; |
668 | 667 | ||
669 | action = new KAction( i18n( "Modify View..." ), "configure", 0, this, | 668 | action = new KAction( i18n( "Modify View..." ), "configure", 0, this, |
670 | SLOT( editView() ), mCore->actionCollection(), "view_modify" ); | 669 | SLOT( editView() ), mCore->actionCollection(), "view_modify" ); |
671 | #ifndef KAB_EMBEDDED | 670 | #ifndef KAB_EMBEDDED |
672 | action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); | 671 | action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); |
673 | #else //KAB_EMBEDDED | 672 | #else //KAB_EMBEDDED |
674 | action->plug(viewmenu); | 673 | action->plug(viewmenu); |
675 | #endif //KAB_EMBEDDED | 674 | #endif //KAB_EMBEDDED |
676 | 675 | ||
677 | action = new KAction( i18n( "Add View..." ), "window_new", 0, this, | 676 | action = new KAction( i18n( "Add View..." ), "window_new", 0, this, |
678 | SLOT( addView() ), mCore->actionCollection(), "view_add" ); | 677 | SLOT( addView() ), mCore->actionCollection(), "view_add" ); |
679 | #ifndef KAB_EMBEDDED | 678 | #ifndef KAB_EMBEDDED |
680 | action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) ); | 679 | action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) ); |
681 | #else //KAB_EMBEDDED | 680 | #else //KAB_EMBEDDED |
682 | action->plug(viewmenu); | 681 | action->plug(viewmenu); |
683 | #endif //KAB_EMBEDDED | 682 | #endif //KAB_EMBEDDED |
684 | 683 | ||
685 | mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, | 684 | mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, |
686 | this, SLOT( deleteView() ), | 685 | this, SLOT( deleteView() ), |
687 | mCore->actionCollection(), "view_delete" ); | 686 | mCore->actionCollection(), "view_delete" ); |
688 | #ifndef KAB_EMBEDDED | 687 | #ifndef KAB_EMBEDDED |
689 | mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); | 688 | mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); |
690 | #else //KAB_EMBEDDED | 689 | #else //KAB_EMBEDDED |
691 | mActionDeleteView->plug(viewmenu); | 690 | mActionDeleteView->plug(viewmenu); |
692 | viewmenu->insertSeparator(); | 691 | viewmenu->insertSeparator(); |
693 | #endif //KAB_EMBEDDED | 692 | #endif //KAB_EMBEDDED |
694 | 693 | ||
695 | #ifndef KAB_EMBEDDED | 694 | #ifndef KAB_EMBEDDED |
696 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, | 695 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, |
697 | SLOT( refreshView(const QString &) ), mCore->actionCollection(), | 696 | SLOT( refreshView(const QString &) ), mCore->actionCollection(), |
698 | "view_refresh" ); | 697 | "view_refresh" ); |
699 | action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); | 698 | action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); |
700 | #else //KAB_EMBEDDED | 699 | #else //KAB_EMBEDDED |
701 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, | 700 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, |
702 | SLOT( refreshView()), mCore->actionCollection(), | 701 | SLOT( refreshView()), mCore->actionCollection(), |
703 | "view_refresh" ); | 702 | "view_refresh" ); |
704 | action->plug(viewmenu); | 703 | action->plug(viewmenu); |
705 | viewmenu->insertSeparator(); | 704 | viewmenu->insertSeparator(); |
706 | #endif //KAB_EMBEDDED | 705 | #endif //KAB_EMBEDDED |
707 | 706 | ||
708 | action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, | 707 | action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, |
709 | SLOT( configureFilters() ), mCore->actionCollection(), | 708 | SLOT( configureFilters() ), mCore->actionCollection(), |
710 | "options_edit_filters" ); | 709 | "options_edit_filters" ); |
711 | 710 | ||
712 | mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); | 711 | mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); |
713 | #if KDE_VERSION >= 309 | 712 | #if KDE_VERSION >= 309 |
714 | mActionSelectFilter->setMenuAccelsEnabled( false ); | 713 | mActionSelectFilter->setMenuAccelsEnabled( false ); |
715 | #endif | 714 | #endif |
716 | connect( mActionSelectFilter, SIGNAL( activated( int ) ), | 715 | connect( mActionSelectFilter, SIGNAL( activated( int ) ), |
717 | SLOT( setActiveFilter( int ) ) ); | 716 | SLOT( setActiveFilter( int ) ) ); |
718 | 717 | ||
719 | #ifdef KAB_EMBEDDED | 718 | #ifdef KAB_EMBEDDED |
720 | action->plug(settingsmenu); | 719 | action->plug(settingsmenu); |
721 | mActionSelectFilter->plug(viewmenu); | 720 | mActionSelectFilter->plug(viewmenu); |
722 | #endif //KAB_EMBEDDED | 721 | #endif //KAB_EMBEDDED |
723 | 722 | ||
724 | } | 723 | } |
725 | 724 | ||
726 | void ViewManager::initGUI() | 725 | void ViewManager::initGUI() |
727 | { | 726 | { |
728 | QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); | 727 | QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); |
729 | mViewWidgetStack = new QWidgetStack( this ); | 728 | mViewWidgetStack = new QWidgetStack( this ); |
730 | layout->addWidget( mViewWidgetStack ); | 729 | layout->addWidget( mViewWidgetStack ); |
731 | } | 730 | } |
732 | 731 | ||
733 | #ifndef KAB_EMBEDDED | 732 | #ifndef KAB_EMBEDDED |
734 | #include "viewmanager.moc" | 733 | #include "viewmanager.moc" |
735 | #endif //KAB_EMBEDDED | 734 | #endif //KAB_EMBEDDED |