-rw-r--r-- | kabc/addressbook.cpp | 31 | ||||
-rw-r--r-- | kabc/addressee.cpp | 19 | ||||
-rw-r--r-- | kabc/addressee.h | 1 | ||||
-rw-r--r-- | kabc/stdaddressbook.cpp | 7 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 27 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 2 |
6 files changed, 59 insertions, 28 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index ec9f893..46a9cf4 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -1,849 +1,866 @@ | |||
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 | 41 | ||
42 | #include <kglobal.h> | 42 | #include <kglobal.h> |
43 | #include <klocale.h> | 43 | #include <klocale.h> |
44 | #include <kdebug.h> | 44 | #include <kdebug.h> |
45 | #include <libkcal/syncdefines.h> | 45 | #include <libkcal/syncdefines.h> |
46 | #include "addressbook.h" | 46 | #include "addressbook.h" |
47 | #include "resource.h" | 47 | #include "resource.h" |
48 | 48 | ||
49 | //US #include "addressbook.moc" | 49 | //US #include "addressbook.moc" |
50 | 50 | ||
51 | using namespace KABC; | 51 | using namespace KABC; |
52 | 52 | ||
53 | struct AddressBook::AddressBookData | 53 | struct AddressBook::AddressBookData |
54 | { | 54 | { |
55 | Addressee::List mAddressees; | 55 | Addressee::List mAddressees; |
56 | Addressee::List mRemovedAddressees; | 56 | Addressee::List mRemovedAddressees; |
57 | Field::List mAllFields; | 57 | Field::List mAllFields; |
58 | KConfig *mConfig; | 58 | KConfig *mConfig; |
59 | KRES::Manager<Resource> *mManager; | 59 | KRES::Manager<Resource> *mManager; |
60 | //US ErrorHandler *mErrorHandler; | 60 | //US ErrorHandler *mErrorHandler; |
61 | }; | 61 | }; |
62 | 62 | ||
63 | struct AddressBook::Iterator::IteratorData | 63 | struct AddressBook::Iterator::IteratorData |
64 | { | 64 | { |
65 | Addressee::List::Iterator mIt; | 65 | Addressee::List::Iterator mIt; |
66 | }; | 66 | }; |
67 | 67 | ||
68 | struct AddressBook::ConstIterator::ConstIteratorData | 68 | struct AddressBook::ConstIterator::ConstIteratorData |
69 | { | 69 | { |
70 | Addressee::List::ConstIterator mIt; | 70 | Addressee::List::ConstIterator mIt; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | AddressBook::Iterator::Iterator() | 73 | AddressBook::Iterator::Iterator() |
74 | { | 74 | { |
75 | d = new IteratorData; | 75 | d = new IteratorData; |
76 | } | 76 | } |
77 | 77 | ||
78 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) | 78 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) |
79 | { | 79 | { |
80 | d = new IteratorData; | 80 | d = new IteratorData; |
81 | d->mIt = i.d->mIt; | 81 | d->mIt = i.d->mIt; |
82 | } | 82 | } |
83 | 83 | ||
84 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) | 84 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) |
85 | { | 85 | { |
86 | if( this == &i ) return *this; // guard against self assignment | 86 | if( this == &i ) return *this; // guard against self assignment |
87 | delete d; // delete the old data the Iterator was completely constructed before | 87 | delete d; // delete the old data the Iterator was completely constructed before |
88 | d = new IteratorData; | 88 | d = new IteratorData; |
89 | d->mIt = i.d->mIt; | 89 | d->mIt = i.d->mIt; |
90 | return *this; | 90 | return *this; |
91 | } | 91 | } |
92 | 92 | ||
93 | AddressBook::Iterator::~Iterator() | 93 | AddressBook::Iterator::~Iterator() |
94 | { | 94 | { |
95 | delete d; | 95 | delete d; |
96 | } | 96 | } |
97 | 97 | ||
98 | const Addressee &AddressBook::Iterator::operator*() const | 98 | const Addressee &AddressBook::Iterator::operator*() const |
99 | { | 99 | { |
100 | return *(d->mIt); | 100 | return *(d->mIt); |
101 | } | 101 | } |
102 | 102 | ||
103 | Addressee &AddressBook::Iterator::operator*() | 103 | Addressee &AddressBook::Iterator::operator*() |
104 | { | 104 | { |
105 | return *(d->mIt); | 105 | return *(d->mIt); |
106 | } | 106 | } |
107 | 107 | ||
108 | Addressee *AddressBook::Iterator::operator->() | 108 | Addressee *AddressBook::Iterator::operator->() |
109 | { | 109 | { |
110 | return &(*(d->mIt)); | 110 | return &(*(d->mIt)); |
111 | } | 111 | } |
112 | 112 | ||
113 | AddressBook::Iterator &AddressBook::Iterator::operator++() | 113 | AddressBook::Iterator &AddressBook::Iterator::operator++() |
114 | { | 114 | { |
115 | (d->mIt)++; | 115 | (d->mIt)++; |
116 | return *this; | 116 | return *this; |
117 | } | 117 | } |
118 | 118 | ||
119 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) | 119 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) |
120 | { | 120 | { |
121 | (d->mIt)++; | 121 | (d->mIt)++; |
122 | return *this; | 122 | return *this; |
123 | } | 123 | } |
124 | 124 | ||
125 | AddressBook::Iterator &AddressBook::Iterator::operator--() | 125 | AddressBook::Iterator &AddressBook::Iterator::operator--() |
126 | { | 126 | { |
127 | (d->mIt)--; | 127 | (d->mIt)--; |
128 | return *this; | 128 | return *this; |
129 | } | 129 | } |
130 | 130 | ||
131 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) | 131 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) |
132 | { | 132 | { |
133 | (d->mIt)--; | 133 | (d->mIt)--; |
134 | return *this; | 134 | return *this; |
135 | } | 135 | } |
136 | 136 | ||
137 | bool AddressBook::Iterator::operator==( const Iterator &it ) | 137 | bool AddressBook::Iterator::operator==( const Iterator &it ) |
138 | { | 138 | { |
139 | return ( d->mIt == it.d->mIt ); | 139 | return ( d->mIt == it.d->mIt ); |
140 | } | 140 | } |
141 | 141 | ||
142 | bool AddressBook::Iterator::operator!=( const Iterator &it ) | 142 | bool AddressBook::Iterator::operator!=( const Iterator &it ) |
143 | { | 143 | { |
144 | return ( d->mIt != it.d->mIt ); | 144 | return ( d->mIt != it.d->mIt ); |
145 | } | 145 | } |
146 | 146 | ||
147 | 147 | ||
148 | AddressBook::ConstIterator::ConstIterator() | 148 | AddressBook::ConstIterator::ConstIterator() |
149 | { | 149 | { |
150 | d = new ConstIteratorData; | 150 | d = new ConstIteratorData; |
151 | } | 151 | } |
152 | 152 | ||
153 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) | 153 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) |
154 | { | 154 | { |
155 | d = new ConstIteratorData; | 155 | d = new ConstIteratorData; |
156 | d->mIt = i.d->mIt; | 156 | d->mIt = i.d->mIt; |
157 | } | 157 | } |
158 | 158 | ||
159 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) | 159 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) |
160 | { | 160 | { |
161 | if( this == &i ) return *this; // guard for self assignment | 161 | if( this == &i ) return *this; // guard for self assignment |
162 | delete d; // delete the old data because the Iterator was really constructed before | 162 | delete d; // delete the old data because the Iterator was really constructed before |
163 | d = new ConstIteratorData; | 163 | d = new ConstIteratorData; |
164 | d->mIt = i.d->mIt; | 164 | d->mIt = i.d->mIt; |
165 | return *this; | 165 | return *this; |
166 | } | 166 | } |
167 | 167 | ||
168 | AddressBook::ConstIterator::~ConstIterator() | 168 | AddressBook::ConstIterator::~ConstIterator() |
169 | { | 169 | { |
170 | delete d; | 170 | delete d; |
171 | } | 171 | } |
172 | 172 | ||
173 | const Addressee &AddressBook::ConstIterator::operator*() const | 173 | const Addressee &AddressBook::ConstIterator::operator*() const |
174 | { | 174 | { |
175 | return *(d->mIt); | 175 | return *(d->mIt); |
176 | } | 176 | } |
177 | 177 | ||
178 | const Addressee* AddressBook::ConstIterator::operator->() const | 178 | const Addressee* AddressBook::ConstIterator::operator->() const |
179 | { | 179 | { |
180 | return &(*(d->mIt)); | 180 | return &(*(d->mIt)); |
181 | } | 181 | } |
182 | 182 | ||
183 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() | 183 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() |
184 | { | 184 | { |
185 | (d->mIt)++; | 185 | (d->mIt)++; |
186 | return *this; | 186 | return *this; |
187 | } | 187 | } |
188 | 188 | ||
189 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) | 189 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) |
190 | { | 190 | { |
191 | (d->mIt)++; | 191 | (d->mIt)++; |
192 | return *this; | 192 | return *this; |
193 | } | 193 | } |
194 | 194 | ||
195 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() | 195 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() |
196 | { | 196 | { |
197 | (d->mIt)--; | 197 | (d->mIt)--; |
198 | return *this; | 198 | return *this; |
199 | } | 199 | } |
200 | 200 | ||
201 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | 201 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) |
202 | { | 202 | { |
203 | (d->mIt)--; | 203 | (d->mIt)--; |
204 | return *this; | 204 | return *this; |
205 | } | 205 | } |
206 | 206 | ||
207 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 207 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
208 | { | 208 | { |
209 | return ( d->mIt == it.d->mIt ); | 209 | return ( d->mIt == it.d->mIt ); |
210 | } | 210 | } |
211 | 211 | ||
212 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 212 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
213 | { | 213 | { |
214 | return ( d->mIt != it.d->mIt ); | 214 | return ( d->mIt != it.d->mIt ); |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | AddressBook::AddressBook() | 218 | AddressBook::AddressBook() |
219 | { | 219 | { |
220 | init(0, "contact"); | 220 | init(0, "contact"); |
221 | } | 221 | } |
222 | 222 | ||
223 | AddressBook::AddressBook( const QString &config ) | 223 | AddressBook::AddressBook( const QString &config ) |
224 | { | 224 | { |
225 | init(config, "contact"); | 225 | init(config, "contact"); |
226 | } | 226 | } |
227 | 227 | ||
228 | AddressBook::AddressBook( const QString &config, const QString &family ) | 228 | AddressBook::AddressBook( const QString &config, const QString &family ) |
229 | { | 229 | { |
230 | init(config, family); | 230 | init(config, family); |
231 | 231 | ||
232 | } | 232 | } |
233 | 233 | ||
234 | // the default family is "contact" | 234 | // the default family is "contact" |
235 | void AddressBook::init(const QString &config, const QString &family ) | 235 | void AddressBook::init(const QString &config, const QString &family ) |
236 | { | 236 | { |
237 | blockLSEchange = false; | 237 | blockLSEchange = false; |
238 | d = new AddressBookData; | 238 | d = new AddressBookData; |
239 | QString fami = family; | 239 | QString fami = family; |
240 | qDebug("new ab "); | 240 | qDebug("new ab "); |
241 | if (config != 0) { | 241 | if (config != 0) { |
242 | qDebug("config != 0 "); | 242 | qDebug("config != 0 "); |
243 | if ( family == "syncContact" ) { | 243 | if ( family == "syncContact" ) { |
244 | qDebug("creating sync config "); | 244 | qDebug("creating sync config "); |
245 | fami = "contact"; | 245 | fami = "contact"; |
246 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); | 246 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); |
247 | con->setGroup( "General" ); | 247 | con->setGroup( "General" ); |
248 | con->writeEntry( "ResourceKeys", QString("sync") ); | 248 | con->writeEntry( "ResourceKeys", QString("sync") ); |
249 | con->writeEntry( "Standard", QString("sync") ); | 249 | con->writeEntry( "Standard", QString("sync") ); |
250 | con->setGroup( "Resource_sync" ); | 250 | con->setGroup( "Resource_sync" ); |
251 | con->writeEntry( "FileFormat", QString("vcard") ); | 251 | con->writeEntry( "FileFormat", QString("vcard") ); |
252 | con->writeEntry( "FileName", config ); | 252 | con->writeEntry( "FileName", config ); |
253 | con->writeEntry( "ResourceIdentifier", QString("sync") ); | 253 | con->writeEntry( "ResourceIdentifier", QString("sync") ); |
254 | con->writeEntry( "ResourceName", QString("sync_res") ); | 254 | con->writeEntry( "ResourceName", QString("sync_res") ); |
255 | con->writeEntry( "ResourceType", QString("file") ); | 255 | con->writeEntry( "ResourceType", QString("file") ); |
256 | //con->sync(); | 256 | //con->sync(); |
257 | d->mConfig = con; | 257 | d->mConfig = con; |
258 | } | 258 | } |
259 | else | 259 | else |
260 | d->mConfig = new KConfig( locateLocal("config", config) ); | 260 | d->mConfig = new KConfig( locateLocal("config", config) ); |
261 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 261 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
262 | } | 262 | } |
263 | else { | 263 | else { |
264 | d->mConfig = 0; | 264 | d->mConfig = 0; |
265 | // qDebug("AddressBook::init 1 config=0"); | 265 | // qDebug("AddressBook::init 1 config=0"); |
266 | } | 266 | } |
267 | 267 | ||
268 | //US d->mErrorHandler = 0; | 268 | //US d->mErrorHandler = 0; |
269 | d->mManager = new KRES::Manager<Resource>( fami, false ); | 269 | d->mManager = new KRES::Manager<Resource>( fami, false ); |
270 | d->mManager->readConfig( d->mConfig ); | 270 | d->mManager->readConfig( d->mConfig ); |
271 | if ( family == "syncContact" ) { | 271 | if ( family == "syncContact" ) { |
272 | KRES::Manager<Resource> *manager = d->mManager; | 272 | KRES::Manager<Resource> *manager = d->mManager; |
273 | KRES::Manager<Resource>::ActiveIterator it; | 273 | KRES::Manager<Resource>::ActiveIterator it; |
274 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 274 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
275 | (*it)->setAddressBook( this ); | 275 | (*it)->setAddressBook( this ); |
276 | if ( !(*it)->open() ) | 276 | if ( !(*it)->open() ) |
277 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 277 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
278 | } | 278 | } |
279 | Resource *res = standardResource(); | 279 | Resource *res = standardResource(); |
280 | if ( !res ) { | 280 | if ( !res ) { |
281 | qDebug("ERROR: no standard resource"); | 281 | qDebug("ERROR: no standard resource"); |
282 | res = manager->createResource( "file" ); | 282 | res = manager->createResource( "file" ); |
283 | if ( res ) | 283 | if ( res ) |
284 | { | 284 | { |
285 | addResource( res ); | 285 | addResource( res ); |
286 | } | 286 | } |
287 | else | 287 | else |
288 | qDebug(" No resource available!!!"); | 288 | qDebug(" No resource available!!!"); |
289 | } | 289 | } |
290 | setStandardResource( res ); | 290 | setStandardResource( res ); |
291 | manager->writeConfig(); | 291 | manager->writeConfig(); |
292 | } | 292 | } |
293 | addCustomField( i18n( "Department" ), KABC::Field::Organization, | 293 | addCustomField( i18n( "Department" ), KABC::Field::Organization, |
294 | "X-Department", "KADDRESSBOOK" ); | 294 | "X-Department", "KADDRESSBOOK" ); |
295 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 295 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
296 | "X-Profession", "KADDRESSBOOK" ); | 296 | "X-Profession", "KADDRESSBOOK" ); |
297 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 297 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
298 | "X-AssistantsName", "KADDRESSBOOK" ); | 298 | "X-AssistantsName", "KADDRESSBOOK" ); |
299 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 299 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
300 | "X-ManagersName", "KADDRESSBOOK" ); | 300 | "X-ManagersName", "KADDRESSBOOK" ); |
301 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 301 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
302 | "X-SpousesName", "KADDRESSBOOK" ); | 302 | "X-SpousesName", "KADDRESSBOOK" ); |
303 | addCustomField( i18n( "Office" ), KABC::Field::Personal, | 303 | addCustomField( i18n( "Office" ), KABC::Field::Personal, |
304 | "X-Office", "KADDRESSBOOK" ); | 304 | "X-Office", "KADDRESSBOOK" ); |
305 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 305 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
306 | "X-IMAddress", "KADDRESSBOOK" ); | 306 | "X-IMAddress", "KADDRESSBOOK" ); |
307 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 307 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
308 | "X-Anniversary", "KADDRESSBOOK" ); | 308 | "X-Anniversary", "KADDRESSBOOK" ); |
309 | 309 | ||
310 | //US added this field to become compatible with Opie/qtopia addressbook | 310 | //US added this field to become compatible with Opie/qtopia addressbook |
311 | // values can be "female" or "male" or "". An empty field represents undefined. | 311 | // values can be "female" or "male" or "". An empty field represents undefined. |
312 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 312 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
313 | "X-Gender", "KADDRESSBOOK" ); | 313 | "X-Gender", "KADDRESSBOOK" ); |
314 | addCustomField( i18n( "Children" ), KABC::Field::Personal, | 314 | addCustomField( i18n( "Children" ), KABC::Field::Personal, |
315 | "X-Children", "KADDRESSBOOK" ); | 315 | "X-Children", "KADDRESSBOOK" ); |
316 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 316 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
317 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 317 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
318 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, | 318 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, |
319 | "X-ExternalID", "KADDRESSBOOK" ); | 319 | "X-ExternalID", "KADDRESSBOOK" ); |
320 | } | 320 | } |
321 | 321 | ||
322 | AddressBook::~AddressBook() | 322 | AddressBook::~AddressBook() |
323 | { | 323 | { |
324 | delete d->mConfig; d->mConfig = 0; | 324 | delete d->mConfig; d->mConfig = 0; |
325 | delete d->mManager; d->mManager = 0; | 325 | delete d->mManager; d->mManager = 0; |
326 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 326 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
327 | delete d; d = 0; | 327 | delete d; d = 0; |
328 | } | 328 | } |
329 | 329 | ||
330 | bool AddressBook::load() | 330 | bool AddressBook::load() |
331 | { | 331 | { |
332 | 332 | ||
333 | 333 | ||
334 | clear(); | 334 | clear(); |
335 | 335 | ||
336 | KRES::Manager<Resource>::ActiveIterator it; | 336 | KRES::Manager<Resource>::ActiveIterator it; |
337 | bool ok = true; | 337 | bool ok = true; |
338 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 338 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
339 | if ( !(*it)->load() ) { | 339 | if ( !(*it)->load() ) { |
340 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 340 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
341 | ok = false; | 341 | ok = false; |
342 | } | 342 | } |
343 | 343 | ||
344 | // mark all addressees as unchanged | 344 | // mark all addressees as unchanged |
345 | Addressee::List::Iterator addrIt; | 345 | Addressee::List::Iterator addrIt; |
346 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) | 346 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { |
347 | (*addrIt).setChanged( false ); | 347 | (*addrIt).setChanged( false ); |
348 | 348 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); | |
349 | if ( !id.isEmpty() ) { | ||
350 | //qDebug("setId aa %s ", id.latin1()); | ||
351 | (*addrIt).setIDStr(id ); | ||
352 | } | ||
353 | } | ||
349 | blockLSEchange = true; | 354 | blockLSEchange = true; |
350 | return ok; | 355 | return ok; |
351 | } | 356 | } |
352 | 357 | ||
353 | bool AddressBook::save( Ticket *ticket ) | 358 | bool AddressBook::save( Ticket *ticket ) |
354 | { | 359 | { |
355 | kdDebug(5700) << "AddressBook::save()"<< endl; | 360 | kdDebug(5700) << "AddressBook::save()"<< endl; |
356 | 361 | ||
357 | if ( ticket->resource() ) { | 362 | if ( ticket->resource() ) { |
358 | deleteRemovedAddressees(); | 363 | deleteRemovedAddressees(); |
359 | return ticket->resource()->save( ticket ); | 364 | return ticket->resource()->save( ticket ); |
360 | } | 365 | } |
361 | 366 | ||
362 | return false; | 367 | return false; |
363 | } | 368 | } |
364 | bool AddressBook::saveAB() | 369 | bool AddressBook::saveAB() |
365 | { | 370 | { |
366 | bool ok = true; | 371 | bool ok = true; |
367 | 372 | ||
368 | deleteRemovedAddressees(); | 373 | deleteRemovedAddressees(); |
369 | 374 | Iterator ait; | |
375 | for ( ait = begin(); ait != end(); ++ait ) { | ||
376 | if ( !(*ait).IDStr().isEmpty() ) { | ||
377 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | ||
378 | } | ||
379 | } | ||
370 | KRES::Manager<Resource>::ActiveIterator it; | 380 | KRES::Manager<Resource>::ActiveIterator it; |
371 | KRES::Manager<Resource> *manager = d->mManager; | 381 | KRES::Manager<Resource> *manager = d->mManager; |
372 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 382 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
373 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 383 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
374 | Ticket *ticket = requestSaveTicket( *it ); | 384 | Ticket *ticket = requestSaveTicket( *it ); |
375 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 385 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
376 | if ( !ticket ) { | 386 | if ( !ticket ) { |
377 | error( i18n( "Unable to save to resource '%1'. It is locked." ) | 387 | error( i18n( "Unable to save to resource '%1'. It is locked." ) |
378 | .arg( (*it)->resourceName() ) ); | 388 | .arg( (*it)->resourceName() ) ); |
379 | return false; | 389 | return false; |
380 | } | 390 | } |
381 | 391 | ||
382 | //if ( !save( ticket ) ) | 392 | //if ( !save( ticket ) ) |
383 | if ( ticket->resource() ) { | 393 | if ( ticket->resource() ) { |
384 | if ( ! ticket->resource()->save( ticket ) ) | 394 | if ( ! ticket->resource()->save( ticket ) ) |
385 | ok = false; | 395 | ok = false; |
386 | } else | 396 | } else |
387 | ok = false; | 397 | ok = false; |
388 | 398 | ||
389 | } | 399 | } |
390 | } | 400 | } |
391 | return ok; | 401 | return ok; |
392 | } | 402 | } |
393 | 403 | ||
394 | AddressBook::Iterator AddressBook::begin() | 404 | AddressBook::Iterator AddressBook::begin() |
395 | { | 405 | { |
396 | Iterator it = Iterator(); | 406 | Iterator it = Iterator(); |
397 | it.d->mIt = d->mAddressees.begin(); | 407 | it.d->mIt = d->mAddressees.begin(); |
398 | return it; | 408 | return it; |
399 | } | 409 | } |
400 | 410 | ||
401 | AddressBook::ConstIterator AddressBook::begin() const | 411 | AddressBook::ConstIterator AddressBook::begin() const |
402 | { | 412 | { |
403 | ConstIterator it = ConstIterator(); | 413 | ConstIterator it = ConstIterator(); |
404 | it.d->mIt = d->mAddressees.begin(); | 414 | it.d->mIt = d->mAddressees.begin(); |
405 | return it; | 415 | return it; |
406 | } | 416 | } |
407 | 417 | ||
408 | AddressBook::Iterator AddressBook::end() | 418 | AddressBook::Iterator AddressBook::end() |
409 | { | 419 | { |
410 | Iterator it = Iterator(); | 420 | Iterator it = Iterator(); |
411 | it.d->mIt = d->mAddressees.end(); | 421 | it.d->mIt = d->mAddressees.end(); |
412 | return it; | 422 | return it; |
413 | } | 423 | } |
414 | 424 | ||
415 | AddressBook::ConstIterator AddressBook::end() const | 425 | AddressBook::ConstIterator AddressBook::end() const |
416 | { | 426 | { |
417 | ConstIterator it = ConstIterator(); | 427 | ConstIterator it = ConstIterator(); |
418 | it.d->mIt = d->mAddressees.end(); | 428 | it.d->mIt = d->mAddressees.end(); |
419 | return it; | 429 | return it; |
420 | } | 430 | } |
421 | 431 | ||
422 | void AddressBook::clear() | 432 | void AddressBook::clear() |
423 | { | 433 | { |
424 | d->mAddressees.clear(); | 434 | d->mAddressees.clear(); |
425 | } | 435 | } |
426 | 436 | ||
427 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 437 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
428 | { | 438 | { |
429 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 439 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
430 | 440 | ||
431 | if ( !resource ) | 441 | if ( !resource ) |
432 | { | 442 | { |
433 | qDebug("AddressBook::requestSaveTicket no resource" ); | 443 | qDebug("AddressBook::requestSaveTicket no resource" ); |
434 | resource = standardResource(); | 444 | resource = standardResource(); |
435 | } | 445 | } |
436 | 446 | ||
437 | KRES::Manager<Resource>::ActiveIterator it; | 447 | KRES::Manager<Resource>::ActiveIterator it; |
438 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 448 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
439 | if ( (*it) == resource ) { | 449 | if ( (*it) == resource ) { |
440 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 450 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
441 | return 0; | 451 | return 0; |
442 | else | 452 | else |
443 | return (*it)->requestSaveTicket(); | 453 | return (*it)->requestSaveTicket(); |
444 | } | 454 | } |
445 | } | 455 | } |
446 | 456 | ||
447 | return 0; | 457 | return 0; |
448 | } | 458 | } |
449 | 459 | ||
450 | void AddressBook::insertAddressee( const Addressee &a, bool setRev ) | 460 | void AddressBook::insertAddressee( const Addressee &a, bool setRev ) |
451 | { | 461 | { |
452 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { | 462 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { |
463 | //qDebug("block insert "); | ||
453 | return; | 464 | return; |
454 | } | 465 | } |
466 | //qDebug("inserting.... %s ",a.uid().latin1() ); | ||
455 | bool found = false; | 467 | bool found = false; |
456 | Addressee::List::Iterator it; | 468 | Addressee::List::Iterator it; |
457 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 469 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
458 | if ( a.uid() == (*it).uid() ) { | 470 | if ( a.uid() == (*it).uid() ) { |
459 | 471 | ||
460 | bool changed = false; | 472 | bool changed = false; |
461 | Addressee addr = a; | 473 | Addressee addr = a; |
462 | if ( addr != (*it) ) | 474 | if ( addr != (*it) ) |
463 | changed = true; | 475 | changed = true; |
464 | 476 | ||
465 | (*it) = a; | 477 | (*it) = a; |
466 | if ( (*it).resource() == 0 ) | 478 | if ( (*it).resource() == 0 ) |
467 | (*it).setResource( standardResource() ); | 479 | (*it).setResource( standardResource() ); |
468 | 480 | ||
469 | if ( changed ) { | 481 | if ( changed ) { |
470 | if ( setRev ) { | 482 | if ( setRev ) { |
471 | 483 | ||
472 | // get rid of micro seconds | 484 | // get rid of micro seconds |
473 | QDateTime dt = QDateTime::currentDateTime(); | 485 | QDateTime dt = QDateTime::currentDateTime(); |
474 | QTime t = dt.time(); | 486 | QTime t = dt.time(); |
475 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 487 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
476 | (*it).setRevision( dt ); | 488 | (*it).setRevision( dt ); |
477 | } | 489 | } |
478 | (*it).setChanged( true ); | 490 | (*it).setChanged( true ); |
479 | } | 491 | } |
480 | 492 | ||
481 | found = true; | 493 | found = true; |
482 | } else { | 494 | } else { |
483 | if ( (*it).uid() == QString("last-syncAddressee-") ) { | 495 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
484 | QString name = (*it).uid().mid( 19 ); | 496 | QString name = (*it).uid().mid( 19 ); |
485 | Addressee b = a; | 497 | Addressee b = a; |
486 | QString id = b.getID( name ); | 498 | QString id = b.getID( name ); |
487 | if ( ! id.isEmpty() ) { | 499 | if ( ! id.isEmpty() ) { |
488 | QString des = (*it).note(); | 500 | QString des = (*it).note(); |
489 | int startN; | 501 | int startN; |
490 | if( (startN = des.find( id ) ) >= 0 ) { | 502 | if( (startN = des.find( id ) ) >= 0 ) { |
491 | int endN = des.find( ",", startN+1 ); | 503 | int endN = des.find( ",", startN+1 ); |
492 | des = des.left( startN ) + des.mid( endN+1 ); | 504 | des = des.left( startN ) + des.mid( endN+1 ); |
493 | (*it).setNote( des ); | 505 | (*it).setNote( des ); |
494 | } | 506 | } |
495 | } | 507 | } |
496 | } | 508 | } |
497 | } | 509 | } |
498 | } | 510 | } |
499 | if ( found ) | 511 | if ( found ) |
500 | return; | 512 | return; |
501 | d->mAddressees.append( a ); | 513 | d->mAddressees.append( a ); |
502 | Addressee& addr = d->mAddressees.last(); | 514 | Addressee& addr = d->mAddressees.last(); |
503 | if ( addr.resource() == 0 ) | 515 | if ( addr.resource() == 0 ) |
504 | addr.setResource( standardResource() ); | 516 | addr.setResource( standardResource() ); |
505 | 517 | ||
506 | addr.setChanged( true ); | 518 | addr.setChanged( true ); |
507 | } | 519 | } |
508 | 520 | ||
509 | void AddressBook::removeAddressee( const Addressee &a ) | 521 | void AddressBook::removeAddressee( const Addressee &a ) |
510 | { | 522 | { |
511 | Iterator it; | 523 | Iterator it; |
512 | Iterator it2; | 524 | Iterator it2; |
513 | bool found = false; | 525 | bool found = false; |
514 | for ( it = begin(); it != end(); ++it ) { | 526 | for ( it = begin(); it != end(); ++it ) { |
515 | if ( a.uid() == (*it).uid() ) { | 527 | if ( a.uid() == (*it).uid() ) { |
516 | found = true; | 528 | found = true; |
517 | it2 = it; | 529 | it2 = it; |
518 | } else { | 530 | } else { |
519 | if ( (*it).uid() == QString("last-syncAddressee-") ) { | 531 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
520 | QString name = (*it).uid().mid( 19 ); | 532 | QString name = (*it).uid().mid( 19 ); |
521 | Addressee b = a; | 533 | Addressee b = a; |
522 | QString id = b.getID( name ); | 534 | QString id = b.getID( name ); |
523 | if ( ! id.isEmpty() ) { | 535 | if ( ! id.isEmpty() ) { |
524 | QString des = (*it).note(); | 536 | QString des = (*it).note(); |
525 | if( des.find( id ) < 0 ) { | 537 | if( des.find( id ) < 0 ) { |
526 | des += id + ","; | 538 | des += id + ","; |
527 | (*it).setNote( des ); | 539 | (*it).setNote( des ); |
528 | } | 540 | } |
529 | } | 541 | } |
530 | } | 542 | } |
531 | 543 | ||
532 | } | 544 | } |
533 | } | 545 | } |
534 | 546 | ||
535 | if ( found ) | 547 | if ( found ) |
536 | removeAddressee( it2 ); | 548 | removeAddressee( it2 ); |
537 | 549 | ||
538 | } | 550 | } |
539 | 551 | ||
540 | void AddressBook::removeDeletedAddressees() | 552 | void AddressBook::removeDeletedAddressees() |
541 | { | 553 | { |
542 | deleteRemovedAddressees(); | 554 | deleteRemovedAddressees(); |
543 | Iterator it = begin(); | 555 | Iterator it = begin(); |
544 | Iterator it2 ; | 556 | Iterator it2 ; |
545 | QDateTime dt ( QDate( 2004,1,1) ); | 557 | QDateTime dt ( QDate( 2004,1,1) ); |
546 | while ( it != end() ) { | 558 | while ( it != end() ) { |
547 | (*it).setRevision( dt ); | 559 | (*it).setRevision( dt ); |
548 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 560 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
561 | (*it).setIDStr(""); | ||
562 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE || (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | ||
549 | it2 = it; | 563 | it2 = it; |
564 | //qDebug("removing %s ",(*it).uid().latin1() ); | ||
550 | ++it; | 565 | ++it; |
551 | removeAddressee( it2 ); | 566 | removeAddressee( it2 ); |
552 | } else | 567 | } else { |
568 | //qDebug("skipping %s ",(*it).uid().latin1() ); | ||
553 | ++it; | 569 | ++it; |
570 | } | ||
554 | } | 571 | } |
555 | deleteRemovedAddressees(); | 572 | deleteRemovedAddressees(); |
556 | } | 573 | } |
557 | 574 | ||
558 | void AddressBook::removeAddressee( const Iterator &it ) | 575 | void AddressBook::removeAddressee( const Iterator &it ) |
559 | { | 576 | { |
560 | d->mRemovedAddressees.append( (*it) ); | 577 | d->mRemovedAddressees.append( (*it) ); |
561 | d->mAddressees.remove( it.d->mIt ); | 578 | d->mAddressees.remove( it.d->mIt ); |
562 | } | 579 | } |
563 | 580 | ||
564 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 581 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
565 | { | 582 | { |
566 | Iterator it; | 583 | Iterator it; |
567 | for ( it = begin(); it != end(); ++it ) { | 584 | for ( it = begin(); it != end(); ++it ) { |
568 | if ( a.uid() == (*it).uid() ) { | 585 | if ( a.uid() == (*it).uid() ) { |
569 | return it; | 586 | return it; |
570 | } | 587 | } |
571 | } | 588 | } |
572 | return end(); | 589 | return end(); |
573 | } | 590 | } |
574 | 591 | ||
575 | Addressee AddressBook::findByUid( const QString &uid ) | 592 | Addressee AddressBook::findByUid( const QString &uid ) |
576 | { | 593 | { |
577 | Iterator it; | 594 | Iterator it; |
578 | for ( it = begin(); it != end(); ++it ) { | 595 | for ( it = begin(); it != end(); ++it ) { |
579 | if ( uid == (*it).uid() ) { | 596 | if ( uid == (*it).uid() ) { |
580 | return *it; | 597 | return *it; |
581 | } | 598 | } |
582 | } | 599 | } |
583 | return Addressee(); | 600 | return Addressee(); |
584 | } | 601 | } |
585 | #if 0 | 602 | #if 0 |
586 | Addressee::List AddressBook::getExternLastSyncAddressees() | 603 | Addressee::List AddressBook::getExternLastSyncAddressees() |
587 | { | 604 | { |
588 | Addressee::List results; | 605 | Addressee::List results; |
589 | 606 | ||
590 | Iterator it; | 607 | Iterator it; |
591 | for ( it = begin(); it != end(); ++it ) { | 608 | for ( it = begin(); it != end(); ++it ) { |
592 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { | 609 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { |
593 | if ( (*it).familyName().left(4) == "!E: " ) | 610 | if ( (*it).familyName().left(4) == "!E: " ) |
594 | results.append( *it ); | 611 | results.append( *it ); |
595 | } | 612 | } |
596 | } | 613 | } |
597 | 614 | ||
598 | return results; | 615 | return results; |
599 | } | 616 | } |
600 | #endif | 617 | #endif |
601 | void AddressBook::resetTempSyncStat() | 618 | void AddressBook::resetTempSyncStat() |
602 | { | 619 | { |
603 | Iterator it; | 620 | Iterator it; |
604 | for ( it = begin(); it != end(); ++it ) { | 621 | for ( it = begin(); it != end(); ++it ) { |
605 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | 622 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); |
606 | } | 623 | } |
607 | 624 | ||
608 | } | 625 | } |
609 | 626 | ||
610 | QStringList AddressBook:: uidList() | 627 | QStringList AddressBook:: uidList() |
611 | { | 628 | { |
612 | QStringList results; | 629 | QStringList results; |
613 | Iterator it; | 630 | Iterator it; |
614 | for ( it = begin(); it != end(); ++it ) { | 631 | for ( it = begin(); it != end(); ++it ) { |
615 | results.append( (*it).uid() ); | 632 | results.append( (*it).uid() ); |
616 | } | 633 | } |
617 | return results; | 634 | return results; |
618 | } | 635 | } |
619 | 636 | ||
620 | 637 | ||
621 | Addressee::List AddressBook::allAddressees() | 638 | Addressee::List AddressBook::allAddressees() |
622 | { | 639 | { |
623 | return d->mAddressees; | 640 | return d->mAddressees; |
624 | 641 | ||
625 | } | 642 | } |
626 | 643 | ||
627 | Addressee::List AddressBook::findByName( const QString &name ) | 644 | Addressee::List AddressBook::findByName( const QString &name ) |
628 | { | 645 | { |
629 | Addressee::List results; | 646 | Addressee::List results; |
630 | 647 | ||
631 | Iterator it; | 648 | Iterator it; |
632 | for ( it = begin(); it != end(); ++it ) { | 649 | for ( it = begin(); it != end(); ++it ) { |
633 | if ( name == (*it).realName() ) { | 650 | if ( name == (*it).realName() ) { |
634 | results.append( *it ); | 651 | results.append( *it ); |
635 | } | 652 | } |
636 | } | 653 | } |
637 | 654 | ||
638 | return results; | 655 | return results; |
639 | } | 656 | } |
640 | 657 | ||
641 | Addressee::List AddressBook::findByEmail( const QString &email ) | 658 | Addressee::List AddressBook::findByEmail( const QString &email ) |
642 | { | 659 | { |
643 | Addressee::List results; | 660 | Addressee::List results; |
644 | QStringList mailList; | 661 | QStringList mailList; |
645 | 662 | ||
646 | Iterator it; | 663 | Iterator it; |
647 | for ( it = begin(); it != end(); ++it ) { | 664 | for ( it = begin(); it != end(); ++it ) { |
648 | mailList = (*it).emails(); | 665 | mailList = (*it).emails(); |
649 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { | 666 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { |
650 | if ( email == (*ite) ) { | 667 | if ( email == (*ite) ) { |
651 | results.append( *it ); | 668 | results.append( *it ); |
652 | } | 669 | } |
653 | } | 670 | } |
654 | } | 671 | } |
655 | 672 | ||
656 | return results; | 673 | return results; |
657 | } | 674 | } |
658 | 675 | ||
659 | Addressee::List AddressBook::findByCategory( const QString &category ) | 676 | Addressee::List AddressBook::findByCategory( const QString &category ) |
660 | { | 677 | { |
661 | Addressee::List results; | 678 | Addressee::List results; |
662 | 679 | ||
663 | Iterator it; | 680 | Iterator it; |
664 | for ( it = begin(); it != end(); ++it ) { | 681 | for ( it = begin(); it != end(); ++it ) { |
665 | if ( (*it).hasCategory( category) ) { | 682 | if ( (*it).hasCategory( category) ) { |
666 | results.append( *it ); | 683 | results.append( *it ); |
667 | } | 684 | } |
668 | } | 685 | } |
669 | 686 | ||
670 | return results; | 687 | return results; |
671 | } | 688 | } |
672 | 689 | ||
673 | void AddressBook::dump() const | 690 | void AddressBook::dump() const |
674 | { | 691 | { |
675 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; | 692 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; |
676 | 693 | ||
677 | ConstIterator it; | 694 | ConstIterator it; |
678 | for( it = begin(); it != end(); ++it ) { | 695 | for( it = begin(); it != end(); ++it ) { |
679 | (*it).dump(); | 696 | (*it).dump(); |
680 | } | 697 | } |
681 | 698 | ||
682 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; | 699 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; |
683 | } | 700 | } |
684 | 701 | ||
685 | QString AddressBook::identifier() | 702 | QString AddressBook::identifier() |
686 | { | 703 | { |
687 | QStringList identifier; | 704 | QStringList identifier; |
688 | 705 | ||
689 | 706 | ||
690 | KRES::Manager<Resource>::ActiveIterator it; | 707 | KRES::Manager<Resource>::ActiveIterator it; |
691 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 708 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
692 | if ( !(*it)->identifier().isEmpty() ) | 709 | if ( !(*it)->identifier().isEmpty() ) |
693 | identifier.append( (*it)->identifier() ); | 710 | identifier.append( (*it)->identifier() ); |
694 | } | 711 | } |
695 | 712 | ||
696 | return identifier.join( ":" ); | 713 | return identifier.join( ":" ); |
697 | } | 714 | } |
698 | 715 | ||
699 | Field::List AddressBook::fields( int category ) | 716 | Field::List AddressBook::fields( int category ) |
700 | { | 717 | { |
701 | if ( d->mAllFields.isEmpty() ) { | 718 | if ( d->mAllFields.isEmpty() ) { |
702 | d->mAllFields = Field::allFields(); | 719 | d->mAllFields = Field::allFields(); |
703 | } | 720 | } |
704 | 721 | ||
705 | if ( category == Field::All ) return d->mAllFields; | 722 | if ( category == Field::All ) return d->mAllFields; |
706 | 723 | ||
707 | Field::List result; | 724 | Field::List result; |
708 | Field::List::ConstIterator it; | 725 | Field::List::ConstIterator it; |
709 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { | 726 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { |
710 | if ( (*it)->category() & category ) result.append( *it ); | 727 | if ( (*it)->category() & category ) result.append( *it ); |
711 | } | 728 | } |
712 | 729 | ||
713 | return result; | 730 | return result; |
714 | } | 731 | } |
715 | 732 | ||
716 | bool AddressBook::addCustomField( const QString &label, int category, | 733 | bool AddressBook::addCustomField( const QString &label, int category, |
717 | const QString &key, const QString &app ) | 734 | const QString &key, const QString &app ) |
718 | { | 735 | { |
719 | if ( d->mAllFields.isEmpty() ) { | 736 | if ( d->mAllFields.isEmpty() ) { |
720 | d->mAllFields = Field::allFields(); | 737 | d->mAllFields = Field::allFields(); |
721 | } | 738 | } |
722 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; | 739 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; |
723 | QString a = app.isNull() ? KGlobal::getAppName() : app; | 740 | QString a = app.isNull() ? KGlobal::getAppName() : app; |
724 | 741 | ||
725 | QString k = key.isNull() ? label : key; | 742 | QString k = key.isNull() ? label : key; |
726 | 743 | ||
727 | Field *field = Field::createCustomField( label, category, k, a ); | 744 | Field *field = Field::createCustomField( label, category, k, a ); |
728 | 745 | ||
729 | if ( !field ) return false; | 746 | if ( !field ) return false; |
730 | 747 | ||
731 | d->mAllFields.append( field ); | 748 | d->mAllFields.append( field ); |
732 | 749 | ||
733 | return true; | 750 | return true; |
734 | } | 751 | } |
735 | 752 | ||
736 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) | 753 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) |
737 | { | 754 | { |
738 | if (!ab.d) return s; | 755 | if (!ab.d) return s; |
739 | 756 | ||
740 | return s << ab.d->mAddressees; | 757 | return s << ab.d->mAddressees; |
741 | } | 758 | } |
742 | 759 | ||
743 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) | 760 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) |
744 | { | 761 | { |
745 | if (!ab.d) return s; | 762 | if (!ab.d) return s; |
746 | 763 | ||
747 | s >> ab.d->mAddressees; | 764 | s >> ab.d->mAddressees; |
748 | 765 | ||
749 | return s; | 766 | return s; |
750 | } | 767 | } |
751 | 768 | ||
752 | bool AddressBook::addResource( Resource *resource ) | 769 | bool AddressBook::addResource( Resource *resource ) |
753 | { | 770 | { |
754 | if ( !resource->open() ) { | 771 | if ( !resource->open() ) { |
755 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; | 772 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; |
756 | return false; | 773 | return false; |
757 | } | 774 | } |
758 | 775 | ||
759 | resource->setAddressBook( this ); | 776 | resource->setAddressBook( this ); |
760 | 777 | ||
761 | d->mManager->add( resource ); | 778 | d->mManager->add( resource ); |
762 | return true; | 779 | return true; |
763 | } | 780 | } |
764 | 781 | ||
765 | bool AddressBook::removeResource( Resource *resource ) | 782 | bool AddressBook::removeResource( Resource *resource ) |
766 | { | 783 | { |
767 | resource->close(); | 784 | resource->close(); |
768 | 785 | ||
769 | if ( resource == standardResource() ) | 786 | if ( resource == standardResource() ) |
770 | d->mManager->setStandardResource( 0 ); | 787 | d->mManager->setStandardResource( 0 ); |
771 | 788 | ||
772 | resource->setAddressBook( 0 ); | 789 | resource->setAddressBook( 0 ); |
773 | 790 | ||
774 | d->mManager->remove( resource ); | 791 | d->mManager->remove( resource ); |
775 | return true; | 792 | return true; |
776 | } | 793 | } |
777 | 794 | ||
778 | QPtrList<Resource> AddressBook::resources() | 795 | QPtrList<Resource> AddressBook::resources() |
779 | { | 796 | { |
780 | QPtrList<Resource> list; | 797 | QPtrList<Resource> list; |
781 | 798 | ||
782 | // qDebug("AddressBook::resources() 1"); | 799 | // qDebug("AddressBook::resources() 1"); |
783 | 800 | ||
784 | KRES::Manager<Resource>::ActiveIterator it; | 801 | KRES::Manager<Resource>::ActiveIterator it; |
785 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 802 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
786 | list.append( *it ); | 803 | list.append( *it ); |
787 | 804 | ||
788 | return list; | 805 | return list; |
789 | } | 806 | } |
790 | 807 | ||
791 | /*US | 808 | /*US |
792 | void AddressBook::setErrorHandler( ErrorHandler *handler ) | 809 | void AddressBook::setErrorHandler( ErrorHandler *handler ) |
793 | { | 810 | { |
794 | delete d->mErrorHandler; | 811 | delete d->mErrorHandler; |
795 | d->mErrorHandler = handler; | 812 | d->mErrorHandler = handler; |
796 | } | 813 | } |
797 | */ | 814 | */ |
798 | 815 | ||
799 | void AddressBook::error( const QString& msg ) | 816 | void AddressBook::error( const QString& msg ) |
800 | { | 817 | { |
801 | /*US | 818 | /*US |
802 | if ( !d->mErrorHandler ) // create default error handler | 819 | if ( !d->mErrorHandler ) // create default error handler |
803 | d->mErrorHandler = new ConsoleErrorHandler; | 820 | d->mErrorHandler = new ConsoleErrorHandler; |
804 | 821 | ||
805 | if ( d->mErrorHandler ) | 822 | if ( d->mErrorHandler ) |
806 | d->mErrorHandler->error( msg ); | 823 | d->mErrorHandler->error( msg ); |
807 | else | 824 | else |
808 | kdError(5700) << "no error handler defined" << endl; | 825 | kdError(5700) << "no error handler defined" << endl; |
809 | */ | 826 | */ |
810 | kdDebug(5700) << "msg" << endl; | 827 | kdDebug(5700) << "msg" << endl; |
811 | qDebug(msg); | 828 | qDebug(msg); |
812 | } | 829 | } |
813 | 830 | ||
814 | void AddressBook::deleteRemovedAddressees() | 831 | void AddressBook::deleteRemovedAddressees() |
815 | { | 832 | { |
816 | Addressee::List::Iterator it; | 833 | Addressee::List::Iterator it; |
817 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { | 834 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { |
818 | Resource *resource = (*it).resource(); | 835 | Resource *resource = (*it).resource(); |
819 | if ( resource && !resource->readOnly() && resource->isOpen() ) | 836 | if ( resource && !resource->readOnly() && resource->isOpen() ) |
820 | resource->removeAddressee( *it ); | 837 | resource->removeAddressee( *it ); |
821 | } | 838 | } |
822 | 839 | ||
823 | d->mRemovedAddressees.clear(); | 840 | d->mRemovedAddressees.clear(); |
824 | } | 841 | } |
825 | 842 | ||
826 | void AddressBook::setStandardResource( Resource *resource ) | 843 | void AddressBook::setStandardResource( Resource *resource ) |
827 | { | 844 | { |
828 | // qDebug("AddressBook::setStandardResource 1"); | 845 | // qDebug("AddressBook::setStandardResource 1"); |
829 | d->mManager->setStandardResource( resource ); | 846 | d->mManager->setStandardResource( resource ); |
830 | } | 847 | } |
831 | 848 | ||
832 | Resource *AddressBook::standardResource() | 849 | Resource *AddressBook::standardResource() |
833 | { | 850 | { |
834 | return d->mManager->standardResource(); | 851 | return d->mManager->standardResource(); |
835 | } | 852 | } |
836 | 853 | ||
837 | KRES::Manager<Resource> *AddressBook::resourceManager() | 854 | KRES::Manager<Resource> *AddressBook::resourceManager() |
838 | { | 855 | { |
839 | return d->mManager; | 856 | return d->mManager; |
840 | } | 857 | } |
841 | 858 | ||
842 | void AddressBook::cleanUp() | 859 | void AddressBook::cleanUp() |
843 | { | 860 | { |
844 | KRES::Manager<Resource>::ActiveIterator it; | 861 | KRES::Manager<Resource>::ActiveIterator it; |
845 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 862 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
846 | if ( !(*it)->readOnly() && (*it)->isOpen() ) | 863 | if ( !(*it)->readOnly() && (*it)->isOpen() ) |
847 | (*it)->cleanUp(); | 864 | (*it)->cleanUp(); |
848 | } | 865 | } |
849 | } | 866 | } |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 0f5d605..d6b70c4 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,1778 +1,1785 @@ | |||
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 | 46 | ||
47 | struct Addressee::AddresseeData : public KShared | 47 | struct Addressee::AddresseeData : public KShared |
48 | { | 48 | { |
49 | QString uid; | 49 | QString uid; |
50 | QString name; | 50 | QString name; |
51 | QString formattedName; | 51 | QString formattedName; |
52 | QString familyName; | 52 | QString familyName; |
53 | QString givenName; | 53 | QString givenName; |
54 | QString additionalName; | 54 | QString additionalName; |
55 | QString prefix; | 55 | QString prefix; |
56 | QString suffix; | 56 | QString suffix; |
57 | QString nickName; | 57 | QString nickName; |
58 | QDateTime birthday; | 58 | QDateTime birthday; |
59 | QString mailer; | 59 | QString mailer; |
60 | TimeZone timeZone; | 60 | TimeZone timeZone; |
61 | Geo geo; | 61 | Geo geo; |
62 | QString title; | 62 | QString title; |
63 | QString role; | 63 | QString role; |
64 | QString organization; | 64 | QString organization; |
65 | QString note; | 65 | QString note; |
66 | QString productId; | 66 | QString productId; |
67 | QDateTime revision; | 67 | QDateTime revision; |
68 | QString sortString; | 68 | QString sortString; |
69 | KURL url; | 69 | KURL url; |
70 | Secrecy secrecy; | 70 | Secrecy secrecy; |
71 | Picture logo; | 71 | Picture logo; |
72 | Picture photo; | 72 | Picture photo; |
73 | Sound sound; | 73 | Sound sound; |
74 | Agent agent; | 74 | Agent agent; |
75 | QString mExternalId; | 75 | QString mExternalId; |
76 | PhoneNumber::List phoneNumbers; | 76 | PhoneNumber::List phoneNumbers; |
77 | Address::List addresses; | 77 | Address::List addresses; |
78 | Key::List keys; | 78 | Key::List keys; |
79 | QStringList emails; | 79 | QStringList emails; |
80 | QStringList categories; | 80 | QStringList categories; |
81 | QStringList custom; | 81 | QStringList custom; |
82 | 82 | int mTempSyncStat; | |
83 | Resource *resource; | 83 | Resource *resource; |
84 | 84 | ||
85 | bool empty :1; | 85 | bool empty :1; |
86 | bool changed :1; | 86 | bool changed :1; |
87 | }; | 87 | }; |
88 | 88 | ||
89 | Addressee::Addressee() | 89 | Addressee::Addressee() |
90 | { | 90 | { |
91 | mData = new AddresseeData; | 91 | mData = new AddresseeData; |
92 | mData->empty = true; | 92 | mData->empty = true; |
93 | mData->changed = false; | 93 | mData->changed = false; |
94 | mData->resource = 0; | 94 | mData->resource = 0; |
95 | mData->mExternalId = ":"; | 95 | mData->mExternalId = ":"; |
96 | mData->revision = QDateTime ( QDate( 2004,1,1)); | 96 | mData->revision = QDateTime ( QDate( 2004,1,1)); |
97 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 97 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
98 | } | 98 | } |
99 | 99 | ||
100 | Addressee::~Addressee() | 100 | Addressee::~Addressee() |
101 | { | 101 | { |
102 | } | 102 | } |
103 | 103 | ||
104 | Addressee::Addressee( const Addressee &a ) | 104 | Addressee::Addressee( const Addressee &a ) |
105 | { | 105 | { |
106 | mData = a.mData; | 106 | mData = a.mData; |
107 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | ||
108 | } | 107 | } |
109 | 108 | ||
110 | Addressee &Addressee::operator=( const Addressee &a ) | 109 | Addressee &Addressee::operator=( const Addressee &a ) |
111 | { | 110 | { |
112 | mData = a.mData; | 111 | mData = a.mData; |
113 | return (*this); | 112 | return (*this); |
114 | } | 113 | } |
115 | 114 | ||
116 | Addressee Addressee::copy() | 115 | Addressee Addressee::copy() |
117 | { | 116 | { |
118 | Addressee a; | 117 | Addressee a; |
119 | *(a.mData) = *mData; | 118 | *(a.mData) = *mData; |
120 | return a; | 119 | return a; |
121 | } | 120 | } |
122 | 121 | ||
123 | void Addressee::detach() | 122 | void Addressee::detach() |
124 | { | 123 | { |
125 | if ( mData.count() == 1 ) return; | 124 | if ( mData.count() == 1 ) return; |
126 | *this = copy(); | 125 | *this = copy(); |
127 | } | 126 | } |
128 | 127 | ||
129 | bool Addressee::operator==( const Addressee &a ) const | 128 | bool Addressee::operator==( const Addressee &a ) const |
130 | { | 129 | { |
131 | if ( uid() != a.uid() ) return false; | 130 | if ( uid() != a.uid() ) return false; |
132 | if ( mData->name != a.mData->name ) return false; | 131 | if ( mData->name != a.mData->name ) return false; |
133 | if ( mData->formattedName != a.mData->formattedName ) return false; | 132 | if ( mData->formattedName != a.mData->formattedName ) return false; |
134 | if ( mData->familyName != a.mData->familyName ) return false; | 133 | if ( mData->familyName != a.mData->familyName ) return false; |
135 | if ( mData->givenName != a.mData->givenName ) return false; | 134 | if ( mData->givenName != a.mData->givenName ) return false; |
136 | if ( mData->additionalName != a.mData->additionalName ) return false; | 135 | if ( mData->additionalName != a.mData->additionalName ) return false; |
137 | if ( mData->prefix != a.mData->prefix ) return false; | 136 | if ( mData->prefix != a.mData->prefix ) return false; |
138 | if ( mData->suffix != a.mData->suffix ) return false; | 137 | if ( mData->suffix != a.mData->suffix ) return false; |
139 | if ( mData->nickName != a.mData->nickName ) return false; | 138 | if ( mData->nickName != a.mData->nickName ) return false; |
140 | if ( mData->birthday != a.mData->birthday ) return false; | 139 | if ( mData->birthday != a.mData->birthday ) return false; |
141 | if ( mData->mailer != a.mData->mailer ) return false; | 140 | if ( mData->mailer != a.mData->mailer ) return false; |
142 | if ( mData->timeZone != a.mData->timeZone ) return false; | 141 | if ( mData->timeZone != a.mData->timeZone ) return false; |
143 | if ( mData->geo != a.mData->geo ) return false; | 142 | if ( mData->geo != a.mData->geo ) return false; |
144 | if ( mData->title != a.mData->title ) return false; | 143 | if ( mData->title != a.mData->title ) return false; |
145 | if ( mData->role != a.mData->role ) return false; | 144 | if ( mData->role != a.mData->role ) return false; |
146 | if ( mData->organization != a.mData->organization ) return false; | 145 | if ( mData->organization != a.mData->organization ) return false; |
147 | if ( mData->note != a.mData->note ) return false; | 146 | if ( mData->note != a.mData->note ) return false; |
148 | if ( mData->productId != a.mData->productId ) return false; | 147 | if ( mData->productId != a.mData->productId ) return false; |
149 | if ( mData->revision != a.mData->revision ) return false; | 148 | if ( mData->revision != a.mData->revision ) return false; |
150 | if ( mData->sortString != a.mData->sortString ) return false; | 149 | if ( mData->sortString != a.mData->sortString ) return false; |
151 | if ( mData->secrecy != a.mData->secrecy ) return false; | 150 | if ( mData->secrecy != a.mData->secrecy ) return false; |
152 | if ( mData->logo != a.mData->logo ) return false; | 151 | if ( mData->logo != a.mData->logo ) return false; |
153 | if ( mData->photo != a.mData->photo ) return false; | 152 | if ( mData->photo != a.mData->photo ) return false; |
154 | if ( mData->sound != a.mData->sound ) return false; | 153 | if ( mData->sound != a.mData->sound ) return false; |
155 | if ( mData->agent != a.mData->agent ) return false; | 154 | if ( mData->agent != a.mData->agent ) return false; |
156 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 155 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
157 | ( mData->url != a.mData->url ) ) return false; | 156 | ( mData->url != a.mData->url ) ) return false; |
158 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 157 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
159 | if ( mData->addresses != a.mData->addresses ) return false; | 158 | if ( mData->addresses != a.mData->addresses ) return false; |
160 | if ( mData->keys != a.mData->keys ) return false; | 159 | if ( mData->keys != a.mData->keys ) return false; |
161 | if ( mData->emails != a.mData->emails ) return false; | 160 | if ( mData->emails != a.mData->emails ) return false; |
162 | if ( mData->categories != a.mData->categories ) return false; | 161 | if ( mData->categories != a.mData->categories ) return false; |
163 | if ( mData->custom != a.mData->custom ) return false; | 162 | if ( mData->custom != a.mData->custom ) return false; |
164 | 163 | ||
165 | return true; | 164 | return true; |
166 | } | 165 | } |
167 | 166 | ||
168 | bool Addressee::operator!=( const Addressee &a ) const | 167 | bool Addressee::operator!=( const Addressee &a ) const |
169 | { | 168 | { |
170 | return !( a == *this ); | 169 | return !( a == *this ); |
171 | } | 170 | } |
172 | 171 | ||
173 | bool Addressee::isEmpty() const | 172 | bool Addressee::isEmpty() const |
174 | { | 173 | { |
175 | return mData->empty; | 174 | return mData->empty; |
176 | } | 175 | } |
177 | ulong Addressee::getCsum4List( const QStringList & attList) | 176 | ulong Addressee::getCsum4List( const QStringList & attList) |
178 | { | 177 | { |
179 | int max = attList.count(); | 178 | int max = attList.count(); |
180 | ulong cSum = 0; | 179 | ulong cSum = 0; |
181 | int j,k,i; | 180 | int j,k,i; |
182 | int add; | 181 | int add; |
183 | for ( i = 0; i < max ; ++i ) { | 182 | for ( i = 0; i < max ; ++i ) { |
184 | QString s = attList[i]; | 183 | QString s = attList[i]; |
185 | if ( ! s.isEmpty() ){ | 184 | if ( ! s.isEmpty() ){ |
186 | j = s.length(); | 185 | j = s.length(); |
187 | for ( k = 0; k < j; ++k ) { | 186 | for ( k = 0; k < j; ++k ) { |
188 | int mul = k +1; | 187 | int mul = k +1; |
189 | add = s[k].unicode (); | 188 | add = s[k].unicode (); |
190 | if ( k < 16 ) | 189 | if ( k < 16 ) |
191 | mul = mul * mul; | 190 | mul = mul * mul; |
192 | int ii = i+1; | 191 | int ii = i+1; |
193 | add = add * mul *ii*ii*ii; | 192 | add = add * mul *ii*ii*ii; |
194 | cSum += add; | 193 | cSum += add; |
195 | } | 194 | } |
196 | } | 195 | } |
197 | 196 | ||
198 | } | 197 | } |
199 | //QString dump = attList.join(","); | 198 | //QString dump = attList.join(","); |
200 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 199 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
201 | 200 | ||
202 | return cSum; | 201 | return cSum; |
203 | 202 | ||
204 | } | 203 | } |
205 | void Addressee::computeCsum(const QString &dev) | 204 | void Addressee::computeCsum(const QString &dev) |
206 | { | 205 | { |
207 | QStringList l; | 206 | QStringList l; |
208 | if ( !mData->name.isEmpty() ) l.append(mData->name); | 207 | if ( !mData->name.isEmpty() ) l.append(mData->name); |
209 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 208 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
210 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 209 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
211 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 210 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
212 | if ( !mData->additionalName ) l.append( mData->additionalName ); | 211 | if ( !mData->additionalName ) l.append( mData->additionalName ); |
213 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 212 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
214 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 213 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
215 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 214 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
216 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 215 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
217 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 216 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
218 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 217 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
219 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 218 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
220 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 219 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
221 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 220 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
222 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 221 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
223 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 222 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
224 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 223 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
225 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 224 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
226 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 225 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
227 | // if ( !mData->logo.isEmpty() ) l.append( ); | 226 | // if ( !mData->logo.isEmpty() ) l.append( ); |
228 | //if ( !mData->photo.isEmpty() ) l.append( ); | 227 | //if ( !mData->photo.isEmpty() ) l.append( ); |
229 | //if ( !mData->sound.isEmpty() ) l.append( ); | 228 | //if ( !mData->sound.isEmpty() ) l.append( ); |
230 | //if ( !mData->agent.isEmpty() ) l.append( ); | 229 | //if ( !mData->agent.isEmpty() ) l.append( ); |
231 | //if ( mData->url.isValid() ) l.append( ); | 230 | //if ( mData->url.isValid() ) l.append( ); |
232 | #if 0 | 231 | #if 0 |
233 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); | 232 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); |
234 | if ( !mData->addresses.isEmpty() ) l.append( ); | 233 | if ( !mData->addresses.isEmpty() ) l.append( ); |
235 | //if ( !mData->keys.isEmpty() ) l.append( ); | 234 | //if ( !mData->keys.isEmpty() ) l.append( ); |
236 | if ( !mData->emails.isEmpty() ) l.append( ); | 235 | if ( !mData->emails.isEmpty() ) l.append( ); |
237 | if ( !mData->categories .isEmpty() ) l.append( ); | 236 | if ( !mData->categories .isEmpty() ) l.append( ); |
238 | if ( !mData->custom.isEmpty() ) l.append( ); | 237 | if ( !mData->custom.isEmpty() ) l.append( ); |
239 | #endif | 238 | #endif |
240 | KABC::PhoneNumber::List phoneNumbers; | 239 | KABC::PhoneNumber::List phoneNumbers; |
241 | KABC::PhoneNumber::List::Iterator phoneIter; | 240 | KABC::PhoneNumber::List::Iterator phoneIter; |
242 | 241 | ||
243 | QStringList t; | 242 | QStringList t; |
244 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 243 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
245 | ++phoneIter ) | 244 | ++phoneIter ) |
246 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 245 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
247 | t.sort(); | 246 | t.sort(); |
248 | uint iii; | 247 | uint iii; |
249 | for ( iii = 0; iii < t.count(); ++iii) | 248 | for ( iii = 0; iii < t.count(); ++iii) |
250 | l.append( t[iii] ); | 249 | l.append( t[iii] ); |
251 | t = mData->emails; | 250 | t = mData->emails; |
252 | t.sort(); | 251 | t.sort(); |
253 | for ( iii = 0; iii < t.count(); ++iii) | 252 | for ( iii = 0; iii < t.count(); ++iii) |
254 | l.append( t[iii] ); | 253 | l.append( t[iii] ); |
255 | t = mData->categories; | 254 | t = mData->categories; |
256 | t.sort(); | 255 | t.sort(); |
257 | for ( iii = 0; iii < t.count(); ++iii) | 256 | for ( iii = 0; iii < t.count(); ++iii) |
258 | l.append( t[iii] ); | 257 | l.append( t[iii] ); |
259 | t = mData->custom; | 258 | t = mData->custom; |
260 | t.sort(); | 259 | t.sort(); |
261 | for ( iii = 0; iii < t.count(); ++iii) | 260 | for ( iii = 0; iii < t.count(); ++iii) |
262 | l.append( t[iii] ); | 261 | l.append( t[iii] ); |
263 | KABC::Address::List::Iterator addressIter; | 262 | KABC::Address::List::Iterator addressIter; |
264 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 263 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
265 | ++addressIter ) { | 264 | ++addressIter ) { |
266 | t = (*addressIter).asList(); | 265 | t = (*addressIter).asList(); |
267 | t.sort(); | 266 | t.sort(); |
268 | for ( iii = 0; iii < t.count(); ++iii) | 267 | for ( iii = 0; iii < t.count(); ++iii) |
269 | l.append( t[iii] ); | 268 | l.append( t[iii] ); |
270 | } | 269 | } |
271 | setCsum( dev, QString::number (getCsum4List(l)) ); | 270 | uint cs = getCsum4List(l); |
271 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | ||
272 | setCsum( dev, QString::number (cs )); | ||
272 | } | 273 | } |
273 | void Addressee::removeID(const QString &prof) | 274 | void Addressee::removeID(const QString &prof) |
274 | { | 275 | { |
275 | detach(); | 276 | detach(); |
276 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 277 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
277 | 278 | ||
278 | } | 279 | } |
279 | void Addressee::setID( const QString & prof , const QString & id ) | 280 | void Addressee::setID( const QString & prof , const QString & id ) |
280 | { | 281 | { |
281 | detach(); | 282 | detach(); |
283 | qDebug("setID1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | ||
282 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 284 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
285 | qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | ||
283 | } | 286 | } |
284 | void Addressee::setTempSyncStat( int id ) | 287 | void Addressee::setTempSyncStat( int id ) |
285 | { | 288 | { |
286 | mTempSyncStat = id; | 289 | if ( mData->mTempSyncStat == id ) return; |
290 | detach(); | ||
291 | mData->mTempSyncStat = id; | ||
287 | } | 292 | } |
288 | int Addressee::tempSyncStat() const | 293 | int Addressee::tempSyncStat() const |
289 | { | 294 | { |
290 | return mTempSyncStat; | 295 | return mData->mTempSyncStat; |
291 | } | 296 | } |
292 | 297 | ||
293 | QString Addressee::getID( const QString & prof) | 298 | QString Addressee::getID( const QString & prof) |
294 | { | 299 | { |
295 | return KIdManager::getId ( mData->mExternalId, prof ); | 300 | return KIdManager::getId ( mData->mExternalId, prof ); |
296 | } | 301 | } |
297 | 302 | ||
298 | void Addressee::setCsum( const QString & prof , const QString & id ) | 303 | void Addressee::setCsum( const QString & prof , const QString & id ) |
299 | { | 304 | { |
300 | detach(); | 305 | detach(); |
306 | qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | ||
301 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 307 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
308 | qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | ||
302 | } | 309 | } |
303 | 310 | ||
304 | QString Addressee::getCsum( const QString & prof) | 311 | QString Addressee::getCsum( const QString & prof) |
305 | { | 312 | { |
306 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 313 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
307 | } | 314 | } |
308 | 315 | ||
309 | void Addressee::setIDStr( const QString & s ) | 316 | void Addressee::setIDStr( const QString & s ) |
310 | { | 317 | { |
311 | detach(); | 318 | detach(); |
312 | mData->mExternalId = s; | 319 | mData->mExternalId = s; |
313 | } | 320 | } |
314 | 321 | ||
315 | QString Addressee::IDStr() const | 322 | QString Addressee::IDStr() const |
316 | { | 323 | { |
317 | return mData->mExternalId; | 324 | return mData->mExternalId; |
318 | } | 325 | } |
319 | 326 | ||
320 | 327 | ||
321 | void Addressee::setUid( const QString &id ) | 328 | void Addressee::setUid( const QString &id ) |
322 | { | 329 | { |
323 | if ( id == mData->uid ) return; | 330 | if ( id == mData->uid ) return; |
324 | detach(); | 331 | detach(); |
325 | mData->empty = false; | 332 | mData->empty = false; |
326 | mData->uid = id; | 333 | mData->uid = id; |
327 | } | 334 | } |
328 | 335 | ||
329 | QString Addressee::uid() const | 336 | QString Addressee::uid() const |
330 | { | 337 | { |
331 | if ( mData->uid.isEmpty() ) | 338 | if ( mData->uid.isEmpty() ) |
332 | mData->uid = KApplication::randomString( 10 ); | 339 | mData->uid = KApplication::randomString( 10 ); |
333 | 340 | ||
334 | return mData->uid; | 341 | return mData->uid; |
335 | } | 342 | } |
336 | 343 | ||
337 | QString Addressee::uidLabel() | 344 | QString Addressee::uidLabel() |
338 | { | 345 | { |
339 | return i18n("Unique Identifier"); | 346 | return i18n("Unique Identifier"); |
340 | } | 347 | } |
341 | 348 | ||
342 | void Addressee::setName( const QString &name ) | 349 | void Addressee::setName( const QString &name ) |
343 | { | 350 | { |
344 | if ( name == mData->name ) return; | 351 | if ( name == mData->name ) return; |
345 | detach(); | 352 | detach(); |
346 | mData->empty = false; | 353 | mData->empty = false; |
347 | mData->name = name; | 354 | mData->name = name; |
348 | } | 355 | } |
349 | 356 | ||
350 | QString Addressee::name() const | 357 | QString Addressee::name() const |
351 | { | 358 | { |
352 | return mData->name; | 359 | return mData->name; |
353 | } | 360 | } |
354 | 361 | ||
355 | QString Addressee::nameLabel() | 362 | QString Addressee::nameLabel() |
356 | { | 363 | { |
357 | return i18n("Name"); | 364 | return i18n("Name"); |
358 | } | 365 | } |
359 | 366 | ||
360 | 367 | ||
361 | void Addressee::setFormattedName( const QString &formattedName ) | 368 | void Addressee::setFormattedName( const QString &formattedName ) |
362 | { | 369 | { |
363 | if ( formattedName == mData->formattedName ) return; | 370 | if ( formattedName == mData->formattedName ) return; |
364 | detach(); | 371 | detach(); |
365 | mData->empty = false; | 372 | mData->empty = false; |
366 | mData->formattedName = formattedName; | 373 | mData->formattedName = formattedName; |
367 | } | 374 | } |
368 | 375 | ||
369 | QString Addressee::formattedName() const | 376 | QString Addressee::formattedName() const |
370 | { | 377 | { |
371 | return mData->formattedName; | 378 | return mData->formattedName; |
372 | } | 379 | } |
373 | 380 | ||
374 | QString Addressee::formattedNameLabel() | 381 | QString Addressee::formattedNameLabel() |
375 | { | 382 | { |
376 | return i18n("Formatted Name"); | 383 | return i18n("Formatted Name"); |
377 | } | 384 | } |
378 | 385 | ||
379 | 386 | ||
380 | void Addressee::setFamilyName( const QString &familyName ) | 387 | void Addressee::setFamilyName( const QString &familyName ) |
381 | { | 388 | { |
382 | if ( familyName == mData->familyName ) return; | 389 | if ( familyName == mData->familyName ) return; |
383 | detach(); | 390 | detach(); |
384 | mData->empty = false; | 391 | mData->empty = false; |
385 | mData->familyName = familyName; | 392 | mData->familyName = familyName; |
386 | } | 393 | } |
387 | 394 | ||
388 | QString Addressee::familyName() const | 395 | QString Addressee::familyName() const |
389 | { | 396 | { |
390 | return mData->familyName; | 397 | return mData->familyName; |
391 | } | 398 | } |
392 | 399 | ||
393 | QString Addressee::familyNameLabel() | 400 | QString Addressee::familyNameLabel() |
394 | { | 401 | { |
395 | return i18n("Family Name"); | 402 | return i18n("Family Name"); |
396 | } | 403 | } |
397 | 404 | ||
398 | 405 | ||
399 | void Addressee::setGivenName( const QString &givenName ) | 406 | void Addressee::setGivenName( const QString &givenName ) |
400 | { | 407 | { |
401 | if ( givenName == mData->givenName ) return; | 408 | if ( givenName == mData->givenName ) return; |
402 | detach(); | 409 | detach(); |
403 | mData->empty = false; | 410 | mData->empty = false; |
404 | mData->givenName = givenName; | 411 | mData->givenName = givenName; |
405 | } | 412 | } |
406 | 413 | ||
407 | QString Addressee::givenName() const | 414 | QString Addressee::givenName() const |
408 | { | 415 | { |
409 | return mData->givenName; | 416 | return mData->givenName; |
410 | } | 417 | } |
411 | 418 | ||
412 | QString Addressee::givenNameLabel() | 419 | QString Addressee::givenNameLabel() |
413 | { | 420 | { |
414 | return i18n("Given Name"); | 421 | return i18n("Given Name"); |
415 | } | 422 | } |
416 | 423 | ||
417 | 424 | ||
418 | void Addressee::setAdditionalName( const QString &additionalName ) | 425 | void Addressee::setAdditionalName( const QString &additionalName ) |
419 | { | 426 | { |
420 | if ( additionalName == mData->additionalName ) return; | 427 | if ( additionalName == mData->additionalName ) return; |
421 | detach(); | 428 | detach(); |
422 | mData->empty = false; | 429 | mData->empty = false; |
423 | mData->additionalName = additionalName; | 430 | mData->additionalName = additionalName; |
424 | } | 431 | } |
425 | 432 | ||
426 | QString Addressee::additionalName() const | 433 | QString Addressee::additionalName() const |
427 | { | 434 | { |
428 | return mData->additionalName; | 435 | return mData->additionalName; |
429 | } | 436 | } |
430 | 437 | ||
431 | QString Addressee::additionalNameLabel() | 438 | QString Addressee::additionalNameLabel() |
432 | { | 439 | { |
433 | return i18n("Additional Names"); | 440 | return i18n("Additional Names"); |
434 | } | 441 | } |
435 | 442 | ||
436 | 443 | ||
437 | void Addressee::setPrefix( const QString &prefix ) | 444 | void Addressee::setPrefix( const QString &prefix ) |
438 | { | 445 | { |
439 | if ( prefix == mData->prefix ) return; | 446 | if ( prefix == mData->prefix ) return; |
440 | detach(); | 447 | detach(); |
441 | mData->empty = false; | 448 | mData->empty = false; |
442 | mData->prefix = prefix; | 449 | mData->prefix = prefix; |
443 | } | 450 | } |
444 | 451 | ||
445 | QString Addressee::prefix() const | 452 | QString Addressee::prefix() const |
446 | { | 453 | { |
447 | return mData->prefix; | 454 | return mData->prefix; |
448 | } | 455 | } |
449 | 456 | ||
450 | QString Addressee::prefixLabel() | 457 | QString Addressee::prefixLabel() |
451 | { | 458 | { |
452 | return i18n("Honorific Prefixes"); | 459 | return i18n("Honorific Prefixes"); |
453 | } | 460 | } |
454 | 461 | ||
455 | 462 | ||
456 | void Addressee::setSuffix( const QString &suffix ) | 463 | void Addressee::setSuffix( const QString &suffix ) |
457 | { | 464 | { |
458 | if ( suffix == mData->suffix ) return; | 465 | if ( suffix == mData->suffix ) return; |
459 | detach(); | 466 | detach(); |
460 | mData->empty = false; | 467 | mData->empty = false; |
461 | mData->suffix = suffix; | 468 | mData->suffix = suffix; |
462 | } | 469 | } |
463 | 470 | ||
464 | QString Addressee::suffix() const | 471 | QString Addressee::suffix() const |
465 | { | 472 | { |
466 | return mData->suffix; | 473 | return mData->suffix; |
467 | } | 474 | } |
468 | 475 | ||
469 | QString Addressee::suffixLabel() | 476 | QString Addressee::suffixLabel() |
470 | { | 477 | { |
471 | return i18n("Honorific Suffixes"); | 478 | return i18n("Honorific Suffixes"); |
472 | } | 479 | } |
473 | 480 | ||
474 | 481 | ||
475 | void Addressee::setNickName( const QString &nickName ) | 482 | void Addressee::setNickName( const QString &nickName ) |
476 | { | 483 | { |
477 | if ( nickName == mData->nickName ) return; | 484 | if ( nickName == mData->nickName ) return; |
478 | detach(); | 485 | detach(); |
479 | mData->empty = false; | 486 | mData->empty = false; |
480 | mData->nickName = nickName; | 487 | mData->nickName = nickName; |
481 | } | 488 | } |
482 | 489 | ||
483 | QString Addressee::nickName() const | 490 | QString Addressee::nickName() const |
484 | { | 491 | { |
485 | return mData->nickName; | 492 | return mData->nickName; |
486 | } | 493 | } |
487 | 494 | ||
488 | QString Addressee::nickNameLabel() | 495 | QString Addressee::nickNameLabel() |
489 | { | 496 | { |
490 | return i18n("Nick Name"); | 497 | return i18n("Nick Name"); |
491 | } | 498 | } |
492 | 499 | ||
493 | 500 | ||
494 | void Addressee::setBirthday( const QDateTime &birthday ) | 501 | void Addressee::setBirthday( const QDateTime &birthday ) |
495 | { | 502 | { |
496 | if ( birthday == mData->birthday ) return; | 503 | if ( birthday == mData->birthday ) return; |
497 | detach(); | 504 | detach(); |
498 | mData->empty = false; | 505 | mData->empty = false; |
499 | mData->birthday = birthday; | 506 | mData->birthday = birthday; |
500 | } | 507 | } |
501 | 508 | ||
502 | QDateTime Addressee::birthday() const | 509 | QDateTime Addressee::birthday() const |
503 | { | 510 | { |
504 | return mData->birthday; | 511 | return mData->birthday; |
505 | } | 512 | } |
506 | 513 | ||
507 | QString Addressee::birthdayLabel() | 514 | QString Addressee::birthdayLabel() |
508 | { | 515 | { |
509 | return i18n("Birthday"); | 516 | return i18n("Birthday"); |
510 | } | 517 | } |
511 | 518 | ||
512 | 519 | ||
513 | QString Addressee::homeAddressStreetLabel() | 520 | QString Addressee::homeAddressStreetLabel() |
514 | { | 521 | { |
515 | return i18n("Home Address Street"); | 522 | return i18n("Home Address Street"); |
516 | } | 523 | } |
517 | 524 | ||
518 | 525 | ||
519 | QString Addressee::homeAddressLocalityLabel() | 526 | QString Addressee::homeAddressLocalityLabel() |
520 | { | 527 | { |
521 | return i18n("Home Address Locality"); | 528 | return i18n("Home Address Locality"); |
522 | } | 529 | } |
523 | 530 | ||
524 | 531 | ||
525 | QString Addressee::homeAddressRegionLabel() | 532 | QString Addressee::homeAddressRegionLabel() |
526 | { | 533 | { |
527 | return i18n("Home Address Region"); | 534 | return i18n("Home Address Region"); |
528 | } | 535 | } |
529 | 536 | ||
530 | 537 | ||
531 | QString Addressee::homeAddressPostalCodeLabel() | 538 | QString Addressee::homeAddressPostalCodeLabel() |
532 | { | 539 | { |
533 | return i18n("Home Address Postal Code"); | 540 | return i18n("Home Address Postal Code"); |
534 | } | 541 | } |
535 | 542 | ||
536 | 543 | ||
537 | QString Addressee::homeAddressCountryLabel() | 544 | QString Addressee::homeAddressCountryLabel() |
538 | { | 545 | { |
539 | return i18n("Home Address Country"); | 546 | return i18n("Home Address Country"); |
540 | } | 547 | } |
541 | 548 | ||
542 | 549 | ||
543 | QString Addressee::homeAddressLabelLabel() | 550 | QString Addressee::homeAddressLabelLabel() |
544 | { | 551 | { |
545 | return i18n("Home Address Label"); | 552 | return i18n("Home Address Label"); |
546 | } | 553 | } |
547 | 554 | ||
548 | 555 | ||
549 | QString Addressee::businessAddressStreetLabel() | 556 | QString Addressee::businessAddressStreetLabel() |
550 | { | 557 | { |
551 | return i18n("Business Address Street"); | 558 | return i18n("Business Address Street"); |
552 | } | 559 | } |
553 | 560 | ||
554 | 561 | ||
555 | QString Addressee::businessAddressLocalityLabel() | 562 | QString Addressee::businessAddressLocalityLabel() |
556 | { | 563 | { |
557 | return i18n("Business Address Locality"); | 564 | return i18n("Business Address Locality"); |
558 | } | 565 | } |
559 | 566 | ||
560 | 567 | ||
561 | QString Addressee::businessAddressRegionLabel() | 568 | QString Addressee::businessAddressRegionLabel() |
562 | { | 569 | { |
563 | return i18n("Business Address Region"); | 570 | return i18n("Business Address Region"); |
564 | } | 571 | } |
565 | 572 | ||
566 | 573 | ||
567 | QString Addressee::businessAddressPostalCodeLabel() | 574 | QString Addressee::businessAddressPostalCodeLabel() |
568 | { | 575 | { |
569 | return i18n("Business Address Postal Code"); | 576 | return i18n("Business Address Postal Code"); |
570 | } | 577 | } |
571 | 578 | ||
572 | 579 | ||
573 | QString Addressee::businessAddressCountryLabel() | 580 | QString Addressee::businessAddressCountryLabel() |
574 | { | 581 | { |
575 | return i18n("Business Address Country"); | 582 | return i18n("Business Address Country"); |
576 | } | 583 | } |
577 | 584 | ||
578 | 585 | ||
579 | QString Addressee::businessAddressLabelLabel() | 586 | QString Addressee::businessAddressLabelLabel() |
580 | { | 587 | { |
581 | return i18n("Business Address Label"); | 588 | return i18n("Business Address Label"); |
582 | } | 589 | } |
583 | 590 | ||
584 | 591 | ||
585 | QString Addressee::homePhoneLabel() | 592 | QString Addressee::homePhoneLabel() |
586 | { | 593 | { |
587 | return i18n("Home Phone"); | 594 | return i18n("Home Phone"); |
588 | } | 595 | } |
589 | 596 | ||
590 | 597 | ||
591 | QString Addressee::businessPhoneLabel() | 598 | QString Addressee::businessPhoneLabel() |
592 | { | 599 | { |
593 | return i18n("Business Phone"); | 600 | return i18n("Business Phone"); |
594 | } | 601 | } |
595 | 602 | ||
596 | 603 | ||
597 | QString Addressee::mobilePhoneLabel() | 604 | QString Addressee::mobilePhoneLabel() |
598 | { | 605 | { |
599 | return i18n("Mobile Phone"); | 606 | return i18n("Mobile Phone"); |
600 | } | 607 | } |
601 | 608 | ||
602 | 609 | ||
603 | QString Addressee::homeFaxLabel() | 610 | QString Addressee::homeFaxLabel() |
604 | { | 611 | { |
605 | return i18n("Home Fax"); | 612 | return i18n("Home Fax"); |
606 | } | 613 | } |
607 | 614 | ||
608 | 615 | ||
609 | QString Addressee::businessFaxLabel() | 616 | QString Addressee::businessFaxLabel() |
610 | { | 617 | { |
611 | return i18n("Business Fax"); | 618 | return i18n("Business Fax"); |
612 | } | 619 | } |
613 | 620 | ||
614 | 621 | ||
615 | QString Addressee::carPhoneLabel() | 622 | QString Addressee::carPhoneLabel() |
616 | { | 623 | { |
617 | return i18n("Car Phone"); | 624 | return i18n("Car Phone"); |
618 | } | 625 | } |
619 | 626 | ||
620 | 627 | ||
621 | QString Addressee::isdnLabel() | 628 | QString Addressee::isdnLabel() |
622 | { | 629 | { |
623 | return i18n("ISDN"); | 630 | return i18n("ISDN"); |
624 | } | 631 | } |
625 | 632 | ||
626 | 633 | ||
627 | QString Addressee::pagerLabel() | 634 | QString Addressee::pagerLabel() |
628 | { | 635 | { |
629 | return i18n("Pager"); | 636 | return i18n("Pager"); |
630 | } | 637 | } |
631 | 638 | ||
632 | QString Addressee::sipLabel() | 639 | QString Addressee::sipLabel() |
633 | { | 640 | { |
634 | return i18n("SIP"); | 641 | return i18n("SIP"); |
635 | } | 642 | } |
636 | 643 | ||
637 | QString Addressee::emailLabel() | 644 | QString Addressee::emailLabel() |
638 | { | 645 | { |
639 | return i18n("Email Address"); | 646 | return i18n("Email Address"); |
640 | } | 647 | } |
641 | 648 | ||
642 | 649 | ||
643 | void Addressee::setMailer( const QString &mailer ) | 650 | void Addressee::setMailer( const QString &mailer ) |
644 | { | 651 | { |
645 | if ( mailer == mData->mailer ) return; | 652 | if ( mailer == mData->mailer ) return; |
646 | detach(); | 653 | detach(); |
647 | mData->empty = false; | 654 | mData->empty = false; |
648 | mData->mailer = mailer; | 655 | mData->mailer = mailer; |
649 | } | 656 | } |
650 | 657 | ||
651 | QString Addressee::mailer() const | 658 | QString Addressee::mailer() const |
652 | { | 659 | { |
653 | return mData->mailer; | 660 | return mData->mailer; |
654 | } | 661 | } |
655 | 662 | ||
656 | QString Addressee::mailerLabel() | 663 | QString Addressee::mailerLabel() |
657 | { | 664 | { |
658 | return i18n("Mail Client"); | 665 | return i18n("Mail Client"); |
659 | } | 666 | } |
660 | 667 | ||
661 | 668 | ||
662 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 669 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
663 | { | 670 | { |
664 | if ( timeZone == mData->timeZone ) return; | 671 | if ( timeZone == mData->timeZone ) return; |
665 | detach(); | 672 | detach(); |
666 | mData->empty = false; | 673 | mData->empty = false; |
667 | mData->timeZone = timeZone; | 674 | mData->timeZone = timeZone; |
668 | } | 675 | } |
669 | 676 | ||
670 | TimeZone Addressee::timeZone() const | 677 | TimeZone Addressee::timeZone() const |
671 | { | 678 | { |
672 | return mData->timeZone; | 679 | return mData->timeZone; |
673 | } | 680 | } |
674 | 681 | ||
675 | QString Addressee::timeZoneLabel() | 682 | QString Addressee::timeZoneLabel() |
676 | { | 683 | { |
677 | return i18n("Time Zone"); | 684 | return i18n("Time Zone"); |
678 | } | 685 | } |
679 | 686 | ||
680 | 687 | ||
681 | void Addressee::setGeo( const Geo &geo ) | 688 | void Addressee::setGeo( const Geo &geo ) |
682 | { | 689 | { |
683 | if ( geo == mData->geo ) return; | 690 | if ( geo == mData->geo ) return; |
684 | detach(); | 691 | detach(); |
685 | mData->empty = false; | 692 | mData->empty = false; |
686 | mData->geo = geo; | 693 | mData->geo = geo; |
687 | } | 694 | } |
688 | 695 | ||
689 | Geo Addressee::geo() const | 696 | Geo Addressee::geo() const |
690 | { | 697 | { |
691 | return mData->geo; | 698 | return mData->geo; |
692 | } | 699 | } |
693 | 700 | ||
694 | QString Addressee::geoLabel() | 701 | QString Addressee::geoLabel() |
695 | { | 702 | { |
696 | return i18n("Geographic Position"); | 703 | return i18n("Geographic Position"); |
697 | } | 704 | } |
698 | 705 | ||
699 | 706 | ||
700 | void Addressee::setTitle( const QString &title ) | 707 | void Addressee::setTitle( const QString &title ) |
701 | { | 708 | { |
702 | if ( title == mData->title ) return; | 709 | if ( title == mData->title ) return; |
703 | detach(); | 710 | detach(); |
704 | mData->empty = false; | 711 | mData->empty = false; |
705 | mData->title = title; | 712 | mData->title = title; |
706 | } | 713 | } |
707 | 714 | ||
708 | QString Addressee::title() const | 715 | QString Addressee::title() const |
709 | { | 716 | { |
710 | return mData->title; | 717 | return mData->title; |
711 | } | 718 | } |
712 | 719 | ||
713 | QString Addressee::titleLabel() | 720 | QString Addressee::titleLabel() |
714 | { | 721 | { |
715 | return i18n("Title"); | 722 | return i18n("Title"); |
716 | } | 723 | } |
717 | 724 | ||
718 | 725 | ||
719 | void Addressee::setRole( const QString &role ) | 726 | void Addressee::setRole( const QString &role ) |
720 | { | 727 | { |
721 | if ( role == mData->role ) return; | 728 | if ( role == mData->role ) return; |
722 | detach(); | 729 | detach(); |
723 | mData->empty = false; | 730 | mData->empty = false; |
724 | mData->role = role; | 731 | mData->role = role; |
725 | } | 732 | } |
726 | 733 | ||
727 | QString Addressee::role() const | 734 | QString Addressee::role() const |
728 | { | 735 | { |
729 | return mData->role; | 736 | return mData->role; |
730 | } | 737 | } |
731 | 738 | ||
732 | QString Addressee::roleLabel() | 739 | QString Addressee::roleLabel() |
733 | { | 740 | { |
734 | return i18n("Role"); | 741 | return i18n("Role"); |
735 | } | 742 | } |
736 | 743 | ||
737 | 744 | ||
738 | void Addressee::setOrganization( const QString &organization ) | 745 | void Addressee::setOrganization( const QString &organization ) |
739 | { | 746 | { |
740 | if ( organization == mData->organization ) return; | 747 | if ( organization == mData->organization ) return; |
741 | detach(); | 748 | detach(); |
742 | mData->empty = false; | 749 | mData->empty = false; |
743 | mData->organization = organization; | 750 | mData->organization = organization; |
744 | } | 751 | } |
745 | 752 | ||
746 | QString Addressee::organization() const | 753 | QString Addressee::organization() const |
747 | { | 754 | { |
748 | return mData->organization; | 755 | return mData->organization; |
749 | } | 756 | } |
750 | 757 | ||
751 | QString Addressee::organizationLabel() | 758 | QString Addressee::organizationLabel() |
752 | { | 759 | { |
753 | return i18n("Organization"); | 760 | return i18n("Organization"); |
754 | } | 761 | } |
755 | 762 | ||
756 | 763 | ||
757 | void Addressee::setNote( const QString ¬e ) | 764 | void Addressee::setNote( const QString ¬e ) |
758 | { | 765 | { |
759 | if ( note == mData->note ) return; | 766 | if ( note == mData->note ) return; |
760 | detach(); | 767 | detach(); |
761 | mData->empty = false; | 768 | mData->empty = false; |
762 | mData->note = note; | 769 | mData->note = note; |
763 | } | 770 | } |
764 | 771 | ||
765 | QString Addressee::note() const | 772 | QString Addressee::note() const |
766 | { | 773 | { |
767 | return mData->note; | 774 | return mData->note; |
768 | } | 775 | } |
769 | 776 | ||
770 | QString Addressee::noteLabel() | 777 | QString Addressee::noteLabel() |
771 | { | 778 | { |
772 | return i18n("Note"); | 779 | return i18n("Note"); |
773 | } | 780 | } |
774 | 781 | ||
775 | 782 | ||
776 | void Addressee::setProductId( const QString &productId ) | 783 | void Addressee::setProductId( const QString &productId ) |
777 | { | 784 | { |
778 | if ( productId == mData->productId ) return; | 785 | if ( productId == mData->productId ) return; |
779 | detach(); | 786 | detach(); |
780 | mData->empty = false; | 787 | mData->empty = false; |
781 | mData->productId = productId; | 788 | mData->productId = productId; |
782 | } | 789 | } |
783 | 790 | ||
784 | QString Addressee::productId() const | 791 | QString Addressee::productId() const |
785 | { | 792 | { |
786 | return mData->productId; | 793 | return mData->productId; |
787 | } | 794 | } |
788 | 795 | ||
789 | QString Addressee::productIdLabel() | 796 | QString Addressee::productIdLabel() |
790 | { | 797 | { |
791 | return i18n("Product Identifier"); | 798 | return i18n("Product Identifier"); |
792 | } | 799 | } |
793 | 800 | ||
794 | 801 | ||
795 | void Addressee::setRevision( const QDateTime &revision ) | 802 | void Addressee::setRevision( const QDateTime &revision ) |
796 | { | 803 | { |
797 | if ( revision == mData->revision ) return; | 804 | if ( revision == mData->revision ) return; |
798 | detach(); | 805 | detach(); |
799 | mData->empty = false; | 806 | mData->empty = false; |
800 | mData->revision = revision; | 807 | mData->revision = revision; |
801 | } | 808 | } |
802 | 809 | ||
803 | QDateTime Addressee::revision() const | 810 | QDateTime Addressee::revision() const |
804 | { | 811 | { |
805 | return mData->revision; | 812 | return mData->revision; |
806 | } | 813 | } |
807 | 814 | ||
808 | QString Addressee::revisionLabel() | 815 | QString Addressee::revisionLabel() |
809 | { | 816 | { |
810 | return i18n("Revision Date"); | 817 | return i18n("Revision Date"); |
811 | } | 818 | } |
812 | 819 | ||
813 | 820 | ||
814 | void Addressee::setSortString( const QString &sortString ) | 821 | void Addressee::setSortString( const QString &sortString ) |
815 | { | 822 | { |
816 | if ( sortString == mData->sortString ) return; | 823 | if ( sortString == mData->sortString ) return; |
817 | detach(); | 824 | detach(); |
818 | mData->empty = false; | 825 | mData->empty = false; |
819 | mData->sortString = sortString; | 826 | mData->sortString = sortString; |
820 | } | 827 | } |
821 | 828 | ||
822 | QString Addressee::sortString() const | 829 | QString Addressee::sortString() const |
823 | { | 830 | { |
824 | return mData->sortString; | 831 | return mData->sortString; |
825 | } | 832 | } |
826 | 833 | ||
827 | QString Addressee::sortStringLabel() | 834 | QString Addressee::sortStringLabel() |
828 | { | 835 | { |
829 | return i18n("Sort String"); | 836 | return i18n("Sort String"); |
830 | } | 837 | } |
831 | 838 | ||
832 | 839 | ||
833 | void Addressee::setUrl( const KURL &url ) | 840 | void Addressee::setUrl( const KURL &url ) |
834 | { | 841 | { |
835 | if ( url == mData->url ) return; | 842 | if ( url == mData->url ) return; |
836 | detach(); | 843 | detach(); |
837 | mData->empty = false; | 844 | mData->empty = false; |
838 | mData->url = url; | 845 | mData->url = url; |
839 | } | 846 | } |
840 | 847 | ||
841 | KURL Addressee::url() const | 848 | KURL Addressee::url() const |
842 | { | 849 | { |
843 | return mData->url; | 850 | return mData->url; |
844 | } | 851 | } |
845 | 852 | ||
846 | QString Addressee::urlLabel() | 853 | QString Addressee::urlLabel() |
847 | { | 854 | { |
848 | return i18n("URL"); | 855 | return i18n("URL"); |
849 | } | 856 | } |
850 | 857 | ||
851 | 858 | ||
852 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 859 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
853 | { | 860 | { |
854 | if ( secrecy == mData->secrecy ) return; | 861 | if ( secrecy == mData->secrecy ) return; |
855 | detach(); | 862 | detach(); |
856 | mData->empty = false; | 863 | mData->empty = false; |
857 | mData->secrecy = secrecy; | 864 | mData->secrecy = secrecy; |
858 | } | 865 | } |
859 | 866 | ||
860 | Secrecy Addressee::secrecy() const | 867 | Secrecy Addressee::secrecy() const |
861 | { | 868 | { |
862 | return mData->secrecy; | 869 | return mData->secrecy; |
863 | } | 870 | } |
864 | 871 | ||
865 | QString Addressee::secrecyLabel() | 872 | QString Addressee::secrecyLabel() |
866 | { | 873 | { |
867 | return i18n("Security Class"); | 874 | return i18n("Security Class"); |
868 | } | 875 | } |
869 | 876 | ||
870 | 877 | ||
871 | void Addressee::setLogo( const Picture &logo ) | 878 | void Addressee::setLogo( const Picture &logo ) |
872 | { | 879 | { |
873 | if ( logo == mData->logo ) return; | 880 | if ( logo == mData->logo ) return; |
874 | detach(); | 881 | detach(); |
875 | mData->empty = false; | 882 | mData->empty = false; |
876 | mData->logo = logo; | 883 | mData->logo = logo; |
877 | } | 884 | } |
878 | 885 | ||
879 | Picture Addressee::logo() const | 886 | Picture Addressee::logo() const |
880 | { | 887 | { |
881 | return mData->logo; | 888 | return mData->logo; |
882 | } | 889 | } |
883 | 890 | ||
884 | QString Addressee::logoLabel() | 891 | QString Addressee::logoLabel() |
885 | { | 892 | { |
886 | return i18n("Logo"); | 893 | return i18n("Logo"); |
887 | } | 894 | } |
888 | 895 | ||
889 | 896 | ||
890 | void Addressee::setPhoto( const Picture &photo ) | 897 | void Addressee::setPhoto( const Picture &photo ) |
891 | { | 898 | { |
892 | if ( photo == mData->photo ) return; | 899 | if ( photo == mData->photo ) return; |
893 | detach(); | 900 | detach(); |
894 | mData->empty = false; | 901 | mData->empty = false; |
895 | mData->photo = photo; | 902 | mData->photo = photo; |
896 | } | 903 | } |
897 | 904 | ||
898 | Picture Addressee::photo() const | 905 | Picture Addressee::photo() const |
899 | { | 906 | { |
900 | return mData->photo; | 907 | return mData->photo; |
901 | } | 908 | } |
902 | 909 | ||
903 | QString Addressee::photoLabel() | 910 | QString Addressee::photoLabel() |
904 | { | 911 | { |
905 | return i18n("Photo"); | 912 | return i18n("Photo"); |
906 | } | 913 | } |
907 | 914 | ||
908 | 915 | ||
909 | void Addressee::setSound( const Sound &sound ) | 916 | void Addressee::setSound( const Sound &sound ) |
910 | { | 917 | { |
911 | if ( sound == mData->sound ) return; | 918 | if ( sound == mData->sound ) return; |
912 | detach(); | 919 | detach(); |
913 | mData->empty = false; | 920 | mData->empty = false; |
914 | mData->sound = sound; | 921 | mData->sound = sound; |
915 | } | 922 | } |
916 | 923 | ||
917 | Sound Addressee::sound() const | 924 | Sound Addressee::sound() const |
918 | { | 925 | { |
919 | return mData->sound; | 926 | return mData->sound; |
920 | } | 927 | } |
921 | 928 | ||
922 | QString Addressee::soundLabel() | 929 | QString Addressee::soundLabel() |
923 | { | 930 | { |
924 | return i18n("Sound"); | 931 | return i18n("Sound"); |
925 | } | 932 | } |
926 | 933 | ||
927 | 934 | ||
928 | void Addressee::setAgent( const Agent &agent ) | 935 | void Addressee::setAgent( const Agent &agent ) |
929 | { | 936 | { |
930 | if ( agent == mData->agent ) return; | 937 | if ( agent == mData->agent ) return; |
931 | detach(); | 938 | detach(); |
932 | mData->empty = false; | 939 | mData->empty = false; |
933 | mData->agent = agent; | 940 | mData->agent = agent; |
934 | } | 941 | } |
935 | 942 | ||
936 | Agent Addressee::agent() const | 943 | Agent Addressee::agent() const |
937 | { | 944 | { |
938 | return mData->agent; | 945 | return mData->agent; |
939 | } | 946 | } |
940 | 947 | ||
941 | QString Addressee::agentLabel() | 948 | QString Addressee::agentLabel() |
942 | { | 949 | { |
943 | return i18n("Agent"); | 950 | return i18n("Agent"); |
944 | } | 951 | } |
945 | 952 | ||
946 | 953 | ||
947 | 954 | ||
948 | void Addressee::setNameFromString( const QString &str ) | 955 | void Addressee::setNameFromString( const QString &str ) |
949 | { | 956 | { |
950 | setFormattedName( str ); | 957 | setFormattedName( str ); |
951 | setName( str ); | 958 | setName( str ); |
952 | 959 | ||
953 | static bool first = true; | 960 | static bool first = true; |
954 | static QStringList titles; | 961 | static QStringList titles; |
955 | static QStringList suffixes; | 962 | static QStringList suffixes; |
956 | static QStringList prefixes; | 963 | static QStringList prefixes; |
957 | 964 | ||
958 | if ( first ) { | 965 | if ( first ) { |
959 | first = false; | 966 | first = false; |
960 | titles += i18n( "Dr." ); | 967 | titles += i18n( "Dr." ); |
961 | titles += i18n( "Miss" ); | 968 | titles += i18n( "Miss" ); |
962 | titles += i18n( "Mr." ); | 969 | titles += i18n( "Mr." ); |
963 | titles += i18n( "Mrs." ); | 970 | titles += i18n( "Mrs." ); |
964 | titles += i18n( "Ms." ); | 971 | titles += i18n( "Ms." ); |
965 | titles += i18n( "Prof." ); | 972 | titles += i18n( "Prof." ); |
966 | 973 | ||
967 | suffixes += i18n( "I" ); | 974 | suffixes += i18n( "I" ); |
968 | suffixes += i18n( "II" ); | 975 | suffixes += i18n( "II" ); |
969 | suffixes += i18n( "III" ); | 976 | suffixes += i18n( "III" ); |
970 | suffixes += i18n( "Jr." ); | 977 | suffixes += i18n( "Jr." ); |
971 | suffixes += i18n( "Sr." ); | 978 | suffixes += i18n( "Sr." ); |
972 | 979 | ||
973 | prefixes += "van"; | 980 | prefixes += "van"; |
974 | prefixes += "von"; | 981 | prefixes += "von"; |
975 | prefixes += "de"; | 982 | prefixes += "de"; |
976 | 983 | ||
977 | KConfig config( locateLocal( "config", "kabcrc") ); | 984 | KConfig config( locateLocal( "config", "kabcrc") ); |
978 | config.setGroup( "General" ); | 985 | config.setGroup( "General" ); |
979 | titles += config.readListEntry( "Prefixes" ); | 986 | titles += config.readListEntry( "Prefixes" ); |
980 | titles.remove( "" ); | 987 | titles.remove( "" ); |
981 | prefixes += config.readListEntry( "Inclusions" ); | 988 | prefixes += config.readListEntry( "Inclusions" ); |
982 | prefixes.remove( "" ); | 989 | prefixes.remove( "" ); |
983 | suffixes += config.readListEntry( "Suffixes" ); | 990 | suffixes += config.readListEntry( "Suffixes" ); |
984 | suffixes.remove( "" ); | 991 | suffixes.remove( "" ); |
985 | } | 992 | } |
986 | 993 | ||
987 | // clear all name parts | 994 | // clear all name parts |
988 | setPrefix( "" ); | 995 | setPrefix( "" ); |
989 | setGivenName( "" ); | 996 | setGivenName( "" ); |
990 | setAdditionalName( "" ); | 997 | setAdditionalName( "" ); |
991 | setFamilyName( "" ); | 998 | setFamilyName( "" ); |
992 | setSuffix( "" ); | 999 | setSuffix( "" ); |
993 | 1000 | ||
994 | if ( str.isEmpty() ) | 1001 | if ( str.isEmpty() ) |
995 | return; | 1002 | return; |
996 | 1003 | ||
997 | int i = str.find(','); | 1004 | int i = str.find(','); |
998 | if( i < 0 ) { | 1005 | if( i < 0 ) { |
999 | QStringList parts = QStringList::split( " ", str ); | 1006 | QStringList parts = QStringList::split( " ", str ); |
1000 | int leftOffset = 0; | 1007 | int leftOffset = 0; |
1001 | int rightOffset = parts.count() - 1; | 1008 | int rightOffset = parts.count() - 1; |
1002 | 1009 | ||
1003 | QString suffix; | 1010 | QString suffix; |
1004 | while ( rightOffset >= 0 ) { | 1011 | while ( rightOffset >= 0 ) { |
1005 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1012 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1006 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1013 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1007 | rightOffset--; | 1014 | rightOffset--; |
1008 | } else | 1015 | } else |
1009 | break; | 1016 | break; |
1010 | } | 1017 | } |
1011 | setSuffix( suffix ); | 1018 | setSuffix( suffix ); |
1012 | 1019 | ||
1013 | if ( rightOffset < 0 ) | 1020 | if ( rightOffset < 0 ) |
1014 | return; | 1021 | return; |
1015 | 1022 | ||
1016 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1023 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1017 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1024 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1018 | rightOffset--; | 1025 | rightOffset--; |
1019 | } else | 1026 | } else |
1020 | setFamilyName( parts[ rightOffset ] ); | 1027 | setFamilyName( parts[ rightOffset ] ); |
1021 | 1028 | ||
1022 | QString prefix; | 1029 | QString prefix; |
1023 | while ( leftOffset < rightOffset ) { | 1030 | while ( leftOffset < rightOffset ) { |
1024 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1031 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1025 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1032 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1026 | leftOffset++; | 1033 | leftOffset++; |
1027 | } else | 1034 | } else |
1028 | break; | 1035 | break; |
1029 | } | 1036 | } |
1030 | setPrefix( prefix ); | 1037 | setPrefix( prefix ); |
1031 | 1038 | ||
1032 | if ( leftOffset < rightOffset ) { | 1039 | if ( leftOffset < rightOffset ) { |
1033 | setGivenName( parts[ leftOffset ] ); | 1040 | setGivenName( parts[ leftOffset ] ); |
1034 | leftOffset++; | 1041 | leftOffset++; |
1035 | } | 1042 | } |
1036 | 1043 | ||
1037 | QString additionalName; | 1044 | QString additionalName; |
1038 | while ( leftOffset < rightOffset ) { | 1045 | while ( leftOffset < rightOffset ) { |
1039 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1046 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1040 | leftOffset++; | 1047 | leftOffset++; |
1041 | } | 1048 | } |
1042 | setAdditionalName( additionalName ); | 1049 | setAdditionalName( additionalName ); |
1043 | } else { | 1050 | } else { |
1044 | QString part1 = str.left( i ); | 1051 | QString part1 = str.left( i ); |
1045 | QString part2 = str.mid( i + 1 ); | 1052 | QString part2 = str.mid( i + 1 ); |
1046 | 1053 | ||
1047 | QStringList parts = QStringList::split( " ", part1 ); | 1054 | QStringList parts = QStringList::split( " ", part1 ); |
1048 | int leftOffset = 0; | 1055 | int leftOffset = 0; |
1049 | int rightOffset = parts.count() - 1; | 1056 | int rightOffset = parts.count() - 1; |
1050 | 1057 | ||
1051 | QString suffix; | 1058 | QString suffix; |
1052 | while ( rightOffset >= 0 ) { | 1059 | while ( rightOffset >= 0 ) { |
1053 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1060 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1054 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1061 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1055 | rightOffset--; | 1062 | rightOffset--; |
1056 | } else | 1063 | } else |
1057 | break; | 1064 | break; |
1058 | } | 1065 | } |
1059 | setSuffix( suffix ); | 1066 | setSuffix( suffix ); |
1060 | 1067 | ||
1061 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1068 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1062 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1069 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1063 | rightOffset--; | 1070 | rightOffset--; |
1064 | } else | 1071 | } else |
1065 | setFamilyName( parts[ rightOffset ] ); | 1072 | setFamilyName( parts[ rightOffset ] ); |
1066 | 1073 | ||
1067 | QString prefix; | 1074 | QString prefix; |
1068 | while ( leftOffset < rightOffset ) { | 1075 | while ( leftOffset < rightOffset ) { |
1069 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1076 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1070 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1077 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1071 | leftOffset++; | 1078 | leftOffset++; |
1072 | } else | 1079 | } else |
1073 | break; | 1080 | break; |
1074 | } | 1081 | } |
1075 | 1082 | ||
1076 | parts = QStringList::split( " ", part2 ); | 1083 | parts = QStringList::split( " ", part2 ); |
1077 | 1084 | ||
1078 | leftOffset = 0; | 1085 | leftOffset = 0; |
1079 | rightOffset = parts.count(); | 1086 | rightOffset = parts.count(); |
1080 | 1087 | ||
1081 | while ( leftOffset < rightOffset ) { | 1088 | while ( leftOffset < rightOffset ) { |
1082 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1089 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1083 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1090 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1084 | leftOffset++; | 1091 | leftOffset++; |
1085 | } else | 1092 | } else |
1086 | break; | 1093 | break; |
1087 | } | 1094 | } |
1088 | setPrefix( prefix ); | 1095 | setPrefix( prefix ); |
1089 | 1096 | ||
1090 | if ( leftOffset < rightOffset ) { | 1097 | if ( leftOffset < rightOffset ) { |
1091 | setGivenName( parts[ leftOffset ] ); | 1098 | setGivenName( parts[ leftOffset ] ); |
1092 | leftOffset++; | 1099 | leftOffset++; |
1093 | } | 1100 | } |
1094 | 1101 | ||
1095 | QString additionalName; | 1102 | QString additionalName; |
1096 | while ( leftOffset < rightOffset ) { | 1103 | while ( leftOffset < rightOffset ) { |
1097 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1104 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1098 | leftOffset++; | 1105 | leftOffset++; |
1099 | } | 1106 | } |
1100 | setAdditionalName( additionalName ); | 1107 | setAdditionalName( additionalName ); |
1101 | } | 1108 | } |
1102 | } | 1109 | } |
1103 | 1110 | ||
1104 | QString Addressee::realName() const | 1111 | QString Addressee::realName() const |
1105 | { | 1112 | { |
1106 | if ( !formattedName().isEmpty() ) | 1113 | if ( !formattedName().isEmpty() ) |
1107 | return formattedName(); | 1114 | return formattedName(); |
1108 | 1115 | ||
1109 | QString n = assembledName(); | 1116 | QString n = assembledName(); |
1110 | 1117 | ||
1111 | if ( n.isEmpty() ) | 1118 | if ( n.isEmpty() ) |
1112 | n = name(); | 1119 | n = name(); |
1113 | 1120 | ||
1114 | return n; | 1121 | return n; |
1115 | } | 1122 | } |
1116 | 1123 | ||
1117 | QString Addressee::assembledName() const | 1124 | QString Addressee::assembledName() const |
1118 | { | 1125 | { |
1119 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1126 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1120 | familyName() + " " + suffix(); | 1127 | familyName() + " " + suffix(); |
1121 | 1128 | ||
1122 | return name.simplifyWhiteSpace(); | 1129 | return name.simplifyWhiteSpace(); |
1123 | } | 1130 | } |
1124 | 1131 | ||
1125 | QString Addressee::fullEmail( const QString &email ) const | 1132 | QString Addressee::fullEmail( const QString &email ) const |
1126 | { | 1133 | { |
1127 | QString e; | 1134 | QString e; |
1128 | if ( email.isNull() ) { | 1135 | if ( email.isNull() ) { |
1129 | e = preferredEmail(); | 1136 | e = preferredEmail(); |
1130 | } else { | 1137 | } else { |
1131 | e = email; | 1138 | e = email; |
1132 | } | 1139 | } |
1133 | if ( e.isEmpty() ) return QString::null; | 1140 | if ( e.isEmpty() ) return QString::null; |
1134 | 1141 | ||
1135 | QString text; | 1142 | QString text; |
1136 | if ( realName().isEmpty() ) | 1143 | if ( realName().isEmpty() ) |
1137 | text = e; | 1144 | text = e; |
1138 | else | 1145 | else |
1139 | text = assembledName() + " <" + e + ">"; | 1146 | text = assembledName() + " <" + e + ">"; |
1140 | 1147 | ||
1141 | return text; | 1148 | return text; |
1142 | } | 1149 | } |
1143 | 1150 | ||
1144 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1151 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1145 | { | 1152 | { |
1146 | detach(); | 1153 | detach(); |
1147 | 1154 | ||
1148 | QStringList::Iterator it = mData->emails.find( email ); | 1155 | QStringList::Iterator it = mData->emails.find( email ); |
1149 | 1156 | ||
1150 | if ( it != mData->emails.end() ) { | 1157 | if ( it != mData->emails.end() ) { |
1151 | if ( !preferred || it == mData->emails.begin() ) return; | 1158 | if ( !preferred || it == mData->emails.begin() ) return; |
1152 | mData->emails.remove( it ); | 1159 | mData->emails.remove( it ); |
1153 | mData->emails.prepend( email ); | 1160 | mData->emails.prepend( email ); |
1154 | } else { | 1161 | } else { |
1155 | if ( preferred ) { | 1162 | if ( preferred ) { |
1156 | mData->emails.prepend( email ); | 1163 | mData->emails.prepend( email ); |
1157 | } else { | 1164 | } else { |
1158 | mData->emails.append( email ); | 1165 | mData->emails.append( email ); |
1159 | } | 1166 | } |
1160 | } | 1167 | } |
1161 | } | 1168 | } |
1162 | 1169 | ||
1163 | void Addressee::removeEmail( const QString &email ) | 1170 | void Addressee::removeEmail( const QString &email ) |
1164 | { | 1171 | { |
1165 | detach(); | 1172 | detach(); |
1166 | 1173 | ||
1167 | QStringList::Iterator it = mData->emails.find( email ); | 1174 | QStringList::Iterator it = mData->emails.find( email ); |
1168 | if ( it == mData->emails.end() ) return; | 1175 | if ( it == mData->emails.end() ) return; |
1169 | 1176 | ||
1170 | mData->emails.remove( it ); | 1177 | mData->emails.remove( it ); |
1171 | } | 1178 | } |
1172 | 1179 | ||
1173 | QString Addressee::preferredEmail() const | 1180 | QString Addressee::preferredEmail() const |
1174 | { | 1181 | { |
1175 | if ( mData->emails.count() == 0 ) return QString::null; | 1182 | if ( mData->emails.count() == 0 ) return QString::null; |
1176 | else return mData->emails.first(); | 1183 | else return mData->emails.first(); |
1177 | } | 1184 | } |
1178 | 1185 | ||
1179 | QStringList Addressee::emails() const | 1186 | QStringList Addressee::emails() const |
1180 | { | 1187 | { |
1181 | return mData->emails; | 1188 | return mData->emails; |
1182 | } | 1189 | } |
1183 | void Addressee::setEmails( const QStringList& emails ) { | 1190 | void Addressee::setEmails( const QStringList& emails ) { |
1184 | detach(); | 1191 | detach(); |
1185 | mData->emails = emails; | 1192 | mData->emails = emails; |
1186 | } | 1193 | } |
1187 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1194 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1188 | { | 1195 | { |
1189 | detach(); | 1196 | detach(); |
1190 | mData->empty = false; | 1197 | mData->empty = false; |
1191 | 1198 | ||
1192 | PhoneNumber::List::Iterator it; | 1199 | PhoneNumber::List::Iterator it; |
1193 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1200 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1194 | if ( (*it).id() == phoneNumber.id() ) { | 1201 | if ( (*it).id() == phoneNumber.id() ) { |
1195 | *it = phoneNumber; | 1202 | *it = phoneNumber; |
1196 | return; | 1203 | return; |
1197 | } | 1204 | } |
1198 | } | 1205 | } |
1199 | mData->phoneNumbers.append( phoneNumber ); | 1206 | mData->phoneNumbers.append( phoneNumber ); |
1200 | } | 1207 | } |
1201 | 1208 | ||
1202 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1209 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1203 | { | 1210 | { |
1204 | detach(); | 1211 | detach(); |
1205 | 1212 | ||
1206 | PhoneNumber::List::Iterator it; | 1213 | PhoneNumber::List::Iterator it; |
1207 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1214 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1208 | if ( (*it).id() == phoneNumber.id() ) { | 1215 | if ( (*it).id() == phoneNumber.id() ) { |
1209 | mData->phoneNumbers.remove( it ); | 1216 | mData->phoneNumbers.remove( it ); |
1210 | return; | 1217 | return; |
1211 | } | 1218 | } |
1212 | } | 1219 | } |
1213 | } | 1220 | } |
1214 | 1221 | ||
1215 | PhoneNumber Addressee::phoneNumber( int type ) const | 1222 | PhoneNumber Addressee::phoneNumber( int type ) const |
1216 | { | 1223 | { |
1217 | PhoneNumber phoneNumber( "", type ); | 1224 | PhoneNumber phoneNumber( "", type ); |
1218 | PhoneNumber::List::ConstIterator it; | 1225 | PhoneNumber::List::ConstIterator it; |
1219 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1226 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1220 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1227 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1221 | if ( (*it).type() & PhoneNumber::Pref ) | 1228 | if ( (*it).type() & PhoneNumber::Pref ) |
1222 | return (*it); | 1229 | return (*it); |
1223 | else if ( phoneNumber.number().isEmpty() ) | 1230 | else if ( phoneNumber.number().isEmpty() ) |
1224 | phoneNumber = (*it); | 1231 | phoneNumber = (*it); |
1225 | } | 1232 | } |
1226 | } | 1233 | } |
1227 | 1234 | ||
1228 | return phoneNumber; | 1235 | return phoneNumber; |
1229 | } | 1236 | } |
1230 | 1237 | ||
1231 | PhoneNumber::List Addressee::phoneNumbers() const | 1238 | PhoneNumber::List Addressee::phoneNumbers() const |
1232 | { | 1239 | { |
1233 | return mData->phoneNumbers; | 1240 | return mData->phoneNumbers; |
1234 | } | 1241 | } |
1235 | 1242 | ||
1236 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1243 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1237 | { | 1244 | { |
1238 | PhoneNumber::List list; | 1245 | PhoneNumber::List list; |
1239 | 1246 | ||
1240 | PhoneNumber::List::ConstIterator it; | 1247 | PhoneNumber::List::ConstIterator it; |
1241 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1248 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1242 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1249 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1243 | list.append( *it ); | 1250 | list.append( *it ); |
1244 | } | 1251 | } |
1245 | } | 1252 | } |
1246 | return list; | 1253 | return list; |
1247 | } | 1254 | } |
1248 | 1255 | ||
1249 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1256 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1250 | { | 1257 | { |
1251 | PhoneNumber::List::ConstIterator it; | 1258 | PhoneNumber::List::ConstIterator it; |
1252 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1259 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1253 | if ( (*it).id() == id ) { | 1260 | if ( (*it).id() == id ) { |
1254 | return *it; | 1261 | return *it; |
1255 | } | 1262 | } |
1256 | } | 1263 | } |
1257 | return PhoneNumber(); | 1264 | return PhoneNumber(); |
1258 | } | 1265 | } |
1259 | 1266 | ||
1260 | void Addressee::insertKey( const Key &key ) | 1267 | void Addressee::insertKey( const Key &key ) |
1261 | { | 1268 | { |
1262 | detach(); | 1269 | detach(); |
1263 | mData->empty = false; | 1270 | mData->empty = false; |
1264 | 1271 | ||
1265 | Key::List::Iterator it; | 1272 | Key::List::Iterator it; |
1266 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1273 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1267 | if ( (*it).id() == key.id() ) { | 1274 | if ( (*it).id() == key.id() ) { |
1268 | *it = key; | 1275 | *it = key; |
1269 | return; | 1276 | return; |
1270 | } | 1277 | } |
1271 | } | 1278 | } |
1272 | mData->keys.append( key ); | 1279 | mData->keys.append( key ); |
1273 | } | 1280 | } |
1274 | 1281 | ||
1275 | void Addressee::removeKey( const Key &key ) | 1282 | void Addressee::removeKey( const Key &key ) |
1276 | { | 1283 | { |
1277 | detach(); | 1284 | detach(); |
1278 | 1285 | ||
1279 | Key::List::Iterator it; | 1286 | Key::List::Iterator it; |
1280 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1287 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1281 | if ( (*it).id() == key.id() ) { | 1288 | if ( (*it).id() == key.id() ) { |
1282 | mData->keys.remove( key ); | 1289 | mData->keys.remove( key ); |
1283 | return; | 1290 | return; |
1284 | } | 1291 | } |
1285 | } | 1292 | } |
1286 | } | 1293 | } |
1287 | 1294 | ||
1288 | Key Addressee::key( int type, QString customTypeString ) const | 1295 | Key Addressee::key( int type, QString customTypeString ) const |
1289 | { | 1296 | { |
1290 | Key::List::ConstIterator it; | 1297 | Key::List::ConstIterator it; |
1291 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1298 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1292 | if ( (*it).type() == type ) { | 1299 | if ( (*it).type() == type ) { |
1293 | if ( type == Key::Custom ) { | 1300 | if ( type == Key::Custom ) { |
1294 | if ( customTypeString.isEmpty() ) { | 1301 | if ( customTypeString.isEmpty() ) { |
1295 | return *it; | 1302 | return *it; |
1296 | } else { | 1303 | } else { |
1297 | if ( (*it).customTypeString() == customTypeString ) | 1304 | if ( (*it).customTypeString() == customTypeString ) |
1298 | return (*it); | 1305 | return (*it); |
1299 | } | 1306 | } |
1300 | } else { | 1307 | } else { |
1301 | return *it; | 1308 | return *it; |
1302 | } | 1309 | } |
1303 | } | 1310 | } |
1304 | } | 1311 | } |
1305 | return Key( QString(), type ); | 1312 | return Key( QString(), type ); |
1306 | } | 1313 | } |
1307 | void Addressee::setKeys( const Key::List& list ) { | 1314 | void Addressee::setKeys( const Key::List& list ) { |
1308 | detach(); | 1315 | detach(); |
1309 | mData->keys = list; | 1316 | mData->keys = list; |
1310 | } | 1317 | } |
1311 | 1318 | ||
1312 | Key::List Addressee::keys() const | 1319 | Key::List Addressee::keys() const |
1313 | { | 1320 | { |
1314 | return mData->keys; | 1321 | return mData->keys; |
1315 | } | 1322 | } |
1316 | 1323 | ||
1317 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1324 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1318 | { | 1325 | { |
1319 | Key::List list; | 1326 | Key::List list; |
1320 | 1327 | ||
1321 | Key::List::ConstIterator it; | 1328 | Key::List::ConstIterator it; |
1322 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1329 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1323 | if ( (*it).type() == type ) { | 1330 | if ( (*it).type() == type ) { |
1324 | if ( type == Key::Custom ) { | 1331 | if ( type == Key::Custom ) { |
1325 | if ( customTypeString.isEmpty() ) { | 1332 | if ( customTypeString.isEmpty() ) { |
1326 | list.append(*it); | 1333 | list.append(*it); |
1327 | } else { | 1334 | } else { |
1328 | if ( (*it).customTypeString() == customTypeString ) | 1335 | if ( (*it).customTypeString() == customTypeString ) |
1329 | list.append(*it); | 1336 | list.append(*it); |
1330 | } | 1337 | } |
1331 | } else { | 1338 | } else { |
1332 | list.append(*it); | 1339 | list.append(*it); |
1333 | } | 1340 | } |
1334 | } | 1341 | } |
1335 | } | 1342 | } |
1336 | return list; | 1343 | return list; |
1337 | } | 1344 | } |
1338 | 1345 | ||
1339 | Key Addressee::findKey( const QString &id ) const | 1346 | Key Addressee::findKey( const QString &id ) const |
1340 | { | 1347 | { |
1341 | Key::List::ConstIterator it; | 1348 | Key::List::ConstIterator it; |
1342 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1349 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1343 | if ( (*it).id() == id ) { | 1350 | if ( (*it).id() == id ) { |
1344 | return *it; | 1351 | return *it; |
1345 | } | 1352 | } |
1346 | } | 1353 | } |
1347 | return Key(); | 1354 | return Key(); |
1348 | } | 1355 | } |
1349 | 1356 | ||
1350 | QString Addressee::asString() const | 1357 | QString Addressee::asString() const |
1351 | { | 1358 | { |
1352 | return "Smith, agent Smith..."; | 1359 | return "Smith, agent Smith..."; |
1353 | } | 1360 | } |
1354 | 1361 | ||
1355 | void Addressee::dump() const | 1362 | void Addressee::dump() const |
1356 | { | 1363 | { |
1357 | return; | 1364 | return; |
1358 | kdDebug(5700) << "Addressee {" << endl; | 1365 | kdDebug(5700) << "Addressee {" << endl; |
1359 | 1366 | ||
1360 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1367 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1361 | 1368 | ||
1362 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1369 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1363 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1370 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1364 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1371 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1365 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1372 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1366 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1373 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1367 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1374 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1368 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1375 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1369 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1376 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1370 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1377 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1371 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1378 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1372 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1379 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1373 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1380 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1374 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1381 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1375 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1382 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1376 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1383 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1377 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1384 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1378 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1385 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1379 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1386 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1380 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1387 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1381 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1388 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1382 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1389 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1383 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1390 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1384 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1391 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1385 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1392 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1386 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1393 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1387 | 1394 | ||
1388 | kdDebug(5700) << " Emails {" << endl; | 1395 | kdDebug(5700) << " Emails {" << endl; |
1389 | QStringList e = emails(); | 1396 | QStringList e = emails(); |
1390 | QStringList::ConstIterator it; | 1397 | QStringList::ConstIterator it; |
1391 | for( it = e.begin(); it != e.end(); ++it ) { | 1398 | for( it = e.begin(); it != e.end(); ++it ) { |
1392 | kdDebug(5700) << " " << (*it) << endl; | 1399 | kdDebug(5700) << " " << (*it) << endl; |
1393 | } | 1400 | } |
1394 | kdDebug(5700) << " }" << endl; | 1401 | kdDebug(5700) << " }" << endl; |
1395 | 1402 | ||
1396 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1403 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1397 | PhoneNumber::List p = phoneNumbers(); | 1404 | PhoneNumber::List p = phoneNumbers(); |
1398 | PhoneNumber::List::ConstIterator it2; | 1405 | PhoneNumber::List::ConstIterator it2; |
1399 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1406 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1400 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1407 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1401 | } | 1408 | } |
1402 | kdDebug(5700) << " }" << endl; | 1409 | kdDebug(5700) << " }" << endl; |
1403 | 1410 | ||
1404 | Address::List a = addresses(); | 1411 | Address::List a = addresses(); |
1405 | Address::List::ConstIterator it3; | 1412 | Address::List::ConstIterator it3; |
1406 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1413 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1407 | (*it3).dump(); | 1414 | (*it3).dump(); |
1408 | } | 1415 | } |
1409 | 1416 | ||
1410 | kdDebug(5700) << " Keys {" << endl; | 1417 | kdDebug(5700) << " Keys {" << endl; |
1411 | Key::List k = keys(); | 1418 | Key::List k = keys(); |
1412 | Key::List::ConstIterator it4; | 1419 | Key::List::ConstIterator it4; |
1413 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1420 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1414 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1421 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1415 | " Key: " << (*it4).textData() << | 1422 | " Key: " << (*it4).textData() << |
1416 | " CustomString: " << (*it4).customTypeString() << endl; | 1423 | " CustomString: " << (*it4).customTypeString() << endl; |
1417 | } | 1424 | } |
1418 | kdDebug(5700) << " }" << endl; | 1425 | kdDebug(5700) << " }" << endl; |
1419 | 1426 | ||
1420 | kdDebug(5700) << "}" << endl; | 1427 | kdDebug(5700) << "}" << endl; |
1421 | } | 1428 | } |
1422 | 1429 | ||
1423 | 1430 | ||
1424 | void Addressee::insertAddress( const Address &address ) | 1431 | void Addressee::insertAddress( const Address &address ) |
1425 | { | 1432 | { |
1426 | detach(); | 1433 | detach(); |
1427 | mData->empty = false; | 1434 | mData->empty = false; |
1428 | 1435 | ||
1429 | Address::List::Iterator it; | 1436 | Address::List::Iterator it; |
1430 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1437 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1431 | if ( (*it).id() == address.id() ) { | 1438 | if ( (*it).id() == address.id() ) { |
1432 | *it = address; | 1439 | *it = address; |
1433 | return; | 1440 | return; |
1434 | } | 1441 | } |
1435 | } | 1442 | } |
1436 | mData->addresses.append( address ); | 1443 | mData->addresses.append( address ); |
1437 | } | 1444 | } |
1438 | 1445 | ||
1439 | void Addressee::removeAddress( const Address &address ) | 1446 | void Addressee::removeAddress( const Address &address ) |
1440 | { | 1447 | { |
1441 | detach(); | 1448 | detach(); |
1442 | 1449 | ||
1443 | Address::List::Iterator it; | 1450 | Address::List::Iterator it; |
1444 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1451 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1445 | if ( (*it).id() == address.id() ) { | 1452 | if ( (*it).id() == address.id() ) { |
1446 | mData->addresses.remove( it ); | 1453 | mData->addresses.remove( it ); |
1447 | return; | 1454 | return; |
1448 | } | 1455 | } |
1449 | } | 1456 | } |
1450 | } | 1457 | } |
1451 | 1458 | ||
1452 | Address Addressee::address( int type ) const | 1459 | Address Addressee::address( int type ) const |
1453 | { | 1460 | { |
1454 | Address address( type ); | 1461 | Address address( type ); |
1455 | Address::List::ConstIterator it; | 1462 | Address::List::ConstIterator it; |
1456 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1463 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1457 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1464 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1458 | if ( (*it).type() & Address::Pref ) | 1465 | if ( (*it).type() & Address::Pref ) |
1459 | return (*it); | 1466 | return (*it); |
1460 | else if ( address.isEmpty() ) | 1467 | else if ( address.isEmpty() ) |
1461 | address = (*it); | 1468 | address = (*it); |
1462 | } | 1469 | } |
1463 | } | 1470 | } |
1464 | 1471 | ||
1465 | return address; | 1472 | return address; |
1466 | } | 1473 | } |
1467 | 1474 | ||
1468 | Address::List Addressee::addresses() const | 1475 | Address::List Addressee::addresses() const |
1469 | { | 1476 | { |
1470 | return mData->addresses; | 1477 | return mData->addresses; |
1471 | } | 1478 | } |
1472 | 1479 | ||
1473 | Address::List Addressee::addresses( int type ) const | 1480 | Address::List Addressee::addresses( int type ) const |
1474 | { | 1481 | { |
1475 | Address::List list; | 1482 | Address::List list; |
1476 | 1483 | ||
1477 | Address::List::ConstIterator it; | 1484 | Address::List::ConstIterator it; |
1478 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1485 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1479 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1486 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1480 | list.append( *it ); | 1487 | list.append( *it ); |
1481 | } | 1488 | } |
1482 | } | 1489 | } |
1483 | 1490 | ||
1484 | return list; | 1491 | return list; |
1485 | } | 1492 | } |
1486 | 1493 | ||
1487 | Address Addressee::findAddress( const QString &id ) const | 1494 | Address Addressee::findAddress( const QString &id ) const |
1488 | { | 1495 | { |
1489 | Address::List::ConstIterator it; | 1496 | Address::List::ConstIterator it; |
1490 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1497 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1491 | if ( (*it).id() == id ) { | 1498 | if ( (*it).id() == id ) { |
1492 | return *it; | 1499 | return *it; |
1493 | } | 1500 | } |
1494 | } | 1501 | } |
1495 | return Address(); | 1502 | return Address(); |
1496 | } | 1503 | } |
1497 | 1504 | ||
1498 | void Addressee::insertCategory( const QString &c ) | 1505 | void Addressee::insertCategory( const QString &c ) |
1499 | { | 1506 | { |
1500 | detach(); | 1507 | detach(); |
1501 | mData->empty = false; | 1508 | mData->empty = false; |
1502 | 1509 | ||
1503 | if ( mData->categories.contains( c ) ) return; | 1510 | if ( mData->categories.contains( c ) ) return; |
1504 | 1511 | ||
1505 | mData->categories.append( c ); | 1512 | mData->categories.append( c ); |
1506 | } | 1513 | } |
1507 | 1514 | ||
1508 | void Addressee::removeCategory( const QString &c ) | 1515 | void Addressee::removeCategory( const QString &c ) |
1509 | { | 1516 | { |
1510 | detach(); | 1517 | detach(); |
1511 | 1518 | ||
1512 | QStringList::Iterator it = mData->categories.find( c ); | 1519 | QStringList::Iterator it = mData->categories.find( c ); |
1513 | if ( it == mData->categories.end() ) return; | 1520 | if ( it == mData->categories.end() ) return; |
1514 | 1521 | ||
1515 | mData->categories.remove( it ); | 1522 | mData->categories.remove( it ); |
1516 | } | 1523 | } |
1517 | 1524 | ||
1518 | bool Addressee::hasCategory( const QString &c ) const | 1525 | bool Addressee::hasCategory( const QString &c ) const |
1519 | { | 1526 | { |
1520 | return ( mData->categories.contains( c ) ); | 1527 | return ( mData->categories.contains( c ) ); |
1521 | } | 1528 | } |
1522 | 1529 | ||
1523 | void Addressee::setCategories( const QStringList &c ) | 1530 | void Addressee::setCategories( const QStringList &c ) |
1524 | { | 1531 | { |
1525 | detach(); | 1532 | detach(); |
1526 | mData->empty = false; | 1533 | mData->empty = false; |
1527 | 1534 | ||
1528 | mData->categories = c; | 1535 | mData->categories = c; |
1529 | } | 1536 | } |
1530 | 1537 | ||
1531 | QStringList Addressee::categories() const | 1538 | QStringList Addressee::categories() const |
1532 | { | 1539 | { |
1533 | return mData->categories; | 1540 | return mData->categories; |
1534 | } | 1541 | } |
1535 | 1542 | ||
1536 | void Addressee::insertCustom( const QString &app, const QString &name, | 1543 | void Addressee::insertCustom( const QString &app, const QString &name, |
1537 | const QString &value ) | 1544 | const QString &value ) |
1538 | { | 1545 | { |
1539 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1546 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1540 | 1547 | ||
1541 | detach(); | 1548 | detach(); |
1542 | mData->empty = false; | 1549 | mData->empty = false; |
1543 | 1550 | ||
1544 | QString qualifiedName = app + "-" + name + ":"; | 1551 | QString qualifiedName = app + "-" + name + ":"; |
1545 | 1552 | ||
1546 | QStringList::Iterator it; | 1553 | QStringList::Iterator it; |
1547 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1554 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1548 | if ( (*it).startsWith( qualifiedName ) ) { | 1555 | if ( (*it).startsWith( qualifiedName ) ) { |
1549 | (*it) = qualifiedName + value; | 1556 | (*it) = qualifiedName + value; |
1550 | return; | 1557 | return; |
1551 | } | 1558 | } |
1552 | } | 1559 | } |
1553 | mData->custom.append( qualifiedName + value ); | 1560 | mData->custom.append( qualifiedName + value ); |
1554 | } | 1561 | } |
1555 | 1562 | ||
1556 | void Addressee::removeCustom( const QString &app, const QString &name) | 1563 | void Addressee::removeCustom( const QString &app, const QString &name) |
1557 | { | 1564 | { |
1558 | detach(); | 1565 | detach(); |
1559 | 1566 | ||
1560 | QString qualifiedName = app + "-" + name + ":"; | 1567 | QString qualifiedName = app + "-" + name + ":"; |
1561 | 1568 | ||
1562 | QStringList::Iterator it; | 1569 | QStringList::Iterator it; |
1563 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1570 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1564 | if ( (*it).startsWith( qualifiedName ) ) { | 1571 | if ( (*it).startsWith( qualifiedName ) ) { |
1565 | mData->custom.remove( it ); | 1572 | mData->custom.remove( it ); |
1566 | return; | 1573 | return; |
1567 | } | 1574 | } |
1568 | } | 1575 | } |
1569 | } | 1576 | } |
1570 | 1577 | ||
1571 | QString Addressee::custom( const QString &app, const QString &name ) const | 1578 | QString Addressee::custom( const QString &app, const QString &name ) const |
1572 | { | 1579 | { |
1573 | QString qualifiedName = app + "-" + name + ":"; | 1580 | QString qualifiedName = app + "-" + name + ":"; |
1574 | QString value; | 1581 | QString value; |
1575 | 1582 | ||
1576 | QStringList::ConstIterator it; | 1583 | QStringList::ConstIterator it; |
1577 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1584 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1578 | if ( (*it).startsWith( qualifiedName ) ) { | 1585 | if ( (*it).startsWith( qualifiedName ) ) { |
1579 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1586 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1580 | break; | 1587 | break; |
1581 | } | 1588 | } |
1582 | } | 1589 | } |
1583 | 1590 | ||
1584 | return value; | 1591 | return value; |
1585 | } | 1592 | } |
1586 | 1593 | ||
1587 | void Addressee::setCustoms( const QStringList &l ) | 1594 | void Addressee::setCustoms( const QStringList &l ) |
1588 | { | 1595 | { |
1589 | detach(); | 1596 | detach(); |
1590 | mData->empty = false; | 1597 | mData->empty = false; |
1591 | 1598 | ||
1592 | mData->custom = l; | 1599 | mData->custom = l; |
1593 | } | 1600 | } |
1594 | 1601 | ||
1595 | QStringList Addressee::customs() const | 1602 | QStringList Addressee::customs() const |
1596 | { | 1603 | { |
1597 | return mData->custom; | 1604 | return mData->custom; |
1598 | } | 1605 | } |
1599 | 1606 | ||
1600 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1607 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1601 | QString &email) | 1608 | QString &email) |
1602 | { | 1609 | { |
1603 | int startPos, endPos, len; | 1610 | int startPos, endPos, len; |
1604 | QString partA, partB, result; | 1611 | QString partA, partB, result; |
1605 | char endCh = '>'; | 1612 | char endCh = '>'; |
1606 | 1613 | ||
1607 | startPos = rawEmail.find('<'); | 1614 | startPos = rawEmail.find('<'); |
1608 | if (startPos < 0) | 1615 | if (startPos < 0) |
1609 | { | 1616 | { |
1610 | startPos = rawEmail.find('('); | 1617 | startPos = rawEmail.find('('); |
1611 | endCh = ')'; | 1618 | endCh = ')'; |
1612 | } | 1619 | } |
1613 | if (startPos < 0) | 1620 | if (startPos < 0) |
1614 | { | 1621 | { |
1615 | // We couldn't find any separators, so we assume the whole string | 1622 | // We couldn't find any separators, so we assume the whole string |
1616 | // is the email address | 1623 | // is the email address |
1617 | email = rawEmail; | 1624 | email = rawEmail; |
1618 | fullName = ""; | 1625 | fullName = ""; |
1619 | } | 1626 | } |
1620 | else | 1627 | else |
1621 | { | 1628 | { |
1622 | // We have a start position, try to find an end | 1629 | // We have a start position, try to find an end |
1623 | endPos = rawEmail.find(endCh, startPos+1); | 1630 | endPos = rawEmail.find(endCh, startPos+1); |
1624 | 1631 | ||
1625 | if (endPos < 0) | 1632 | if (endPos < 0) |
1626 | { | 1633 | { |
1627 | // We couldn't find the end of the email address. We can only | 1634 | // We couldn't find the end of the email address. We can only |
1628 | // assume the entire string is the email address. | 1635 | // assume the entire string is the email address. |
1629 | email = rawEmail; | 1636 | email = rawEmail; |
1630 | fullName = ""; | 1637 | fullName = ""; |
1631 | } | 1638 | } |
1632 | else | 1639 | else |
1633 | { | 1640 | { |
1634 | // We have a start and end to the email address | 1641 | // We have a start and end to the email address |
1635 | 1642 | ||
1636 | // Grab the name part | 1643 | // Grab the name part |
1637 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 1644 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
1638 | 1645 | ||
1639 | // grab the email part | 1646 | // grab the email part |
1640 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 1647 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
1641 | 1648 | ||
1642 | // Check that we do not have any extra characters on the end of the | 1649 | // Check that we do not have any extra characters on the end of the |
1643 | // strings | 1650 | // strings |
1644 | len = fullName.length(); | 1651 | len = fullName.length(); |
1645 | if (fullName[0]=='"' && fullName[len-1]=='"') | 1652 | if (fullName[0]=='"' && fullName[len-1]=='"') |
1646 | fullName = fullName.mid(1, len-2); | 1653 | fullName = fullName.mid(1, len-2); |
1647 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 1654 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
1648 | fullName = fullName.mid(1, len-2); | 1655 | fullName = fullName.mid(1, len-2); |
1649 | else if (fullName[0]=='(' && fullName[len-1]==')') | 1656 | else if (fullName[0]=='(' && fullName[len-1]==')') |
1650 | fullName = fullName.mid(1, len-2); | 1657 | fullName = fullName.mid(1, len-2); |
1651 | } | 1658 | } |
1652 | } | 1659 | } |
1653 | } | 1660 | } |
1654 | 1661 | ||
1655 | void Addressee::setResource( Resource *resource ) | 1662 | void Addressee::setResource( Resource *resource ) |
1656 | { | 1663 | { |
1657 | detach(); | 1664 | detach(); |
1658 | mData->resource = resource; | 1665 | mData->resource = resource; |
1659 | } | 1666 | } |
1660 | 1667 | ||
1661 | Resource *Addressee::resource() const | 1668 | Resource *Addressee::resource() const |
1662 | { | 1669 | { |
1663 | return mData->resource; | 1670 | return mData->resource; |
1664 | } | 1671 | } |
1665 | 1672 | ||
1666 | //US | 1673 | //US |
1667 | QString Addressee::resourceLabel() | 1674 | QString Addressee::resourceLabel() |
1668 | { | 1675 | { |
1669 | return i18n("Resource"); | 1676 | return i18n("Resource"); |
1670 | } | 1677 | } |
1671 | 1678 | ||
1672 | void Addressee::setChanged( bool value ) | 1679 | void Addressee::setChanged( bool value ) |
1673 | { | 1680 | { |
1674 | detach(); | 1681 | detach(); |
1675 | mData->changed = value; | 1682 | mData->changed = value; |
1676 | } | 1683 | } |
1677 | 1684 | ||
1678 | bool Addressee::changed() const | 1685 | bool Addressee::changed() const |
1679 | { | 1686 | { |
1680 | return mData->changed; | 1687 | return mData->changed; |
1681 | } | 1688 | } |
1682 | 1689 | ||
1683 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 1690 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
1684 | { | 1691 | { |
1685 | if (!a.mData) return s; | 1692 | if (!a.mData) return s; |
1686 | 1693 | ||
1687 | s << a.uid(); | 1694 | s << a.uid(); |
1688 | 1695 | ||
1689 | s << a.mData->name; | 1696 | s << a.mData->name; |
1690 | s << a.mData->formattedName; | 1697 | s << a.mData->formattedName; |
1691 | s << a.mData->familyName; | 1698 | s << a.mData->familyName; |
1692 | s << a.mData->givenName; | 1699 | s << a.mData->givenName; |
1693 | s << a.mData->additionalName; | 1700 | s << a.mData->additionalName; |
1694 | s << a.mData->prefix; | 1701 | s << a.mData->prefix; |
1695 | s << a.mData->suffix; | 1702 | s << a.mData->suffix; |
1696 | s << a.mData->nickName; | 1703 | s << a.mData->nickName; |
1697 | s << a.mData->birthday; | 1704 | s << a.mData->birthday; |
1698 | s << a.mData->mailer; | 1705 | s << a.mData->mailer; |
1699 | s << a.mData->timeZone; | 1706 | s << a.mData->timeZone; |
1700 | s << a.mData->geo; | 1707 | s << a.mData->geo; |
1701 | s << a.mData->title; | 1708 | s << a.mData->title; |
1702 | s << a.mData->role; | 1709 | s << a.mData->role; |
1703 | s << a.mData->organization; | 1710 | s << a.mData->organization; |
1704 | s << a.mData->note; | 1711 | s << a.mData->note; |
1705 | s << a.mData->productId; | 1712 | s << a.mData->productId; |
1706 | s << a.mData->revision; | 1713 | s << a.mData->revision; |
1707 | s << a.mData->sortString; | 1714 | s << a.mData->sortString; |
1708 | s << a.mData->url; | 1715 | s << a.mData->url; |
1709 | s << a.mData->secrecy; | 1716 | s << a.mData->secrecy; |
1710 | s << a.mData->logo; | 1717 | s << a.mData->logo; |
1711 | s << a.mData->photo; | 1718 | s << a.mData->photo; |
1712 | s << a.mData->sound; | 1719 | s << a.mData->sound; |
1713 | s << a.mData->agent; | 1720 | s << a.mData->agent; |
1714 | s << a.mData->phoneNumbers; | 1721 | s << a.mData->phoneNumbers; |
1715 | s << a.mData->addresses; | 1722 | s << a.mData->addresses; |
1716 | s << a.mData->emails; | 1723 | s << a.mData->emails; |
1717 | s << a.mData->categories; | 1724 | s << a.mData->categories; |
1718 | s << a.mData->custom; | 1725 | s << a.mData->custom; |
1719 | s << a.mData->keys; | 1726 | s << a.mData->keys; |
1720 | return s; | 1727 | return s; |
1721 | } | 1728 | } |
1722 | 1729 | ||
1723 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 1730 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
1724 | { | 1731 | { |
1725 | if (!a.mData) return s; | 1732 | if (!a.mData) return s; |
1726 | 1733 | ||
1727 | s >> a.mData->uid; | 1734 | s >> a.mData->uid; |
1728 | 1735 | ||
1729 | s >> a.mData->name; | 1736 | s >> a.mData->name; |
1730 | s >> a.mData->formattedName; | 1737 | s >> a.mData->formattedName; |
1731 | s >> a.mData->familyName; | 1738 | s >> a.mData->familyName; |
1732 | s >> a.mData->givenName; | 1739 | s >> a.mData->givenName; |
1733 | s >> a.mData->additionalName; | 1740 | s >> a.mData->additionalName; |
1734 | s >> a.mData->prefix; | 1741 | s >> a.mData->prefix; |
1735 | s >> a.mData->suffix; | 1742 | s >> a.mData->suffix; |
1736 | s >> a.mData->nickName; | 1743 | s >> a.mData->nickName; |
1737 | s >> a.mData->birthday; | 1744 | s >> a.mData->birthday; |
1738 | s >> a.mData->mailer; | 1745 | s >> a.mData->mailer; |
1739 | s >> a.mData->timeZone; | 1746 | s >> a.mData->timeZone; |
1740 | s >> a.mData->geo; | 1747 | s >> a.mData->geo; |
1741 | s >> a.mData->title; | 1748 | s >> a.mData->title; |
1742 | s >> a.mData->role; | 1749 | s >> a.mData->role; |
1743 | s >> a.mData->organization; | 1750 | s >> a.mData->organization; |
1744 | s >> a.mData->note; | 1751 | s >> a.mData->note; |
1745 | s >> a.mData->productId; | 1752 | s >> a.mData->productId; |
1746 | s >> a.mData->revision; | 1753 | s >> a.mData->revision; |
1747 | s >> a.mData->sortString; | 1754 | s >> a.mData->sortString; |
1748 | s >> a.mData->url; | 1755 | s >> a.mData->url; |
1749 | s >> a.mData->secrecy; | 1756 | s >> a.mData->secrecy; |
1750 | s >> a.mData->logo; | 1757 | s >> a.mData->logo; |
1751 | s >> a.mData->photo; | 1758 | s >> a.mData->photo; |
1752 | s >> a.mData->sound; | 1759 | s >> a.mData->sound; |
1753 | s >> a.mData->agent; | 1760 | s >> a.mData->agent; |
1754 | s >> a.mData->phoneNumbers; | 1761 | s >> a.mData->phoneNumbers; |
1755 | s >> a.mData->addresses; | 1762 | s >> a.mData->addresses; |
1756 | s >> a.mData->emails; | 1763 | s >> a.mData->emails; |
1757 | s >> a.mData->categories; | 1764 | s >> a.mData->categories; |
1758 | s >> a.mData->custom; | 1765 | s >> a.mData->custom; |
1759 | s >> a.mData->keys; | 1766 | s >> a.mData->keys; |
1760 | 1767 | ||
1761 | a.mData->empty = false; | 1768 | a.mData->empty = false; |
1762 | 1769 | ||
1763 | return s; | 1770 | return s; |
1764 | } | 1771 | } |
1765 | 1772 | ||
1766 | bool matchBinaryPattern( int value, int pattern ) | 1773 | bool matchBinaryPattern( int value, int pattern ) |
1767 | { | 1774 | { |
1768 | /** | 1775 | /** |
1769 | We want to match all telephonnumbers/addresses which have the bits in the | 1776 | We want to match all telephonnumbers/addresses which have the bits in the |
1770 | pattern set. More are allowed. | 1777 | pattern set. More are allowed. |
1771 | if pattern == 0 we have a special handling, then we want only those with | 1778 | if pattern == 0 we have a special handling, then we want only those with |
1772 | exactly no bit set. | 1779 | exactly no bit set. |
1773 | */ | 1780 | */ |
1774 | if ( pattern == 0 ) | 1781 | if ( pattern == 0 ) |
1775 | return ( value == 0 ); | 1782 | return ( value == 0 ); |
1776 | else | 1783 | else |
1777 | return ( pattern == ( pattern & value ) ); | 1784 | return ( pattern == ( pattern & value ) ); |
1778 | } | 1785 | } |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 0805458..bfb0840 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -1,840 +1,839 @@ | |||
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 | #ifndef KABC_ADDRESSEE_H | 29 | #ifndef KABC_ADDRESSEE_H |
30 | #define KABC_ADDRESSEE_H | 30 | #define KABC_ADDRESSEE_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | 36 | ||
37 | #include <ksharedptr.h> | 37 | #include <ksharedptr.h> |
38 | #include <kurl.h> | 38 | #include <kurl.h> |
39 | 39 | ||
40 | #include "address.h" | 40 | #include "address.h" |
41 | #include "agent.h" | 41 | #include "agent.h" |
42 | #include "geo.h" | 42 | #include "geo.h" |
43 | #include "key.h" | 43 | #include "key.h" |
44 | #include "phonenumber.h" | 44 | #include "phonenumber.h" |
45 | #include "picture.h" | 45 | #include "picture.h" |
46 | #include "secrecy.h" | 46 | #include "secrecy.h" |
47 | #include "sound.h" | 47 | #include "sound.h" |
48 | #include "timezone.h" | 48 | #include "timezone.h" |
49 | 49 | ||
50 | namespace KABC { | 50 | namespace KABC { |
51 | 51 | ||
52 | class Resource; | 52 | class Resource; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | @short address book entry | 55 | @short address book entry |
56 | 56 | ||
57 | This class represents an entry in the address book. | 57 | This class represents an entry in the address book. |
58 | 58 | ||
59 | The data of this class is implicitly shared. You can pass this class by value. | 59 | The data of this class is implicitly shared. You can pass this class by value. |
60 | 60 | ||
61 | If you need the name of a field for presenting it to the user you should use | 61 | If you need the name of a field for presenting it to the user you should use |
62 | the functions ending in Label(). They return a translated string which can be | 62 | the functions ending in Label(). They return a translated string which can be |
63 | used as label for the corresponding field. | 63 | used as label for the corresponding field. |
64 | 64 | ||
65 | About the name fields: | 65 | About the name fields: |
66 | 66 | ||
67 | givenName() is the first name and familyName() the last name. In some | 67 | givenName() is the first name and familyName() the last name. In some |
68 | countries the family name comes first, that's the reason for the | 68 | countries the family name comes first, that's the reason for the |
69 | naming. formattedName() is the full name with the correct formatting. | 69 | naming. formattedName() is the full name with the correct formatting. |
70 | It is used as an override, when the correct formatting can't be generated | 70 | It is used as an override, when the correct formatting can't be generated |
71 | from the other name fields automatically. | 71 | from the other name fields automatically. |
72 | 72 | ||
73 | realName() returns a fully formatted name(). It uses formattedName, if set, | 73 | realName() returns a fully formatted name(). It uses formattedName, if set, |
74 | otherwise it constucts the name from the name fields. As fallback, if | 74 | otherwise it constucts the name from the name fields. As fallback, if |
75 | nothing else is set it uses name(). | 75 | nothing else is set it uses name(). |
76 | 76 | ||
77 | name() is the NAME type of RFC2426. It can be used as internal name for the | 77 | name() is the NAME type of RFC2426. It can be used as internal name for the |
78 | data enty, but shouldn't be used for displaying the data to the user. | 78 | data enty, but shouldn't be used for displaying the data to the user. |
79 | */ | 79 | */ |
80 | class Addressee | 80 | class Addressee |
81 | { | 81 | { |
82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); | 82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); |
83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); | 83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); |
84 | 84 | ||
85 | public: | 85 | public: |
86 | typedef QValueList<Addressee> List; | 86 | typedef QValueList<Addressee> List; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | Construct an empty address book entry. | 89 | Construct an empty address book entry. |
90 | */ | 90 | */ |
91 | Addressee(); | 91 | Addressee(); |
92 | ~Addressee(); | 92 | ~Addressee(); |
93 | 93 | ||
94 | Addressee( const Addressee & ); | 94 | Addressee( const Addressee & ); |
95 | Addressee &operator=( const Addressee & ); | 95 | Addressee &operator=( const Addressee & ); |
96 | 96 | ||
97 | bool operator==( const Addressee & ) const; | 97 | bool operator==( const Addressee & ) const; |
98 | bool operator!=( const Addressee & ) const; | 98 | bool operator!=( const Addressee & ) const; |
99 | // sync stuff | 99 | // sync stuff |
100 | void setTempSyncStat(int id); | 100 | void setTempSyncStat(int id); |
101 | int tempSyncStat() const; | 101 | int tempSyncStat() const; |
102 | void setIDStr( const QString & ); | 102 | void setIDStr( const QString & ); |
103 | QString IDStr() const; | 103 | QString IDStr() const; |
104 | void setID( const QString &, const QString & ); | 104 | void setID( const QString &, const QString & ); |
105 | QString getID( const QString & ); | 105 | QString getID( const QString & ); |
106 | void setCsum( const QString &, const QString & ); | 106 | void setCsum( const QString &, const QString & ); |
107 | QString getCsum( const QString & ); | 107 | QString getCsum( const QString & ); |
108 | void removeID(const QString &); | 108 | void removeID(const QString &); |
109 | void computeCsum(const QString &dev); | 109 | void computeCsum(const QString &dev); |
110 | ulong getCsum4List( const QStringList & attList); | 110 | ulong getCsum4List( const QStringList & attList); |
111 | /** | 111 | /** |
112 | Return, if the address book entry is empty. | 112 | Return, if the address book entry is empty. |
113 | */ | 113 | */ |
114 | bool isEmpty() const; | 114 | bool isEmpty() const; |
115 | 115 | ||
116 | /** | 116 | /** |
117 | Set unique identifier. | 117 | Set unique identifier. |
118 | */ | 118 | */ |
119 | void setUid( const QString &uid ); | 119 | void setUid( const QString &uid ); |
120 | /** | 120 | /** |
121 | Return unique identifier. | 121 | Return unique identifier. |
122 | */ | 122 | */ |
123 | QString uid() const; | 123 | QString uid() const; |
124 | /** | 124 | /** |
125 | Return translated label for uid field. | 125 | Return translated label for uid field. |
126 | */ | 126 | */ |
127 | static QString uidLabel(); | 127 | static QString uidLabel(); |
128 | 128 | ||
129 | /** | 129 | /** |
130 | Set name. | 130 | Set name. |
131 | */ | 131 | */ |
132 | void setName( const QString &name ); | 132 | void setName( const QString &name ); |
133 | /** | 133 | /** |
134 | Return name. | 134 | Return name. |
135 | */ | 135 | */ |
136 | QString name() const; | 136 | QString name() const; |
137 | /** | 137 | /** |
138 | Return translated label for name field. | 138 | Return translated label for name field. |
139 | */ | 139 | */ |
140 | static QString nameLabel(); | 140 | static QString nameLabel(); |
141 | 141 | ||
142 | /** | 142 | /** |
143 | Set formatted name. | 143 | Set formatted name. |
144 | */ | 144 | */ |
145 | void setFormattedName( const QString &formattedName ); | 145 | void setFormattedName( const QString &formattedName ); |
146 | /** | 146 | /** |
147 | Return formatted name. | 147 | Return formatted name. |
148 | */ | 148 | */ |
149 | QString formattedName() const; | 149 | QString formattedName() const; |
150 | /** | 150 | /** |
151 | Return translated label for formattedName field. | 151 | Return translated label for formattedName field. |
152 | */ | 152 | */ |
153 | static QString formattedNameLabel(); | 153 | static QString formattedNameLabel(); |
154 | 154 | ||
155 | /** | 155 | /** |
156 | Set family name. | 156 | Set family name. |
157 | */ | 157 | */ |
158 | void setFamilyName( const QString &familyName ); | 158 | void setFamilyName( const QString &familyName ); |
159 | /** | 159 | /** |
160 | Return family name. | 160 | Return family name. |
161 | */ | 161 | */ |
162 | QString familyName() const; | 162 | QString familyName() const; |
163 | /** | 163 | /** |
164 | Return translated label for familyName field. | 164 | Return translated label for familyName field. |
165 | */ | 165 | */ |
166 | static QString familyNameLabel(); | 166 | static QString familyNameLabel(); |
167 | 167 | ||
168 | /** | 168 | /** |
169 | Set given name. | 169 | Set given name. |
170 | */ | 170 | */ |
171 | void setGivenName( const QString &givenName ); | 171 | void setGivenName( const QString &givenName ); |
172 | /** | 172 | /** |
173 | Return given name. | 173 | Return given name. |
174 | */ | 174 | */ |
175 | QString givenName() const; | 175 | QString givenName() const; |
176 | /** | 176 | /** |
177 | Return translated label for givenName field. | 177 | Return translated label for givenName field. |
178 | */ | 178 | */ |
179 | static QString givenNameLabel(); | 179 | static QString givenNameLabel(); |
180 | 180 | ||
181 | /** | 181 | /** |
182 | Set additional names. | 182 | Set additional names. |
183 | */ | 183 | */ |
184 | void setAdditionalName( const QString &additionalName ); | 184 | void setAdditionalName( const QString &additionalName ); |
185 | /** | 185 | /** |
186 | Return additional names. | 186 | Return additional names. |
187 | */ | 187 | */ |
188 | QString additionalName() const; | 188 | QString additionalName() const; |
189 | /** | 189 | /** |
190 | Return translated label for additionalName field. | 190 | Return translated label for additionalName field. |
191 | */ | 191 | */ |
192 | static QString additionalNameLabel(); | 192 | static QString additionalNameLabel(); |
193 | 193 | ||
194 | /** | 194 | /** |
195 | Set honorific prefixes. | 195 | Set honorific prefixes. |
196 | */ | 196 | */ |
197 | void setPrefix( const QString &prefix ); | 197 | void setPrefix( const QString &prefix ); |
198 | /** | 198 | /** |
199 | Return honorific prefixes. | 199 | Return honorific prefixes. |
200 | */ | 200 | */ |
201 | QString prefix() const; | 201 | QString prefix() const; |
202 | /** | 202 | /** |
203 | Return translated label for prefix field. | 203 | Return translated label for prefix field. |
204 | */ | 204 | */ |
205 | static QString prefixLabel(); | 205 | static QString prefixLabel(); |
206 | 206 | ||
207 | /** | 207 | /** |
208 | Set honorific suffixes. | 208 | Set honorific suffixes. |
209 | */ | 209 | */ |
210 | void setSuffix( const QString &suffix ); | 210 | void setSuffix( const QString &suffix ); |
211 | /** | 211 | /** |
212 | Return honorific suffixes. | 212 | Return honorific suffixes. |
213 | */ | 213 | */ |
214 | QString suffix() const; | 214 | QString suffix() const; |
215 | /** | 215 | /** |
216 | Return translated label for suffix field. | 216 | Return translated label for suffix field. |
217 | */ | 217 | */ |
218 | static QString suffixLabel(); | 218 | static QString suffixLabel(); |
219 | 219 | ||
220 | /** | 220 | /** |
221 | Set nick name. | 221 | Set nick name. |
222 | */ | 222 | */ |
223 | void setNickName( const QString &nickName ); | 223 | void setNickName( const QString &nickName ); |
224 | /** | 224 | /** |
225 | Return nick name. | 225 | Return nick name. |
226 | */ | 226 | */ |
227 | QString nickName() const; | 227 | QString nickName() const; |
228 | /** | 228 | /** |
229 | Return translated label for nickName field. | 229 | Return translated label for nickName field. |
230 | */ | 230 | */ |
231 | static QString nickNameLabel(); | 231 | static QString nickNameLabel(); |
232 | 232 | ||
233 | /** | 233 | /** |
234 | Set birthday. | 234 | Set birthday. |
235 | */ | 235 | */ |
236 | void setBirthday( const QDateTime &birthday ); | 236 | void setBirthday( const QDateTime &birthday ); |
237 | /** | 237 | /** |
238 | Return birthday. | 238 | Return birthday. |
239 | */ | 239 | */ |
240 | QDateTime birthday() const; | 240 | QDateTime birthday() const; |
241 | /** | 241 | /** |
242 | Return translated label for birthday field. | 242 | Return translated label for birthday field. |
243 | */ | 243 | */ |
244 | static QString birthdayLabel(); | 244 | static QString birthdayLabel(); |
245 | 245 | ||
246 | /** | 246 | /** |
247 | Return translated label for homeAddressStreet field. | 247 | Return translated label for homeAddressStreet field. |
248 | */ | 248 | */ |
249 | static QString homeAddressStreetLabel(); | 249 | static QString homeAddressStreetLabel(); |
250 | 250 | ||
251 | /** | 251 | /** |
252 | Return translated label for homeAddressLocality field. | 252 | Return translated label for homeAddressLocality field. |
253 | */ | 253 | */ |
254 | static QString homeAddressLocalityLabel(); | 254 | static QString homeAddressLocalityLabel(); |
255 | 255 | ||
256 | /** | 256 | /** |
257 | Return translated label for homeAddressRegion field. | 257 | Return translated label for homeAddressRegion field. |
258 | */ | 258 | */ |
259 | static QString homeAddressRegionLabel(); | 259 | static QString homeAddressRegionLabel(); |
260 | 260 | ||
261 | /** | 261 | /** |
262 | Return translated label for homeAddressPostalCode field. | 262 | Return translated label for homeAddressPostalCode field. |
263 | */ | 263 | */ |
264 | static QString homeAddressPostalCodeLabel(); | 264 | static QString homeAddressPostalCodeLabel(); |
265 | 265 | ||
266 | /** | 266 | /** |
267 | Return translated label for homeAddressCountry field. | 267 | Return translated label for homeAddressCountry field. |
268 | */ | 268 | */ |
269 | static QString homeAddressCountryLabel(); | 269 | static QString homeAddressCountryLabel(); |
270 | 270 | ||
271 | /** | 271 | /** |
272 | Return translated label for homeAddressLabel field. | 272 | Return translated label for homeAddressLabel field. |
273 | */ | 273 | */ |
274 | static QString homeAddressLabelLabel(); | 274 | static QString homeAddressLabelLabel(); |
275 | 275 | ||
276 | /** | 276 | /** |
277 | Return translated label for businessAddressStreet field. | 277 | Return translated label for businessAddressStreet field. |
278 | */ | 278 | */ |
279 | static QString businessAddressStreetLabel(); | 279 | static QString businessAddressStreetLabel(); |
280 | 280 | ||
281 | /** | 281 | /** |
282 | Return translated label for businessAddressLocality field. | 282 | Return translated label for businessAddressLocality field. |
283 | */ | 283 | */ |
284 | static QString businessAddressLocalityLabel(); | 284 | static QString businessAddressLocalityLabel(); |
285 | 285 | ||
286 | /** | 286 | /** |
287 | Return translated label for businessAddressRegion field. | 287 | Return translated label for businessAddressRegion field. |
288 | */ | 288 | */ |
289 | static QString businessAddressRegionLabel(); | 289 | static QString businessAddressRegionLabel(); |
290 | 290 | ||
291 | /** | 291 | /** |
292 | Return translated label for businessAddressPostalCode field. | 292 | Return translated label for businessAddressPostalCode field. |
293 | */ | 293 | */ |
294 | static QString businessAddressPostalCodeLabel(); | 294 | static QString businessAddressPostalCodeLabel(); |
295 | 295 | ||
296 | /** | 296 | /** |
297 | Return translated label for businessAddressCountry field. | 297 | Return translated label for businessAddressCountry field. |
298 | */ | 298 | */ |
299 | static QString businessAddressCountryLabel(); | 299 | static QString businessAddressCountryLabel(); |
300 | 300 | ||
301 | /** | 301 | /** |
302 | Return translated label for businessAddressLabel field. | 302 | Return translated label for businessAddressLabel field. |
303 | */ | 303 | */ |
304 | static QString businessAddressLabelLabel(); | 304 | static QString businessAddressLabelLabel(); |
305 | 305 | ||
306 | /** | 306 | /** |
307 | Return translated label for homePhone field. | 307 | Return translated label for homePhone field. |
308 | */ | 308 | */ |
309 | static QString homePhoneLabel(); | 309 | static QString homePhoneLabel(); |
310 | 310 | ||
311 | /** | 311 | /** |
312 | Return translated label for businessPhone field. | 312 | Return translated label for businessPhone field. |
313 | */ | 313 | */ |
314 | static QString businessPhoneLabel(); | 314 | static QString businessPhoneLabel(); |
315 | 315 | ||
316 | /** | 316 | /** |
317 | Return translated label for mobilePhone field. | 317 | Return translated label for mobilePhone field. |
318 | */ | 318 | */ |
319 | static QString mobilePhoneLabel(); | 319 | static QString mobilePhoneLabel(); |
320 | 320 | ||
321 | /** | 321 | /** |
322 | Return translated label for homeFax field. | 322 | Return translated label for homeFax field. |
323 | */ | 323 | */ |
324 | static QString homeFaxLabel(); | 324 | static QString homeFaxLabel(); |
325 | 325 | ||
326 | /** | 326 | /** |
327 | Return translated label for businessFax field. | 327 | Return translated label for businessFax field. |
328 | */ | 328 | */ |
329 | static QString businessFaxLabel(); | 329 | static QString businessFaxLabel(); |
330 | 330 | ||
331 | /** | 331 | /** |
332 | Return translated label for carPhone field. | 332 | Return translated label for carPhone field. |
333 | */ | 333 | */ |
334 | static QString carPhoneLabel(); | 334 | static QString carPhoneLabel(); |
335 | 335 | ||
336 | /** | 336 | /** |
337 | Return translated label for isdn field. | 337 | Return translated label for isdn field. |
338 | */ | 338 | */ |
339 | static QString isdnLabel(); | 339 | static QString isdnLabel(); |
340 | 340 | ||
341 | /** | 341 | /** |
342 | Return translated label for pager field. | 342 | Return translated label for pager field. |
343 | */ | 343 | */ |
344 | static QString pagerLabel(); | 344 | static QString pagerLabel(); |
345 | 345 | ||
346 | /** | 346 | /** |
347 | Return translated label for sip field. | 347 | Return translated label for sip field. |
348 | */ | 348 | */ |
349 | static QString sipLabel(); | 349 | static QString sipLabel(); |
350 | 350 | ||
351 | /** | 351 | /** |
352 | Return translated label for email field. | 352 | Return translated label for email field. |
353 | */ | 353 | */ |
354 | static QString emailLabel(); | 354 | static QString emailLabel(); |
355 | 355 | ||
356 | /** | 356 | /** |
357 | Set mail client. | 357 | Set mail client. |
358 | */ | 358 | */ |
359 | void setMailer( const QString &mailer ); | 359 | void setMailer( const QString &mailer ); |
360 | /** | 360 | /** |
361 | Return mail client. | 361 | Return mail client. |
362 | */ | 362 | */ |
363 | QString mailer() const; | 363 | QString mailer() const; |
364 | /** | 364 | /** |
365 | Return translated label for mailer field. | 365 | Return translated label for mailer field. |
366 | */ | 366 | */ |
367 | static QString mailerLabel(); | 367 | static QString mailerLabel(); |
368 | 368 | ||
369 | /** | 369 | /** |
370 | Set time zone. | 370 | Set time zone. |
371 | */ | 371 | */ |
372 | void setTimeZone( const TimeZone &timeZone ); | 372 | void setTimeZone( const TimeZone &timeZone ); |
373 | /** | 373 | /** |
374 | Return time zone. | 374 | Return time zone. |
375 | */ | 375 | */ |
376 | TimeZone timeZone() const; | 376 | TimeZone timeZone() const; |
377 | /** | 377 | /** |
378 | Return translated label for timeZone field. | 378 | Return translated label for timeZone field. |
379 | */ | 379 | */ |
380 | static QString timeZoneLabel(); | 380 | static QString timeZoneLabel(); |
381 | 381 | ||
382 | /** | 382 | /** |
383 | Set geographic position. | 383 | Set geographic position. |
384 | */ | 384 | */ |
385 | void setGeo( const Geo &geo ); | 385 | void setGeo( const Geo &geo ); |
386 | /** | 386 | /** |
387 | Return geographic position. | 387 | Return geographic position. |
388 | */ | 388 | */ |
389 | Geo geo() const; | 389 | Geo geo() const; |
390 | /** | 390 | /** |
391 | Return translated label for geo field. | 391 | Return translated label for geo field. |
392 | */ | 392 | */ |
393 | static QString geoLabel(); | 393 | static QString geoLabel(); |
394 | 394 | ||
395 | /** | 395 | /** |
396 | Set title. | 396 | Set title. |
397 | */ | 397 | */ |
398 | void setTitle( const QString &title ); | 398 | void setTitle( const QString &title ); |
399 | /** | 399 | /** |
400 | Return title. | 400 | Return title. |
401 | */ | 401 | */ |
402 | QString title() const; | 402 | QString title() const; |
403 | /** | 403 | /** |
404 | Return translated label for title field. | 404 | Return translated label for title field. |
405 | */ | 405 | */ |
406 | static QString titleLabel(); | 406 | static QString titleLabel(); |
407 | 407 | ||
408 | /** | 408 | /** |
409 | Set role. | 409 | Set role. |
410 | */ | 410 | */ |
411 | void setRole( const QString &role ); | 411 | void setRole( const QString &role ); |
412 | /** | 412 | /** |
413 | Return role. | 413 | Return role. |
414 | */ | 414 | */ |
415 | QString role() const; | 415 | QString role() const; |
416 | /** | 416 | /** |
417 | Return translated label for role field. | 417 | Return translated label for role field. |
418 | */ | 418 | */ |
419 | static QString roleLabel(); | 419 | static QString roleLabel(); |
420 | 420 | ||
421 | /** | 421 | /** |
422 | Set organization. | 422 | Set organization. |
423 | */ | 423 | */ |
424 | void setOrganization( const QString &organization ); | 424 | void setOrganization( const QString &organization ); |
425 | /** | 425 | /** |
426 | Return organization. | 426 | Return organization. |
427 | */ | 427 | */ |
428 | QString organization() const; | 428 | QString organization() const; |
429 | /** | 429 | /** |
430 | Return translated label for organization field. | 430 | Return translated label for organization field. |
431 | */ | 431 | */ |
432 | static QString organizationLabel(); | 432 | static QString organizationLabel(); |
433 | 433 | ||
434 | /** | 434 | /** |
435 | Set note. | 435 | Set note. |
436 | */ | 436 | */ |
437 | void setNote( const QString ¬e ); | 437 | void setNote( const QString ¬e ); |
438 | /** | 438 | /** |
439 | Return note. | 439 | Return note. |
440 | */ | 440 | */ |
441 | QString note() const; | 441 | QString note() const; |
442 | /** | 442 | /** |
443 | Return translated label for note field. | 443 | Return translated label for note field. |
444 | */ | 444 | */ |
445 | static QString noteLabel(); | 445 | static QString noteLabel(); |
446 | 446 | ||
447 | /** | 447 | /** |
448 | Set product identifier. | 448 | Set product identifier. |
449 | */ | 449 | */ |
450 | void setProductId( const QString &productId ); | 450 | void setProductId( const QString &productId ); |
451 | /** | 451 | /** |
452 | Return product identifier. | 452 | Return product identifier. |
453 | */ | 453 | */ |
454 | QString productId() const; | 454 | QString productId() const; |
455 | /** | 455 | /** |
456 | Return translated label for productId field. | 456 | Return translated label for productId field. |
457 | */ | 457 | */ |
458 | static QString productIdLabel(); | 458 | static QString productIdLabel(); |
459 | 459 | ||
460 | /** | 460 | /** |
461 | Set revision date. | 461 | Set revision date. |
462 | */ | 462 | */ |
463 | void setRevision( const QDateTime &revision ); | 463 | void setRevision( const QDateTime &revision ); |
464 | /** | 464 | /** |
465 | Return revision date. | 465 | Return revision date. |
466 | */ | 466 | */ |
467 | QDateTime revision() const; | 467 | QDateTime revision() const; |
468 | /** | 468 | /** |
469 | Return translated label for revision field. | 469 | Return translated label for revision field. |
470 | */ | 470 | */ |
471 | static QString revisionLabel(); | 471 | static QString revisionLabel(); |
472 | 472 | ||
473 | /** | 473 | /** |
474 | Set sort string. | 474 | Set sort string. |
475 | */ | 475 | */ |
476 | void setSortString( const QString &sortString ); | 476 | void setSortString( const QString &sortString ); |
477 | /** | 477 | /** |
478 | Return sort string. | 478 | Return sort string. |
479 | */ | 479 | */ |
480 | QString sortString() const; | 480 | QString sortString() const; |
481 | /** | 481 | /** |
482 | Return translated label for sortString field. | 482 | Return translated label for sortString field. |
483 | */ | 483 | */ |
484 | static QString sortStringLabel(); | 484 | static QString sortStringLabel(); |
485 | 485 | ||
486 | /** | 486 | /** |
487 | Set URL. | 487 | Set URL. |
488 | */ | 488 | */ |
489 | void setUrl( const KURL &url ); | 489 | void setUrl( const KURL &url ); |
490 | /** | 490 | /** |
491 | Return URL. | 491 | Return URL. |
492 | */ | 492 | */ |
493 | KURL url() const; | 493 | KURL url() const; |
494 | /** | 494 | /** |
495 | Return translated label for url field. | 495 | Return translated label for url field. |
496 | */ | 496 | */ |
497 | static QString urlLabel(); | 497 | static QString urlLabel(); |
498 | 498 | ||
499 | /** | 499 | /** |
500 | Set security class. | 500 | Set security class. |
501 | */ | 501 | */ |
502 | void setSecrecy( const Secrecy &secrecy ); | 502 | void setSecrecy( const Secrecy &secrecy ); |
503 | /** | 503 | /** |
504 | Return security class. | 504 | Return security class. |
505 | */ | 505 | */ |
506 | Secrecy secrecy() const; | 506 | Secrecy secrecy() const; |
507 | /** | 507 | /** |
508 | Return translated label for secrecy field. | 508 | Return translated label for secrecy field. |
509 | */ | 509 | */ |
510 | static QString secrecyLabel(); | 510 | static QString secrecyLabel(); |
511 | 511 | ||
512 | /** | 512 | /** |
513 | Set logo. | 513 | Set logo. |
514 | */ | 514 | */ |
515 | void setLogo( const Picture &logo ); | 515 | void setLogo( const Picture &logo ); |
516 | /** | 516 | /** |
517 | Return logo. | 517 | Return logo. |
518 | */ | 518 | */ |
519 | Picture logo() const; | 519 | Picture logo() const; |
520 | /** | 520 | /** |
521 | Return translated label for logo field. | 521 | Return translated label for logo field. |
522 | */ | 522 | */ |
523 | static QString logoLabel(); | 523 | static QString logoLabel(); |
524 | 524 | ||
525 | /** | 525 | /** |
526 | Set photo. | 526 | Set photo. |
527 | */ | 527 | */ |
528 | void setPhoto( const Picture &photo ); | 528 | void setPhoto( const Picture &photo ); |
529 | /** | 529 | /** |
530 | Return photo. | 530 | Return photo. |
531 | */ | 531 | */ |
532 | Picture photo() const; | 532 | Picture photo() const; |
533 | /** | 533 | /** |
534 | Return translated label for photo field. | 534 | Return translated label for photo field. |
535 | */ | 535 | */ |
536 | static QString photoLabel(); | 536 | static QString photoLabel(); |
537 | 537 | ||
538 | /** | 538 | /** |
539 | Set sound. | 539 | Set sound. |
540 | */ | 540 | */ |
541 | void setSound( const Sound &sound ); | 541 | void setSound( const Sound &sound ); |
542 | /** | 542 | /** |
543 | Return sound. | 543 | Return sound. |
544 | */ | 544 | */ |
545 | Sound sound() const; | 545 | Sound sound() const; |
546 | /** | 546 | /** |
547 | Return translated label for sound field. | 547 | Return translated label for sound field. |
548 | */ | 548 | */ |
549 | static QString soundLabel(); | 549 | static QString soundLabel(); |
550 | 550 | ||
551 | /** | 551 | /** |
552 | Set agent. | 552 | Set agent. |
553 | */ | 553 | */ |
554 | void setAgent( const Agent &agent ); | 554 | void setAgent( const Agent &agent ); |
555 | /** | 555 | /** |
556 | Return agent. | 556 | Return agent. |
557 | */ | 557 | */ |
558 | Agent agent() const; | 558 | Agent agent() const; |
559 | /** | 559 | /** |
560 | Return translated label for agent field. | 560 | Return translated label for agent field. |
561 | */ | 561 | */ |
562 | static QString agentLabel(); | 562 | static QString agentLabel(); |
563 | 563 | ||
564 | /** | 564 | /** |
565 | Set name fields by parsing the given string and trying to associate the | 565 | Set name fields by parsing the given string and trying to associate the |
566 | parts of the string with according fields. This function should probably | 566 | parts of the string with according fields. This function should probably |
567 | be a bit more clever. | 567 | be a bit more clever. |
568 | */ | 568 | */ |
569 | void setNameFromString( const QString & ); | 569 | void setNameFromString( const QString & ); |
570 | 570 | ||
571 | /** | 571 | /** |
572 | Return the name of the addressee. This is calculated from all the name | 572 | Return the name of the addressee. This is calculated from all the name |
573 | fields. | 573 | fields. |
574 | */ | 574 | */ |
575 | QString realName() const; | 575 | QString realName() const; |
576 | 576 | ||
577 | /** | 577 | /** |
578 | Return the name that consists of all name parts. | 578 | Return the name that consists of all name parts. |
579 | */ | 579 | */ |
580 | QString assembledName() const; | 580 | QString assembledName() const; |
581 | 581 | ||
582 | /** | 582 | /** |
583 | Return email address including real name. | 583 | Return email address including real name. |
584 | 584 | ||
585 | @param email Email address to be used to construct the full email string. | 585 | @param email Email address to be used to construct the full email string. |
586 | If this is QString::null the preferred email address is used. | 586 | If this is QString::null the preferred email address is used. |
587 | */ | 587 | */ |
588 | QString fullEmail( const QString &email=QString::null ) const; | 588 | QString fullEmail( const QString &email=QString::null ) const; |
589 | 589 | ||
590 | /** | 590 | /** |
591 | Insert an email address. If the email address already exists in this | 591 | Insert an email address. If the email address already exists in this |
592 | addressee it is not duplicated. | 592 | addressee it is not duplicated. |
593 | 593 | ||
594 | @param email Email address | 594 | @param email Email address |
595 | @param preferred Set to true, if this is the preferred email address of | 595 | @param preferred Set to true, if this is the preferred email address of |
596 | the addressee. | 596 | the addressee. |
597 | */ | 597 | */ |
598 | void insertEmail( const QString &email, bool preferred=false ); | 598 | void insertEmail( const QString &email, bool preferred=false ); |
599 | 599 | ||
600 | /** | 600 | /** |
601 | Remove email address. If the email address doesn't exist, nothing happens. | 601 | Remove email address. If the email address doesn't exist, nothing happens. |
602 | */ | 602 | */ |
603 | void removeEmail( const QString &email ); | 603 | void removeEmail( const QString &email ); |
604 | 604 | ||
605 | /** | 605 | /** |
606 | Return preferred email address. This is the first email address or the | 606 | Return preferred email address. This is the first email address or the |
607 | last one added with @ref insertEmail() with a set preferred parameter. | 607 | last one added with @ref insertEmail() with a set preferred parameter. |
608 | */ | 608 | */ |
609 | QString preferredEmail() const; | 609 | QString preferredEmail() const; |
610 | 610 | ||
611 | /** | 611 | /** |
612 | Return list of all email addresses. | 612 | Return list of all email addresses. |
613 | */ | 613 | */ |
614 | QStringList emails() const; | 614 | QStringList emails() const; |
615 | 615 | ||
616 | /** | 616 | /** |
617 | Set the emails to @param. | 617 | Set the emails to @param. |
618 | The first email address gets the preferred one! | 618 | The first email address gets the preferred one! |
619 | @param list The list of email addresses. | 619 | @param list The list of email addresses. |
620 | */ | 620 | */ |
621 | void setEmails( const QStringList& list); | 621 | void setEmails( const QStringList& list); |
622 | 622 | ||
623 | /** | 623 | /** |
624 | Insert a phone number. If a phone number with the same id already exists | 624 | Insert a phone number. If a phone number with the same id already exists |
625 | in this addressee it is not duplicated. | 625 | in this addressee it is not duplicated. |
626 | */ | 626 | */ |
627 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); | 627 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); |
628 | 628 | ||
629 | /** | 629 | /** |
630 | Remove phone number. If no phone number with the given id exists for this | 630 | Remove phone number. If no phone number with the given id exists for this |
631 | addresse nothing happens. | 631 | addresse nothing happens. |
632 | */ | 632 | */ |
633 | void removePhoneNumber( const PhoneNumber &phoneNumber ); | 633 | void removePhoneNumber( const PhoneNumber &phoneNumber ); |
634 | 634 | ||
635 | /** | 635 | /** |
636 | Return phone number, which matches the given type. | 636 | Return phone number, which matches the given type. |
637 | */ | 637 | */ |
638 | PhoneNumber phoneNumber( int type ) const; | 638 | PhoneNumber phoneNumber( int type ) const; |
639 | 639 | ||
640 | /** | 640 | /** |
641 | Return list of all phone numbers. | 641 | Return list of all phone numbers. |
642 | */ | 642 | */ |
643 | PhoneNumber::List phoneNumbers() const; | 643 | PhoneNumber::List phoneNumbers() const; |
644 | 644 | ||
645 | /** | 645 | /** |
646 | Return list of phone numbers with a special type. | 646 | Return list of phone numbers with a special type. |
647 | */ | 647 | */ |
648 | PhoneNumber::List phoneNumbers( int type ) const; | 648 | PhoneNumber::List phoneNumbers( int type ) const; |
649 | 649 | ||
650 | /** | 650 | /** |
651 | Return phone number with the given id. | 651 | Return phone number with the given id. |
652 | */ | 652 | */ |
653 | PhoneNumber findPhoneNumber( const QString &id ) const; | 653 | PhoneNumber findPhoneNumber( const QString &id ) const; |
654 | 654 | ||
655 | /** | 655 | /** |
656 | Insert a key. If a key with the same id already exists | 656 | Insert a key. If a key with the same id already exists |
657 | in this addressee it is not duplicated. | 657 | in this addressee it is not duplicated. |
658 | */ | 658 | */ |
659 | void insertKey( const Key &key ); | 659 | void insertKey( const Key &key ); |
660 | 660 | ||
661 | /** | 661 | /** |
662 | Remove a key. If no key with the given id exists for this | 662 | Remove a key. If no key with the given id exists for this |
663 | addresse nothing happens. | 663 | addresse nothing happens. |
664 | */ | 664 | */ |
665 | void removeKey( const Key &key ); | 665 | void removeKey( const Key &key ); |
666 | 666 | ||
667 | /** | 667 | /** |
668 | Return key, which matches the given type. | 668 | Return key, which matches the given type. |
669 | If @p type == Key::Custom you can specify a string | 669 | If @p type == Key::Custom you can specify a string |
670 | that should match. If you leave the string empty, the first | 670 | that should match. If you leave the string empty, the first |
671 | key with a custom value is returned. | 671 | key with a custom value is returned. |
672 | */ | 672 | */ |
673 | Key key( int type, QString customTypeString = QString::null ) const; | 673 | Key key( int type, QString customTypeString = QString::null ) const; |
674 | 674 | ||
675 | /** | 675 | /** |
676 | Return list of all keys. | 676 | Return list of all keys. |
677 | */ | 677 | */ |
678 | Key::List keys() const; | 678 | Key::List keys() const; |
679 | 679 | ||
680 | /** | 680 | /** |
681 | Set the list of keys | 681 | Set the list of keys |
682 | @param keys The keys to be set. | 682 | @param keys The keys to be set. |
683 | */ | 683 | */ |
684 | void setKeys( const Key::List& keys); | 684 | void setKeys( const Key::List& keys); |
685 | 685 | ||
686 | /** | 686 | /** |
687 | Return list of keys with a special type. | 687 | Return list of keys with a special type. |
688 | If @p type == Key::Custom you can specify a string | 688 | If @p type == Key::Custom you can specify a string |
689 | that should match. If you leave the string empty, all custom | 689 | that should match. If you leave the string empty, all custom |
690 | keys will be returned. | 690 | keys will be returned. |
691 | */ | 691 | */ |
692 | Key::List keys( int type, QString customTypeString = QString::null ) const; | 692 | Key::List keys( int type, QString customTypeString = QString::null ) const; |
693 | 693 | ||
694 | /** | 694 | /** |
695 | Return key with the given id. | 695 | Return key with the given id. |
696 | */ | 696 | */ |
697 | Key findKey( const QString &id ) const; | 697 | Key findKey( const QString &id ) const; |
698 | 698 | ||
699 | /** | 699 | /** |
700 | Insert an address. If an address with the same id already exists | 700 | Insert an address. If an address with the same id already exists |
701 | in this addressee it is not duplicated. | 701 | in this addressee it is not duplicated. |
702 | */ | 702 | */ |
703 | void insertAddress( const Address &address ); | 703 | void insertAddress( const Address &address ); |
704 | 704 | ||
705 | /** | 705 | /** |
706 | Remove address. If no address with the given id exists for this | 706 | Remove address. If no address with the given id exists for this |
707 | addresse nothing happens. | 707 | addresse nothing happens. |
708 | */ | 708 | */ |
709 | void removeAddress( const Address &address ); | 709 | void removeAddress( const Address &address ); |
710 | 710 | ||
711 | /** | 711 | /** |
712 | Return address, which matches the given type. | 712 | Return address, which matches the given type. |
713 | */ | 713 | */ |
714 | Address address( int type ) const; | 714 | Address address( int type ) const; |
715 | 715 | ||
716 | /** | 716 | /** |
717 | Return list of all addresses. | 717 | Return list of all addresses. |
718 | */ | 718 | */ |
719 | Address::List addresses() const; | 719 | Address::List addresses() const; |
720 | 720 | ||
721 | /** | 721 | /** |
722 | Return list of addresses with a special type. | 722 | Return list of addresses with a special type. |
723 | */ | 723 | */ |
724 | Address::List addresses( int type ) const; | 724 | Address::List addresses( int type ) const; |
725 | 725 | ||
726 | /** | 726 | /** |
727 | Return address with the given id. | 727 | Return address with the given id. |
728 | */ | 728 | */ |
729 | Address findAddress( const QString &id ) const; | 729 | Address findAddress( const QString &id ) const; |
730 | 730 | ||
731 | /** | 731 | /** |
732 | Insert category. If the category already exists it is not duplicated. | 732 | Insert category. If the category already exists it is not duplicated. |
733 | */ | 733 | */ |
734 | void insertCategory( const QString & ); | 734 | void insertCategory( const QString & ); |
735 | 735 | ||
736 | /** | 736 | /** |
737 | Remove category. | 737 | Remove category. |
738 | */ | 738 | */ |
739 | void removeCategory( const QString & ); | 739 | void removeCategory( const QString & ); |
740 | 740 | ||
741 | /** | 741 | /** |
742 | Return, if addressee has the given category. | 742 | Return, if addressee has the given category. |
743 | */ | 743 | */ |
744 | bool hasCategory( const QString & ) const; | 744 | bool hasCategory( const QString & ) const; |
745 | 745 | ||
746 | /** | 746 | /** |
747 | Set categories to given value. | 747 | Set categories to given value. |
748 | */ | 748 | */ |
749 | void setCategories( const QStringList & ); | 749 | void setCategories( const QStringList & ); |
750 | 750 | ||
751 | /** | 751 | /** |
752 | Return list of all set categories. | 752 | Return list of all set categories. |
753 | */ | 753 | */ |
754 | QStringList categories() const; | 754 | QStringList categories() const; |
755 | 755 | ||
756 | /** | 756 | /** |
757 | Insert custom entry. The entry is identified by the name of the inserting | 757 | Insert custom entry. The entry is identified by the name of the inserting |
758 | application and a unique name. If an entry with the given app and name | 758 | application and a unique name. If an entry with the given app and name |
759 | already exists its value is replaced with the new given value. | 759 | already exists its value is replaced with the new given value. |
760 | */ | 760 | */ |
761 | void insertCustom( const QString &app, const QString &name, | 761 | void insertCustom( const QString &app, const QString &name, |
762 | const QString &value ); | 762 | const QString &value ); |
763 | 763 | ||
764 | /** | 764 | /** |
765 | Remove custom entry. | 765 | Remove custom entry. |
766 | */ | 766 | */ |
767 | void removeCustom( const QString &app, const QString &name ); | 767 | void removeCustom( const QString &app, const QString &name ); |
768 | 768 | ||
769 | /** | 769 | /** |
770 | Return value of custom entry, identified by app and entry name. | 770 | Return value of custom entry, identified by app and entry name. |
771 | */ | 771 | */ |
772 | QString custom( const QString &app, const QString &name ) const; | 772 | QString custom( const QString &app, const QString &name ) const; |
773 | 773 | ||
774 | /** | 774 | /** |
775 | Set all custom entries. | 775 | Set all custom entries. |
776 | */ | 776 | */ |
777 | void setCustoms( const QStringList & ); | 777 | void setCustoms( const QStringList & ); |
778 | 778 | ||
779 | /** | 779 | /** |
780 | Return list of all custom entries. | 780 | Return list of all custom entries. |
781 | */ | 781 | */ |
782 | QStringList customs() const; | 782 | QStringList customs() const; |
783 | 783 | ||
784 | /** | 784 | /** |
785 | Parse full email address. The result is given back in fullName and email. | 785 | Parse full email address. The result is given back in fullName and email. |
786 | */ | 786 | */ |
787 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, | 787 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, |
788 | QString &email ); | 788 | QString &email ); |
789 | 789 | ||
790 | /** | 790 | /** |
791 | Debug output. | 791 | Debug output. |
792 | */ | 792 | */ |
793 | void dump() const; | 793 | void dump() const; |
794 | 794 | ||
795 | /** | 795 | /** |
796 | Returns string representation of the addressee. | 796 | Returns string representation of the addressee. |
797 | */ | 797 | */ |
798 | QString asString() const; | 798 | QString asString() const; |
799 | 799 | ||
800 | /** | 800 | /** |
801 | Set resource where the addressee is from. | 801 | Set resource where the addressee is from. |
802 | */ | 802 | */ |
803 | void setResource( Resource *resource ); | 803 | void setResource( Resource *resource ); |
804 | 804 | ||
805 | /** | 805 | /** |
806 | Return pointer to resource. | 806 | Return pointer to resource. |
807 | */ | 807 | */ |
808 | Resource *resource() const; | 808 | Resource *resource() const; |
809 | 809 | ||
810 | /** | 810 | /** |
811 | Return resourcelabel. | 811 | Return resourcelabel. |
812 | */ | 812 | */ |
813 | //US | 813 | //US |
814 | static QString resourceLabel(); | 814 | static QString resourceLabel(); |
815 | 815 | ||
816 | /** | 816 | /** |
817 | Mark addressee as changed. | 817 | Mark addressee as changed. |
818 | */ | 818 | */ |
819 | void setChanged( bool value ); | 819 | void setChanged( bool value ); |
820 | 820 | ||
821 | /** | 821 | /** |
822 | Return whether the addressee is changed. | 822 | Return whether the addressee is changed. |
823 | */ | 823 | */ |
824 | bool changed() const; | 824 | bool changed() const; |
825 | 825 | ||
826 | private: | 826 | private: |
827 | Addressee copy(); | 827 | Addressee copy(); |
828 | void detach(); | 828 | void detach(); |
829 | int mTempSyncStat; | ||
830 | 829 | ||
831 | struct AddresseeData; | 830 | struct AddresseeData; |
832 | mutable KSharedPtr<AddresseeData> mData; | 831 | mutable KSharedPtr<AddresseeData> mData; |
833 | }; | 832 | }; |
834 | 833 | ||
835 | QDataStream &operator<<( QDataStream &, const Addressee & ); | 834 | QDataStream &operator<<( QDataStream &, const Addressee & ); |
836 | QDataStream &operator>>( QDataStream &, Addressee & ); | 835 | QDataStream &operator>>( QDataStream &, Addressee & ); |
837 | 836 | ||
838 | } | 837 | } |
839 | 838 | ||
840 | #endif | 839 | #endif |
diff --git a/kabc/stdaddressbook.cpp b/kabc/stdaddressbook.cpp index ec47a4e..181a09e 100644 --- a/kabc/stdaddressbook.cpp +++ b/kabc/stdaddressbook.cpp | |||
@@ -1,224 +1,229 @@ | |||
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 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include "resource.h" | 29 | #include "resource.h" |
30 | #include <kresources/manager.h> | 30 | #include <kresources/manager.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <klocale.h> | 32 | #include <klocale.h> |
33 | #include <kstaticdeleter.h> | 33 | #include <kstaticdeleter.h> |
34 | #include <kstandarddirs.h> | 34 | #include <kstandarddirs.h> |
35 | 35 | ||
36 | #include "stdaddressbook.h" | 36 | #include "stdaddressbook.h" |
37 | 37 | ||
38 | using namespace KABC; | 38 | using namespace KABC; |
39 | 39 | ||
40 | StdAddressBook *StdAddressBook::mSelf = 0; | 40 | StdAddressBook *StdAddressBook::mSelf = 0; |
41 | bool StdAddressBook::mAutomaticSave = true; | 41 | bool StdAddressBook::mAutomaticSave = true; |
42 | 42 | ||
43 | static KStaticDeleter<StdAddressBook> addressBookDeleter; | 43 | static KStaticDeleter<StdAddressBook> addressBookDeleter; |
44 | 44 | ||
45 | QString StdAddressBook::fileName() | 45 | QString StdAddressBook::fileName() |
46 | { | 46 | { |
47 | return locateLocal( "data", "kabc/std.vcf" ); | 47 | return locateLocal( "data", "kabc/std.vcf" ); |
48 | } | 48 | } |
49 | 49 | ||
50 | QString StdAddressBook::directoryName() | 50 | QString StdAddressBook::directoryName() |
51 | { | 51 | { |
52 | return locateLocal( "data", "kabc/stdvcf" ); | 52 | return locateLocal( "data", "kabc/stdvcf" ); |
53 | } | 53 | } |
54 | 54 | ||
55 | void StdAddressBook::handleCrash() | 55 | void StdAddressBook::handleCrash() |
56 | { | 56 | { |
57 | StdAddressBook::self()->cleanUp(); | 57 | StdAddressBook::self()->cleanUp(); |
58 | } | 58 | } |
59 | 59 | ||
60 | StdAddressBook *StdAddressBook::self() | 60 | StdAddressBook *StdAddressBook::self() |
61 | { | 61 | { |
62 | 62 | ||
63 | if ( !mSelf ) | 63 | if ( !mSelf ) |
64 | { | 64 | { |
65 | QString appdir = StdAddressBook::setTempAppDir(); | 65 | QString appdir = StdAddressBook::setTempAppDir(); |
66 | // US im am not sure why I have to use the other format here?? | 66 | // US im am not sure why I have to use the other format here?? |
67 | #ifdef KAB_EMBEDDED | 67 | #ifdef KAB_EMBEDDED |
68 | mSelf = addressBookDeleter.setObject( new StdAddressBook ); | 68 | mSelf = addressBookDeleter.setObject( new StdAddressBook ); |
69 | #else //KAB_EMBEDDED | 69 | #else //KAB_EMBEDDED |
70 | addressBookDeleter.setObject( mSelf, new StdAddressBook ); | 70 | addressBookDeleter.setObject( mSelf, new StdAddressBook ); |
71 | #endif //KAB_EMBEDDED | 71 | #endif //KAB_EMBEDDED |
72 | KStandardDirs::setAppDir( appdir ); | 72 | KStandardDirs::setAppDir( appdir ); |
73 | } | 73 | } |
74 | 74 | ||
75 | return mSelf; | 75 | return mSelf; |
76 | } | 76 | } |
77 | 77 | ||
78 | QString StdAddressBook::setTempAppDir() | 78 | QString StdAddressBook::setTempAppDir() |
79 | { | 79 | { |
80 | QString appDIR = KStandardDirs::appDir(); | 80 | QString appDIR = KStandardDirs::appDir(); |
81 | #ifdef DESKTOP_VERSION | 81 | #ifdef DESKTOP_VERSION |
82 | QString appdir = QDir::homeDirPath(); | 82 | QString appdir = QDir::homeDirPath(); |
83 | if ( appdir.right(1) == "\\" || appdir.right(1) == "/" ) | 83 | if ( appdir.right(1) == "\\" || appdir.right(1) == "/" ) |
84 | appdir += "kaddressbook/"; | 84 | appdir += "kaddressbook/"; |
85 | else | 85 | else |
86 | appdir += "/kaddressbook/"; | 86 | appdir += "/kaddressbook/"; |
87 | KStandardDirs::setAppDir( QDir::convertSeparators( appdir )); | 87 | KStandardDirs::setAppDir( QDir::convertSeparators( appdir )); |
88 | #else | 88 | #else |
89 | QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook"; | 89 | QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook"; |
90 | 90 | ||
91 | KStandardDirs::setAppDir( appdir ); | 91 | KStandardDirs::setAppDir( appdir ); |
92 | #endif | 92 | #endif |
93 | 93 | ||
94 | return appDIR; | 94 | return appDIR; |
95 | } | 95 | } |
96 | StdAddressBook *StdAddressBook::self( bool onlyFastResources ) | 96 | StdAddressBook *StdAddressBook::self( bool onlyFastResources ) |
97 | { | 97 | { |
98 | 98 | ||
99 | if ( !mSelf ) | 99 | if ( !mSelf ) |
100 | { | 100 | { |
101 | QString appdir =StdAddressBook::setTempAppDir(); | 101 | QString appdir =StdAddressBook::setTempAppDir(); |
102 | #ifdef KAB_EMBEDDED | 102 | #ifdef KAB_EMBEDDED |
103 | mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) ); | 103 | mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) ); |
104 | #else //KAB_EMBEDDED | 104 | #else //KAB_EMBEDDED |
105 | addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) ); | 105 | addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) ); |
106 | #endif //KAB_EMBEDDED | 106 | #endif //KAB_EMBEDDED |
107 | KStandardDirs::setAppDir( appdir ); | 107 | KStandardDirs::setAppDir( appdir ); |
108 | } | 108 | } |
109 | return mSelf; | 109 | return mSelf; |
110 | } | 110 | } |
111 | 111 | ||
112 | StdAddressBook::StdAddressBook() | 112 | StdAddressBook::StdAddressBook() |
113 | : AddressBook( "kabcrc" ) | 113 | : AddressBook( "kabcrc" ) |
114 | { | 114 | { |
115 | 115 | ||
116 | init( false ); | 116 | init( false ); |
117 | } | 117 | } |
118 | 118 | ||
119 | StdAddressBook::StdAddressBook( bool onlyFastResources ) | 119 | StdAddressBook::StdAddressBook( bool onlyFastResources ) |
120 | : AddressBook( "kabcrc" ) | 120 | : AddressBook( "kabcrc" ) |
121 | { | 121 | { |
122 | 122 | ||
123 | init( onlyFastResources ); | 123 | init( onlyFastResources ); |
124 | } | 124 | } |
125 | 125 | ||
126 | StdAddressBook::~StdAddressBook() | 126 | StdAddressBook::~StdAddressBook() |
127 | { | 127 | { |
128 | if ( mAutomaticSave ) | 128 | if ( mAutomaticSave ) |
129 | save(); | 129 | save(); |
130 | } | 130 | } |
131 | 131 | ||
132 | void StdAddressBook::init( bool ) | 132 | void StdAddressBook::init( bool ) |
133 | { | 133 | { |
134 | KRES::Manager<Resource> *manager = resourceManager(); | 134 | KRES::Manager<Resource> *manager = resourceManager(); |
135 | KRES::Manager<Resource>::ActiveIterator it; | 135 | KRES::Manager<Resource>::ActiveIterator it; |
136 | 136 | ||
137 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 137 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
138 | (*it)->setAddressBook( this ); | 138 | (*it)->setAddressBook( this ); |
139 | if ( !(*it)->open() ) | 139 | if ( !(*it)->open() ) |
140 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 140 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
141 | } | 141 | } |
142 | 142 | ||
143 | Resource *res = standardResource(); | 143 | Resource *res = standardResource(); |
144 | if ( !res ) { | 144 | if ( !res ) { |
145 | res = manager->createResource( "file" ); | 145 | res = manager->createResource( "file" ); |
146 | if ( res ) | 146 | if ( res ) |
147 | { | 147 | { |
148 | addResource( res ); | 148 | addResource( res ); |
149 | } | 149 | } |
150 | else | 150 | else |
151 | qDebug(" No resource available!!!"); | 151 | qDebug(" No resource available!!!"); |
152 | } | 152 | } |
153 | 153 | ||
154 | setStandardResource( res ); | 154 | setStandardResource( res ); |
155 | manager->writeConfig(); | 155 | manager->writeConfig(); |
156 | 156 | ||
157 | load(); | 157 | load(); |
158 | } | 158 | } |
159 | 159 | ||
160 | bool StdAddressBook::save() | 160 | bool StdAddressBook::save() |
161 | { | 161 | { |
162 | kdDebug(5700) << "StdAddressBook::save()" << endl; | 162 | kdDebug(5700) << "StdAddressBook::save()" << endl; |
163 | 163 | ||
164 | bool ok = true; | 164 | bool ok = true; |
165 | AddressBook *ab = self(); | 165 | AddressBook *ab = self(); |
166 | 166 | ||
167 | ab->deleteRemovedAddressees(); | 167 | ab->deleteRemovedAddressees(); |
168 | 168 | Iterator ait; | |
169 | for ( ait = ab->begin(); ait != ab->end(); ++ait ) { | ||
170 | if ( !(*ait).IDStr().isEmpty() ) { | ||
171 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | ||
172 | } | ||
173 | } | ||
169 | KRES::Manager<Resource>::ActiveIterator it; | 174 | KRES::Manager<Resource>::ActiveIterator it; |
170 | KRES::Manager<Resource> *manager = ab->resourceManager(); | 175 | KRES::Manager<Resource> *manager = ab->resourceManager(); |
171 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 176 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
172 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 177 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
173 | Ticket *ticket = ab->requestSaveTicket( *it ); | 178 | Ticket *ticket = ab->requestSaveTicket( *it ); |
174 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 179 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
175 | if ( !ticket ) { | 180 | if ( !ticket ) { |
176 | ab->error( i18n( "Unable to save to resource '%1'. It is locked." ) | 181 | ab->error( i18n( "Unable to save to resource '%1'. It is locked." ) |
177 | .arg( (*it)->resourceName() ) ); | 182 | .arg( (*it)->resourceName() ) ); |
178 | return false; | 183 | return false; |
179 | } | 184 | } |
180 | 185 | ||
181 | if ( !ab->save( ticket ) ) | 186 | if ( !ab->save( ticket ) ) |
182 | ok = false; | 187 | ok = false; |
183 | } | 188 | } |
184 | } | 189 | } |
185 | 190 | ||
186 | return ok; | 191 | return ok; |
187 | } | 192 | } |
188 | 193 | ||
189 | void StdAddressBook::close() | 194 | void StdAddressBook::close() |
190 | { | 195 | { |
191 | //US destructObject is not defined on my system???. Is setObject(0) the same ??? | 196 | //US destructObject is not defined on my system???. Is setObject(0) the same ??? |
192 | //US addressBookDeleter.destructObject(); | 197 | //US addressBookDeleter.destructObject(); |
193 | addressBookDeleter.setObject(0); | 198 | addressBookDeleter.setObject(0); |
194 | 199 | ||
195 | } | 200 | } |
196 | 201 | ||
197 | void StdAddressBook::setAutomaticSave( bool enable ) | 202 | void StdAddressBook::setAutomaticSave( bool enable ) |
198 | { | 203 | { |
199 | mAutomaticSave = enable; | 204 | mAutomaticSave = enable; |
200 | } | 205 | } |
201 | 206 | ||
202 | bool StdAddressBook::automaticSave() | 207 | bool StdAddressBook::automaticSave() |
203 | { | 208 | { |
204 | return mAutomaticSave; | 209 | return mAutomaticSave; |
205 | } | 210 | } |
206 | 211 | ||
207 | // should get const for 4.X | 212 | // should get const for 4.X |
208 | Addressee StdAddressBook::whoAmI() | 213 | Addressee StdAddressBook::whoAmI() |
209 | { | 214 | { |
210 | //US KConfig config( "kabcrc" ); | 215 | //US KConfig config( "kabcrc" ); |
211 | KConfig config( locateLocal("config", "kabcrc") ); | 216 | KConfig config( locateLocal("config", "kabcrc") ); |
212 | config.setGroup( "General" ); | 217 | config.setGroup( "General" ); |
213 | 218 | ||
214 | return findByUid( config.readEntry( "WhoAmI" ) ); | 219 | return findByUid( config.readEntry( "WhoAmI" ) ); |
215 | } | 220 | } |
216 | 221 | ||
217 | void StdAddressBook::setWhoAmI( const Addressee &addr ) | 222 | void StdAddressBook::setWhoAmI( const Addressee &addr ) |
218 | { | 223 | { |
219 | //US KConfig config( "kabcrc" ); | 224 | //US KConfig config( "kabcrc" ); |
220 | KConfig config( locateLocal("config", "kabcrc") ); | 225 | KConfig config( locateLocal("config", "kabcrc") ); |
221 | config.setGroup( "General" ); | 226 | config.setGroup( "General" ); |
222 | 227 | ||
223 | config.writeEntry( "WhoAmI", addr.uid() ); | 228 | config.writeEntry( "WhoAmI", addr.uid() ); |
224 | } | 229 | } |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 8776b53..56f6af2 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -993,2029 +993,2030 @@ void KABCore::importVCard( const KURL &url, bool showPreview ) | |||
993 | { | 993 | { |
994 | mXXPortManager->importVCard( url, showPreview ); | 994 | mXXPortManager->importVCard( url, showPreview ); |
995 | } | 995 | } |
996 | void KABCore::importFromOL() | 996 | void KABCore::importFromOL() |
997 | { | 997 | { |
998 | #ifdef _WIN32_ | 998 | #ifdef _WIN32_ |
999 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 999 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1000 | idgl->exec(); | 1000 | idgl->exec(); |
1001 | KABC::Addressee::List list = idgl->getAddressList(); | 1001 | KABC::Addressee::List list = idgl->getAddressList(); |
1002 | if ( list.count() > 0 ) { | 1002 | if ( list.count() > 0 ) { |
1003 | KABC::Addressee::List listNew; | 1003 | KABC::Addressee::List listNew; |
1004 | KABC::Addressee::List listExisting; | 1004 | KABC::Addressee::List listExisting; |
1005 | KABC::Addressee::List::Iterator it; | 1005 | KABC::Addressee::List::Iterator it; |
1006 | KABC::AddressBook::Iterator iter; | 1006 | KABC::AddressBook::Iterator iter; |
1007 | for ( it = list.begin(); it != list.end(); ++it ) { | 1007 | for ( it = list.begin(); it != list.end(); ++it ) { |
1008 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1008 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1009 | listNew.append( (*it) ); | 1009 | listNew.append( (*it) ); |
1010 | else | 1010 | else |
1011 | listExisting.append( (*it) ); | 1011 | listExisting.append( (*it) ); |
1012 | } | 1012 | } |
1013 | if ( listExisting.count() > 0 ) | 1013 | if ( listExisting.count() > 0 ) |
1014 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1014 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1015 | if ( listNew.count() > 0 ) { | 1015 | if ( listNew.count() > 0 ) { |
1016 | pasteWithNewUid = false; | 1016 | pasteWithNewUid = false; |
1017 | pasteContacts( listNew ); | 1017 | pasteContacts( listNew ); |
1018 | pasteWithNewUid = true; | 1018 | pasteWithNewUid = true; |
1019 | } | 1019 | } |
1020 | } | 1020 | } |
1021 | delete idgl; | 1021 | delete idgl; |
1022 | #endif | 1022 | #endif |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1025 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1026 | { | 1026 | { |
1027 | mXXPortManager->importVCard( vCard, showPreview ); | 1027 | mXXPortManager->importVCard( vCard, showPreview ); |
1028 | } | 1028 | } |
1029 | 1029 | ||
1030 | //US added a second method without defaultparameter | 1030 | //US added a second method without defaultparameter |
1031 | void KABCore::editContact2() { | 1031 | void KABCore::editContact2() { |
1032 | editContact( QString::null ); | 1032 | editContact( QString::null ); |
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | void KABCore::editContact( const QString &uid ) | 1035 | void KABCore::editContact( const QString &uid ) |
1036 | { | 1036 | { |
1037 | 1037 | ||
1038 | if ( mExtensionManager->isQuickEditVisible() ) | 1038 | if ( mExtensionManager->isQuickEditVisible() ) |
1039 | return; | 1039 | return; |
1040 | 1040 | ||
1041 | // First, locate the contact entry | 1041 | // First, locate the contact entry |
1042 | QString localUID = uid; | 1042 | QString localUID = uid; |
1043 | if ( localUID.isNull() ) { | 1043 | if ( localUID.isNull() ) { |
1044 | QStringList uidList = mViewManager->selectedUids(); | 1044 | QStringList uidList = mViewManager->selectedUids(); |
1045 | if ( uidList.count() > 0 ) | 1045 | if ( uidList.count() > 0 ) |
1046 | localUID = *( uidList.at( 0 ) ); | 1046 | localUID = *( uidList.at( 0 ) ); |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1049 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1050 | if ( !addr.isEmpty() ) { | 1050 | if ( !addr.isEmpty() ) { |
1051 | mEditorDialog->setAddressee( addr ); | 1051 | mEditorDialog->setAddressee( addr ); |
1052 | KApplication::execDialog ( mEditorDialog ); | 1052 | KApplication::execDialog ( mEditorDialog ); |
1053 | } | 1053 | } |
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | /** | 1056 | /** |
1057 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1057 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1058 | the method will try to find a selected addressee in the view. | 1058 | the method will try to find a selected addressee in the view. |
1059 | */ | 1059 | */ |
1060 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1060 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1061 | { | 1061 | { |
1062 | if ( mMultipleViewsAtOnce ) | 1062 | if ( mMultipleViewsAtOnce ) |
1063 | { | 1063 | { |
1064 | editContact( uid ); | 1064 | editContact( uid ); |
1065 | } | 1065 | } |
1066 | else | 1066 | else |
1067 | { | 1067 | { |
1068 | setDetailsVisible( true ); | 1068 | setDetailsVisible( true ); |
1069 | mActionDetails->setChecked(true); | 1069 | mActionDetails->setChecked(true); |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | } | 1072 | } |
1073 | 1073 | ||
1074 | void KABCore::save() | 1074 | void KABCore::save() |
1075 | { | 1075 | { |
1076 | if (mBlockSaveFlag) | 1076 | if (mBlockSaveFlag) |
1077 | return; | 1077 | return; |
1078 | mBlockSaveFlag = true; | 1078 | mBlockSaveFlag = true; |
1079 | if ( !mModified ) | 1079 | if ( !mModified ) |
1080 | return; | 1080 | return; |
1081 | QString text = i18n( "There was an error while attempting to save\n the " | 1081 | QString text = i18n( "There was an error while attempting to save\n the " |
1082 | "address book. Please check that some \nother application is " | 1082 | "address book. Please check that some \nother application is " |
1083 | "not using it. " ); | 1083 | "not using it. " ); |
1084 | statusMessage(i18n("Saving addressbook ... ")); | 1084 | statusMessage(i18n("Saving addressbook ... ")); |
1085 | #ifndef KAB_EMBEDDED | 1085 | #ifndef KAB_EMBEDDED |
1086 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1086 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1087 | if ( !b || !b->save() ) { | 1087 | if ( !b || !b->save() ) { |
1088 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1088 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1089 | } | 1089 | } |
1090 | #else //KAB_EMBEDDED | 1090 | #else //KAB_EMBEDDED |
1091 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1091 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1092 | if ( !b || !b->save() ) { | 1092 | if ( !b || !b->save() ) { |
1093 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1093 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1094 | } | 1094 | } |
1095 | #endif //KAB_EMBEDDED | 1095 | #endif //KAB_EMBEDDED |
1096 | 1096 | ||
1097 | statusMessage(i18n("Addressbook saved!")); | 1097 | statusMessage(i18n("Addressbook saved!")); |
1098 | setModified( false ); | 1098 | setModified( false ); |
1099 | mBlockSaveFlag = false; | 1099 | mBlockSaveFlag = false; |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | void KABCore::statusMessage(QString mess , int time ) | 1102 | void KABCore::statusMessage(QString mess , int time ) |
1103 | { | 1103 | { |
1104 | //topLevelWidget()->setCaption( mess ); | 1104 | //topLevelWidget()->setCaption( mess ); |
1105 | // pending setting timer to revome message | 1105 | // pending setting timer to revome message |
1106 | } | 1106 | } |
1107 | void KABCore::undo() | 1107 | void KABCore::undo() |
1108 | { | 1108 | { |
1109 | UndoStack::instance()->undo(); | 1109 | UndoStack::instance()->undo(); |
1110 | 1110 | ||
1111 | // Refresh the view | 1111 | // Refresh the view |
1112 | mViewManager->refreshView(); | 1112 | mViewManager->refreshView(); |
1113 | } | 1113 | } |
1114 | 1114 | ||
1115 | void KABCore::redo() | 1115 | void KABCore::redo() |
1116 | { | 1116 | { |
1117 | RedoStack::instance()->redo(); | 1117 | RedoStack::instance()->redo(); |
1118 | 1118 | ||
1119 | // Refresh the view | 1119 | // Refresh the view |
1120 | mViewManager->refreshView(); | 1120 | mViewManager->refreshView(); |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1123 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1124 | { | 1124 | { |
1125 | if (mMultipleViewsAtOnce) | 1125 | if (mMultipleViewsAtOnce) |
1126 | { | 1126 | { |
1127 | if ( visible ) | 1127 | if ( visible ) |
1128 | mJumpButtonBar->show(); | 1128 | mJumpButtonBar->show(); |
1129 | else | 1129 | else |
1130 | mJumpButtonBar->hide(); | 1130 | mJumpButtonBar->hide(); |
1131 | } | 1131 | } |
1132 | else | 1132 | else |
1133 | { | 1133 | { |
1134 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1134 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1135 | if (mViewManager->isVisible()) | 1135 | if (mViewManager->isVisible()) |
1136 | { | 1136 | { |
1137 | if ( visible ) | 1137 | if ( visible ) |
1138 | mJumpButtonBar->show(); | 1138 | mJumpButtonBar->show(); |
1139 | else | 1139 | else |
1140 | mJumpButtonBar->hide(); | 1140 | mJumpButtonBar->hide(); |
1141 | } | 1141 | } |
1142 | else | 1142 | else |
1143 | { | 1143 | { |
1144 | mJumpButtonBar->hide(); | 1144 | mJumpButtonBar->hide(); |
1145 | } | 1145 | } |
1146 | } | 1146 | } |
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | 1149 | ||
1150 | void KABCore::setDetailsToState() | 1150 | void KABCore::setDetailsToState() |
1151 | { | 1151 | { |
1152 | setDetailsVisible( mActionDetails->isChecked() ); | 1152 | setDetailsVisible( mActionDetails->isChecked() ); |
1153 | } | 1153 | } |
1154 | 1154 | ||
1155 | 1155 | ||
1156 | 1156 | ||
1157 | void KABCore::setDetailsVisible( bool visible ) | 1157 | void KABCore::setDetailsVisible( bool visible ) |
1158 | { | 1158 | { |
1159 | if (visible && mDetails->isHidden()) | 1159 | if (visible && mDetails->isHidden()) |
1160 | { | 1160 | { |
1161 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1161 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1162 | if ( addrList.count() > 0 ) | 1162 | if ( addrList.count() > 0 ) |
1163 | mDetails->setAddressee( addrList[ 0 ] ); | 1163 | mDetails->setAddressee( addrList[ 0 ] ); |
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1166 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1167 | // the listview and the detailview. We do that by changing the splitbar size. | 1167 | // the listview and the detailview. We do that by changing the splitbar size. |
1168 | if (mMultipleViewsAtOnce) | 1168 | if (mMultipleViewsAtOnce) |
1169 | { | 1169 | { |
1170 | if ( visible ) | 1170 | if ( visible ) |
1171 | mDetails->show(); | 1171 | mDetails->show(); |
1172 | else | 1172 | else |
1173 | mDetails->hide(); | 1173 | mDetails->hide(); |
1174 | } | 1174 | } |
1175 | else | 1175 | else |
1176 | { | 1176 | { |
1177 | if ( visible ) { | 1177 | if ( visible ) { |
1178 | mViewManager->hide(); | 1178 | mViewManager->hide(); |
1179 | mDetails->show(); | 1179 | mDetails->show(); |
1180 | } | 1180 | } |
1181 | else { | 1181 | else { |
1182 | mViewManager->show(); | 1182 | mViewManager->show(); |
1183 | mDetails->hide(); | 1183 | mDetails->hide(); |
1184 | } | 1184 | } |
1185 | setJumpButtonBarVisible( !visible ); | 1185 | setJumpButtonBarVisible( !visible ); |
1186 | } | 1186 | } |
1187 | 1187 | ||
1188 | } | 1188 | } |
1189 | 1189 | ||
1190 | void KABCore::extensionChanged( int id ) | 1190 | void KABCore::extensionChanged( int id ) |
1191 | { | 1191 | { |
1192 | //change the details view only for non desktop systems | 1192 | //change the details view only for non desktop systems |
1193 | #ifndef DESKTOP_VERSION | 1193 | #ifndef DESKTOP_VERSION |
1194 | 1194 | ||
1195 | if (id == 0) | 1195 | if (id == 0) |
1196 | { | 1196 | { |
1197 | //the user disabled the extension. | 1197 | //the user disabled the extension. |
1198 | 1198 | ||
1199 | if (mMultipleViewsAtOnce) | 1199 | if (mMultipleViewsAtOnce) |
1200 | { // enable detailsview again | 1200 | { // enable detailsview again |
1201 | setDetailsVisible( true ); | 1201 | setDetailsVisible( true ); |
1202 | mActionDetails->setChecked( true ); | 1202 | mActionDetails->setChecked( true ); |
1203 | } | 1203 | } |
1204 | else | 1204 | else |
1205 | { //go back to the listview | 1205 | { //go back to the listview |
1206 | setDetailsVisible( false ); | 1206 | setDetailsVisible( false ); |
1207 | mActionDetails->setChecked( false ); | 1207 | mActionDetails->setChecked( false ); |
1208 | mActionDetails->setEnabled(true); | 1208 | mActionDetails->setEnabled(true); |
1209 | } | 1209 | } |
1210 | 1210 | ||
1211 | } | 1211 | } |
1212 | else | 1212 | else |
1213 | { | 1213 | { |
1214 | //the user enabled the extension. | 1214 | //the user enabled the extension. |
1215 | setDetailsVisible( false ); | 1215 | setDetailsVisible( false ); |
1216 | mActionDetails->setChecked( false ); | 1216 | mActionDetails->setChecked( false ); |
1217 | 1217 | ||
1218 | if (!mMultipleViewsAtOnce) | 1218 | if (!mMultipleViewsAtOnce) |
1219 | { | 1219 | { |
1220 | mActionDetails->setEnabled(false); | 1220 | mActionDetails->setEnabled(false); |
1221 | } | 1221 | } |
1222 | 1222 | ||
1223 | mExtensionManager->setSelectionChanged(); | 1223 | mExtensionManager->setSelectionChanged(); |
1224 | 1224 | ||
1225 | } | 1225 | } |
1226 | 1226 | ||
1227 | #endif// DESKTOP_VERSION | 1227 | #endif// DESKTOP_VERSION |
1228 | 1228 | ||
1229 | } | 1229 | } |
1230 | 1230 | ||
1231 | 1231 | ||
1232 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1232 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1233 | { | 1233 | { |
1234 | 1234 | ||
1235 | if ( list.count() != 0 ) { | 1235 | if ( list.count() != 0 ) { |
1236 | KABC::Addressee::List::ConstIterator it; | 1236 | KABC::Addressee::List::ConstIterator it; |
1237 | for ( it = list.begin(); it != list.end(); ++it ) | 1237 | for ( it = list.begin(); it != list.end(); ++it ) |
1238 | mAddressBook->insertAddressee( *it ); | 1238 | mAddressBook->insertAddressee( *it ); |
1239 | if ( list.count() > 1 ) | 1239 | if ( list.count() > 1 ) |
1240 | setModified(); | 1240 | setModified(); |
1241 | else | 1241 | else |
1242 | setModifiedWOrefresh(); | 1242 | setModifiedWOrefresh(); |
1243 | } | 1243 | } |
1244 | if ( list.count() == 0 ) | 1244 | if ( list.count() == 0 ) |
1245 | mViewManager->refreshView(); | 1245 | mViewManager->refreshView(); |
1246 | else | 1246 | else |
1247 | mViewManager->refreshView( list[ 0 ].uid() ); | 1247 | mViewManager->refreshView( list[ 0 ].uid() ); |
1248 | 1248 | ||
1249 | 1249 | ||
1250 | 1250 | ||
1251 | } | 1251 | } |
1252 | 1252 | ||
1253 | QString KABCore::getNameByPhone( const QString &phone ) | 1253 | QString KABCore::getNameByPhone( const QString &phone ) |
1254 | { | 1254 | { |
1255 | #ifndef KAB_EMBEDDED | 1255 | #ifndef KAB_EMBEDDED |
1256 | QRegExp r( "[/*/-/ ]" ); | 1256 | QRegExp r( "[/*/-/ ]" ); |
1257 | QString localPhone( phone ); | 1257 | QString localPhone( phone ); |
1258 | 1258 | ||
1259 | bool found = false; | 1259 | bool found = false; |
1260 | QString ownerName = ""; | 1260 | QString ownerName = ""; |
1261 | KABC::AddressBook::Iterator iter; | 1261 | KABC::AddressBook::Iterator iter; |
1262 | KABC::PhoneNumber::List::Iterator phoneIter; | 1262 | KABC::PhoneNumber::List::Iterator phoneIter; |
1263 | KABC::PhoneNumber::List phoneList; | 1263 | KABC::PhoneNumber::List phoneList; |
1264 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1264 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1265 | phoneList = (*iter).phoneNumbers(); | 1265 | phoneList = (*iter).phoneNumbers(); |
1266 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1266 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1267 | ++phoneIter) { | 1267 | ++phoneIter) { |
1268 | // Get rid of separator chars so just the numbers are compared. | 1268 | // Get rid of separator chars so just the numbers are compared. |
1269 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1269 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1270 | ownerName = (*iter).formattedName(); | 1270 | ownerName = (*iter).formattedName(); |
1271 | found = true; | 1271 | found = true; |
1272 | } | 1272 | } |
1273 | } | 1273 | } |
1274 | } | 1274 | } |
1275 | 1275 | ||
1276 | return ownerName; | 1276 | return ownerName; |
1277 | #else //KAB_EMBEDDED | 1277 | #else //KAB_EMBEDDED |
1278 | qDebug("KABCore::getNameByPhone finsih method"); | 1278 | qDebug("KABCore::getNameByPhone finsih method"); |
1279 | return ""; | 1279 | return ""; |
1280 | #endif //KAB_EMBEDDED | 1280 | #endif //KAB_EMBEDDED |
1281 | 1281 | ||
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | void KABCore::openConfigDialog() | 1284 | void KABCore::openConfigDialog() |
1285 | { | 1285 | { |
1286 | KABPrefs* kab_prefs = KABPrefs::instance(); | 1286 | KABPrefs* kab_prefs = KABPrefs::instance(); |
1287 | KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); | 1287 | KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); |
1288 | 1288 | ||
1289 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1289 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1290 | KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1290 | KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1291 | ConfigureDialog->addModule(kabcfg ); | 1291 | ConfigureDialog->addModule(kabcfg ); |
1292 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1292 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1293 | ConfigureDialog->addModule(kdelibcfg ); | 1293 | ConfigureDialog->addModule(kdelibcfg ); |
1294 | 1294 | ||
1295 | 1295 | ||
1296 | 1296 | ||
1297 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1297 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1298 | this, SLOT( configurationChanged() ) ); | 1298 | this, SLOT( configurationChanged() ) ); |
1299 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1299 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1300 | this, SLOT( configurationChanged() ) ); | 1300 | this, SLOT( configurationChanged() ) ); |
1301 | saveSettings(); | 1301 | saveSettings(); |
1302 | #ifndef DESKTOP_VERSION | 1302 | #ifndef DESKTOP_VERSION |
1303 | ConfigureDialog->showMaximized(); | 1303 | ConfigureDialog->showMaximized(); |
1304 | #endif | 1304 | #endif |
1305 | if ( ConfigureDialog->exec() ) | 1305 | if ( ConfigureDialog->exec() ) |
1306 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1306 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1307 | delete ConfigureDialog; | 1307 | delete ConfigureDialog; |
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | void KABCore::openLDAPDialog() | 1310 | void KABCore::openLDAPDialog() |
1311 | { | 1311 | { |
1312 | #ifndef KAB_EMBEDDED | 1312 | #ifndef KAB_EMBEDDED |
1313 | if ( !mLdapSearchDialog ) { | 1313 | if ( !mLdapSearchDialog ) { |
1314 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1314 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1315 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1315 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1316 | SLOT( refreshView() ) ); | 1316 | SLOT( refreshView() ) ); |
1317 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1317 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1318 | SLOT( setModified() ) ); | 1318 | SLOT( setModified() ) ); |
1319 | } else | 1319 | } else |
1320 | mLdapSearchDialog->restoreSettings(); | 1320 | mLdapSearchDialog->restoreSettings(); |
1321 | 1321 | ||
1322 | if ( mLdapSearchDialog->isOK() ) | 1322 | if ( mLdapSearchDialog->isOK() ) |
1323 | mLdapSearchDialog->exec(); | 1323 | mLdapSearchDialog->exec(); |
1324 | #else //KAB_EMBEDDED | 1324 | #else //KAB_EMBEDDED |
1325 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1325 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1326 | #endif //KAB_EMBEDDED | 1326 | #endif //KAB_EMBEDDED |
1327 | } | 1327 | } |
1328 | 1328 | ||
1329 | void KABCore::print() | 1329 | void KABCore::print() |
1330 | { | 1330 | { |
1331 | #ifndef KAB_EMBEDDED | 1331 | #ifndef KAB_EMBEDDED |
1332 | KPrinter printer; | 1332 | KPrinter printer; |
1333 | if ( !printer.setup( this ) ) | 1333 | if ( !printer.setup( this ) ) |
1334 | return; | 1334 | return; |
1335 | 1335 | ||
1336 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1336 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1337 | mViewManager->selectedUids(), this ); | 1337 | mViewManager->selectedUids(), this ); |
1338 | 1338 | ||
1339 | wizard.exec(); | 1339 | wizard.exec(); |
1340 | #else //KAB_EMBEDDED | 1340 | #else //KAB_EMBEDDED |
1341 | qDebug("KABCore::print() finsih method"); | 1341 | qDebug("KABCore::print() finsih method"); |
1342 | #endif //KAB_EMBEDDED | 1342 | #endif //KAB_EMBEDDED |
1343 | 1343 | ||
1344 | } | 1344 | } |
1345 | 1345 | ||
1346 | 1346 | ||
1347 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1347 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1348 | { | 1348 | { |
1349 | if ( mGUIClient ) | 1349 | if ( mGUIClient ) |
1350 | mGUIClient->insertChildClient( client ); | 1350 | mGUIClient->insertChildClient( client ); |
1351 | else | 1351 | else |
1352 | KMessageBox::error( this, "no KXMLGUICLient"); | 1352 | KMessageBox::error( this, "no KXMLGUICLient"); |
1353 | } | 1353 | } |
1354 | 1354 | ||
1355 | 1355 | ||
1356 | void KABCore::configurationChanged() | 1356 | void KABCore::configurationChanged() |
1357 | { | 1357 | { |
1358 | mExtensionManager->reconfigure(); | 1358 | mExtensionManager->reconfigure(); |
1359 | } | 1359 | } |
1360 | 1360 | ||
1361 | void KABCore::addressBookChanged() | 1361 | void KABCore::addressBookChanged() |
1362 | { | 1362 | { |
1363 | /*US | 1363 | /*US |
1364 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1364 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1365 | while ( it.current() ) { | 1365 | while ( it.current() ) { |
1366 | if ( it.current()->dirty() ) { | 1366 | if ( it.current()->dirty() ) { |
1367 | QString text = i18n( "Data has been changed externally. Unsaved " | 1367 | QString text = i18n( "Data has been changed externally. Unsaved " |
1368 | "changes will be lost." ); | 1368 | "changes will be lost." ); |
1369 | KMessageBox::information( this, text ); | 1369 | KMessageBox::information( this, text ); |
1370 | } | 1370 | } |
1371 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1371 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1372 | ++it; | 1372 | ++it; |
1373 | } | 1373 | } |
1374 | */ | 1374 | */ |
1375 | if (mEditorDialog) | 1375 | if (mEditorDialog) |
1376 | { | 1376 | { |
1377 | if (mEditorDialog->dirty()) | 1377 | if (mEditorDialog->dirty()) |
1378 | { | 1378 | { |
1379 | QString text = i18n( "Data has been changed externally. Unsaved " | 1379 | QString text = i18n( "Data has been changed externally. Unsaved " |
1380 | "changes will be lost." ); | 1380 | "changes will be lost." ); |
1381 | KMessageBox::information( this, text ); | 1381 | KMessageBox::information( this, text ); |
1382 | } | 1382 | } |
1383 | QString currentuid = mEditorDialog->addressee().uid(); | 1383 | QString currentuid = mEditorDialog->addressee().uid(); |
1384 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1384 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1385 | } | 1385 | } |
1386 | mViewManager->refreshView(); | 1386 | mViewManager->refreshView(); |
1387 | // mDetails->refreshView(); | 1387 | // mDetails->refreshView(); |
1388 | 1388 | ||
1389 | 1389 | ||
1390 | } | 1390 | } |
1391 | 1391 | ||
1392 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1392 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1393 | const char *name ) | 1393 | const char *name ) |
1394 | { | 1394 | { |
1395 | 1395 | ||
1396 | if ( mEditorDialog == 0 ) { | 1396 | if ( mEditorDialog == 0 ) { |
1397 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1397 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1398 | name ? name : "editorDialog" ); | 1398 | name ? name : "editorDialog" ); |
1399 | 1399 | ||
1400 | 1400 | ||
1401 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1401 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1402 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1402 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1403 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1403 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1404 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1404 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1405 | } | 1405 | } |
1406 | 1406 | ||
1407 | return mEditorDialog; | 1407 | return mEditorDialog; |
1408 | } | 1408 | } |
1409 | 1409 | ||
1410 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1410 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1411 | { | 1411 | { |
1412 | //mEditorDict.remove( uid ); | 1412 | //mEditorDict.remove( uid ); |
1413 | } | 1413 | } |
1414 | 1414 | ||
1415 | void KABCore::initGUI() | 1415 | void KABCore::initGUI() |
1416 | { | 1416 | { |
1417 | #ifndef KAB_EMBEDDED | 1417 | #ifndef KAB_EMBEDDED |
1418 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1418 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1419 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1419 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1420 | 1420 | ||
1421 | mExtensionBarSplitter = new QSplitter( this ); | 1421 | mExtensionBarSplitter = new QSplitter( this ); |
1422 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1422 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1423 | 1423 | ||
1424 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1424 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1425 | 1425 | ||
1426 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1426 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1427 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1427 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1428 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1428 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1429 | SLOT( incrementalSearch( const QString& ) ) ); | 1429 | SLOT( incrementalSearch( const QString& ) ) ); |
1430 | 1430 | ||
1431 | mViewManager = new ViewManager( this, viewSpace ); | 1431 | mViewManager = new ViewManager( this, viewSpace ); |
1432 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1432 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1433 | 1433 | ||
1434 | mDetails = new ViewContainer( mDetailsSplitter ); | 1434 | mDetails = new ViewContainer( mDetailsSplitter ); |
1435 | 1435 | ||
1436 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1436 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1437 | 1437 | ||
1438 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1438 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1439 | 1439 | ||
1440 | topLayout->addWidget( mExtensionBarSplitter ); | 1440 | topLayout->addWidget( mExtensionBarSplitter ); |
1441 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1441 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1442 | topLayout->addWidget( mJumpButtonBar ); | 1442 | topLayout->addWidget( mJumpButtonBar ); |
1443 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1443 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1444 | 1444 | ||
1445 | mXXPortManager = new XXPortManager( this, this ); | 1445 | mXXPortManager = new XXPortManager( this, this ); |
1446 | 1446 | ||
1447 | #else //KAB_EMBEDDED | 1447 | #else //KAB_EMBEDDED |
1448 | //US initialize viewMenu before settingup viewmanager. | 1448 | //US initialize viewMenu before settingup viewmanager. |
1449 | // Viewmanager needs this menu to plugin submenues. | 1449 | // Viewmanager needs this menu to plugin submenues. |
1450 | viewMenu = new QPopupMenu( this ); | 1450 | viewMenu = new QPopupMenu( this ); |
1451 | settingsMenu = new QPopupMenu( this ); | 1451 | settingsMenu = new QPopupMenu( this ); |
1452 | //filterMenu = new QPopupMenu( this ); | 1452 | //filterMenu = new QPopupMenu( this ); |
1453 | ImportMenu = new QPopupMenu( this ); | 1453 | ImportMenu = new QPopupMenu( this ); |
1454 | ExportMenu = new QPopupMenu( this ); | 1454 | ExportMenu = new QPopupMenu( this ); |
1455 | syncMenu = new QPopupMenu( this ); | 1455 | syncMenu = new QPopupMenu( this ); |
1456 | changeMenu= new QPopupMenu( this ); | 1456 | changeMenu= new QPopupMenu( this ); |
1457 | 1457 | ||
1458 | //US since we have no splitter for the embedded system, setup | 1458 | //US since we have no splitter for the embedded system, setup |
1459 | // a layout with two frames. One left and one right. | 1459 | // a layout with two frames. One left and one right. |
1460 | 1460 | ||
1461 | QBoxLayout *topLayout; | 1461 | QBoxLayout *topLayout; |
1462 | 1462 | ||
1463 | // = new QHBoxLayout( this ); | 1463 | // = new QHBoxLayout( this ); |
1464 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1464 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1465 | 1465 | ||
1466 | // QWidget *mainBox = new QWidget( this ); | 1466 | // QWidget *mainBox = new QWidget( this ); |
1467 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1467 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1468 | 1468 | ||
1469 | #ifdef DESKTOP_VERSION | 1469 | #ifdef DESKTOP_VERSION |
1470 | topLayout = new QHBoxLayout( this ); | 1470 | topLayout = new QHBoxLayout( this ); |
1471 | 1471 | ||
1472 | 1472 | ||
1473 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1473 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1474 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1474 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1475 | 1475 | ||
1476 | topLayout->addWidget(mMiniSplitter ); | 1476 | topLayout->addWidget(mMiniSplitter ); |
1477 | 1477 | ||
1478 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1478 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1479 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1479 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1480 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1480 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1481 | mDetails = new ViewContainer( mMiniSplitter ); | 1481 | mDetails = new ViewContainer( mMiniSplitter ); |
1482 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1482 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1483 | #else | 1483 | #else |
1484 | if ( QApplication::desktop()->width() > 480 ) { | 1484 | if ( QApplication::desktop()->width() > 480 ) { |
1485 | topLayout = new QHBoxLayout( this ); | 1485 | topLayout = new QHBoxLayout( this ); |
1486 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1486 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1487 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1487 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1488 | } else { | 1488 | } else { |
1489 | 1489 | ||
1490 | topLayout = new QHBoxLayout( this ); | 1490 | topLayout = new QHBoxLayout( this ); |
1491 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1491 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1492 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1492 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1493 | } | 1493 | } |
1494 | 1494 | ||
1495 | topLayout->addWidget(mMiniSplitter ); | 1495 | topLayout->addWidget(mMiniSplitter ); |
1496 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1496 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1497 | mDetails = new ViewContainer( mMiniSplitter ); | 1497 | mDetails = new ViewContainer( mMiniSplitter ); |
1498 | 1498 | ||
1499 | 1499 | ||
1500 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1500 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1501 | #endif | 1501 | #endif |
1502 | //eh->hide(); | 1502 | //eh->hide(); |
1503 | // topLayout->addWidget(mExtensionManager ); | 1503 | // topLayout->addWidget(mExtensionManager ); |
1504 | 1504 | ||
1505 | 1505 | ||
1506 | /*US | 1506 | /*US |
1507 | #ifndef KAB_NOSPLITTER | 1507 | #ifndef KAB_NOSPLITTER |
1508 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1508 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1509 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1509 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1510 | topLayout->setSpacing( 10 ); | 1510 | topLayout->setSpacing( 10 ); |
1511 | 1511 | ||
1512 | mDetailsSplitter = new QSplitter( this ); | 1512 | mDetailsSplitter = new QSplitter( this ); |
1513 | 1513 | ||
1514 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1514 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1515 | 1515 | ||
1516 | mViewManager = new ViewManager( this, viewSpace ); | 1516 | mViewManager = new ViewManager( this, viewSpace ); |
1517 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1517 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1518 | 1518 | ||
1519 | mDetails = new ViewContainer( mDetailsSplitter ); | 1519 | mDetails = new ViewContainer( mDetailsSplitter ); |
1520 | 1520 | ||
1521 | topLayout->addWidget( mDetailsSplitter ); | 1521 | topLayout->addWidget( mDetailsSplitter ); |
1522 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1522 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1523 | #else //KAB_NOSPLITTER | 1523 | #else //KAB_NOSPLITTER |
1524 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1524 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1525 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1525 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1526 | topLayout->setSpacing( 10 ); | 1526 | topLayout->setSpacing( 10 ); |
1527 | 1527 | ||
1528 | // mDetailsSplitter = new QSplitter( this ); | 1528 | // mDetailsSplitter = new QSplitter( this ); |
1529 | 1529 | ||
1530 | QVBox *viewSpace = new QVBox( this ); | 1530 | QVBox *viewSpace = new QVBox( this ); |
1531 | 1531 | ||
1532 | mViewManager = new ViewManager( this, viewSpace ); | 1532 | mViewManager = new ViewManager( this, viewSpace ); |
1533 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1533 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1534 | 1534 | ||
1535 | mDetails = new ViewContainer( this ); | 1535 | mDetails = new ViewContainer( this ); |
1536 | 1536 | ||
1537 | topLayout->addWidget( viewSpace ); | 1537 | topLayout->addWidget( viewSpace ); |
1538 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1538 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1539 | topLayout->addWidget( mDetails ); | 1539 | topLayout->addWidget( mDetails ); |
1540 | #endif //KAB_NOSPLITTER | 1540 | #endif //KAB_NOSPLITTER |
1541 | */ | 1541 | */ |
1542 | 1542 | ||
1543 | 1543 | ||
1544 | #endif //KAB_EMBEDDED | 1544 | #endif //KAB_EMBEDDED |
1545 | initActions(); | 1545 | initActions(); |
1546 | 1546 | ||
1547 | #ifdef KAB_EMBEDDED | 1547 | #ifdef KAB_EMBEDDED |
1548 | addActionsManually(); | 1548 | addActionsManually(); |
1549 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1549 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1550 | mXXPortManager = new XXPortManager( this, this ); | 1550 | mXXPortManager = new XXPortManager( this, this ); |
1551 | 1551 | ||
1552 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1552 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1553 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1553 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1554 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1554 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1555 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1555 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1556 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1556 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1557 | // mIncSearchWidget->hide(); | 1557 | // mIncSearchWidget->hide(); |
1558 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1558 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1559 | SLOT( incrementalSearch( const QString& ) ) ); | 1559 | SLOT( incrementalSearch( const QString& ) ) ); |
1560 | 1560 | ||
1561 | 1561 | ||
1562 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1562 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1563 | 1563 | ||
1564 | topLayout->addWidget( mJumpButtonBar ); | 1564 | topLayout->addWidget( mJumpButtonBar ); |
1565 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1565 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1566 | 1566 | ||
1567 | // mMainWindow->getIconToolBar()->raise(); | 1567 | // mMainWindow->getIconToolBar()->raise(); |
1568 | 1568 | ||
1569 | #endif //KAB_EMBEDDED | 1569 | #endif //KAB_EMBEDDED |
1570 | 1570 | ||
1571 | } | 1571 | } |
1572 | void KABCore::initActions() | 1572 | void KABCore::initActions() |
1573 | { | 1573 | { |
1574 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1574 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1575 | 1575 | ||
1576 | #ifndef KAB_EMBEDDED | 1576 | #ifndef KAB_EMBEDDED |
1577 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1577 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1578 | SLOT( clipboardDataChanged() ) ); | 1578 | SLOT( clipboardDataChanged() ) ); |
1579 | #endif //KAB_EMBEDDED | 1579 | #endif //KAB_EMBEDDED |
1580 | 1580 | ||
1581 | // file menu | 1581 | // file menu |
1582 | if ( mIsPart ) { | 1582 | if ( mIsPart ) { |
1583 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1583 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1584 | SLOT( sendMail() ), actionCollection(), | 1584 | SLOT( sendMail() ), actionCollection(), |
1585 | "kaddressbook_mail" ); | 1585 | "kaddressbook_mail" ); |
1586 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1586 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1587 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1587 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1588 | 1588 | ||
1589 | } else { | 1589 | } else { |
1590 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1590 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1591 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1591 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1592 | } | 1592 | } |
1593 | 1593 | ||
1594 | 1594 | ||
1595 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1595 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1596 | SLOT( save() ), actionCollection(), "file_sync" ); | 1596 | SLOT( save() ), actionCollection(), "file_sync" ); |
1597 | 1597 | ||
1598 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1598 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1599 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1599 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1600 | 1600 | ||
1601 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1601 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1602 | this, SLOT( mailVCard() ), | 1602 | this, SLOT( mailVCard() ), |
1603 | actionCollection(), "file_mail_vcard"); | 1603 | actionCollection(), "file_mail_vcard"); |
1604 | 1604 | ||
1605 | mActionBeamVCard = 0; | 1605 | mActionBeamVCard = 0; |
1606 | mActionBeam = 0; | 1606 | mActionBeam = 0; |
1607 | 1607 | ||
1608 | #ifndef DESKTOP_VERSION | 1608 | #ifndef DESKTOP_VERSION |
1609 | if ( Ir::supported() ) { | 1609 | if ( Ir::supported() ) { |
1610 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1610 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1611 | SLOT( beamVCard() ), actionCollection(), | 1611 | SLOT( beamVCard() ), actionCollection(), |
1612 | "kaddressbook_beam_vcard" ); | 1612 | "kaddressbook_beam_vcard" ); |
1613 | 1613 | ||
1614 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1614 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1615 | SLOT( beamMySelf() ), actionCollection(), | 1615 | SLOT( beamMySelf() ), actionCollection(), |
1616 | "kaddressbook_beam_myself" ); | 1616 | "kaddressbook_beam_myself" ); |
1617 | } | 1617 | } |
1618 | #endif | 1618 | #endif |
1619 | 1619 | ||
1620 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1620 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1621 | this, SLOT( editContact2() ), | 1621 | this, SLOT( editContact2() ), |
1622 | actionCollection(), "file_properties" ); | 1622 | actionCollection(), "file_properties" ); |
1623 | 1623 | ||
1624 | #ifdef KAB_EMBEDDED | 1624 | #ifdef KAB_EMBEDDED |
1625 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1625 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1626 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1626 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1627 | mMainWindow, SLOT( exit() ), | 1627 | mMainWindow, SLOT( exit() ), |
1628 | actionCollection(), "quit" ); | 1628 | actionCollection(), "quit" ); |
1629 | #endif //KAB_EMBEDDED | 1629 | #endif //KAB_EMBEDDED |
1630 | 1630 | ||
1631 | // edit menu | 1631 | // edit menu |
1632 | if ( mIsPart ) { | 1632 | if ( mIsPart ) { |
1633 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1633 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1634 | SLOT( copyContacts() ), actionCollection(), | 1634 | SLOT( copyContacts() ), actionCollection(), |
1635 | "kaddressbook_copy" ); | 1635 | "kaddressbook_copy" ); |
1636 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1636 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1637 | SLOT( cutContacts() ), actionCollection(), | 1637 | SLOT( cutContacts() ), actionCollection(), |
1638 | "kaddressbook_cut" ); | 1638 | "kaddressbook_cut" ); |
1639 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1639 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1640 | SLOT( pasteContacts() ), actionCollection(), | 1640 | SLOT( pasteContacts() ), actionCollection(), |
1641 | "kaddressbook_paste" ); | 1641 | "kaddressbook_paste" ); |
1642 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1642 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1643 | SLOT( selectAllContacts() ), actionCollection(), | 1643 | SLOT( selectAllContacts() ), actionCollection(), |
1644 | "kaddressbook_select_all" ); | 1644 | "kaddressbook_select_all" ); |
1645 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1645 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1646 | SLOT( undo() ), actionCollection(), | 1646 | SLOT( undo() ), actionCollection(), |
1647 | "kaddressbook_undo" ); | 1647 | "kaddressbook_undo" ); |
1648 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1648 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1649 | this, SLOT( redo() ), actionCollection(), | 1649 | this, SLOT( redo() ), actionCollection(), |
1650 | "kaddressbook_redo" ); | 1650 | "kaddressbook_redo" ); |
1651 | } else { | 1651 | } else { |
1652 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1652 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1653 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1653 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1654 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1654 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1655 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1655 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1656 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1656 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1657 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1657 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1658 | } | 1658 | } |
1659 | 1659 | ||
1660 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1660 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1661 | Key_Delete, this, SLOT( deleteContacts() ), | 1661 | Key_Delete, this, SLOT( deleteContacts() ), |
1662 | actionCollection(), "edit_delete" ); | 1662 | actionCollection(), "edit_delete" ); |
1663 | 1663 | ||
1664 | mActionUndo->setEnabled( false ); | 1664 | mActionUndo->setEnabled( false ); |
1665 | mActionRedo->setEnabled( false ); | 1665 | mActionRedo->setEnabled( false ); |
1666 | 1666 | ||
1667 | // settings menu | 1667 | // settings menu |
1668 | #ifdef KAB_EMBEDDED | 1668 | #ifdef KAB_EMBEDDED |
1669 | //US special menuentry to configure the addressbook resources. On KDE | 1669 | //US special menuentry to configure the addressbook resources. On KDE |
1670 | // you do that through the control center !!! | 1670 | // you do that through the control center !!! |
1671 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1671 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1672 | SLOT( configureResources() ), actionCollection(), | 1672 | SLOT( configureResources() ), actionCollection(), |
1673 | "kaddressbook_configure_resources" ); | 1673 | "kaddressbook_configure_resources" ); |
1674 | #endif //KAB_EMBEDDED | 1674 | #endif //KAB_EMBEDDED |
1675 | 1675 | ||
1676 | if ( mIsPart ) { | 1676 | if ( mIsPart ) { |
1677 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1677 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1678 | SLOT( openConfigDialog() ), actionCollection(), | 1678 | SLOT( openConfigDialog() ), actionCollection(), |
1679 | "kaddressbook_configure" ); | 1679 | "kaddressbook_configure" ); |
1680 | 1680 | ||
1681 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1681 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1682 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1682 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1683 | "kaddressbook_configure_shortcuts" ); | 1683 | "kaddressbook_configure_shortcuts" ); |
1684 | #ifdef KAB_EMBEDDED | 1684 | #ifdef KAB_EMBEDDED |
1685 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1685 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1686 | mActionConfigureToolbars->setEnabled( false ); | 1686 | mActionConfigureToolbars->setEnabled( false ); |
1687 | #endif //KAB_EMBEDDED | 1687 | #endif //KAB_EMBEDDED |
1688 | 1688 | ||
1689 | } else { | 1689 | } else { |
1690 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1690 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1691 | 1691 | ||
1692 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1692 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1693 | } | 1693 | } |
1694 | 1694 | ||
1695 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1695 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1696 | actionCollection(), "options_show_jump_bar" ); | 1696 | actionCollection(), "options_show_jump_bar" ); |
1697 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1697 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1698 | 1698 | ||
1699 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1699 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1700 | actionCollection(), "options_show_details" ); | 1700 | actionCollection(), "options_show_details" ); |
1701 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1701 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1702 | 1702 | ||
1703 | // misc | 1703 | // misc |
1704 | // only enable LDAP lookup if we can handle the protocol | 1704 | // only enable LDAP lookup if we can handle the protocol |
1705 | #ifndef KAB_EMBEDDED | 1705 | #ifndef KAB_EMBEDDED |
1706 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1706 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1707 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1707 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1708 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1708 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1709 | "ldap_lookup" ); | 1709 | "ldap_lookup" ); |
1710 | } | 1710 | } |
1711 | #else //KAB_EMBEDDED | 1711 | #else //KAB_EMBEDDED |
1712 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1712 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1713 | #endif //KAB_EMBEDDED | 1713 | #endif //KAB_EMBEDDED |
1714 | 1714 | ||
1715 | 1715 | ||
1716 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1716 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1717 | SLOT( setWhoAmI() ), actionCollection(), | 1717 | SLOT( setWhoAmI() ), actionCollection(), |
1718 | "set_personal" ); | 1718 | "set_personal" ); |
1719 | 1719 | ||
1720 | 1720 | ||
1721 | 1721 | ||
1722 | 1722 | ||
1723 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1723 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1724 | SLOT( setCategories() ), actionCollection(), | 1724 | SLOT( setCategories() ), actionCollection(), |
1725 | "edit_set_categories" ); | 1725 | "edit_set_categories" ); |
1726 | 1726 | ||
1727 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1727 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1728 | SLOT( removeVoice() ), actionCollection(), | 1728 | SLOT( removeVoice() ), actionCollection(), |
1729 | "remove_voice" ); | 1729 | "remove_voice" ); |
1730 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1730 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1731 | SLOT( importFromOL() ), actionCollection(), | 1731 | SLOT( importFromOL() ), actionCollection(), |
1732 | "import_OL" ); | 1732 | "import_OL" ); |
1733 | #ifdef KAB_EMBEDDED | 1733 | #ifdef KAB_EMBEDDED |
1734 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1734 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1735 | this, SLOT( showLicence() ), actionCollection(), | 1735 | this, SLOT( showLicence() ), actionCollection(), |
1736 | "licence_about_data" ); | 1736 | "licence_about_data" ); |
1737 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1737 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1738 | this, SLOT( faq() ), actionCollection(), | 1738 | this, SLOT( faq() ), actionCollection(), |
1739 | "faq_about_data" ); | 1739 | "faq_about_data" ); |
1740 | 1740 | ||
1741 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1741 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1742 | this, SLOT( createAboutData() ), actionCollection(), | 1742 | this, SLOT( createAboutData() ), actionCollection(), |
1743 | "kaddressbook_about_data" ); | 1743 | "kaddressbook_about_data" ); |
1744 | #endif //KAB_EMBEDDED | 1744 | #endif //KAB_EMBEDDED |
1745 | 1745 | ||
1746 | clipboardDataChanged(); | 1746 | clipboardDataChanged(); |
1747 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1747 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1748 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1748 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1749 | } | 1749 | } |
1750 | 1750 | ||
1751 | //US we need this function, to plug all actions into the correct menues. | 1751 | //US we need this function, to plug all actions into the correct menues. |
1752 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1752 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1753 | void KABCore::addActionsManually() | 1753 | void KABCore::addActionsManually() |
1754 | { | 1754 | { |
1755 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1755 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1756 | 1756 | ||
1757 | #ifdef KAB_EMBEDDED | 1757 | #ifdef KAB_EMBEDDED |
1758 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1758 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1759 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1759 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1760 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1760 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1761 | 1761 | ||
1762 | KToolBar* tb = mMainWindow->toolBar(); | 1762 | KToolBar* tb = mMainWindow->toolBar(); |
1763 | 1763 | ||
1764 | #ifdef DESKTOP_VERSION | 1764 | #ifdef DESKTOP_VERSION |
1765 | QMenuBar* mb = mMainWindow->menuBar(); | 1765 | QMenuBar* mb = mMainWindow->menuBar(); |
1766 | 1766 | ||
1767 | //US setup menubar. | 1767 | //US setup menubar. |
1768 | //Disable the following block if you do not want to have a menubar. | 1768 | //Disable the following block if you do not want to have a menubar. |
1769 | mb->insertItem( "&File", fileMenu ); | 1769 | mb->insertItem( "&File", fileMenu ); |
1770 | mb->insertItem( "&Edit", editMenu ); | 1770 | mb->insertItem( "&Edit", editMenu ); |
1771 | mb->insertItem( "&View", viewMenu ); | 1771 | mb->insertItem( "&View", viewMenu ); |
1772 | mb->insertItem( "&Settings", settingsMenu ); | 1772 | mb->insertItem( "&Settings", settingsMenu ); |
1773 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1773 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1774 | mb->insertItem( "&Change selected", changeMenu ); | 1774 | mb->insertItem( "&Change selected", changeMenu ); |
1775 | mb->insertItem( "&Help", helpMenu ); | 1775 | mb->insertItem( "&Help", helpMenu ); |
1776 | mIncSearchWidget = new IncSearchWidget( tb ); | 1776 | mIncSearchWidget = new IncSearchWidget( tb ); |
1777 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1777 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1778 | 1778 | ||
1779 | #else | 1779 | #else |
1780 | //US setup toolbar | 1780 | //US setup toolbar |
1781 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1781 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1782 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1782 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1783 | menuBarTB->insertItem( "ME", popupBarTB); | 1783 | menuBarTB->insertItem( "ME", popupBarTB); |
1784 | tb->insertWidget(-1, 0, menuBarTB); | 1784 | tb->insertWidget(-1, 0, menuBarTB); |
1785 | mIncSearchWidget = new IncSearchWidget( tb ); | 1785 | mIncSearchWidget = new IncSearchWidget( tb ); |
1786 | 1786 | ||
1787 | tb->enableMoving(false); | 1787 | tb->enableMoving(false); |
1788 | popupBarTB->insertItem( "&File", fileMenu ); | 1788 | popupBarTB->insertItem( "&File", fileMenu ); |
1789 | popupBarTB->insertItem( "&Edit", editMenu ); | 1789 | popupBarTB->insertItem( "&Edit", editMenu ); |
1790 | popupBarTB->insertItem( "&View", viewMenu ); | 1790 | popupBarTB->insertItem( "&View", viewMenu ); |
1791 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1791 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1792 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1792 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1793 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1793 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1794 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1794 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1795 | popupBarTB->insertItem( "&Help", helpMenu ); | 1795 | popupBarTB->insertItem( "&Help", helpMenu ); |
1796 | if (QApplication::desktop()->width() > 320 ) { | 1796 | if (QApplication::desktop()->width() > 320 ) { |
1797 | // mViewManager->getFilterAction()->plug ( tb); | 1797 | // mViewManager->getFilterAction()->plug ( tb); |
1798 | } | 1798 | } |
1799 | #endif | 1799 | #endif |
1800 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1800 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1801 | 1801 | ||
1802 | 1802 | ||
1803 | 1803 | ||
1804 | //US Now connect the actions with the menue entries. | 1804 | //US Now connect the actions with the menue entries. |
1805 | mActionPrint->plug( fileMenu ); | 1805 | mActionPrint->plug( fileMenu ); |
1806 | mActionMail->plug( fileMenu ); | 1806 | mActionMail->plug( fileMenu ); |
1807 | fileMenu->insertSeparator(); | 1807 | fileMenu->insertSeparator(); |
1808 | 1808 | ||
1809 | mActionNewContact->plug( fileMenu ); | 1809 | mActionNewContact->plug( fileMenu ); |
1810 | mActionNewContact->plug( tb ); | 1810 | mActionNewContact->plug( tb ); |
1811 | 1811 | ||
1812 | mActionEditAddressee->plug( fileMenu ); | 1812 | mActionEditAddressee->plug( fileMenu ); |
1813 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1813 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1814 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1814 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1815 | mActionEditAddressee->plug( tb ); | 1815 | mActionEditAddressee->plug( tb ); |
1816 | 1816 | ||
1817 | fileMenu->insertSeparator(); | 1817 | fileMenu->insertSeparator(); |
1818 | mActionSave->plug( fileMenu ); | 1818 | mActionSave->plug( fileMenu ); |
1819 | fileMenu->insertItem( "&Import", ImportMenu ); | 1819 | fileMenu->insertItem( "&Import", ImportMenu ); |
1820 | fileMenu->insertItem( "&Export", ExportMenu ); | 1820 | fileMenu->insertItem( "&Export", ExportMenu ); |
1821 | fileMenu->insertSeparator(); | 1821 | fileMenu->insertSeparator(); |
1822 | mActionMailVCard->plug( fileMenu ); | 1822 | mActionMailVCard->plug( fileMenu ); |
1823 | #ifndef DESKTOP_VERSION | 1823 | #ifndef DESKTOP_VERSION |
1824 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1824 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1825 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1825 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1826 | #endif | 1826 | #endif |
1827 | fileMenu->insertSeparator(); | 1827 | fileMenu->insertSeparator(); |
1828 | mActionQuit->plug( fileMenu ); | 1828 | mActionQuit->plug( fileMenu ); |
1829 | #ifdef _WIN32_ | 1829 | #ifdef _WIN32_ |
1830 | mActionImportOL->plug( ImportMenu ); | 1830 | mActionImportOL->plug( ImportMenu ); |
1831 | #endif | 1831 | #endif |
1832 | // edit menu | 1832 | // edit menu |
1833 | mActionUndo->plug( editMenu ); | 1833 | mActionUndo->plug( editMenu ); |
1834 | mActionRedo->plug( editMenu ); | 1834 | mActionRedo->plug( editMenu ); |
1835 | editMenu->insertSeparator(); | 1835 | editMenu->insertSeparator(); |
1836 | mActionCut->plug( editMenu ); | 1836 | mActionCut->plug( editMenu ); |
1837 | mActionCopy->plug( editMenu ); | 1837 | mActionCopy->plug( editMenu ); |
1838 | mActionPaste->plug( editMenu ); | 1838 | mActionPaste->plug( editMenu ); |
1839 | mActionDelete->plug( editMenu ); | 1839 | mActionDelete->plug( editMenu ); |
1840 | editMenu->insertSeparator(); | 1840 | editMenu->insertSeparator(); |
1841 | mActionSelectAll->plug( editMenu ); | 1841 | mActionSelectAll->plug( editMenu ); |
1842 | 1842 | ||
1843 | mActionRemoveVoice->plug( changeMenu ); | 1843 | mActionRemoveVoice->plug( changeMenu ); |
1844 | // settings menu | 1844 | // settings menu |
1845 | //US special menuentry to configure the addressbook resources. On KDE | 1845 | //US special menuentry to configure the addressbook resources. On KDE |
1846 | // you do that through the control center !!! | 1846 | // you do that through the control center !!! |
1847 | mActionConfigResources->plug( settingsMenu ); | 1847 | mActionConfigResources->plug( settingsMenu ); |
1848 | settingsMenu->insertSeparator(); | 1848 | settingsMenu->insertSeparator(); |
1849 | 1849 | ||
1850 | mActionConfigKAddressbook->plug( settingsMenu ); | 1850 | mActionConfigKAddressbook->plug( settingsMenu ); |
1851 | 1851 | ||
1852 | if ( mIsPart ) { | 1852 | if ( mIsPart ) { |
1853 | mActionConfigShortcuts->plug( settingsMenu ); | 1853 | mActionConfigShortcuts->plug( settingsMenu ); |
1854 | mActionConfigureToolbars->plug( settingsMenu ); | 1854 | mActionConfigureToolbars->plug( settingsMenu ); |
1855 | 1855 | ||
1856 | } else { | 1856 | } else { |
1857 | mActionKeyBindings->plug( settingsMenu ); | 1857 | mActionKeyBindings->plug( settingsMenu ); |
1858 | } | 1858 | } |
1859 | 1859 | ||
1860 | settingsMenu->insertSeparator(); | 1860 | settingsMenu->insertSeparator(); |
1861 | 1861 | ||
1862 | mActionJumpBar->plug( settingsMenu ); | 1862 | mActionJumpBar->plug( settingsMenu ); |
1863 | mActionDetails->plug( settingsMenu ); | 1863 | mActionDetails->plug( settingsMenu ); |
1864 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 1864 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
1865 | mActionDetails->plug( tb ); | 1865 | mActionDetails->plug( tb ); |
1866 | settingsMenu->insertSeparator(); | 1866 | settingsMenu->insertSeparator(); |
1867 | 1867 | ||
1868 | mActionWhoAmI->plug( settingsMenu ); | 1868 | mActionWhoAmI->plug( settingsMenu ); |
1869 | mActionCategories->plug( settingsMenu ); | 1869 | mActionCategories->plug( settingsMenu ); |
1870 | 1870 | ||
1871 | mActionLicence->plug( helpMenu ); | 1871 | mActionLicence->plug( helpMenu ); |
1872 | mActionFaq->plug( helpMenu ); | 1872 | mActionFaq->plug( helpMenu ); |
1873 | mActionAboutKAddressbook->plug( helpMenu ); | 1873 | mActionAboutKAddressbook->plug( helpMenu ); |
1874 | 1874 | ||
1875 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 1875 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
1876 | 1876 | ||
1877 | mActionSave->plug( tb ); | 1877 | mActionSave->plug( tb ); |
1878 | mViewManager->getFilterAction()->plug ( tb); | 1878 | mViewManager->getFilterAction()->plug ( tb); |
1879 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 1879 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
1880 | mActionUndo->plug( tb ); | 1880 | mActionUndo->plug( tb ); |
1881 | mActionDelete->plug( tb ); | 1881 | mActionDelete->plug( tb ); |
1882 | mActionRedo->plug( tb ); | 1882 | mActionRedo->plug( tb ); |
1883 | } | 1883 | } |
1884 | } | 1884 | } |
1885 | //mActionQuit->plug ( tb ); | 1885 | //mActionQuit->plug ( tb ); |
1886 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 1886 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
1887 | 1887 | ||
1888 | //US link the searchwidget first to this. | 1888 | //US link the searchwidget first to this. |
1889 | // The real linkage to the toolbar happens later. | 1889 | // The real linkage to the toolbar happens later. |
1890 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 1890 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
1891 | //US tb->insertItem( mIncSearchWidget ); | 1891 | //US tb->insertItem( mIncSearchWidget ); |
1892 | /*US | 1892 | /*US |
1893 | mIncSearchWidget = new IncSearchWidget( tb ); | 1893 | mIncSearchWidget = new IncSearchWidget( tb ); |
1894 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1894 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1895 | SLOT( incrementalSearch( const QString& ) ) ); | 1895 | SLOT( incrementalSearch( const QString& ) ) ); |
1896 | 1896 | ||
1897 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1897 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1898 | 1898 | ||
1899 | //US topLayout->addWidget( mJumpButtonBar ); | 1899 | //US topLayout->addWidget( mJumpButtonBar ); |
1900 | this->layout()->add( mJumpButtonBar ); | 1900 | this->layout()->add( mJumpButtonBar ); |
1901 | */ | 1901 | */ |
1902 | 1902 | ||
1903 | #endif //KAB_EMBEDDED | 1903 | #endif //KAB_EMBEDDED |
1904 | 1904 | ||
1905 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); | 1905 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); |
1906 | fillSyncMenu(); | 1906 | fillSyncMenu(); |
1907 | 1907 | ||
1908 | } | 1908 | } |
1909 | void KABCore::showLicence() | 1909 | void KABCore::showLicence() |
1910 | { | 1910 | { |
1911 | KApplication::showLicence(); | 1911 | KApplication::showLicence(); |
1912 | } | 1912 | } |
1913 | void KABCore::removeVoice() | 1913 | void KABCore::removeVoice() |
1914 | { | 1914 | { |
1915 | 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 ) | 1915 | 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 ) |
1916 | return; | 1916 | return; |
1917 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 1917 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
1918 | KABC::Addressee::List::Iterator it; | 1918 | KABC::Addressee::List::Iterator it; |
1919 | for ( it = list.begin(); it != list.end(); ++it ) { | 1919 | for ( it = list.begin(); it != list.end(); ++it ) { |
1920 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); | 1920 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); |
1921 | PhoneNumber::List::Iterator phoneIt; | 1921 | PhoneNumber::List::Iterator phoneIt; |
1922 | bool found = false; | 1922 | bool found = false; |
1923 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | 1923 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { |
1924 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 1924 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
1925 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 1925 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
1926 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 1926 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
1927 | (*it).insertPhoneNumber( (*phoneIt) ); | 1927 | (*it).insertPhoneNumber( (*phoneIt) ); |
1928 | found = true; | 1928 | found = true; |
1929 | } | 1929 | } |
1930 | } | 1930 | } |
1931 | 1931 | ||
1932 | } | 1932 | } |
1933 | if ( found ) | 1933 | if ( found ) |
1934 | contactModified((*it) ); | 1934 | contactModified((*it) ); |
1935 | } | 1935 | } |
1936 | } | 1936 | } |
1937 | 1937 | ||
1938 | 1938 | ||
1939 | 1939 | ||
1940 | void KABCore::clipboardDataChanged() | 1940 | void KABCore::clipboardDataChanged() |
1941 | { | 1941 | { |
1942 | 1942 | ||
1943 | if ( mReadWrite ) | 1943 | if ( mReadWrite ) |
1944 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 1944 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
1945 | 1945 | ||
1946 | } | 1946 | } |
1947 | 1947 | ||
1948 | void KABCore::updateActionMenu() | 1948 | void KABCore::updateActionMenu() |
1949 | { | 1949 | { |
1950 | UndoStack *undo = UndoStack::instance(); | 1950 | UndoStack *undo = UndoStack::instance(); |
1951 | RedoStack *redo = RedoStack::instance(); | 1951 | RedoStack *redo = RedoStack::instance(); |
1952 | 1952 | ||
1953 | if ( undo->isEmpty() ) | 1953 | if ( undo->isEmpty() ) |
1954 | mActionUndo->setText( i18n( "Undo" ) ); | 1954 | mActionUndo->setText( i18n( "Undo" ) ); |
1955 | else | 1955 | else |
1956 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 1956 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
1957 | 1957 | ||
1958 | mActionUndo->setEnabled( !undo->isEmpty() ); | 1958 | mActionUndo->setEnabled( !undo->isEmpty() ); |
1959 | 1959 | ||
1960 | if ( !redo->top() ) | 1960 | if ( !redo->top() ) |
1961 | mActionRedo->setText( i18n( "Redo" ) ); | 1961 | mActionRedo->setText( i18n( "Redo" ) ); |
1962 | else | 1962 | else |
1963 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 1963 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
1964 | 1964 | ||
1965 | mActionRedo->setEnabled( !redo->isEmpty() ); | 1965 | mActionRedo->setEnabled( !redo->isEmpty() ); |
1966 | } | 1966 | } |
1967 | 1967 | ||
1968 | void KABCore::configureKeyBindings() | 1968 | void KABCore::configureKeyBindings() |
1969 | { | 1969 | { |
1970 | #ifndef KAB_EMBEDDED | 1970 | #ifndef KAB_EMBEDDED |
1971 | KKeyDialog::configure( actionCollection(), true ); | 1971 | KKeyDialog::configure( actionCollection(), true ); |
1972 | #else //KAB_EMBEDDED | 1972 | #else //KAB_EMBEDDED |
1973 | qDebug("KABCore::configureKeyBindings() not implemented"); | 1973 | qDebug("KABCore::configureKeyBindings() not implemented"); |
1974 | #endif //KAB_EMBEDDED | 1974 | #endif //KAB_EMBEDDED |
1975 | } | 1975 | } |
1976 | 1976 | ||
1977 | #ifdef KAB_EMBEDDED | 1977 | #ifdef KAB_EMBEDDED |
1978 | void KABCore::configureResources() | 1978 | void KABCore::configureResources() |
1979 | { | 1979 | { |
1980 | KRES::KCMKResources dlg( this, "" , 0 ); | 1980 | KRES::KCMKResources dlg( this, "" , 0 ); |
1981 | 1981 | ||
1982 | if ( !dlg.exec() ) | 1982 | if ( !dlg.exec() ) |
1983 | return; | 1983 | return; |
1984 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 1984 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
1985 | } | 1985 | } |
1986 | #endif //KAB_EMBEDDED | 1986 | #endif //KAB_EMBEDDED |
1987 | 1987 | ||
1988 | 1988 | ||
1989 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 1989 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
1990 | * for the attendees list of an event. | 1990 | * for the attendees list of an event. |
1991 | */ | 1991 | */ |
1992 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 1992 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
1993 | { | 1993 | { |
1994 | QStringList nameList; | 1994 | QStringList nameList; |
1995 | QStringList emailList; | 1995 | QStringList emailList; |
1996 | QStringList uidList; | 1996 | QStringList uidList; |
1997 | 1997 | ||
1998 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 1998 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
1999 | uint i=0; | 1999 | uint i=0; |
2000 | for (i=0; i < list.count(); i++) | 2000 | for (i=0; i < list.count(); i++) |
2001 | { | 2001 | { |
2002 | nameList.append(list[i].realName()); | 2002 | nameList.append(list[i].realName()); |
2003 | emailList.append(list[i].preferredEmail()); | 2003 | emailList.append(list[i].preferredEmail()); |
2004 | uidList.append(list[i].uid()); | 2004 | uidList.append(list[i].uid()); |
2005 | } | 2005 | } |
2006 | 2006 | ||
2007 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2007 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2008 | 2008 | ||
2009 | } | 2009 | } |
2010 | 2010 | ||
2011 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2011 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2012 | */ | 2012 | */ |
2013 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2013 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2014 | { | 2014 | { |
2015 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2015 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2016 | 2016 | ||
2017 | QString foundUid = QString::null; | 2017 | QString foundUid = QString::null; |
2018 | if ( ! uid.isEmpty() ) { | 2018 | if ( ! uid.isEmpty() ) { |
2019 | Addressee adrr = mAddressBook->findByUid( uid ); | 2019 | Addressee adrr = mAddressBook->findByUid( uid ); |
2020 | if ( !adrr.isEmpty() ) { | 2020 | if ( !adrr.isEmpty() ) { |
2021 | foundUid = uid; | 2021 | foundUid = uid; |
2022 | } | 2022 | } |
2023 | if ( email == "sendbacklist" ) { | 2023 | if ( email == "sendbacklist" ) { |
2024 | //qDebug("ssssssssssssssssssssssend "); | 2024 | //qDebug("ssssssssssssssssssssssend "); |
2025 | QStringList nameList; | 2025 | QStringList nameList; |
2026 | QStringList emailList; | 2026 | QStringList emailList; |
2027 | QStringList uidList; | 2027 | QStringList uidList; |
2028 | nameList.append(adrr.realName()); | 2028 | nameList.append(adrr.realName()); |
2029 | emailList = adrr.emails(); | 2029 | emailList = adrr.emails(); |
2030 | uidList.append( adrr.preferredEmail()); | 2030 | uidList.append( adrr.preferredEmail()); |
2031 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2031 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2032 | return; | 2032 | return; |
2033 | } | 2033 | } |
2034 | 2034 | ||
2035 | } | 2035 | } |
2036 | 2036 | ||
2037 | if ( email == "sendbacklist" ) | 2037 | if ( email == "sendbacklist" ) |
2038 | return; | 2038 | return; |
2039 | if (foundUid.isEmpty()) | 2039 | if (foundUid.isEmpty()) |
2040 | { | 2040 | { |
2041 | //find the uid of the person first | 2041 | //find the uid of the person first |
2042 | Addressee::List namelist; | 2042 | Addressee::List namelist; |
2043 | Addressee::List emaillist; | 2043 | Addressee::List emaillist; |
2044 | 2044 | ||
2045 | if (!name.isEmpty()) | 2045 | if (!name.isEmpty()) |
2046 | namelist = mAddressBook->findByName( name ); | 2046 | namelist = mAddressBook->findByName( name ); |
2047 | 2047 | ||
2048 | if (!email.isEmpty()) | 2048 | if (!email.isEmpty()) |
2049 | emaillist = mAddressBook->findByEmail( email ); | 2049 | emaillist = mAddressBook->findByEmail( email ); |
2050 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2050 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2051 | //check if we have a match in Namelist and Emaillist | 2051 | //check if we have a match in Namelist and Emaillist |
2052 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2052 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2053 | foundUid = emaillist[0].uid(); | 2053 | foundUid = emaillist[0].uid(); |
2054 | } | 2054 | } |
2055 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2055 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2056 | foundUid = namelist[0].uid(); | 2056 | foundUid = namelist[0].uid(); |
2057 | else | 2057 | else |
2058 | { | 2058 | { |
2059 | for (int i = 0; i < namelist.count(); i++) | 2059 | for (int i = 0; i < namelist.count(); i++) |
2060 | { | 2060 | { |
2061 | for (int j = 0; j < emaillist.count(); j++) | 2061 | for (int j = 0; j < emaillist.count(); j++) |
2062 | { | 2062 | { |
2063 | if (namelist[i] == emaillist[j]) | 2063 | if (namelist[i] == emaillist[j]) |
2064 | { | 2064 | { |
2065 | foundUid = namelist[i].uid(); | 2065 | foundUid = namelist[i].uid(); |
2066 | } | 2066 | } |
2067 | } | 2067 | } |
2068 | } | 2068 | } |
2069 | } | 2069 | } |
2070 | } | 2070 | } |
2071 | else | 2071 | else |
2072 | { | 2072 | { |
2073 | foundUid = uid; | 2073 | foundUid = uid; |
2074 | } | 2074 | } |
2075 | 2075 | ||
2076 | if (!foundUid.isEmpty()) | 2076 | if (!foundUid.isEmpty()) |
2077 | { | 2077 | { |
2078 | 2078 | ||
2079 | // raise Ka/Pi if it is in the background | 2079 | // raise Ka/Pi if it is in the background |
2080 | #ifndef DESKTOP_VERSION | 2080 | #ifndef DESKTOP_VERSION |
2081 | #ifndef KORG_NODCOP | 2081 | #ifndef KORG_NODCOP |
2082 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2082 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2083 | #endif | 2083 | #endif |
2084 | #endif | 2084 | #endif |
2085 | 2085 | ||
2086 | mMainWindow->showMaximized(); | 2086 | mMainWindow->showMaximized(); |
2087 | mMainWindow-> raise(); | 2087 | mMainWindow-> raise(); |
2088 | 2088 | ||
2089 | mViewManager->setSelected( "", false); | 2089 | mViewManager->setSelected( "", false); |
2090 | mViewManager->refreshView( "" ); | 2090 | mViewManager->refreshView( "" ); |
2091 | mViewManager->setSelected( foundUid, true ); | 2091 | mViewManager->setSelected( foundUid, true ); |
2092 | mViewManager->refreshView( foundUid ); | 2092 | mViewManager->refreshView( foundUid ); |
2093 | 2093 | ||
2094 | if ( !mMultipleViewsAtOnce ) | 2094 | if ( !mMultipleViewsAtOnce ) |
2095 | { | 2095 | { |
2096 | setDetailsVisible( true ); | 2096 | setDetailsVisible( true ); |
2097 | mActionDetails->setChecked(true); | 2097 | mActionDetails->setChecked(true); |
2098 | } | 2098 | } |
2099 | } | 2099 | } |
2100 | } | 2100 | } |
2101 | 2101 | ||
2102 | 2102 | ||
2103 | void KABCore::faq() | 2103 | void KABCore::faq() |
2104 | { | 2104 | { |
2105 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2105 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2106 | } | 2106 | } |
2107 | 2107 | ||
2108 | 2108 | ||
2109 | void KABCore::fillSyncMenu() | 2109 | void KABCore::fillSyncMenu() |
2110 | { | 2110 | { |
2111 | if ( syncMenu->count() ) | 2111 | if ( syncMenu->count() ) |
2112 | syncMenu->clear(); | 2112 | syncMenu->clear(); |
2113 | syncMenu->insertItem( i18n("Configure..."), 0 ); | 2113 | syncMenu->insertItem( i18n("Configure..."), 0 ); |
2114 | syncMenu->insertSeparator(); | 2114 | syncMenu->insertSeparator(); |
2115 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); | 2115 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); |
2116 | syncMenu->insertSeparator(); | 2116 | syncMenu->insertSeparator(); |
2117 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2117 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2118 | config.setGroup("General"); | 2118 | config.setGroup("General"); |
2119 | QStringList prof = config.readListEntry("SyncProfileNames"); | 2119 | QStringList prof = config.readListEntry("SyncProfileNames"); |
2120 | KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 2120 | KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
2121 | if ( prof.count() < 3 ) { | 2121 | if ( prof.count() < 3 ) { |
2122 | prof.clear(); | 2122 | prof.clear(); |
2123 | prof << i18n("Sharp_DTM"); | 2123 | prof << i18n("Sharp_DTM"); |
2124 | prof << i18n("Local_file"); | 2124 | prof << i18n("Local_file"); |
2125 | prof << i18n("Last_file"); | 2125 | prof << i18n("Last_file"); |
2126 | KSyncProfile* temp = new KSyncProfile (); | 2126 | KSyncProfile* temp = new KSyncProfile (); |
2127 | temp->setName( prof[0] ); | 2127 | temp->setName( prof[0] ); |
2128 | temp->writeConfig(&config); | 2128 | temp->writeConfig(&config); |
2129 | temp->setName( prof[1] ); | 2129 | temp->setName( prof[1] ); |
2130 | temp->writeConfig(&config); | 2130 | temp->writeConfig(&config); |
2131 | temp->setName( prof[2] ); | 2131 | temp->setName( prof[2] ); |
2132 | temp->writeConfig(&config); | 2132 | temp->writeConfig(&config); |
2133 | config.setGroup("General"); | 2133 | config.setGroup("General"); |
2134 | config.writeEntry("SyncProfileNames",prof); | 2134 | config.writeEntry("SyncProfileNames",prof); |
2135 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 2135 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
2136 | config.sync(); | 2136 | config.sync(); |
2137 | delete temp; | 2137 | delete temp; |
2138 | } | 2138 | } |
2139 | KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 2139 | KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
2140 | KABPrefs::instance()->mSyncProfileNames = prof; | 2140 | KABPrefs::instance()->mSyncProfileNames = prof; |
2141 | int i; | 2141 | int i; |
2142 | for ( i = 0; i < prof.count(); ++i ) { | 2142 | for ( i = 0; i < prof.count(); ++i ) { |
2143 | 2143 | ||
2144 | syncMenu->insertItem( prof[i], 1000+i ); | 2144 | syncMenu->insertItem( prof[i], 1000+i ); |
2145 | if ( i == 2 ) | 2145 | if ( i == 2 ) |
2146 | syncMenu->insertSeparator(); | 2146 | syncMenu->insertSeparator(); |
2147 | } | 2147 | } |
2148 | QDir app_dir; | 2148 | QDir app_dir; |
2149 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 2149 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
2150 | syncMenu->setItemEnabled( false , 1000 ); | 2150 | syncMenu->setItemEnabled( false , 1000 ); |
2151 | } | 2151 | } |
2152 | //probaly useless | 2152 | //probaly useless |
2153 | //mView->setupExternSyncProfiles(); | 2153 | //mView->setupExternSyncProfiles(); |
2154 | } | 2154 | } |
2155 | void KABCore::slotSyncMenu( int action ) | 2155 | void KABCore::slotSyncMenu( int action ) |
2156 | { | 2156 | { |
2157 | //qDebug("syncaction %d ", action); | 2157 | //qDebug("syncaction %d ", action); |
2158 | if ( action == 0 ) { | 2158 | if ( action == 0 ) { |
2159 | 2159 | ||
2160 | // seems to be a Qt2 event handling bug | 2160 | // seems to be a Qt2 event handling bug |
2161 | // syncmenu.clear causes a segfault at first time | 2161 | // syncmenu.clear causes a segfault at first time |
2162 | // when we call it after the main event loop, it is ok | 2162 | // when we call it after the main event loop, it is ok |
2163 | // same behaviour when calling OM/Pi via QCOP for the first time | 2163 | // same behaviour when calling OM/Pi via QCOP for the first time |
2164 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 2164 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
2165 | //confSync(); | 2165 | //confSync(); |
2166 | 2166 | ||
2167 | return; | 2167 | return; |
2168 | } | 2168 | } |
2169 | if ( action == 1 ) { | 2169 | if ( action == 1 ) { |
2170 | multiSync( true ); | 2170 | multiSync( true ); |
2171 | return; | 2171 | return; |
2172 | } | 2172 | } |
2173 | 2173 | ||
2174 | if (mBlockSaveFlag) | 2174 | if (mBlockSaveFlag) |
2175 | return; | 2175 | return; |
2176 | mBlockSaveFlag = true; | 2176 | mBlockSaveFlag = true; |
2177 | mCurrentSyncProfile = action - 1000 ; | 2177 | mCurrentSyncProfile = action - 1000 ; |
2178 | mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ; | 2178 | mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ; |
2179 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ; | 2179 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ; |
2180 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2180 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2181 | KSyncProfile* temp = new KSyncProfile (); | 2181 | KSyncProfile* temp = new KSyncProfile (); |
2182 | temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2182 | temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2183 | temp->readConfig(&config); | 2183 | temp->readConfig(&config); |
2184 | KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2184 | KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2185 | KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 2185 | KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
2186 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2186 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2187 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2187 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2188 | KABPrefs::instance()->mWriteBackInFuture = 0; | 2188 | KABPrefs::instance()->mWriteBackInFuture = 0; |
2189 | if ( temp->getWriteBackFuture() ) | 2189 | if ( temp->getWriteBackFuture() ) |
2190 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2190 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2191 | KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 2191 | KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
2192 | if ( action == 1000 ) { | 2192 | if ( action == 1000 ) { |
2193 | syncSharp(); | 2193 | syncSharp(); |
2194 | 2194 | ||
2195 | } else if ( action == 1001 ) { | 2195 | } else if ( action == 1001 ) { |
2196 | syncLocalFile(); | 2196 | syncLocalFile(); |
2197 | 2197 | ||
2198 | } else if ( action == 1002 ) { | 2198 | } else if ( action == 1002 ) { |
2199 | quickSyncLocalFile(); | 2199 | quickSyncLocalFile(); |
2200 | 2200 | ||
2201 | } else if ( action >= 1003 ) { | 2201 | } else if ( action >= 1003 ) { |
2202 | if ( temp->getIsLocalFileSync() ) { | 2202 | if ( temp->getIsLocalFileSync() ) { |
2203 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 2203 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
2204 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 2204 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
2205 | } else { | 2205 | } else { |
2206 | if ( temp->getIsPhoneSync() ) { | 2206 | if ( temp->getIsPhoneSync() ) { |
2207 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 2207 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
2208 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 2208 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
2209 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 2209 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
2210 | syncPhone(); | 2210 | syncPhone(); |
2211 | } else | 2211 | } else |
2212 | syncRemote( temp ); | 2212 | syncRemote( temp ); |
2213 | 2213 | ||
2214 | } | 2214 | } |
2215 | } | 2215 | } |
2216 | delete temp; | 2216 | delete temp; |
2217 | mBlockSaveFlag = false; | 2217 | mBlockSaveFlag = false; |
2218 | } | 2218 | } |
2219 | 2219 | ||
2220 | void KABCore::syncLocalFile() | 2220 | void KABCore::syncLocalFile() |
2221 | { | 2221 | { |
2222 | 2222 | ||
2223 | QString fn =KABPrefs::instance()->mLastSyncedLocalFile; | 2223 | QString fn =KABPrefs::instance()->mLastSyncedLocalFile; |
2224 | 2224 | ||
2225 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 2225 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
2226 | if ( fn == "" ) | 2226 | if ( fn == "" ) |
2227 | return; | 2227 | return; |
2228 | if ( syncWithFile( fn, false ) ) { | 2228 | if ( syncWithFile( fn, false ) ) { |
2229 | qDebug("syncLocalFile() successful "); | 2229 | qDebug("syncLocalFile() successful "); |
2230 | } | 2230 | } |
2231 | 2231 | ||
2232 | } | 2232 | } |
2233 | bool KABCore::syncWithFile( QString fn , bool quick ) | 2233 | bool KABCore::syncWithFile( QString fn , bool quick ) |
2234 | { | 2234 | { |
2235 | bool ret = false; | 2235 | bool ret = false; |
2236 | QFileInfo info; | 2236 | QFileInfo info; |
2237 | info.setFile( fn ); | 2237 | info.setFile( fn ); |
2238 | QString mess; | 2238 | QString mess; |
2239 | bool loadbup = true; | 2239 | bool loadbup = true; |
2240 | if ( !info. exists() ) { | 2240 | if ( !info. exists() ) { |
2241 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 2241 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
2242 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2242 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2243 | mess ); | 2243 | mess ); |
2244 | return ret; | 2244 | return ret; |
2245 | } | 2245 | } |
2246 | int result = 0; | 2246 | int result = 0; |
2247 | if ( !quick ) { | 2247 | if ( !quick ) { |
2248 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2248 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2249 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2249 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2250 | mess, | 2250 | mess, |
2251 | i18n("Sync"), i18n("Cancel"), 0, | 2251 | i18n("Sync"), i18n("Cancel"), 0, |
2252 | 0, 1 ); | 2252 | 0, 1 ); |
2253 | if ( result ) | 2253 | if ( result ) |
2254 | return false; | 2254 | return false; |
2255 | } | 2255 | } |
2256 | if ( KABPrefs::instance()->mAskForPreferences ) | 2256 | if ( KABPrefs::instance()->mAskForPreferences ) |
2257 | edit_sync_options(); | 2257 | edit_sync_options(); |
2258 | if ( result == 0 ) { | 2258 | if ( result == 0 ) { |
2259 | //qDebug("Now sycing ... "); | 2259 | //qDebug("Now sycing ... "); |
2260 | if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) ) | 2260 | if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) ) |
2261 | setCaption( i18n("Synchronization successful") ); | 2261 | setCaption( i18n("Synchronization successful") ); |
2262 | else | 2262 | else |
2263 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 2263 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
2264 | if ( ! quick ) | 2264 | if ( ! quick ) |
2265 | KABPrefs::instance()->mLastSyncedLocalFile = fn; | 2265 | KABPrefs::instance()->mLastSyncedLocalFile = fn; |
2266 | setModified(); | 2266 | setModified(); |
2267 | } | 2267 | } |
2268 | return ret; | 2268 | return ret; |
2269 | } | 2269 | } |
2270 | void KABCore::quickSyncLocalFile() | 2270 | void KABCore::quickSyncLocalFile() |
2271 | { | 2271 | { |
2272 | 2272 | ||
2273 | if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) { | 2273 | if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) { |
2274 | qDebug("quick syncLocalFile() successful "); | 2274 | qDebug("quick syncLocalFile() successful "); |
2275 | 2275 | ||
2276 | } | 2276 | } |
2277 | } | 2277 | } |
2278 | void KABCore::multiSync( bool askforPrefs ) | 2278 | void KABCore::multiSync( bool askforPrefs ) |
2279 | { | 2279 | { |
2280 | if (mBlockSaveFlag) | 2280 | if (mBlockSaveFlag) |
2281 | return; | 2281 | return; |
2282 | mBlockSaveFlag = true; | 2282 | mBlockSaveFlag = true; |
2283 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 2283 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
2284 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2284 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2285 | question, | 2285 | question, |
2286 | i18n("Yes"), i18n("No"), | 2286 | i18n("Yes"), i18n("No"), |
2287 | 0, 0 ) != 0 ) { | 2287 | 0, 0 ) != 0 ) { |
2288 | mBlockSaveFlag = false; | 2288 | mBlockSaveFlag = false; |
2289 | setCaption(i18n("Aborted! Nothing synced!")); | 2289 | setCaption(i18n("Aborted! Nothing synced!")); |
2290 | return; | 2290 | return; |
2291 | } | 2291 | } |
2292 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 2292 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
2293 | KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs; | 2293 | KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs; |
2294 | if ( askforPrefs ) { | 2294 | if ( askforPrefs ) { |
2295 | edit_sync_options(); | 2295 | edit_sync_options(); |
2296 | KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs; | 2296 | KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs; |
2297 | } | 2297 | } |
2298 | setCaption(i18n("Multiple sync started.") ); | 2298 | setCaption(i18n("Multiple sync started.") ); |
2299 | qApp->processEvents(); | 2299 | qApp->processEvents(); |
2300 | int num = ringSync() ; | 2300 | int num = ringSync() ; |
2301 | if ( num > 1 ) | 2301 | if ( num > 1 ) |
2302 | ringSync(); | 2302 | ringSync(); |
2303 | mBlockSaveFlag = false; | 2303 | mBlockSaveFlag = false; |
2304 | if ( num ) | 2304 | if ( num ) |
2305 | save(); | 2305 | save(); |
2306 | if ( num ) | 2306 | if ( num ) |
2307 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 2307 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); |
2308 | else | 2308 | else |
2309 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 2309 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
2310 | return; | 2310 | return; |
2311 | } | 2311 | } |
2312 | int KABCore::ringSync() | 2312 | int KABCore::ringSync() |
2313 | { | 2313 | { |
2314 | int syncedProfiles = 0; | 2314 | int syncedProfiles = 0; |
2315 | int i; | 2315 | int i; |
2316 | QTime timer; | 2316 | QTime timer; |
2317 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2317 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2318 | QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; | 2318 | QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; |
2319 | KSyncProfile* temp = new KSyncProfile (); | 2319 | KSyncProfile* temp = new KSyncProfile (); |
2320 | KABPrefs::instance()->mAskForPreferences = false; | 2320 | KABPrefs::instance()->mAskForPreferences = false; |
2321 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 2321 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
2322 | mCurrentSyncProfile = i; | 2322 | mCurrentSyncProfile = i; |
2323 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 2323 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
2324 | temp->readConfig(&config); | 2324 | temp->readConfig(&config); |
2325 | if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) { | 2325 | if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) { |
2326 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 2326 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
2327 | ++syncedProfiles; | 2327 | ++syncedProfiles; |
2328 | // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2328 | // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2329 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2329 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2330 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2330 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2331 | KABPrefs::instance()->mWriteBackInFuture = 0; | 2331 | KABPrefs::instance()->mWriteBackInFuture = 0; |
2332 | if ( temp->getWriteBackFuture() ) | 2332 | if ( temp->getWriteBackFuture() ) |
2333 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2333 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2334 | KABPrefs::instance()->mShowSyncSummary = false; | 2334 | KABPrefs::instance()->mShowSyncSummary = false; |
2335 | mCurrentSyncDevice = syncProfileNames[i] ; | 2335 | mCurrentSyncDevice = syncProfileNames[i] ; |
2336 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; | 2336 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; |
2337 | if ( i == 0 ) { | 2337 | if ( i == 0 ) { |
2338 | syncSharp(); | 2338 | syncSharp(); |
2339 | } else { | 2339 | } else { |
2340 | if ( temp->getIsLocalFileSync() ) { | 2340 | if ( temp->getIsLocalFileSync() ) { |
2341 | if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) ) | 2341 | if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) ) |
2342 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 2342 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
2343 | } else { | 2343 | } else { |
2344 | if ( temp->getIsPhoneSync() ) { | 2344 | if ( temp->getIsPhoneSync() ) { |
2345 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 2345 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
2346 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 2346 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
2347 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 2347 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
2348 | syncPhone(); | 2348 | syncPhone(); |
2349 | } else | 2349 | } else |
2350 | syncRemote( temp, false ); | 2350 | syncRemote( temp, false ); |
2351 | 2351 | ||
2352 | } | 2352 | } |
2353 | } | 2353 | } |
2354 | timer.start(); | 2354 | timer.start(); |
2355 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | 2355 | setCaption(i18n("Multiple sync in progress ... please wait!") ); |
2356 | while ( timer.elapsed () < 2000 ) { | 2356 | while ( timer.elapsed () < 2000 ) { |
2357 | qApp->processEvents(); | 2357 | qApp->processEvents(); |
2358 | #ifndef _WIN32_ | 2358 | #ifndef _WIN32_ |
2359 | sleep (1); | 2359 | sleep (1); |
2360 | #endif | 2360 | #endif |
2361 | } | 2361 | } |
2362 | 2362 | ||
2363 | } | 2363 | } |
2364 | 2364 | ||
2365 | } | 2365 | } |
2366 | delete temp; | 2366 | delete temp; |
2367 | return syncedProfiles; | 2367 | return syncedProfiles; |
2368 | } | 2368 | } |
2369 | 2369 | ||
2370 | void KABCore::syncRemote( KSyncProfile* prof, bool ask) | 2370 | void KABCore::syncRemote( KSyncProfile* prof, bool ask) |
2371 | { | 2371 | { |
2372 | QString question; | 2372 | QString question; |
2373 | if ( ask ) { | 2373 | if ( ask ) { |
2374 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 2374 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
2375 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2375 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2376 | question, | 2376 | question, |
2377 | i18n("Yes"), i18n("No"), | 2377 | i18n("Yes"), i18n("No"), |
2378 | 0, 0 ) != 0 ) | 2378 | 0, 0 ) != 0 ) |
2379 | return; | 2379 | return; |
2380 | } | 2380 | } |
2381 | QString command = prof->getPreSyncCommandAB(); | 2381 | QString command = prof->getPreSyncCommandAB(); |
2382 | int fi; | 2382 | int fi; |
2383 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2383 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2384 | QString pwd = getPassword(); | 2384 | QString pwd = getPassword(); |
2385 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2385 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2386 | 2386 | ||
2387 | } | 2387 | } |
2388 | int maxlen = 30; | 2388 | int maxlen = 30; |
2389 | if ( QApplication::desktop()->width() > 320 ) | 2389 | if ( QApplication::desktop()->width() > 320 ) |
2390 | maxlen += 25; | 2390 | maxlen += 25; |
2391 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | 2391 | setCaption ( i18n( "Copy remote file to local machine..." ) ); |
2392 | int fileSize = 0; | 2392 | int fileSize = 0; |
2393 | int result = system ( command ); | 2393 | int result = system ( command ); |
2394 | // 0 : okay | 2394 | // 0 : okay |
2395 | // 256: no such file or dir | 2395 | // 256: no such file or dir |
2396 | // | 2396 | // |
2397 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 2397 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
2398 | if ( result != 0 ) { | 2398 | if ( result != 0 ) { |
2399 | int len = maxlen; | 2399 | int len = maxlen; |
2400 | while ( len < command.length() ) { | 2400 | while ( len < command.length() ) { |
2401 | command.insert( len , "\n" ); | 2401 | command.insert( len , "\n" ); |
2402 | len += maxlen +2; | 2402 | len += maxlen +2; |
2403 | } | 2403 | } |
2404 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; | 2404 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; |
2405 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2405 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2406 | question, | 2406 | question, |
2407 | i18n("Okay!")) ; | 2407 | i18n("Okay!")) ; |
2408 | setCaption ("KO/Pi"); | 2408 | setCaption ("KO/Pi"); |
2409 | return; | 2409 | return; |
2410 | } | 2410 | } |
2411 | setCaption ( i18n( "Copying succeed." ) ); | 2411 | setCaption ( i18n( "Copying succeed." ) ); |
2412 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 2412 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
2413 | if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { | 2413 | if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { |
2414 | // Event* e = mView->getLastSyncEvent(); | 2414 | // Event* e = mView->getLastSyncEvent(); |
2415 | // e->setReadOnly( false ); | 2415 | // e->setReadOnly( false ); |
2416 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2416 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2417 | // e->setReadOnly( true ); | 2417 | // e->setReadOnly( true ); |
2418 | if ( KABPrefs::instance()->mWriteBackFile ) { | 2418 | if ( KABPrefs::instance()->mWriteBackFile ) { |
2419 | command = prof->getPostSyncCommandAB(); | 2419 | command = prof->getPostSyncCommandAB(); |
2420 | int fi; | 2420 | int fi; |
2421 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2421 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2422 | QString pwd = getPassword(); | 2422 | QString pwd = getPassword(); |
2423 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2423 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2424 | 2424 | ||
2425 | } | 2425 | } |
2426 | setCaption ( i18n( "Writing back file ..." ) ); | 2426 | setCaption ( i18n( "Writing back file ..." ) ); |
2427 | result = system ( command ); | 2427 | result = system ( command ); |
2428 | qDebug("KO: Writing back file result: %d ", result); | 2428 | qDebug("KO: Writing back file result: %d ", result); |
2429 | if ( result != 0 ) { | 2429 | if ( result != 0 ) { |
2430 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 2430 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
2431 | return; | 2431 | return; |
2432 | } else { | 2432 | } else { |
2433 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 2433 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
2434 | } | 2434 | } |
2435 | } | 2435 | } |
2436 | } | 2436 | } |
2437 | return; | 2437 | return; |
2438 | } | 2438 | } |
2439 | #include <qpushbutton.h> | 2439 | #include <qpushbutton.h> |
2440 | #include <qradiobutton.h> | 2440 | #include <qradiobutton.h> |
2441 | #include <qbuttongroup.h> | 2441 | #include <qbuttongroup.h> |
2442 | void KABCore::edit_sync_options() | 2442 | void KABCore::edit_sync_options() |
2443 | { | 2443 | { |
2444 | //mDialogManager->showSyncOptions(); | 2444 | //mDialogManager->showSyncOptions(); |
2445 | //KABPrefs::instance()->mSyncAlgoPrefs | 2445 | //KABPrefs::instance()->mSyncAlgoPrefs |
2446 | QDialog dia( this, "dia", true ); | 2446 | QDialog dia( this, "dia", true ); |
2447 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 2447 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
2448 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 2448 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
2449 | QVBoxLayout lay ( &dia ); | 2449 | QVBoxLayout lay ( &dia ); |
2450 | lay.setSpacing( 2 ); | 2450 | lay.setSpacing( 2 ); |
2451 | lay.setMargin( 3 ); | 2451 | lay.setMargin( 3 ); |
2452 | lay.addWidget(&gr); | 2452 | lay.addWidget(&gr); |
2453 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 2453 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
2454 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 2454 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
2455 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 2455 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
2456 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 2456 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
2457 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 2457 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
2458 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 2458 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
2459 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 2459 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
2460 | QPushButton pb ( "OK", &dia); | 2460 | QPushButton pb ( "OK", &dia); |
2461 | lay.addWidget( &pb ); | 2461 | lay.addWidget( &pb ); |
2462 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2462 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2463 | switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { | 2463 | switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { |
2464 | case 0: | 2464 | case 0: |
2465 | loc.setChecked( true); | 2465 | loc.setChecked( true); |
2466 | break; | 2466 | break; |
2467 | case 1: | 2467 | case 1: |
2468 | rem.setChecked( true ); | 2468 | rem.setChecked( true ); |
2469 | break; | 2469 | break; |
2470 | case 2: | 2470 | case 2: |
2471 | newest.setChecked( true); | 2471 | newest.setChecked( true); |
2472 | break; | 2472 | break; |
2473 | case 3: | 2473 | case 3: |
2474 | ask.setChecked( true); | 2474 | ask.setChecked( true); |
2475 | break; | 2475 | break; |
2476 | case 4: | 2476 | case 4: |
2477 | f_loc.setChecked( true); | 2477 | f_loc.setChecked( true); |
2478 | break; | 2478 | break; |
2479 | case 5: | 2479 | case 5: |
2480 | f_rem.setChecked( true); | 2480 | f_rem.setChecked( true); |
2481 | break; | 2481 | break; |
2482 | case 6: | 2482 | case 6: |
2483 | // both.setChecked( true); | 2483 | // both.setChecked( true); |
2484 | break; | 2484 | break; |
2485 | default: | 2485 | default: |
2486 | break; | 2486 | break; |
2487 | } | 2487 | } |
2488 | if ( dia.exec() ) { | 2488 | if ( dia.exec() ) { |
2489 | KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 2489 | KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
2490 | } | 2490 | } |
2491 | 2491 | ||
2492 | 2492 | ||
2493 | } | 2493 | } |
2494 | QString KABCore::getPassword( ) | 2494 | QString KABCore::getPassword( ) |
2495 | { | 2495 | { |
2496 | QString retfile = ""; | 2496 | QString retfile = ""; |
2497 | QDialog dia ( this, "input-dialog", true ); | 2497 | QDialog dia ( this, "input-dialog", true ); |
2498 | QLineEdit lab ( &dia ); | 2498 | QLineEdit lab ( &dia ); |
2499 | lab.setEchoMode( QLineEdit::Password ); | 2499 | lab.setEchoMode( QLineEdit::Password ); |
2500 | QVBoxLayout lay( &dia ); | 2500 | QVBoxLayout lay( &dia ); |
2501 | lay.setMargin(7); | 2501 | lay.setMargin(7); |
2502 | lay.setSpacing(7); | 2502 | lay.setSpacing(7); |
2503 | lay.addWidget( &lab); | 2503 | lay.addWidget( &lab); |
2504 | dia.setFixedSize( 230,50 ); | 2504 | dia.setFixedSize( 230,50 ); |
2505 | dia.setCaption( i18n("Enter password") ); | 2505 | dia.setCaption( i18n("Enter password") ); |
2506 | QPushButton pb ( "OK", &dia); | 2506 | QPushButton pb ( "OK", &dia); |
2507 | lay.addWidget( &pb ); | 2507 | lay.addWidget( &pb ); |
2508 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2508 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2509 | dia.show(); | 2509 | dia.show(); |
2510 | int res = dia.exec(); | 2510 | int res = dia.exec(); |
2511 | if ( res ) | 2511 | if ( res ) |
2512 | retfile = lab.text(); | 2512 | retfile = lab.text(); |
2513 | dia.hide(); | 2513 | dia.hide(); |
2514 | qApp->processEvents(); | 2514 | qApp->processEvents(); |
2515 | return retfile; | 2515 | return retfile; |
2516 | 2516 | ||
2517 | } | 2517 | } |
2518 | #include <libkcal/syncdefines.h> | 2518 | #include <libkcal/syncdefines.h> |
2519 | 2519 | ||
2520 | KABC::Addressee KABCore::getLastSyncAddressee() | 2520 | KABC::Addressee KABCore::getLastSyncAddressee() |
2521 | { | 2521 | { |
2522 | Addressee lse; | 2522 | Addressee lse; |
2523 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2523 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2524 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2524 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2525 | if (lse.isEmpty()) { | 2525 | if (lse.isEmpty()) { |
2526 | qDebug("Creating new last-syncAddressee "); | 2526 | qDebug("Creating new last-syncAddressee "); |
2527 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2527 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2528 | QString sum = ""; | 2528 | QString sum = ""; |
2529 | if ( KABPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 2529 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2530 | sum = "E: "; | 2530 | sum = "E: "; |
2531 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2531 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2532 | lse.setRevision( mLastAddressbookSync ); | 2532 | lse.setRevision( mLastAddressbookSync ); |
2533 | lse.setCategories( i18n("SyncEvent") ); | 2533 | lse.setCategories( i18n("SyncEvent") ); |
2534 | mAddressBook->insertAddressee( lse ); | 2534 | mAddressBook->insertAddressee( lse ); |
2535 | } | 2535 | } |
2536 | return lse; | 2536 | return lse; |
2537 | } | 2537 | } |
2538 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2538 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2539 | { | 2539 | { |
2540 | 2540 | ||
2541 | //void setZaurusId(int id); | 2541 | //void setZaurusId(int id); |
2542 | // int zaurusId() const; | 2542 | // int zaurusId() const; |
2543 | // void setZaurusUid(int id); | 2543 | // void setZaurusUid(int id); |
2544 | // int zaurusUid() const; | 2544 | // int zaurusUid() const; |
2545 | // void setZaurusStat(int id); | 2545 | // void setZaurusStat(int id); |
2546 | // int zaurusStat() const; | 2546 | // int zaurusStat() const; |
2547 | // 0 equal | 2547 | // 0 equal |
2548 | // 1 take local | 2548 | // 1 take local |
2549 | // 2 take remote | 2549 | // 2 take remote |
2550 | // 3 cancel | 2550 | // 3 cancel |
2551 | QDateTime lastSync = mLastAddressbookSync; | 2551 | QDateTime lastSync = mLastAddressbookSync; |
2552 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2552 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2553 | bool remCh, locCh; | 2553 | bool remCh, locCh; |
2554 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2554 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2555 | //if ( remCh ) | 2555 | if ( remCh ) |
2556 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2556 | qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2557 | locCh = ( local->revision() > mLastAddressbookSync ); | 2557 | locCh = ( local->revision() > mLastAddressbookSync ); |
2558 | if ( !remCh && ! locCh ) { | 2558 | if ( !remCh && ! locCh ) { |
2559 | //qDebug("both not changed "); | 2559 | qDebug("both not changed "); |
2560 | lastSync = local->revision().addDays(1); | 2560 | lastSync = local->revision().addDays(1); |
2561 | if ( mode <= SYNC_PREF_ASK ) | ||
2562 | return 0; | ||
2561 | } else { | 2563 | } else { |
2562 | if ( locCh ) { | 2564 | if ( locCh ) { |
2563 | //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); | 2565 | qDebug("loc changed %s %s", local->revision().toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2564 | lastSync = local->revision().addDays( -1 ); | 2566 | lastSync = local->revision().addDays( -1 ); |
2565 | if ( !remCh ) | 2567 | if ( !remCh ) |
2566 | remote->setRevision( lastSync.addDays( -1 ) ); | 2568 | remote->setRevision( lastSync.addDays( -1 ) ); |
2567 | } else { | 2569 | } else { |
2568 | //qDebug(" not loc changed "); | 2570 | //qDebug(" not loc changed "); |
2569 | lastSync = local->revision().addDays( 1 ); | 2571 | lastSync = local->revision().addDays( 1 ); |
2570 | if ( remCh ) | 2572 | if ( remCh ) |
2571 | remote->setRevision( lastSync.addDays( 1 ) ); | 2573 | remote->setRevision( lastSync.addDays( 1 ) ); |
2572 | 2574 | ||
2573 | } | 2575 | } |
2574 | } | 2576 | } |
2575 | full = true; | 2577 | full = true; |
2576 | if ( mode < SYNC_PREF_ASK ) | 2578 | if ( mode < SYNC_PREF_ASK ) |
2577 | mode = SYNC_PREF_ASK; | 2579 | mode = SYNC_PREF_ASK; |
2578 | } else { | 2580 | } else { |
2579 | if ( local->revision() == remote->revision() ) | 2581 | if ( local->revision() == remote->revision() ) |
2580 | return 0; | 2582 | return 0; |
2581 | 2583 | ||
2582 | } | 2584 | } |
2583 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2585 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2584 | 2586 | ||
2585 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 2587 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); |
2586 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2588 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2587 | //full = true; //debug only | 2589 | //full = true; //debug only |
2588 | if ( full ) { | 2590 | if ( full ) { |
2589 | bool equ = ( (*local) == (*remote) ); | 2591 | bool equ = ( (*local) == (*remote) ); |
2590 | if ( equ ) { | 2592 | if ( equ ) { |
2591 | //qDebug("equal "); | 2593 | //qDebug("equal "); |
2592 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2594 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2593 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2595 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2594 | } | 2596 | } |
2595 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2597 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2596 | return 0; | 2598 | return 0; |
2597 | 2599 | ||
2598 | }//else //debug only | 2600 | }//else //debug only |
2599 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2601 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2600 | } | 2602 | } |
2601 | int result; | 2603 | int result; |
2602 | bool localIsNew; | 2604 | bool localIsNew; |
2603 | //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() ); | 2605 | //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() ); |
2604 | 2606 | ||
2605 | if ( full && mode < SYNC_PREF_NEWEST ) | 2607 | if ( full && mode < SYNC_PREF_NEWEST ) |
2606 | mode = SYNC_PREF_ASK; | 2608 | mode = SYNC_PREF_ASK; |
2607 | 2609 | ||
2608 | switch( mode ) { | 2610 | switch( mode ) { |
2609 | case SYNC_PREF_LOCAL: | 2611 | case SYNC_PREF_LOCAL: |
2610 | if ( lastSync > remote->revision() ) | 2612 | if ( lastSync > remote->revision() ) |
2611 | return 1; | 2613 | return 1; |
2612 | if ( lastSync > local->revision() ) | 2614 | if ( lastSync > local->revision() ) |
2613 | return 2; | 2615 | return 2; |
2614 | return 1; | 2616 | return 1; |
2615 | break; | 2617 | break; |
2616 | case SYNC_PREF_REMOTE: | 2618 | case SYNC_PREF_REMOTE: |
2617 | if ( lastSync > remote->revision() ) | 2619 | if ( lastSync > remote->revision() ) |
2618 | return 1; | 2620 | return 1; |
2619 | if ( lastSync > local->revision() ) | 2621 | if ( lastSync > local->revision() ) |
2620 | return 2; | 2622 | return 2; |
2621 | return 2; | 2623 | return 2; |
2622 | break; | 2624 | break; |
2623 | case SYNC_PREF_NEWEST: | 2625 | case SYNC_PREF_NEWEST: |
2624 | if ( local->revision() > remote->revision() ) | 2626 | if ( local->revision() > remote->revision() ) |
2625 | return 1; | 2627 | return 1; |
2626 | else | 2628 | else |
2627 | return 2; | 2629 | return 2; |
2628 | break; | 2630 | break; |
2629 | case SYNC_PREF_ASK: | 2631 | case SYNC_PREF_ASK: |
2630 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); | 2632 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); |
2631 | if ( lastSync > remote->revision() ) | 2633 | if ( lastSync > remote->revision() ) |
2632 | return 1; | 2634 | return 1; |
2633 | if ( lastSync > local->revision() ) | 2635 | if ( lastSync > local->revision() ) |
2634 | return 2; | 2636 | return 2; |
2635 | localIsNew = local->revision() >= remote->revision(); | 2637 | localIsNew = local->revision() >= remote->revision(); |
2636 | //qDebug("conflict! ************************************** "); | 2638 | //qDebug("conflict! ************************************** "); |
2637 | { | 2639 | { |
2638 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2640 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2639 | result = acd.executeD(localIsNew); | 2641 | result = acd.executeD(localIsNew); |
2640 | return result; | 2642 | return result; |
2641 | } | 2643 | } |
2642 | break; | 2644 | break; |
2643 | case SYNC_PREF_FORCE_LOCAL: | 2645 | case SYNC_PREF_FORCE_LOCAL: |
2644 | return 1; | 2646 | return 1; |
2645 | break; | 2647 | break; |
2646 | case SYNC_PREF_FORCE_REMOTE: | 2648 | case SYNC_PREF_FORCE_REMOTE: |
2647 | return 2; | 2649 | return 2; |
2648 | break; | 2650 | break; |
2649 | 2651 | ||
2650 | default: | 2652 | default: |
2651 | // SYNC_PREF_TAKE_BOTH not implemented | 2653 | // SYNC_PREF_TAKE_BOTH not implemented |
2652 | break; | 2654 | break; |
2653 | } | 2655 | } |
2654 | return 0; | 2656 | return 0; |
2655 | } | 2657 | } |
2656 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2658 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2657 | { | 2659 | { |
2658 | bool syncOK = true; | 2660 | bool syncOK = true; |
2659 | int addedAddressee = 0; | 2661 | int addedAddressee = 0; |
2660 | int addedAddresseeR = 0; | 2662 | int addedAddresseeR = 0; |
2661 | int deletedAddresseeR = 0; | 2663 | int deletedAddresseeR = 0; |
2662 | int deletedAddresseeL = 0; | 2664 | int deletedAddresseeL = 0; |
2663 | int changedLocal = 0; | 2665 | int changedLocal = 0; |
2664 | int changedRemote = 0; | 2666 | int changedRemote = 0; |
2665 | //QPtrList<Addressee> el = local->rawAddressees(); | 2667 | //QPtrList<Addressee> el = local->rawAddressees(); |
2666 | Addressee addresseeR; | 2668 | Addressee addresseeR; |
2667 | QString uid; | 2669 | QString uid; |
2668 | int take; | 2670 | int take; |
2669 | Addressee addresseeL; | 2671 | Addressee addresseeL; |
2670 | Addressee addresseeRSync; | 2672 | Addressee addresseeRSync; |
2671 | Addressee addresseeLSync; | 2673 | Addressee addresseeLSync; |
2672 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2674 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2673 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2675 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2674 | bool fullDateRange = false; | 2676 | bool fullDateRange = false; |
2675 | local->resetTempSyncStat(); | 2677 | local->resetTempSyncStat(); |
2676 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2678 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2677 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2679 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2678 | addresseeLSync = getLastSyncAddressee(); | 2680 | addresseeLSync = getLastSyncAddressee(); |
2679 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2681 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2680 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2682 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2681 | if ( !addresseeR.isEmpty() ) { | 2683 | if ( !addresseeR.isEmpty() ) { |
2682 | addresseeRSync = addresseeR; | 2684 | addresseeRSync = addresseeR; |
2683 | remote->removeAddressee(addresseeR ); | 2685 | remote->removeAddressee(addresseeR ); |
2684 | 2686 | ||
2685 | } else { | 2687 | } else { |
2686 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2688 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2687 | addresseeRSync = addresseeLSync ; | 2689 | addresseeRSync = addresseeLSync ; |
2688 | } else { | 2690 | } else { |
2689 | qDebug("FULLDATE 1"); | 2691 | qDebug("FULLDATE 1"); |
2690 | fullDateRange = true; | 2692 | fullDateRange = true; |
2691 | Addressee newAdd; | 2693 | Addressee newAdd; |
2692 | addresseeRSync = newAdd; | 2694 | addresseeRSync = newAdd; |
2693 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2695 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2694 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2696 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2695 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2697 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2696 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2698 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2697 | } | 2699 | } |
2698 | } | 2700 | } |
2699 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2701 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2700 | qDebug("FULLDATE 2"); | 2702 | qDebug("FULLDATE 2"); |
2701 | fullDateRange = true; | 2703 | fullDateRange = true; |
2702 | } | 2704 | } |
2703 | if ( ! fullDateRange ) { | 2705 | if ( ! fullDateRange ) { |
2704 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2706 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2705 | 2707 | ||
2706 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2708 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2707 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2709 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2708 | fullDateRange = true; | 2710 | fullDateRange = true; |
2709 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2711 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2710 | } | 2712 | } |
2711 | } | 2713 | } |
2712 | // fullDateRange = true; // debug only! | 2714 | // fullDateRange = true; // debug only! |
2713 | if ( fullDateRange ) | 2715 | if ( fullDateRange ) |
2714 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2716 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2715 | else | 2717 | else |
2716 | mLastAddressbookSync = addresseeLSync.revision(); | 2718 | mLastAddressbookSync = addresseeLSync.revision(); |
2717 | // for resyncing if own file has changed | 2719 | // for resyncing if own file has changed |
2718 | // PENDING fixme later when implemented | 2720 | // PENDING fixme later when implemented |
2719 | #if 0 | 2721 | #if 0 |
2720 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2722 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2721 | mLastAddressbookSync = loadedFileVersion; | 2723 | mLastAddressbookSync = loadedFileVersion; |
2722 | qDebug("setting mLastAddressbookSync "); | 2724 | qDebug("setting mLastAddressbookSync "); |
2723 | } | 2725 | } |
2724 | #endif | 2726 | #endif |
2725 | 2727 | ||
2726 | //qDebug("*************************** "); | 2728 | //qDebug("*************************** "); |
2727 | qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2729 | qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2728 | QStringList er = remote->uidList(); | 2730 | QStringList er = remote->uidList(); |
2729 | Addressee inR ;//= er.first(); | 2731 | Addressee inR ;//= er.first(); |
2730 | Addressee inL; | 2732 | Addressee inL; |
2731 | QProgressBar bar( er.count(),0 ); | 2733 | QProgressBar bar( er.count(),0 ); |
2732 | bar.setCaption (i18n("Syncing - close to abort!") ); | 2734 | bar.setCaption (i18n("Syncing - close to abort!") ); |
2733 | 2735 | ||
2734 | int w = 300; | 2736 | int w = 300; |
2735 | if ( QApplication::desktop()->width() < 320 ) | 2737 | if ( QApplication::desktop()->width() < 320 ) |
2736 | w = 220; | 2738 | w = 220; |
2737 | int h = bar.sizeHint().height() ; | 2739 | int h = bar.sizeHint().height() ; |
2738 | int dw = QApplication::desktop()->width(); | 2740 | int dw = QApplication::desktop()->width(); |
2739 | int dh = QApplication::desktop()->height(); | 2741 | int dh = QApplication::desktop()->height(); |
2740 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2742 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2741 | bar.show(); | 2743 | bar.show(); |
2742 | int modulo = (er.count()/10)+1; | 2744 | int modulo = (er.count()/10)+1; |
2743 | int incCounter = 0; | 2745 | int incCounter = 0; |
2744 | while ( incCounter < er.count()) { | 2746 | while ( incCounter < er.count()) { |
2745 | if ( ! bar.isVisible() ) | 2747 | if ( ! bar.isVisible() ) |
2746 | return false; | 2748 | return false; |
2747 | if ( incCounter % modulo == 0 ) | 2749 | if ( incCounter % modulo == 0 ) |
2748 | bar.setProgress( incCounter ); | 2750 | bar.setProgress( incCounter ); |
2749 | uid = er[ incCounter ]; | 2751 | uid = er[ incCounter ]; |
2750 | bool skipIncidence = false; | 2752 | bool skipIncidence = false; |
2751 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2753 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2752 | skipIncidence = true; | 2754 | skipIncidence = true; |
2753 | QString idS; | 2755 | QString idS; |
2754 | qApp->processEvents(); | 2756 | qApp->processEvents(); |
2755 | if ( !skipIncidence ) { | 2757 | if ( !skipIncidence ) { |
2756 | inL = local->findByUid( uid ); | 2758 | inL = local->findByUid( uid ); |
2757 | inR = remote->findByUid( uid ); | 2759 | inR = remote->findByUid( uid ); |
2758 | //inL.setResource( 0 ); | 2760 | //inL.setResource( 0 ); |
2759 | //inR.setResource( 0 ); | 2761 | //inR.setResource( 0 ); |
2760 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2762 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2761 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2763 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2762 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2764 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2763 | if ( take == 3 ) | 2765 | if ( take == 3 ) |
2764 | return false; | 2766 | return false; |
2765 | if ( take == 1 ) {// take local | 2767 | if ( take == 1 ) {// take local |
2766 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2768 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2767 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2769 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2768 | local->insertAddressee( inL, false ); | 2770 | local->insertAddressee( inL, false ); |
2769 | } | 2771 | } |
2770 | else | 2772 | else |
2771 | idS = inR.IDStr(); | 2773 | idS = inR.IDStr(); |
2772 | remote->removeAddressee( inR ); | 2774 | remote->removeAddressee( inR ); |
2773 | inR = inL; | 2775 | inR = inL; |
2774 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2776 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2775 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 2777 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
2776 | inR.setIDStr( idS ); | 2778 | inR.setIDStr( idS ); |
2777 | inR.setResource( 0 ); | 2779 | inR.setResource( 0 ); |
2778 | remote->insertAddressee( inR , false); | 2780 | remote->insertAddressee( inR , false); |
2779 | ++changedRemote; | 2781 | ++changedRemote; |
2780 | } else { | 2782 | } else { |
2781 | idS = inL.IDStr(); | 2783 | idS = inL.IDStr(); |
2782 | local->removeAddressee( inL ); | 2784 | local->removeAddressee( inL ); |
2783 | inL = inR; | 2785 | inL = inR; |
2784 | inL.setIDStr( idS ); | 2786 | inL.setIDStr( idS ); |
2785 | inL.setResource( 0 ); | 2787 | inL.setResource( 0 ); |
2786 | local->insertAddressee( inL , false ); | 2788 | local->insertAddressee( inL , false ); |
2787 | ++changedLocal; | 2789 | ++changedLocal; |
2788 | } | 2790 | } |
2789 | } | 2791 | } |
2790 | } else { // no conflict | 2792 | } else { // no conflict |
2791 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2793 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2792 | QString des = addresseeLSync.note(); | 2794 | QString des = addresseeLSync.note(); |
2793 | QString pref = "a"; | 2795 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2794 | if ( des.find(pref+ inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | ||
2795 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2796 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2797 | remote->insertAddressee( inR, false ); | ||
2796 | ++deletedAddresseeR; | 2798 | ++deletedAddresseeR; |
2797 | } else { | 2799 | } else { |
2798 | inR.setRevision( modifiedCalendar ); | 2800 | inR.setRevision( modifiedCalendar ); |
2799 | remote->insertAddressee( inR, false ); | 2801 | remote->insertAddressee( inR, false ); |
2800 | inL = inR; | 2802 | inL = inR; |
2801 | inL.setResource( 0 ); | 2803 | inL.setResource( 0 ); |
2802 | local->insertAddressee( inL , false); | 2804 | local->insertAddressee( inL , false); |
2803 | ++addedAddressee; | 2805 | ++addedAddressee; |
2804 | } | 2806 | } |
2805 | } else { | 2807 | } else { |
2806 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2808 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2807 | inR.setRevision( modifiedCalendar ); | 2809 | inR.setRevision( modifiedCalendar ); |
2808 | remote->insertAddressee( inR, false ); | 2810 | remote->insertAddressee( inR, false ); |
2809 | inR.setResource( 0 ); | 2811 | inR.setResource( 0 ); |
2810 | local->insertAddressee( inR, false ); | 2812 | local->insertAddressee( inR, false ); |
2811 | ++addedAddressee; | 2813 | ++addedAddressee; |
2812 | } else { | 2814 | } else { |
2813 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2815 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2814 | remote->removeAddressee( inR ); | 2816 | remote->removeAddressee( inR ); |
2815 | ++deletedAddresseeR; | 2817 | ++deletedAddresseeR; |
2816 | } | 2818 | } |
2817 | } | 2819 | } |
2818 | } | 2820 | } |
2819 | } | 2821 | } |
2820 | ++incCounter; | 2822 | ++incCounter; |
2821 | } | 2823 | } |
2822 | er.clear(); | 2824 | er.clear(); |
2823 | QStringList el = remote->uidList(); | 2825 | QStringList el = local->uidList(); |
2824 | modulo = (el.count()/10)+1; | 2826 | modulo = (el.count()/10)+1; |
2825 | bar.setCaption (i18n("Add / remove addressees") ); | 2827 | bar.setCaption (i18n("Add / remove addressees") ); |
2826 | bar.setTotalSteps ( el.count() ) ; | 2828 | bar.setTotalSteps ( el.count() ) ; |
2827 | bar.show(); | 2829 | bar.show(); |
2828 | incCounter = 0; | 2830 | incCounter = 0; |
2829 | while ( incCounter < el.count()) { | 2831 | while ( incCounter < el.count()) { |
2830 | |||
2831 | qApp->processEvents(); | 2832 | qApp->processEvents(); |
2832 | if ( ! bar.isVisible() ) | 2833 | if ( ! bar.isVisible() ) |
2833 | return false; | 2834 | return false; |
2834 | if ( incCounter % modulo == 0 ) | 2835 | if ( incCounter % modulo == 0 ) |
2835 | bar.setProgress( incCounter ); | 2836 | bar.setProgress( incCounter ); |
2836 | uid = el[ incCounter ]; | 2837 | uid = el[ incCounter ]; |
2837 | bool skipIncidence = false; | 2838 | bool skipIncidence = false; |
2838 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2839 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2839 | skipIncidence = true; | 2840 | skipIncidence = true; |
2840 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | ||
2841 | skipIncidence = true; | ||
2842 | if ( !skipIncidence ) { | 2841 | if ( !skipIncidence ) { |
2843 | inL = local->findByUid( uid ); | 2842 | inL = local->findByUid( uid ); |
2844 | inR = remote->findByUid( uid ); | 2843 | inR = remote->findByUid( uid ); |
2845 | if ( inR.isEmpty() ) { | 2844 | if ( inR.isEmpty() ) { |
2846 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2845 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2847 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2846 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2848 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2847 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2849 | local->removeAddressee( inL ); | 2848 | local->removeAddressee( inL ); |
2850 | ++deletedAddresseeL; | 2849 | ++deletedAddresseeL; |
2851 | } else { | 2850 | } else { |
2852 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2851 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { |
2853 | inL.removeID(mCurrentSyncDevice ); | 2852 | inL.removeID(mCurrentSyncDevice ); |
2854 | ++addedAddresseeR; | 2853 | ++addedAddresseeR; |
2855 | //qDebug("remote added Incidence %s ", inL.summary().latin1()); | ||
2856 | inL.setRevision( modifiedCalendar ); | 2854 | inL.setRevision( modifiedCalendar ); |
2857 | local->insertAddressee( inL, false ); | 2855 | local->insertAddressee( inL, false ); |
2858 | inR = inL; | 2856 | inR = inL; |
2859 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2857 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2860 | inR.setResource( 0 ); | 2858 | inR.setResource( 0 ); |
2861 | remote->insertAddressee( inR, false ); | 2859 | remote->insertAddressee( inR, false ); |
2862 | } | 2860 | } |
2863 | } | 2861 | } |
2864 | } else { | 2862 | } else { |
2865 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2863 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2866 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2864 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2867 | local->removeAddressee( inL ); | 2865 | local->removeAddressee( inL ); |
2868 | ++deletedAddresseeL; | 2866 | ++deletedAddresseeL; |
2869 | } else { | 2867 | } else { |
2870 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2868 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { |
2871 | ++addedAddresseeR; | 2869 | ++addedAddresseeR; |
2872 | inL.setRevision( modifiedCalendar ); | 2870 | inL.setRevision( modifiedCalendar ); |
2873 | local->insertAddressee( inL, false ); | 2871 | local->insertAddressee( inL, false ); |
2874 | inR = inL; | 2872 | inR = inL; |
2875 | inR.setResource( 0 ); | 2873 | inR.setResource( 0 ); |
2876 | remote->insertAddressee( inR, false ); | 2874 | remote->insertAddressee( inR, false ); |
2877 | } | 2875 | } |
2878 | } | 2876 | } |
2879 | } | 2877 | } |
2880 | } | 2878 | } |
2881 | } | 2879 | } |
2882 | ++incCounter; | 2880 | ++incCounter; |
2883 | } | 2881 | } |
2884 | el.clear(); | 2882 | el.clear(); |
2885 | bar.hide(); | 2883 | bar.hide(); |
2886 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2884 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2887 | // get rid of micro seconds | 2885 | // get rid of micro seconds |
2888 | QTime t = mLastAddressbookSync.time(); | 2886 | QTime t = mLastAddressbookSync.time(); |
2889 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2887 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2890 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2888 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2891 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2889 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2892 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2890 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2893 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2891 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2894 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2892 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2895 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2893 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2896 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2894 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2897 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2895 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2896 | addresseeRSync.setNote( "" ) ; | ||
2897 | addresseeLSync.setNote( "" ); | ||
2898 | 2898 | ||
2899 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2899 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2900 | remote->insertAddressee( addresseeRSync, false ); | 2900 | remote->insertAddressee( addresseeRSync, false ); |
2901 | local->insertAddressee( addresseeLSync, false ); | 2901 | local->insertAddressee( addresseeLSync, false ); |
2902 | QString mes; | 2902 | QString mes; |
2903 | 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 ); | 2903 | 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 ); |
2904 | if ( KABPrefs::instance()->mShowSyncSummary ) { | 2904 | if ( KABPrefs::instance()->mShowSyncSummary ) { |
2905 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2905 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2906 | } | 2906 | } |
2907 | qDebug( mes ); | 2907 | qDebug( mes ); |
2908 | return syncOK; | 2908 | return syncOK; |
2909 | } | 2909 | } |
2910 | 2910 | ||
2911 | bool KABCore::syncAB(QString filename, int mode) | 2911 | bool KABCore::syncAB(QString filename, int mode) |
2912 | { | 2912 | { |
2913 | 2913 | ||
2914 | //pending prepare addresseeview for output | 2914 | //pending prepare addresseeview for output |
2915 | //pending detect, if remote file has REV field. if not switch to external sync | 2915 | //pending detect, if remote file has REV field. if not switch to external sync |
2916 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2916 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2917 | AddressBook abLocal(filename,"syncContact"); | 2917 | AddressBook abLocal(filename,"syncContact"); |
2918 | bool syncOK = false; | 2918 | bool syncOK = false; |
2919 | if ( abLocal.load() ) { | 2919 | if ( abLocal.load() ) { |
2920 | qDebug("AB loaded %s mode %d",filename.latin1(), mode ); | 2920 | qDebug("AB loaded %s mode %d",filename.latin1(), mode ); |
2921 | bool external = false; | 2921 | bool external = false; |
2922 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2922 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2923 | if ( ! lse.isEmpty() ) { | 2923 | if ( ! lse.isEmpty() ) { |
2924 | if ( lse.familyName().left(4) == "!E: " ) | 2924 | if ( lse.familyName().left(4) == "!E: " ) |
2925 | external = true; | 2925 | external = true; |
2926 | } else { | 2926 | } else { |
2927 | bool found = false; | 2927 | bool found = false; |
2928 | QDateTime dt( QDate( 2004,1,1)); | 2928 | QDateTime dt( QDate( 2004,1,1)); |
2929 | AddressBook::Iterator it; | 2929 | AddressBook::Iterator it; |
2930 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2930 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2931 | if ( (*it).revision() != dt ) { | 2931 | if ( (*it).revision() != dt ) { |
2932 | found = true; | 2932 | found = true; |
2933 | break; | 2933 | break; |
2934 | } | 2934 | } |
2935 | } | 2935 | } |
2936 | external = ! found; | 2936 | external = ! found; |
2937 | } | 2937 | } |
2938 | 2938 | ||
2939 | if ( external ) { | 2939 | if ( external ) { |
2940 | qDebug("**********Setting vcf mode to external "); | ||
2940 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2941 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2941 | AddressBook::Iterator it; | 2942 | AddressBook::Iterator it; |
2942 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2943 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2943 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2944 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2944 | (*it).computeCsum( mCurrentSyncDevice ); | 2945 | (*it).computeCsum( mCurrentSyncDevice ); |
2945 | } | 2946 | } |
2946 | } | 2947 | } |
2947 | //AddressBook::Iterator it; | 2948 | //AddressBook::Iterator it; |
2948 | //QStringList vcards; | 2949 | //QStringList vcards; |
2949 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2950 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2950 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2951 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2951 | //} | 2952 | //} |
2952 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2953 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2953 | if ( syncOK ) { | 2954 | if ( syncOK ) { |
2954 | if ( KABPrefs::instance()->mWriteBackFile ) | 2955 | if ( KABPrefs::instance()->mWriteBackFile ) |
2955 | { | 2956 | { |
2956 | if ( external ) | 2957 | if ( external ) |
2957 | abLocal.removeDeletedAddressees(); | 2958 | abLocal.removeDeletedAddressees(); |
2958 | qDebug("saving remote AB "); | 2959 | qDebug("saving remote AB "); |
2959 | abLocal.saveAB(); | 2960 | abLocal.saveAB(); |
2960 | } | 2961 | } |
2961 | } | 2962 | } |
2962 | setModified(); | 2963 | setModified(); |
2963 | 2964 | ||
2964 | } | 2965 | } |
2965 | if ( syncOK ) | 2966 | if ( syncOK ) |
2966 | mViewManager->refreshView(); | 2967 | mViewManager->refreshView(); |
2967 | return syncOK; | 2968 | return syncOK; |
2968 | #if 0 | 2969 | #if 0 |
2969 | 2970 | ||
2970 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2971 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2971 | getEventViewerDialog()->setSyncMode( true ); | 2972 | getEventViewerDialog()->setSyncMode( true ); |
2972 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2973 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2973 | getEventViewerDialog()->setSyncMode( false ); | 2974 | getEventViewerDialog()->setSyncMode( false ); |
2974 | if ( syncOK ) { | 2975 | if ( syncOK ) { |
2975 | if ( KOPrefs::instance()->mWriteBackFile ) | 2976 | if ( KOPrefs::instance()->mWriteBackFile ) |
2976 | { | 2977 | { |
2977 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2978 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2978 | storage->save(); | 2979 | storage->save(); |
2979 | } | 2980 | } |
2980 | } | 2981 | } |
2981 | setModified(); | 2982 | setModified(); |
2982 | } | 2983 | } |
2983 | 2984 | ||
2984 | #endif | 2985 | #endif |
2985 | } | 2986 | } |
2986 | 2987 | ||
2987 | void KABCore::confSync() | 2988 | void KABCore::confSync() |
2988 | { | 2989 | { |
2989 | static KSyncPrefsDialog* sp = 0; | 2990 | static KSyncPrefsDialog* sp = 0; |
2990 | if ( ! sp ) { | 2991 | if ( ! sp ) { |
2991 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 2992 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
2992 | } | 2993 | } |
2993 | sp->usrReadConfig(); | 2994 | sp->usrReadConfig(); |
2994 | #ifndef DESKTOP_VERSION | 2995 | #ifndef DESKTOP_VERSION |
2995 | sp->showMaximized(); | 2996 | sp->showMaximized(); |
2996 | #else | 2997 | #else |
2997 | sp->show(); | 2998 | sp->show(); |
2998 | #endif | 2999 | #endif |
2999 | sp->exec(); | 3000 | sp->exec(); |
3000 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 3001 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
3001 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 3002 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
3002 | fillSyncMenu(); | 3003 | fillSyncMenu(); |
3003 | } | 3004 | } |
3004 | void KABCore::syncSharp() | 3005 | void KABCore::syncSharp() |
3005 | { | 3006 | { |
3006 | if ( mModified ) | 3007 | if ( mModified ) |
3007 | save(); | 3008 | save(); |
3008 | qDebug("pending syncSharp() "); | 3009 | qDebug("pending syncSharp() "); |
3009 | //mView->syncSharp(); | 3010 | //mView->syncSharp(); |
3010 | setModified(); | 3011 | setModified(); |
3011 | 3012 | ||
3012 | } | 3013 | } |
3013 | void KABCore::syncPhone() | 3014 | void KABCore::syncPhone() |
3014 | { | 3015 | { |
3015 | if ( mModified ) | 3016 | if ( mModified ) |
3016 | save(); | 3017 | save(); |
3017 | qDebug("pending syncPhone(); "); | 3018 | qDebug("pending syncPhone(); "); |
3018 | //mView->syncPhone(); | 3019 | //mView->syncPhone(); |
3019 | setModified(); | 3020 | setModified(); |
3020 | 3021 | ||
3021 | } | 3022 | } |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 56b3fb0..0c75632 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,2273 +1,2275 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preston.brown@yale.edu) | 8 | Preston Brown (preston.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | 66 | ||
67 | #include <libkcal/vcaldrag.h> | 67 | #include <libkcal/vcaldrag.h> |
68 | #include <libkcal/icaldrag.h> | 68 | #include <libkcal/icaldrag.h> |
69 | #include <libkcal/icalformat.h> | 69 | #include <libkcal/icalformat.h> |
70 | #include <libkcal/vcalformat.h> | 70 | #include <libkcal/vcalformat.h> |
71 | #include <libkcal/scheduler.h> | 71 | #include <libkcal/scheduler.h> |
72 | #include <libkcal/calendarlocal.h> | 72 | #include <libkcal/calendarlocal.h> |
73 | #include <libkcal/journal.h> | 73 | #include <libkcal/journal.h> |
74 | #include <libkcal/calfilter.h> | 74 | #include <libkcal/calfilter.h> |
75 | #include <libkcal/attendee.h> | 75 | #include <libkcal/attendee.h> |
76 | #include <libkcal/dndfactory.h> | 76 | #include <libkcal/dndfactory.h> |
77 | #include <libkcal/freebusy.h> | 77 | #include <libkcal/freebusy.h> |
78 | #include <libkcal/filestorage.h> | 78 | #include <libkcal/filestorage.h> |
79 | #include <libkcal/calendarresources.h> | 79 | #include <libkcal/calendarresources.h> |
80 | #include <libkcal/qtopiaformat.h> | 80 | #include <libkcal/qtopiaformat.h> |
81 | #include "../kalarmd/alarmdialog.h" | 81 | #include "../kalarmd/alarmdialog.h" |
82 | 82 | ||
83 | #ifndef DESKTOP_VERSION | 83 | #ifndef DESKTOP_VERSION |
84 | #include <libkcal/sharpformat.h> | 84 | #include <libkcal/sharpformat.h> |
85 | #endif | 85 | #endif |
86 | #include <libkcal/phoneformat.h> | 86 | #include <libkcal/phoneformat.h> |
87 | #ifndef KORG_NOMAIL | 87 | #ifndef KORG_NOMAIL |
88 | #include "komailclient.h" | 88 | #include "komailclient.h" |
89 | #endif | 89 | #endif |
90 | #ifndef KORG_NOPRINTER | 90 | #ifndef KORG_NOPRINTER |
91 | #include "calprinter.h" | 91 | #include "calprinter.h" |
92 | #endif | 92 | #endif |
93 | #ifndef KORG_NOPLUGINS | 93 | #ifndef KORG_NOPLUGINS |
94 | #include "kocore.h" | 94 | #include "kocore.h" |
95 | #endif | 95 | #endif |
96 | #include "koeventeditor.h" | 96 | #include "koeventeditor.h" |
97 | #include "kotodoeditor.h" | 97 | #include "kotodoeditor.h" |
98 | #include "koprefs.h" | 98 | #include "koprefs.h" |
99 | #include "koeventviewerdialog.h" | 99 | #include "koeventviewerdialog.h" |
100 | #include "publishdialog.h" | 100 | #include "publishdialog.h" |
101 | #include "kofilterview.h" | 101 | #include "kofilterview.h" |
102 | #include "koglobals.h" | 102 | #include "koglobals.h" |
103 | #include "koviewmanager.h" | 103 | #include "koviewmanager.h" |
104 | #include "koagendaview.h" | 104 | #include "koagendaview.h" |
105 | #include "kodialogmanager.h" | 105 | #include "kodialogmanager.h" |
106 | #include "outgoingdialog.h" | 106 | #include "outgoingdialog.h" |
107 | #include "incomingdialog.h" | 107 | #include "incomingdialog.h" |
108 | #include "statusdialog.h" | 108 | #include "statusdialog.h" |
109 | #include "kdatenavigator.h" | 109 | #include "kdatenavigator.h" |
110 | #include "kotodoview.h" | 110 | #include "kotodoview.h" |
111 | #include "datenavigator.h" | 111 | #include "datenavigator.h" |
112 | #include "resourceview.h" | 112 | #include "resourceview.h" |
113 | #include "navigatorbar.h" | 113 | #include "navigatorbar.h" |
114 | #include "searchdialog.h" | 114 | #include "searchdialog.h" |
115 | #include "mainwindow.h" | 115 | #include "mainwindow.h" |
116 | 116 | ||
117 | #include "calendarview.h" | 117 | #include "calendarview.h" |
118 | #ifndef DESKTOP_VERSION | 118 | #ifndef DESKTOP_VERSION |
119 | #include <qtopia/alarmserver.h> | 119 | #include <qtopia/alarmserver.h> |
120 | #endif | 120 | #endif |
121 | #ifndef _WIN32_ | 121 | #ifndef _WIN32_ |
122 | #include <stdlib.h> | 122 | #include <stdlib.h> |
123 | #include <stdio.h> | 123 | #include <stdio.h> |
124 | #include <unistd.h> | 124 | #include <unistd.h> |
125 | #else | 125 | #else |
126 | #include <qprocess.h> | 126 | #include <qprocess.h> |
127 | #endif | 127 | #endif |
128 | using namespace KOrg; | 128 | using namespace KOrg; |
129 | using namespace KCal; | 129 | using namespace KCal; |
130 | extern int globalFlagBlockAgenda; | 130 | extern int globalFlagBlockAgenda; |
131 | extern int globalFlagBlockStartup; | 131 | extern int globalFlagBlockStartup; |
132 | 132 | ||
133 | 133 | ||
134 | 134 | ||
135 | class KOBeamPrefs : public QDialog | 135 | class KOBeamPrefs : public QDialog |
136 | { | 136 | { |
137 | public: | 137 | public: |
138 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 138 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
139 | QDialog( parent, name, true ) | 139 | QDialog( parent, name, true ) |
140 | { | 140 | { |
141 | setCaption( i18n("Beam Options") ); | 141 | setCaption( i18n("Beam Options") ); |
142 | QVBoxLayout* lay = new QVBoxLayout( this ); | 142 | QVBoxLayout* lay = new QVBoxLayout( this ); |
143 | lay->setSpacing( 3 ); | 143 | lay->setSpacing( 3 ); |
144 | lay->setMargin( 3 ); | 144 | lay->setMargin( 3 ); |
145 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 145 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
146 | lay->addWidget( format ); | 146 | lay->addWidget( format ); |
147 | format->setExclusive ( true ) ; | 147 | format->setExclusive ( true ) ; |
148 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 148 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
149 | lay->addWidget( time ); time->setExclusive ( true ) ; | 149 | lay->addWidget( time ); time->setExclusive ( true ) ; |
150 | vcal = new QRadioButton(" vCalendar ", format ); | 150 | vcal = new QRadioButton(" vCalendar ", format ); |
151 | ical = new QRadioButton(" iCalendar ", format ); | 151 | ical = new QRadioButton(" iCalendar ", format ); |
152 | vcal->setChecked( true ); | 152 | vcal->setChecked( true ); |
153 | tz = new QRadioButton(i18n(" With timezone "), time ); | 153 | tz = new QRadioButton(i18n(" With timezone "), time ); |
154 | local = new QRadioButton(i18n(" Local time "), time ); | 154 | local = new QRadioButton(i18n(" Local time "), time ); |
155 | tz->setChecked( true ); | 155 | tz->setChecked( true ); |
156 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 156 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
157 | lay->addWidget( ok ); | 157 | lay->addWidget( ok ); |
158 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 158 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
159 | lay->addWidget( cancel ); | 159 | lay->addWidget( cancel ); |
160 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 160 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
161 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 161 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
162 | resize( 200, 200 ); | 162 | resize( 200, 200 ); |
163 | } | 163 | } |
164 | 164 | ||
165 | bool beamVcal() { return vcal->isChecked(); } | 165 | bool beamVcal() { return vcal->isChecked(); } |
166 | bool beamLocal() { return local->isChecked(); } | 166 | bool beamLocal() { return local->isChecked(); } |
167 | private: | 167 | private: |
168 | QRadioButton* vcal, *ical, *local, *tz; | 168 | QRadioButton* vcal, *ical, *local, *tz; |
169 | }; | 169 | }; |
170 | class KOCatPrefs : public QDialog | 170 | class KOCatPrefs : public QDialog |
171 | { | 171 | { |
172 | public: | 172 | public: |
173 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 173 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
174 | QDialog( parent, name, true ) | 174 | QDialog( parent, name, true ) |
175 | { | 175 | { |
176 | setCaption( i18n("Manage new Categories") ); | 176 | setCaption( i18n("Manage new Categories") ); |
177 | QVBoxLayout* lay = new QVBoxLayout( this ); | 177 | QVBoxLayout* lay = new QVBoxLayout( this ); |
178 | lay->setSpacing( 3 ); | 178 | lay->setSpacing( 3 ); |
179 | lay->setMargin( 3 ); | 179 | lay->setMargin( 3 ); |
180 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 180 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
181 | lay->addWidget( lab ); | 181 | lay->addWidget( lab ); |
182 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 182 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
183 | lay->addWidget( format ); | 183 | lay->addWidget( format ); |
184 | format->setExclusive ( true ) ; | 184 | format->setExclusive ( true ) ; |
185 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 185 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
186 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 186 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
187 | addCatBut->setChecked( true ); | 187 | addCatBut->setChecked( true ); |
188 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 188 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
189 | lay->addWidget( ok ); | 189 | lay->addWidget( ok ); |
190 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 190 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
191 | lay->addWidget( cancel ); | 191 | lay->addWidget( cancel ); |
192 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 192 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
193 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 193 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
194 | resize( 200, 200 ); | 194 | resize( 200, 200 ); |
195 | } | 195 | } |
196 | 196 | ||
197 | bool addCat() { return addCatBut->isChecked(); } | 197 | bool addCat() { return addCatBut->isChecked(); } |
198 | private: | 198 | private: |
199 | QRadioButton* addCatBut; | 199 | QRadioButton* addCatBut; |
200 | }; | 200 | }; |
201 | 201 | ||
202 | 202 | ||
203 | 203 | ||
204 | CalendarView::CalendarView( CalendarResources *calendar, | 204 | CalendarView::CalendarView( CalendarResources *calendar, |
205 | QWidget *parent, const char *name ) | 205 | QWidget *parent, const char *name ) |
206 | : CalendarViewBase( parent, name ), | 206 | : CalendarViewBase( parent, name ), |
207 | mCalendar( calendar ), | 207 | mCalendar( calendar ), |
208 | mResourceManager( calendar->resourceManager() ) | 208 | mResourceManager( calendar->resourceManager() ) |
209 | { | 209 | { |
210 | 210 | ||
211 | mEventEditor = 0; | 211 | mEventEditor = 0; |
212 | mTodoEditor = 0; | 212 | mTodoEditor = 0; |
213 | 213 | ||
214 | init(); | 214 | init(); |
215 | } | 215 | } |
216 | 216 | ||
217 | CalendarView::CalendarView( Calendar *calendar, | 217 | CalendarView::CalendarView( Calendar *calendar, |
218 | QWidget *parent, const char *name ) | 218 | QWidget *parent, const char *name ) |
219 | : CalendarViewBase( parent, name ), | 219 | : CalendarViewBase( parent, name ), |
220 | mCalendar( calendar ), | 220 | mCalendar( calendar ), |
221 | mResourceManager( 0 ) | 221 | mResourceManager( 0 ) |
222 | { | 222 | { |
223 | 223 | ||
224 | mEventEditor = 0; | 224 | mEventEditor = 0; |
225 | mTodoEditor = 0; | 225 | mTodoEditor = 0; |
226 | init();} | 226 | init();} |
227 | 227 | ||
228 | void CalendarView::init() | 228 | void CalendarView::init() |
229 | { | 229 | { |
230 | beamDialog = new KOBeamPrefs(); | 230 | beamDialog = new KOBeamPrefs(); |
231 | mDatePickerMode = 0; | 231 | mDatePickerMode = 0; |
232 | mCurrentSyncDevice = ""; | 232 | mCurrentSyncDevice = ""; |
233 | writeLocale(); | 233 | writeLocale(); |
234 | mViewManager = new KOViewManager( this ); | 234 | mViewManager = new KOViewManager( this ); |
235 | mDialogManager = new KODialogManager( this ); | 235 | mDialogManager = new KODialogManager( this ); |
236 | mEventViewerDialog = 0; | 236 | mEventViewerDialog = 0; |
237 | mModified = false; | 237 | mModified = false; |
238 | mReadOnly = false; | 238 | mReadOnly = false; |
239 | mSelectedIncidence = 0; | 239 | mSelectedIncidence = 0; |
240 | mCalPrinter = 0; | 240 | mCalPrinter = 0; |
241 | mFilters.setAutoDelete(true); | 241 | mFilters.setAutoDelete(true); |
242 | 242 | ||
243 | mCalendar->registerObserver( this ); | 243 | mCalendar->registerObserver( this ); |
244 | // TODO: Make sure that view is updated, when calendar is changed. | 244 | // TODO: Make sure that view is updated, when calendar is changed. |
245 | 245 | ||
246 | mStorage = new FileStorage( mCalendar ); | 246 | mStorage = new FileStorage( mCalendar ); |
247 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 247 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
248 | 248 | ||
249 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 249 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
250 | #ifndef KORG_NOSPLITTER | 250 | #ifndef KORG_NOSPLITTER |
251 | // create the main layout frames. | 251 | // create the main layout frames. |
252 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 252 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
253 | topLayout->addWidget(mPanner); | 253 | topLayout->addWidget(mPanner); |
254 | 254 | ||
255 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 255 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
256 | "CalendarView::LeftFrame"); | 256 | "CalendarView::LeftFrame"); |
257 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 257 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
258 | 258 | ||
259 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 259 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
260 | "CalendarView::DateNavigator", QDate::currentDate() ); | 260 | "CalendarView::DateNavigator", QDate::currentDate() ); |
261 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 261 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
262 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 262 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
263 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 263 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
264 | 264 | ||
265 | #ifdef KORG_NORESOURCEVIEW | 265 | #ifdef KORG_NORESOURCEVIEW |
266 | mResourceView = 0; | 266 | mResourceView = 0; |
267 | #else | 267 | #else |
268 | if ( mResourceManager ) { | 268 | if ( mResourceManager ) { |
269 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 269 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
270 | mResourceView->updateView(); | 270 | mResourceView->updateView(); |
271 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 271 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
272 | SLOT( updateView() ) ); | 272 | SLOT( updateView() ) ); |
273 | } else { | 273 | } else { |
274 | mResourceView = 0; | 274 | mResourceView = 0; |
275 | } | 275 | } |
276 | #endif | 276 | #endif |
277 | QWidget *rightBox = new QWidget( mPanner ); | 277 | QWidget *rightBox = new QWidget( mPanner ); |
278 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 278 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
279 | 279 | ||
280 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 280 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
281 | rightLayout->addWidget( mNavigatorBar ); | 281 | rightLayout->addWidget( mNavigatorBar ); |
282 | 282 | ||
283 | mRightFrame = new QWidgetStack( rightBox ); | 283 | mRightFrame = new QWidgetStack( rightBox ); |
284 | rightLayout->addWidget( mRightFrame, 1 ); | 284 | rightLayout->addWidget( mRightFrame, 1 ); |
285 | 285 | ||
286 | mLeftFrame = mLeftSplitter; | 286 | mLeftFrame = mLeftSplitter; |
287 | #else | 287 | #else |
288 | QWidget *mainBox = new QWidget( this ); | 288 | QWidget *mainBox = new QWidget( this ); |
289 | QWidget *leftFrame = new QWidget( mainBox ); | 289 | QWidget *leftFrame = new QWidget( mainBox ); |
290 | 290 | ||
291 | QBoxLayout * mainBoxLayout; | 291 | QBoxLayout * mainBoxLayout; |
292 | QBoxLayout * leftFrameLayout; | 292 | QBoxLayout * leftFrameLayout; |
293 | if ( KOPrefs::instance()->mVerticalScreen ) { | 293 | if ( KOPrefs::instance()->mVerticalScreen ) { |
294 | mainBoxLayout = new QVBoxLayout(mainBox); | 294 | mainBoxLayout = new QVBoxLayout(mainBox); |
295 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 295 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
296 | } else { | 296 | } else { |
297 | mainBoxLayout = new QHBoxLayout(mainBox); | 297 | mainBoxLayout = new QHBoxLayout(mainBox); |
298 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 298 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
299 | } | 299 | } |
300 | topLayout->addWidget( mainBox ); | 300 | topLayout->addWidget( mainBox ); |
301 | mainBoxLayout->addWidget (leftFrame); | 301 | mainBoxLayout->addWidget (leftFrame); |
302 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 302 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
303 | "CalendarView::DateNavigator", QDate::currentDate()); | 303 | "CalendarView::DateNavigator", QDate::currentDate()); |
304 | // mDateNavigator->blockSignals( true ); | 304 | // mDateNavigator->blockSignals( true ); |
305 | leftFrameLayout->addWidget( mDateNavigator ); | 305 | leftFrameLayout->addWidget( mDateNavigator ); |
306 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 306 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
307 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); | 307 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); |
308 | 308 | ||
309 | if ( QApplication::desktop()->width() < 480 ) { | 309 | if ( QApplication::desktop()->width() < 480 ) { |
310 | leftFrameLayout->addWidget(mFilterView); | 310 | leftFrameLayout->addWidget(mFilterView); |
311 | leftFrameLayout->addWidget(mTodoList, 2 ); | 311 | leftFrameLayout->addWidget(mTodoList, 2 ); |
312 | 312 | ||
313 | } else { | 313 | } else { |
314 | leftFrameLayout->addWidget(mTodoList,2 ); | 314 | leftFrameLayout->addWidget(mTodoList,2 ); |
315 | leftFrameLayout->addWidget(mFilterView ); | 315 | leftFrameLayout->addWidget(mFilterView ); |
316 | } | 316 | } |
317 | mFilterView->hide(); | 317 | mFilterView->hide(); |
318 | QWidget *rightBox = new QWidget( mainBox ); | 318 | QWidget *rightBox = new QWidget( mainBox ); |
319 | mainBoxLayout->addWidget ( rightBox, 10 ); | 319 | mainBoxLayout->addWidget ( rightBox, 10 ); |
320 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 320 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
321 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 321 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
322 | mRightFrame = new QWidgetStack( rightBox ); | 322 | mRightFrame = new QWidgetStack( rightBox ); |
323 | rightLayout->addWidget( mNavigatorBar ); | 323 | rightLayout->addWidget( mNavigatorBar ); |
324 | rightLayout->addWidget( mRightFrame, 10 ); | 324 | rightLayout->addWidget( mRightFrame, 10 ); |
325 | 325 | ||
326 | mLeftFrame = leftFrame; | 326 | mLeftFrame = leftFrame; |
327 | if ( KOPrefs::instance()->mVerticalScreen ) { | 327 | if ( KOPrefs::instance()->mVerticalScreen ) { |
328 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 328 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
329 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 329 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
330 | } else { | 330 | } else { |
331 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 331 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
332 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 332 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
333 | } | 333 | } |
334 | 334 | ||
335 | //qDebug("Calendarview Size %d %d ", width(), height()); | 335 | //qDebug("Calendarview Size %d %d ", width(), height()); |
336 | #endif | 336 | #endif |
337 | 337 | ||
338 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 338 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
339 | SLOT( showDates( const KCal::DateList & ) ) ); | 339 | SLOT( showDates( const KCal::DateList & ) ) ); |
340 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 340 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
341 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 341 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
342 | 342 | ||
343 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 343 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
344 | mNavigator, SLOT( selectPreviousYear() ) ); | 344 | mNavigator, SLOT( selectPreviousYear() ) ); |
345 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 345 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
346 | mNavigator, SLOT( selectNextYear() ) ); | 346 | mNavigator, SLOT( selectNextYear() ) ); |
347 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 347 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
348 | mNavigator, SLOT( selectPreviousMonth() ) ); | 348 | mNavigator, SLOT( selectPreviousMonth() ) ); |
349 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 349 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
350 | mNavigator, SLOT( selectNextMonth() ) ); | 350 | mNavigator, SLOT( selectNextMonth() ) ); |
351 | 351 | ||
352 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 352 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
353 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 353 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
354 | 354 | ||
355 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 355 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
356 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 356 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
357 | 357 | ||
358 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 358 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
359 | mNavigator, SLOT( selectPreviousYear() ) ); | 359 | mNavigator, SLOT( selectPreviousYear() ) ); |
360 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 360 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
361 | mNavigator, SLOT( selectNextYear() ) ); | 361 | mNavigator, SLOT( selectNextYear() ) ); |
362 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 362 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
363 | mNavigator, SLOT( selectPreviousMonth() ) ); | 363 | mNavigator, SLOT( selectPreviousMonth() ) ); |
364 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 364 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
365 | mNavigator, SLOT( selectNextMonth() ) ); | 365 | mNavigator, SLOT( selectNextMonth() ) ); |
366 | 366 | ||
367 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 367 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
368 | mNavigator, SLOT( selectPrevious() ) ); | 368 | mNavigator, SLOT( selectPrevious() ) ); |
369 | connect( mDateNavigator, SIGNAL( goNext() ), | 369 | connect( mDateNavigator, SIGNAL( goNext() ), |
370 | mNavigator, SLOT( selectNext() ) ); | 370 | mNavigator, SLOT( selectNext() ) ); |
371 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 371 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
372 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 372 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
373 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 373 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
374 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 374 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
375 | 375 | ||
376 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 376 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
377 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 377 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
378 | 378 | ||
379 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 379 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
380 | SLOT( eventAdded( Event *) ) ); | 380 | SLOT( eventAdded( Event *) ) ); |
381 | 381 | ||
382 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 382 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
383 | 383 | ||
384 | connect( this, SIGNAL( configChanged() ), | 384 | connect( this, SIGNAL( configChanged() ), |
385 | mDateNavigator, SLOT( updateConfig() ) ); | 385 | mDateNavigator, SLOT( updateConfig() ) ); |
386 | 386 | ||
387 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 387 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
388 | SLOT( newTodo() ) ); | 388 | SLOT( newTodo() ) ); |
389 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 389 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
390 | SLOT( newSubTodo( Todo * ) ) ); | 390 | SLOT( newSubTodo( Todo * ) ) ); |
391 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 391 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
392 | SLOT( editTodo( Todo * ) ) ); | 392 | SLOT( editTodo( Todo * ) ) ); |
393 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 393 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
394 | SLOT( showTodo( Todo *) ) ); | 394 | SLOT( showTodo( Todo *) ) ); |
395 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 395 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
396 | SLOT( deleteTodo( Todo *) ) ); | 396 | SLOT( deleteTodo( Todo *) ) ); |
397 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 397 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
398 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 398 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
399 | SLOT( purgeCompleted() ) ); | 399 | SLOT( purgeCompleted() ) ); |
400 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 400 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
401 | SIGNAL( todoModified( Todo *, int ) ) ); | 401 | SIGNAL( todoModified( Todo *, int ) ) ); |
402 | 402 | ||
403 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 403 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
404 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 404 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
405 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 405 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
406 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 406 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
407 | 407 | ||
408 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 408 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
409 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 409 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
410 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 410 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
411 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 411 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
412 | 412 | ||
413 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 413 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
414 | this, SLOT ( todo_unsub( Todo * ) ) ); | 414 | this, SLOT ( todo_unsub( Todo * ) ) ); |
415 | 415 | ||
416 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 416 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
417 | SLOT( updateTodo( Todo *, int ) ) ); | 417 | SLOT( updateTodo( Todo *, int ) ) ); |
418 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 418 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
419 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 419 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
420 | 420 | ||
421 | 421 | ||
422 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 422 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
423 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 423 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
424 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 424 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
425 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 425 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
426 | 426 | ||
427 | 427 | ||
428 | 428 | ||
429 | 429 | ||
430 | 430 | ||
431 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 431 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
432 | SLOT(checkClipboard())); | 432 | SLOT(checkClipboard())); |
433 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 433 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
434 | SLOT( processTodoListSelection( Incidence * ) ) ); | 434 | SLOT( processTodoListSelection( Incidence * ) ) ); |
435 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 435 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
436 | 436 | ||
437 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 437 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
438 | 438 | ||
439 | mDateFrame = new QVBox(0,0,WType_Popup); | 439 | mDateFrame = new QVBox(0,0,WType_Popup); |
440 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 440 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
441 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 441 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
442 | mDateFrame->setLineWidth(3); | 442 | mDateFrame->setLineWidth(3); |
443 | mDateFrame->hide(); | 443 | mDateFrame->hide(); |
444 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 444 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
445 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 445 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
446 | 446 | ||
447 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 447 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
448 | 448 | ||
449 | mEventEditor = mDialogManager->getEventEditor(); | 449 | mEventEditor = mDialogManager->getEventEditor(); |
450 | mTodoEditor = mDialogManager->getTodoEditor(); | 450 | mTodoEditor = mDialogManager->getTodoEditor(); |
451 | 451 | ||
452 | mFlagEditDescription = false; | 452 | mFlagEditDescription = false; |
453 | 453 | ||
454 | mSuspendTimer = new QTimer( this ); | 454 | mSuspendTimer = new QTimer( this ); |
455 | mAlarmTimer = new QTimer( this ); | 455 | mAlarmTimer = new QTimer( this ); |
456 | mRecheckAlarmTimer = new QTimer( this ); | 456 | mRecheckAlarmTimer = new QTimer( this ); |
457 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 457 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
458 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 458 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
459 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 459 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
460 | mAlarmDialog = new AlarmDialog( this ); | 460 | mAlarmDialog = new AlarmDialog( this ); |
461 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 461 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
462 | mAlarmDialog->setServerNotification( false ); | 462 | mAlarmDialog->setServerNotification( false ); |
463 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 463 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | CalendarView::~CalendarView() | 467 | CalendarView::~CalendarView() |
468 | { | 468 | { |
469 | // kdDebug() << "~CalendarView()" << endl; | 469 | // kdDebug() << "~CalendarView()" << endl; |
470 | //qDebug("CalendarView::~CalendarView() "); | 470 | //qDebug("CalendarView::~CalendarView() "); |
471 | delete mDialogManager; | 471 | delete mDialogManager; |
472 | delete mViewManager; | 472 | delete mViewManager; |
473 | delete mStorage; | 473 | delete mStorage; |
474 | delete mDateFrame ; | 474 | delete mDateFrame ; |
475 | delete beamDialog; | 475 | delete beamDialog; |
476 | //kdDebug() << "~CalendarView() done" << endl; | 476 | //kdDebug() << "~CalendarView() done" << endl; |
477 | } | 477 | } |
478 | void CalendarView::timerAlarm() | 478 | void CalendarView::timerAlarm() |
479 | { | 479 | { |
480 | //qDebug("CalendarView::timerAlarm() "); | 480 | //qDebug("CalendarView::timerAlarm() "); |
481 | computeAlarm(mAlarmNotification ); | 481 | computeAlarm(mAlarmNotification ); |
482 | } | 482 | } |
483 | 483 | ||
484 | void CalendarView::suspendAlarm() | 484 | void CalendarView::suspendAlarm() |
485 | { | 485 | { |
486 | //qDebug(" CalendarView::suspendAlarm() "); | 486 | //qDebug(" CalendarView::suspendAlarm() "); |
487 | computeAlarm(mSuspendAlarmNotification ); | 487 | computeAlarm(mSuspendAlarmNotification ); |
488 | 488 | ||
489 | } | 489 | } |
490 | 490 | ||
491 | void CalendarView::startAlarm( QString mess , QString filename) | 491 | void CalendarView::startAlarm( QString mess , QString filename) |
492 | { | 492 | { |
493 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 493 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
494 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 494 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
495 | 495 | ||
496 | } | 496 | } |
497 | 497 | ||
498 | void CalendarView::checkNextTimerAlarm() | 498 | void CalendarView::checkNextTimerAlarm() |
499 | { | 499 | { |
500 | mCalendar->checkAlarmForIncidence( 0, true ); | 500 | mCalendar->checkAlarmForIncidence( 0, true ); |
501 | } | 501 | } |
502 | 502 | ||
503 | void CalendarView::computeAlarm( QString msg ) | 503 | void CalendarView::computeAlarm( QString msg ) |
504 | { | 504 | { |
505 | 505 | ||
506 | QString mess = msg; | 506 | QString mess = msg; |
507 | QString mAlarmMessage = mess.mid( 9 ); | 507 | QString mAlarmMessage = mess.mid( 9 ); |
508 | QString filename = MainWindow::resourcePath(); | 508 | QString filename = MainWindow::resourcePath(); |
509 | filename += "koalarm.wav"; | 509 | filename += "koalarm.wav"; |
510 | QString tempfilename; | 510 | QString tempfilename; |
511 | if ( mess.left( 13 ) == "suspend_alarm") { | 511 | if ( mess.left( 13 ) == "suspend_alarm") { |
512 | bool error = false; | 512 | bool error = false; |
513 | int len = mess.mid( 13 ).find("+++"); | 513 | int len = mess.mid( 13 ).find("+++"); |
514 | if ( len < 2 ) | 514 | if ( len < 2 ) |
515 | error = true; | 515 | error = true; |
516 | else { | 516 | else { |
517 | tempfilename = mess.mid( 13, len ); | 517 | tempfilename = mess.mid( 13, len ); |
518 | if ( !QFile::exists( tempfilename ) ) | 518 | if ( !QFile::exists( tempfilename ) ) |
519 | error = true; | 519 | error = true; |
520 | } | 520 | } |
521 | if ( ! error ) { | 521 | if ( ! error ) { |
522 | filename = tempfilename; | 522 | filename = tempfilename; |
523 | } | 523 | } |
524 | mAlarmMessage = mess.mid( 13+len+3 ); | 524 | mAlarmMessage = mess.mid( 13+len+3 ); |
525 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 525 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
526 | startAlarm( mAlarmMessage, filename); | 526 | startAlarm( mAlarmMessage, filename); |
527 | return; | 527 | return; |
528 | } | 528 | } |
529 | if ( mess.left( 11 ) == "timer_alarm") { | 529 | if ( mess.left( 11 ) == "timer_alarm") { |
530 | //mTimerTime = 0; | 530 | //mTimerTime = 0; |
531 | startAlarm( mess.mid( 11 ), filename ); | 531 | startAlarm( mess.mid( 11 ), filename ); |
532 | return; | 532 | return; |
533 | } | 533 | } |
534 | if ( mess.left( 10 ) == "proc_alarm") { | 534 | if ( mess.left( 10 ) == "proc_alarm") { |
535 | bool error = false; | 535 | bool error = false; |
536 | int len = mess.mid( 10 ).find("+++"); | 536 | int len = mess.mid( 10 ).find("+++"); |
537 | if ( len < 2 ) | 537 | if ( len < 2 ) |
538 | error = true; | 538 | error = true; |
539 | else { | 539 | else { |
540 | tempfilename = mess.mid( 10, len ); | 540 | tempfilename = mess.mid( 10, len ); |
541 | if ( !QFile::exists( tempfilename ) ) | 541 | if ( !QFile::exists( tempfilename ) ) |
542 | error = true; | 542 | error = true; |
543 | } | 543 | } |
544 | if ( error ) { | 544 | if ( error ) { |
545 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 545 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
546 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 546 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
547 | } else { | 547 | } else { |
548 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 548 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
549 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 549 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
550 | #ifndef _WIN32_ | 550 | #ifndef _WIN32_ |
551 | if ( vfork () == 0 ) { | 551 | if ( vfork () == 0 ) { |
552 | execl ( tempfilename.latin1(), 0 ); | 552 | execl ( tempfilename.latin1(), 0 ); |
553 | return; | 553 | return; |
554 | } | 554 | } |
555 | #else | 555 | #else |
556 | QProcess* p = new QProcess(); | 556 | QProcess* p = new QProcess(); |
557 | p->addArgument( tempfilename.latin1() ); | 557 | p->addArgument( tempfilename.latin1() ); |
558 | p->start(); | 558 | p->start(); |
559 | return; | 559 | return; |
560 | #endif | 560 | #endif |
561 | 561 | ||
562 | return; | 562 | return; |
563 | } | 563 | } |
564 | 564 | ||
565 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 565 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
566 | } | 566 | } |
567 | if ( mess.left( 11 ) == "audio_alarm") { | 567 | if ( mess.left( 11 ) == "audio_alarm") { |
568 | bool error = false; | 568 | bool error = false; |
569 | int len = mess.mid( 11 ).find("+++"); | 569 | int len = mess.mid( 11 ).find("+++"); |
570 | if ( len < 2 ) | 570 | if ( len < 2 ) |
571 | error = true; | 571 | error = true; |
572 | else { | 572 | else { |
573 | tempfilename = mess.mid( 11, len ); | 573 | tempfilename = mess.mid( 11, len ); |
574 | if ( !QFile::exists( tempfilename ) ) | 574 | if ( !QFile::exists( tempfilename ) ) |
575 | error = true; | 575 | error = true; |
576 | } | 576 | } |
577 | if ( ! error ) { | 577 | if ( ! error ) { |
578 | filename = tempfilename; | 578 | filename = tempfilename; |
579 | } | 579 | } |
580 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 580 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
581 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 581 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
582 | } | 582 | } |
583 | if ( mess.left( 9 ) == "cal_alarm") { | 583 | if ( mess.left( 9 ) == "cal_alarm") { |
584 | mAlarmMessage = mess.mid( 9 ) ; | 584 | mAlarmMessage = mess.mid( 9 ) ; |
585 | } | 585 | } |
586 | 586 | ||
587 | startAlarm( mAlarmMessage, filename ); | 587 | startAlarm( mAlarmMessage, filename ); |
588 | 588 | ||
589 | 589 | ||
590 | } | 590 | } |
591 | 591 | ||
592 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 592 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
593 | { | 593 | { |
594 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 594 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
595 | 595 | ||
596 | mSuspendAlarmNotification = noti; | 596 | mSuspendAlarmNotification = noti; |
597 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 597 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
598 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 598 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
599 | mSuspendTimer->start( ms , true ); | 599 | mSuspendTimer->start( ms , true ); |
600 | 600 | ||
601 | } | 601 | } |
602 | 602 | ||
603 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 603 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
604 | { | 604 | { |
605 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 605 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
606 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 606 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
607 | #ifndef DESKTOP_VERSION | 607 | #ifndef DESKTOP_VERSION |
608 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 608 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
609 | #endif | 609 | #endif |
610 | return; | 610 | return; |
611 | } | 611 | } |
612 | int maxSec; | 612 | int maxSec; |
613 | //maxSec = 5; //testing only | 613 | //maxSec = 5; //testing only |
614 | maxSec = 86400+3600; // one day+1hour | 614 | maxSec = 86400+3600; // one day+1hour |
615 | mAlarmNotification = noti; | 615 | mAlarmNotification = noti; |
616 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 616 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
617 | if ( sec > maxSec ) { | 617 | if ( sec > maxSec ) { |
618 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 618 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
619 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 619 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
620 | return; | 620 | return; |
621 | } else { | 621 | } else { |
622 | mRecheckAlarmTimer->stop(); | 622 | mRecheckAlarmTimer->stop(); |
623 | } | 623 | } |
624 | //qDebug("Alarm timer started with secs: %d ", sec); | 624 | //qDebug("Alarm timer started with secs: %d ", sec); |
625 | mAlarmTimer->start( sec *1000 , true ); | 625 | mAlarmTimer->start( sec *1000 , true ); |
626 | 626 | ||
627 | } | 627 | } |
628 | // called by mRecheckAlarmTimer to get next alarm | 628 | // called by mRecheckAlarmTimer to get next alarm |
629 | // we need this, because a QTimer has only a max range of 25 days | 629 | // we need this, because a QTimer has only a max range of 25 days |
630 | void CalendarView::recheckTimerAlarm() | 630 | void CalendarView::recheckTimerAlarm() |
631 | { | 631 | { |
632 | mAlarmTimer->stop(); | 632 | mAlarmTimer->stop(); |
633 | mRecheckAlarmTimer->stop(); | 633 | mRecheckAlarmTimer->stop(); |
634 | mCalendar->checkAlarmForIncidence( 0, true ); | 634 | mCalendar->checkAlarmForIncidence( 0, true ); |
635 | } | 635 | } |
636 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 636 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
637 | { | 637 | { |
638 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 638 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
639 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 639 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
640 | #ifndef DESKTOP_VERSION | 640 | #ifndef DESKTOP_VERSION |
641 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 641 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
642 | #endif | 642 | #endif |
643 | return; | 643 | return; |
644 | } | 644 | } |
645 | mAlarmTimer->stop(); | 645 | mAlarmTimer->stop(); |
646 | } | 646 | } |
647 | void CalendarView::selectWeekNum ( int num ) | 647 | void CalendarView::selectWeekNum ( int num ) |
648 | { | 648 | { |
649 | dateNavigator()->selectWeek( num ); | 649 | dateNavigator()->selectWeek( num ); |
650 | mViewManager->showWeekView(); | 650 | mViewManager->showWeekView(); |
651 | } | 651 | } |
652 | KOViewManager *CalendarView::viewManager() | 652 | KOViewManager *CalendarView::viewManager() |
653 | { | 653 | { |
654 | return mViewManager; | 654 | return mViewManager; |
655 | } | 655 | } |
656 | 656 | ||
657 | KODialogManager *CalendarView::dialogManager() | 657 | KODialogManager *CalendarView::dialogManager() |
658 | { | 658 | { |
659 | return mDialogManager; | 659 | return mDialogManager; |
660 | } | 660 | } |
661 | 661 | ||
662 | QDate CalendarView::startDate() | 662 | QDate CalendarView::startDate() |
663 | { | 663 | { |
664 | DateList dates = mNavigator->selectedDates(); | 664 | DateList dates = mNavigator->selectedDates(); |
665 | 665 | ||
666 | return dates.first(); | 666 | return dates.first(); |
667 | } | 667 | } |
668 | 668 | ||
669 | QDate CalendarView::endDate() | 669 | QDate CalendarView::endDate() |
670 | { | 670 | { |
671 | DateList dates = mNavigator->selectedDates(); | 671 | DateList dates = mNavigator->selectedDates(); |
672 | 672 | ||
673 | return dates.last(); | 673 | return dates.last(); |
674 | } | 674 | } |
675 | 675 | ||
676 | 676 | ||
677 | void CalendarView::createPrinter() | 677 | void CalendarView::createPrinter() |
678 | { | 678 | { |
679 | #ifndef KORG_NOPRINTER | 679 | #ifndef KORG_NOPRINTER |
680 | if (!mCalPrinter) { | 680 | if (!mCalPrinter) { |
681 | mCalPrinter = new CalPrinter(this, mCalendar); | 681 | mCalPrinter = new CalPrinter(this, mCalendar); |
682 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 682 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
683 | } | 683 | } |
684 | #endif | 684 | #endif |
685 | } | 685 | } |
686 | 686 | ||
687 | void CalendarView::confSync() | 687 | void CalendarView::confSync() |
688 | { | 688 | { |
689 | static KSyncPrefsDialog* sp = 0; | 689 | static KSyncPrefsDialog* sp = 0; |
690 | if ( ! sp ) { | 690 | if ( ! sp ) { |
691 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 691 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
692 | } | 692 | } |
693 | sp->usrReadConfig(); | 693 | sp->usrReadConfig(); |
694 | #ifndef DESKTOP_VERSION | 694 | #ifndef DESKTOP_VERSION |
695 | sp->showMaximized(); | 695 | sp->showMaximized(); |
696 | #else | 696 | #else |
697 | sp->show(); | 697 | sp->show(); |
698 | #endif | 698 | #endif |
699 | sp->exec(); | 699 | sp->exec(); |
700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
702 | } | 702 | } |
703 | 703 | ||
704 | 704 | ||
705 | //KOPrefs::instance()->mWriteBackFile | 705 | //KOPrefs::instance()->mWriteBackFile |
706 | //KOPrefs::instance()->mWriteBackExistingOnly | 706 | //KOPrefs::instance()->mWriteBackExistingOnly |
707 | 707 | ||
708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
714 | 714 | ||
715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
716 | { | 716 | { |
717 | 717 | ||
718 | //void setZaurusId(int id); | 718 | //void setZaurusId(int id); |
719 | // int zaurusId() const; | 719 | // int zaurusId() const; |
720 | // void setZaurusUid(int id); | 720 | // void setZaurusUid(int id); |
721 | // int zaurusUid() const; | 721 | // int zaurusUid() const; |
722 | // void setZaurusStat(int id); | 722 | // void setZaurusStat(int id); |
723 | // int zaurusStat() const; | 723 | // int zaurusStat() const; |
724 | // 0 equal | 724 | // 0 equal |
725 | // 1 take local | 725 | // 1 take local |
726 | // 2 take remote | 726 | // 2 take remote |
727 | // 3 cancel | 727 | // 3 cancel |
728 | QDateTime lastSync = mLastCalendarSync; | 728 | QDateTime lastSync = mLastCalendarSync; |
729 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 729 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
730 | bool remCh, locCh; | 730 | bool remCh, locCh; |
731 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 731 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
732 | //if ( remCh ) | 732 | //if ( remCh ) |
733 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 733 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
734 | locCh = ( local->lastModified() > mLastCalendarSync ); | 734 | locCh = ( local->lastModified() > mLastCalendarSync ); |
735 | if ( !remCh && ! locCh ) { | 735 | if ( !remCh && ! locCh ) { |
736 | //qDebug("both not changed "); | 736 | //qDebug("both not changed "); |
737 | lastSync = local->lastModified().addDays(1); | 737 | lastSync = local->lastModified().addDays(1); |
738 | if ( mode <= SYNC_PREF_ASK ) | ||
739 | return 0; | ||
738 | } else { | 740 | } else { |
739 | if ( locCh ) { | 741 | if ( locCh ) { |
740 | //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); | 742 | //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); |
741 | lastSync = local->lastModified().addDays( -1 ); | 743 | lastSync = local->lastModified().addDays( -1 ); |
742 | if ( !remCh ) | 744 | if ( !remCh ) |
743 | remote->setLastModified( lastSync.addDays( -1 ) ); | 745 | remote->setLastModified( lastSync.addDays( -1 ) ); |
744 | } else { | 746 | } else { |
745 | //qDebug(" not loc changed "); | 747 | //qDebug(" not loc changed "); |
746 | lastSync = local->lastModified().addDays( 1 ); | 748 | lastSync = local->lastModified().addDays( 1 ); |
747 | if ( remCh ) | 749 | if ( remCh ) |
748 | remote->setLastModified( lastSync.addDays( 1 ) ); | 750 | remote->setLastModified( lastSync.addDays( 1 ) ); |
749 | 751 | ||
750 | } | 752 | } |
751 | } | 753 | } |
752 | full = true; | 754 | full = true; |
753 | if ( mode < SYNC_PREF_ASK ) | 755 | if ( mode < SYNC_PREF_ASK ) |
754 | mode = SYNC_PREF_ASK; | 756 | mode = SYNC_PREF_ASK; |
755 | } else { | 757 | } else { |
756 | if ( local->lastModified() == remote->lastModified() ) | 758 | if ( local->lastModified() == remote->lastModified() ) |
757 | if ( local->revision() == remote->revision() ) | 759 | if ( local->revision() == remote->revision() ) |
758 | return 0; | 760 | return 0; |
759 | 761 | ||
760 | } | 762 | } |
761 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 763 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
762 | 764 | ||
763 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 765 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); |
764 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 766 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
765 | //full = true; //debug only | 767 | //full = true; //debug only |
766 | if ( full ) { | 768 | if ( full ) { |
767 | bool equ = false; | 769 | bool equ = false; |
768 | if ( local->type() == "Event" ) { | 770 | if ( local->type() == "Event" ) { |
769 | equ = (*((Event*) local) == *((Event*) remote)); | 771 | equ = (*((Event*) local) == *((Event*) remote)); |
770 | } | 772 | } |
771 | else if ( local->type() =="Todo" ) | 773 | else if ( local->type() =="Todo" ) |
772 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 774 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
773 | else if ( local->type() =="Journal" ) | 775 | else if ( local->type() =="Journal" ) |
774 | equ = (*((Journal*) local) == *((Journal*) remote)); | 776 | equ = (*((Journal*) local) == *((Journal*) remote)); |
775 | if ( equ ) { | 777 | if ( equ ) { |
776 | //qDebug("equal "); | 778 | //qDebug("equal "); |
777 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 779 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
778 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 780 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
779 | } | 781 | } |
780 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 782 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
781 | return 0; | 783 | return 0; |
782 | 784 | ||
783 | }//else //debug only | 785 | }//else //debug only |
784 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 786 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
785 | } | 787 | } |
786 | int result; | 788 | int result; |
787 | bool localIsNew; | 789 | bool localIsNew; |
788 | //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() ); | 790 | //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() ); |
789 | 791 | ||
790 | if ( full && mode < SYNC_PREF_NEWEST ) | 792 | if ( full && mode < SYNC_PREF_NEWEST ) |
791 | mode = SYNC_PREF_ASK; | 793 | mode = SYNC_PREF_ASK; |
792 | 794 | ||
793 | switch( mode ) { | 795 | switch( mode ) { |
794 | case SYNC_PREF_LOCAL: | 796 | case SYNC_PREF_LOCAL: |
795 | if ( lastSync > remote->lastModified() ) | 797 | if ( lastSync > remote->lastModified() ) |
796 | return 1; | 798 | return 1; |
797 | if ( lastSync > local->lastModified() ) | 799 | if ( lastSync > local->lastModified() ) |
798 | return 2; | 800 | return 2; |
799 | return 1; | 801 | return 1; |
800 | break; | 802 | break; |
801 | case SYNC_PREF_REMOTE: | 803 | case SYNC_PREF_REMOTE: |
802 | if ( lastSync > remote->lastModified() ) | 804 | if ( lastSync > remote->lastModified() ) |
803 | return 1; | 805 | return 1; |
804 | if ( lastSync > local->lastModified() ) | 806 | if ( lastSync > local->lastModified() ) |
805 | return 2; | 807 | return 2; |
806 | return 2; | 808 | return 2; |
807 | break; | 809 | break; |
808 | case SYNC_PREF_NEWEST: | 810 | case SYNC_PREF_NEWEST: |
809 | if ( local->lastModified() > remote->lastModified() ) | 811 | if ( local->lastModified() > remote->lastModified() ) |
810 | return 1; | 812 | return 1; |
811 | else | 813 | else |
812 | return 2; | 814 | return 2; |
813 | break; | 815 | break; |
814 | case SYNC_PREF_ASK: | 816 | case SYNC_PREF_ASK: |
815 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
816 | if ( lastSync > remote->lastModified() ) | 818 | if ( lastSync > remote->lastModified() ) |
817 | return 1; | 819 | return 1; |
818 | if ( lastSync > local->lastModified() ) | 820 | if ( lastSync > local->lastModified() ) |
819 | return 2; | 821 | return 2; |
820 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 822 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
821 | localIsNew = local->lastModified() >= remote->lastModified(); | 823 | localIsNew = local->lastModified() >= remote->lastModified(); |
822 | if ( localIsNew ) | 824 | if ( localIsNew ) |
823 | getEventViewerDialog()->setColorMode( 1 ); | 825 | getEventViewerDialog()->setColorMode( 1 ); |
824 | else | 826 | else |
825 | getEventViewerDialog()->setColorMode( 2 ); | 827 | getEventViewerDialog()->setColorMode( 2 ); |
826 | getEventViewerDialog()->setIncidence(local); | 828 | getEventViewerDialog()->setIncidence(local); |
827 | if ( localIsNew ) | 829 | if ( localIsNew ) |
828 | getEventViewerDialog()->setColorMode( 2 ); | 830 | getEventViewerDialog()->setColorMode( 2 ); |
829 | else | 831 | else |
830 | getEventViewerDialog()->setColorMode( 1 ); | 832 | getEventViewerDialog()->setColorMode( 1 ); |
831 | getEventViewerDialog()->addIncidence(remote); | 833 | getEventViewerDialog()->addIncidence(remote); |
832 | getEventViewerDialog()->setColorMode( 0 ); | 834 | getEventViewerDialog()->setColorMode( 0 ); |
833 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 835 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
834 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 836 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
835 | getEventViewerDialog()->showMe(); | 837 | getEventViewerDialog()->showMe(); |
836 | result = getEventViewerDialog()->executeS( localIsNew ); | 838 | result = getEventViewerDialog()->executeS( localIsNew ); |
837 | return result; | 839 | return result; |
838 | 840 | ||
839 | break; | 841 | break; |
840 | case SYNC_PREF_FORCE_LOCAL: | 842 | case SYNC_PREF_FORCE_LOCAL: |
841 | return 1; | 843 | return 1; |
842 | break; | 844 | break; |
843 | case SYNC_PREF_FORCE_REMOTE: | 845 | case SYNC_PREF_FORCE_REMOTE: |
844 | return 2; | 846 | return 2; |
845 | break; | 847 | break; |
846 | 848 | ||
847 | default: | 849 | default: |
848 | // SYNC_PREF_TAKE_BOTH not implemented | 850 | // SYNC_PREF_TAKE_BOTH not implemented |
849 | break; | 851 | break; |
850 | } | 852 | } |
851 | return 0; | 853 | return 0; |
852 | } | 854 | } |
853 | Event* CalendarView::getLastSyncEvent() | 855 | Event* CalendarView::getLastSyncEvent() |
854 | { | 856 | { |
855 | Event* lse; | 857 | Event* lse; |
856 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 858 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
857 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 859 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
858 | if (!lse) { | 860 | if (!lse) { |
859 | lse = new Event(); | 861 | lse = new Event(); |
860 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 862 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
861 | QString sum = ""; | 863 | QString sum = ""; |
862 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 864 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
863 | sum = "E: "; | 865 | sum = "E: "; |
864 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 866 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
865 | lse->setDtStart( mLastCalendarSync ); | 867 | lse->setDtStart( mLastCalendarSync ); |
866 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 868 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
867 | lse->setCategories( i18n("SyncEvent") ); | 869 | lse->setCategories( i18n("SyncEvent") ); |
868 | lse->setReadOnly( true ); | 870 | lse->setReadOnly( true ); |
869 | mCalendar->addEvent( lse ); | 871 | mCalendar->addEvent( lse ); |
870 | } | 872 | } |
871 | 873 | ||
872 | return lse; | 874 | return lse; |
873 | 875 | ||
874 | } | 876 | } |
875 | // probaly useless | 877 | // probaly useless |
876 | void CalendarView::setupExternSyncProfiles() | 878 | void CalendarView::setupExternSyncProfiles() |
877 | { | 879 | { |
878 | Event* lse; | 880 | Event* lse; |
879 | mExternLastSyncEvent.clear(); | 881 | mExternLastSyncEvent.clear(); |
880 | int i; | 882 | int i; |
881 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { | 883 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { |
882 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); | 884 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); |
883 | if ( lse ) | 885 | if ( lse ) |
884 | mExternLastSyncEvent.append( lse ); | 886 | mExternLastSyncEvent.append( lse ); |
885 | else | 887 | else |
886 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); | 888 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); |
887 | } | 889 | } |
888 | 890 | ||
889 | } | 891 | } |
890 | // we check, if the to delete event has a id for a profile | 892 | // we check, if the to delete event has a id for a profile |
891 | // if yes, we set this id in the profile to delete | 893 | // if yes, we set this id in the profile to delete |
892 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 894 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
893 | { | 895 | { |
894 | if ( lastSync.count() == 0 ) { | 896 | if ( lastSync.count() == 0 ) { |
895 | //qDebug(" lastSync.count() == 0"); | 897 | //qDebug(" lastSync.count() == 0"); |
896 | return; | 898 | return; |
897 | } | 899 | } |
898 | if ( toDelete->type() == "Journal" ) | 900 | if ( toDelete->type() == "Journal" ) |
899 | return; | 901 | return; |
900 | 902 | ||
901 | Event* eve = lastSync.first(); | 903 | Event* eve = lastSync.first(); |
902 | 904 | ||
903 | while ( eve ) { | 905 | while ( eve ) { |
904 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 906 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
905 | if ( !id.isEmpty() ) { | 907 | if ( !id.isEmpty() ) { |
906 | QString des = eve->description(); | 908 | QString des = eve->description(); |
907 | QString pref = "e"; | 909 | QString pref = "e"; |
908 | if ( toDelete->type() == "Todo" ) | 910 | if ( toDelete->type() == "Todo" ) |
909 | pref = "t"; | 911 | pref = "t"; |
910 | des += pref+ id + ","; | 912 | des += pref+ id + ","; |
911 | eve->setReadOnly( false ); | 913 | eve->setReadOnly( false ); |
912 | eve->setDescription( des ); | 914 | eve->setDescription( des ); |
913 | //qDebug("setdes %s ", des.latin1()); | 915 | //qDebug("setdes %s ", des.latin1()); |
914 | eve->setReadOnly( true ); | 916 | eve->setReadOnly( true ); |
915 | } | 917 | } |
916 | eve = lastSync.next(); | 918 | eve = lastSync.next(); |
917 | } | 919 | } |
918 | 920 | ||
919 | } | 921 | } |
920 | void CalendarView::checkExternalId( Incidence * inc ) | 922 | void CalendarView::checkExternalId( Incidence * inc ) |
921 | { | 923 | { |
922 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 924 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
923 | checkExternSyncEvent( lastSync, inc ); | 925 | checkExternSyncEvent( lastSync, inc ); |
924 | 926 | ||
925 | } | 927 | } |
926 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 928 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
927 | { | 929 | { |
928 | bool syncOK = true; | 930 | bool syncOK = true; |
929 | int addedEvent = 0; | 931 | int addedEvent = 0; |
930 | int addedEventR = 0; | 932 | int addedEventR = 0; |
931 | int deletedEventR = 0; | 933 | int deletedEventR = 0; |
932 | int deletedEventL = 0; | 934 | int deletedEventL = 0; |
933 | int changedLocal = 0; | 935 | int changedLocal = 0; |
934 | int changedRemote = 0; | 936 | int changedRemote = 0; |
935 | //QPtrList<Event> el = local->rawEvents(); | 937 | //QPtrList<Event> el = local->rawEvents(); |
936 | Event* eventR; | 938 | Event* eventR; |
937 | QString uid; | 939 | QString uid; |
938 | int take; | 940 | int take; |
939 | Event* eventL; | 941 | Event* eventL; |
940 | Event* eventRSync; | 942 | Event* eventRSync; |
941 | Event* eventLSync; | 943 | Event* eventLSync; |
942 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 944 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
943 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 945 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
944 | bool fullDateRange = false; | 946 | bool fullDateRange = false; |
945 | local->resetTempSyncStat(); | 947 | local->resetTempSyncStat(); |
946 | mLastCalendarSync = QDateTime::currentDateTime(); | 948 | mLastCalendarSync = QDateTime::currentDateTime(); |
947 | QDateTime modifiedCalendar = mLastCalendarSync;; | 949 | QDateTime modifiedCalendar = mLastCalendarSync;; |
948 | eventLSync = getLastSyncEvent(); | 950 | eventLSync = getLastSyncEvent(); |
949 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 951 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
950 | if ( eventR ) { | 952 | if ( eventR ) { |
951 | eventRSync = (Event*) eventR->clone(); | 953 | eventRSync = (Event*) eventR->clone(); |
952 | remote->deleteEvent(eventR ); | 954 | remote->deleteEvent(eventR ); |
953 | 955 | ||
954 | } else { | 956 | } else { |
955 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 957 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
956 | eventRSync = (Event*)eventLSync->clone(); | 958 | eventRSync = (Event*)eventLSync->clone(); |
957 | } else { | 959 | } else { |
958 | fullDateRange = true; | 960 | fullDateRange = true; |
959 | eventRSync = new Event(); | 961 | eventRSync = new Event(); |
960 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 962 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
961 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 963 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
962 | eventRSync->setDtStart( mLastCalendarSync ); | 964 | eventRSync->setDtStart( mLastCalendarSync ); |
963 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 965 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
964 | eventRSync->setCategories( i18n("SyncEvent") ); | 966 | eventRSync->setCategories( i18n("SyncEvent") ); |
965 | } | 967 | } |
966 | } | 968 | } |
967 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 969 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
968 | fullDateRange = true; | 970 | fullDateRange = true; |
969 | 971 | ||
970 | if ( ! fullDateRange ) { | 972 | if ( ! fullDateRange ) { |
971 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 973 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
972 | 974 | ||
973 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 975 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
974 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 976 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
975 | fullDateRange = true; | 977 | fullDateRange = true; |
976 | } | 978 | } |
977 | } | 979 | } |
978 | if ( fullDateRange ) | 980 | if ( fullDateRange ) |
979 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 981 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
980 | else | 982 | else |
981 | mLastCalendarSync = eventLSync->dtStart(); | 983 | mLastCalendarSync = eventLSync->dtStart(); |
982 | // for resyncing if own file has changed | 984 | // for resyncing if own file has changed |
983 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 985 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
984 | mLastCalendarSync = loadedFileVersion; | 986 | mLastCalendarSync = loadedFileVersion; |
985 | qDebug("setting mLastCalendarSync "); | 987 | qDebug("setting mLastCalendarSync "); |
986 | } | 988 | } |
987 | //qDebug("*************************** "); | 989 | //qDebug("*************************** "); |
988 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 990 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
989 | QPtrList<Incidence> er = remote->rawIncidences(); | 991 | QPtrList<Incidence> er = remote->rawIncidences(); |
990 | Incidence* inR = er.first(); | 992 | Incidence* inR = er.first(); |
991 | Incidence* inL; | 993 | Incidence* inL; |
992 | QProgressBar bar( er.count(),0 ); | 994 | QProgressBar bar( er.count(),0 ); |
993 | bar.setCaption (i18n("Syncing - close to abort!") ); | 995 | bar.setCaption (i18n("Syncing - close to abort!") ); |
994 | 996 | ||
995 | int w = 300; | 997 | int w = 300; |
996 | if ( QApplication::desktop()->width() < 320 ) | 998 | if ( QApplication::desktop()->width() < 320 ) |
997 | w = 220; | 999 | w = 220; |
998 | int h = bar.sizeHint().height() ; | 1000 | int h = bar.sizeHint().height() ; |
999 | int dw = QApplication::desktop()->width(); | 1001 | int dw = QApplication::desktop()->width(); |
1000 | int dh = QApplication::desktop()->height(); | 1002 | int dh = QApplication::desktop()->height(); |
1001 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1003 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1002 | bar.show(); | 1004 | bar.show(); |
1003 | int modulo = (er.count()/10)+1; | 1005 | int modulo = (er.count()/10)+1; |
1004 | int incCounter = 0; | 1006 | int incCounter = 0; |
1005 | while ( inR ) { | 1007 | while ( inR ) { |
1006 | if ( ! bar.isVisible() ) | 1008 | if ( ! bar.isVisible() ) |
1007 | return false; | 1009 | return false; |
1008 | if ( incCounter % modulo == 0 ) | 1010 | if ( incCounter % modulo == 0 ) |
1009 | bar.setProgress( incCounter ); | 1011 | bar.setProgress( incCounter ); |
1010 | ++incCounter; | 1012 | ++incCounter; |
1011 | uid = inR->uid(); | 1013 | uid = inR->uid(); |
1012 | bool skipIncidence = false; | 1014 | bool skipIncidence = false; |
1013 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1015 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1014 | skipIncidence = true; | 1016 | skipIncidence = true; |
1015 | QString idS; | 1017 | QString idS; |
1016 | qApp->processEvents(); | 1018 | qApp->processEvents(); |
1017 | if ( !skipIncidence ) { | 1019 | if ( !skipIncidence ) { |
1018 | inL = local->incidence( uid ); | 1020 | inL = local->incidence( uid ); |
1019 | if ( inL ) { // maybe conflict - same uid in both calendars | 1021 | if ( inL ) { // maybe conflict - same uid in both calendars |
1020 | int maxrev = inL->revision(); | 1022 | int maxrev = inL->revision(); |
1021 | if ( maxrev < inR->revision() ) | 1023 | if ( maxrev < inR->revision() ) |
1022 | maxrev = inR->revision(); | 1024 | maxrev = inR->revision(); |
1023 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1025 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1024 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1026 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1025 | if ( take == 3 ) | 1027 | if ( take == 3 ) |
1026 | return false; | 1028 | return false; |
1027 | if ( take == 1 ) {// take local | 1029 | if ( take == 1 ) {// take local |
1028 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1030 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1029 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1031 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1030 | else | 1032 | else |
1031 | idS = inR->IDStr(); | 1033 | idS = inR->IDStr(); |
1032 | remote->deleteIncidence( inR ); | 1034 | remote->deleteIncidence( inR ); |
1033 | if ( inL->revision() < maxrev ) | 1035 | if ( inL->revision() < maxrev ) |
1034 | inL->setRevision( maxrev ); | 1036 | inL->setRevision( maxrev ); |
1035 | inR = inL->clone(); | 1037 | inR = inL->clone(); |
1036 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1038 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1037 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1039 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1038 | inR->setIDStr( idS ); | 1040 | inR->setIDStr( idS ); |
1039 | remote->addIncidence( inR ); | 1041 | remote->addIncidence( inR ); |
1040 | ++changedRemote; | 1042 | ++changedRemote; |
1041 | } else { | 1043 | } else { |
1042 | if ( inR->revision() < maxrev ) | 1044 | if ( inR->revision() < maxrev ) |
1043 | inR->setRevision( maxrev ); | 1045 | inR->setRevision( maxrev ); |
1044 | idS = inL->IDStr(); | 1046 | idS = inL->IDStr(); |
1045 | local->deleteIncidence( inL ); | 1047 | local->deleteIncidence( inL ); |
1046 | inL = inR->clone(); | 1048 | inL = inR->clone(); |
1047 | inL->setIDStr( idS ); | 1049 | inL->setIDStr( idS ); |
1048 | local->addIncidence( inL ); | 1050 | local->addIncidence( inL ); |
1049 | ++changedLocal; | 1051 | ++changedLocal; |
1050 | } | 1052 | } |
1051 | } | 1053 | } |
1052 | } else { // no conflict | 1054 | } else { // no conflict |
1053 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1055 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1054 | QString des = eventLSync->description(); | 1056 | QString des = eventLSync->description(); |
1055 | QString pref = "e"; | 1057 | QString pref = "e"; |
1056 | if ( inR->type() == "Todo" ) | 1058 | if ( inR->type() == "Todo" ) |
1057 | pref = "t"; | 1059 | pref = "t"; |
1058 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1060 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1059 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1061 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1060 | //remote->deleteIncidence( inR ); | 1062 | //remote->deleteIncidence( inR ); |
1061 | ++deletedEventR; | 1063 | ++deletedEventR; |
1062 | } else { | 1064 | } else { |
1063 | inR->setLastModified( modifiedCalendar ); | 1065 | inR->setLastModified( modifiedCalendar ); |
1064 | inL = inR->clone(); | 1066 | inL = inR->clone(); |
1065 | local->addIncidence( inL ); | 1067 | local->addIncidence( inL ); |
1066 | ++addedEvent; | 1068 | ++addedEvent; |
1067 | } | 1069 | } |
1068 | } else { | 1070 | } else { |
1069 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1071 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1070 | inR->setLastModified( modifiedCalendar ); | 1072 | inR->setLastModified( modifiedCalendar ); |
1071 | local->addIncidence( inR->clone() ); | 1073 | local->addIncidence( inR->clone() ); |
1072 | ++addedEvent; | 1074 | ++addedEvent; |
1073 | } else { | 1075 | } else { |
1074 | checkExternSyncEvent(eventRSyncSharp, inR); | 1076 | checkExternSyncEvent(eventRSyncSharp, inR); |
1075 | remote->deleteIncidence( inR ); | 1077 | remote->deleteIncidence( inR ); |
1076 | ++deletedEventR; | 1078 | ++deletedEventR; |
1077 | } | 1079 | } |
1078 | } | 1080 | } |
1079 | } | 1081 | } |
1080 | } | 1082 | } |
1081 | inR = er.next(); | 1083 | inR = er.next(); |
1082 | } | 1084 | } |
1083 | QPtrList<Incidence> el = local->rawIncidences(); | 1085 | QPtrList<Incidence> el = local->rawIncidences(); |
1084 | inL = el.first(); | 1086 | inL = el.first(); |
1085 | modulo = (el.count()/10)+1; | 1087 | modulo = (el.count()/10)+1; |
1086 | bar.setCaption (i18n("Add / remove events") ); | 1088 | bar.setCaption (i18n("Add / remove events") ); |
1087 | bar.setTotalSteps ( el.count() ) ; | 1089 | bar.setTotalSteps ( el.count() ) ; |
1088 | bar.show(); | 1090 | bar.show(); |
1089 | incCounter = 0; | 1091 | incCounter = 0; |
1090 | 1092 | ||
1091 | while ( inL ) { | 1093 | while ( inL ) { |
1092 | 1094 | ||
1093 | qApp->processEvents(); | 1095 | qApp->processEvents(); |
1094 | if ( ! bar.isVisible() ) | 1096 | if ( ! bar.isVisible() ) |
1095 | return false; | 1097 | return false; |
1096 | if ( incCounter % modulo == 0 ) | 1098 | if ( incCounter % modulo == 0 ) |
1097 | bar.setProgress( incCounter ); | 1099 | bar.setProgress( incCounter ); |
1098 | ++incCounter; | 1100 | ++incCounter; |
1099 | uid = inL->uid(); | 1101 | uid = inL->uid(); |
1100 | bool skipIncidence = false; | 1102 | bool skipIncidence = false; |
1101 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1103 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1102 | skipIncidence = true; | 1104 | skipIncidence = true; |
1103 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1105 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1104 | skipIncidence = true; | 1106 | skipIncidence = true; |
1105 | if ( !skipIncidence ) { | 1107 | if ( !skipIncidence ) { |
1106 | inR = remote->incidence( uid ); | 1108 | inR = remote->incidence( uid ); |
1107 | if ( ! inR ) { | 1109 | if ( ! inR ) { |
1108 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1110 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1109 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1111 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1110 | checkExternSyncEvent(eventLSyncSharp, inL); | 1112 | checkExternSyncEvent(eventLSyncSharp, inL); |
1111 | local->deleteIncidence( inL ); | 1113 | local->deleteIncidence( inL ); |
1112 | ++deletedEventL; | 1114 | ++deletedEventL; |
1113 | } else { | 1115 | } else { |
1114 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1116 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1115 | inL->removeID(mCurrentSyncDevice ); | 1117 | inL->removeID(mCurrentSyncDevice ); |
1116 | ++addedEventR; | 1118 | ++addedEventR; |
1117 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1119 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1118 | inL->setLastModified( modifiedCalendar ); | 1120 | inL->setLastModified( modifiedCalendar ); |
1119 | inR = inL->clone(); | 1121 | inR = inL->clone(); |
1120 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1122 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1121 | remote->addIncidence( inR ); | 1123 | remote->addIncidence( inR ); |
1122 | } | 1124 | } |
1123 | } | 1125 | } |
1124 | } else { | 1126 | } else { |
1125 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1127 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1126 | checkExternSyncEvent(eventLSyncSharp, inL); | 1128 | checkExternSyncEvent(eventLSyncSharp, inL); |
1127 | local->deleteIncidence( inL ); | 1129 | local->deleteIncidence( inL ); |
1128 | ++deletedEventL; | 1130 | ++deletedEventL; |
1129 | } else { | 1131 | } else { |
1130 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1132 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1131 | ++addedEventR; | 1133 | ++addedEventR; |
1132 | inL->setLastModified( modifiedCalendar ); | 1134 | inL->setLastModified( modifiedCalendar ); |
1133 | remote->addIncidence( inL->clone() ); | 1135 | remote->addIncidence( inL->clone() ); |
1134 | } | 1136 | } |
1135 | } | 1137 | } |
1136 | } | 1138 | } |
1137 | } | 1139 | } |
1138 | } | 1140 | } |
1139 | inL = el.next(); | 1141 | inL = el.next(); |
1140 | } | 1142 | } |
1141 | int delFut = 0; | 1143 | int delFut = 0; |
1142 | if ( KOPrefs::instance()->mWriteBackInFuture ) { | 1144 | if ( KOPrefs::instance()->mWriteBackInFuture ) { |
1143 | er = remote->rawIncidences(); | 1145 | er = remote->rawIncidences(); |
1144 | inR = er.first(); | 1146 | inR = er.first(); |
1145 | QDateTime dt; | 1147 | QDateTime dt; |
1146 | QDateTime cur = QDateTime::currentDateTime(); | 1148 | QDateTime cur = QDateTime::currentDateTime(); |
1147 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); | 1149 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); |
1148 | while ( inR ) { | 1150 | while ( inR ) { |
1149 | if ( inR->type() == "Todo" ) { | 1151 | if ( inR->type() == "Todo" ) { |
1150 | Todo * t = (Todo*)inR; | 1152 | Todo * t = (Todo*)inR; |
1151 | if ( t->hasDueDate() ) | 1153 | if ( t->hasDueDate() ) |
1152 | dt = t->dtDue(); | 1154 | dt = t->dtDue(); |
1153 | else | 1155 | else |
1154 | dt = cur.addSecs( 62 ); | 1156 | dt = cur.addSecs( 62 ); |
1155 | } | 1157 | } |
1156 | else if (inR->type() == "Event" ) { | 1158 | else if (inR->type() == "Event" ) { |
1157 | bool ok; | 1159 | bool ok; |
1158 | dt = inR->getNextOccurence( cur, &ok ); | 1160 | dt = inR->getNextOccurence( cur, &ok ); |
1159 | if ( !ok ) | 1161 | if ( !ok ) |
1160 | dt = cur.addSecs( -62 ); | 1162 | dt = cur.addSecs( -62 ); |
1161 | } | 1163 | } |
1162 | else | 1164 | else |
1163 | dt = inR->dtStart(); | 1165 | dt = inR->dtStart(); |
1164 | if ( dt < cur || dt > end ) { | 1166 | if ( dt < cur || dt > end ) { |
1165 | remote->deleteIncidence( inR ); | 1167 | remote->deleteIncidence( inR ); |
1166 | ++delFut; | 1168 | ++delFut; |
1167 | } | 1169 | } |
1168 | inR = er.next(); | 1170 | inR = er.next(); |
1169 | } | 1171 | } |
1170 | } | 1172 | } |
1171 | bar.hide(); | 1173 | bar.hide(); |
1172 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1174 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1173 | eventLSync->setReadOnly( false ); | 1175 | eventLSync->setReadOnly( false ); |
1174 | eventLSync->setDtStart( mLastCalendarSync ); | 1176 | eventLSync->setDtStart( mLastCalendarSync ); |
1175 | eventRSync->setDtStart( mLastCalendarSync ); | 1177 | eventRSync->setDtStart( mLastCalendarSync ); |
1176 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1178 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1177 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1179 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1178 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1180 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1179 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1181 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1180 | eventLSync->setReadOnly( true ); | 1182 | eventLSync->setReadOnly( true ); |
1181 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1183 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
1182 | remote->addEvent( eventRSync ); | 1184 | remote->addEvent( eventRSync ); |
1183 | QString mes; | 1185 | QString mes; |
1184 | 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1186 | 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); |
1185 | QString delmess; | 1187 | QString delmess; |
1186 | if ( delFut ) { | 1188 | if ( delFut ) { |
1187 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); | 1189 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); |
1188 | mes += delmess; | 1190 | mes += delmess; |
1189 | } | 1191 | } |
1190 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 1192 | if ( KOPrefs::instance()->mShowSyncSummary ) { |
1191 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1193 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1192 | } | 1194 | } |
1193 | qDebug( mes ); | 1195 | qDebug( mes ); |
1194 | mCalendar->checkAlarmForIncidence( 0, true ); | 1196 | mCalendar->checkAlarmForIncidence( 0, true ); |
1195 | return syncOK; | 1197 | return syncOK; |
1196 | } | 1198 | } |
1197 | 1199 | ||
1198 | void CalendarView::setSyncDevice( QString s ) | 1200 | void CalendarView::setSyncDevice( QString s ) |
1199 | { | 1201 | { |
1200 | mCurrentSyncDevice= s; | 1202 | mCurrentSyncDevice= s; |
1201 | } | 1203 | } |
1202 | void CalendarView::setSyncName( QString s ) | 1204 | void CalendarView::setSyncName( QString s ) |
1203 | { | 1205 | { |
1204 | mCurrentSyncName= s; | 1206 | mCurrentSyncName= s; |
1205 | } | 1207 | } |
1206 | bool CalendarView::syncCalendar(QString filename, int mode) | 1208 | bool CalendarView::syncCalendar(QString filename, int mode) |
1207 | { | 1209 | { |
1208 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1210 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1209 | CalendarLocal* calendar = new CalendarLocal(); | 1211 | CalendarLocal* calendar = new CalendarLocal(); |
1210 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1212 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1211 | FileStorage* storage = new FileStorage( calendar ); | 1213 | FileStorage* storage = new FileStorage( calendar ); |
1212 | bool syncOK = false; | 1214 | bool syncOK = false; |
1213 | storage->setFileName( filename ); | 1215 | storage->setFileName( filename ); |
1214 | // qDebug("loading ... "); | 1216 | // qDebug("loading ... "); |
1215 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 1217 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
1216 | getEventViewerDialog()->setSyncMode( true ); | 1218 | getEventViewerDialog()->setSyncMode( true ); |
1217 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1219 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1218 | getEventViewerDialog()->setSyncMode( false ); | 1220 | getEventViewerDialog()->setSyncMode( false ); |
1219 | if ( syncOK ) { | 1221 | if ( syncOK ) { |
1220 | if ( KOPrefs::instance()->mWriteBackFile ) | 1222 | if ( KOPrefs::instance()->mWriteBackFile ) |
1221 | { | 1223 | { |
1222 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 1224 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
1223 | storage->save(); | 1225 | storage->save(); |
1224 | } | 1226 | } |
1225 | } | 1227 | } |
1226 | setModified( true ); | 1228 | setModified( true ); |
1227 | } | 1229 | } |
1228 | delete storage; | 1230 | delete storage; |
1229 | delete calendar; | 1231 | delete calendar; |
1230 | if ( syncOK ) | 1232 | if ( syncOK ) |
1231 | updateView(); | 1233 | updateView(); |
1232 | return syncOK; | 1234 | return syncOK; |
1233 | } | 1235 | } |
1234 | void CalendarView::syncPhone() | 1236 | void CalendarView::syncPhone() |
1235 | { | 1237 | { |
1236 | syncExternal( 1 ); | 1238 | syncExternal( 1 ); |
1237 | } | 1239 | } |
1238 | void CalendarView::syncExternal( int mode ) | 1240 | void CalendarView::syncExternal( int mode ) |
1239 | { | 1241 | { |
1240 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1242 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1241 | //mCurrentSyncDevice = "sharp-DTM"; | 1243 | //mCurrentSyncDevice = "sharp-DTM"; |
1242 | if ( KOPrefs::instance()->mAskForPreferences ) | 1244 | if ( KOPrefs::instance()->mAskForPreferences ) |
1243 | edit_sync_options(); | 1245 | edit_sync_options(); |
1244 | qApp->processEvents(); | 1246 | qApp->processEvents(); |
1245 | CalendarLocal* calendar = new CalendarLocal(); | 1247 | CalendarLocal* calendar = new CalendarLocal(); |
1246 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1248 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1247 | bool syncOK = false; | 1249 | bool syncOK = false; |
1248 | bool loadSuccess = false; | 1250 | bool loadSuccess = false; |
1249 | PhoneFormat* phoneFormat = 0; | 1251 | PhoneFormat* phoneFormat = 0; |
1250 | #ifndef DESKTOP_VERSION | 1252 | #ifndef DESKTOP_VERSION |
1251 | SharpFormat* sharpFormat = 0; | 1253 | SharpFormat* sharpFormat = 0; |
1252 | if ( mode == 0 ) { // sharp | 1254 | if ( mode == 0 ) { // sharp |
1253 | sharpFormat = new SharpFormat () ; | 1255 | sharpFormat = new SharpFormat () ; |
1254 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1256 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1255 | 1257 | ||
1256 | } else | 1258 | } else |
1257 | #endif | 1259 | #endif |
1258 | if ( mode == 1 ) { // phone | 1260 | if ( mode == 1 ) { // phone |
1259 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1261 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1260 | KOPrefs::instance()->mPhoneDevice, | 1262 | KOPrefs::instance()->mPhoneDevice, |
1261 | KOPrefs::instance()->mPhoneConnection, | 1263 | KOPrefs::instance()->mPhoneConnection, |
1262 | KOPrefs::instance()->mPhoneModel); | 1264 | KOPrefs::instance()->mPhoneModel); |
1263 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1265 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1264 | 1266 | ||
1265 | } else | 1267 | } else |
1266 | return; | 1268 | return; |
1267 | if ( loadSuccess ) { | 1269 | if ( loadSuccess ) { |
1268 | getEventViewerDialog()->setSyncMode( true ); | 1270 | getEventViewerDialog()->setSyncMode( true ); |
1269 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1271 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1270 | getEventViewerDialog()->setSyncMode( false ); | 1272 | getEventViewerDialog()->setSyncMode( false ); |
1271 | qApp->processEvents(); | 1273 | qApp->processEvents(); |
1272 | if ( syncOK ) { | 1274 | if ( syncOK ) { |
1273 | if ( KOPrefs::instance()->mWriteBackFile ) | 1275 | if ( KOPrefs::instance()->mWriteBackFile ) |
1274 | { | 1276 | { |
1275 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1277 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1276 | Incidence* inc = iL.first(); | 1278 | Incidence* inc = iL.first(); |
1277 | if ( phoneFormat ) { | 1279 | if ( phoneFormat ) { |
1278 | while ( inc ) { | 1280 | while ( inc ) { |
1279 | inc->removeID(mCurrentSyncDevice); | 1281 | inc->removeID(mCurrentSyncDevice); |
1280 | inc = iL.next(); | 1282 | inc = iL.next(); |
1281 | } | 1283 | } |
1282 | } | 1284 | } |
1283 | #ifndef DESKTOP_VERSION | 1285 | #ifndef DESKTOP_VERSION |
1284 | if ( sharpFormat ) | 1286 | if ( sharpFormat ) |
1285 | sharpFormat->save(calendar); | 1287 | sharpFormat->save(calendar); |
1286 | #endif | 1288 | #endif |
1287 | if ( phoneFormat ) | 1289 | if ( phoneFormat ) |
1288 | phoneFormat->save(calendar); | 1290 | phoneFormat->save(calendar); |
1289 | iL = calendar->rawIncidences(); | 1291 | iL = calendar->rawIncidences(); |
1290 | inc = iL.first(); | 1292 | inc = iL.first(); |
1291 | Incidence* loc; | 1293 | Incidence* loc; |
1292 | while ( inc ) { | 1294 | while ( inc ) { |
1293 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1295 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1294 | loc = mCalendar->incidence(inc->uid() ); | 1296 | loc = mCalendar->incidence(inc->uid() ); |
1295 | if ( loc ) { | 1297 | if ( loc ) { |
1296 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1298 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1297 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1299 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1298 | } | 1300 | } |
1299 | } | 1301 | } |
1300 | inc = iL.next(); | 1302 | inc = iL.next(); |
1301 | } | 1303 | } |
1302 | Incidence* lse = getLastSyncEvent(); | 1304 | Incidence* lse = getLastSyncEvent(); |
1303 | if ( lse ) { | 1305 | if ( lse ) { |
1304 | lse->setReadOnly( false ); | 1306 | lse->setReadOnly( false ); |
1305 | lse->setDescription( "" ); | 1307 | lse->setDescription( "" ); |
1306 | lse->setReadOnly( true ); | 1308 | lse->setReadOnly( true ); |
1307 | } | 1309 | } |
1308 | } | 1310 | } |
1309 | } | 1311 | } |
1310 | setModified( true ); | 1312 | setModified( true ); |
1311 | } else { | 1313 | } else { |
1312 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1314 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1313 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1315 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1314 | question, i18n("Ok")) ; | 1316 | question, i18n("Ok")) ; |
1315 | 1317 | ||
1316 | } | 1318 | } |
1317 | delete calendar; | 1319 | delete calendar; |
1318 | updateView(); | 1320 | updateView(); |
1319 | return ;//syncOK; | 1321 | return ;//syncOK; |
1320 | 1322 | ||
1321 | } | 1323 | } |
1322 | void CalendarView::syncSharp() | 1324 | void CalendarView::syncSharp() |
1323 | { | 1325 | { |
1324 | syncExternal( 0 ); | 1326 | syncExternal( 0 ); |
1325 | 1327 | ||
1326 | } | 1328 | } |
1327 | 1329 | ||
1328 | 1330 | ||
1329 | //#include <kabc/stdaddressbook.h> | 1331 | //#include <kabc/stdaddressbook.h> |
1330 | bool CalendarView::importBday() | 1332 | bool CalendarView::importBday() |
1331 | { | 1333 | { |
1332 | #if 0 | 1334 | #if 0 |
1333 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1335 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1334 | KABC::AddressBook::Iterator it; | 1336 | KABC::AddressBook::Iterator it; |
1335 | int count = 0; | 1337 | int count = 0; |
1336 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1338 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1337 | ++count; | 1339 | ++count; |
1338 | } | 1340 | } |
1339 | QProgressBar bar(count,0 ); | 1341 | QProgressBar bar(count,0 ); |
1340 | int w = 300; | 1342 | int w = 300; |
1341 | if ( QApplication::desktop()->width() < 320 ) | 1343 | if ( QApplication::desktop()->width() < 320 ) |
1342 | w = 220; | 1344 | w = 220; |
1343 | int h = bar.sizeHint().height() ; | 1345 | int h = bar.sizeHint().height() ; |
1344 | int dw = QApplication::desktop()->width(); | 1346 | int dw = QApplication::desktop()->width(); |
1345 | int dh = QApplication::desktop()->height(); | 1347 | int dh = QApplication::desktop()->height(); |
1346 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1348 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1347 | bar.show(); | 1349 | bar.show(); |
1348 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1350 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1349 | qApp->processEvents(); | 1351 | qApp->processEvents(); |
1350 | count = 0; | 1352 | count = 0; |
1351 | int addCount = 0; | 1353 | int addCount = 0; |
1352 | KCal::Attendee* a = 0; | 1354 | KCal::Attendee* a = 0; |
1353 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1355 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1354 | if ( ! bar.isVisible() ) | 1356 | if ( ! bar.isVisible() ) |
1355 | return false; | 1357 | return false; |
1356 | bar.setProgress( count++ ); | 1358 | bar.setProgress( count++ ); |
1357 | qApp->processEvents(); | 1359 | qApp->processEvents(); |
1358 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1360 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1359 | if ( (*it).birthday().date().isValid() ){ | 1361 | if ( (*it).birthday().date().isValid() ){ |
1360 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1362 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1361 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1363 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1362 | ++addCount; | 1364 | ++addCount; |
1363 | } | 1365 | } |
1364 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1366 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1365 | if ( anni.isValid() ){ | 1367 | if ( anni.isValid() ){ |
1366 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1368 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1367 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1369 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1368 | ++addCount; | 1370 | ++addCount; |
1369 | } | 1371 | } |
1370 | } | 1372 | } |
1371 | updateView(); | 1373 | updateView(); |
1372 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1374 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1373 | #endif | 1375 | #endif |
1374 | return true; | 1376 | return true; |
1375 | } | 1377 | } |
1376 | 1378 | ||
1377 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1379 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1378 | { | 1380 | { |
1379 | //qDebug("addAnni "); | 1381 | //qDebug("addAnni "); |
1380 | Event * ev = new Event(); | 1382 | Event * ev = new Event(); |
1381 | if ( a ) { | 1383 | if ( a ) { |
1382 | ev->addAttendee( a ); | 1384 | ev->addAttendee( a ); |
1383 | } | 1385 | } |
1384 | QString kind; | 1386 | QString kind; |
1385 | if ( birthday ) | 1387 | if ( birthday ) |
1386 | kind = i18n( "Birthday" ); | 1388 | kind = i18n( "Birthday" ); |
1387 | else | 1389 | else |
1388 | kind = i18n( "Anniversary" ); | 1390 | kind = i18n( "Anniversary" ); |
1389 | ev->setSummary( name + " - " + kind ); | 1391 | ev->setSummary( name + " - " + kind ); |
1390 | ev->setOrganizer( "nobody@nowhere" ); | 1392 | ev->setOrganizer( "nobody@nowhere" ); |
1391 | ev->setCategories( kind ); | 1393 | ev->setCategories( kind ); |
1392 | ev->setDtStart( QDateTime(date) ); | 1394 | ev->setDtStart( QDateTime(date) ); |
1393 | ev->setDtEnd( QDateTime(date) ); | 1395 | ev->setDtEnd( QDateTime(date) ); |
1394 | ev->setFloats( true ); | 1396 | ev->setFloats( true ); |
1395 | Recurrence * rec = ev->recurrence(); | 1397 | Recurrence * rec = ev->recurrence(); |
1396 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1398 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1397 | rec->addYearlyNum( date.month() ); | 1399 | rec->addYearlyNum( date.month() ); |
1398 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1400 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1399 | delete ev; | 1401 | delete ev; |
1400 | return false; | 1402 | return false; |
1401 | } | 1403 | } |
1402 | return true; | 1404 | return true; |
1403 | 1405 | ||
1404 | } | 1406 | } |
1405 | bool CalendarView::importQtopia( const QString &categories, | 1407 | bool CalendarView::importQtopia( const QString &categories, |
1406 | const QString &datebook, | 1408 | const QString &datebook, |
1407 | const QString &todolist ) | 1409 | const QString &todolist ) |
1408 | { | 1410 | { |
1409 | 1411 | ||
1410 | QtopiaFormat qtopiaFormat; | 1412 | QtopiaFormat qtopiaFormat; |
1411 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1413 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1412 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1414 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1413 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1415 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1414 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1416 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1415 | 1417 | ||
1416 | updateView(); | 1418 | updateView(); |
1417 | return true; | 1419 | return true; |
1418 | 1420 | ||
1419 | #if 0 | 1421 | #if 0 |
1420 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1422 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1421 | mCurrentSyncDevice = "qtopia-XML"; | 1423 | mCurrentSyncDevice = "qtopia-XML"; |
1422 | if ( KOPrefs::instance()->mAskForPreferences ) | 1424 | if ( KOPrefs::instance()->mAskForPreferences ) |
1423 | edit_sync_options(); | 1425 | edit_sync_options(); |
1424 | qApp->processEvents(); | 1426 | qApp->processEvents(); |
1425 | CalendarLocal* calendar = new CalendarLocal(); | 1427 | CalendarLocal* calendar = new CalendarLocal(); |
1426 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1428 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1427 | bool syncOK = false; | 1429 | bool syncOK = false; |
1428 | QtopiaFormat qtopiaFormat; | 1430 | QtopiaFormat qtopiaFormat; |
1429 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1431 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1430 | bool loadOk = true; | 1432 | bool loadOk = true; |
1431 | if ( !categories.isEmpty() ) | 1433 | if ( !categories.isEmpty() ) |
1432 | loadOk = qtopiaFormat.load( calendar, categories ); | 1434 | loadOk = qtopiaFormat.load( calendar, categories ); |
1433 | if ( loadOk && !datebook.isEmpty() ) | 1435 | if ( loadOk && !datebook.isEmpty() ) |
1434 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1436 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1435 | if ( loadOk && !todolist.isEmpty() ) | 1437 | if ( loadOk && !todolist.isEmpty() ) |
1436 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1438 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1437 | 1439 | ||
1438 | if ( loadOk ) { | 1440 | if ( loadOk ) { |
1439 | getEventViewerDialog()->setSyncMode( true ); | 1441 | getEventViewerDialog()->setSyncMode( true ); |
1440 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1442 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1441 | getEventViewerDialog()->setSyncMode( false ); | 1443 | getEventViewerDialog()->setSyncMode( false ); |
1442 | qApp->processEvents(); | 1444 | qApp->processEvents(); |
1443 | if ( syncOK ) { | 1445 | if ( syncOK ) { |
1444 | if ( KOPrefs::instance()->mWriteBackFile ) | 1446 | if ( KOPrefs::instance()->mWriteBackFile ) |
1445 | { | 1447 | { |
1446 | // write back XML file | 1448 | // write back XML file |
1447 | 1449 | ||
1448 | } | 1450 | } |
1449 | setModified( true ); | 1451 | setModified( true ); |
1450 | } | 1452 | } |
1451 | } else { | 1453 | } else { |
1452 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1454 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1453 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1455 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1454 | question, i18n("Ok")) ; | 1456 | question, i18n("Ok")) ; |
1455 | } | 1457 | } |
1456 | delete calendar; | 1458 | delete calendar; |
1457 | updateView(); | 1459 | updateView(); |
1458 | return syncOK; | 1460 | return syncOK; |
1459 | 1461 | ||
1460 | 1462 | ||
1461 | #endif | 1463 | #endif |
1462 | 1464 | ||
1463 | } | 1465 | } |
1464 | 1466 | ||
1465 | void CalendarView::setSyncEventsReadOnly() | 1467 | void CalendarView::setSyncEventsReadOnly() |
1466 | { | 1468 | { |
1467 | Event * ev; | 1469 | Event * ev; |
1468 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1470 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1469 | ev = eL.first(); | 1471 | ev = eL.first(); |
1470 | while ( ev ) { | 1472 | while ( ev ) { |
1471 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1473 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1472 | ev->setReadOnly( true ); | 1474 | ev->setReadOnly( true ); |
1473 | ev = eL.next(); | 1475 | ev = eL.next(); |
1474 | } | 1476 | } |
1475 | } | 1477 | } |
1476 | bool CalendarView::openCalendar(QString filename, bool merge) | 1478 | bool CalendarView::openCalendar(QString filename, bool merge) |
1477 | { | 1479 | { |
1478 | 1480 | ||
1479 | if (filename.isEmpty()) { | 1481 | if (filename.isEmpty()) { |
1480 | return false; | 1482 | return false; |
1481 | } | 1483 | } |
1482 | 1484 | ||
1483 | if (!QFile::exists(filename)) { | 1485 | if (!QFile::exists(filename)) { |
1484 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1486 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1485 | return false; | 1487 | return false; |
1486 | } | 1488 | } |
1487 | 1489 | ||
1488 | globalFlagBlockAgenda = 1; | 1490 | globalFlagBlockAgenda = 1; |
1489 | if (!merge) mCalendar->close(); | 1491 | if (!merge) mCalendar->close(); |
1490 | 1492 | ||
1491 | mStorage->setFileName( filename ); | 1493 | mStorage->setFileName( filename ); |
1492 | 1494 | ||
1493 | if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { | 1495 | if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { |
1494 | if ( merge ) ;//setModified( true ); | 1496 | if ( merge ) ;//setModified( true ); |
1495 | else { | 1497 | else { |
1496 | //setModified( true ); | 1498 | //setModified( true ); |
1497 | mViewManager->setDocumentId( filename ); | 1499 | mViewManager->setDocumentId( filename ); |
1498 | mDialogManager->setDocumentId( filename ); | 1500 | mDialogManager->setDocumentId( filename ); |
1499 | mTodoList->setDocumentId( filename ); | 1501 | mTodoList->setDocumentId( filename ); |
1500 | } | 1502 | } |
1501 | globalFlagBlockAgenda = 2; | 1503 | globalFlagBlockAgenda = 2; |
1502 | // if ( getLastSyncEvent() ) | 1504 | // if ( getLastSyncEvent() ) |
1503 | // getLastSyncEvent()->setReadOnly( true ); | 1505 | // getLastSyncEvent()->setReadOnly( true ); |
1504 | mCalendar->reInitAlarmSettings(); | 1506 | mCalendar->reInitAlarmSettings(); |
1505 | setSyncEventsReadOnly(); | 1507 | setSyncEventsReadOnly(); |
1506 | updateUnmanagedViews(); | 1508 | updateUnmanagedViews(); |
1507 | updateView(); | 1509 | updateView(); |
1508 | if ( filename != MainWindow::defaultFileName() ) | 1510 | if ( filename != MainWindow::defaultFileName() ) |
1509 | saveCalendar( MainWindow::defaultFileName() ); | 1511 | saveCalendar( MainWindow::defaultFileName() ); |
1510 | loadedFileVersion = QDateTime::currentDateTime(); | 1512 | loadedFileVersion = QDateTime::currentDateTime(); |
1511 | return true; | 1513 | return true; |
1512 | } else { | 1514 | } else { |
1513 | // while failing to load, the calendar object could | 1515 | // while failing to load, the calendar object could |
1514 | // have become partially populated. Clear it out. | 1516 | // have become partially populated. Clear it out. |
1515 | if ( !merge ) mCalendar->close(); | 1517 | if ( !merge ) mCalendar->close(); |
1516 | 1518 | ||
1517 | KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1519 | KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1518 | 1520 | ||
1519 | globalFlagBlockAgenda = 2; | 1521 | globalFlagBlockAgenda = 2; |
1520 | updateView(); | 1522 | updateView(); |
1521 | } | 1523 | } |
1522 | return false; | 1524 | return false; |
1523 | } | 1525 | } |
1524 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1526 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1525 | { | 1527 | { |
1526 | loadedFileVersion = dt; | 1528 | loadedFileVersion = dt; |
1527 | } | 1529 | } |
1528 | bool CalendarView::checkFileChanged(QString fn) | 1530 | bool CalendarView::checkFileChanged(QString fn) |
1529 | { | 1531 | { |
1530 | QFileInfo finf ( fn ); | 1532 | QFileInfo finf ( fn ); |
1531 | if ( !finf.exists() ) | 1533 | if ( !finf.exists() ) |
1532 | return true; | 1534 | return true; |
1533 | QDateTime dt = finf.lastModified (); | 1535 | QDateTime dt = finf.lastModified (); |
1534 | if ( dt <= loadedFileVersion ) | 1536 | if ( dt <= loadedFileVersion ) |
1535 | return false; | 1537 | return false; |
1536 | return true; | 1538 | return true; |
1537 | 1539 | ||
1538 | } | 1540 | } |
1539 | bool CalendarView::checkFileVersion(QString fn) | 1541 | bool CalendarView::checkFileVersion(QString fn) |
1540 | { | 1542 | { |
1541 | QFileInfo finf ( fn ); | 1543 | QFileInfo finf ( fn ); |
1542 | if ( !finf.exists() ) | 1544 | if ( !finf.exists() ) |
1543 | return true; | 1545 | return true; |
1544 | QDateTime dt = finf.lastModified (); | 1546 | QDateTime dt = finf.lastModified (); |
1545 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1547 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1546 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1548 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1547 | if ( dt <= loadedFileVersion ) | 1549 | if ( dt <= loadedFileVersion ) |
1548 | return true; | 1550 | return true; |
1549 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , | 1551 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , |
1550 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1552 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1551 | i18n("Sync+save")); | 1553 | i18n("Sync+save")); |
1552 | 1554 | ||
1553 | if ( km == KMessageBox::Cancel ) | 1555 | if ( km == KMessageBox::Cancel ) |
1554 | return false; | 1556 | return false; |
1555 | if ( km == KMessageBox::Yes ) | 1557 | if ( km == KMessageBox::Yes ) |
1556 | return true; | 1558 | return true; |
1557 | 1559 | ||
1558 | setSyncDevice("deleteaftersync" ); | 1560 | setSyncDevice("deleteaftersync" ); |
1559 | KOPrefs::instance()->mAskForPreferences = true; | 1561 | KOPrefs::instance()->mAskForPreferences = true; |
1560 | KOPrefs::instance()->mSyncAlgoPrefs = 3; | 1562 | KOPrefs::instance()->mSyncAlgoPrefs = 3; |
1561 | KOPrefs::instance()->mWriteBackFile = false; | 1563 | KOPrefs::instance()->mWriteBackFile = false; |
1562 | KOPrefs::instance()->mWriteBackExistingOnly = false; | 1564 | KOPrefs::instance()->mWriteBackExistingOnly = false; |
1563 | KOPrefs::instance()->mShowSyncSummary = false; | 1565 | KOPrefs::instance()->mShowSyncSummary = false; |
1564 | syncCalendar( fn, 3 ); | 1566 | syncCalendar( fn, 3 ); |
1565 | Event * e = getLastSyncEvent(); | 1567 | Event * e = getLastSyncEvent(); |
1566 | mCalendar->deleteEvent ( e ); | 1568 | mCalendar->deleteEvent ( e ); |
1567 | updateView(); | 1569 | updateView(); |
1568 | return true; | 1570 | return true; |
1569 | } | 1571 | } |
1570 | 1572 | ||
1571 | bool CalendarView::saveCalendar( QString filename ) | 1573 | bool CalendarView::saveCalendar( QString filename ) |
1572 | { | 1574 | { |
1573 | 1575 | ||
1574 | // Store back all unsaved data into calendar object | 1576 | // Store back all unsaved data into calendar object |
1575 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1577 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1576 | if ( mViewManager->currentView() ) | 1578 | if ( mViewManager->currentView() ) |
1577 | mViewManager->currentView()->flushView(); | 1579 | mViewManager->currentView()->flushView(); |
1578 | 1580 | ||
1579 | //mStorage->setFileName( filename ); | 1581 | //mStorage->setFileName( filename ); |
1580 | 1582 | ||
1581 | mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 1583 | mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
1582 | mStorage->setFileName( filename ); | 1584 | mStorage->setFileName( filename ); |
1583 | bool success; | 1585 | bool success; |
1584 | success = mStorage->save(); | 1586 | success = mStorage->save(); |
1585 | if ( !success ) { | 1587 | if ( !success ) { |
1586 | return false; | 1588 | return false; |
1587 | } | 1589 | } |
1588 | 1590 | ||
1589 | return true; | 1591 | return true; |
1590 | } | 1592 | } |
1591 | 1593 | ||
1592 | void CalendarView::closeCalendar() | 1594 | void CalendarView::closeCalendar() |
1593 | { | 1595 | { |
1594 | 1596 | ||
1595 | // child windows no longer valid | 1597 | // child windows no longer valid |
1596 | emit closingDown(); | 1598 | emit closingDown(); |
1597 | 1599 | ||
1598 | mCalendar->close(); | 1600 | mCalendar->close(); |
1599 | setModified(false); | 1601 | setModified(false); |
1600 | updateView(); | 1602 | updateView(); |
1601 | } | 1603 | } |
1602 | 1604 | ||
1603 | void CalendarView::archiveCalendar() | 1605 | void CalendarView::archiveCalendar() |
1604 | { | 1606 | { |
1605 | mDialogManager->showArchiveDialog(); | 1607 | mDialogManager->showArchiveDialog(); |
1606 | } | 1608 | } |
1607 | 1609 | ||
1608 | 1610 | ||
1609 | void CalendarView::readSettings() | 1611 | void CalendarView::readSettings() |
1610 | { | 1612 | { |
1611 | 1613 | ||
1612 | 1614 | ||
1613 | // mViewManager->showAgendaView(); | 1615 | // mViewManager->showAgendaView(); |
1614 | QString str; | 1616 | QString str; |
1615 | //qDebug("CalendarView::readSettings() "); | 1617 | //qDebug("CalendarView::readSettings() "); |
1616 | // read settings from the KConfig, supplying reasonable | 1618 | // read settings from the KConfig, supplying reasonable |
1617 | // defaults where none are to be found | 1619 | // defaults where none are to be found |
1618 | KConfig *config = KOGlobals::config(); | 1620 | KConfig *config = KOGlobals::config(); |
1619 | #ifndef KORG_NOSPLITTER | 1621 | #ifndef KORG_NOSPLITTER |
1620 | config->setGroup("KOrganizer Geometry"); | 1622 | config->setGroup("KOrganizer Geometry"); |
1621 | 1623 | ||
1622 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1624 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1623 | if (sizes.count() != 2) { | 1625 | if (sizes.count() != 2) { |
1624 | sizes << mDateNavigator->minimumSizeHint().width(); | 1626 | sizes << mDateNavigator->minimumSizeHint().width(); |
1625 | sizes << 300; | 1627 | sizes << 300; |
1626 | } | 1628 | } |
1627 | mPanner->setSizes(sizes); | 1629 | mPanner->setSizes(sizes); |
1628 | 1630 | ||
1629 | sizes = config->readIntListEntry("Separator2"); | 1631 | sizes = config->readIntListEntry("Separator2"); |
1630 | if ( ( mResourceView && sizes.count() == 4 ) || | 1632 | if ( ( mResourceView && sizes.count() == 4 ) || |
1631 | ( !mResourceView && sizes.count() == 3 ) ) { | 1633 | ( !mResourceView && sizes.count() == 3 ) ) { |
1632 | mLeftSplitter->setSizes(sizes); | 1634 | mLeftSplitter->setSizes(sizes); |
1633 | } | 1635 | } |
1634 | #endif | 1636 | #endif |
1635 | globalFlagBlockAgenda = 1; | 1637 | globalFlagBlockAgenda = 1; |
1636 | mViewManager->showAgendaView(); | 1638 | mViewManager->showAgendaView(); |
1637 | //mViewManager->readSettings( config ); | 1639 | //mViewManager->readSettings( config ); |
1638 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1640 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1639 | readFilterSettings(config); | 1641 | readFilterSettings(config); |
1640 | config->setGroup( "Views" ); | 1642 | config->setGroup( "Views" ); |
1641 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1643 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1642 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1644 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1643 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1645 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1644 | else mNavigator->selectDates( dateCount ); | 1646 | else mNavigator->selectDates( dateCount ); |
1645 | // mViewManager->readSettings( config ); | 1647 | // mViewManager->readSettings( config ); |
1646 | updateConfig(); | 1648 | updateConfig(); |
1647 | globalFlagBlockAgenda = 2; | 1649 | globalFlagBlockAgenda = 2; |
1648 | mViewManager->readSettings( config ); | 1650 | mViewManager->readSettings( config ); |
1649 | #ifdef DESKTOP_VERSION | 1651 | #ifdef DESKTOP_VERSION |
1650 | config->setGroup("WidgetLayout"); | 1652 | config->setGroup("WidgetLayout"); |
1651 | QStringList list; | 1653 | QStringList list; |
1652 | list = config->readListEntry("MainLayout"); | 1654 | list = config->readListEntry("MainLayout"); |
1653 | int x,y,w,h; | 1655 | int x,y,w,h; |
1654 | if ( ! list.isEmpty() ) { | 1656 | if ( ! list.isEmpty() ) { |
1655 | x = list[0].toInt(); | 1657 | x = list[0].toInt(); |
1656 | y = list[1].toInt(); | 1658 | y = list[1].toInt(); |
1657 | w = list[2].toInt(); | 1659 | w = list[2].toInt(); |
1658 | h = list[3].toInt(); | 1660 | h = list[3].toInt(); |
1659 | topLevelWidget()->setGeometry(x,y,w,h); | 1661 | topLevelWidget()->setGeometry(x,y,w,h); |
1660 | 1662 | ||
1661 | } else { | 1663 | } else { |
1662 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1664 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1663 | } | 1665 | } |
1664 | list = config->readListEntry("EditEventLayout"); | 1666 | list = config->readListEntry("EditEventLayout"); |
1665 | if ( ! list.isEmpty() ) { | 1667 | if ( ! list.isEmpty() ) { |
1666 | x = list[0].toInt(); | 1668 | x = list[0].toInt(); |
1667 | y = list[1].toInt(); | 1669 | y = list[1].toInt(); |
1668 | w = list[2].toInt(); | 1670 | w = list[2].toInt(); |
1669 | h = list[3].toInt(); | 1671 | h = list[3].toInt(); |
1670 | mEventEditor->setGeometry(x,y,w,h); | 1672 | mEventEditor->setGeometry(x,y,w,h); |
1671 | 1673 | ||
1672 | } | 1674 | } |
1673 | list = config->readListEntry("EditTodoLayout"); | 1675 | list = config->readListEntry("EditTodoLayout"); |
1674 | if ( ! list.isEmpty() ) { | 1676 | if ( ! list.isEmpty() ) { |
1675 | x = list[0].toInt(); | 1677 | x = list[0].toInt(); |
1676 | y = list[1].toInt(); | 1678 | y = list[1].toInt(); |
1677 | w = list[2].toInt(); | 1679 | w = list[2].toInt(); |
1678 | h = list[3].toInt(); | 1680 | h = list[3].toInt(); |
1679 | mTodoEditor->setGeometry(x,y,w,h); | 1681 | mTodoEditor->setGeometry(x,y,w,h); |
1680 | 1682 | ||
1681 | } | 1683 | } |
1682 | list = config->readListEntry("ViewerLayout"); | 1684 | list = config->readListEntry("ViewerLayout"); |
1683 | if ( ! list.isEmpty() ) { | 1685 | if ( ! list.isEmpty() ) { |
1684 | x = list[0].toInt(); | 1686 | x = list[0].toInt(); |
1685 | y = list[1].toInt(); | 1687 | y = list[1].toInt(); |
1686 | w = list[2].toInt(); | 1688 | w = list[2].toInt(); |
1687 | h = list[3].toInt(); | 1689 | h = list[3].toInt(); |
1688 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1690 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1689 | } | 1691 | } |
1690 | #endif | 1692 | #endif |
1691 | 1693 | ||
1692 | } | 1694 | } |
1693 | 1695 | ||
1694 | 1696 | ||
1695 | void CalendarView::writeSettings() | 1697 | void CalendarView::writeSettings() |
1696 | { | 1698 | { |
1697 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1699 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1698 | 1700 | ||
1699 | KConfig *config = KOGlobals::config(); | 1701 | KConfig *config = KOGlobals::config(); |
1700 | 1702 | ||
1701 | #ifndef KORG_NOSPLITTER | 1703 | #ifndef KORG_NOSPLITTER |
1702 | config->setGroup("KOrganizer Geometry"); | 1704 | config->setGroup("KOrganizer Geometry"); |
1703 | 1705 | ||
1704 | QValueList<int> list = mPanner->sizes(); | 1706 | QValueList<int> list = mPanner->sizes(); |
1705 | config->writeEntry("Separator1",list); | 1707 | config->writeEntry("Separator1",list); |
1706 | 1708 | ||
1707 | list = mLeftSplitter->sizes(); | 1709 | list = mLeftSplitter->sizes(); |
1708 | config->writeEntry("Separator2",list); | 1710 | config->writeEntry("Separator2",list); |
1709 | #endif | 1711 | #endif |
1710 | 1712 | ||
1711 | mViewManager->writeSettings( config ); | 1713 | mViewManager->writeSettings( config ); |
1712 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1714 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1713 | mDialogManager->writeSettings( config ); | 1715 | mDialogManager->writeSettings( config ); |
1714 | //KOPrefs::instance()->usrWriteConfig(); | 1716 | //KOPrefs::instance()->usrWriteConfig(); |
1715 | KOPrefs::instance()->writeConfig(); | 1717 | KOPrefs::instance()->writeConfig(); |
1716 | 1718 | ||
1717 | writeFilterSettings(config); | 1719 | writeFilterSettings(config); |
1718 | 1720 | ||
1719 | config->setGroup( "Views" ); | 1721 | config->setGroup( "Views" ); |
1720 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1722 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1721 | 1723 | ||
1722 | #ifdef DESKTOP_VERSION | 1724 | #ifdef DESKTOP_VERSION |
1723 | config->setGroup("WidgetLayout"); | 1725 | config->setGroup("WidgetLayout"); |
1724 | QStringList list ;//= config->readListEntry("MainLayout"); | 1726 | QStringList list ;//= config->readListEntry("MainLayout"); |
1725 | int x,y,w,h; | 1727 | int x,y,w,h; |
1726 | QWidget* wid; | 1728 | QWidget* wid; |
1727 | wid = topLevelWidget(); | 1729 | wid = topLevelWidget(); |
1728 | x = wid->geometry().x(); | 1730 | x = wid->geometry().x(); |
1729 | y = wid->geometry().y(); | 1731 | y = wid->geometry().y(); |
1730 | w = wid->width(); | 1732 | w = wid->width(); |
1731 | h = wid->height(); | 1733 | h = wid->height(); |
1732 | list.clear(); | 1734 | list.clear(); |
1733 | list << QString::number( x ); | 1735 | list << QString::number( x ); |
1734 | list << QString::number( y ); | 1736 | list << QString::number( y ); |
1735 | list << QString::number( w ); | 1737 | list << QString::number( w ); |
1736 | list << QString::number( h ); | 1738 | list << QString::number( h ); |
1737 | config->writeEntry("MainLayout",list ); | 1739 | config->writeEntry("MainLayout",list ); |
1738 | 1740 | ||
1739 | wid = mEventEditor; | 1741 | wid = mEventEditor; |
1740 | x = wid->geometry().x(); | 1742 | x = wid->geometry().x(); |
1741 | y = wid->geometry().y(); | 1743 | y = wid->geometry().y(); |
1742 | w = wid->width(); | 1744 | w = wid->width(); |
1743 | h = wid->height(); | 1745 | h = wid->height(); |
1744 | list.clear(); | 1746 | list.clear(); |
1745 | list << QString::number( x ); | 1747 | list << QString::number( x ); |
1746 | list << QString::number( y ); | 1748 | list << QString::number( y ); |
1747 | list << QString::number( w ); | 1749 | list << QString::number( w ); |
1748 | list << QString::number( h ); | 1750 | list << QString::number( h ); |
1749 | config->writeEntry("EditEventLayout",list ); | 1751 | config->writeEntry("EditEventLayout",list ); |
1750 | 1752 | ||
1751 | wid = mTodoEditor; | 1753 | wid = mTodoEditor; |
1752 | x = wid->geometry().x(); | 1754 | x = wid->geometry().x(); |
1753 | y = wid->geometry().y(); | 1755 | y = wid->geometry().y(); |
1754 | w = wid->width(); | 1756 | w = wid->width(); |
1755 | h = wid->height(); | 1757 | h = wid->height(); |
1756 | list.clear(); | 1758 | list.clear(); |
1757 | list << QString::number( x ); | 1759 | list << QString::number( x ); |
1758 | list << QString::number( y ); | 1760 | list << QString::number( y ); |
1759 | list << QString::number( w ); | 1761 | list << QString::number( w ); |
1760 | list << QString::number( h ); | 1762 | list << QString::number( h ); |
1761 | config->writeEntry("EditTodoLayout",list ); | 1763 | config->writeEntry("EditTodoLayout",list ); |
1762 | wid = getEventViewerDialog(); | 1764 | wid = getEventViewerDialog(); |
1763 | x = wid->geometry().x(); | 1765 | x = wid->geometry().x(); |
1764 | y = wid->geometry().y(); | 1766 | y = wid->geometry().y(); |
1765 | w = wid->width(); | 1767 | w = wid->width(); |
1766 | h = wid->height(); | 1768 | h = wid->height(); |
1767 | list.clear(); | 1769 | list.clear(); |
1768 | list << QString::number( x ); | 1770 | list << QString::number( x ); |
1769 | list << QString::number( y ); | 1771 | list << QString::number( y ); |
1770 | list << QString::number( w ); | 1772 | list << QString::number( w ); |
1771 | list << QString::number( h ); | 1773 | list << QString::number( h ); |
1772 | config->writeEntry("ViewerLayout",list ); | 1774 | config->writeEntry("ViewerLayout",list ); |
1773 | wid = mDialogManager->getSearchDialog(); | 1775 | wid = mDialogManager->getSearchDialog(); |
1774 | if ( wid ) { | 1776 | if ( wid ) { |
1775 | x = wid->geometry().x(); | 1777 | x = wid->geometry().x(); |
1776 | y = wid->geometry().y(); | 1778 | y = wid->geometry().y(); |
1777 | w = wid->width(); | 1779 | w = wid->width(); |
1778 | h = wid->height(); | 1780 | h = wid->height(); |
1779 | list.clear(); | 1781 | list.clear(); |
1780 | list << QString::number( x ); | 1782 | list << QString::number( x ); |
1781 | list << QString::number( y ); | 1783 | list << QString::number( y ); |
1782 | list << QString::number( w ); | 1784 | list << QString::number( w ); |
1783 | list << QString::number( h ); | 1785 | list << QString::number( h ); |
1784 | config->writeEntry("SearchLayout",list ); | 1786 | config->writeEntry("SearchLayout",list ); |
1785 | } | 1787 | } |
1786 | #endif | 1788 | #endif |
1787 | 1789 | ||
1788 | 1790 | ||
1789 | config->sync(); | 1791 | config->sync(); |
1790 | } | 1792 | } |
1791 | 1793 | ||
1792 | void CalendarView::readFilterSettings(KConfig *config) | 1794 | void CalendarView::readFilterSettings(KConfig *config) |
1793 | { | 1795 | { |
1794 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1796 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1795 | 1797 | ||
1796 | mFilters.clear(); | 1798 | mFilters.clear(); |
1797 | 1799 | ||
1798 | config->setGroup("General"); | 1800 | config->setGroup("General"); |
1799 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1801 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1800 | 1802 | ||
1801 | QStringList::ConstIterator it = filterList.begin(); | 1803 | QStringList::ConstIterator it = filterList.begin(); |
1802 | QStringList::ConstIterator end = filterList.end(); | 1804 | QStringList::ConstIterator end = filterList.end(); |
1803 | while(it != end) { | 1805 | while(it != end) { |
1804 | // kdDebug() << " filter: " << (*it) << endl; | 1806 | // kdDebug() << " filter: " << (*it) << endl; |
1805 | 1807 | ||
1806 | CalFilter *filter; | 1808 | CalFilter *filter; |
1807 | filter = new CalFilter(*it); | 1809 | filter = new CalFilter(*it); |
1808 | config->setGroup("Filter_" + (*it)); | 1810 | config->setGroup("Filter_" + (*it)); |
1809 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1811 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1810 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1812 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1811 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1813 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1812 | mFilters.append(filter); | 1814 | mFilters.append(filter); |
1813 | 1815 | ||
1814 | ++it; | 1816 | ++it; |
1815 | } | 1817 | } |
1816 | 1818 | ||
1817 | if (mFilters.count() == 0) { | 1819 | if (mFilters.count() == 0) { |
1818 | CalFilter *filter = new CalFilter(i18n("Default")); | 1820 | CalFilter *filter = new CalFilter(i18n("Default")); |
1819 | mFilters.append(filter); | 1821 | mFilters.append(filter); |
1820 | } | 1822 | } |
1821 | mFilterView->updateFilters(); | 1823 | mFilterView->updateFilters(); |
1822 | config->setGroup("FilterView"); | 1824 | config->setGroup("FilterView"); |
1823 | 1825 | ||
1824 | mFilterView->blockSignals(true); | 1826 | mFilterView->blockSignals(true); |
1825 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1827 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1826 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1828 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1827 | mFilterView->blockSignals(false); | 1829 | mFilterView->blockSignals(false); |
1828 | // We do it manually to avoid it being done twice by the above calls | 1830 | // We do it manually to avoid it being done twice by the above calls |
1829 | updateFilter(); | 1831 | updateFilter(); |
1830 | } | 1832 | } |
1831 | 1833 | ||
1832 | void CalendarView::writeFilterSettings(KConfig *config) | 1834 | void CalendarView::writeFilterSettings(KConfig *config) |
1833 | { | 1835 | { |
1834 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1836 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1835 | 1837 | ||
1836 | QStringList filterList; | 1838 | QStringList filterList; |
1837 | 1839 | ||
1838 | CalFilter *filter = mFilters.first(); | 1840 | CalFilter *filter = mFilters.first(); |
1839 | while(filter) { | 1841 | while(filter) { |
1840 | // kdDebug() << " fn: " << filter->name() << endl; | 1842 | // kdDebug() << " fn: " << filter->name() << endl; |
1841 | filterList << filter->name(); | 1843 | filterList << filter->name(); |
1842 | config->setGroup("Filter_" + filter->name()); | 1844 | config->setGroup("Filter_" + filter->name()); |
1843 | config->writeEntry("Criteria",filter->criteria()); | 1845 | config->writeEntry("Criteria",filter->criteria()); |
1844 | config->writeEntry("CategoryList",filter->categoryList()); | 1846 | config->writeEntry("CategoryList",filter->categoryList()); |
1845 | filter = mFilters.next(); | 1847 | filter = mFilters.next(); |
1846 | } | 1848 | } |
1847 | config->setGroup("General"); | 1849 | config->setGroup("General"); |
1848 | config->writeEntry("CalendarFilters",filterList); | 1850 | config->writeEntry("CalendarFilters",filterList); |
1849 | 1851 | ||
1850 | config->setGroup("FilterView"); | 1852 | config->setGroup("FilterView"); |
1851 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1853 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1852 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1854 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1853 | } | 1855 | } |
1854 | 1856 | ||
1855 | 1857 | ||
1856 | void CalendarView::goToday() | 1858 | void CalendarView::goToday() |
1857 | { | 1859 | { |
1858 | mNavigator->selectToday(); | 1860 | mNavigator->selectToday(); |
1859 | } | 1861 | } |
1860 | 1862 | ||
1861 | void CalendarView::goNext() | 1863 | void CalendarView::goNext() |
1862 | { | 1864 | { |
1863 | mNavigator->selectNext(); | 1865 | mNavigator->selectNext(); |
1864 | } | 1866 | } |
1865 | 1867 | ||
1866 | void CalendarView::goPrevious() | 1868 | void CalendarView::goPrevious() |
1867 | { | 1869 | { |
1868 | mNavigator->selectPrevious(); | 1870 | mNavigator->selectPrevious(); |
1869 | } | 1871 | } |
1870 | void CalendarView::goNextMonth() | 1872 | void CalendarView::goNextMonth() |
1871 | { | 1873 | { |
1872 | mNavigator->selectNextMonth(); | 1874 | mNavigator->selectNextMonth(); |
1873 | } | 1875 | } |
1874 | 1876 | ||
1875 | void CalendarView::goPreviousMonth() | 1877 | void CalendarView::goPreviousMonth() |
1876 | { | 1878 | { |
1877 | mNavigator->selectPreviousMonth(); | 1879 | mNavigator->selectPreviousMonth(); |
1878 | } | 1880 | } |
1879 | void CalendarView::writeLocale() | 1881 | void CalendarView::writeLocale() |
1880 | { | 1882 | { |
1881 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 1883 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
1882 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 1884 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
1883 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 1885 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
1884 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 1886 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
1885 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 1887 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
1886 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 1888 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
1887 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 1889 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
1888 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 1890 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
1889 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 1891 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
1890 | KOPrefs::instance()->mDaylightsavingStart, | 1892 | KOPrefs::instance()->mDaylightsavingStart, |
1891 | KOPrefs::instance()->mDaylightsavingEnd ); | 1893 | KOPrefs::instance()->mDaylightsavingEnd ); |
1892 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); | 1894 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); |
1893 | } | 1895 | } |
1894 | void CalendarView::updateConfig() | 1896 | void CalendarView::updateConfig() |
1895 | { | 1897 | { |
1896 | writeLocale(); | 1898 | writeLocale(); |
1897 | if ( KOPrefs::instance()->mUseAppColors ) | 1899 | if ( KOPrefs::instance()->mUseAppColors ) |
1898 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 1900 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
1899 | emit configChanged(); | 1901 | emit configChanged(); |
1900 | mTodoList->updateConfig(); | 1902 | mTodoList->updateConfig(); |
1901 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 1903 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
1902 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1904 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1903 | // To make the "fill window" configurations work | 1905 | // To make the "fill window" configurations work |
1904 | //mViewManager->raiseCurrentView(); | 1906 | //mViewManager->raiseCurrentView(); |
1905 | } | 1907 | } |
1906 | 1908 | ||
1907 | 1909 | ||
1908 | void CalendarView::eventChanged(Event *event) | 1910 | void CalendarView::eventChanged(Event *event) |
1909 | { | 1911 | { |
1910 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 1912 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
1911 | //updateUnmanagedViews(); | 1913 | //updateUnmanagedViews(); |
1912 | } | 1914 | } |
1913 | 1915 | ||
1914 | void CalendarView::eventAdded(Event *event) | 1916 | void CalendarView::eventAdded(Event *event) |
1915 | { | 1917 | { |
1916 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 1918 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
1917 | } | 1919 | } |
1918 | 1920 | ||
1919 | void CalendarView::eventToBeDeleted(Event *) | 1921 | void CalendarView::eventToBeDeleted(Event *) |
1920 | { | 1922 | { |
1921 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 1923 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
1922 | } | 1924 | } |
1923 | 1925 | ||
1924 | void CalendarView::eventDeleted() | 1926 | void CalendarView::eventDeleted() |
1925 | { | 1927 | { |
1926 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 1928 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
1927 | } | 1929 | } |
1928 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 1930 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
1929 | { | 1931 | { |
1930 | changeIncidenceDisplay((Incidence *)which, action); | 1932 | changeIncidenceDisplay((Incidence *)which, action); |
1931 | mDateNavigator->updateView(); | 1933 | mDateNavigator->updateView(); |
1932 | //mDialogManager->updateSearchDialog(); | 1934 | //mDialogManager->updateSearchDialog(); |
1933 | 1935 | ||
1934 | if (which) { | 1936 | if (which) { |
1935 | mViewManager->currentView()->updateView(); | 1937 | mViewManager->currentView()->updateView(); |
1936 | //mTodoList->updateView(); | 1938 | //mTodoList->updateView(); |
1937 | } | 1939 | } |
1938 | 1940 | ||
1939 | } | 1941 | } |
1940 | 1942 | ||
1941 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 1943 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
1942 | { | 1944 | { |
1943 | updateUnmanagedViews(); | 1945 | updateUnmanagedViews(); |
1944 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 1946 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
1945 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 1947 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
1946 | mCalendar->checkAlarmForIncidence( 0, true ); | 1948 | mCalendar->checkAlarmForIncidence( 0, true ); |
1947 | if ( mEventViewerDialog ) | 1949 | if ( mEventViewerDialog ) |
1948 | mEventViewerDialog->hide(); | 1950 | mEventViewerDialog->hide(); |
1949 | } | 1951 | } |
1950 | else | 1952 | else |
1951 | mCalendar->checkAlarmForIncidence( which , false ); | 1953 | mCalendar->checkAlarmForIncidence( which , false ); |
1952 | } | 1954 | } |
1953 | 1955 | ||
1954 | // most of the changeEventDisplays() right now just call the view's | 1956 | // most of the changeEventDisplays() right now just call the view's |
1955 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 1957 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
1956 | void CalendarView::changeEventDisplay(Event *which, int action) | 1958 | void CalendarView::changeEventDisplay(Event *which, int action) |
1957 | { | 1959 | { |
1958 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 1960 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
1959 | changeIncidenceDisplay((Incidence *)which, action); | 1961 | changeIncidenceDisplay((Incidence *)which, action); |
1960 | mDateNavigator->updateView(); | 1962 | mDateNavigator->updateView(); |
1961 | //mDialogManager->updateSearchDialog(); | 1963 | //mDialogManager->updateSearchDialog(); |
1962 | 1964 | ||
1963 | if (which) { | 1965 | if (which) { |
1964 | // If there is an event view visible update the display | 1966 | // If there is an event view visible update the display |
1965 | mViewManager->currentView()->changeEventDisplay(which,action); | 1967 | mViewManager->currentView()->changeEventDisplay(which,action); |
1966 | // TODO: check, if update needed | 1968 | // TODO: check, if update needed |
1967 | // if (which->getTodoStatus()) { | 1969 | // if (which->getTodoStatus()) { |
1968 | mTodoList->updateView(); | 1970 | mTodoList->updateView(); |
1969 | // } | 1971 | // } |
1970 | } else { | 1972 | } else { |
1971 | mViewManager->currentView()->updateView(); | 1973 | mViewManager->currentView()->updateView(); |
1972 | } | 1974 | } |
1973 | } | 1975 | } |
1974 | 1976 | ||
1975 | 1977 | ||
1976 | void CalendarView::updateTodoViews() | 1978 | void CalendarView::updateTodoViews() |
1977 | { | 1979 | { |
1978 | 1980 | ||
1979 | mTodoList->updateView(); | 1981 | mTodoList->updateView(); |
1980 | mViewManager->currentView()->updateView(); | 1982 | mViewManager->currentView()->updateView(); |
1981 | 1983 | ||
1982 | } | 1984 | } |
1983 | 1985 | ||
1984 | 1986 | ||
1985 | void CalendarView::updateView(const QDate &start, const QDate &end) | 1987 | void CalendarView::updateView(const QDate &start, const QDate &end) |
1986 | { | 1988 | { |
1987 | mTodoList->updateView(); | 1989 | mTodoList->updateView(); |
1988 | mViewManager->updateView(start, end); | 1990 | mViewManager->updateView(start, end); |
1989 | //mDateNavigator->updateView(); | 1991 | //mDateNavigator->updateView(); |
1990 | } | 1992 | } |
1991 | 1993 | ||
1992 | void CalendarView::updateView() | 1994 | void CalendarView::updateView() |
1993 | { | 1995 | { |
1994 | DateList tmpList = mNavigator->selectedDates(); | 1996 | DateList tmpList = mNavigator->selectedDates(); |
1995 | 1997 | ||
1996 | // We assume that the navigator only selects consecutive days. | 1998 | // We assume that the navigator only selects consecutive days. |
1997 | updateView( tmpList.first(), tmpList.last() ); | 1999 | updateView( tmpList.first(), tmpList.last() ); |
1998 | } | 2000 | } |
1999 | 2001 | ||
2000 | void CalendarView::updateUnmanagedViews() | 2002 | void CalendarView::updateUnmanagedViews() |
2001 | { | 2003 | { |
2002 | mDateNavigator->updateDayMatrix(); | 2004 | mDateNavigator->updateDayMatrix(); |
2003 | } | 2005 | } |
2004 | 2006 | ||
2005 | int CalendarView::msgItemDelete() | 2007 | int CalendarView::msgItemDelete() |
2006 | { | 2008 | { |
2007 | return KMessageBox::warningContinueCancel(this, | 2009 | return KMessageBox::warningContinueCancel(this, |
2008 | i18n("This item will be\npermanently deleted."), | 2010 | i18n("This item will be\npermanently deleted."), |
2009 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2011 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2010 | } | 2012 | } |
2011 | 2013 | ||
2012 | 2014 | ||
2013 | void CalendarView::edit_cut() | 2015 | void CalendarView::edit_cut() |
2014 | { | 2016 | { |
2015 | Event *anEvent=0; | 2017 | Event *anEvent=0; |
2016 | 2018 | ||
2017 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2019 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2018 | 2020 | ||
2019 | if (mViewManager->currentView()->isEventView()) { | 2021 | if (mViewManager->currentView()->isEventView()) { |
2020 | if ( incidence && incidence->type() == "Event" ) { | 2022 | if ( incidence && incidence->type() == "Event" ) { |
2021 | anEvent = static_cast<Event *>(incidence); | 2023 | anEvent = static_cast<Event *>(incidence); |
2022 | } | 2024 | } |
2023 | } | 2025 | } |
2024 | 2026 | ||
2025 | if (!anEvent) { | 2027 | if (!anEvent) { |
2026 | KNotifyClient::beep(); | 2028 | KNotifyClient::beep(); |
2027 | return; | 2029 | return; |
2028 | } | 2030 | } |
2029 | DndFactory factory( mCalendar ); | 2031 | DndFactory factory( mCalendar ); |
2030 | factory.cutEvent(anEvent); | 2032 | factory.cutEvent(anEvent); |
2031 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2033 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2032 | } | 2034 | } |
2033 | 2035 | ||
2034 | void CalendarView::edit_copy() | 2036 | void CalendarView::edit_copy() |
2035 | { | 2037 | { |
2036 | Event *anEvent=0; | 2038 | Event *anEvent=0; |
2037 | 2039 | ||
2038 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2040 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2039 | 2041 | ||
2040 | if (mViewManager->currentView()->isEventView()) { | 2042 | if (mViewManager->currentView()->isEventView()) { |
2041 | if ( incidence && incidence->type() == "Event" ) { | 2043 | if ( incidence && incidence->type() == "Event" ) { |
2042 | anEvent = static_cast<Event *>(incidence); | 2044 | anEvent = static_cast<Event *>(incidence); |
2043 | } | 2045 | } |
2044 | } | 2046 | } |
2045 | 2047 | ||
2046 | if (!anEvent) { | 2048 | if (!anEvent) { |
2047 | KNotifyClient::beep(); | 2049 | KNotifyClient::beep(); |
2048 | return; | 2050 | return; |
2049 | } | 2051 | } |
2050 | DndFactory factory( mCalendar ); | 2052 | DndFactory factory( mCalendar ); |
2051 | factory.copyEvent(anEvent); | 2053 | factory.copyEvent(anEvent); |
2052 | } | 2054 | } |
2053 | 2055 | ||
2054 | void CalendarView::edit_paste() | 2056 | void CalendarView::edit_paste() |
2055 | { | 2057 | { |
2056 | QDate date = mNavigator->selectedDates().first(); | 2058 | QDate date = mNavigator->selectedDates().first(); |
2057 | 2059 | ||
2058 | DndFactory factory( mCalendar ); | 2060 | DndFactory factory( mCalendar ); |
2059 | Event *pastedEvent = factory.pasteEvent( date ); | 2061 | Event *pastedEvent = factory.pasteEvent( date ); |
2060 | 2062 | ||
2061 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2063 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2062 | } | 2064 | } |
2063 | 2065 | ||
2064 | void CalendarView::edit_options() | 2066 | void CalendarView::edit_options() |
2065 | { | 2067 | { |
2066 | mDialogManager->showOptionsDialog(); | 2068 | mDialogManager->showOptionsDialog(); |
2067 | //writeSettings(); | 2069 | //writeSettings(); |
2068 | } | 2070 | } |
2069 | void CalendarView::edit_sync_options() | 2071 | void CalendarView::edit_sync_options() |
2070 | { | 2072 | { |
2071 | //mDialogManager->showSyncOptions(); | 2073 | //mDialogManager->showSyncOptions(); |
2072 | //KOPrefs::instance()->mSyncAlgoPrefs | 2074 | //KOPrefs::instance()->mSyncAlgoPrefs |
2073 | QDialog dia( this, "dia", true ); | 2075 | QDialog dia( this, "dia", true ); |
2074 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 2076 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
2075 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 2077 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
2076 | QVBoxLayout lay ( &dia ); | 2078 | QVBoxLayout lay ( &dia ); |
2077 | lay.setSpacing( 2 ); | 2079 | lay.setSpacing( 2 ); |
2078 | lay.setMargin( 3 ); | 2080 | lay.setMargin( 3 ); |
2079 | lay.addWidget(&gr); | 2081 | lay.addWidget(&gr); |
2080 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 2082 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
2081 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 2083 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
2082 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 2084 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
2083 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 2085 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
2084 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 2086 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
2085 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 2087 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
2086 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 2088 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
2087 | QPushButton pb ( "OK", &dia); | 2089 | QPushButton pb ( "OK", &dia); |
2088 | lay.addWidget( &pb ); | 2090 | lay.addWidget( &pb ); |
2089 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2091 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2090 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { | 2092 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { |
2091 | case 0: | 2093 | case 0: |
2092 | loc.setChecked( true); | 2094 | loc.setChecked( true); |
2093 | break; | 2095 | break; |
2094 | case 1: | 2096 | case 1: |
2095 | rem.setChecked( true ); | 2097 | rem.setChecked( true ); |
2096 | break; | 2098 | break; |
2097 | case 2: | 2099 | case 2: |
2098 | newest.setChecked( true); | 2100 | newest.setChecked( true); |
2099 | break; | 2101 | break; |
2100 | case 3: | 2102 | case 3: |
2101 | ask.setChecked( true); | 2103 | ask.setChecked( true); |
2102 | break; | 2104 | break; |
2103 | case 4: | 2105 | case 4: |
2104 | f_loc.setChecked( true); | 2106 | f_loc.setChecked( true); |
2105 | break; | 2107 | break; |
2106 | case 5: | 2108 | case 5: |
2107 | f_rem.setChecked( true); | 2109 | f_rem.setChecked( true); |
2108 | break; | 2110 | break; |
2109 | case 6: | 2111 | case 6: |
2110 | // both.setChecked( true); | 2112 | // both.setChecked( true); |
2111 | break; | 2113 | break; |
2112 | default: | 2114 | default: |
2113 | break; | 2115 | break; |
2114 | } | 2116 | } |
2115 | if ( dia.exec() ) { | 2117 | if ( dia.exec() ) { |
2116 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 2118 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
2117 | } | 2119 | } |
2118 | 2120 | ||
2119 | } | 2121 | } |
2120 | 2122 | ||
2121 | void CalendarView::slotSelectPickerDate( QDate d) | 2123 | void CalendarView::slotSelectPickerDate( QDate d) |
2122 | { | 2124 | { |
2123 | mDateFrame->hide(); | 2125 | mDateFrame->hide(); |
2124 | if ( mDatePickerMode == 1 ) { | 2126 | if ( mDatePickerMode == 1 ) { |
2125 | mNavigator->slotDaySelect( d ); | 2127 | mNavigator->slotDaySelect( d ); |
2126 | } else if ( mDatePickerMode == 2 ) { | 2128 | } else if ( mDatePickerMode == 2 ) { |
2127 | if ( mMoveIncidence->type() == "Todo" ) { | 2129 | if ( mMoveIncidence->type() == "Todo" ) { |
2128 | Todo * to = (Todo *) mMoveIncidence; | 2130 | Todo * to = (Todo *) mMoveIncidence; |
2129 | QTime tim; | 2131 | QTime tim; |
2130 | if ( to->hasDueDate() ) | 2132 | if ( to->hasDueDate() ) |
2131 | tim = to->dtDue().time(); | 2133 | tim = to->dtDue().time(); |
2132 | else { | 2134 | else { |
2133 | tim = QTime ( 0,0,0 ); | 2135 | tim = QTime ( 0,0,0 ); |
2134 | to->setFloats( true ); | 2136 | to->setFloats( true ); |
2135 | to->setHasDueDate( true ); | 2137 | to->setHasDueDate( true ); |
2136 | } | 2138 | } |
2137 | QDateTime dt ( d,tim ); | 2139 | QDateTime dt ( d,tim ); |
2138 | to->setDtDue( dt ); | 2140 | to->setDtDue( dt ); |
2139 | todoChanged( to ); | 2141 | todoChanged( to ); |
2140 | } else { | 2142 | } else { |
2141 | QTime tim = mMoveIncidence->dtStart().time(); | 2143 | QTime tim = mMoveIncidence->dtStart().time(); |
2142 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2144 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2143 | QDateTime dt ( d,tim ); | 2145 | QDateTime dt ( d,tim ); |
2144 | mMoveIncidence->setDtStart( dt ); | 2146 | mMoveIncidence->setDtStart( dt ); |
2145 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2147 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2146 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2148 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2147 | } | 2149 | } |
2148 | 2150 | ||
2149 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2151 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2150 | } | 2152 | } |
2151 | } | 2153 | } |
2152 | 2154 | ||
2153 | void CalendarView::removeCategories() | 2155 | void CalendarView::removeCategories() |
2154 | { | 2156 | { |
2155 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2157 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2156 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2158 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2157 | QStringList catIncList; | 2159 | QStringList catIncList; |
2158 | QStringList newCatList; | 2160 | QStringList newCatList; |
2159 | Incidence* inc = incList.first(); | 2161 | Incidence* inc = incList.first(); |
2160 | int i; | 2162 | int i; |
2161 | int count = 0; | 2163 | int count = 0; |
2162 | while ( inc ) { | 2164 | while ( inc ) { |
2163 | newCatList.clear(); | 2165 | newCatList.clear(); |
2164 | catIncList = inc->categories() ; | 2166 | catIncList = inc->categories() ; |
2165 | for( i = 0; i< catIncList.count(); ++i ) { | 2167 | for( i = 0; i< catIncList.count(); ++i ) { |
2166 | if ( catList.contains (catIncList[i])) | 2168 | if ( catList.contains (catIncList[i])) |
2167 | newCatList.append( catIncList[i] ); | 2169 | newCatList.append( catIncList[i] ); |
2168 | } | 2170 | } |
2169 | newCatList.sort(); | 2171 | newCatList.sort(); |
2170 | inc->setCategories( newCatList.join(",") ); | 2172 | inc->setCategories( newCatList.join(",") ); |
2171 | inc = incList.next(); | 2173 | inc = incList.next(); |
2172 | } | 2174 | } |
2173 | } | 2175 | } |
2174 | 2176 | ||
2175 | int CalendarView::addCategories() | 2177 | int CalendarView::addCategories() |
2176 | { | 2178 | { |
2177 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2179 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2178 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2180 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2179 | QStringList catIncList; | 2181 | QStringList catIncList; |
2180 | Incidence* inc = incList.first(); | 2182 | Incidence* inc = incList.first(); |
2181 | int i; | 2183 | int i; |
2182 | int count = 0; | 2184 | int count = 0; |
2183 | while ( inc ) { | 2185 | while ( inc ) { |
2184 | catIncList = inc->categories() ; | 2186 | catIncList = inc->categories() ; |
2185 | for( i = 0; i< catIncList.count(); ++i ) { | 2187 | for( i = 0; i< catIncList.count(); ++i ) { |
2186 | if ( !catList.contains (catIncList[i])) { | 2188 | if ( !catList.contains (catIncList[i])) { |
2187 | catList.append( catIncList[i] ); | 2189 | catList.append( catIncList[i] ); |
2188 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2190 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2189 | ++count; | 2191 | ++count; |
2190 | } | 2192 | } |
2191 | } | 2193 | } |
2192 | inc = incList.next(); | 2194 | inc = incList.next(); |
2193 | } | 2195 | } |
2194 | catList.sort(); | 2196 | catList.sort(); |
2195 | KOPrefs::instance()->mCustomCategories = catList; | 2197 | KOPrefs::instance()->mCustomCategories = catList; |
2196 | return count; | 2198 | return count; |
2197 | } | 2199 | } |
2198 | 2200 | ||
2199 | void CalendarView::manageCategories() | 2201 | void CalendarView::manageCategories() |
2200 | { | 2202 | { |
2201 | KOCatPrefs* cp = new KOCatPrefs(); | 2203 | KOCatPrefs* cp = new KOCatPrefs(); |
2202 | cp->show(); | 2204 | cp->show(); |
2203 | int w =cp->sizeHint().width() ; | 2205 | int w =cp->sizeHint().width() ; |
2204 | int h = cp->sizeHint().height() ; | 2206 | int h = cp->sizeHint().height() ; |
2205 | int dw = QApplication::desktop()->width(); | 2207 | int dw = QApplication::desktop()->width(); |
2206 | int dh = QApplication::desktop()->height(); | 2208 | int dh = QApplication::desktop()->height(); |
2207 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2209 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2208 | if ( !cp->exec() ) { | 2210 | if ( !cp->exec() ) { |
2209 | delete cp; | 2211 | delete cp; |
2210 | return; | 2212 | return; |
2211 | } | 2213 | } |
2212 | int count = 0; | 2214 | int count = 0; |
2213 | if ( cp->addCat() ) { | 2215 | if ( cp->addCat() ) { |
2214 | count = addCategories(); | 2216 | count = addCategories(); |
2215 | if ( count ) { | 2217 | if ( count ) { |
2216 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2218 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2217 | writeSettings(); | 2219 | writeSettings(); |
2218 | } | 2220 | } |
2219 | } else { | 2221 | } else { |
2220 | removeCategories(); | 2222 | removeCategories(); |
2221 | updateView(); | 2223 | updateView(); |
2222 | } | 2224 | } |
2223 | delete cp; | 2225 | delete cp; |
2224 | } | 2226 | } |
2225 | 2227 | ||
2226 | void CalendarView::beamIncidence(Incidence * Inc) | 2228 | void CalendarView::beamIncidence(Incidence * Inc) |
2227 | { | 2229 | { |
2228 | QPtrList<Incidence> delSel ; | 2230 | QPtrList<Incidence> delSel ; |
2229 | delSel.append(Inc); | 2231 | delSel.append(Inc); |
2230 | beamIncidenceList( delSel ); | 2232 | beamIncidenceList( delSel ); |
2231 | } | 2233 | } |
2232 | void CalendarView::beamCalendar() | 2234 | void CalendarView::beamCalendar() |
2233 | { | 2235 | { |
2234 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2236 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2235 | //qDebug("beamCalendar() "); | 2237 | //qDebug("beamCalendar() "); |
2236 | beamIncidenceList( delSel ); | 2238 | beamIncidenceList( delSel ); |
2237 | } | 2239 | } |
2238 | void CalendarView::beamFilteredCalendar() | 2240 | void CalendarView::beamFilteredCalendar() |
2239 | { | 2241 | { |
2240 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2242 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2241 | //qDebug("beamFilteredCalendar() "); | 2243 | //qDebug("beamFilteredCalendar() "); |
2242 | beamIncidenceList( delSel ); | 2244 | beamIncidenceList( delSel ); |
2243 | } | 2245 | } |
2244 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2246 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2245 | { | 2247 | { |
2246 | if ( beamDialog->exec () == QDialog::Rejected ) | 2248 | if ( beamDialog->exec () == QDialog::Rejected ) |
2247 | return; | 2249 | return; |
2248 | 2250 | ||
2249 | QString fn = "/tmp/kopibeamfile"; | 2251 | QString fn = "/tmp/kopibeamfile"; |
2250 | QString mes; | 2252 | QString mes; |
2251 | bool createbup = true; | 2253 | bool createbup = true; |
2252 | if ( createbup ) { | 2254 | if ( createbup ) { |
2253 | QString description = "\n"; | 2255 | QString description = "\n"; |
2254 | CalendarLocal* cal = new CalendarLocal(); | 2256 | CalendarLocal* cal = new CalendarLocal(); |
2255 | if ( beamDialog->beamLocal() ) | 2257 | if ( beamDialog->beamLocal() ) |
2256 | cal->setLocalTime(); | 2258 | cal->setLocalTime(); |
2257 | else | 2259 | else |
2258 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2260 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2259 | Incidence *incidence = delSel.first(); | 2261 | Incidence *incidence = delSel.first(); |
2260 | bool addText = false; | 2262 | bool addText = false; |
2261 | if ( delSel.count() < 10 ) | 2263 | if ( delSel.count() < 10 ) |
2262 | addText = true; | 2264 | addText = true; |
2263 | else { | 2265 | else { |
2264 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2266 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2265 | } | 2267 | } |
2266 | while ( incidence ) { | 2268 | while ( incidence ) { |
2267 | Incidence *in = incidence->clone(); | 2269 | Incidence *in = incidence->clone(); |
2268 | if ( addText ) | 2270 | if ( addText ) |
2269 | description += in->summary() + "\n"; | 2271 | description += in->summary() + "\n"; |
2270 | cal->addIncidence( in ); | 2272 | cal->addIncidence( in ); |
2271 | incidence = delSel.next(); | 2273 | incidence = delSel.next(); |
2272 | } | 2274 | } |
2273 | if ( beamDialog->beamVcal() ) { | 2275 | if ( beamDialog->beamVcal() ) { |