author | zautrix <zautrix> | 2004-10-27 12:27:39 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-27 12:27:39 (UTC) |
commit | 2f3396d84d2f3c92e1e0e420d677892c1f9c0778 (patch) (unidiff) | |
tree | 1ebab5dc6d00cb09720789897ce2c86df05cc9ab | |
parent | f73d249579d52d7aeaacde2dcb23abeb42f9ee95 (diff) | |
download | kdepimpi-2f3396d84d2f3c92e1e0e420d677892c1f9c0778.zip kdepimpi-2f3396d84d2f3c92e1e0e420d677892c1f9c0778.tar.gz kdepimpi-2f3396d84d2f3c92e1e0e420d677892c1f9c0778.tar.bz2 |
completed KDE AB sync. but will it work ...?
-rw-r--r-- | kabc/addressbook.cpp | 7 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 23 | ||||
-rw-r--r-- | kaddressbook/viewmanager.cpp | 5 | ||||
-rw-r--r-- | kaddressbook/viewmanager.h | 1 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 15 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 22 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 2 |
8 files changed, 61 insertions, 15 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index d101589..9b196b5 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -97,1144 +97,1147 @@ AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iter | |||
97 | return *this; | 97 | return *this; |
98 | } | 98 | } |
99 | 99 | ||
100 | AddressBook::Iterator::~Iterator() | 100 | AddressBook::Iterator::~Iterator() |
101 | { | 101 | { |
102 | delete d; | 102 | delete d; |
103 | } | 103 | } |
104 | 104 | ||
105 | const Addressee &AddressBook::Iterator::operator*() const | 105 | const Addressee &AddressBook::Iterator::operator*() const |
106 | { | 106 | { |
107 | return *(d->mIt); | 107 | return *(d->mIt); |
108 | } | 108 | } |
109 | 109 | ||
110 | Addressee &AddressBook::Iterator::operator*() | 110 | Addressee &AddressBook::Iterator::operator*() |
111 | { | 111 | { |
112 | return *(d->mIt); | 112 | return *(d->mIt); |
113 | } | 113 | } |
114 | 114 | ||
115 | Addressee *AddressBook::Iterator::operator->() | 115 | Addressee *AddressBook::Iterator::operator->() |
116 | { | 116 | { |
117 | return &(*(d->mIt)); | 117 | return &(*(d->mIt)); |
118 | } | 118 | } |
119 | 119 | ||
120 | AddressBook::Iterator &AddressBook::Iterator::operator++() | 120 | AddressBook::Iterator &AddressBook::Iterator::operator++() |
121 | { | 121 | { |
122 | (d->mIt)++; | 122 | (d->mIt)++; |
123 | return *this; | 123 | return *this; |
124 | } | 124 | } |
125 | 125 | ||
126 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) | 126 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) |
127 | { | 127 | { |
128 | (d->mIt)++; | 128 | (d->mIt)++; |
129 | return *this; | 129 | return *this; |
130 | } | 130 | } |
131 | 131 | ||
132 | AddressBook::Iterator &AddressBook::Iterator::operator--() | 132 | AddressBook::Iterator &AddressBook::Iterator::operator--() |
133 | { | 133 | { |
134 | (d->mIt)--; | 134 | (d->mIt)--; |
135 | return *this; | 135 | return *this; |
136 | } | 136 | } |
137 | 137 | ||
138 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) | 138 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) |
139 | { | 139 | { |
140 | (d->mIt)--; | 140 | (d->mIt)--; |
141 | return *this; | 141 | return *this; |
142 | } | 142 | } |
143 | 143 | ||
144 | bool AddressBook::Iterator::operator==( const Iterator &it ) | 144 | bool AddressBook::Iterator::operator==( const Iterator &it ) |
145 | { | 145 | { |
146 | return ( d->mIt == it.d->mIt ); | 146 | return ( d->mIt == it.d->mIt ); |
147 | } | 147 | } |
148 | 148 | ||
149 | bool AddressBook::Iterator::operator!=( const Iterator &it ) | 149 | bool AddressBook::Iterator::operator!=( const Iterator &it ) |
150 | { | 150 | { |
151 | return ( d->mIt != it.d->mIt ); | 151 | return ( d->mIt != it.d->mIt ); |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | AddressBook::ConstIterator::ConstIterator() | 155 | AddressBook::ConstIterator::ConstIterator() |
156 | { | 156 | { |
157 | d = new ConstIteratorData; | 157 | d = new ConstIteratorData; |
158 | } | 158 | } |
159 | 159 | ||
160 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) | 160 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) |
161 | { | 161 | { |
162 | d = new ConstIteratorData; | 162 | d = new ConstIteratorData; |
163 | d->mIt = i.d->mIt; | 163 | d->mIt = i.d->mIt; |
164 | } | 164 | } |
165 | 165 | ||
166 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) | 166 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) |
167 | { | 167 | { |
168 | if( this == &i ) return *this; // guard for self assignment | 168 | if( this == &i ) return *this; // guard for self assignment |
169 | delete d; // delete the old data because the Iterator was really constructed before | 169 | delete d; // delete the old data because the Iterator was really constructed before |
170 | d = new ConstIteratorData; | 170 | d = new ConstIteratorData; |
171 | d->mIt = i.d->mIt; | 171 | d->mIt = i.d->mIt; |
172 | return *this; | 172 | return *this; |
173 | } | 173 | } |
174 | 174 | ||
175 | AddressBook::ConstIterator::~ConstIterator() | 175 | AddressBook::ConstIterator::~ConstIterator() |
176 | { | 176 | { |
177 | delete d; | 177 | delete d; |
178 | } | 178 | } |
179 | 179 | ||
180 | const Addressee &AddressBook::ConstIterator::operator*() const | 180 | const Addressee &AddressBook::ConstIterator::operator*() const |
181 | { | 181 | { |
182 | return *(d->mIt); | 182 | return *(d->mIt); |
183 | } | 183 | } |
184 | 184 | ||
185 | const Addressee* AddressBook::ConstIterator::operator->() const | 185 | const Addressee* AddressBook::ConstIterator::operator->() const |
186 | { | 186 | { |
187 | return &(*(d->mIt)); | 187 | return &(*(d->mIt)); |
188 | } | 188 | } |
189 | 189 | ||
190 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() | 190 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() |
191 | { | 191 | { |
192 | (d->mIt)++; | 192 | (d->mIt)++; |
193 | return *this; | 193 | return *this; |
194 | } | 194 | } |
195 | 195 | ||
196 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) | 196 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) |
197 | { | 197 | { |
198 | (d->mIt)++; | 198 | (d->mIt)++; |
199 | return *this; | 199 | return *this; |
200 | } | 200 | } |
201 | 201 | ||
202 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() | 202 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() |
203 | { | 203 | { |
204 | (d->mIt)--; | 204 | (d->mIt)--; |
205 | return *this; | 205 | return *this; |
206 | } | 206 | } |
207 | 207 | ||
208 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | 208 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) |
209 | { | 209 | { |
210 | (d->mIt)--; | 210 | (d->mIt)--; |
211 | return *this; | 211 | return *this; |
212 | } | 212 | } |
213 | 213 | ||
214 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 214 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
215 | { | 215 | { |
216 | return ( d->mIt == it.d->mIt ); | 216 | return ( d->mIt == it.d->mIt ); |
217 | } | 217 | } |
218 | 218 | ||
219 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 219 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
220 | { | 220 | { |
221 | return ( d->mIt != it.d->mIt ); | 221 | return ( d->mIt != it.d->mIt ); |
222 | } | 222 | } |
223 | 223 | ||
224 | 224 | ||
225 | AddressBook::AddressBook() | 225 | AddressBook::AddressBook() |
226 | { | 226 | { |
227 | init(0, "contact"); | 227 | init(0, "contact"); |
228 | } | 228 | } |
229 | 229 | ||
230 | AddressBook::AddressBook( const QString &config ) | 230 | AddressBook::AddressBook( const QString &config ) |
231 | { | 231 | { |
232 | init(config, "contact"); | 232 | init(config, "contact"); |
233 | } | 233 | } |
234 | 234 | ||
235 | AddressBook::AddressBook( const QString &config, const QString &family ) | 235 | AddressBook::AddressBook( const QString &config, const QString &family ) |
236 | { | 236 | { |
237 | init(config, family); | 237 | init(config, family); |
238 | 238 | ||
239 | } | 239 | } |
240 | 240 | ||
241 | // the default family is "contact" | 241 | // the default family is "contact" |
242 | void AddressBook::init(const QString &config, const QString &family ) | 242 | void AddressBook::init(const QString &config, const QString &family ) |
243 | { | 243 | { |
244 | blockLSEchange = false; | 244 | blockLSEchange = false; |
245 | d = new AddressBookData; | 245 | d = new AddressBookData; |
246 | QString fami = family; | 246 | QString fami = family; |
247 | if (config != 0) { | 247 | if (config != 0) { |
248 | if ( family == "syncContact" ) { | 248 | if ( family == "syncContact" ) { |
249 | qDebug("creating sync config "); | 249 | qDebug("creating sync config "); |
250 | fami = "contact"; | 250 | fami = "contact"; |
251 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); | 251 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); |
252 | con->setGroup( "General" ); | 252 | con->setGroup( "General" ); |
253 | con->writeEntry( "ResourceKeys", QString("sync") ); | 253 | con->writeEntry( "ResourceKeys", QString("sync") ); |
254 | con->writeEntry( "Standard", QString("sync") ); | 254 | con->writeEntry( "Standard", QString("sync") ); |
255 | con->setGroup( "Resource_sync" ); | 255 | con->setGroup( "Resource_sync" ); |
256 | con->writeEntry( "FileName", config ); | 256 | con->writeEntry( "FileName", config ); |
257 | con->writeEntry( "FileFormat", QString("vcard") ); | 257 | con->writeEntry( "FileFormat", QString("vcard") ); |
258 | con->writeEntry( "ResourceIdentifier", QString("sync") ); | 258 | con->writeEntry( "ResourceIdentifier", QString("sync") ); |
259 | con->writeEntry( "ResourceName", QString("sync_res") ); | 259 | con->writeEntry( "ResourceName", QString("sync_res") ); |
260 | if ( config.right(4) == ".xml" ) | 260 | if ( config.right(4) == ".xml" ) |
261 | con->writeEntry( "ResourceType", QString("qtopia") ); | 261 | con->writeEntry( "ResourceType", QString("qtopia") ); |
262 | else if ( config == "sharp" ) { | 262 | else if ( config == "sharp" ) { |
263 | con->writeEntry( "ResourceType", QString("sharp") ); | 263 | con->writeEntry( "ResourceType", QString("sharp") ); |
264 | } else { | 264 | } else { |
265 | con->writeEntry( "ResourceType", QString("file") ); | 265 | con->writeEntry( "ResourceType", QString("file") ); |
266 | } | 266 | } |
267 | //con->sync(); | 267 | //con->sync(); |
268 | d->mConfig = con; | 268 | d->mConfig = con; |
269 | } | 269 | } |
270 | else | 270 | else |
271 | d->mConfig = new KConfig( locateLocal("config", config) ); | 271 | d->mConfig = new KConfig( locateLocal("config", config) ); |
272 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 272 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
273 | } | 273 | } |
274 | else { | 274 | else { |
275 | d->mConfig = 0; | 275 | d->mConfig = 0; |
276 | // qDebug("AddressBook::init 1 config=0"); | 276 | // qDebug("AddressBook::init 1 config=0"); |
277 | } | 277 | } |
278 | 278 | ||
279 | //US d->mErrorHandler = 0; | 279 | //US d->mErrorHandler = 0; |
280 | d->mManager = new KRES::Manager<Resource>( fami ); | 280 | d->mManager = new KRES::Manager<Resource>( fami ); |
281 | d->mManager->readConfig( d->mConfig ); | 281 | d->mManager->readConfig( d->mConfig ); |
282 | if ( family == "syncContact" ) { | 282 | if ( family == "syncContact" ) { |
283 | KRES::Manager<Resource> *manager = d->mManager; | 283 | KRES::Manager<Resource> *manager = d->mManager; |
284 | KRES::Manager<Resource>::ActiveIterator it; | 284 | KRES::Manager<Resource>::ActiveIterator it; |
285 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 285 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
286 | (*it)->setAddressBook( this ); | 286 | (*it)->setAddressBook( this ); |
287 | if ( !(*it)->open() ) | 287 | if ( !(*it)->open() ) |
288 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 288 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
289 | } | 289 | } |
290 | Resource *res = standardResource(); | 290 | Resource *res = standardResource(); |
291 | if ( !res ) { | 291 | if ( !res ) { |
292 | qDebug("ERROR: no standard resource"); | 292 | qDebug("ERROR: no standard resource"); |
293 | res = manager->createResource( "file" ); | 293 | res = manager->createResource( "file" ); |
294 | if ( res ) | 294 | if ( res ) |
295 | { | 295 | { |
296 | addResource( res ); | 296 | addResource( res ); |
297 | } | 297 | } |
298 | else | 298 | else |
299 | qDebug(" No resource available!!!"); | 299 | qDebug(" No resource available!!!"); |
300 | } | 300 | } |
301 | setStandardResource( res ); | 301 | setStandardResource( res ); |
302 | manager->writeConfig(); | 302 | manager->writeConfig(); |
303 | } | 303 | } |
304 | addCustomField( i18n( "Department" ), KABC::Field::Organization, | 304 | addCustomField( i18n( "Department" ), KABC::Field::Organization, |
305 | "X-Department", "KADDRESSBOOK" ); | 305 | "X-Department", "KADDRESSBOOK" ); |
306 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 306 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
307 | "X-Profession", "KADDRESSBOOK" ); | 307 | "X-Profession", "KADDRESSBOOK" ); |
308 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 308 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
309 | "X-AssistantsName", "KADDRESSBOOK" ); | 309 | "X-AssistantsName", "KADDRESSBOOK" ); |
310 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 310 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
311 | "X-ManagersName", "KADDRESSBOOK" ); | 311 | "X-ManagersName", "KADDRESSBOOK" ); |
312 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 312 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
313 | "X-SpousesName", "KADDRESSBOOK" ); | 313 | "X-SpousesName", "KADDRESSBOOK" ); |
314 | addCustomField( i18n( "Office" ), KABC::Field::Personal, | 314 | addCustomField( i18n( "Office" ), KABC::Field::Personal, |
315 | "X-Office", "KADDRESSBOOK" ); | 315 | "X-Office", "KADDRESSBOOK" ); |
316 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 316 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
317 | "X-IMAddress", "KADDRESSBOOK" ); | 317 | "X-IMAddress", "KADDRESSBOOK" ); |
318 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 318 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
319 | "X-Anniversary", "KADDRESSBOOK" ); | 319 | "X-Anniversary", "KADDRESSBOOK" ); |
320 | 320 | ||
321 | //US added this field to become compatible with Opie/qtopia addressbook | 321 | //US added this field to become compatible with Opie/qtopia addressbook |
322 | // values can be "female" or "male" or "". An empty field represents undefined. | 322 | // values can be "female" or "male" or "". An empty field represents undefined. |
323 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 323 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
324 | "X-Gender", "KADDRESSBOOK" ); | 324 | "X-Gender", "KADDRESSBOOK" ); |
325 | addCustomField( i18n( "Children" ), KABC::Field::Personal, | 325 | addCustomField( i18n( "Children" ), KABC::Field::Personal, |
326 | "X-Children", "KADDRESSBOOK" ); | 326 | "X-Children", "KADDRESSBOOK" ); |
327 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 327 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
328 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 328 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
329 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, | 329 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, |
330 | "X-ExternalID", "KADDRESSBOOK" ); | 330 | "X-ExternalID", "KADDRESSBOOK" ); |
331 | } | 331 | } |
332 | 332 | ||
333 | AddressBook::~AddressBook() | 333 | AddressBook::~AddressBook() |
334 | { | 334 | { |
335 | delete d->mConfig; d->mConfig = 0; | 335 | delete d->mConfig; d->mConfig = 0; |
336 | delete d->mManager; d->mManager = 0; | 336 | delete d->mManager; d->mManager = 0; |
337 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 337 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
338 | delete d; d = 0; | 338 | delete d; d = 0; |
339 | } | 339 | } |
340 | 340 | ||
341 | bool AddressBook::load() | 341 | bool AddressBook::load() |
342 | { | 342 | { |
343 | 343 | ||
344 | clear(); | 344 | clear(); |
345 | KRES::Manager<Resource>::ActiveIterator it; | 345 | KRES::Manager<Resource>::ActiveIterator it; |
346 | bool ok = true; | 346 | bool ok = true; |
347 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 347 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
348 | if ( !(*it)->load() ) { | 348 | if ( !(*it)->load() ) { |
349 | qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 349 | qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
350 | ok = false; | 350 | ok = false; |
351 | } else { | 351 | } else { |
352 | qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) ); | 352 | qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) ); |
353 | } | 353 | } |
354 | // mark all addressees as unchanged | 354 | // mark all addressees as unchanged |
355 | Addressee::List::Iterator addrIt; | 355 | Addressee::List::Iterator addrIt; |
356 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { | 356 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { |
357 | (*addrIt).setChanged( false ); | 357 | (*addrIt).setChanged( false ); |
358 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); | 358 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); |
359 | if ( !id.isEmpty() ) { | 359 | if ( !id.isEmpty() ) { |
360 | //qDebug("setId aa %s ", id.latin1()); | 360 | //qDebug("setId aa %s ", id.latin1()); |
361 | (*addrIt).setIDStr(id ); | 361 | (*addrIt).setIDStr(id ); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | blockLSEchange = true; | 364 | blockLSEchange = true; |
365 | return ok; | 365 | return ok; |
366 | } | 366 | } |
367 | 367 | ||
368 | bool AddressBook::save( Ticket *ticket ) | 368 | bool AddressBook::save( Ticket *ticket ) |
369 | { | 369 | { |
370 | kdDebug(5700) << "AddressBook::save()"<< endl; | 370 | kdDebug(5700) << "AddressBook::save()"<< endl; |
371 | 371 | ||
372 | if ( ticket->resource() ) { | 372 | if ( ticket->resource() ) { |
373 | deleteRemovedAddressees(); | 373 | deleteRemovedAddressees(); |
374 | return ticket->resource()->save( ticket ); | 374 | return ticket->resource()->save( ticket ); |
375 | } | 375 | } |
376 | 376 | ||
377 | return false; | 377 | return false; |
378 | } | 378 | } |
379 | // exports all Addressees, which are syncable | 379 | // exports all Addressees, which are syncable |
380 | void AddressBook::export2File( QString fileName ) | 380 | void AddressBook::export2File( QString fileName ) |
381 | { | 381 | { |
382 | 382 | ||
383 | QFile outFile( fileName ); | 383 | QFile outFile( fileName ); |
384 | if ( !outFile.open( IO_WriteOnly ) ) { | 384 | if ( !outFile.open( IO_WriteOnly ) ) { |
385 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 385 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
386 | KMessageBox::error( 0, text.arg( fileName ) ); | 386 | KMessageBox::error( 0, text.arg( fileName ) ); |
387 | return ; | 387 | return ; |
388 | } | 388 | } |
389 | QTextStream t( &outFile ); | 389 | QTextStream t( &outFile ); |
390 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 390 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
391 | Iterator it; | 391 | Iterator it; |
392 | KABC::VCardConverter::Version version; | 392 | KABC::VCardConverter::Version version; |
393 | version = KABC::VCardConverter::v3_0; | 393 | version = KABC::VCardConverter::v3_0; |
394 | for ( it = begin(); it != end(); ++it ) { | 394 | for ( it = begin(); it != end(); ++it ) { |
395 | if ( (*it).resource() && (*it).resource()->includeInSync() ) { | 395 | if ( (*it).resource() && (*it).resource()->includeInSync() ) { |
396 | if ( !(*it).IDStr().isEmpty() ) { | 396 | if ( !(*it).IDStr().isEmpty() ) { |
397 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); | 397 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); |
398 | } | 398 | } |
399 | KABC::VCardConverter converter; | 399 | KABC::VCardConverter converter; |
400 | QString vcard; | 400 | QString vcard; |
401 | //Resource *resource() const; | 401 | //Resource *resource() const; |
402 | converter.addresseeToVCard( *it, vcard, version ); | 402 | converter.addresseeToVCard( *it, vcard, version ); |
403 | t << vcard << "\r\n"; | 403 | t << vcard << "\r\n"; |
404 | } | 404 | } |
405 | } | 405 | } |
406 | t << "\r\n\r\n"; | 406 | t << "\r\n\r\n"; |
407 | outFile.close(); | 407 | outFile.close(); |
408 | } | 408 | } |
409 | // if QStringList uids is empty, all are exported | 409 | // if QStringList uids is empty, all are exported |
410 | bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) | 410 | bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) |
411 | { | 411 | { |
412 | KABC::VCardConverter converter; | 412 | KABC::VCardConverter converter; |
413 | QString datastream; | 413 | QString datastream; |
414 | Iterator it; | 414 | Iterator it; |
415 | bool all = uids.isEmpty(); | 415 | bool all = uids.isEmpty(); |
416 | for ( it = begin(); it != end(); ++it ) { | 416 | for ( it = begin(); it != end(); ++it ) { |
417 | // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 417 | // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
418 | if ( ! all ) { | 418 | if ( ! all ) { |
419 | if ( ! ( uids.contains((*it).uid() ) )) | 419 | if ( ! ( uids.contains((*it).uid() ) )) |
420 | continue; | 420 | continue; |
421 | } | 421 | } |
422 | KABC::Addressee a = ( *it ); | 422 | KABC::Addressee a = ( *it ); |
423 | if ( a.isEmpty() ) | 423 | if ( a.isEmpty() ) |
424 | continue; | 424 | continue; |
425 | if ( all && a.resource() && !a.resource()->includeInSync() ) | 425 | if ( all && a.resource() && !a.resource()->includeInSync() ) |
426 | continue; | 426 | continue; |
427 | a.simplifyEmails(); | 427 | a.simplifyEmails(); |
428 | a.simplifyPhoneNumbers(); | 428 | a.simplifyPhoneNumbers(); |
429 | a.simplifyPhoneNumberTypes(); | 429 | a.simplifyPhoneNumberTypes(); |
430 | a.simplifyAddresses(); | 430 | a.simplifyAddresses(); |
431 | 431 | ||
432 | QString vcard; | 432 | QString vcard; |
433 | QString vcardnew; | 433 | QString vcardnew; |
434 | converter.addresseeToVCard( a, vcard ); | 434 | converter.addresseeToVCard( a, vcard ); |
435 | int start = 0; | 435 | int start = 0; |
436 | int next; | 436 | int next; |
437 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 437 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
438 | int semi = vcard.find(";", next); | 438 | int semi = vcard.find(";", next); |
439 | int dopp = vcard.find(":", next); | 439 | int dopp = vcard.find(":", next); |
440 | int sep; | 440 | int sep; |
441 | if ( semi < dopp && semi >= 0 ) | 441 | if ( semi < dopp && semi >= 0 ) |
442 | sep = semi ; | 442 | sep = semi ; |
443 | else | 443 | else |
444 | sep = dopp; | 444 | sep = dopp; |
445 | vcardnew +=vcard.mid( start, next - start); | 445 | vcardnew +=vcard.mid( start, next - start); |
446 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); | 446 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); |
447 | start = sep; | 447 | start = sep; |
448 | } | 448 | } |
449 | vcardnew += vcard.mid( start,vcard.length() ); | 449 | vcardnew += vcard.mid( start,vcard.length() ); |
450 | vcard = ""; | 450 | vcard = ""; |
451 | start = 0; | 451 | start = 0; |
452 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { | 452 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { |
453 | int sep = vcardnew.find(":", next); | 453 | int sep = vcardnew.find(":", next); |
454 | vcard +=vcardnew.mid( start, next - start+3); | 454 | vcard +=vcardnew.mid( start, next - start+3); |
455 | start = sep; | 455 | start = sep; |
456 | } | 456 | } |
457 | vcard += vcardnew.mid( start,vcardnew.length() ); | 457 | vcard += vcardnew.mid( start,vcardnew.length() ); |
458 | vcard.replace ( QRegExp(";;;") , "" ); | 458 | vcard.replace ( QRegExp(";;;") , "" ); |
459 | vcard.replace ( QRegExp(";;") , "" ); | 459 | vcard.replace ( QRegExp(";;") , "" ); |
460 | datastream += vcard; | 460 | datastream += vcard; |
461 | 461 | ||
462 | } | 462 | } |
463 | 463 | ||
464 | QFile outFile(fileName); | 464 | QFile outFile(fileName); |
465 | if ( outFile.open(IO_WriteOnly) ) { | 465 | if ( outFile.open(IO_WriteOnly) ) { |
466 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 466 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
467 | QTextStream t( &outFile ); // use a text stream | 467 | QTextStream t( &outFile ); // use a text stream |
468 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 468 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
469 | t <<datastream; | 469 | t <<datastream; |
470 | t << "\r\n\r\n"; | 470 | t << "\r\n\r\n"; |
471 | outFile.close(); | 471 | outFile.close(); |
472 | 472 | ||
473 | } else { | 473 | } else { |
474 | qDebug("Error open temp file "); | 474 | qDebug("Error open temp file "); |
475 | return false; | 475 | return false; |
476 | } | 476 | } |
477 | return true; | 477 | return true; |
478 | 478 | ||
479 | } | 479 | } |
480 | int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) | 480 | int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) |
481 | { | 481 | { |
482 | 482 | ||
483 | if ( removeOld ) | 483 | if ( removeOld ) |
484 | setUntagged( true ); | 484 | setUntagged( true ); |
485 | KABC::Addressee::List list; | 485 | KABC::Addressee::List list; |
486 | QFile file( fileName ); | 486 | QFile file( fileName ); |
487 | file.open( IO_ReadOnly ); | 487 | file.open( IO_ReadOnly ); |
488 | QByteArray rawData = file.readAll(); | 488 | QByteArray rawData = file.readAll(); |
489 | file.close(); | 489 | file.close(); |
490 | QString data; | 490 | QString data; |
491 | if ( replaceLabel ) { | 491 | if ( replaceLabel ) { |
492 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); | 492 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); |
493 | data.replace ( QRegExp("LABEL") , "ADR" ); | 493 | data.replace ( QRegExp("LABEL") , "ADR" ); |
494 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); | 494 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); |
495 | } else | 495 | } else |
496 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 496 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
497 | KABC::VCardTool tool; | 497 | KABC::VCardTool tool; |
498 | list = tool.parseVCards( data ); | 498 | list = tool.parseVCards( data ); |
499 | KABC::Addressee::List::Iterator it; | 499 | KABC::Addressee::List::Iterator it; |
500 | for ( it = list.begin(); it != list.end(); ++it ) { | 500 | for ( it = list.begin(); it != list.end(); ++it ) { |
501 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); | 501 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); |
502 | if ( !id.isEmpty() ) | 502 | if ( !id.isEmpty() ) |
503 | (*it).setIDStr(id ); | 503 | (*it).setIDStr(id ); |
504 | (*it).setResource( 0 ); | 504 | (*it).setResource( 0 ); |
505 | if ( replaceLabel ) | 505 | if ( replaceLabel ) |
506 | (*it).removeVoice(); | 506 | (*it).removeVoice(); |
507 | if ( removeOld ) | 507 | if ( removeOld ) |
508 | (*it).setTagged( true ); | 508 | (*it).setTagged( true ); |
509 | insertAddressee( (*it), false, true ); | 509 | insertAddressee( (*it), false, true ); |
510 | } | 510 | } |
511 | if ( removeOld ) | 511 | if ( removeOld ) |
512 | removeUntagged(); | 512 | removeUntagged(); |
513 | return list.count(); | 513 | return list.count(); |
514 | } | 514 | } |
515 | void AddressBook::setUntagged(bool setNonSyncTagged) // = false) | 515 | void AddressBook::setUntagged(bool setNonSyncTagged) // = false) |
516 | { | 516 | { |
517 | Iterator ait; | 517 | Iterator ait; |
518 | for ( ait = begin(); ait != end(); ++ait ) { | 518 | for ( ait = begin(); ait != end(); ++ait ) { |
519 | if ( setNonSyncTagged ) { | 519 | if ( setNonSyncTagged ) { |
520 | if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { | 520 | if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { |
521 | (*ait).setTagged( true ); | 521 | (*ait).setTagged( true ); |
522 | } else | 522 | } else |
523 | (*ait).setTagged( false ); | 523 | (*ait).setTagged( false ); |
524 | } else | 524 | } else |
525 | (*ait).setTagged( false ); | 525 | (*ait).setTagged( false ); |
526 | } | 526 | } |
527 | } | 527 | } |
528 | void AddressBook::removeUntagged() | 528 | void AddressBook::removeUntagged() |
529 | { | 529 | { |
530 | Iterator ait; | 530 | Iterator ait; |
531 | bool todelete = false; | 531 | bool todelete = false; |
532 | Iterator todel; | 532 | Iterator todel; |
533 | for ( ait = begin(); ait != end(); ++ait ) { | 533 | for ( ait = begin(); ait != end(); ++ait ) { |
534 | if ( todelete ) | 534 | if ( todelete ) |
535 | removeAddressee( todel ); | 535 | removeAddressee( todel ); |
536 | if (!(*ait).tagged()) { | 536 | if (!(*ait).tagged()) { |
537 | todelete = true; | 537 | todelete = true; |
538 | todel = ait; | 538 | todel = ait; |
539 | } else | 539 | } else |
540 | todelete = false; | 540 | todelete = false; |
541 | } | 541 | } |
542 | if ( todelete ) | 542 | if ( todelete ) |
543 | removeAddressee( todel ); | 543 | removeAddressee( todel ); |
544 | deleteRemovedAddressees(); | 544 | deleteRemovedAddressees(); |
545 | } | 545 | } |
546 | void AddressBook::smplifyAddressees() | 546 | void AddressBook::smplifyAddressees() |
547 | { | 547 | { |
548 | Iterator ait; | 548 | Iterator ait; |
549 | for ( ait = begin(); ait != end(); ++ait ) { | 549 | for ( ait = begin(); ait != end(); ++ait ) { |
550 | (*ait).simplifyEmails(); | 550 | (*ait).simplifyEmails(); |
551 | (*ait).simplifyPhoneNumbers(); | 551 | (*ait).simplifyPhoneNumbers(); |
552 | (*ait).simplifyPhoneNumberTypes(); | 552 | (*ait).simplifyPhoneNumberTypes(); |
553 | (*ait).simplifyAddresses(); | 553 | (*ait).simplifyAddresses(); |
554 | } | 554 | } |
555 | } | 555 | } |
556 | void AddressBook::removeSyncInfo( QString syncProfile) | 556 | void AddressBook::removeSyncInfo( QString syncProfile) |
557 | { | 557 | { |
558 | Iterator ait; | 558 | Iterator ait; |
559 | for ( ait = begin(); ait != end(); ++ait ) { | 559 | for ( ait = begin(); ait != end(); ++ait ) { |
560 | (*ait).removeID( syncProfile ); | 560 | (*ait).removeID( syncProfile ); |
561 | } | 561 | } |
562 | if ( syncProfile.isEmpty() ) { | 562 | if ( syncProfile.isEmpty() ) { |
563 | Iterator it = begin(); | 563 | Iterator it = begin(); |
564 | Iterator it2 ; | 564 | Iterator it2 ; |
565 | QDateTime dt ( QDate( 2004,1,1) ); | 565 | QDateTime dt ( QDate( 2004,1,1) ); |
566 | while ( it != end() ) { | 566 | while ( it != end() ) { |
567 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 567 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
568 | it2 = it; | 568 | it2 = it; |
569 | //qDebug("removing %s ",(*it).uid().latin1() ); | 569 | //qDebug("removing %s ",(*it).uid().latin1() ); |
570 | ++it; | 570 | ++it; |
571 | removeAddressee( it2 ); | 571 | removeAddressee( it2 ); |
572 | } else { | 572 | } else { |
573 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 573 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
574 | ++it; | 574 | ++it; |
575 | } | 575 | } |
576 | } | 576 | } |
577 | } else { | 577 | } else { |
578 | Addressee lse; | 578 | Addressee lse; |
579 | lse = findByUid( "last-syncAddressee-"+ syncProfile ); | 579 | lse = findByUid( "last-syncAddressee-"+ syncProfile ); |
580 | if ( ! lse.isEmpty() ) | 580 | if ( ! lse.isEmpty() ) |
581 | removeAddressee( lse ); | 581 | removeAddressee( lse ); |
582 | } | 582 | } |
583 | 583 | ||
584 | } | 584 | } |
585 | void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) | 585 | void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) |
586 | { | 586 | { |
587 | Iterator ait; | 587 | Iterator ait; |
588 | for ( ait = begin(); ait != end(); ++ait ) { | 588 | for ( ait = begin(); ait != end(); ++ait ) { |
589 | QString id = (*ait).IDStr(); | 589 | QString id = (*ait).IDStr(); |
590 | (*ait).setIDStr( ":"); | 590 | (*ait).setIDStr( ":"); |
591 | (*ait).setExternalUID( id ); | 591 | (*ait).setExternalUID( id ); |
592 | (*ait).setOriginalExternalUID( id ); | 592 | (*ait).setOriginalExternalUID( id ); |
593 | if ( isPreSync ) | 593 | if ( isPreSync ) |
594 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 594 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
595 | else { | 595 | else { |
596 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 596 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
597 | (*ait).setID( currentSyncDevice,id ); | 597 | (*ait).setID( currentSyncDevice,id ); |
598 | 598 | ||
599 | } | 599 | } |
600 | } | 600 | } |
601 | } | 601 | } |
602 | void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) | 602 | void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) |
603 | { | 603 | { |
604 | 604 | ||
605 | setUntagged(); | 605 | setUntagged(); |
606 | KABC::Addressee::List list; | 606 | KABC::Addressee::List list; |
607 | QFile file( fileName ); | 607 | QFile file( fileName ); |
608 | file.open( IO_ReadOnly ); | 608 | file.open( IO_ReadOnly ); |
609 | QByteArray rawData = file.readAll(); | 609 | QByteArray rawData = file.readAll(); |
610 | file.close(); | 610 | file.close(); |
611 | QString data; | 611 | QString data; |
612 | 612 | ||
613 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 613 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
614 | KABC::VCardTool tool; | 614 | KABC::VCardTool tool; |
615 | list = tool.parseVCards( data ); | 615 | list = tool.parseVCards( data ); |
616 | KABC::Addressee::List::Iterator it; | 616 | KABC::Addressee::List::Iterator it; |
617 | for ( it = list.begin(); it != list.end(); ++it ) { | 617 | for ( it = list.begin(); it != list.end(); ++it ) { |
618 | Iterator ait; | 618 | Iterator ait; |
619 | for ( ait = begin(); ait != end(); ++ait ) { | 619 | for ( ait = begin(); ait != end(); ++ait ) { |
620 | if ( !(*ait).tagged() ) { | 620 | if ( !(*ait).tagged() ) { |
621 | if ( (*ait).containsAdr(*it)) { | 621 | if ( (*ait).containsAdr(*it)) { |
622 | (*ait).setTagged(true); | 622 | (*ait).setTagged(true); |
623 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); | 623 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); |
624 | (*it).setIDStr( ":"); | 624 | (*it).setIDStr( ":"); |
625 | (*it).setID( currentSyncDevice,id ); | 625 | (*it).setID( currentSyncDevice,id ); |
626 | (*it).setExternalUID( id ); | 626 | (*it).setExternalUID( id ); |
627 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 627 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
628 | (*it).setUid( ( (*ait).uid() )); | 628 | (*it).setUid( ( (*ait).uid() )); |
629 | break; | 629 | break; |
630 | } | 630 | } |
631 | } | 631 | } |
632 | 632 | ||
633 | } | 633 | } |
634 | if ( ait == end() ) | 634 | if ( ait == end() ) |
635 | qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); | 635 | qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); |
636 | } | 636 | } |
637 | clear(); | 637 | clear(); |
638 | for ( it = list.begin(); it != list.end(); ++it ) { | 638 | for ( it = list.begin(); it != list.end(); ++it ) { |
639 | insertAddressee( (*it) ); | 639 | insertAddressee( (*it) ); |
640 | } | 640 | } |
641 | } | 641 | } |
642 | 642 | ||
643 | bool AddressBook::saveABphone( QString fileName ) | 643 | bool AddressBook::saveABphone( QString fileName ) |
644 | { | 644 | { |
645 | //smplifyAddressees(); | 645 | //smplifyAddressees(); |
646 | qDebug("saveABphone:: saving AB... "); | 646 | qDebug("saveABphone:: saving AB... "); |
647 | if ( ! export2PhoneFormat( QStringList() ,fileName ) ) | 647 | if ( ! export2PhoneFormat( QStringList() ,fileName ) ) |
648 | return false; | 648 | return false; |
649 | qDebug("saveABphone:: writing to phone... "); | 649 | qDebug("saveABphone:: writing to phone... "); |
650 | if ( !PhoneAccess::writeToPhone( fileName) ) { | 650 | if ( !PhoneAccess::writeToPhone( fileName) ) { |
651 | return false; | 651 | return false; |
652 | } | 652 | } |
653 | qDebug("saveABphone:: re-reading from phone... "); | 653 | qDebug("saveABphone:: re-reading from phone... "); |
654 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 654 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
655 | return false; | 655 | return false; |
656 | } | 656 | } |
657 | return true; | 657 | return true; |
658 | } | 658 | } |
659 | bool AddressBook::saveAB() | 659 | bool AddressBook::saveAB() |
660 | { | 660 | { |
661 | bool ok = true; | 661 | bool ok = true; |
662 | 662 | ||
663 | deleteRemovedAddressees(); | 663 | deleteRemovedAddressees(); |
664 | Iterator ait; | 664 | Iterator ait; |
665 | for ( ait = begin(); ait != end(); ++ait ) { | 665 | for ( ait = begin(); ait != end(); ++ait ) { |
666 | if ( !(*ait).IDStr().isEmpty() ) { | 666 | if ( !(*ait).IDStr().isEmpty() ) { |
667 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | 667 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); |
668 | } | 668 | } |
669 | } | 669 | } |
670 | KRES::Manager<Resource>::ActiveIterator it; | 670 | KRES::Manager<Resource>::ActiveIterator it; |
671 | KRES::Manager<Resource> *manager = d->mManager; | 671 | KRES::Manager<Resource> *manager = d->mManager; |
672 | qDebug("SaveAB::saving..." ); | 672 | qDebug("SaveAB::saving..." ); |
673 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 673 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
674 | qDebug("SaveAB::checking resource..." ); | 674 | qDebug("SaveAB::checking resource..." ); |
675 | if ( (*it)->readOnly() ) | 675 | if ( (*it)->readOnly() ) |
676 | qDebug("resource is readonly." ); | 676 | qDebug("resource is readonly." ); |
677 | if ( (*it)->isOpen() ) | 677 | if ( (*it)->isOpen() ) |
678 | qDebug("resource is open" ); | 678 | qDebug("resource is open" ); |
679 | 679 | ||
680 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 680 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
681 | Ticket *ticket = requestSaveTicket( *it ); | 681 | Ticket *ticket = requestSaveTicket( *it ); |
682 | qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 682 | qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
683 | if ( !ticket ) { | 683 | if ( !ticket ) { |
684 | qDebug( i18n( "Unable to save to resource '%1'. It is locked." ) | 684 | qDebug( i18n( "Unable to save to resource '%1'. It is locked." ) |
685 | .arg( (*it)->resourceName() ) ); | 685 | .arg( (*it)->resourceName() ) ); |
686 | return false; | 686 | return false; |
687 | } | 687 | } |
688 | 688 | ||
689 | //if ( !save( ticket ) ) | 689 | //if ( !save( ticket ) ) |
690 | if ( ticket->resource() ) { | 690 | if ( ticket->resource() ) { |
691 | QString name = ticket->resource()->resourceName(); | 691 | QString name = ticket->resource()->resourceName(); |
692 | if ( ! ticket->resource()->save( ticket ) ) | 692 | if ( ! ticket->resource()->save( ticket ) ) |
693 | ok = false; | 693 | ok = false; |
694 | else | 694 | else |
695 | qDebug("StdAddressBook::resource saved '%s'", name.latin1() ); | 695 | qDebug("StdAddressBook::resource saved '%s'", name.latin1() ); |
696 | 696 | ||
697 | } else | 697 | } else |
698 | ok = false; | 698 | ok = false; |
699 | 699 | ||
700 | } | 700 | } |
701 | } | 701 | } |
702 | return ok; | 702 | return ok; |
703 | } | 703 | } |
704 | 704 | ||
705 | AddressBook::Iterator AddressBook::begin() | 705 | AddressBook::Iterator AddressBook::begin() |
706 | { | 706 | { |
707 | Iterator it = Iterator(); | 707 | Iterator it = Iterator(); |
708 | it.d->mIt = d->mAddressees.begin(); | 708 | it.d->mIt = d->mAddressees.begin(); |
709 | return it; | 709 | return it; |
710 | } | 710 | } |
711 | 711 | ||
712 | AddressBook::ConstIterator AddressBook::begin() const | 712 | AddressBook::ConstIterator AddressBook::begin() const |
713 | { | 713 | { |
714 | ConstIterator it = ConstIterator(); | 714 | ConstIterator it = ConstIterator(); |
715 | it.d->mIt = d->mAddressees.begin(); | 715 | it.d->mIt = d->mAddressees.begin(); |
716 | return it; | 716 | return it; |
717 | } | 717 | } |
718 | 718 | ||
719 | AddressBook::Iterator AddressBook::end() | 719 | AddressBook::Iterator AddressBook::end() |
720 | { | 720 | { |
721 | Iterator it = Iterator(); | 721 | Iterator it = Iterator(); |
722 | it.d->mIt = d->mAddressees.end(); | 722 | it.d->mIt = d->mAddressees.end(); |
723 | return it; | 723 | return it; |
724 | } | 724 | } |
725 | 725 | ||
726 | AddressBook::ConstIterator AddressBook::end() const | 726 | AddressBook::ConstIterator AddressBook::end() const |
727 | { | 727 | { |
728 | ConstIterator it = ConstIterator(); | 728 | ConstIterator it = ConstIterator(); |
729 | it.d->mIt = d->mAddressees.end(); | 729 | it.d->mIt = d->mAddressees.end(); |
730 | return it; | 730 | return it; |
731 | } | 731 | } |
732 | 732 | ||
733 | void AddressBook::clear() | 733 | void AddressBook::clear() |
734 | { | 734 | { |
735 | d->mAddressees.clear(); | 735 | d->mAddressees.clear(); |
736 | } | 736 | } |
737 | 737 | ||
738 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 738 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
739 | { | 739 | { |
740 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 740 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
741 | 741 | ||
742 | if ( !resource ) | 742 | if ( !resource ) |
743 | { | 743 | { |
744 | qDebug("AddressBook::requestSaveTicket no resource" ); | 744 | qDebug("AddressBook::requestSaveTicket no resource" ); |
745 | resource = standardResource(); | 745 | resource = standardResource(); |
746 | } | 746 | } |
747 | 747 | ||
748 | KRES::Manager<Resource>::ActiveIterator it; | 748 | KRES::Manager<Resource>::ActiveIterator it; |
749 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 749 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
750 | if ( (*it) == resource ) { | 750 | if ( (*it) == resource ) { |
751 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 751 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
752 | return 0; | 752 | return 0; |
753 | else | 753 | else |
754 | return (*it)->requestSaveTicket(); | 754 | return (*it)->requestSaveTicket(); |
755 | } | 755 | } |
756 | } | 756 | } |
757 | 757 | ||
758 | return 0; | 758 | return 0; |
759 | } | 759 | } |
760 | //void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); | 760 | //void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); |
761 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) | 761 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) |
762 | { | 762 | { |
763 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { | 763 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { |
764 | //qDebug("block insert "); | 764 | //qDebug("block insert "); |
765 | return; | 765 | return; |
766 | } | 766 | } |
767 | //qDebug("inserting.... %s ",a.uid().latin1() ); | 767 | //qDebug("inserting.... %s ",a.uid().latin1() ); |
768 | bool found = false; | 768 | bool found = false; |
769 | Addressee::List::Iterator it; | 769 | Addressee::List::Iterator it; |
770 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 770 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
771 | if ( a.uid() == (*it).uid() ) { | 771 | if ( a.uid() == (*it).uid() ) { |
772 | 772 | ||
773 | bool changed = false; | 773 | bool changed = false; |
774 | Addressee addr = a; | 774 | Addressee addr = a; |
775 | if ( addr != (*it) ) | 775 | if ( addr != (*it) ) |
776 | changed = true; | 776 | changed = true; |
777 | 777 | ||
778 | if ( takeResource ) { | 778 | if ( takeResource ) { |
779 | Resource * res = (*it).resource(); | 779 | Resource * res = (*it).resource(); |
780 | (*it) = a; | 780 | (*it) = a; |
781 | (*it).setResource( res ); | 781 | (*it).setResource( res ); |
782 | } else { | 782 | } else { |
783 | (*it) = a; | 783 | (*it) = a; |
784 | if ( (*it).resource() == 0 ) | 784 | if ( (*it).resource() == 0 ) |
785 | (*it).setResource( standardResource() ); | 785 | (*it).setResource( standardResource() ); |
786 | } | 786 | } |
787 | if ( changed ) { | 787 | if ( changed ) { |
788 | if ( setRev ) { | 788 | if ( setRev ) { |
789 | 789 | ||
790 | // get rid of micro seconds | 790 | // get rid of micro seconds |
791 | QDateTime dt = QDateTime::currentDateTime(); | 791 | QDateTime dt = QDateTime::currentDateTime(); |
792 | QTime t = dt.time(); | 792 | QTime t = dt.time(); |
793 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 793 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
794 | (*it).setRevision( dt ); | 794 | (*it).setRevision( dt ); |
795 | } | 795 | } |
796 | (*it).setChanged( true ); | 796 | (*it).setChanged( true ); |
797 | } | 797 | } |
798 | 798 | ||
799 | found = true; | 799 | found = true; |
800 | } else { | 800 | } else { |
801 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 801 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
802 | QString name = (*it).uid().mid( 19 ); | 802 | QString name = (*it).uid().mid( 19 ); |
803 | Addressee b = a; | 803 | Addressee b = a; |
804 | QString id = b.getID( name ); | 804 | QString id = b.getID( name ); |
805 | if ( ! id.isEmpty() ) { | 805 | if ( ! id.isEmpty() ) { |
806 | QString des = (*it).note(); | 806 | QString des = (*it).note(); |
807 | int startN; | 807 | int startN; |
808 | if( (startN = des.find( id ) ) >= 0 ) { | 808 | if( (startN = des.find( id ) ) >= 0 ) { |
809 | int endN = des.find( ",", startN+1 ); | 809 | int endN = des.find( ",", startN+1 ); |
810 | des = des.left( startN ) + des.mid( endN+1 ); | 810 | des = des.left( startN ) + des.mid( endN+1 ); |
811 | (*it).setNote( des ); | 811 | (*it).setNote( des ); |
812 | } | 812 | } |
813 | } | 813 | } |
814 | } | 814 | } |
815 | } | 815 | } |
816 | } | 816 | } |
817 | if ( found ) | 817 | if ( found ) |
818 | return; | 818 | return; |
819 | d->mAddressees.append( a ); | 819 | d->mAddressees.append( a ); |
820 | Addressee& addr = d->mAddressees.last(); | 820 | Addressee& addr = d->mAddressees.last(); |
821 | if ( addr.resource() == 0 ) | 821 | if ( addr.resource() == 0 ) |
822 | addr.setResource( standardResource() ); | 822 | addr.setResource( standardResource() ); |
823 | 823 | ||
824 | addr.setChanged( true ); | 824 | addr.setChanged( true ); |
825 | } | 825 | } |
826 | 826 | ||
827 | void AddressBook::removeAddressee( const Addressee &a ) | 827 | void AddressBook::removeAddressee( const Addressee &a ) |
828 | { | 828 | { |
829 | Iterator it; | 829 | Iterator it; |
830 | Iterator it2; | 830 | Iterator it2; |
831 | bool found = false; | 831 | bool found = false; |
832 | for ( it = begin(); it != end(); ++it ) { | 832 | for ( it = begin(); it != end(); ++it ) { |
833 | if ( a.uid() == (*it).uid() ) { | 833 | if ( a.uid() == (*it).uid() ) { |
834 | found = true; | 834 | found = true; |
835 | it2 = it; | 835 | it2 = it; |
836 | } else { | 836 | } else { |
837 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 837 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
838 | QString name = (*it).uid().mid( 19 ); | 838 | QString name = (*it).uid().mid( 19 ); |
839 | Addressee b = a; | 839 | Addressee b = a; |
840 | QString id = b.getID( name ); | 840 | QString id = b.getID( name ); |
841 | if ( ! id.isEmpty() ) { | 841 | if ( ! id.isEmpty() ) { |
842 | QString des = (*it).note(); | 842 | QString des = (*it).note(); |
843 | if( des.find( id ) < 0 ) { | 843 | if( des.find( id ) < 0 ) { |
844 | des += id + ","; | 844 | des += id + ","; |
845 | (*it).setNote( des ); | 845 | (*it).setNote( des ); |
846 | } | 846 | } |
847 | } | 847 | } |
848 | } | 848 | } |
849 | 849 | ||
850 | } | 850 | } |
851 | } | 851 | } |
852 | 852 | ||
853 | if ( found ) | 853 | if ( found ) |
854 | removeAddressee( it2 ); | 854 | removeAddressee( it2 ); |
855 | 855 | ||
856 | } | 856 | } |
857 | 857 | ||
858 | void AddressBook::removeSyncAddressees( bool removeDeleted ) | 858 | void AddressBook::removeSyncAddressees( bool removeDeleted ) |
859 | { | 859 | { |
860 | Iterator it = begin(); | 860 | Iterator it = begin(); |
861 | Iterator it2 ; | 861 | Iterator it2 ; |
862 | QDateTime dt ( QDate( 2004,1,1) ); | 862 | QDateTime dt ( QDate( 2004,1,1) ); |
863 | while ( it != end() ) { | 863 | while ( it != end() ) { |
864 | (*it).setRevision( dt ); | 864 | (*it).setRevision( dt ); |
865 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 865 | if (( *it).IDStr() != "changed" ) { |
866 | (*it).setIDStr(""); | 866 | // "changed" is used for tagging changed addressees when syncing with KDE or OL |
867 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | ||
868 | (*it).setIDStr(""); | ||
869 | } | ||
867 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | 870 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { |
868 | it2 = it; | 871 | it2 = it; |
869 | //qDebug("removing %s ",(*it).uid().latin1() ); | 872 | //qDebug("removing %s ",(*it).uid().latin1() ); |
870 | ++it; | 873 | ++it; |
871 | removeAddressee( it2 ); | 874 | removeAddressee( it2 ); |
872 | } else { | 875 | } else { |
873 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 876 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
874 | ++it; | 877 | ++it; |
875 | } | 878 | } |
876 | } | 879 | } |
877 | deleteRemovedAddressees(); | 880 | deleteRemovedAddressees(); |
878 | } | 881 | } |
879 | 882 | ||
880 | void AddressBook::removeAddressee( const Iterator &it ) | 883 | void AddressBook::removeAddressee( const Iterator &it ) |
881 | { | 884 | { |
882 | d->mRemovedAddressees.append( (*it) ); | 885 | d->mRemovedAddressees.append( (*it) ); |
883 | d->mAddressees.remove( it.d->mIt ); | 886 | d->mAddressees.remove( it.d->mIt ); |
884 | } | 887 | } |
885 | 888 | ||
886 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 889 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
887 | { | 890 | { |
888 | Iterator it; | 891 | Iterator it; |
889 | for ( it = begin(); it != end(); ++it ) { | 892 | for ( it = begin(); it != end(); ++it ) { |
890 | if ( a.uid() == (*it).uid() ) { | 893 | if ( a.uid() == (*it).uid() ) { |
891 | return it; | 894 | return it; |
892 | } | 895 | } |
893 | } | 896 | } |
894 | return end(); | 897 | return end(); |
895 | } | 898 | } |
896 | 899 | ||
897 | Addressee AddressBook::findByUid( const QString &uid ) | 900 | Addressee AddressBook::findByUid( const QString &uid ) |
898 | { | 901 | { |
899 | Iterator it; | 902 | Iterator it; |
900 | for ( it = begin(); it != end(); ++it ) { | 903 | for ( it = begin(); it != end(); ++it ) { |
901 | if ( uid == (*it).uid() ) { | 904 | if ( uid == (*it).uid() ) { |
902 | return *it; | 905 | return *it; |
903 | } | 906 | } |
904 | } | 907 | } |
905 | return Addressee(); | 908 | return Addressee(); |
906 | } | 909 | } |
907 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) | 910 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) |
908 | { | 911 | { |
909 | //qDebug("AddressBook::preExternSync "); | 912 | //qDebug("AddressBook::preExternSync "); |
910 | AddressBook::Iterator it; | 913 | AddressBook::Iterator it; |
911 | for ( it = begin(); it != end(); ++it ) { | 914 | for ( it = begin(); it != end(); ++it ) { |
912 | (*it).setID( csd, (*it).externalUID() ); | 915 | (*it).setID( csd, (*it).externalUID() ); |
913 | (*it).computeCsum( csd ); | 916 | (*it).computeCsum( csd ); |
914 | } | 917 | } |
915 | mergeAB( aBook ,csd, isSubset ); | 918 | mergeAB( aBook ,csd, isSubset ); |
916 | } | 919 | } |
917 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) | 920 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) |
918 | { | 921 | { |
919 | //qDebug("AddressBook::postExternSync "); | 922 | //qDebug("AddressBook::postExternSync "); |
920 | AddressBook::Iterator it; | 923 | AddressBook::Iterator it; |
921 | for ( it = begin(); it != end(); ++it ) { | 924 | for ( it = begin(); it != end(); ++it ) { |
922 | // qDebug("check uid %s ", (*it).uid().latin1() ); | 925 | // qDebug("check uid %s ", (*it).uid().latin1() ); |
923 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 926 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
924 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { | 927 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { |
925 | Addressee ad = aBook->findByUid( ( (*it).uid() )); | 928 | Addressee ad = aBook->findByUid( ( (*it).uid() )); |
926 | if ( ad.isEmpty() ) { | 929 | if ( ad.isEmpty() ) { |
927 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); | 930 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); |
928 | } else { | 931 | } else { |
929 | (*it).computeCsum( csd ); | 932 | (*it).computeCsum( csd ); |
930 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) | 933 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) |
931 | ad.setID( csd, (*it).externalUID() ); | 934 | ad.setID( csd, (*it).externalUID() ); |
932 | ad.setCsum( csd, (*it).getCsum( csd ) ); | 935 | ad.setCsum( csd, (*it).getCsum( csd ) ); |
933 | aBook->insertAddressee( ad ); | 936 | aBook->insertAddressee( ad ); |
934 | } | 937 | } |
935 | } | 938 | } |
936 | } | 939 | } |
937 | } | 940 | } |
938 | 941 | ||
939 | bool AddressBook::containsExternalUid( const QString& uid ) | 942 | bool AddressBook::containsExternalUid( const QString& uid ) |
940 | { | 943 | { |
941 | Iterator it; | 944 | Iterator it; |
942 | for ( it = begin(); it != end(); ++it ) { | 945 | for ( it = begin(); it != end(); ++it ) { |
943 | if ( uid == (*it).externalUID( ) ) | 946 | if ( uid == (*it).externalUID( ) ) |
944 | return true; | 947 | return true; |
945 | } | 948 | } |
946 | return false; | 949 | return false; |
947 | } | 950 | } |
948 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) | 951 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) |
949 | { | 952 | { |
950 | Iterator it; | 953 | Iterator it; |
951 | for ( it = begin(); it != end(); ++it ) { | 954 | for ( it = begin(); it != end(); ++it ) { |
952 | if ( uid == (*it).getID( profile ) ) | 955 | if ( uid == (*it).getID( profile ) ) |
953 | return (*it); | 956 | return (*it); |
954 | } | 957 | } |
955 | return Addressee(); | 958 | return Addressee(); |
956 | } | 959 | } |
957 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) | 960 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) |
958 | { | 961 | { |
959 | Iterator it; | 962 | Iterator it; |
960 | Addressee ad; | 963 | Addressee ad; |
961 | for ( it = begin(); it != end(); ++it ) { | 964 | for ( it = begin(); it != end(); ++it ) { |
962 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); | 965 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); |
963 | if ( !ad.isEmpty() ) { | 966 | if ( !ad.isEmpty() ) { |
964 | (*it).mergeContact( ad ,isSubset); | 967 | (*it).mergeContact( ad ,isSubset); |
965 | } | 968 | } |
966 | } | 969 | } |
967 | #if 0 | 970 | #if 0 |
968 | // test only | 971 | // test only |
969 | for ( it = begin(); it != end(); ++it ) { | 972 | for ( it = begin(); it != end(); ++it ) { |
970 | 973 | ||
971 | qDebug("uid %s ", (*it).uid().latin1()); | 974 | qDebug("uid %s ", (*it).uid().latin1()); |
972 | } | 975 | } |
973 | #endif | 976 | #endif |
974 | } | 977 | } |
975 | 978 | ||
976 | #if 0 | 979 | #if 0 |
977 | Addressee::List AddressBook::getExternLastSyncAddressees() | 980 | Addressee::List AddressBook::getExternLastSyncAddressees() |
978 | { | 981 | { |
979 | Addressee::List results; | 982 | Addressee::List results; |
980 | 983 | ||
981 | Iterator it; | 984 | Iterator it; |
982 | for ( it = begin(); it != end(); ++it ) { | 985 | for ( it = begin(); it != end(); ++it ) { |
983 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { | 986 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { |
984 | if ( (*it).familyName().left(4) == "!E: " ) | 987 | if ( (*it).familyName().left(4) == "!E: " ) |
985 | results.append( *it ); | 988 | results.append( *it ); |
986 | } | 989 | } |
987 | } | 990 | } |
988 | 991 | ||
989 | return results; | 992 | return results; |
990 | } | 993 | } |
991 | #endif | 994 | #endif |
992 | void AddressBook::resetTempSyncStat() | 995 | void AddressBook::resetTempSyncStat() |
993 | { | 996 | { |
994 | Iterator it; | 997 | Iterator it; |
995 | for ( it = begin(); it != end(); ++it ) { | 998 | for ( it = begin(); it != end(); ++it ) { |
996 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | 999 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); |
997 | } | 1000 | } |
998 | 1001 | ||
999 | } | 1002 | } |
1000 | 1003 | ||
1001 | QStringList AddressBook:: uidList() | 1004 | QStringList AddressBook:: uidList() |
1002 | { | 1005 | { |
1003 | QStringList results; | 1006 | QStringList results; |
1004 | Iterator it; | 1007 | Iterator it; |
1005 | for ( it = begin(); it != end(); ++it ) { | 1008 | for ( it = begin(); it != end(); ++it ) { |
1006 | results.append( (*it).uid() ); | 1009 | results.append( (*it).uid() ); |
1007 | } | 1010 | } |
1008 | return results; | 1011 | return results; |
1009 | } | 1012 | } |
1010 | 1013 | ||
1011 | 1014 | ||
1012 | Addressee::List AddressBook::allAddressees() | 1015 | Addressee::List AddressBook::allAddressees() |
1013 | { | 1016 | { |
1014 | return d->mAddressees; | 1017 | return d->mAddressees; |
1015 | 1018 | ||
1016 | } | 1019 | } |
1017 | 1020 | ||
1018 | Addressee::List AddressBook::findByName( const QString &name ) | 1021 | Addressee::List AddressBook::findByName( const QString &name ) |
1019 | { | 1022 | { |
1020 | Addressee::List results; | 1023 | Addressee::List results; |
1021 | 1024 | ||
1022 | Iterator it; | 1025 | Iterator it; |
1023 | for ( it = begin(); it != end(); ++it ) { | 1026 | for ( it = begin(); it != end(); ++it ) { |
1024 | if ( name == (*it).realName() ) { | 1027 | if ( name == (*it).realName() ) { |
1025 | results.append( *it ); | 1028 | results.append( *it ); |
1026 | } | 1029 | } |
1027 | } | 1030 | } |
1028 | 1031 | ||
1029 | return results; | 1032 | return results; |
1030 | } | 1033 | } |
1031 | 1034 | ||
1032 | Addressee::List AddressBook::findByEmail( const QString &email ) | 1035 | Addressee::List AddressBook::findByEmail( const QString &email ) |
1033 | { | 1036 | { |
1034 | Addressee::List results; | 1037 | Addressee::List results; |
1035 | QStringList mailList; | 1038 | QStringList mailList; |
1036 | 1039 | ||
1037 | Iterator it; | 1040 | Iterator it; |
1038 | for ( it = begin(); it != end(); ++it ) { | 1041 | for ( it = begin(); it != end(); ++it ) { |
1039 | mailList = (*it).emails(); | 1042 | mailList = (*it).emails(); |
1040 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { | 1043 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { |
1041 | if ( email == (*ite) ) { | 1044 | if ( email == (*ite) ) { |
1042 | results.append( *it ); | 1045 | results.append( *it ); |
1043 | } | 1046 | } |
1044 | } | 1047 | } |
1045 | } | 1048 | } |
1046 | 1049 | ||
1047 | return results; | 1050 | return results; |
1048 | } | 1051 | } |
1049 | 1052 | ||
1050 | Addressee::List AddressBook::findByCategory( const QString &category ) | 1053 | Addressee::List AddressBook::findByCategory( const QString &category ) |
1051 | { | 1054 | { |
1052 | Addressee::List results; | 1055 | Addressee::List results; |
1053 | 1056 | ||
1054 | Iterator it; | 1057 | Iterator it; |
1055 | for ( it = begin(); it != end(); ++it ) { | 1058 | for ( it = begin(); it != end(); ++it ) { |
1056 | if ( (*it).hasCategory( category) ) { | 1059 | if ( (*it).hasCategory( category) ) { |
1057 | results.append( *it ); | 1060 | results.append( *it ); |
1058 | } | 1061 | } |
1059 | } | 1062 | } |
1060 | 1063 | ||
1061 | return results; | 1064 | return results; |
1062 | } | 1065 | } |
1063 | 1066 | ||
1064 | void AddressBook::dump() const | 1067 | void AddressBook::dump() const |
1065 | { | 1068 | { |
1066 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; | 1069 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; |
1067 | 1070 | ||
1068 | ConstIterator it; | 1071 | ConstIterator it; |
1069 | for( it = begin(); it != end(); ++it ) { | 1072 | for( it = begin(); it != end(); ++it ) { |
1070 | (*it).dump(); | 1073 | (*it).dump(); |
1071 | } | 1074 | } |
1072 | 1075 | ||
1073 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; | 1076 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; |
1074 | } | 1077 | } |
1075 | 1078 | ||
1076 | QString AddressBook::identifier() | 1079 | QString AddressBook::identifier() |
1077 | { | 1080 | { |
1078 | QStringList identifier; | 1081 | QStringList identifier; |
1079 | 1082 | ||
1080 | 1083 | ||
1081 | KRES::Manager<Resource>::ActiveIterator it; | 1084 | KRES::Manager<Resource>::ActiveIterator it; |
1082 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 1085 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
1083 | if ( !(*it)->identifier().isEmpty() ) | 1086 | if ( !(*it)->identifier().isEmpty() ) |
1084 | identifier.append( (*it)->identifier() ); | 1087 | identifier.append( (*it)->identifier() ); |
1085 | } | 1088 | } |
1086 | 1089 | ||
1087 | return identifier.join( ":" ); | 1090 | return identifier.join( ":" ); |
1088 | } | 1091 | } |
1089 | 1092 | ||
1090 | Field::List AddressBook::fields( int category ) | 1093 | Field::List AddressBook::fields( int category ) |
1091 | { | 1094 | { |
1092 | if ( d->mAllFields.isEmpty() ) { | 1095 | if ( d->mAllFields.isEmpty() ) { |
1093 | d->mAllFields = Field::allFields(); | 1096 | d->mAllFields = Field::allFields(); |
1094 | } | 1097 | } |
1095 | 1098 | ||
1096 | if ( category == Field::All ) return d->mAllFields; | 1099 | if ( category == Field::All ) return d->mAllFields; |
1097 | 1100 | ||
1098 | Field::List result; | 1101 | Field::List result; |
1099 | Field::List::ConstIterator it; | 1102 | Field::List::ConstIterator it; |
1100 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { | 1103 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { |
1101 | if ( (*it)->category() & category ) result.append( *it ); | 1104 | if ( (*it)->category() & category ) result.append( *it ); |
1102 | } | 1105 | } |
1103 | 1106 | ||
1104 | return result; | 1107 | return result; |
1105 | } | 1108 | } |
1106 | 1109 | ||
1107 | bool AddressBook::addCustomField( const QString &label, int category, | 1110 | bool AddressBook::addCustomField( const QString &label, int category, |
1108 | const QString &key, const QString &app ) | 1111 | const QString &key, const QString &app ) |
1109 | { | 1112 | { |
1110 | if ( d->mAllFields.isEmpty() ) { | 1113 | if ( d->mAllFields.isEmpty() ) { |
1111 | d->mAllFields = Field::allFields(); | 1114 | d->mAllFields = Field::allFields(); |
1112 | } | 1115 | } |
1113 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; | 1116 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; |
1114 | QString a = app.isNull() ? KGlobal::getAppName() : app; | 1117 | QString a = app.isNull() ? KGlobal::getAppName() : app; |
1115 | 1118 | ||
1116 | QString k = key.isNull() ? label : key; | 1119 | QString k = key.isNull() ? label : key; |
1117 | 1120 | ||
1118 | Field *field = Field::createCustomField( label, category, k, a ); | 1121 | Field *field = Field::createCustomField( label, category, k, a ); |
1119 | 1122 | ||
1120 | if ( !field ) return false; | 1123 | if ( !field ) return false; |
1121 | 1124 | ||
1122 | d->mAllFields.append( field ); | 1125 | d->mAllFields.append( field ); |
1123 | 1126 | ||
1124 | return true; | 1127 | return true; |
1125 | } | 1128 | } |
1126 | 1129 | ||
1127 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) | 1130 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) |
1128 | { | 1131 | { |
1129 | if (!ab.d) return s; | 1132 | if (!ab.d) return s; |
1130 | 1133 | ||
1131 | return s << ab.d->mAddressees; | 1134 | return s << ab.d->mAddressees; |
1132 | } | 1135 | } |
1133 | 1136 | ||
1134 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) | 1137 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) |
1135 | { | 1138 | { |
1136 | if (!ab.d) return s; | 1139 | if (!ab.d) return s; |
1137 | 1140 | ||
1138 | s >> ab.d->mAddressees; | 1141 | s >> ab.d->mAddressees; |
1139 | 1142 | ||
1140 | return s; | 1143 | return s; |
1141 | } | 1144 | } |
1142 | 1145 | ||
1143 | bool AddressBook::addResource( Resource *resource ) | 1146 | bool AddressBook::addResource( Resource *resource ) |
1144 | { | 1147 | { |
1145 | if ( !resource->open() ) { | 1148 | if ( !resource->open() ) { |
1146 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; | 1149 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; |
1147 | return false; | 1150 | return false; |
1148 | } | 1151 | } |
1149 | 1152 | ||
1150 | resource->setAddressBook( this ); | 1153 | resource->setAddressBook( this ); |
1151 | 1154 | ||
1152 | d->mManager->add( resource ); | 1155 | d->mManager->add( resource ); |
1153 | return true; | 1156 | return true; |
1154 | } | 1157 | } |
1155 | 1158 | ||
1156 | bool AddressBook::removeResource( Resource *resource ) | 1159 | bool AddressBook::removeResource( Resource *resource ) |
1157 | { | 1160 | { |
1158 | resource->close(); | 1161 | resource->close(); |
1159 | 1162 | ||
1160 | if ( resource == standardResource() ) | 1163 | if ( resource == standardResource() ) |
1161 | d->mManager->setStandardResource( 0 ); | 1164 | d->mManager->setStandardResource( 0 ); |
1162 | 1165 | ||
1163 | resource->setAddressBook( 0 ); | 1166 | resource->setAddressBook( 0 ); |
1164 | 1167 | ||
1165 | d->mManager->remove( resource ); | 1168 | d->mManager->remove( resource ); |
1166 | return true; | 1169 | return true; |
1167 | } | 1170 | } |
1168 | 1171 | ||
1169 | QPtrList<Resource> AddressBook::resources() | 1172 | QPtrList<Resource> AddressBook::resources() |
1170 | { | 1173 | { |
1171 | QPtrList<Resource> list; | 1174 | QPtrList<Resource> list; |
1172 | 1175 | ||
1173 | // qDebug("AddressBook::resources() 1"); | 1176 | // qDebug("AddressBook::resources() 1"); |
1174 | 1177 | ||
1175 | KRES::Manager<Resource>::ActiveIterator it; | 1178 | KRES::Manager<Resource>::ActiveIterator it; |
1176 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 1179 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
1177 | list.append( *it ); | 1180 | list.append( *it ); |
1178 | 1181 | ||
1179 | return list; | 1182 | return list; |
1180 | } | 1183 | } |
1181 | 1184 | ||
1182 | /*US | 1185 | /*US |
1183 | void AddressBook::setErrorHandler( ErrorHandler *handler ) | 1186 | void AddressBook::setErrorHandler( ErrorHandler *handler ) |
1184 | { | 1187 | { |
1185 | delete d->mErrorHandler; | 1188 | delete d->mErrorHandler; |
1186 | d->mErrorHandler = handler; | 1189 | d->mErrorHandler = handler; |
1187 | } | 1190 | } |
1188 | */ | 1191 | */ |
1189 | 1192 | ||
1190 | void AddressBook::error( const QString& msg ) | 1193 | void AddressBook::error( const QString& msg ) |
1191 | { | 1194 | { |
1192 | /*US | 1195 | /*US |
1193 | if ( !d->mErrorHandler ) // create default error handler | 1196 | if ( !d->mErrorHandler ) // create default error handler |
1194 | d->mErrorHandler = new ConsoleErrorHandler; | 1197 | d->mErrorHandler = new ConsoleErrorHandler; |
1195 | 1198 | ||
1196 | if ( d->mErrorHandler ) | 1199 | if ( d->mErrorHandler ) |
1197 | d->mErrorHandler->error( msg ); | 1200 | d->mErrorHandler->error( msg ); |
1198 | else | 1201 | else |
1199 | kdError(5700) << "no error handler defined" << endl; | 1202 | kdError(5700) << "no error handler defined" << endl; |
1200 | */ | 1203 | */ |
1201 | kdDebug(5700) << "msg" << endl; | 1204 | kdDebug(5700) << "msg" << endl; |
1202 | qDebug(msg); | 1205 | qDebug(msg); |
1203 | } | 1206 | } |
1204 | 1207 | ||
1205 | void AddressBook::deleteRemovedAddressees() | 1208 | void AddressBook::deleteRemovedAddressees() |
1206 | { | 1209 | { |
1207 | Addressee::List::Iterator it; | 1210 | Addressee::List::Iterator it; |
1208 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { | 1211 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { |
1209 | Resource *resource = (*it).resource(); | 1212 | Resource *resource = (*it).resource(); |
1210 | if ( resource && !resource->readOnly() && resource->isOpen() ) | 1213 | if ( resource && !resource->readOnly() && resource->isOpen() ) |
1211 | resource->removeAddressee( *it ); | 1214 | resource->removeAddressee( *it ); |
1212 | } | 1215 | } |
1213 | 1216 | ||
1214 | d->mRemovedAddressees.clear(); | 1217 | d->mRemovedAddressees.clear(); |
1215 | } | 1218 | } |
1216 | 1219 | ||
1217 | void AddressBook::setStandardResource( Resource *resource ) | 1220 | void AddressBook::setStandardResource( Resource *resource ) |
1218 | { | 1221 | { |
1219 | // qDebug("AddressBook::setStandardResource 1"); | 1222 | // qDebug("AddressBook::setStandardResource 1"); |
1220 | d->mManager->setStandardResource( resource ); | 1223 | d->mManager->setStandardResource( resource ); |
1221 | } | 1224 | } |
1222 | 1225 | ||
1223 | Resource *AddressBook::standardResource() | 1226 | Resource *AddressBook::standardResource() |
1224 | { | 1227 | { |
1225 | return d->mManager->standardResource(); | 1228 | return d->mManager->standardResource(); |
1226 | } | 1229 | } |
1227 | 1230 | ||
1228 | KRES::Manager<Resource> *AddressBook::resourceManager() | 1231 | KRES::Manager<Resource> *AddressBook::resourceManager() |
1229 | { | 1232 | { |
1230 | return d->mManager; | 1233 | return d->mManager; |
1231 | } | 1234 | } |
1232 | 1235 | ||
1233 | void AddressBook::cleanUp() | 1236 | void AddressBook::cleanUp() |
1234 | { | 1237 | { |
1235 | KRES::Manager<Resource>::ActiveIterator it; | 1238 | KRES::Manager<Resource>::ActiveIterator it; |
1236 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 1239 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
1237 | if ( !(*it)->readOnly() && (*it)->isOpen() ) | 1240 | if ( !(*it)->readOnly() && (*it)->isOpen() ) |
1238 | (*it)->cleanUp(); | 1241 | (*it)->cleanUp(); |
1239 | } | 1242 | } |
1240 | } | 1243 | } |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 2f00a09..ea87929 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -547,2370 +547,2389 @@ void KABCore::createAboutData() | |||
547 | about->addAuthor( "Cornelius Schumacher", | 547 | about->addAuthor( "Cornelius Schumacher", |
548 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 548 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
549 | "schumacher@kde.org" ); | 549 | "schumacher@kde.org" ); |
550 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 550 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
551 | "mpilone@slac.com" ); | 551 | "mpilone@slac.com" ); |
552 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 552 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
553 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 553 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
554 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 554 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
555 | "michel@klaralvdalens-datakonsult.se" ); | 555 | "michel@klaralvdalens-datakonsult.se" ); |
556 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 556 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
557 | "hansen@kde.org" ); | 557 | "hansen@kde.org" ); |
558 | 558 | ||
559 | return about; | 559 | return about; |
560 | #endif //KAB_EMBEDDED | 560 | #endif //KAB_EMBEDDED |
561 | 561 | ||
562 | QString version; | 562 | QString version; |
563 | #include <../version> | 563 | #include <../version> |
564 | QMessageBox::about( this, "About KAddressbook/Pi", | 564 | QMessageBox::about( this, "About KAddressbook/Pi", |
565 | "KAddressbook/Platform-independent\n" | 565 | "KAddressbook/Platform-independent\n" |
566 | "(KA/Pi) " +version + " - " + | 566 | "(KA/Pi) " +version + " - " + |
567 | #ifdef DESKTOP_VERSION | 567 | #ifdef DESKTOP_VERSION |
568 | "Desktop Edition\n" | 568 | "Desktop Edition\n" |
569 | #else | 569 | #else |
570 | "PDA-Edition\n" | 570 | "PDA-Edition\n" |
571 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 571 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
572 | #endif | 572 | #endif |
573 | 573 | ||
574 | "(c) 2004 Ulf Schenk\n" | 574 | "(c) 2004 Ulf Schenk\n" |
575 | "(c) 2004 Lutz Rogowski\n" | 575 | "(c) 2004 Lutz Rogowski\n" |
576 | "(c) 1997-2003, The KDE PIM Team\n" | 576 | "(c) 1997-2003, The KDE PIM Team\n" |
577 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 577 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
578 | "Don Sanders Original author\n" | 578 | "Don Sanders Original author\n" |
579 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 579 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
580 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 580 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
581 | "Greg Stern DCOP interface\n" | 581 | "Greg Stern DCOP interface\n" |
582 | "Mark Westcot Contact pinning\n" | 582 | "Mark Westcot Contact pinning\n" |
583 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 583 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
584 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 584 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
585 | #ifdef _WIN32_ | 585 | #ifdef _WIN32_ |
586 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 586 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
587 | #endif | 587 | #endif |
588 | ); | 588 | ); |
589 | } | 589 | } |
590 | 590 | ||
591 | void KABCore::setContactSelected( const QString &uid ) | 591 | void KABCore::setContactSelected( const QString &uid ) |
592 | { | 592 | { |
593 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 593 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
594 | if ( !mDetails->isHidden() ) | 594 | if ( !mDetails->isHidden() ) |
595 | mDetails->setAddressee( addr ); | 595 | mDetails->setAddressee( addr ); |
596 | 596 | ||
597 | if ( !addr.isEmpty() ) { | 597 | if ( !addr.isEmpty() ) { |
598 | emit contactSelected( addr.formattedName() ); | 598 | emit contactSelected( addr.formattedName() ); |
599 | KABC::Picture pic = addr.photo(); | 599 | KABC::Picture pic = addr.photo(); |
600 | if ( pic.isIntern() ) { | 600 | if ( pic.isIntern() ) { |
601 | //US emit contactSelected( pic.data() ); | 601 | //US emit contactSelected( pic.data() ); |
602 | //US instead use: | 602 | //US instead use: |
603 | QPixmap px; | 603 | QPixmap px; |
604 | if (pic.data().isNull() != true) | 604 | if (pic.data().isNull() != true) |
605 | { | 605 | { |
606 | px.convertFromImage(pic.data()); | 606 | px.convertFromImage(pic.data()); |
607 | } | 607 | } |
608 | 608 | ||
609 | emit contactSelected( px ); | 609 | emit contactSelected( px ); |
610 | } | 610 | } |
611 | } | 611 | } |
612 | 612 | ||
613 | 613 | ||
614 | mExtensionManager->setSelectionChanged(); | 614 | mExtensionManager->setSelectionChanged(); |
615 | 615 | ||
616 | // update the actions | 616 | // update the actions |
617 | bool selected = !uid.isEmpty(); | 617 | bool selected = !uid.isEmpty(); |
618 | 618 | ||
619 | if ( mReadWrite ) { | 619 | if ( mReadWrite ) { |
620 | mActionCut->setEnabled( selected ); | 620 | mActionCut->setEnabled( selected ); |
621 | mActionPaste->setEnabled( selected ); | 621 | mActionPaste->setEnabled( selected ); |
622 | } | 622 | } |
623 | 623 | ||
624 | mActionCopy->setEnabled( selected ); | 624 | mActionCopy->setEnabled( selected ); |
625 | mActionDelete->setEnabled( selected ); | 625 | mActionDelete->setEnabled( selected ); |
626 | mActionEditAddressee->setEnabled( selected ); | 626 | mActionEditAddressee->setEnabled( selected ); |
627 | mActionMail->setEnabled( selected ); | 627 | mActionMail->setEnabled( selected ); |
628 | mActionMailVCard->setEnabled( selected ); | 628 | mActionMailVCard->setEnabled( selected ); |
629 | //if (mActionBeam) | 629 | //if (mActionBeam) |
630 | //mActionBeam->setEnabled( selected ); | 630 | //mActionBeam->setEnabled( selected ); |
631 | 631 | ||
632 | if (mActionBeamVCard) | 632 | if (mActionBeamVCard) |
633 | mActionBeamVCard->setEnabled( selected ); | 633 | mActionBeamVCard->setEnabled( selected ); |
634 | 634 | ||
635 | mActionExport2phone->setEnabled( selected ); | 635 | mActionExport2phone->setEnabled( selected ); |
636 | mActionWhoAmI->setEnabled( selected ); | 636 | mActionWhoAmI->setEnabled( selected ); |
637 | mActionCategories->setEnabled( selected ); | 637 | mActionCategories->setEnabled( selected ); |
638 | } | 638 | } |
639 | 639 | ||
640 | void KABCore::sendMail() | 640 | void KABCore::sendMail() |
641 | { | 641 | { |
642 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 642 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
643 | } | 643 | } |
644 | 644 | ||
645 | void KABCore::sendMail( const QString& emaillist ) | 645 | void KABCore::sendMail( const QString& emaillist ) |
646 | { | 646 | { |
647 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 647 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
648 | if (emaillist.contains(",") > 0) | 648 | if (emaillist.contains(",") > 0) |
649 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 649 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
650 | else | 650 | else |
651 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 651 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
652 | } | 652 | } |
653 | 653 | ||
654 | 654 | ||
655 | 655 | ||
656 | void KABCore::mailVCard() | 656 | void KABCore::mailVCard() |
657 | { | 657 | { |
658 | QStringList uids = mViewManager->selectedUids(); | 658 | QStringList uids = mViewManager->selectedUids(); |
659 | if ( !uids.isEmpty() ) | 659 | if ( !uids.isEmpty() ) |
660 | mailVCard( uids ); | 660 | mailVCard( uids ); |
661 | } | 661 | } |
662 | 662 | ||
663 | void KABCore::mailVCard( const QStringList& uids ) | 663 | void KABCore::mailVCard( const QStringList& uids ) |
664 | { | 664 | { |
665 | QStringList urls; | 665 | QStringList urls; |
666 | 666 | ||
667 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 667 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
668 | 668 | ||
669 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 669 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
670 | 670 | ||
671 | 671 | ||
672 | 672 | ||
673 | QDir().mkdir( dirName, true ); | 673 | QDir().mkdir( dirName, true ); |
674 | 674 | ||
675 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 675 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
676 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 676 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
677 | 677 | ||
678 | if ( a.isEmpty() ) | 678 | if ( a.isEmpty() ) |
679 | continue; | 679 | continue; |
680 | 680 | ||
681 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 681 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
682 | 682 | ||
683 | QString fileName = dirName + "/" + name; | 683 | QString fileName = dirName + "/" + name; |
684 | 684 | ||
685 | QFile outFile(fileName); | 685 | QFile outFile(fileName); |
686 | 686 | ||
687 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 687 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
688 | KABC::VCardConverter converter; | 688 | KABC::VCardConverter converter; |
689 | QString vcard; | 689 | QString vcard; |
690 | 690 | ||
691 | converter.addresseeToVCard( a, vcard ); | 691 | converter.addresseeToVCard( a, vcard ); |
692 | 692 | ||
693 | QTextStream t( &outFile ); // use a text stream | 693 | QTextStream t( &outFile ); // use a text stream |
694 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 694 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
695 | t << vcard; | 695 | t << vcard; |
696 | 696 | ||
697 | outFile.close(); | 697 | outFile.close(); |
698 | 698 | ||
699 | urls.append( fileName ); | 699 | urls.append( fileName ); |
700 | } | 700 | } |
701 | } | 701 | } |
702 | 702 | ||
703 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 703 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
704 | 704 | ||
705 | 705 | ||
706 | /*US | 706 | /*US |
707 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 707 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
708 | QString::null, // subject | 708 | QString::null, // subject |
709 | QString::null, // body | 709 | QString::null, // body |
710 | QString::null, | 710 | QString::null, |
711 | urls ); // attachments | 711 | urls ); // attachments |
712 | */ | 712 | */ |
713 | 713 | ||
714 | } | 714 | } |
715 | 715 | ||
716 | /** | 716 | /** |
717 | Beams the "WhoAmI contact. | 717 | Beams the "WhoAmI contact. |
718 | */ | 718 | */ |
719 | void KABCore::beamMySelf() | 719 | void KABCore::beamMySelf() |
720 | { | 720 | { |
721 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 721 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
722 | if (!a.isEmpty()) | 722 | if (!a.isEmpty()) |
723 | { | 723 | { |
724 | QStringList uids; | 724 | QStringList uids; |
725 | uids << a.uid(); | 725 | uids << a.uid(); |
726 | 726 | ||
727 | beamVCard(uids); | 727 | beamVCard(uids); |
728 | } else { | 728 | } else { |
729 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 729 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
730 | 730 | ||
731 | 731 | ||
732 | } | 732 | } |
733 | } | 733 | } |
734 | 734 | ||
735 | void KABCore::export2phone() | 735 | void KABCore::export2phone() |
736 | { | 736 | { |
737 | 737 | ||
738 | KAex2phonePrefs ex2phone; | 738 | KAex2phonePrefs ex2phone; |
739 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 739 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
740 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 740 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
741 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 741 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
742 | 742 | ||
743 | if ( !ex2phone.exec() ) { | 743 | if ( !ex2phone.exec() ) { |
744 | return; | 744 | return; |
745 | } | 745 | } |
746 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 746 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
747 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 747 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
748 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 748 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
749 | 749 | ||
750 | 750 | ||
751 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 751 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
752 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 752 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
753 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 753 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
754 | 754 | ||
755 | QStringList uids = mViewManager->selectedUids(); | 755 | QStringList uids = mViewManager->selectedUids(); |
756 | if ( uids.isEmpty() ) | 756 | if ( uids.isEmpty() ) |
757 | return; | 757 | return; |
758 | 758 | ||
759 | QString fileName = getPhoneFile(); | 759 | QString fileName = getPhoneFile(); |
760 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 760 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
761 | return; | 761 | return; |
762 | 762 | ||
763 | message(i18n("Exporting to phone...")); | 763 | message(i18n("Exporting to phone...")); |
764 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 764 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
765 | 765 | ||
766 | } | 766 | } |
767 | QString KABCore::getPhoneFile() | 767 | QString KABCore::getPhoneFile() |
768 | { | 768 | { |
769 | #ifdef DESKTOP_VERSION | 769 | #ifdef DESKTOP_VERSION |
770 | return locateLocal("tmp", "phonefile.vcf"); | 770 | return locateLocal("tmp", "phonefile.vcf"); |
771 | #else | 771 | #else |
772 | return "/tmp/phonefile.vcf"; | 772 | return "/tmp/phonefile.vcf"; |
773 | #endif | 773 | #endif |
774 | 774 | ||
775 | } | 775 | } |
776 | void KABCore::writeToPhone( ) | 776 | void KABCore::writeToPhone( ) |
777 | { | 777 | { |
778 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 778 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
779 | message(i18n("Export to phone finished!")); | 779 | message(i18n("Export to phone finished!")); |
780 | else | 780 | else |
781 | qDebug(i18n("Error exporting to phone")); | 781 | qDebug(i18n("Error exporting to phone")); |
782 | } | 782 | } |
783 | void KABCore::beamVCard() | 783 | void KABCore::beamVCard() |
784 | { | 784 | { |
785 | QStringList uids = mViewManager->selectedUids(); | 785 | QStringList uids = mViewManager->selectedUids(); |
786 | if ( !uids.isEmpty() ) | 786 | if ( !uids.isEmpty() ) |
787 | beamVCard( uids ); | 787 | beamVCard( uids ); |
788 | } | 788 | } |
789 | 789 | ||
790 | 790 | ||
791 | void KABCore::beamVCard(const QStringList& uids) | 791 | void KABCore::beamVCard(const QStringList& uids) |
792 | { | 792 | { |
793 | 793 | ||
794 | // LR: we should use the /tmp dir on the Zaurus, | 794 | // LR: we should use the /tmp dir on the Zaurus, |
795 | // because: /tmp = RAM, (HOME)/kdepim = flash memory | 795 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
796 | 796 | ||
797 | #ifdef DESKTOP_VERSION | 797 | #ifdef DESKTOP_VERSION |
798 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | 798 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); |
799 | #else | 799 | #else |
800 | QString fileName = "/tmp/kapibeamfile.vcf"; | 800 | QString fileName = "/tmp/kapibeamfile.vcf"; |
801 | #endif | 801 | #endif |
802 | 802 | ||
803 | KABC::VCardConverter converter; | 803 | KABC::VCardConverter converter; |
804 | QString description; | 804 | QString description; |
805 | QString datastream; | 805 | QString datastream; |
806 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 806 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
807 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 807 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
808 | 808 | ||
809 | if ( a.isEmpty() ) | 809 | if ( a.isEmpty() ) |
810 | continue; | 810 | continue; |
811 | 811 | ||
812 | if (description.isEmpty()) | 812 | if (description.isEmpty()) |
813 | description = a.formattedName(); | 813 | description = a.formattedName(); |
814 | 814 | ||
815 | QString vcard; | 815 | QString vcard; |
816 | converter.addresseeToVCard( a, vcard ); | 816 | converter.addresseeToVCard( a, vcard ); |
817 | int start = 0; | 817 | int start = 0; |
818 | int next; | 818 | int next; |
819 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 819 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
820 | int semi = vcard.find(";", next); | 820 | int semi = vcard.find(";", next); |
821 | int dopp = vcard.find(":", next); | 821 | int dopp = vcard.find(":", next); |
822 | int sep; | 822 | int sep; |
823 | if ( semi < dopp && semi >= 0 ) | 823 | if ( semi < dopp && semi >= 0 ) |
824 | sep = semi ; | 824 | sep = semi ; |
825 | else | 825 | else |
826 | sep = dopp; | 826 | sep = dopp; |
827 | datastream +=vcard.mid( start, next - start); | 827 | datastream +=vcard.mid( start, next - start); |
828 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 828 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
829 | start = sep; | 829 | start = sep; |
830 | } | 830 | } |
831 | datastream += vcard.mid( start,vcard.length() ); | 831 | datastream += vcard.mid( start,vcard.length() ); |
832 | } | 832 | } |
833 | #ifndef DESKTOP_VERSION | 833 | #ifndef DESKTOP_VERSION |
834 | QFile outFile(fileName); | 834 | QFile outFile(fileName); |
835 | if ( outFile.open(IO_WriteOnly) ) { | 835 | if ( outFile.open(IO_WriteOnly) ) { |
836 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 836 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
837 | QTextStream t( &outFile ); // use a text stream | 837 | QTextStream t( &outFile ); // use a text stream |
838 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 838 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
839 | t.setEncoding( QTextStream::Latin1 ); | 839 | t.setEncoding( QTextStream::Latin1 ); |
840 | t <<datastream.latin1(); | 840 | t <<datastream.latin1(); |
841 | outFile.close(); | 841 | outFile.close(); |
842 | Ir *ir = new Ir( this ); | 842 | Ir *ir = new Ir( this ); |
843 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 843 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
844 | ir->send( fileName, description, "text/x-vCard" ); | 844 | ir->send( fileName, description, "text/x-vCard" ); |
845 | } else { | 845 | } else { |
846 | qDebug("Error open temp beam file "); | 846 | qDebug("Error open temp beam file "); |
847 | return; | 847 | return; |
848 | } | 848 | } |
849 | #endif | 849 | #endif |
850 | 850 | ||
851 | } | 851 | } |
852 | 852 | ||
853 | void KABCore::beamDone( Ir *ir ) | 853 | void KABCore::beamDone( Ir *ir ) |
854 | { | 854 | { |
855 | #ifndef DESKTOP_VERSION | 855 | #ifndef DESKTOP_VERSION |
856 | delete ir; | 856 | delete ir; |
857 | #endif | 857 | #endif |
858 | topLevelWidget()->raise(); | 858 | topLevelWidget()->raise(); |
859 | message( i18n("Beaming finished!") ); | 859 | message( i18n("Beaming finished!") ); |
860 | } | 860 | } |
861 | 861 | ||
862 | 862 | ||
863 | void KABCore::browse( const QString& url ) | 863 | void KABCore::browse( const QString& url ) |
864 | { | 864 | { |
865 | #ifndef KAB_EMBEDDED | 865 | #ifndef KAB_EMBEDDED |
866 | kapp->invokeBrowser( url ); | 866 | kapp->invokeBrowser( url ); |
867 | #else //KAB_EMBEDDED | 867 | #else //KAB_EMBEDDED |
868 | qDebug("KABCore::browse must be fixed"); | 868 | qDebug("KABCore::browse must be fixed"); |
869 | #endif //KAB_EMBEDDED | 869 | #endif //KAB_EMBEDDED |
870 | } | 870 | } |
871 | 871 | ||
872 | void KABCore::selectAllContacts() | 872 | void KABCore::selectAllContacts() |
873 | { | 873 | { |
874 | mViewManager->setSelected( QString::null, true ); | 874 | mViewManager->setSelected( QString::null, true ); |
875 | } | 875 | } |
876 | 876 | ||
877 | void KABCore::deleteContacts() | 877 | void KABCore::deleteContacts() |
878 | { | 878 | { |
879 | QStringList uidList = mViewManager->selectedUids(); | 879 | QStringList uidList = mViewManager->selectedUids(); |
880 | deleteContacts( uidList ); | 880 | deleteContacts( uidList ); |
881 | } | 881 | } |
882 | 882 | ||
883 | void KABCore::deleteContacts( const QStringList &uids ) | 883 | void KABCore::deleteContacts( const QStringList &uids ) |
884 | { | 884 | { |
885 | if ( uids.count() > 0 ) { | 885 | if ( uids.count() > 0 ) { |
886 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 886 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
887 | UndoStack::instance()->push( command ); | 887 | UndoStack::instance()->push( command ); |
888 | RedoStack::instance()->clear(); | 888 | RedoStack::instance()->clear(); |
889 | 889 | ||
890 | // now if we deleted anything, refresh | 890 | // now if we deleted anything, refresh |
891 | setContactSelected( QString::null ); | 891 | setContactSelected( QString::null ); |
892 | setModified( true ); | 892 | setModified( true ); |
893 | } | 893 | } |
894 | } | 894 | } |
895 | 895 | ||
896 | void KABCore::copyContacts() | 896 | void KABCore::copyContacts() |
897 | { | 897 | { |
898 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 898 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
899 | 899 | ||
900 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 900 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
901 | 901 | ||
902 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 902 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
903 | 903 | ||
904 | QClipboard *cb = QApplication::clipboard(); | 904 | QClipboard *cb = QApplication::clipboard(); |
905 | cb->setText( clipText ); | 905 | cb->setText( clipText ); |
906 | } | 906 | } |
907 | 907 | ||
908 | void KABCore::cutContacts() | 908 | void KABCore::cutContacts() |
909 | { | 909 | { |
910 | QStringList uidList = mViewManager->selectedUids(); | 910 | QStringList uidList = mViewManager->selectedUids(); |
911 | 911 | ||
912 | //US if ( uidList.size() > 0 ) { | 912 | //US if ( uidList.size() > 0 ) { |
913 | if ( uidList.count() > 0 ) { | 913 | if ( uidList.count() > 0 ) { |
914 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 914 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
915 | UndoStack::instance()->push( command ); | 915 | UndoStack::instance()->push( command ); |
916 | RedoStack::instance()->clear(); | 916 | RedoStack::instance()->clear(); |
917 | 917 | ||
918 | setModified( true ); | 918 | setModified( true ); |
919 | } | 919 | } |
920 | } | 920 | } |
921 | 921 | ||
922 | void KABCore::pasteContacts() | 922 | void KABCore::pasteContacts() |
923 | { | 923 | { |
924 | QClipboard *cb = QApplication::clipboard(); | 924 | QClipboard *cb = QApplication::clipboard(); |
925 | 925 | ||
926 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 926 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
927 | 927 | ||
928 | pasteContacts( list ); | 928 | pasteContacts( list ); |
929 | } | 929 | } |
930 | 930 | ||
931 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 931 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
932 | { | 932 | { |
933 | KABC::Resource *resource = requestResource( this ); | 933 | KABC::Resource *resource = requestResource( this ); |
934 | KABC::Addressee::List::Iterator it; | 934 | KABC::Addressee::List::Iterator it; |
935 | for ( it = list.begin(); it != list.end(); ++it ) | 935 | for ( it = list.begin(); it != list.end(); ++it ) |
936 | (*it).setResource( resource ); | 936 | (*it).setResource( resource ); |
937 | 937 | ||
938 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 938 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
939 | UndoStack::instance()->push( command ); | 939 | UndoStack::instance()->push( command ); |
940 | RedoStack::instance()->clear(); | 940 | RedoStack::instance()->clear(); |
941 | 941 | ||
942 | setModified( true ); | 942 | setModified( true ); |
943 | } | 943 | } |
944 | 944 | ||
945 | void KABCore::setWhoAmI() | 945 | void KABCore::setWhoAmI() |
946 | { | 946 | { |
947 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 947 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
948 | 948 | ||
949 | if ( addrList.count() > 1 ) { | 949 | if ( addrList.count() > 1 ) { |
950 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 950 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
951 | return; | 951 | return; |
952 | } | 952 | } |
953 | 953 | ||
954 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 954 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
955 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 955 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
956 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 956 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
957 | } | 957 | } |
958 | 958 | ||
959 | void KABCore::setCategories() | 959 | void KABCore::setCategories() |
960 | { | 960 | { |
961 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 961 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
962 | if ( !dlg.exec() ) | 962 | if ( !dlg.exec() ) |
963 | return; | 963 | return; |
964 | 964 | ||
965 | bool merge = false; | 965 | bool merge = false; |
966 | QString msg = i18n( "Merge with existing categories?" ); | 966 | QString msg = i18n( "Merge with existing categories?" ); |
967 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 967 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
968 | merge = true; | 968 | merge = true; |
969 | 969 | ||
970 | QStringList categories = dlg.selectedCategories(); | 970 | QStringList categories = dlg.selectedCategories(); |
971 | 971 | ||
972 | QStringList uids = mViewManager->selectedUids(); | 972 | QStringList uids = mViewManager->selectedUids(); |
973 | QStringList::Iterator it; | 973 | QStringList::Iterator it; |
974 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 974 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
975 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 975 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
976 | if ( !addr.isEmpty() ) { | 976 | if ( !addr.isEmpty() ) { |
977 | if ( !merge ) | 977 | if ( !merge ) |
978 | addr.setCategories( categories ); | 978 | addr.setCategories( categories ); |
979 | else { | 979 | else { |
980 | QStringList addrCategories = addr.categories(); | 980 | QStringList addrCategories = addr.categories(); |
981 | QStringList::Iterator catIt; | 981 | QStringList::Iterator catIt; |
982 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 982 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
983 | if ( !addrCategories.contains( *catIt ) ) | 983 | if ( !addrCategories.contains( *catIt ) ) |
984 | addrCategories.append( *catIt ); | 984 | addrCategories.append( *catIt ); |
985 | } | 985 | } |
986 | addr.setCategories( addrCategories ); | 986 | addr.setCategories( addrCategories ); |
987 | } | 987 | } |
988 | 988 | ||
989 | mAddressBook->insertAddressee( addr ); | 989 | mAddressBook->insertAddressee( addr ); |
990 | } | 990 | } |
991 | } | 991 | } |
992 | 992 | ||
993 | if ( uids.count() > 0 ) | 993 | if ( uids.count() > 0 ) |
994 | setModified( true ); | 994 | setModified( true ); |
995 | } | 995 | } |
996 | 996 | ||
997 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 997 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
998 | { | 998 | { |
999 | mIncSearchWidget->setFields( fields ); | 999 | mIncSearchWidget->setFields( fields ); |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | void KABCore::incrementalSearch( const QString& text ) | 1002 | void KABCore::incrementalSearch( const QString& text ) |
1003 | { | 1003 | { |
1004 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1004 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | void KABCore::setModified() | 1007 | void KABCore::setModified() |
1008 | { | 1008 | { |
1009 | setModified( true ); | 1009 | setModified( true ); |
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | void KABCore::setModifiedWOrefresh() | 1012 | void KABCore::setModifiedWOrefresh() |
1013 | { | 1013 | { |
1014 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1014 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1015 | mModified = true; | 1015 | mModified = true; |
1016 | mActionSave->setEnabled( mModified ); | 1016 | mActionSave->setEnabled( mModified ); |
1017 | #ifdef DESKTOP_VERSION | 1017 | #ifdef DESKTOP_VERSION |
1018 | mDetails->refreshView(); | 1018 | mDetails->refreshView(); |
1019 | #endif | 1019 | #endif |
1020 | 1020 | ||
1021 | } | 1021 | } |
1022 | void KABCore::setModified( bool modified ) | 1022 | void KABCore::setModified( bool modified ) |
1023 | { | 1023 | { |
1024 | mModified = modified; | 1024 | mModified = modified; |
1025 | mActionSave->setEnabled( mModified ); | 1025 | mActionSave->setEnabled( mModified ); |
1026 | 1026 | ||
1027 | if ( modified ) | 1027 | if ( modified ) |
1028 | mJumpButtonBar->recreateButtons(); | 1028 | mJumpButtonBar->recreateButtons(); |
1029 | 1029 | ||
1030 | mViewManager->refreshView(); | 1030 | mViewManager->refreshView(); |
1031 | mDetails->refreshView(); | 1031 | mDetails->refreshView(); |
1032 | 1032 | ||
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | bool KABCore::modified() const | 1035 | bool KABCore::modified() const |
1036 | { | 1036 | { |
1037 | return mModified; | 1037 | return mModified; |
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1040 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1041 | { | 1041 | { |
1042 | 1042 | ||
1043 | Command *command = 0; | 1043 | Command *command = 0; |
1044 | QString uid; | 1044 | QString uid; |
1045 | 1045 | ||
1046 | // check if it exists already | 1046 | // check if it exists already |
1047 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1047 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1048 | if ( origAddr.isEmpty() ) | 1048 | if ( origAddr.isEmpty() ) |
1049 | command = new PwNewCommand( mAddressBook, addr ); | 1049 | command = new PwNewCommand( mAddressBook, addr ); |
1050 | else { | 1050 | else { |
1051 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1051 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1052 | uid = addr.uid(); | 1052 | uid = addr.uid(); |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | UndoStack::instance()->push( command ); | 1055 | UndoStack::instance()->push( command ); |
1056 | RedoStack::instance()->clear(); | 1056 | RedoStack::instance()->clear(); |
1057 | 1057 | ||
1058 | setModified( true ); | 1058 | setModified( true ); |
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | void KABCore::newContact() | 1061 | void KABCore::newContact() |
1062 | { | 1062 | { |
1063 | 1063 | ||
1064 | 1064 | ||
1065 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1065 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1066 | 1066 | ||
1067 | QPtrList<KRES::Resource> kresResources; | 1067 | QPtrList<KRES::Resource> kresResources; |
1068 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1068 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1069 | KABC::Resource *resource; | 1069 | KABC::Resource *resource; |
1070 | while ( ( resource = it.current() ) != 0 ) { | 1070 | while ( ( resource = it.current() ) != 0 ) { |
1071 | ++it; | 1071 | ++it; |
1072 | if ( !resource->readOnly() ) { | 1072 | if ( !resource->readOnly() ) { |
1073 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1073 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1074 | if ( res ) | 1074 | if ( res ) |
1075 | kresResources.append( res ); | 1075 | kresResources.append( res ); |
1076 | } | 1076 | } |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1079 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1080 | resource = static_cast<KABC::Resource*>( res ); | 1080 | resource = static_cast<KABC::Resource*>( res ); |
1081 | 1081 | ||
1082 | if ( resource ) { | 1082 | if ( resource ) { |
1083 | KABC::Addressee addr; | 1083 | KABC::Addressee addr; |
1084 | addr.setResource( resource ); | 1084 | addr.setResource( resource ); |
1085 | mEditorDialog->setAddressee( addr ); | 1085 | mEditorDialog->setAddressee( addr ); |
1086 | KApplication::execDialog ( mEditorDialog ); | 1086 | KApplication::execDialog ( mEditorDialog ); |
1087 | 1087 | ||
1088 | } else | 1088 | } else |
1089 | return; | 1089 | return; |
1090 | 1090 | ||
1091 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1091 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1092 | 1092 | ||
1093 | 1093 | ||
1094 | } | 1094 | } |
1095 | 1095 | ||
1096 | void KABCore::addEmail( QString aStr ) | 1096 | void KABCore::addEmail( QString aStr ) |
1097 | { | 1097 | { |
1098 | #ifndef KAB_EMBEDDED | 1098 | #ifndef KAB_EMBEDDED |
1099 | QString fullName, email; | 1099 | QString fullName, email; |
1100 | 1100 | ||
1101 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1101 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1102 | 1102 | ||
1103 | // Try to lookup the addressee matching the email address | 1103 | // Try to lookup the addressee matching the email address |
1104 | bool found = false; | 1104 | bool found = false; |
1105 | QStringList emailList; | 1105 | QStringList emailList; |
1106 | KABC::AddressBook::Iterator it; | 1106 | KABC::AddressBook::Iterator it; |
1107 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1107 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1108 | emailList = (*it).emails(); | 1108 | emailList = (*it).emails(); |
1109 | if ( emailList.contains( email ) > 0 ) { | 1109 | if ( emailList.contains( email ) > 0 ) { |
1110 | found = true; | 1110 | found = true; |
1111 | (*it).setNameFromString( fullName ); | 1111 | (*it).setNameFromString( fullName ); |
1112 | editContact( (*it).uid() ); | 1112 | editContact( (*it).uid() ); |
1113 | } | 1113 | } |
1114 | } | 1114 | } |
1115 | 1115 | ||
1116 | if ( !found ) { | 1116 | if ( !found ) { |
1117 | KABC::Addressee addr; | 1117 | KABC::Addressee addr; |
1118 | addr.setNameFromString( fullName ); | 1118 | addr.setNameFromString( fullName ); |
1119 | addr.insertEmail( email, true ); | 1119 | addr.insertEmail( email, true ); |
1120 | 1120 | ||
1121 | mAddressBook->insertAddressee( addr ); | 1121 | mAddressBook->insertAddressee( addr ); |
1122 | mViewManager->refreshView( addr.uid() ); | 1122 | mViewManager->refreshView( addr.uid() ); |
1123 | editContact( addr.uid() ); | 1123 | editContact( addr.uid() ); |
1124 | } | 1124 | } |
1125 | #else //KAB_EMBEDDED | 1125 | #else //KAB_EMBEDDED |
1126 | qDebug("KABCore::addEmail finsih method"); | 1126 | qDebug("KABCore::addEmail finsih method"); |
1127 | #endif //KAB_EMBEDDED | 1127 | #endif //KAB_EMBEDDED |
1128 | } | 1128 | } |
1129 | 1129 | ||
1130 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1130 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1131 | { | 1131 | { |
1132 | mXXPortManager->importVCard( url, showPreview ); | 1132 | mXXPortManager->importVCard( url, showPreview ); |
1133 | } | 1133 | } |
1134 | void KABCore::importFromOL() | 1134 | void KABCore::importFromOL() |
1135 | { | 1135 | { |
1136 | #ifdef _WIN32_ | 1136 | #ifdef _WIN32_ |
1137 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1137 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1138 | idgl->exec(); | 1138 | idgl->exec(); |
1139 | KABC::Addressee::List list = idgl->getAddressList(); | 1139 | KABC::Addressee::List list = idgl->getAddressList(); |
1140 | if ( list.count() > 0 ) { | 1140 | if ( list.count() > 0 ) { |
1141 | KABC::Addressee::List listNew; | 1141 | KABC::Addressee::List listNew; |
1142 | KABC::Addressee::List listExisting; | 1142 | KABC::Addressee::List listExisting; |
1143 | KABC::Addressee::List::Iterator it; | 1143 | KABC::Addressee::List::Iterator it; |
1144 | KABC::AddressBook::Iterator iter; | 1144 | KABC::AddressBook::Iterator iter; |
1145 | for ( it = list.begin(); it != list.end(); ++it ) { | 1145 | for ( it = list.begin(); it != list.end(); ++it ) { |
1146 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1146 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1147 | listNew.append( (*it) ); | 1147 | listNew.append( (*it) ); |
1148 | else | 1148 | else |
1149 | listExisting.append( (*it) ); | 1149 | listExisting.append( (*it) ); |
1150 | } | 1150 | } |
1151 | if ( listExisting.count() > 0 ) | 1151 | if ( listExisting.count() > 0 ) |
1152 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1152 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1153 | if ( listNew.count() > 0 ) { | 1153 | if ( listNew.count() > 0 ) { |
1154 | pasteWithNewUid = false; | 1154 | pasteWithNewUid = false; |
1155 | pasteContacts( listNew ); | 1155 | pasteContacts( listNew ); |
1156 | pasteWithNewUid = true; | 1156 | pasteWithNewUid = true; |
1157 | } | 1157 | } |
1158 | } | 1158 | } |
1159 | delete idgl; | 1159 | delete idgl; |
1160 | #endif | 1160 | #endif |
1161 | } | 1161 | } |
1162 | 1162 | ||
1163 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1163 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1164 | { | 1164 | { |
1165 | mXXPortManager->importVCard( vCard, showPreview ); | 1165 | mXXPortManager->importVCard( vCard, showPreview ); |
1166 | } | 1166 | } |
1167 | 1167 | ||
1168 | //US added a second method without defaultparameter | 1168 | //US added a second method without defaultparameter |
1169 | void KABCore::editContact2() { | 1169 | void KABCore::editContact2() { |
1170 | editContact( QString::null ); | 1170 | editContact( QString::null ); |
1171 | } | 1171 | } |
1172 | 1172 | ||
1173 | void KABCore::editContact( const QString &uid ) | 1173 | void KABCore::editContact( const QString &uid ) |
1174 | { | 1174 | { |
1175 | 1175 | ||
1176 | if ( mExtensionManager->isQuickEditVisible() ) | 1176 | if ( mExtensionManager->isQuickEditVisible() ) |
1177 | return; | 1177 | return; |
1178 | 1178 | ||
1179 | // First, locate the contact entry | 1179 | // First, locate the contact entry |
1180 | QString localUID = uid; | 1180 | QString localUID = uid; |
1181 | if ( localUID.isNull() ) { | 1181 | if ( localUID.isNull() ) { |
1182 | QStringList uidList = mViewManager->selectedUids(); | 1182 | QStringList uidList = mViewManager->selectedUids(); |
1183 | if ( uidList.count() > 0 ) | 1183 | if ( uidList.count() > 0 ) |
1184 | localUID = *( uidList.at( 0 ) ); | 1184 | localUID = *( uidList.at( 0 ) ); |
1185 | } | 1185 | } |
1186 | 1186 | ||
1187 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1187 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1188 | if ( !addr.isEmpty() ) { | 1188 | if ( !addr.isEmpty() ) { |
1189 | mEditorDialog->setAddressee( addr ); | 1189 | mEditorDialog->setAddressee( addr ); |
1190 | KApplication::execDialog ( mEditorDialog ); | 1190 | KApplication::execDialog ( mEditorDialog ); |
1191 | } | 1191 | } |
1192 | } | 1192 | } |
1193 | 1193 | ||
1194 | /** | 1194 | /** |
1195 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1195 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1196 | the method will try to find a selected addressee in the view. | 1196 | the method will try to find a selected addressee in the view. |
1197 | */ | 1197 | */ |
1198 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1198 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1199 | { | 1199 | { |
1200 | if ( mMultipleViewsAtOnce ) | 1200 | if ( mMultipleViewsAtOnce ) |
1201 | { | 1201 | { |
1202 | editContact( uid ); | 1202 | editContact( uid ); |
1203 | } | 1203 | } |
1204 | else | 1204 | else |
1205 | { | 1205 | { |
1206 | setDetailsVisible( true ); | 1206 | setDetailsVisible( true ); |
1207 | mActionDetails->setChecked(true); | 1207 | mActionDetails->setChecked(true); |
1208 | } | 1208 | } |
1209 | 1209 | ||
1210 | } | 1210 | } |
1211 | 1211 | ||
1212 | void KABCore::save() | 1212 | void KABCore::save() |
1213 | { | 1213 | { |
1214 | if (syncManager->blockSave()) | 1214 | if (syncManager->blockSave()) |
1215 | return; | 1215 | return; |
1216 | if ( !mModified ) | 1216 | if ( !mModified ) |
1217 | return; | 1217 | return; |
1218 | 1218 | ||
1219 | syncManager->setBlockSave(true); | 1219 | syncManager->setBlockSave(true); |
1220 | QString text = i18n( "There was an error while attempting to save\n the " | 1220 | QString text = i18n( "There was an error while attempting to save\n the " |
1221 | "address book. Please check that some \nother application is " | 1221 | "address book. Please check that some \nother application is " |
1222 | "not using it. " ); | 1222 | "not using it. " ); |
1223 | message(i18n("Saving addressbook ... ")); | 1223 | message(i18n("Saving addressbook ... ")); |
1224 | #ifndef KAB_EMBEDDED | 1224 | #ifndef KAB_EMBEDDED |
1225 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1225 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1226 | if ( !b || !b->save() ) { | 1226 | if ( !b || !b->save() ) { |
1227 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1227 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1228 | } | 1228 | } |
1229 | #else //KAB_EMBEDDED | 1229 | #else //KAB_EMBEDDED |
1230 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1230 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1231 | if ( !b || !b->save() ) { | 1231 | if ( !b || !b->save() ) { |
1232 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1232 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1233 | } | 1233 | } |
1234 | #endif //KAB_EMBEDDED | 1234 | #endif //KAB_EMBEDDED |
1235 | 1235 | ||
1236 | message(i18n("Addressbook saved!")); | 1236 | message(i18n("Addressbook saved!")); |
1237 | setModified( false ); | 1237 | setModified( false ); |
1238 | syncManager->setBlockSave(false); | 1238 | syncManager->setBlockSave(false); |
1239 | } | 1239 | } |
1240 | 1240 | ||
1241 | 1241 | ||
1242 | void KABCore::undo() | 1242 | void KABCore::undo() |
1243 | { | 1243 | { |
1244 | UndoStack::instance()->undo(); | 1244 | UndoStack::instance()->undo(); |
1245 | 1245 | ||
1246 | // Refresh the view | 1246 | // Refresh the view |
1247 | mViewManager->refreshView(); | 1247 | mViewManager->refreshView(); |
1248 | } | 1248 | } |
1249 | 1249 | ||
1250 | void KABCore::redo() | 1250 | void KABCore::redo() |
1251 | { | 1251 | { |
1252 | RedoStack::instance()->redo(); | 1252 | RedoStack::instance()->redo(); |
1253 | 1253 | ||
1254 | // Refresh the view | 1254 | // Refresh the view |
1255 | mViewManager->refreshView(); | 1255 | mViewManager->refreshView(); |
1256 | } | 1256 | } |
1257 | 1257 | ||
1258 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1258 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1259 | { | 1259 | { |
1260 | if (mMultipleViewsAtOnce) | 1260 | if (mMultipleViewsAtOnce) |
1261 | { | 1261 | { |
1262 | if ( visible ) | 1262 | if ( visible ) |
1263 | mJumpButtonBar->show(); | 1263 | mJumpButtonBar->show(); |
1264 | else | 1264 | else |
1265 | mJumpButtonBar->hide(); | 1265 | mJumpButtonBar->hide(); |
1266 | } | 1266 | } |
1267 | else | 1267 | else |
1268 | { | 1268 | { |
1269 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1269 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1270 | if (mViewManager->isVisible()) | 1270 | if (mViewManager->isVisible()) |
1271 | { | 1271 | { |
1272 | if ( visible ) | 1272 | if ( visible ) |
1273 | mJumpButtonBar->show(); | 1273 | mJumpButtonBar->show(); |
1274 | else | 1274 | else |
1275 | mJumpButtonBar->hide(); | 1275 | mJumpButtonBar->hide(); |
1276 | } | 1276 | } |
1277 | else | 1277 | else |
1278 | { | 1278 | { |
1279 | mJumpButtonBar->hide(); | 1279 | mJumpButtonBar->hide(); |
1280 | } | 1280 | } |
1281 | } | 1281 | } |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | 1284 | ||
1285 | void KABCore::setDetailsToState() | 1285 | void KABCore::setDetailsToState() |
1286 | { | 1286 | { |
1287 | setDetailsVisible( mActionDetails->isChecked() ); | 1287 | setDetailsVisible( mActionDetails->isChecked() ); |
1288 | } | 1288 | } |
1289 | 1289 | ||
1290 | 1290 | ||
1291 | 1291 | ||
1292 | void KABCore::setDetailsVisible( bool visible ) | 1292 | void KABCore::setDetailsVisible( bool visible ) |
1293 | { | 1293 | { |
1294 | if (visible && mDetails->isHidden()) | 1294 | if (visible && mDetails->isHidden()) |
1295 | { | 1295 | { |
1296 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1296 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1297 | if ( addrList.count() > 0 ) | 1297 | if ( addrList.count() > 0 ) |
1298 | mDetails->setAddressee( addrList[ 0 ] ); | 1298 | mDetails->setAddressee( addrList[ 0 ] ); |
1299 | } | 1299 | } |
1300 | 1300 | ||
1301 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1301 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1302 | // the listview and the detailview. We do that by changing the splitbar size. | 1302 | // the listview and the detailview. We do that by changing the splitbar size. |
1303 | if (mMultipleViewsAtOnce) | 1303 | if (mMultipleViewsAtOnce) |
1304 | { | 1304 | { |
1305 | if ( visible ) | 1305 | if ( visible ) |
1306 | mDetails->show(); | 1306 | mDetails->show(); |
1307 | else | 1307 | else |
1308 | mDetails->hide(); | 1308 | mDetails->hide(); |
1309 | } | 1309 | } |
1310 | else | 1310 | else |
1311 | { | 1311 | { |
1312 | if ( visible ) { | 1312 | if ( visible ) { |
1313 | mViewManager->hide(); | 1313 | mViewManager->hide(); |
1314 | mDetails->show(); | 1314 | mDetails->show(); |
1315 | mIncSearchWidget->setFocus(); | ||
1315 | } | 1316 | } |
1316 | else { | 1317 | else { |
1317 | mViewManager->show(); | 1318 | mViewManager->show(); |
1318 | mDetails->hide(); | 1319 | mDetails->hide(); |
1320 | mViewManager->setFocusAV(); | ||
1319 | } | 1321 | } |
1320 | setJumpButtonBarVisible( !visible ); | 1322 | setJumpButtonBarVisible( !visible ); |
1321 | } | 1323 | } |
1322 | 1324 | ||
1323 | } | 1325 | } |
1324 | 1326 | ||
1325 | void KABCore::extensionChanged( int id ) | 1327 | void KABCore::extensionChanged( int id ) |
1326 | { | 1328 | { |
1327 | //change the details view only for non desktop systems | 1329 | //change the details view only for non desktop systems |
1328 | #ifndef DESKTOP_VERSION | 1330 | #ifndef DESKTOP_VERSION |
1329 | 1331 | ||
1330 | if (id == 0) | 1332 | if (id == 0) |
1331 | { | 1333 | { |
1332 | //the user disabled the extension. | 1334 | //the user disabled the extension. |
1333 | 1335 | ||
1334 | if (mMultipleViewsAtOnce) | 1336 | if (mMultipleViewsAtOnce) |
1335 | { // enable detailsview again | 1337 | { // enable detailsview again |
1336 | setDetailsVisible( true ); | 1338 | setDetailsVisible( true ); |
1337 | mActionDetails->setChecked( true ); | 1339 | mActionDetails->setChecked( true ); |
1338 | } | 1340 | } |
1339 | else | 1341 | else |
1340 | { //go back to the listview | 1342 | { //go back to the listview |
1341 | setDetailsVisible( false ); | 1343 | setDetailsVisible( false ); |
1342 | mActionDetails->setChecked( false ); | 1344 | mActionDetails->setChecked( false ); |
1343 | mActionDetails->setEnabled(true); | 1345 | mActionDetails->setEnabled(true); |
1344 | } | 1346 | } |
1345 | 1347 | ||
1346 | } | 1348 | } |
1347 | else | 1349 | else |
1348 | { | 1350 | { |
1349 | //the user enabled the extension. | 1351 | //the user enabled the extension. |
1350 | setDetailsVisible( false ); | 1352 | setDetailsVisible( false ); |
1351 | mActionDetails->setChecked( false ); | 1353 | mActionDetails->setChecked( false ); |
1352 | 1354 | ||
1353 | if (!mMultipleViewsAtOnce) | 1355 | if (!mMultipleViewsAtOnce) |
1354 | { | 1356 | { |
1355 | mActionDetails->setEnabled(false); | 1357 | mActionDetails->setEnabled(false); |
1356 | } | 1358 | } |
1357 | 1359 | ||
1358 | mExtensionManager->setSelectionChanged(); | 1360 | mExtensionManager->setSelectionChanged(); |
1359 | 1361 | ||
1360 | } | 1362 | } |
1361 | 1363 | ||
1362 | #endif// DESKTOP_VERSION | 1364 | #endif// DESKTOP_VERSION |
1363 | 1365 | ||
1364 | } | 1366 | } |
1365 | 1367 | ||
1366 | 1368 | ||
1367 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1369 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1368 | { | 1370 | { |
1369 | 1371 | ||
1370 | if ( list.count() != 0 ) { | 1372 | if ( list.count() != 0 ) { |
1371 | KABC::Addressee::List::ConstIterator it; | 1373 | KABC::Addressee::List::ConstIterator it; |
1372 | for ( it = list.begin(); it != list.end(); ++it ) | 1374 | for ( it = list.begin(); it != list.end(); ++it ) |
1373 | mAddressBook->insertAddressee( *it ); | 1375 | mAddressBook->insertAddressee( *it ); |
1374 | if ( list.count() > 1 ) | 1376 | if ( list.count() > 1 ) |
1375 | setModified(); | 1377 | setModified(); |
1376 | else | 1378 | else |
1377 | setModifiedWOrefresh(); | 1379 | setModifiedWOrefresh(); |
1378 | } | 1380 | } |
1379 | if ( list.count() == 0 ) | 1381 | if ( list.count() == 0 ) |
1380 | mViewManager->refreshView(); | 1382 | mViewManager->refreshView(); |
1381 | else | 1383 | else |
1382 | mViewManager->refreshView( list[ 0 ].uid() ); | 1384 | mViewManager->refreshView( list[ 0 ].uid() ); |
1383 | 1385 | ||
1384 | 1386 | ||
1385 | 1387 | ||
1386 | } | 1388 | } |
1387 | 1389 | ||
1388 | QString KABCore::getNameByPhone( const QString &phone ) | 1390 | QString KABCore::getNameByPhone( const QString &phone ) |
1389 | { | 1391 | { |
1390 | #ifndef KAB_EMBEDDED | 1392 | #ifndef KAB_EMBEDDED |
1391 | QRegExp r( "[/*/-/ ]" ); | 1393 | QRegExp r( "[/*/-/ ]" ); |
1392 | QString localPhone( phone ); | 1394 | QString localPhone( phone ); |
1393 | 1395 | ||
1394 | bool found = false; | 1396 | bool found = false; |
1395 | QString ownerName = ""; | 1397 | QString ownerName = ""; |
1396 | KABC::AddressBook::Iterator iter; | 1398 | KABC::AddressBook::Iterator iter; |
1397 | KABC::PhoneNumber::List::Iterator phoneIter; | 1399 | KABC::PhoneNumber::List::Iterator phoneIter; |
1398 | KABC::PhoneNumber::List phoneList; | 1400 | KABC::PhoneNumber::List phoneList; |
1399 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1401 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1400 | phoneList = (*iter).phoneNumbers(); | 1402 | phoneList = (*iter).phoneNumbers(); |
1401 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1403 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1402 | ++phoneIter) { | 1404 | ++phoneIter) { |
1403 | // Get rid of separator chars so just the numbers are compared. | 1405 | // Get rid of separator chars so just the numbers are compared. |
1404 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1406 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1405 | ownerName = (*iter).formattedName(); | 1407 | ownerName = (*iter).formattedName(); |
1406 | found = true; | 1408 | found = true; |
1407 | } | 1409 | } |
1408 | } | 1410 | } |
1409 | } | 1411 | } |
1410 | 1412 | ||
1411 | return ownerName; | 1413 | return ownerName; |
1412 | #else //KAB_EMBEDDED | 1414 | #else //KAB_EMBEDDED |
1413 | qDebug("KABCore::getNameByPhone finsih method"); | 1415 | qDebug("KABCore::getNameByPhone finsih method"); |
1414 | return ""; | 1416 | return ""; |
1415 | #endif //KAB_EMBEDDED | 1417 | #endif //KAB_EMBEDDED |
1416 | 1418 | ||
1417 | } | 1419 | } |
1418 | 1420 | ||
1419 | void KABCore::openConfigDialog() | 1421 | void KABCore::openConfigDialog() |
1420 | { | 1422 | { |
1421 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1423 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1422 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1424 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1423 | ConfigureDialog->addModule(kabcfg ); | 1425 | ConfigureDialog->addModule(kabcfg ); |
1424 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1426 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1425 | ConfigureDialog->addModule(kdelibcfg ); | 1427 | ConfigureDialog->addModule(kdelibcfg ); |
1426 | 1428 | ||
1427 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1429 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1428 | this, SLOT( configurationChanged() ) ); | 1430 | this, SLOT( configurationChanged() ) ); |
1429 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1431 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1430 | this, SLOT( configurationChanged() ) ); | 1432 | this, SLOT( configurationChanged() ) ); |
1431 | saveSettings(); | 1433 | saveSettings(); |
1432 | #ifndef DESKTOP_VERSION | 1434 | #ifndef DESKTOP_VERSION |
1433 | ConfigureDialog->showMaximized(); | 1435 | ConfigureDialog->showMaximized(); |
1434 | #endif | 1436 | #endif |
1435 | if ( ConfigureDialog->exec() ) | 1437 | if ( ConfigureDialog->exec() ) |
1436 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1438 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1437 | delete ConfigureDialog; | 1439 | delete ConfigureDialog; |
1438 | } | 1440 | } |
1439 | 1441 | ||
1440 | void KABCore::openLDAPDialog() | 1442 | void KABCore::openLDAPDialog() |
1441 | { | 1443 | { |
1442 | #ifndef KAB_EMBEDDED | 1444 | #ifndef KAB_EMBEDDED |
1443 | if ( !mLdapSearchDialog ) { | 1445 | if ( !mLdapSearchDialog ) { |
1444 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1446 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1445 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1447 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1446 | SLOT( refreshView() ) ); | 1448 | SLOT( refreshView() ) ); |
1447 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1449 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1448 | SLOT( setModified() ) ); | 1450 | SLOT( setModified() ) ); |
1449 | } else | 1451 | } else |
1450 | mLdapSearchDialog->restoreSettings(); | 1452 | mLdapSearchDialog->restoreSettings(); |
1451 | 1453 | ||
1452 | if ( mLdapSearchDialog->isOK() ) | 1454 | if ( mLdapSearchDialog->isOK() ) |
1453 | mLdapSearchDialog->exec(); | 1455 | mLdapSearchDialog->exec(); |
1454 | #else //KAB_EMBEDDED | 1456 | #else //KAB_EMBEDDED |
1455 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1457 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1456 | #endif //KAB_EMBEDDED | 1458 | #endif //KAB_EMBEDDED |
1457 | } | 1459 | } |
1458 | 1460 | ||
1459 | void KABCore::print() | 1461 | void KABCore::print() |
1460 | { | 1462 | { |
1461 | #ifndef KAB_EMBEDDED | 1463 | #ifndef KAB_EMBEDDED |
1462 | KPrinter printer; | 1464 | KPrinter printer; |
1463 | if ( !printer.setup( this ) ) | 1465 | if ( !printer.setup( this ) ) |
1464 | return; | 1466 | return; |
1465 | 1467 | ||
1466 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1468 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1467 | mViewManager->selectedUids(), this ); | 1469 | mViewManager->selectedUids(), this ); |
1468 | 1470 | ||
1469 | wizard.exec(); | 1471 | wizard.exec(); |
1470 | #else //KAB_EMBEDDED | 1472 | #else //KAB_EMBEDDED |
1471 | qDebug("KABCore::print() finsih method"); | 1473 | qDebug("KABCore::print() finsih method"); |
1472 | #endif //KAB_EMBEDDED | 1474 | #endif //KAB_EMBEDDED |
1473 | 1475 | ||
1474 | } | 1476 | } |
1475 | 1477 | ||
1476 | 1478 | ||
1477 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1479 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1478 | { | 1480 | { |
1479 | if ( mGUIClient ) | 1481 | if ( mGUIClient ) |
1480 | mGUIClient->insertChildClient( client ); | 1482 | mGUIClient->insertChildClient( client ); |
1481 | else | 1483 | else |
1482 | KMessageBox::error( this, "no KXMLGUICLient"); | 1484 | KMessageBox::error( this, "no KXMLGUICLient"); |
1483 | } | 1485 | } |
1484 | 1486 | ||
1485 | 1487 | ||
1486 | void KABCore::configurationChanged() | 1488 | void KABCore::configurationChanged() |
1487 | { | 1489 | { |
1488 | mExtensionManager->reconfigure(); | 1490 | mExtensionManager->reconfigure(); |
1489 | } | 1491 | } |
1490 | 1492 | ||
1491 | void KABCore::addressBookChanged() | 1493 | void KABCore::addressBookChanged() |
1492 | { | 1494 | { |
1493 | /*US | 1495 | /*US |
1494 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1496 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1495 | while ( it.current() ) { | 1497 | while ( it.current() ) { |
1496 | if ( it.current()->dirty() ) { | 1498 | if ( it.current()->dirty() ) { |
1497 | QString text = i18n( "Data has been changed externally. Unsaved " | 1499 | QString text = i18n( "Data has been changed externally. Unsaved " |
1498 | "changes will be lost." ); | 1500 | "changes will be lost." ); |
1499 | KMessageBox::information( this, text ); | 1501 | KMessageBox::information( this, text ); |
1500 | } | 1502 | } |
1501 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1503 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1502 | ++it; | 1504 | ++it; |
1503 | } | 1505 | } |
1504 | */ | 1506 | */ |
1505 | if (mEditorDialog) | 1507 | if (mEditorDialog) |
1506 | { | 1508 | { |
1507 | if (mEditorDialog->dirty()) | 1509 | if (mEditorDialog->dirty()) |
1508 | { | 1510 | { |
1509 | QString text = i18n( "Data has been changed externally. Unsaved " | 1511 | QString text = i18n( "Data has been changed externally. Unsaved " |
1510 | "changes will be lost." ); | 1512 | "changes will be lost." ); |
1511 | KMessageBox::information( this, text ); | 1513 | KMessageBox::information( this, text ); |
1512 | } | 1514 | } |
1513 | QString currentuid = mEditorDialog->addressee().uid(); | 1515 | QString currentuid = mEditorDialog->addressee().uid(); |
1514 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1516 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1515 | } | 1517 | } |
1516 | mViewManager->refreshView(); | 1518 | mViewManager->refreshView(); |
1517 | // mDetails->refreshView(); | 1519 | // mDetails->refreshView(); |
1518 | 1520 | ||
1519 | 1521 | ||
1520 | } | 1522 | } |
1521 | 1523 | ||
1522 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1524 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1523 | const char *name ) | 1525 | const char *name ) |
1524 | { | 1526 | { |
1525 | 1527 | ||
1526 | if ( mEditorDialog == 0 ) { | 1528 | if ( mEditorDialog == 0 ) { |
1527 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1529 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1528 | name ? name : "editorDialog" ); | 1530 | name ? name : "editorDialog" ); |
1529 | 1531 | ||
1530 | 1532 | ||
1531 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1533 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1532 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1534 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1533 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1535 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1534 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1536 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1535 | } | 1537 | } |
1536 | 1538 | ||
1537 | return mEditorDialog; | 1539 | return mEditorDialog; |
1538 | } | 1540 | } |
1539 | 1541 | ||
1540 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1542 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1541 | { | 1543 | { |
1542 | //mEditorDict.remove( uid ); | 1544 | //mEditorDict.remove( uid ); |
1543 | } | 1545 | } |
1544 | 1546 | ||
1545 | void KABCore::initGUI() | 1547 | void KABCore::initGUI() |
1546 | { | 1548 | { |
1547 | #ifndef KAB_EMBEDDED | 1549 | #ifndef KAB_EMBEDDED |
1548 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1550 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1549 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1551 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1550 | 1552 | ||
1551 | mExtensionBarSplitter = new QSplitter( this ); | 1553 | mExtensionBarSplitter = new QSplitter( this ); |
1552 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1554 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1553 | 1555 | ||
1554 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1556 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1555 | 1557 | ||
1556 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1558 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1557 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1559 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1558 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1560 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1559 | SLOT( incrementalSearch( const QString& ) ) ); | 1561 | SLOT( incrementalSearch( const QString& ) ) ); |
1560 | 1562 | ||
1561 | mViewManager = new ViewManager( this, viewSpace ); | 1563 | mViewManager = new ViewManager( this, viewSpace ); |
1562 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1564 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1563 | 1565 | ||
1564 | mDetails = new ViewContainer( mDetailsSplitter ); | 1566 | mDetails = new ViewContainer( mDetailsSplitter ); |
1565 | 1567 | ||
1566 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1568 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1567 | 1569 | ||
1568 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1570 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1569 | 1571 | ||
1570 | topLayout->addWidget( mExtensionBarSplitter ); | 1572 | topLayout->addWidget( mExtensionBarSplitter ); |
1571 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1573 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1572 | topLayout->addWidget( mJumpButtonBar ); | 1574 | topLayout->addWidget( mJumpButtonBar ); |
1573 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1575 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1574 | 1576 | ||
1575 | mXXPortManager = new XXPortManager( this, this ); | 1577 | mXXPortManager = new XXPortManager( this, this ); |
1576 | 1578 | ||
1577 | #else //KAB_EMBEDDED | 1579 | #else //KAB_EMBEDDED |
1578 | //US initialize viewMenu before settingup viewmanager. | 1580 | //US initialize viewMenu before settingup viewmanager. |
1579 | // Viewmanager needs this menu to plugin submenues. | 1581 | // Viewmanager needs this menu to plugin submenues. |
1580 | viewMenu = new QPopupMenu( this ); | 1582 | viewMenu = new QPopupMenu( this ); |
1581 | settingsMenu = new QPopupMenu( this ); | 1583 | settingsMenu = new QPopupMenu( this ); |
1582 | //filterMenu = new QPopupMenu( this ); | 1584 | //filterMenu = new QPopupMenu( this ); |
1583 | ImportMenu = new QPopupMenu( this ); | 1585 | ImportMenu = new QPopupMenu( this ); |
1584 | ExportMenu = new QPopupMenu( this ); | 1586 | ExportMenu = new QPopupMenu( this ); |
1585 | syncMenu = new QPopupMenu( this ); | 1587 | syncMenu = new QPopupMenu( this ); |
1586 | changeMenu= new QPopupMenu( this ); | 1588 | changeMenu= new QPopupMenu( this ); |
1587 | 1589 | ||
1588 | //US since we have no splitter for the embedded system, setup | 1590 | //US since we have no splitter for the embedded system, setup |
1589 | // a layout with two frames. One left and one right. | 1591 | // a layout with two frames. One left and one right. |
1590 | 1592 | ||
1591 | QBoxLayout *topLayout; | 1593 | QBoxLayout *topLayout; |
1592 | 1594 | ||
1593 | // = new QHBoxLayout( this ); | 1595 | // = new QHBoxLayout( this ); |
1594 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1596 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1595 | 1597 | ||
1596 | // QWidget *mainBox = new QWidget( this ); | 1598 | // QWidget *mainBox = new QWidget( this ); |
1597 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1599 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1598 | 1600 | ||
1599 | #ifdef DESKTOP_VERSION | 1601 | #ifdef DESKTOP_VERSION |
1600 | topLayout = new QHBoxLayout( this ); | 1602 | topLayout = new QHBoxLayout( this ); |
1601 | 1603 | ||
1602 | 1604 | ||
1603 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1605 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1604 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1606 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1605 | 1607 | ||
1606 | topLayout->addWidget(mMiniSplitter ); | 1608 | topLayout->addWidget(mMiniSplitter ); |
1607 | 1609 | ||
1608 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1610 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1609 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1611 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1610 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1612 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1611 | mDetails = new ViewContainer( mMiniSplitter ); | 1613 | mDetails = new ViewContainer( mMiniSplitter ); |
1612 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1614 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1613 | #else | 1615 | #else |
1614 | if ( QApplication::desktop()->width() > 480 ) { | 1616 | if ( QApplication::desktop()->width() > 480 ) { |
1615 | topLayout = new QHBoxLayout( this ); | 1617 | topLayout = new QHBoxLayout( this ); |
1616 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1618 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1617 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1619 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1618 | } else { | 1620 | } else { |
1619 | 1621 | ||
1620 | topLayout = new QHBoxLayout( this ); | 1622 | topLayout = new QHBoxLayout( this ); |
1621 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1623 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1622 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1624 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1623 | } | 1625 | } |
1624 | 1626 | ||
1625 | topLayout->addWidget(mMiniSplitter ); | 1627 | topLayout->addWidget(mMiniSplitter ); |
1626 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1628 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1627 | mDetails = new ViewContainer( mMiniSplitter ); | 1629 | mDetails = new ViewContainer( mMiniSplitter ); |
1628 | 1630 | ||
1629 | 1631 | ||
1630 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1632 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1631 | #endif | 1633 | #endif |
1632 | //eh->hide(); | 1634 | //eh->hide(); |
1633 | // topLayout->addWidget(mExtensionManager ); | 1635 | // topLayout->addWidget(mExtensionManager ); |
1634 | 1636 | ||
1635 | 1637 | ||
1636 | /*US | 1638 | /*US |
1637 | #ifndef KAB_NOSPLITTER | 1639 | #ifndef KAB_NOSPLITTER |
1638 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1640 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1639 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1641 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1640 | topLayout->setSpacing( 10 ); | 1642 | topLayout->setSpacing( 10 ); |
1641 | 1643 | ||
1642 | mDetailsSplitter = new QSplitter( this ); | 1644 | mDetailsSplitter = new QSplitter( this ); |
1643 | 1645 | ||
1644 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1646 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1645 | 1647 | ||
1646 | mViewManager = new ViewManager( this, viewSpace ); | 1648 | mViewManager = new ViewManager( this, viewSpace ); |
1647 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1649 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1648 | 1650 | ||
1649 | mDetails = new ViewContainer( mDetailsSplitter ); | 1651 | mDetails = new ViewContainer( mDetailsSplitter ); |
1650 | 1652 | ||
1651 | topLayout->addWidget( mDetailsSplitter ); | 1653 | topLayout->addWidget( mDetailsSplitter ); |
1652 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1654 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1653 | #else //KAB_NOSPLITTER | 1655 | #else //KAB_NOSPLITTER |
1654 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1656 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1655 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1657 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1656 | topLayout->setSpacing( 10 ); | 1658 | topLayout->setSpacing( 10 ); |
1657 | 1659 | ||
1658 | // mDetailsSplitter = new QSplitter( this ); | 1660 | // mDetailsSplitter = new QSplitter( this ); |
1659 | 1661 | ||
1660 | QVBox *viewSpace = new QVBox( this ); | 1662 | QVBox *viewSpace = new QVBox( this ); |
1661 | 1663 | ||
1662 | mViewManager = new ViewManager( this, viewSpace ); | 1664 | mViewManager = new ViewManager( this, viewSpace ); |
1663 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1665 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1664 | 1666 | ||
1665 | mDetails = new ViewContainer( this ); | 1667 | mDetails = new ViewContainer( this ); |
1666 | 1668 | ||
1667 | topLayout->addWidget( viewSpace ); | 1669 | topLayout->addWidget( viewSpace ); |
1668 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1670 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1669 | topLayout->addWidget( mDetails ); | 1671 | topLayout->addWidget( mDetails ); |
1670 | #endif //KAB_NOSPLITTER | 1672 | #endif //KAB_NOSPLITTER |
1671 | */ | 1673 | */ |
1672 | 1674 | ||
1673 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1675 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1674 | syncManager->setBlockSave(false); | 1676 | syncManager->setBlockSave(false); |
1675 | 1677 | ||
1676 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1678 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1677 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1679 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1678 | syncManager->setDefaultFileName( sentSyncFile()); | 1680 | syncManager->setDefaultFileName( sentSyncFile()); |
1679 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1681 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1680 | 1682 | ||
1681 | #endif //KAB_EMBEDDED | 1683 | #endif //KAB_EMBEDDED |
1682 | initActions(); | 1684 | initActions(); |
1683 | 1685 | ||
1684 | #ifdef KAB_EMBEDDED | 1686 | #ifdef KAB_EMBEDDED |
1685 | addActionsManually(); | 1687 | addActionsManually(); |
1686 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1688 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1687 | mXXPortManager = new XXPortManager( this, this ); | 1689 | mXXPortManager = new XXPortManager( this, this ); |
1688 | 1690 | ||
1689 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1691 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1690 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1692 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1691 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1693 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1692 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1694 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1693 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1695 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1694 | // mIncSearchWidget->hide(); | 1696 | // mIncSearchWidget->hide(); |
1695 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1697 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1696 | SLOT( incrementalSearch( const QString& ) ) ); | 1698 | SLOT( incrementalSearch( const QString& ) ) ); |
1697 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1699 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1698 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1700 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1699 | 1701 | ||
1700 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1702 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1701 | 1703 | ||
1702 | topLayout->addWidget( mJumpButtonBar ); | 1704 | topLayout->addWidget( mJumpButtonBar ); |
1703 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1705 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1704 | 1706 | ||
1705 | // mMainWindow->getIconToolBar()->raise(); | 1707 | // mMainWindow->getIconToolBar()->raise(); |
1706 | 1708 | ||
1707 | #endif //KAB_EMBEDDED | 1709 | #endif //KAB_EMBEDDED |
1708 | 1710 | ||
1709 | } | 1711 | } |
1710 | void KABCore::initActions() | 1712 | void KABCore::initActions() |
1711 | { | 1713 | { |
1712 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1714 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1713 | 1715 | ||
1714 | #ifndef KAB_EMBEDDED | 1716 | #ifndef KAB_EMBEDDED |
1715 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1717 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1716 | SLOT( clipboardDataChanged() ) ); | 1718 | SLOT( clipboardDataChanged() ) ); |
1717 | #endif //KAB_EMBEDDED | 1719 | #endif //KAB_EMBEDDED |
1718 | 1720 | ||
1719 | // file menu | 1721 | // file menu |
1720 | if ( mIsPart ) { | 1722 | if ( mIsPart ) { |
1721 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1723 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1722 | SLOT( sendMail() ), actionCollection(), | 1724 | SLOT( sendMail() ), actionCollection(), |
1723 | "kaddressbook_mail" ); | 1725 | "kaddressbook_mail" ); |
1724 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1726 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1725 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1727 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1726 | 1728 | ||
1727 | } else { | 1729 | } else { |
1728 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1730 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1729 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1731 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1730 | } | 1732 | } |
1731 | 1733 | ||
1732 | 1734 | ||
1733 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1735 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1734 | SLOT( save() ), actionCollection(), "file_sync" ); | 1736 | SLOT( save() ), actionCollection(), "file_sync" ); |
1735 | 1737 | ||
1736 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1738 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1737 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1739 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1738 | 1740 | ||
1739 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1741 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1740 | this, SLOT( mailVCard() ), | 1742 | this, SLOT( mailVCard() ), |
1741 | actionCollection(), "file_mail_vcard"); | 1743 | actionCollection(), "file_mail_vcard"); |
1742 | 1744 | ||
1743 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, | 1745 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, |
1744 | SLOT( export2phone() ), actionCollection(), | 1746 | SLOT( export2phone() ), actionCollection(), |
1745 | "kaddressbook_ex2phone" ); | 1747 | "kaddressbook_ex2phone" ); |
1746 | 1748 | ||
1747 | mActionBeamVCard = 0; | 1749 | mActionBeamVCard = 0; |
1748 | mActionBeam = 0; | 1750 | mActionBeam = 0; |
1749 | 1751 | ||
1750 | #ifndef DESKTOP_VERSION | 1752 | #ifndef DESKTOP_VERSION |
1751 | if ( Ir::supported() ) { | 1753 | if ( Ir::supported() ) { |
1752 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1754 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1753 | SLOT( beamVCard() ), actionCollection(), | 1755 | SLOT( beamVCard() ), actionCollection(), |
1754 | "kaddressbook_beam_vcard" ); | 1756 | "kaddressbook_beam_vcard" ); |
1755 | 1757 | ||
1756 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1758 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1757 | SLOT( beamMySelf() ), actionCollection(), | 1759 | SLOT( beamMySelf() ), actionCollection(), |
1758 | "kaddressbook_beam_myself" ); | 1760 | "kaddressbook_beam_myself" ); |
1759 | } | 1761 | } |
1760 | #endif | 1762 | #endif |
1761 | 1763 | ||
1762 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1764 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1763 | this, SLOT( editContact2() ), | 1765 | this, SLOT( editContact2() ), |
1764 | actionCollection(), "file_properties" ); | 1766 | actionCollection(), "file_properties" ); |
1765 | 1767 | ||
1766 | #ifdef KAB_EMBEDDED | 1768 | #ifdef KAB_EMBEDDED |
1767 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1769 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1768 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1770 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1769 | mMainWindow, SLOT( exit() ), | 1771 | mMainWindow, SLOT( exit() ), |
1770 | actionCollection(), "quit" ); | 1772 | actionCollection(), "quit" ); |
1771 | #endif //KAB_EMBEDDED | 1773 | #endif //KAB_EMBEDDED |
1772 | 1774 | ||
1773 | // edit menu | 1775 | // edit menu |
1774 | if ( mIsPart ) { | 1776 | if ( mIsPart ) { |
1775 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1777 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1776 | SLOT( copyContacts() ), actionCollection(), | 1778 | SLOT( copyContacts() ), actionCollection(), |
1777 | "kaddressbook_copy" ); | 1779 | "kaddressbook_copy" ); |
1778 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1780 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1779 | SLOT( cutContacts() ), actionCollection(), | 1781 | SLOT( cutContacts() ), actionCollection(), |
1780 | "kaddressbook_cut" ); | 1782 | "kaddressbook_cut" ); |
1781 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1783 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1782 | SLOT( pasteContacts() ), actionCollection(), | 1784 | SLOT( pasteContacts() ), actionCollection(), |
1783 | "kaddressbook_paste" ); | 1785 | "kaddressbook_paste" ); |
1784 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1786 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1785 | SLOT( selectAllContacts() ), actionCollection(), | 1787 | SLOT( selectAllContacts() ), actionCollection(), |
1786 | "kaddressbook_select_all" ); | 1788 | "kaddressbook_select_all" ); |
1787 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1789 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1788 | SLOT( undo() ), actionCollection(), | 1790 | SLOT( undo() ), actionCollection(), |
1789 | "kaddressbook_undo" ); | 1791 | "kaddressbook_undo" ); |
1790 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1792 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1791 | this, SLOT( redo() ), actionCollection(), | 1793 | this, SLOT( redo() ), actionCollection(), |
1792 | "kaddressbook_redo" ); | 1794 | "kaddressbook_redo" ); |
1793 | } else { | 1795 | } else { |
1794 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1796 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1795 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1797 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1796 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1798 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1797 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1799 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1798 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1800 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1799 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1801 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1800 | } | 1802 | } |
1801 | 1803 | ||
1802 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1804 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1803 | Key_Delete, this, SLOT( deleteContacts() ), | 1805 | Key_Delete, this, SLOT( deleteContacts() ), |
1804 | actionCollection(), "edit_delete" ); | 1806 | actionCollection(), "edit_delete" ); |
1805 | 1807 | ||
1806 | mActionUndo->setEnabled( false ); | 1808 | mActionUndo->setEnabled( false ); |
1807 | mActionRedo->setEnabled( false ); | 1809 | mActionRedo->setEnabled( false ); |
1808 | 1810 | ||
1809 | // settings menu | 1811 | // settings menu |
1810 | #ifdef KAB_EMBEDDED | 1812 | #ifdef KAB_EMBEDDED |
1811 | //US special menuentry to configure the addressbook resources. On KDE | 1813 | //US special menuentry to configure the addressbook resources. On KDE |
1812 | // you do that through the control center !!! | 1814 | // you do that through the control center !!! |
1813 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1815 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1814 | SLOT( configureResources() ), actionCollection(), | 1816 | SLOT( configureResources() ), actionCollection(), |
1815 | "kaddressbook_configure_resources" ); | 1817 | "kaddressbook_configure_resources" ); |
1816 | #endif //KAB_EMBEDDED | 1818 | #endif //KAB_EMBEDDED |
1817 | 1819 | ||
1818 | if ( mIsPart ) { | 1820 | if ( mIsPart ) { |
1819 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1821 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1820 | SLOT( openConfigDialog() ), actionCollection(), | 1822 | SLOT( openConfigDialog() ), actionCollection(), |
1821 | "kaddressbook_configure" ); | 1823 | "kaddressbook_configure" ); |
1822 | 1824 | ||
1823 | //US not implemented yet | 1825 | //US not implemented yet |
1824 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1826 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1825 | // this, SLOT( configureKeyBindings() ), actionCollection(), | 1827 | // this, SLOT( configureKeyBindings() ), actionCollection(), |
1826 | // "kaddressbook_configure_shortcuts" ); | 1828 | // "kaddressbook_configure_shortcuts" ); |
1827 | #ifdef KAB_EMBEDDED | 1829 | #ifdef KAB_EMBEDDED |
1828 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1830 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1829 | mActionConfigureToolbars->setEnabled( false ); | 1831 | mActionConfigureToolbars->setEnabled( false ); |
1830 | #endif //KAB_EMBEDDED | 1832 | #endif //KAB_EMBEDDED |
1831 | 1833 | ||
1832 | } else { | 1834 | } else { |
1833 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1835 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1834 | 1836 | ||
1835 | //US not implemented yet | 1837 | //US not implemented yet |
1836 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1838 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1837 | } | 1839 | } |
1838 | 1840 | ||
1839 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1841 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1840 | actionCollection(), "options_show_jump_bar" ); | 1842 | actionCollection(), "options_show_jump_bar" ); |
1841 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1843 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1842 | 1844 | ||
1843 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1845 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1844 | actionCollection(), "options_show_details" ); | 1846 | actionCollection(), "options_show_details" ); |
1845 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1847 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1846 | 1848 | ||
1847 | 1849 | ||
1848 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, | 1850 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
1849 | SLOT( toggleBeamReceive() ), actionCollection(), | 1851 | SLOT( toggleBeamReceive() ), actionCollection(), |
1850 | "kaddressbook_beam_rec" ); | 1852 | "kaddressbook_beam_rec" ); |
1851 | 1853 | ||
1852 | 1854 | ||
1853 | // misc | 1855 | // misc |
1854 | // only enable LDAP lookup if we can handle the protocol | 1856 | // only enable LDAP lookup if we can handle the protocol |
1855 | #ifndef KAB_EMBEDDED | 1857 | #ifndef KAB_EMBEDDED |
1856 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1858 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1857 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1859 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1858 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1860 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1859 | "ldap_lookup" ); | 1861 | "ldap_lookup" ); |
1860 | } | 1862 | } |
1861 | #else //KAB_EMBEDDED | 1863 | #else //KAB_EMBEDDED |
1862 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1864 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1863 | #endif //KAB_EMBEDDED | 1865 | #endif //KAB_EMBEDDED |
1864 | 1866 | ||
1865 | 1867 | ||
1866 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1868 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1867 | SLOT( setWhoAmI() ), actionCollection(), | 1869 | SLOT( setWhoAmI() ), actionCollection(), |
1868 | "set_personal" ); | 1870 | "set_personal" ); |
1869 | 1871 | ||
1870 | 1872 | ||
1871 | 1873 | ||
1872 | 1874 | ||
1873 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1875 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1874 | SLOT( setCategories() ), actionCollection(), | 1876 | SLOT( setCategories() ), actionCollection(), |
1875 | "edit_set_categories" ); | 1877 | "edit_set_categories" ); |
1876 | 1878 | ||
1877 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1879 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1878 | SLOT( removeVoice() ), actionCollection(), | 1880 | SLOT( removeVoice() ), actionCollection(), |
1879 | "remove_voice" ); | 1881 | "remove_voice" ); |
1880 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1882 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1881 | SLOT( importFromOL() ), actionCollection(), | 1883 | SLOT( importFromOL() ), actionCollection(), |
1882 | "import_OL" ); | 1884 | "import_OL" ); |
1883 | #ifdef KAB_EMBEDDED | 1885 | #ifdef KAB_EMBEDDED |
1884 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1886 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1885 | this, SLOT( showLicence() ), actionCollection(), | 1887 | this, SLOT( showLicence() ), actionCollection(), |
1886 | "licence_about_data" ); | 1888 | "licence_about_data" ); |
1887 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1889 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1888 | this, SLOT( faq() ), actionCollection(), | 1890 | this, SLOT( faq() ), actionCollection(), |
1889 | "faq_about_data" ); | 1891 | "faq_about_data" ); |
1890 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 1892 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
1891 | this, SLOT( whatsnew() ), actionCollection(), | 1893 | this, SLOT( whatsnew() ), actionCollection(), |
1892 | "wn" ); | 1894 | "wn" ); |
1893 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 1895 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
1894 | this, SLOT( synchowto() ), actionCollection(), | 1896 | this, SLOT( synchowto() ), actionCollection(), |
1895 | "sync" ); | 1897 | "sync" ); |
1896 | 1898 | ||
1897 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1899 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1898 | this, SLOT( createAboutData() ), actionCollection(), | 1900 | this, SLOT( createAboutData() ), actionCollection(), |
1899 | "kaddressbook_about_data" ); | 1901 | "kaddressbook_about_data" ); |
1900 | #endif //KAB_EMBEDDED | 1902 | #endif //KAB_EMBEDDED |
1901 | 1903 | ||
1902 | clipboardDataChanged(); | 1904 | clipboardDataChanged(); |
1903 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1905 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1904 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1906 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1905 | } | 1907 | } |
1906 | 1908 | ||
1907 | //US we need this function, to plug all actions into the correct menues. | 1909 | //US we need this function, to plug all actions into the correct menues. |
1908 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1910 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1909 | void KABCore::addActionsManually() | 1911 | void KABCore::addActionsManually() |
1910 | { | 1912 | { |
1911 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1913 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1912 | 1914 | ||
1913 | #ifdef KAB_EMBEDDED | 1915 | #ifdef KAB_EMBEDDED |
1914 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1916 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1915 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1917 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1916 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1918 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1917 | 1919 | ||
1918 | KToolBar* tb = mMainWindow->toolBar(); | 1920 | KToolBar* tb = mMainWindow->toolBar(); |
1919 | 1921 | ||
1920 | #ifdef DESKTOP_VERSION | 1922 | #ifdef DESKTOP_VERSION |
1921 | QMenuBar* mb = mMainWindow->menuBar(); | 1923 | QMenuBar* mb = mMainWindow->menuBar(); |
1922 | 1924 | ||
1923 | //US setup menubar. | 1925 | //US setup menubar. |
1924 | //Disable the following block if you do not want to have a menubar. | 1926 | //Disable the following block if you do not want to have a menubar. |
1925 | mb->insertItem( "&File", fileMenu ); | 1927 | mb->insertItem( "&File", fileMenu ); |
1926 | mb->insertItem( "&Edit", editMenu ); | 1928 | mb->insertItem( "&Edit", editMenu ); |
1927 | mb->insertItem( "&View", viewMenu ); | 1929 | mb->insertItem( "&View", viewMenu ); |
1928 | mb->insertItem( "&Settings", settingsMenu ); | 1930 | mb->insertItem( "&Settings", settingsMenu ); |
1929 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1931 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1930 | mb->insertItem( "&Change selected", changeMenu ); | 1932 | mb->insertItem( "&Change selected", changeMenu ); |
1931 | mb->insertItem( "&Help", helpMenu ); | 1933 | mb->insertItem( "&Help", helpMenu ); |
1932 | mIncSearchWidget = new IncSearchWidget( tb ); | 1934 | mIncSearchWidget = new IncSearchWidget( tb ); |
1933 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1935 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1934 | 1936 | ||
1935 | #else | 1937 | #else |
1936 | //US setup toolbar | 1938 | //US setup toolbar |
1937 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1939 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1938 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1940 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1939 | menuBarTB->insertItem( "ME", popupBarTB); | 1941 | menuBarTB->insertItem( "ME", popupBarTB); |
1940 | tb->insertWidget(-1, 0, menuBarTB); | 1942 | tb->insertWidget(-1, 0, menuBarTB); |
1941 | mIncSearchWidget = new IncSearchWidget( tb ); | 1943 | mIncSearchWidget = new IncSearchWidget( tb ); |
1942 | 1944 | ||
1943 | tb->enableMoving(false); | 1945 | tb->enableMoving(false); |
1944 | popupBarTB->insertItem( "&File", fileMenu ); | 1946 | popupBarTB->insertItem( "&File", fileMenu ); |
1945 | popupBarTB->insertItem( "&Edit", editMenu ); | 1947 | popupBarTB->insertItem( "&Edit", editMenu ); |
1946 | popupBarTB->insertItem( "&View", viewMenu ); | 1948 | popupBarTB->insertItem( "&View", viewMenu ); |
1947 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1949 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1948 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1950 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1949 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1951 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1950 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1952 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1951 | popupBarTB->insertItem( "&Help", helpMenu ); | 1953 | popupBarTB->insertItem( "&Help", helpMenu ); |
1952 | if (QApplication::desktop()->width() > 320 ) { | 1954 | if (QApplication::desktop()->width() > 320 ) { |
1953 | // mViewManager->getFilterAction()->plug ( tb); | 1955 | // mViewManager->getFilterAction()->plug ( tb); |
1954 | } | 1956 | } |
1955 | #endif | 1957 | #endif |
1956 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1958 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1957 | 1959 | ||
1958 | 1960 | ||
1959 | 1961 | ||
1960 | //US Now connect the actions with the menue entries. | 1962 | //US Now connect the actions with the menue entries. |
1961 | mActionPrint->plug( fileMenu ); | 1963 | mActionPrint->plug( fileMenu ); |
1962 | mActionMail->plug( fileMenu ); | 1964 | mActionMail->plug( fileMenu ); |
1963 | fileMenu->insertSeparator(); | 1965 | fileMenu->insertSeparator(); |
1964 | 1966 | ||
1965 | mActionNewContact->plug( fileMenu ); | 1967 | mActionNewContact->plug( fileMenu ); |
1966 | mActionNewContact->plug( tb ); | 1968 | mActionNewContact->plug( tb ); |
1967 | 1969 | ||
1968 | mActionEditAddressee->plug( fileMenu ); | 1970 | mActionEditAddressee->plug( fileMenu ); |
1969 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1971 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1970 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1972 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1971 | mActionEditAddressee->plug( tb ); | 1973 | mActionEditAddressee->plug( tb ); |
1972 | 1974 | ||
1973 | fileMenu->insertSeparator(); | 1975 | fileMenu->insertSeparator(); |
1974 | mActionSave->plug( fileMenu ); | 1976 | mActionSave->plug( fileMenu ); |
1975 | fileMenu->insertItem( "&Import", ImportMenu ); | 1977 | fileMenu->insertItem( "&Import", ImportMenu ); |
1976 | fileMenu->insertItem( "&Export", ExportMenu ); | 1978 | fileMenu->insertItem( "&Export", ExportMenu ); |
1977 | fileMenu->insertSeparator(); | 1979 | fileMenu->insertSeparator(); |
1978 | mActionMailVCard->plug( fileMenu ); | 1980 | mActionMailVCard->plug( fileMenu ); |
1979 | #ifndef DESKTOP_VERSION | 1981 | #ifndef DESKTOP_VERSION |
1980 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1982 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1981 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1983 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1982 | #endif | 1984 | #endif |
1983 | fileMenu->insertSeparator(); | 1985 | fileMenu->insertSeparator(); |
1984 | mActionQuit->plug( fileMenu ); | 1986 | mActionQuit->plug( fileMenu ); |
1985 | #ifdef _WIN32_ | 1987 | #ifdef _WIN32_ |
1986 | mActionImportOL->plug( ImportMenu ); | 1988 | mActionImportOL->plug( ImportMenu ); |
1987 | #endif | 1989 | #endif |
1988 | // edit menu | 1990 | // edit menu |
1989 | mActionUndo->plug( editMenu ); | 1991 | mActionUndo->plug( editMenu ); |
1990 | mActionRedo->plug( editMenu ); | 1992 | mActionRedo->plug( editMenu ); |
1991 | editMenu->insertSeparator(); | 1993 | editMenu->insertSeparator(); |
1992 | mActionCut->plug( editMenu ); | 1994 | mActionCut->plug( editMenu ); |
1993 | mActionCopy->plug( editMenu ); | 1995 | mActionCopy->plug( editMenu ); |
1994 | mActionPaste->plug( editMenu ); | 1996 | mActionPaste->plug( editMenu ); |
1995 | mActionDelete->plug( editMenu ); | 1997 | mActionDelete->plug( editMenu ); |
1996 | editMenu->insertSeparator(); | 1998 | editMenu->insertSeparator(); |
1997 | mActionSelectAll->plug( editMenu ); | 1999 | mActionSelectAll->plug( editMenu ); |
1998 | 2000 | ||
1999 | mActionRemoveVoice->plug( changeMenu ); | 2001 | mActionRemoveVoice->plug( changeMenu ); |
2000 | // settings menu | 2002 | // settings menu |
2001 | //US special menuentry to configure the addressbook resources. On KDE | 2003 | //US special menuentry to configure the addressbook resources. On KDE |
2002 | // you do that through the control center !!! | 2004 | // you do that through the control center !!! |
2003 | mActionConfigResources->plug( settingsMenu ); | 2005 | mActionConfigResources->plug( settingsMenu ); |
2004 | settingsMenu->insertSeparator(); | 2006 | settingsMenu->insertSeparator(); |
2005 | 2007 | ||
2006 | mActionConfigKAddressbook->plug( settingsMenu ); | 2008 | mActionConfigKAddressbook->plug( settingsMenu ); |
2007 | 2009 | ||
2008 | if ( mIsPart ) { | 2010 | if ( mIsPart ) { |
2009 | //US not implemented yet | 2011 | //US not implemented yet |
2010 | //mActionConfigShortcuts->plug( settingsMenu ); | 2012 | //mActionConfigShortcuts->plug( settingsMenu ); |
2011 | //mActionConfigureToolbars->plug( settingsMenu ); | 2013 | //mActionConfigureToolbars->plug( settingsMenu ); |
2012 | 2014 | ||
2013 | } else { | 2015 | } else { |
2014 | //US not implemented yet | 2016 | //US not implemented yet |
2015 | //mActionKeyBindings->plug( settingsMenu ); | 2017 | //mActionKeyBindings->plug( settingsMenu ); |
2016 | } | 2018 | } |
2017 | 2019 | ||
2018 | settingsMenu->insertSeparator(); | 2020 | settingsMenu->insertSeparator(); |
2019 | 2021 | ||
2020 | mActionJumpBar->plug( settingsMenu ); | 2022 | mActionJumpBar->plug( settingsMenu ); |
2021 | mActionDetails->plug( settingsMenu ); | 2023 | mActionDetails->plug( settingsMenu ); |
2022 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2024 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2023 | mActionDetails->plug( tb ); | 2025 | mActionDetails->plug( tb ); |
2024 | settingsMenu->insertSeparator(); | 2026 | settingsMenu->insertSeparator(); |
2025 | mActionBR->plug(settingsMenu ); | 2027 | mActionBR->plug(settingsMenu ); |
2026 | settingsMenu->insertSeparator(); | 2028 | settingsMenu->insertSeparator(); |
2027 | 2029 | ||
2028 | mActionWhoAmI->plug( settingsMenu ); | 2030 | mActionWhoAmI->plug( settingsMenu ); |
2029 | mActionCategories->plug( settingsMenu ); | 2031 | mActionCategories->plug( settingsMenu ); |
2030 | 2032 | ||
2031 | 2033 | ||
2032 | mActionWN->plug( helpMenu ); | 2034 | mActionWN->plug( helpMenu ); |
2033 | mActionSyncHowto->plug( helpMenu ); | 2035 | mActionSyncHowto->plug( helpMenu ); |
2034 | mActionLicence->plug( helpMenu ); | 2036 | mActionLicence->plug( helpMenu ); |
2035 | mActionFaq->plug( helpMenu ); | 2037 | mActionFaq->plug( helpMenu ); |
2036 | mActionAboutKAddressbook->plug( helpMenu ); | 2038 | mActionAboutKAddressbook->plug( helpMenu ); |
2037 | 2039 | ||
2038 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2040 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2039 | 2041 | ||
2040 | mActionSave->plug( tb ); | 2042 | mActionSave->plug( tb ); |
2041 | mViewManager->getFilterAction()->plug ( tb); | 2043 | mViewManager->getFilterAction()->plug ( tb); |
2042 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2044 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2043 | mActionUndo->plug( tb ); | 2045 | mActionUndo->plug( tb ); |
2044 | mActionDelete->plug( tb ); | 2046 | mActionDelete->plug( tb ); |
2045 | mActionRedo->plug( tb ); | 2047 | mActionRedo->plug( tb ); |
2046 | } | 2048 | } |
2049 | } else { | ||
2050 | if (KABPrefs::instance()->mMultipleViewsAtOnce ) | ||
2051 | mActionSave->plug( tb ); | ||
2047 | } | 2052 | } |
2048 | //mActionQuit->plug ( tb ); | 2053 | //mActionQuit->plug ( tb ); |
2049 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2054 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2050 | 2055 | ||
2051 | //US link the searchwidget first to this. | 2056 | //US link the searchwidget first to this. |
2052 | // The real linkage to the toolbar happens later. | 2057 | // The real linkage to the toolbar happens later. |
2053 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2058 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2054 | //US tb->insertItem( mIncSearchWidget ); | 2059 | //US tb->insertItem( mIncSearchWidget ); |
2055 | /*US | 2060 | /*US |
2056 | mIncSearchWidget = new IncSearchWidget( tb ); | 2061 | mIncSearchWidget = new IncSearchWidget( tb ); |
2057 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2062 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2058 | SLOT( incrementalSearch( const QString& ) ) ); | 2063 | SLOT( incrementalSearch( const QString& ) ) ); |
2059 | 2064 | ||
2060 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2065 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2061 | 2066 | ||
2062 | //US topLayout->addWidget( mJumpButtonBar ); | 2067 | //US topLayout->addWidget( mJumpButtonBar ); |
2063 | this->layout()->add( mJumpButtonBar ); | 2068 | this->layout()->add( mJumpButtonBar ); |
2064 | */ | 2069 | */ |
2065 | 2070 | ||
2066 | #endif //KAB_EMBEDDED | 2071 | #endif //KAB_EMBEDDED |
2067 | 2072 | ||
2068 | mActionExport2phone->plug( ExportMenu ); | 2073 | mActionExport2phone->plug( ExportMenu ); |
2069 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2074 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2070 | syncManager->fillSyncMenu(); | 2075 | syncManager->fillSyncMenu(); |
2071 | 2076 | ||
2072 | } | 2077 | } |
2073 | void KABCore::showLicence() | 2078 | void KABCore::showLicence() |
2074 | { | 2079 | { |
2075 | KApplication::showLicence(); | 2080 | KApplication::showLicence(); |
2076 | } | 2081 | } |
2077 | void KABCore::removeVoice() | 2082 | void KABCore::removeVoice() |
2078 | { | 2083 | { |
2079 | 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 ) | 2084 | 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 ) |
2080 | return; | 2085 | return; |
2081 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2086 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2082 | KABC::Addressee::List::Iterator it; | 2087 | KABC::Addressee::List::Iterator it; |
2083 | for ( it = list.begin(); it != list.end(); ++it ) { | 2088 | for ( it = list.begin(); it != list.end(); ++it ) { |
2084 | 2089 | ||
2085 | if ( (*it).removeVoice() ) | 2090 | if ( (*it).removeVoice() ) |
2086 | contactModified((*it) ); | 2091 | contactModified((*it) ); |
2087 | } | 2092 | } |
2088 | } | 2093 | } |
2089 | 2094 | ||
2090 | 2095 | ||
2091 | 2096 | ||
2092 | void KABCore::clipboardDataChanged() | 2097 | void KABCore::clipboardDataChanged() |
2093 | { | 2098 | { |
2094 | 2099 | ||
2095 | if ( mReadWrite ) | 2100 | if ( mReadWrite ) |
2096 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2101 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2097 | 2102 | ||
2098 | } | 2103 | } |
2099 | 2104 | ||
2100 | void KABCore::updateActionMenu() | 2105 | void KABCore::updateActionMenu() |
2101 | { | 2106 | { |
2102 | UndoStack *undo = UndoStack::instance(); | 2107 | UndoStack *undo = UndoStack::instance(); |
2103 | RedoStack *redo = RedoStack::instance(); | 2108 | RedoStack *redo = RedoStack::instance(); |
2104 | 2109 | ||
2105 | if ( undo->isEmpty() ) | 2110 | if ( undo->isEmpty() ) |
2106 | mActionUndo->setText( i18n( "Undo" ) ); | 2111 | mActionUndo->setText( i18n( "Undo" ) ); |
2107 | else | 2112 | else |
2108 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2113 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2109 | 2114 | ||
2110 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2115 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2111 | 2116 | ||
2112 | if ( !redo->top() ) | 2117 | if ( !redo->top() ) |
2113 | mActionRedo->setText( i18n( "Redo" ) ); | 2118 | mActionRedo->setText( i18n( "Redo" ) ); |
2114 | else | 2119 | else |
2115 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2120 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2116 | 2121 | ||
2117 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2122 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2118 | } | 2123 | } |
2119 | 2124 | ||
2120 | void KABCore::configureKeyBindings() | 2125 | void KABCore::configureKeyBindings() |
2121 | { | 2126 | { |
2122 | #ifndef KAB_EMBEDDED | 2127 | #ifndef KAB_EMBEDDED |
2123 | KKeyDialog::configure( actionCollection(), true ); | 2128 | KKeyDialog::configure( actionCollection(), true ); |
2124 | #else //KAB_EMBEDDED | 2129 | #else //KAB_EMBEDDED |
2125 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2130 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2126 | #endif //KAB_EMBEDDED | 2131 | #endif //KAB_EMBEDDED |
2127 | } | 2132 | } |
2128 | 2133 | ||
2129 | #ifdef KAB_EMBEDDED | 2134 | #ifdef KAB_EMBEDDED |
2130 | void KABCore::configureResources() | 2135 | void KABCore::configureResources() |
2131 | { | 2136 | { |
2132 | KRES::KCMKResources dlg( this, "" , 0 ); | 2137 | KRES::KCMKResources dlg( this, "" , 0 ); |
2133 | 2138 | ||
2134 | if ( !dlg.exec() ) | 2139 | if ( !dlg.exec() ) |
2135 | return; | 2140 | return; |
2136 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2141 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2137 | } | 2142 | } |
2138 | #endif //KAB_EMBEDDED | 2143 | #endif //KAB_EMBEDDED |
2139 | 2144 | ||
2140 | 2145 | ||
2141 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2146 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2142 | * for the attendees list of an event. | 2147 | * for the attendees list of an event. |
2143 | */ | 2148 | */ |
2144 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2149 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2145 | { | 2150 | { |
2146 | QStringList nameList; | 2151 | QStringList nameList; |
2147 | QStringList emailList; | 2152 | QStringList emailList; |
2148 | QStringList uidList; | 2153 | QStringList uidList; |
2149 | 2154 | ||
2150 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2155 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2151 | uint i=0; | 2156 | uint i=0; |
2152 | for (i=0; i < list.count(); i++) | 2157 | for (i=0; i < list.count(); i++) |
2153 | { | 2158 | { |
2154 | nameList.append(list[i].realName()); | 2159 | nameList.append(list[i].realName()); |
2155 | emailList.append(list[i].preferredEmail()); | 2160 | emailList.append(list[i].preferredEmail()); |
2156 | uidList.append(list[i].uid()); | 2161 | uidList.append(list[i].uid()); |
2157 | } | 2162 | } |
2158 | 2163 | ||
2159 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2164 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2160 | 2165 | ||
2161 | } | 2166 | } |
2162 | 2167 | ||
2163 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2168 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2164 | * to put them into the calendar. | 2169 | * to put them into the calendar. |
2165 | */ | 2170 | */ |
2166 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2171 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2167 | { | 2172 | { |
2168 | // qDebug("KABCore::requestForBirthdayList"); | 2173 | // qDebug("KABCore::requestForBirthdayList"); |
2169 | QStringList birthdayList; | 2174 | QStringList birthdayList; |
2170 | QStringList anniversaryList; | 2175 | QStringList anniversaryList; |
2171 | QStringList realNameList; | 2176 | QStringList realNameList; |
2172 | QStringList preferredEmailList; | 2177 | QStringList preferredEmailList; |
2173 | QStringList assembledNameList; | 2178 | QStringList assembledNameList; |
2174 | QStringList uidList; | 2179 | QStringList uidList; |
2175 | 2180 | ||
2176 | KABC::AddressBook::Iterator it; | 2181 | KABC::AddressBook::Iterator it; |
2177 | 2182 | ||
2178 | int count = 0; | 2183 | int count = 0; |
2179 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2184 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2180 | ++count; | 2185 | ++count; |
2181 | } | 2186 | } |
2182 | QProgressBar bar(count,0 ); | 2187 | QProgressBar bar(count,0 ); |
2183 | int w = 300; | 2188 | int w = 300; |
2184 | if ( QApplication::desktop()->width() < 320 ) | 2189 | if ( QApplication::desktop()->width() < 320 ) |
2185 | w = 220; | 2190 | w = 220; |
2186 | int h = bar.sizeHint().height() ; | 2191 | int h = bar.sizeHint().height() ; |
2187 | int dw = QApplication::desktop()->width(); | 2192 | int dw = QApplication::desktop()->width(); |
2188 | int dh = QApplication::desktop()->height(); | 2193 | int dh = QApplication::desktop()->height(); |
2189 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2194 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2190 | bar.show(); | 2195 | bar.show(); |
2191 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2196 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2192 | qApp->processEvents(); | 2197 | qApp->processEvents(); |
2193 | 2198 | ||
2194 | QDate bday; | 2199 | QDate bday; |
2195 | QString anni; | 2200 | QString anni; |
2196 | QString formattedbday; | 2201 | QString formattedbday; |
2197 | 2202 | ||
2198 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2203 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2199 | { | 2204 | { |
2200 | if ( ! bar.isVisible() ) | 2205 | if ( ! bar.isVisible() ) |
2201 | return; | 2206 | return; |
2202 | bar.setProgress( count++ ); | 2207 | bar.setProgress( count++ ); |
2203 | qApp->processEvents(); | 2208 | qApp->processEvents(); |
2204 | bday = (*it).birthday().date(); | 2209 | bday = (*it).birthday().date(); |
2205 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2210 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2206 | 2211 | ||
2207 | if ( bday.isValid() || !anni.isEmpty()) | 2212 | if ( bday.isValid() || !anni.isEmpty()) |
2208 | { | 2213 | { |
2209 | if (bday.isValid()) | 2214 | if (bday.isValid()) |
2210 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2215 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2211 | else | 2216 | else |
2212 | formattedbday = "NOTVALID"; | 2217 | formattedbday = "NOTVALID"; |
2213 | if (anni.isEmpty()) | 2218 | if (anni.isEmpty()) |
2214 | anni = "INVALID"; | 2219 | anni = "INVALID"; |
2215 | 2220 | ||
2216 | birthdayList.append(formattedbday); | 2221 | birthdayList.append(formattedbday); |
2217 | anniversaryList.append(anni); //should be ISODate | 2222 | anniversaryList.append(anni); //should be ISODate |
2218 | realNameList.append((*it).realName()); | 2223 | realNameList.append((*it).realName()); |
2219 | preferredEmailList.append((*it).preferredEmail()); | 2224 | preferredEmailList.append((*it).preferredEmail()); |
2220 | assembledNameList.append((*it).assembledName()); | 2225 | assembledNameList.append((*it).assembledName()); |
2221 | uidList.append((*it).uid()); | 2226 | uidList.append((*it).uid()); |
2222 | 2227 | ||
2223 | qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2228 | qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2224 | } | 2229 | } |
2225 | } | 2230 | } |
2226 | 2231 | ||
2227 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2232 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2228 | 2233 | ||
2229 | } | 2234 | } |
2230 | 2235 | ||
2231 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2236 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2232 | */ | 2237 | */ |
2233 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2238 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2234 | { | 2239 | { |
2235 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2240 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2236 | 2241 | ||
2237 | QString foundUid = QString::null; | 2242 | QString foundUid = QString::null; |
2238 | if ( ! uid.isEmpty() ) { | 2243 | if ( ! uid.isEmpty() ) { |
2239 | Addressee adrr = mAddressBook->findByUid( uid ); | 2244 | Addressee adrr = mAddressBook->findByUid( uid ); |
2240 | if ( !adrr.isEmpty() ) { | 2245 | if ( !adrr.isEmpty() ) { |
2241 | foundUid = uid; | 2246 | foundUid = uid; |
2242 | } | 2247 | } |
2243 | if ( email == "sendbacklist" ) { | 2248 | if ( email == "sendbacklist" ) { |
2244 | //qDebug("ssssssssssssssssssssssend "); | 2249 | //qDebug("ssssssssssssssssssssssend "); |
2245 | QStringList nameList; | 2250 | QStringList nameList; |
2246 | QStringList emailList; | 2251 | QStringList emailList; |
2247 | QStringList uidList; | 2252 | QStringList uidList; |
2248 | nameList.append(adrr.realName()); | 2253 | nameList.append(adrr.realName()); |
2249 | emailList = adrr.emails(); | 2254 | emailList = adrr.emails(); |
2250 | uidList.append( adrr.preferredEmail()); | 2255 | uidList.append( adrr.preferredEmail()); |
2251 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2256 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2252 | return; | 2257 | return; |
2253 | } | 2258 | } |
2254 | 2259 | ||
2255 | } | 2260 | } |
2256 | 2261 | ||
2257 | if ( email == "sendbacklist" ) | 2262 | if ( email == "sendbacklist" ) |
2258 | return; | 2263 | return; |
2259 | if (foundUid.isEmpty()) | 2264 | if (foundUid.isEmpty()) |
2260 | { | 2265 | { |
2261 | //find the uid of the person first | 2266 | //find the uid of the person first |
2262 | Addressee::List namelist; | 2267 | Addressee::List namelist; |
2263 | Addressee::List emaillist; | 2268 | Addressee::List emaillist; |
2264 | 2269 | ||
2265 | if (!name.isEmpty()) | 2270 | if (!name.isEmpty()) |
2266 | namelist = mAddressBook->findByName( name ); | 2271 | namelist = mAddressBook->findByName( name ); |
2267 | 2272 | ||
2268 | if (!email.isEmpty()) | 2273 | if (!email.isEmpty()) |
2269 | emaillist = mAddressBook->findByEmail( email ); | 2274 | emaillist = mAddressBook->findByEmail( email ); |
2270 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2275 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2271 | //check if we have a match in Namelist and Emaillist | 2276 | //check if we have a match in Namelist and Emaillist |
2272 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2277 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2273 | foundUid = emaillist[0].uid(); | 2278 | foundUid = emaillist[0].uid(); |
2274 | } | 2279 | } |
2275 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2280 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2276 | foundUid = namelist[0].uid(); | 2281 | foundUid = namelist[0].uid(); |
2277 | else | 2282 | else |
2278 | { | 2283 | { |
2279 | for (int i = 0; i < namelist.count(); i++) | 2284 | for (int i = 0; i < namelist.count(); i++) |
2280 | { | 2285 | { |
2281 | for (int j = 0; j < emaillist.count(); j++) | 2286 | for (int j = 0; j < emaillist.count(); j++) |
2282 | { | 2287 | { |
2283 | if (namelist[i] == emaillist[j]) | 2288 | if (namelist[i] == emaillist[j]) |
2284 | { | 2289 | { |
2285 | foundUid = namelist[i].uid(); | 2290 | foundUid = namelist[i].uid(); |
2286 | } | 2291 | } |
2287 | } | 2292 | } |
2288 | } | 2293 | } |
2289 | } | 2294 | } |
2290 | } | 2295 | } |
2291 | else | 2296 | else |
2292 | { | 2297 | { |
2293 | foundUid = uid; | 2298 | foundUid = uid; |
2294 | } | 2299 | } |
2295 | 2300 | ||
2296 | if (!foundUid.isEmpty()) | 2301 | if (!foundUid.isEmpty()) |
2297 | { | 2302 | { |
2298 | 2303 | ||
2299 | // raise Ka/Pi if it is in the background | 2304 | // raise Ka/Pi if it is in the background |
2300 | #ifndef DESKTOP_VERSION | 2305 | #ifndef DESKTOP_VERSION |
2301 | #ifndef KORG_NODCOP | 2306 | #ifndef KORG_NODCOP |
2302 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2307 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2303 | #endif | 2308 | #endif |
2304 | #endif | 2309 | #endif |
2305 | 2310 | ||
2306 | mMainWindow->showMaximized(); | 2311 | mMainWindow->showMaximized(); |
2307 | mMainWindow-> raise(); | 2312 | mMainWindow-> raise(); |
2308 | 2313 | ||
2309 | mViewManager->setSelected( "", false); | 2314 | mViewManager->setSelected( "", false); |
2310 | mViewManager->refreshView( "" ); | 2315 | mViewManager->refreshView( "" ); |
2311 | mViewManager->setSelected( foundUid, true ); | 2316 | mViewManager->setSelected( foundUid, true ); |
2312 | mViewManager->refreshView( foundUid ); | 2317 | mViewManager->refreshView( foundUid ); |
2313 | 2318 | ||
2314 | if ( !mMultipleViewsAtOnce ) | 2319 | if ( !mMultipleViewsAtOnce ) |
2315 | { | 2320 | { |
2316 | setDetailsVisible( true ); | 2321 | setDetailsVisible( true ); |
2317 | mActionDetails->setChecked(true); | 2322 | mActionDetails->setChecked(true); |
2318 | } | 2323 | } |
2319 | } | 2324 | } |
2320 | } | 2325 | } |
2321 | 2326 | ||
2322 | void KABCore::whatsnew() | 2327 | void KABCore::whatsnew() |
2323 | { | 2328 | { |
2324 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2329 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2325 | } | 2330 | } |
2326 | void KABCore::synchowto() | 2331 | void KABCore::synchowto() |
2327 | { | 2332 | { |
2328 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2333 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2329 | } | 2334 | } |
2330 | 2335 | ||
2331 | void KABCore::faq() | 2336 | void KABCore::faq() |
2332 | { | 2337 | { |
2333 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2338 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2334 | } | 2339 | } |
2335 | 2340 | ||
2336 | #include <libkcal/syncdefines.h> | 2341 | #include <libkcal/syncdefines.h> |
2337 | 2342 | ||
2338 | KABC::Addressee KABCore::getLastSyncAddressee() | 2343 | KABC::Addressee KABCore::getLastSyncAddressee() |
2339 | { | 2344 | { |
2340 | Addressee lse; | 2345 | Addressee lse; |
2341 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2346 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2342 | 2347 | ||
2343 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2348 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2344 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2349 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2345 | if (lse.isEmpty()) { | 2350 | if (lse.isEmpty()) { |
2346 | qDebug("Creating new last-syncAddressee "); | 2351 | qDebug("Creating new last-syncAddressee "); |
2347 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2352 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2348 | QString sum = ""; | 2353 | QString sum = ""; |
2349 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2354 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2350 | sum = "E: "; | 2355 | sum = "E: "; |
2351 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2356 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2352 | lse.setRevision( mLastAddressbookSync ); | 2357 | lse.setRevision( mLastAddressbookSync ); |
2353 | lse.setCategories( i18n("SyncEvent") ); | 2358 | lse.setCategories( i18n("SyncEvent") ); |
2354 | mAddressBook->insertAddressee( lse ); | 2359 | mAddressBook->insertAddressee( lse ); |
2355 | } | 2360 | } |
2356 | return lse; | 2361 | return lse; |
2357 | } | 2362 | } |
2358 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2363 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2359 | { | 2364 | { |
2360 | 2365 | ||
2361 | //void setZaurusId(int id); | 2366 | //void setZaurusId(int id); |
2362 | // int zaurusId() const; | 2367 | // int zaurusId() const; |
2363 | // void setZaurusUid(int id); | 2368 | // void setZaurusUid(int id); |
2364 | // int zaurusUid() const; | 2369 | // int zaurusUid() const; |
2365 | // void setZaurusStat(int id); | 2370 | // void setZaurusStat(int id); |
2366 | // int zaurusStat() const; | 2371 | // int zaurusStat() const; |
2367 | // 0 equal | 2372 | // 0 equal |
2368 | // 1 take local | 2373 | // 1 take local |
2369 | // 2 take remote | 2374 | // 2 take remote |
2370 | // 3 cancel | 2375 | // 3 cancel |
2371 | QDateTime lastSync = mLastAddressbookSync; | 2376 | QDateTime lastSync = mLastAddressbookSync; |
2372 | QDateTime localMod = local->revision(); | 2377 | QDateTime localMod = local->revision(); |
2373 | QDateTime remoteMod = remote->revision(); | 2378 | QDateTime remoteMod = remote->revision(); |
2374 | 2379 | ||
2375 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2380 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2376 | 2381 | ||
2377 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2382 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2378 | bool remCh, locCh; | 2383 | bool remCh, locCh; |
2379 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2384 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2380 | 2385 | ||
2381 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2386 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2382 | locCh = ( localMod > mLastAddressbookSync ); | 2387 | locCh = ( localMod > mLastAddressbookSync ); |
2383 | if ( !remCh && ! locCh ) { | 2388 | if ( !remCh && ! locCh ) { |
2384 | //qDebug("both not changed "); | 2389 | //qDebug("both not changed "); |
2385 | lastSync = localMod.addDays(1); | 2390 | lastSync = localMod.addDays(1); |
2386 | if ( mode <= SYNC_PREF_ASK ) | 2391 | if ( mode <= SYNC_PREF_ASK ) |
2387 | return 0; | 2392 | return 0; |
2388 | } else { | 2393 | } else { |
2389 | if ( locCh ) { | 2394 | if ( locCh ) { |
2390 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2395 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2391 | lastSync = localMod.addDays( -1 ); | 2396 | lastSync = localMod.addDays( -1 ); |
2392 | if ( !remCh ) | 2397 | if ( !remCh ) |
2393 | remoteMod =( lastSync.addDays( -1 ) ); | 2398 | remoteMod =( lastSync.addDays( -1 ) ); |
2394 | } else { | 2399 | } else { |
2395 | //qDebug(" not loc changed "); | 2400 | //qDebug(" not loc changed "); |
2396 | lastSync = localMod.addDays( 1 ); | 2401 | lastSync = localMod.addDays( 1 ); |
2397 | if ( remCh ) | 2402 | if ( remCh ) |
2398 | remoteMod =( lastSync.addDays( 1 ) ); | 2403 | remoteMod =( lastSync.addDays( 1 ) ); |
2399 | 2404 | ||
2400 | } | 2405 | } |
2401 | } | 2406 | } |
2402 | full = true; | 2407 | full = true; |
2403 | if ( mode < SYNC_PREF_ASK ) | 2408 | if ( mode < SYNC_PREF_ASK ) |
2404 | mode = SYNC_PREF_ASK; | 2409 | mode = SYNC_PREF_ASK; |
2405 | } else { | 2410 | } else { |
2406 | if ( localMod == remoteMod ) | 2411 | if ( localMod == remoteMod ) |
2407 | return 0; | 2412 | return 0; |
2408 | 2413 | ||
2409 | } | 2414 | } |
2410 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2415 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2411 | 2416 | ||
2412 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 2417 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
2413 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2418 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2414 | //full = true; //debug only | 2419 | //full = true; //debug only |
2415 | if ( full ) { | 2420 | if ( full ) { |
2416 | bool equ = ( (*local) == (*remote) ); | 2421 | bool equ = ( (*local) == (*remote) ); |
2417 | if ( equ ) { | 2422 | if ( equ ) { |
2418 | //qDebug("equal "); | 2423 | //qDebug("equal "); |
2419 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2424 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2420 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2425 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2421 | } | 2426 | } |
2422 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2427 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2423 | return 0; | 2428 | return 0; |
2424 | 2429 | ||
2425 | }//else //debug only | 2430 | }//else //debug only |
2426 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2431 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2427 | } | 2432 | } |
2428 | int result; | 2433 | int result; |
2429 | bool localIsNew; | 2434 | bool localIsNew; |
2430 | //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() ); | 2435 | //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() ); |
2431 | 2436 | ||
2432 | if ( full && mode < SYNC_PREF_NEWEST ) | 2437 | if ( full && mode < SYNC_PREF_NEWEST ) |
2433 | mode = SYNC_PREF_ASK; | 2438 | mode = SYNC_PREF_ASK; |
2434 | 2439 | ||
2435 | switch( mode ) { | 2440 | switch( mode ) { |
2436 | case SYNC_PREF_LOCAL: | 2441 | case SYNC_PREF_LOCAL: |
2437 | if ( lastSync > remoteMod ) | 2442 | if ( lastSync > remoteMod ) |
2438 | return 1; | 2443 | return 1; |
2439 | if ( lastSync > localMod ) | 2444 | if ( lastSync > localMod ) |
2440 | return 2; | 2445 | return 2; |
2441 | return 1; | 2446 | return 1; |
2442 | break; | 2447 | break; |
2443 | case SYNC_PREF_REMOTE: | 2448 | case SYNC_PREF_REMOTE: |
2444 | if ( lastSync > remoteMod ) | 2449 | if ( lastSync > remoteMod ) |
2445 | return 1; | 2450 | return 1; |
2446 | if ( lastSync > localMod ) | 2451 | if ( lastSync > localMod ) |
2447 | return 2; | 2452 | return 2; |
2448 | return 2; | 2453 | return 2; |
2449 | break; | 2454 | break; |
2450 | case SYNC_PREF_NEWEST: | 2455 | case SYNC_PREF_NEWEST: |
2451 | if ( localMod > remoteMod ) | 2456 | if ( localMod > remoteMod ) |
2452 | return 1; | 2457 | return 1; |
2453 | else | 2458 | else |
2454 | return 2; | 2459 | return 2; |
2455 | break; | 2460 | break; |
2456 | case SYNC_PREF_ASK: | 2461 | case SYNC_PREF_ASK: |
2457 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2462 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2458 | if ( lastSync > remoteMod ) | 2463 | if ( lastSync > remoteMod ) |
2459 | return 1; | 2464 | return 1; |
2460 | if ( lastSync > localMod ) | 2465 | if ( lastSync > localMod ) |
2461 | return 2; | 2466 | return 2; |
2462 | localIsNew = localMod >= remoteMod; | 2467 | localIsNew = localMod >= remoteMod; |
2463 | //qDebug("conflict! ************************************** "); | 2468 | //qDebug("conflict! ************************************** "); |
2464 | { | 2469 | { |
2465 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2470 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2466 | result = acd.executeD(localIsNew); | 2471 | result = acd.executeD(localIsNew); |
2467 | return result; | 2472 | return result; |
2468 | } | 2473 | } |
2469 | break; | 2474 | break; |
2470 | case SYNC_PREF_FORCE_LOCAL: | 2475 | case SYNC_PREF_FORCE_LOCAL: |
2471 | return 1; | 2476 | return 1; |
2472 | break; | 2477 | break; |
2473 | case SYNC_PREF_FORCE_REMOTE: | 2478 | case SYNC_PREF_FORCE_REMOTE: |
2474 | return 2; | 2479 | return 2; |
2475 | break; | 2480 | break; |
2476 | 2481 | ||
2477 | default: | 2482 | default: |
2478 | // SYNC_PREF_TAKE_BOTH not implemented | 2483 | // SYNC_PREF_TAKE_BOTH not implemented |
2479 | break; | 2484 | break; |
2480 | } | 2485 | } |
2481 | return 0; | 2486 | return 0; |
2482 | } | 2487 | } |
2483 | 2488 | ||
2484 | 2489 | ||
2485 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2490 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2486 | { | 2491 | { |
2487 | bool syncOK = true; | 2492 | bool syncOK = true; |
2488 | int addedAddressee = 0; | 2493 | int addedAddressee = 0; |
2489 | int addedAddresseeR = 0; | 2494 | int addedAddresseeR = 0; |
2490 | int deletedAddresseeR = 0; | 2495 | int deletedAddresseeR = 0; |
2491 | int deletedAddresseeL = 0; | 2496 | int deletedAddresseeL = 0; |
2492 | int changedLocal = 0; | 2497 | int changedLocal = 0; |
2493 | int changedRemote = 0; | 2498 | int changedRemote = 0; |
2494 | 2499 | ||
2495 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2500 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2496 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2501 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2497 | 2502 | ||
2498 | //QPtrList<Addressee> el = local->rawAddressees(); | 2503 | //QPtrList<Addressee> el = local->rawAddressees(); |
2499 | Addressee addresseeR; | 2504 | Addressee addresseeR; |
2500 | QString uid; | 2505 | QString uid; |
2501 | int take; | 2506 | int take; |
2502 | Addressee addresseeL; | 2507 | Addressee addresseeL; |
2503 | Addressee addresseeRSync; | 2508 | Addressee addresseeRSync; |
2504 | Addressee addresseeLSync; | 2509 | Addressee addresseeLSync; |
2505 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2510 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2506 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2511 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2507 | bool fullDateRange = false; | 2512 | bool fullDateRange = false; |
2508 | local->resetTempSyncStat(); | 2513 | local->resetTempSyncStat(); |
2509 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2514 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2510 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2515 | if ( syncManager->syncWithDesktop() ) { |
2516 | remote->removeSyncInfo( QString());//remove all info | ||
2517 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | ||
2518 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | ||
2519 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | ||
2520 | } else { | ||
2521 | qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); | ||
2522 | } | ||
2523 | } | ||
2524 | QDateTime modifiedCalendar = mLastAddressbookSync; | ||
2511 | addresseeLSync = getLastSyncAddressee(); | 2525 | addresseeLSync = getLastSyncAddressee(); |
2512 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2526 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2513 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2527 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2514 | if ( !addresseeR.isEmpty() ) { | 2528 | if ( !addresseeR.isEmpty() ) { |
2515 | addresseeRSync = addresseeR; | 2529 | addresseeRSync = addresseeR; |
2516 | remote->removeAddressee(addresseeR ); | 2530 | remote->removeAddressee(addresseeR ); |
2517 | 2531 | ||
2518 | } else { | 2532 | } else { |
2519 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2533 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2520 | addresseeRSync = addresseeLSync ; | 2534 | addresseeRSync = addresseeLSync ; |
2521 | } else { | 2535 | } else { |
2522 | qDebug("FULLDATE 1"); | 2536 | qDebug("FULLDATE 1"); |
2523 | fullDateRange = true; | 2537 | fullDateRange = true; |
2524 | Addressee newAdd; | 2538 | Addressee newAdd; |
2525 | addresseeRSync = newAdd; | 2539 | addresseeRSync = newAdd; |
2526 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2540 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2527 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2541 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2528 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2542 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2529 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2543 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2530 | } | 2544 | } |
2531 | } | 2545 | } |
2532 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2546 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2533 | qDebug("FULLDATE 2"); | 2547 | qDebug("FULLDATE 2"); |
2534 | fullDateRange = true; | 2548 | fullDateRange = true; |
2535 | } | 2549 | } |
2536 | if ( ! fullDateRange ) { | 2550 | if ( ! fullDateRange ) { |
2537 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2551 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2538 | 2552 | ||
2539 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2553 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2540 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2554 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2541 | fullDateRange = true; | 2555 | fullDateRange = true; |
2542 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2556 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2543 | } | 2557 | } |
2544 | } | 2558 | } |
2545 | // fullDateRange = true; // debug only! | 2559 | // fullDateRange = true; // debug only! |
2546 | if ( fullDateRange ) | 2560 | if ( fullDateRange ) |
2547 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2561 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2548 | else | 2562 | else |
2549 | mLastAddressbookSync = addresseeLSync.revision(); | 2563 | mLastAddressbookSync = addresseeLSync.revision(); |
2550 | // for resyncing if own file has changed | 2564 | // for resyncing if own file has changed |
2551 | // PENDING fixme later when implemented | 2565 | // PENDING fixme later when implemented |
2552 | #if 0 | 2566 | #if 0 |
2553 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2567 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2554 | mLastAddressbookSync = loadedFileVersion; | 2568 | mLastAddressbookSync = loadedFileVersion; |
2555 | qDebug("setting mLastAddressbookSync "); | 2569 | qDebug("setting mLastAddressbookSync "); |
2556 | } | 2570 | } |
2557 | #endif | 2571 | #endif |
2558 | 2572 | ||
2559 | //qDebug("*************************** "); | 2573 | //qDebug("*************************** "); |
2560 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2574 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2561 | QStringList er = remote->uidList(); | 2575 | QStringList er = remote->uidList(); |
2562 | Addressee inR ;//= er.first(); | 2576 | Addressee inR ;//= er.first(); |
2563 | Addressee inL; | 2577 | Addressee inL; |
2564 | 2578 | ||
2565 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2579 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2566 | 2580 | ||
2567 | int modulo = (er.count()/10)+1; | 2581 | int modulo = (er.count()/10)+1; |
2568 | int incCounter = 0; | 2582 | int incCounter = 0; |
2569 | while ( incCounter < er.count()) { | 2583 | while ( incCounter < er.count()) { |
2570 | if (syncManager->isProgressBarCanceled()) | 2584 | if (syncManager->isProgressBarCanceled()) |
2571 | return false; | 2585 | return false; |
2572 | if ( incCounter % modulo == 0 ) | 2586 | if ( incCounter % modulo == 0 ) |
2573 | syncManager->showProgressBar(incCounter); | 2587 | syncManager->showProgressBar(incCounter); |
2574 | 2588 | ||
2575 | uid = er[ incCounter ]; | 2589 | uid = er[ incCounter ]; |
2576 | bool skipIncidence = false; | 2590 | bool skipIncidence = false; |
2577 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2591 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2578 | skipIncidence = true; | 2592 | skipIncidence = true; |
2579 | QString idS,OidS; | 2593 | QString idS,OidS; |
2580 | qApp->processEvents(); | 2594 | qApp->processEvents(); |
2581 | if ( !skipIncidence ) { | 2595 | if ( !skipIncidence ) { |
2582 | inL = local->findByUid( uid ); | 2596 | inL = local->findByUid( uid ); |
2583 | inR = remote->findByUid( uid ); | 2597 | inR = remote->findByUid( uid ); |
2584 | //inL.setResource( 0 ); | 2598 | //inL.setResource( 0 ); |
2585 | //inR.setResource( 0 ); | 2599 | //inR.setResource( 0 ); |
2586 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2600 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2587 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2601 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2588 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2602 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2589 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2603 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2590 | if ( take == 3 ) | 2604 | if ( take == 3 ) |
2591 | return false; | 2605 | return false; |
2592 | if ( take == 1 ) {// take local | 2606 | if ( take == 1 ) {// take local |
2593 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2607 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2594 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2608 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2595 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2609 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2596 | local->insertAddressee( inL, false ); | 2610 | local->insertAddressee( inL, false ); |
2597 | idS = inR.externalUID(); | 2611 | idS = inR.externalUID(); |
2598 | OidS = inR.originalExternalUID(); | 2612 | OidS = inR.originalExternalUID(); |
2599 | } | 2613 | } |
2600 | else | 2614 | else |
2601 | idS = inR.IDStr(); | 2615 | idS = inR.IDStr(); |
2602 | remote->removeAddressee( inR ); | 2616 | remote->removeAddressee( inR ); |
2603 | inR = inL; | 2617 | inR = inL; |
2604 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2618 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2605 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2619 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2606 | inR.setOriginalExternalUID( OidS ); | 2620 | inR.setOriginalExternalUID( OidS ); |
2607 | inR.setExternalUID( idS ); | 2621 | inR.setExternalUID( idS ); |
2622 | if ( syncManager->syncWithDesktop() ) | ||
2623 | inR.setIDStr( "changed" ); | ||
2608 | } else { | 2624 | } else { |
2609 | inR.setIDStr( idS ); | 2625 | inR.setIDStr( idS ); |
2610 | } | 2626 | } |
2611 | inR.setResource( 0 ); | 2627 | inR.setResource( 0 ); |
2612 | remote->insertAddressee( inR , false); | 2628 | remote->insertAddressee( inR , false); |
2613 | ++changedRemote; | 2629 | ++changedRemote; |
2614 | } else { // take == 2 take remote | 2630 | } else { // take == 2 take remote |
2615 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2631 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2616 | if ( inR.revision().date().year() < 2004 ) | 2632 | if ( inR.revision().date().year() < 2004 ) |
2617 | inR.setRevision( modifiedCalendar ); | 2633 | inR.setRevision( modifiedCalendar ); |
2618 | } | 2634 | } |
2619 | idS = inL.IDStr(); | 2635 | idS = inL.IDStr(); |
2620 | local->removeAddressee( inL ); | 2636 | local->removeAddressee( inL ); |
2621 | inL = inR; | 2637 | inL = inR; |
2622 | inL.setIDStr( idS ); | 2638 | inL.setIDStr( idS ); |
2623 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2639 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2624 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2640 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2625 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2641 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2626 | } | 2642 | } |
2627 | inL.setResource( 0 ); | 2643 | inL.setResource( 0 ); |
2628 | local->insertAddressee( inL , false ); | 2644 | local->insertAddressee( inL , false ); |
2629 | ++changedLocal; | 2645 | ++changedLocal; |
2630 | } | 2646 | } |
2631 | } | 2647 | } |
2632 | } | 2648 | } |
2633 | } else { // no conflict | 2649 | } else { // no conflict |
2634 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2650 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2635 | QString des = addresseeLSync.note(); | 2651 | QString des = addresseeLSync.note(); |
2636 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2652 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2637 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2653 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2638 | remote->insertAddressee( inR, false ); | 2654 | remote->insertAddressee( inR, false ); |
2639 | ++deletedAddresseeR; | 2655 | ++deletedAddresseeR; |
2640 | } else { | 2656 | } else { |
2641 | inR.setRevision( modifiedCalendar ); | 2657 | inR.setRevision( modifiedCalendar ); |
2642 | remote->insertAddressee( inR, false ); | 2658 | remote->insertAddressee( inR, false ); |
2643 | inL = inR; | 2659 | inL = inR; |
2644 | inL.setResource( 0 ); | 2660 | inL.setResource( 0 ); |
2645 | local->insertAddressee( inL , false); | 2661 | local->insertAddressee( inL , false); |
2646 | ++addedAddressee; | 2662 | ++addedAddressee; |
2647 | } | 2663 | } |
2648 | } else { | 2664 | } else { |
2649 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2665 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2650 | inR.setRevision( modifiedCalendar ); | 2666 | inR.setRevision( modifiedCalendar ); |
2651 | remote->insertAddressee( inR, false ); | 2667 | remote->insertAddressee( inR, false ); |
2652 | inR.setResource( 0 ); | 2668 | inR.setResource( 0 ); |
2653 | local->insertAddressee( inR, false ); | 2669 | local->insertAddressee( inR, false ); |
2654 | ++addedAddressee; | 2670 | ++addedAddressee; |
2655 | } else { | 2671 | } else { |
2656 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2672 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2657 | remote->removeAddressee( inR ); | 2673 | remote->removeAddressee( inR ); |
2658 | ++deletedAddresseeR; | 2674 | ++deletedAddresseeR; |
2659 | } | 2675 | } |
2660 | } | 2676 | } |
2661 | } | 2677 | } |
2662 | } | 2678 | } |
2663 | ++incCounter; | 2679 | ++incCounter; |
2664 | } | 2680 | } |
2665 | er.clear(); | 2681 | er.clear(); |
2666 | QStringList el = local->uidList(); | 2682 | QStringList el = local->uidList(); |
2667 | modulo = (el.count()/10)+1; | 2683 | modulo = (el.count()/10)+1; |
2668 | 2684 | ||
2669 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2685 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2670 | incCounter = 0; | 2686 | incCounter = 0; |
2671 | while ( incCounter < el.count()) { | 2687 | while ( incCounter < el.count()) { |
2672 | qApp->processEvents(); | 2688 | qApp->processEvents(); |
2673 | if (syncManager->isProgressBarCanceled()) | 2689 | if (syncManager->isProgressBarCanceled()) |
2674 | return false; | 2690 | return false; |
2675 | if ( incCounter % modulo == 0 ) | 2691 | if ( incCounter % modulo == 0 ) |
2676 | syncManager->showProgressBar(incCounter); | 2692 | syncManager->showProgressBar(incCounter); |
2677 | uid = el[ incCounter ]; | 2693 | uid = el[ incCounter ]; |
2678 | bool skipIncidence = false; | 2694 | bool skipIncidence = false; |
2679 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2695 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2680 | skipIncidence = true; | 2696 | skipIncidence = true; |
2681 | if ( !skipIncidence ) { | 2697 | if ( !skipIncidence ) { |
2682 | inL = local->findByUid( uid ); | 2698 | inL = local->findByUid( uid ); |
2683 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2699 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2684 | inR = remote->findByUid( uid ); | 2700 | inR = remote->findByUid( uid ); |
2685 | if ( inR.isEmpty() ) { | 2701 | if ( inR.isEmpty() ) { |
2686 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2702 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2687 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2703 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2688 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2704 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2689 | local->removeAddressee( inL ); | 2705 | local->removeAddressee( inL ); |
2690 | ++deletedAddresseeL; | 2706 | ++deletedAddresseeL; |
2691 | } else { | 2707 | } else { |
2692 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2708 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2693 | inL.removeID(mCurrentSyncDevice ); | 2709 | inL.removeID(mCurrentSyncDevice ); |
2694 | ++addedAddresseeR; | 2710 | ++addedAddresseeR; |
2695 | inL.setRevision( modifiedCalendar ); | 2711 | inL.setRevision( modifiedCalendar ); |
2696 | local->insertAddressee( inL, false ); | 2712 | local->insertAddressee( inL, false ); |
2697 | inR = inL; | 2713 | inR = inL; |
2698 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2714 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2699 | inR.setResource( 0 ); | 2715 | inR.setResource( 0 ); |
2700 | remote->insertAddressee( inR, false ); | 2716 | remote->insertAddressee( inR, false ); |
2701 | } | 2717 | } |
2702 | } | 2718 | } |
2703 | } else { | 2719 | } else { |
2704 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2720 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2705 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2721 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2706 | local->removeAddressee( inL ); | 2722 | local->removeAddressee( inL ); |
2707 | ++deletedAddresseeL; | 2723 | ++deletedAddresseeL; |
2708 | } else { | 2724 | } else { |
2709 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2725 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2710 | ++addedAddresseeR; | 2726 | ++addedAddresseeR; |
2711 | inL.setRevision( modifiedCalendar ); | 2727 | inL.setRevision( modifiedCalendar ); |
2712 | local->insertAddressee( inL, false ); | 2728 | local->insertAddressee( inL, false ); |
2713 | inR = inL; | 2729 | inR = inL; |
2714 | inR.setResource( 0 ); | 2730 | inR.setResource( 0 ); |
2715 | remote->insertAddressee( inR, false ); | 2731 | remote->insertAddressee( inR, false ); |
2716 | } | 2732 | } |
2717 | } | 2733 | } |
2718 | } | 2734 | } |
2719 | } | 2735 | } |
2720 | } | 2736 | } |
2721 | } | 2737 | } |
2722 | ++incCounter; | 2738 | ++incCounter; |
2723 | } | 2739 | } |
2724 | el.clear(); | 2740 | el.clear(); |
2725 | syncManager->hideProgressBar(); | 2741 | syncManager->hideProgressBar(); |
2726 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2742 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2727 | // get rid of micro seconds | 2743 | // get rid of micro seconds |
2728 | QTime t = mLastAddressbookSync.time(); | 2744 | QTime t = mLastAddressbookSync.time(); |
2729 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2745 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2730 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2746 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2731 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2747 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2732 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2748 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2733 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2749 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2734 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2750 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2735 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2751 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2736 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2752 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2737 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2753 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2738 | addresseeRSync.setNote( "" ) ; | 2754 | addresseeRSync.setNote( "" ) ; |
2739 | addresseeLSync.setNote( "" ); | 2755 | addresseeLSync.setNote( "" ); |
2740 | 2756 | ||
2741 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2757 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2742 | remote->insertAddressee( addresseeRSync, false ); | 2758 | remote->insertAddressee( addresseeRSync, false ); |
2743 | local->insertAddressee( addresseeLSync, false ); | 2759 | local->insertAddressee( addresseeLSync, false ); |
2744 | QString mes; | 2760 | QString mes; |
2745 | 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 ); | 2761 | 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 ); |
2746 | if ( syncManager->mShowSyncSummary ) { | 2762 | if ( syncManager->mShowSyncSummary ) { |
2747 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2763 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2748 | } | 2764 | } |
2749 | qDebug( mes ); | 2765 | qDebug( mes ); |
2750 | return syncOK; | 2766 | return syncOK; |
2751 | } | 2767 | } |
2752 | 2768 | ||
2753 | 2769 | ||
2754 | //this is a overwritten callbackmethods from the syncinterface | 2770 | //this is a overwritten callbackmethods from the syncinterface |
2755 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2771 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2756 | { | 2772 | { |
2757 | 2773 | ||
2758 | //pending prepare addresseeview for output | 2774 | //pending prepare addresseeview for output |
2759 | //pending detect, if remote file has REV field. if not switch to external sync | 2775 | //pending detect, if remote file has REV field. if not switch to external sync |
2760 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2776 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2761 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2777 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2762 | 2778 | ||
2763 | AddressBook abLocal(filename,"syncContact"); | 2779 | AddressBook abLocal(filename,"syncContact"); |
2764 | bool syncOK = false; | 2780 | bool syncOK = false; |
2765 | if ( abLocal.load() ) { | 2781 | if ( abLocal.load() ) { |
2766 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2782 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2767 | bool external = false; | 2783 | bool external = false; |
2768 | bool isXML = false; | 2784 | bool isXML = false; |
2769 | if ( filename.right(4) == ".xml") { | 2785 | if ( filename.right(4) == ".xml") { |
2770 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2786 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2771 | isXML = true; | 2787 | isXML = true; |
2772 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2788 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2773 | } else { | 2789 | } else { |
2774 | external = !manager->mIsKapiFile; | 2790 | external = !manager->mIsKapiFile; |
2775 | if ( external ) { | 2791 | if ( external ) { |
2776 | qDebug("Setting vcf mode to external "); | 2792 | qDebug("Setting vcf mode to external "); |
2777 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2793 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2778 | AddressBook::Iterator it; | 2794 | AddressBook::Iterator it; |
2779 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2795 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2780 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2796 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2781 | (*it).computeCsum( mCurrentSyncDevice ); | 2797 | (*it).computeCsum( mCurrentSyncDevice ); |
2782 | } | 2798 | } |
2783 | } | 2799 | } |
2784 | } | 2800 | } |
2785 | //AddressBook::Iterator it; | 2801 | //AddressBook::Iterator it; |
2786 | //QStringList vcards; | 2802 | //QStringList vcards; |
2787 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2803 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2788 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2804 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2789 | //} | 2805 | //} |
2790 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2806 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2791 | if ( syncOK ) { | 2807 | if ( syncOK ) { |
2792 | if ( syncManager->mWriteBackFile ) | 2808 | if ( syncManager->mWriteBackFile ) |
2793 | { | 2809 | { |
2794 | if ( external ) | 2810 | if ( external ) |
2795 | abLocal.removeSyncAddressees( !isXML); | 2811 | abLocal.removeSyncAddressees( !isXML); |
2796 | qDebug("Saving remote AB "); | 2812 | qDebug("Saving remote AB "); |
2797 | if ( ! abLocal.saveAB()) | 2813 | if ( ! abLocal.saveAB()) |
2798 | qDebug("Error writing back AB to file "); | 2814 | qDebug("Error writing back AB to file "); |
2799 | if ( isXML ) { | 2815 | if ( isXML ) { |
2800 | // afterwrite processing | 2816 | // afterwrite processing |
2801 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2817 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2802 | } | 2818 | } |
2803 | } | 2819 | } |
2804 | } | 2820 | } |
2805 | setModified(); | 2821 | setModified(); |
2806 | 2822 | ||
2807 | } | 2823 | } |
2808 | if ( syncOK ) | 2824 | if ( syncOK ) |
2809 | mViewManager->refreshView(); | 2825 | mViewManager->refreshView(); |
2810 | return syncOK; | 2826 | return syncOK; |
2811 | 2827 | ||
2812 | } | 2828 | } |
2813 | void KABCore::removeSyncInfo( QString syncProfile) | 2829 | void KABCore::removeSyncInfo( QString syncProfile) |
2814 | { | 2830 | { |
2815 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 2831 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
2816 | mAddressBook->removeSyncInfo( syncProfile ); | 2832 | mAddressBook->removeSyncInfo( syncProfile ); |
2817 | } | 2833 | } |
2818 | 2834 | ||
2819 | 2835 | ||
2820 | //this is a overwritten callbackmethods from the syncinterface | 2836 | //this is a overwritten callbackmethods from the syncinterface |
2821 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2837 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2822 | { | 2838 | { |
2823 | if ( resource == "phone" ) | 2839 | if ( resource == "phone" ) |
2824 | return syncPhone(); | 2840 | return syncPhone(); |
2825 | disableBR( true ); | 2841 | disableBR( true ); |
2826 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2842 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2827 | 2843 | ||
2828 | AddressBook abLocal( resource,"syncContact"); | 2844 | AddressBook abLocal( resource,"syncContact"); |
2829 | bool syncOK = false; | 2845 | bool syncOK = false; |
2830 | if ( abLocal.load() ) { | 2846 | if ( abLocal.load() ) { |
2831 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2847 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2832 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2848 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2833 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 2849 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
2834 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2850 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2835 | if ( syncOK ) { | 2851 | if ( syncOK ) { |
2836 | if ( syncManager->mWriteBackFile ) { | 2852 | if ( syncManager->mWriteBackFile ) { |
2837 | abLocal.removeSyncAddressees( false ); | 2853 | abLocal.removeSyncAddressees( false ); |
2838 | abLocal.saveAB(); | 2854 | abLocal.saveAB(); |
2839 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2855 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2840 | } | 2856 | } |
2841 | } | 2857 | } |
2842 | setModified(); | 2858 | setModified(); |
2843 | } | 2859 | } |
2844 | if ( syncOK ) | 2860 | if ( syncOK ) |
2845 | mViewManager->refreshView(); | 2861 | mViewManager->refreshView(); |
2846 | disableBR( false ); | 2862 | disableBR( false ); |
2847 | return syncOK; | 2863 | return syncOK; |
2848 | 2864 | ||
2849 | } | 2865 | } |
2850 | void KABCore::message( QString m ) | 2866 | void KABCore::message( QString m ) |
2851 | { | 2867 | { |
2852 | topLevelWidget()->setCaption( m ); | 2868 | topLevelWidget()->setCaption( m ); |
2853 | mMessageTimer->start( 15000, true ); | 2869 | mMessageTimer->start( 15000, true ); |
2854 | } | 2870 | } |
2855 | bool KABCore::syncPhone() | 2871 | bool KABCore::syncPhone() |
2856 | { | 2872 | { |
2857 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2873 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2858 | QString fileName = getPhoneFile(); | 2874 | QString fileName = getPhoneFile(); |
2859 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 2875 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
2860 | message(i18n("Phone access failed!")); | 2876 | message(i18n("Phone access failed!")); |
2861 | return false; | 2877 | return false; |
2862 | } | 2878 | } |
2863 | AddressBook abLocal( fileName,"syncContact"); | 2879 | AddressBook abLocal( fileName,"syncContact"); |
2864 | bool syncOK = false; | 2880 | bool syncOK = false; |
2865 | { | 2881 | { |
2866 | abLocal.importFromFile( fileName ); | 2882 | abLocal.importFromFile( fileName ); |
2867 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2883 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2868 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2884 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2869 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 2885 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
2870 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2886 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2871 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2887 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2872 | if ( syncOK ) { | 2888 | if ( syncOK ) { |
2873 | if ( syncManager->mWriteBackFile ) { | 2889 | if ( syncManager->mWriteBackFile ) { |
2874 | abLocal.removeSyncAddressees( true ); | 2890 | abLocal.removeSyncAddressees( true ); |
2875 | abLocal.saveABphone( fileName ); | 2891 | abLocal.saveABphone( fileName ); |
2876 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 2892 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
2877 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 2893 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
2878 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2894 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2879 | } | 2895 | } |
2880 | } | 2896 | } |
2881 | setModified(); | 2897 | setModified(); |
2882 | } | 2898 | } |
2883 | if ( syncOK ) | 2899 | if ( syncOK ) |
2884 | mViewManager->refreshView(); | 2900 | mViewManager->refreshView(); |
2885 | return syncOK; | 2901 | return syncOK; |
2886 | } | 2902 | } |
2887 | void KABCore::getFile( bool success ) | 2903 | void KABCore::getFile( bool success ) |
2888 | { | 2904 | { |
2889 | if ( ! success ) { | 2905 | if ( ! success ) { |
2890 | message( i18n("Error receiving file. Nothing changed!") ); | 2906 | message( i18n("Error receiving file. Nothing changed!") ); |
2891 | return; | 2907 | return; |
2892 | } | 2908 | } |
2893 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 2909 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
2894 | if ( count ) | 2910 | if ( count ) |
2895 | setModified( true ); | 2911 | setModified( true ); |
2896 | message( i18n("Pi-Sync successful!") ); | 2912 | message( i18n("Pi-Sync successful!") ); |
2897 | mViewManager->refreshView(); | 2913 | mViewManager->refreshView(); |
2898 | } | 2914 | } |
2899 | void KABCore::syncFileRequest() | 2915 | void KABCore::syncFileRequest() |
2900 | { | 2916 | { |
2917 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | ||
2918 | syncManager->slotSyncMenu( 999 ); | ||
2919 | } | ||
2901 | mAddressBook->export2File( sentSyncFile() ); | 2920 | mAddressBook->export2File( sentSyncFile() ); |
2902 | } | 2921 | } |
2903 | QString KABCore::sentSyncFile() | 2922 | QString KABCore::sentSyncFile() |
2904 | { | 2923 | { |
2905 | #ifdef DESKTOP_VERSION | 2924 | #ifdef DESKTOP_VERSION |
2906 | return locateLocal( "tmp", "copysyncab.vcf" ); | 2925 | return locateLocal( "tmp", "copysyncab.vcf" ); |
2907 | #else | 2926 | #else |
2908 | return QString( "/tmp/copysyncab.vcf" ); | 2927 | return QString( "/tmp/copysyncab.vcf" ); |
2909 | #endif | 2928 | #endif |
2910 | } | 2929 | } |
2911 | 2930 | ||
2912 | void KABCore::setCaptionBack() | 2931 | void KABCore::setCaptionBack() |
2913 | { | 2932 | { |
2914 | mMessageTimer->stop(); | 2933 | mMessageTimer->stop(); |
2915 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 2934 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
2916 | } | 2935 | } |
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index f4fb08b..81e0d99 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp | |||
@@ -1,713 +1,718 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | 31 | ||
32 | #ifndef KAB_EMBEDDED | 32 | #ifndef KAB_EMBEDDED |
33 | #include <libkdepim/kvcarddrag.h> | 33 | #include <libkdepim/kvcarddrag.h> |
34 | #include <kabc/vcardconverter.h> | 34 | #include <kabc/vcardconverter.h> |
35 | #include <kconfig.h> | 35 | #include <kconfig.h> |
36 | #include <kdeversion.h> | 36 | #include <kdeversion.h> |
37 | #include <kiconloader.h> | 37 | #include <kiconloader.h> |
38 | #include <klocale.h> | 38 | #include <klocale.h> |
39 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
40 | #include <kmultipledrag.h> | 40 | #include <kmultipledrag.h> |
41 | #include <ktrader.h> | 41 | #include <ktrader.h> |
42 | #include <kurldrag.h> | 42 | #include <kurldrag.h> |
43 | 43 | ||
44 | #include "addresseeutil.h" | 44 | #include "addresseeutil.h" |
45 | #else //KAB_EMBEDDED | 45 | #else //KAB_EMBEDDED |
46 | #include "views/kaddressbookiconview.h" | 46 | #include "views/kaddressbookiconview.h" |
47 | #include "views/kaddressbooktableview.h" | 47 | #include "views/kaddressbooktableview.h" |
48 | #include "views/kaddressbookcardview.h" | 48 | #include "views/kaddressbookcardview.h" |
49 | #include "kaddressbookview.h" | 49 | #include "kaddressbookview.h" |
50 | 50 | ||
51 | #include <qaction.h> | 51 | #include <qaction.h> |
52 | #include <qmessagebox.h> | 52 | #include <qmessagebox.h> |
53 | #include <qpopupmenu.h> | 53 | #include <qpopupmenu.h> |
54 | #include <kconfigbase.h> | 54 | #include <kconfigbase.h> |
55 | 55 | ||
56 | #endif //KAB_EMBEDDED | 56 | #endif //KAB_EMBEDDED |
57 | 57 | ||
58 | 58 | ||
59 | #include <kdebug.h> | 59 | #include <kdebug.h> |
60 | #include <kactionclasses.h> | 60 | #include <kactionclasses.h> |
61 | 61 | ||
62 | #include <qlayout.h> | 62 | #include <qlayout.h> |
63 | #include <qwidgetstack.h> | 63 | #include <qwidgetstack.h> |
64 | 64 | ||
65 | #include <kabc/addressbook.h> | 65 | #include <kabc/addressbook.h> |
66 | #include "filtereditdialog.h" | 66 | #include "filtereditdialog.h" |
67 | #include "addviewdialog.h" | 67 | #include "addviewdialog.h" |
68 | #include "kabcore.h" | 68 | #include "kabcore.h" |
69 | #include "kabprefs.h" | 69 | #include "kabprefs.h" |
70 | #include "viewmanager.h" | 70 | #include "viewmanager.h" |
71 | 71 | ||
72 | ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) | 72 | ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) |
73 | : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) | 73 | : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) |
74 | { | 74 | { |
75 | initGUI(); | 75 | initGUI(); |
76 | initActions(); | 76 | initActions(); |
77 | 77 | ||
78 | mViewDict.setAutoDelete( true ); | 78 | mViewDict.setAutoDelete( true ); |
79 | 79 | ||
80 | createViewFactories(); | 80 | createViewFactories(); |
81 | } | 81 | } |
82 | 82 | ||
83 | ViewManager::~ViewManager() | 83 | ViewManager::~ViewManager() |
84 | { | 84 | { |
85 | unloadViews(); | 85 | unloadViews(); |
86 | mViewFactoryDict.clear(); | 86 | mViewFactoryDict.clear(); |
87 | } | 87 | } |
88 | void ViewManager::scrollUP() | 88 | void ViewManager::scrollUP() |
89 | { | 89 | { |
90 | if ( mActiveView ) | 90 | if ( mActiveView ) |
91 | mActiveView->scrollUP(); | 91 | mActiveView->scrollUP(); |
92 | } | 92 | } |
93 | void ViewManager::scrollDOWN() | 93 | void ViewManager::scrollDOWN() |
94 | { | 94 | { |
95 | if ( mActiveView ) | 95 | if ( mActiveView ) |
96 | mActiveView->scrollDOWN(); | 96 | mActiveView->scrollDOWN(); |
97 | } | 97 | } |
98 | void ViewManager::restoreSettings() | 98 | void ViewManager::restoreSettings() |
99 | { | 99 | { |
100 | mViewNameList = KABPrefs::instance()->mViewNames; | 100 | mViewNameList = KABPrefs::instance()->mViewNames; |
101 | QString activeViewName = KABPrefs::instance()->mCurrentView; | 101 | QString activeViewName = KABPrefs::instance()->mCurrentView; |
102 | 102 | ||
103 | mActionSelectView->setItems( mViewNameList ); | 103 | mActionSelectView->setItems( mViewNameList ); |
104 | 104 | ||
105 | // Filter | 105 | // Filter |
106 | mFilterList = Filter::restore( mCore->config(), "Filter" ); | 106 | mFilterList = Filter::restore( mCore->config(), "Filter" ); |
107 | mActionSelectFilter->setItems( filterNames() ); | 107 | mActionSelectFilter->setItems( filterNames() ); |
108 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); | 108 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); |
109 | 109 | ||
110 | // Tell the views to reread their config, since they may have | 110 | // Tell the views to reread their config, since they may have |
111 | // been modified by global settings | 111 | // been modified by global settings |
112 | QString _oldgroup = mCore->config()->group(); | 112 | QString _oldgroup = mCore->config()->group(); |
113 | 113 | ||
114 | QDictIterator<KAddressBookView> it( mViewDict ); | 114 | QDictIterator<KAddressBookView> it( mViewDict ); |
115 | for ( it.toFirst(); it.current(); ++it ) { | 115 | for ( it.toFirst(); it.current(); ++it ) { |
116 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 116 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
117 | it.current()->readConfig( mCore->config() ); | 117 | it.current()->readConfig( mCore->config() ); |
118 | } | 118 | } |
119 | setActiveView( activeViewName ); | 119 | setActiveView( activeViewName ); |
120 | 120 | ||
121 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 121 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
122 | } | 122 | } |
123 | 123 | ||
124 | void ViewManager::saveSettings() | 124 | void ViewManager::saveSettings() |
125 | { | 125 | { |
126 | QString _oldgroup = mCore->config()->group(); | 126 | QString _oldgroup = mCore->config()->group(); |
127 | 127 | ||
128 | QDictIterator<KAddressBookView> it( mViewDict ); | 128 | QDictIterator<KAddressBookView> it( mViewDict ); |
129 | for ( it.toFirst(); it.current(); ++it ) { | 129 | for ( it.toFirst(); it.current(); ++it ) { |
130 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 130 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
131 | #ifdef DESKTOP_VERSION | 131 | #ifdef DESKTOP_VERSION |
132 | (*it)->writeConfig( mCore->config() ); | 132 | (*it)->writeConfig( mCore->config() ); |
133 | #else | 133 | #else |
134 | (*it).writeConfig( mCore->config() ); | 134 | (*it).writeConfig( mCore->config() ); |
135 | #endif | 135 | #endif |
136 | } | 136 | } |
137 | 137 | ||
138 | Filter::save( mCore->config(), "Filter", mFilterList ); | 138 | Filter::save( mCore->config(), "Filter", mFilterList ); |
139 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); | 139 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); |
140 | 140 | ||
141 | // write the view name list | 141 | // write the view name list |
142 | KABPrefs::instance()->mViewNames = mViewNameList; | 142 | KABPrefs::instance()->mViewNames = mViewNameList; |
143 | KABPrefs::instance()->mCurrentView = mActiveView->caption(); | 143 | KABPrefs::instance()->mCurrentView = mActiveView->caption(); |
144 | 144 | ||
145 | } | 145 | } |
146 | 146 | ||
147 | QStringList ViewManager::selectedUids() const | 147 | QStringList ViewManager::selectedUids() const |
148 | { | 148 | { |
149 | if ( mActiveView ) | 149 | if ( mActiveView ) |
150 | return mActiveView->selectedUids(); | 150 | return mActiveView->selectedUids(); |
151 | else | 151 | else |
152 | return QStringList(); | 152 | return QStringList(); |
153 | } | 153 | } |
154 | 154 | ||
155 | QStringList ViewManager::selectedEmails() const | 155 | QStringList ViewManager::selectedEmails() const |
156 | { | 156 | { |
157 | if ( mActiveView ) | 157 | if ( mActiveView ) |
158 | return mActiveView->selectedEmails(); | 158 | return mActiveView->selectedEmails(); |
159 | else | 159 | else |
160 | return QStringList(); | 160 | return QStringList(); |
161 | } | 161 | } |
162 | 162 | ||
163 | KABC::Addressee::List ViewManager::selectedAddressees() const | 163 | KABC::Addressee::List ViewManager::selectedAddressees() const |
164 | { | 164 | { |
165 | KABC::Addressee::List list; | 165 | KABC::Addressee::List list; |
166 | if ( mActiveView ) { | 166 | if ( mActiveView ) { |
167 | QStringList uids = mActiveView->selectedUids(); | 167 | QStringList uids = mActiveView->selectedUids(); |
168 | QStringList::Iterator it; | 168 | QStringList::Iterator it; |
169 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 169 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
170 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); | 170 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); |
171 | if ( !addr.isEmpty() ) | 171 | if ( !addr.isEmpty() ) |
172 | list.append( addr ); | 172 | list.append( addr ); |
173 | } | 173 | } |
174 | } | 174 | } |
175 | 175 | ||
176 | return list; | 176 | return list; |
177 | } | 177 | } |
178 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 178 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
179 | void ViewManager::setSelected() | 179 | void ViewManager::setSelected() |
180 | { | 180 | { |
181 | setSelected( QString::null, true ); | 181 | setSelected( QString::null, true ); |
182 | } | 182 | } |
183 | 183 | ||
184 | void ViewManager::setSelected( const QString &uid, bool selected ) | 184 | void ViewManager::setSelected( const QString &uid, bool selected ) |
185 | { | 185 | { |
186 | if ( mActiveView ) | 186 | if ( mActiveView ) |
187 | mActiveView->setSelected( uid, selected ); | 187 | mActiveView->setSelected( uid, selected ); |
188 | } | 188 | } |
189 | 189 | ||
190 | void ViewManager::setListSelected(QStringList list) | 190 | void ViewManager::setListSelected(QStringList list) |
191 | { | 191 | { |
192 | int i, count = list.count(); | 192 | int i, count = list.count(); |
193 | for ( i = 0; i < count;++i ) | 193 | for ( i = 0; i < count;++i ) |
194 | setSelected( list[i], true ); | 194 | setSelected( list[i], true ); |
195 | 195 | ||
196 | } | 196 | } |
197 | void ViewManager::unloadViews() | 197 | void ViewManager::unloadViews() |
198 | { | 198 | { |
199 | mViewDict.clear(); | 199 | mViewDict.clear(); |
200 | mActiveView = 0; | 200 | mActiveView = 0; |
201 | } | 201 | } |
202 | 202 | ||
203 | void ViewManager::setActiveView( const QString &name ) | 203 | void ViewManager::setActiveView( const QString &name ) |
204 | { | 204 | { |
205 | KAddressBookView *view = 0; | 205 | KAddressBookView *view = 0; |
206 | 206 | ||
207 | // Check that this isn't the same as the current active view | 207 | // Check that this isn't the same as the current active view |
208 | if ( mActiveView && ( mActiveView->caption() == name ) ) | 208 | if ( mActiveView && ( mActiveView->caption() == name ) ) |
209 | return; | 209 | return; |
210 | 210 | ||
211 | // At this point we know the view that should be active is not | 211 | // At this point we know the view that should be active is not |
212 | // currently active. We will try to find the new on in the list. If | 212 | // currently active. We will try to find the new on in the list. If |
213 | // we can't find it, it means it hasn't been instantiated, so we will | 213 | // we can't find it, it means it hasn't been instantiated, so we will |
214 | // create it on demand. | 214 | // create it on demand. |
215 | 215 | ||
216 | view = mViewDict.find( name ); | 216 | view = mViewDict.find( name ); |
217 | 217 | ||
218 | // Check if we found the view. If we didn't, then we need to create it | 218 | // Check if we found the view. If we didn't, then we need to create it |
219 | if ( view == 0 ) { | 219 | if ( view == 0 ) { |
220 | KConfig *config = mCore->config(); | 220 | KConfig *config = mCore->config(); |
221 | 221 | ||
222 | KConfigGroupSaver saver( config, name ); | 222 | KConfigGroupSaver saver( config, name ); |
223 | 223 | ||
224 | QString type = config->readEntry( "Type", "Table" ); | 224 | QString type = config->readEntry( "Type", "Table" ); |
225 | 225 | ||
226 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; | 226 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; |
227 | 227 | ||
228 | ViewFactory *factory = mViewFactoryDict.find( type ); | 228 | ViewFactory *factory = mViewFactoryDict.find( type ); |
229 | if ( factory ) | 229 | if ( factory ) |
230 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); | 230 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); |
231 | 231 | ||
232 | if ( view ) { | 232 | if ( view ) { |
233 | view->setCaption( name ); | 233 | view->setCaption( name ); |
234 | mViewDict.insert( name, view ); | 234 | mViewDict.insert( name, view ); |
235 | //US my version needs an int as second parameter to addWidget | 235 | //US my version needs an int as second parameter to addWidget |
236 | mViewWidgetStack->addWidget( view, -1 ); | 236 | mViewWidgetStack->addWidget( view, -1 ); |
237 | view->readConfig( config ); | 237 | view->readConfig( config ); |
238 | 238 | ||
239 | // The manager just relays the signals | 239 | // The manager just relays the signals |
240 | connect( view, SIGNAL( selected( const QString& ) ), | 240 | connect( view, SIGNAL( selected( const QString& ) ), |
241 | SIGNAL( selected( const QString & ) ) ); | 241 | SIGNAL( selected( const QString & ) ) ); |
242 | connect( view, SIGNAL( executed( const QString& ) ), | 242 | connect( view, SIGNAL( executed( const QString& ) ), |
243 | SIGNAL( executed( const QString& ) ) ); | 243 | SIGNAL( executed( const QString& ) ) ); |
244 | 244 | ||
245 | connect( view, SIGNAL( deleteRequest( ) ), | 245 | connect( view, SIGNAL( deleteRequest( ) ), |
246 | SIGNAL( deleteRequest( ) ) ); | 246 | SIGNAL( deleteRequest( ) ) ); |
247 | 247 | ||
248 | connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); | 248 | connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); |
249 | connect( view, SIGNAL( dropped( QDropEvent* ) ), | 249 | connect( view, SIGNAL( dropped( QDropEvent* ) ), |
250 | SLOT( dropped( QDropEvent* ) ) ); | 250 | SLOT( dropped( QDropEvent* ) ) ); |
251 | connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); | 251 | connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); |
252 | } | 252 | } |
253 | } | 253 | } |
254 | 254 | ||
255 | // If we found or created the view, raise it and refresh it | 255 | // If we found or created the view, raise it and refresh it |
256 | if ( view ) { | 256 | if ( view ) { |
257 | mActiveView = view; | 257 | mActiveView = view; |
258 | mViewWidgetStack->raiseWidget( view ); | 258 | mViewWidgetStack->raiseWidget( view ); |
259 | // Set the proper filter in the view. By setting the combo | 259 | // Set the proper filter in the view. By setting the combo |
260 | // box, the activated slot will be called, which will push | 260 | // box, the activated slot will be called, which will push |
261 | // the filter to the view and refresh it. | 261 | // the filter to the view and refresh it. |
262 | 262 | ||
263 | if ( view->defaultFilterType() == KAddressBookView::None ) { | 263 | if ( view->defaultFilterType() == KAddressBookView::None ) { |
264 | 264 | ||
265 | mActionSelectFilter->setCurrentItem( 0 ); | 265 | mActionSelectFilter->setCurrentItem( 0 ); |
266 | setActiveFilter( 0 ); | 266 | setActiveFilter( 0 ); |
267 | } else if ( view->defaultFilterType() == KAddressBookView::Active ) { | 267 | } else if ( view->defaultFilterType() == KAddressBookView::Active ) { |
268 | setActiveFilter( mActionSelectFilter->currentItem() ); | 268 | setActiveFilter( mActionSelectFilter->currentItem() ); |
269 | } else { | 269 | } else { |
270 | uint pos = filterPosition( view->defaultFilterName() ); | 270 | uint pos = filterPosition( view->defaultFilterName() ); |
271 | mActionSelectFilter->setCurrentItem( pos ); | 271 | mActionSelectFilter->setCurrentItem( pos ); |
272 | setActiveFilter( pos ); | 272 | setActiveFilter( pos ); |
273 | } | 273 | } |
274 | //US qDebug("ViewManager::setActiveView 6" ); | 274 | //US qDebug("ViewManager::setActiveView 6" ); |
275 | 275 | ||
276 | // Update the inc search widget to show the fields in the new active | 276 | // Update the inc search widget to show the fields in the new active |
277 | // view. | 277 | // view. |
278 | mCore->setSearchFields( mActiveView->fields() ); | 278 | mCore->setSearchFields( mActiveView->fields() ); |
279 | 279 | ||
280 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() | 280 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
281 | //US mActiveView->refresh(); | 281 | //US mActiveView->refresh(); |
282 | 282 | ||
283 | } | 283 | } |
284 | else | 284 | else |
285 | { | 285 | { |
286 | qDebug("ViewManager::setActiveView: unable to find view" ); | 286 | qDebug("ViewManager::setActiveView: unable to find view" ); |
287 | kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; | 287 | kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; |
288 | } | 288 | } |
289 | } | 289 | } |
290 | 290 | ||
291 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 291 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
292 | void ViewManager::refreshView() | 292 | void ViewManager::refreshView() |
293 | { | 293 | { |
294 | refreshView( QString::null ); | 294 | refreshView( QString::null ); |
295 | } | 295 | } |
296 | 296 | ||
297 | void ViewManager::refreshView( const QString &uid ) | 297 | void ViewManager::refreshView( const QString &uid ) |
298 | { | 298 | { |
299 | if ( mActiveView ) | 299 | if ( mActiveView ) |
300 | mActiveView->refresh( uid ); | 300 | mActiveView->refresh( uid ); |
301 | } | 301 | } |
302 | 302 | ||
303 | void ViewManager::setFocusAV() | ||
304 | { | ||
305 | if ( mActiveView ) | ||
306 | mActiveView->setFocus(); | ||
307 | } | ||
303 | void ViewManager::editView() | 308 | void ViewManager::editView() |
304 | { | 309 | { |
305 | if ( !mActiveView ) | 310 | if ( !mActiveView ) |
306 | return; | 311 | return; |
307 | 312 | ||
308 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); | 313 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); |
309 | ViewConfigureWidget *wdg = 0; | 314 | ViewConfigureWidget *wdg = 0; |
310 | ViewConfigureDialog* dlg = 0; | 315 | ViewConfigureDialog* dlg = 0; |
311 | if ( factory ) { | 316 | if ( factory ) { |
312 | // Save the filters so the dialog has the latest set | 317 | // Save the filters so the dialog has the latest set |
313 | Filter::save( mCore->config(), "Filter", mFilterList ); | 318 | Filter::save( mCore->config(), "Filter", mFilterList ); |
314 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); | 319 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); |
315 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); | 320 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); |
316 | } else { | 321 | } else { |
317 | qDebug("ViewManager::editView()::cannot find viewfactory "); | 322 | qDebug("ViewManager::editView()::cannot find viewfactory "); |
318 | return; | 323 | return; |
319 | } | 324 | } |
320 | if ( wdg ) { | 325 | if ( wdg ) { |
321 | dlg->setWidget( wdg ); | 326 | dlg->setWidget( wdg ); |
322 | 327 | ||
323 | #ifndef DESKTOP_VERSION | 328 | #ifndef DESKTOP_VERSION |
324 | //dlg.setMaximumSize( 640, 480 ); | 329 | //dlg.setMaximumSize( 640, 480 ); |
325 | //dlg->setGeometry( 40,40, 400, 300); | 330 | //dlg->setGeometry( 40,40, 400, 300); |
326 | dlg->showMaximized(); | 331 | dlg->showMaximized(); |
327 | #endif | 332 | #endif |
328 | 333 | ||
329 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); | 334 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); |
330 | 335 | ||
331 | dlg->restoreSettings( mCore->config() ); | 336 | dlg->restoreSettings( mCore->config() ); |
332 | 337 | ||
333 | if ( dlg->exec() ) { | 338 | if ( dlg->exec() ) { |
334 | dlg->saveSettings( mCore->config() ); | 339 | dlg->saveSettings( mCore->config() ); |
335 | mActiveView->readConfig( mCore->config() ); | 340 | mActiveView->readConfig( mCore->config() ); |
336 | 341 | ||
337 | // Set the proper filter in the view. By setting the combo | 342 | // Set the proper filter in the view. By setting the combo |
338 | // box, the activated slot will be called, which will push | 343 | // box, the activated slot will be called, which will push |
339 | // the filter to the view and refresh it. | 344 | // the filter to the view and refresh it. |
340 | if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { | 345 | if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { |
341 | mActionSelectFilter->setCurrentItem( 0 ); | 346 | mActionSelectFilter->setCurrentItem( 0 ); |
342 | setActiveFilter( 0 ); | 347 | setActiveFilter( 0 ); |
343 | } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { | 348 | } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { |
344 | setActiveFilter( mActionSelectFilter->currentItem() ); | 349 | setActiveFilter( mActionSelectFilter->currentItem() ); |
345 | } else { | 350 | } else { |
346 | uint pos = filterPosition( mActiveView->defaultFilterName() ); | 351 | uint pos = filterPosition( mActiveView->defaultFilterName() ); |
347 | mActionSelectFilter->setCurrentItem( pos ); | 352 | mActionSelectFilter->setCurrentItem( pos ); |
348 | setActiveFilter( pos ); | 353 | setActiveFilter( pos ); |
349 | } | 354 | } |
350 | mCore->setSearchFields( mActiveView->fields() ); | 355 | mCore->setSearchFields( mActiveView->fields() ); |
351 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() | 356 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
352 | //US mActiveView->refresh(); | 357 | //US mActiveView->refresh(); |
353 | 358 | ||
354 | 359 | ||
355 | //US this is a bugfix, that we get notified if we change a views configuration | 360 | //US this is a bugfix, that we get notified if we change a views configuration |
356 | emit modified(); | 361 | emit modified(); |
357 | 362 | ||
358 | } | 363 | } |
359 | 364 | ||
360 | } | 365 | } |
361 | delete dlg; | 366 | delete dlg; |
362 | } | 367 | } |
363 | 368 | ||
364 | void ViewManager::deleteView() | 369 | void ViewManager::deleteView() |
365 | { | 370 | { |
366 | QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) | 371 | QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) |
367 | .arg( mActiveView->caption() ); | 372 | .arg( mActiveView->caption() ); |
368 | QString caption = i18n( "Confirm Delete" ); | 373 | QString caption = i18n( "Confirm Delete" ); |
369 | 374 | ||
370 | 375 | ||
371 | if (QMessageBox::information( this, caption, | 376 | if (QMessageBox::information( this, caption, |
372 | text, | 377 | text, |
373 | i18n("Yes!"), i18n("No"), 0, 0 ) == 0) | 378 | i18n("Yes!"), i18n("No"), 0, 0 ) == 0) |
374 | { | 379 | { |
375 | mViewNameList.remove( mActiveView->caption() ); | 380 | mViewNameList.remove( mActiveView->caption() ); |
376 | 381 | ||
377 | // remove the view from the config file | 382 | // remove the view from the config file |
378 | KConfig *config = mCore->config(); | 383 | KConfig *config = mCore->config(); |
379 | config->deleteGroup( mActiveView->caption() ); | 384 | config->deleteGroup( mActiveView->caption() ); |
380 | 385 | ||
381 | mViewDict.remove( mActiveView->caption() ); | 386 | mViewDict.remove( mActiveView->caption() ); |
382 | mActiveView = 0; | 387 | mActiveView = 0; |
383 | 388 | ||
384 | // we are in an invalid state now, but that should be fixed after | 389 | // we are in an invalid state now, but that should be fixed after |
385 | // we emit the signal | 390 | // we emit the signal |
386 | mActionSelectView->setItems( mViewNameList ); | 391 | mActionSelectView->setItems( mViewNameList ); |
387 | if ( mViewNameList.count() > 0 ) { | 392 | if ( mViewNameList.count() > 0 ) { |
388 | mActionSelectView->setCurrentItem( 0 ); | 393 | mActionSelectView->setCurrentItem( 0 ); |
389 | setActiveView( mViewNameList[ 0 ] ); | 394 | setActiveView( mViewNameList[ 0 ] ); |
390 | } | 395 | } |
391 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 396 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
392 | } | 397 | } |
393 | } | 398 | } |
394 | 399 | ||
395 | void ViewManager::addView() | 400 | void ViewManager::addView() |
396 | { | 401 | { |
397 | AddViewDialog dialog( &mViewFactoryDict, this ); | 402 | AddViewDialog dialog( &mViewFactoryDict, this ); |
398 | 403 | ||
399 | if ( dialog.exec() ) { | 404 | if ( dialog.exec() ) { |
400 | QString newName = dialog.viewName(); | 405 | QString newName = dialog.viewName(); |
401 | QString type = dialog.viewType(); | 406 | QString type = dialog.viewType(); |
402 | 407 | ||
403 | // Check for name conflicts | 408 | // Check for name conflicts |
404 | bool firstConflict = true; | 409 | bool firstConflict = true; |
405 | int numTries = 1; | 410 | int numTries = 1; |
406 | while ( mViewNameList.contains( newName ) > 0 ) { | 411 | while ( mViewNameList.contains( newName ) > 0 ) { |
407 | if ( !firstConflict ) { | 412 | if ( !firstConflict ) { |
408 | newName = newName.left( newName.length() - 4 ); | 413 | newName = newName.left( newName.length() - 4 ); |
409 | firstConflict = false; | 414 | firstConflict = false; |
410 | } | 415 | } |
411 | 416 | ||
412 | newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); | 417 | newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); |
413 | numTries++; | 418 | numTries++; |
414 | } | 419 | } |
415 | 420 | ||
416 | // Add the new one to the list | 421 | // Add the new one to the list |
417 | mViewNameList.append( newName ); | 422 | mViewNameList.append( newName ); |
418 | 423 | ||
419 | // write the view to the config file, | 424 | // write the view to the config file, |
420 | KConfig *config = mCore->config(); | 425 | KConfig *config = mCore->config(); |
421 | 426 | ||
422 | config->deleteGroup( newName ); | 427 | config->deleteGroup( newName ); |
423 | 428 | ||
424 | KConfigGroupSaver saver( config, newName ); | 429 | KConfigGroupSaver saver( config, newName ); |
425 | 430 | ||
426 | config->writeEntry( "Type", type ); | 431 | config->writeEntry( "Type", type ); |
427 | 432 | ||
428 | // try to set the active view | 433 | // try to set the active view |
429 | mActionSelectView->setItems( mViewNameList ); | 434 | mActionSelectView->setItems( mViewNameList ); |
430 | mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); | 435 | mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); |
431 | setActiveView( newName ); | 436 | setActiveView( newName ); |
432 | 437 | ||
433 | editView(); | 438 | editView(); |
434 | 439 | ||
435 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 440 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
436 | } | 441 | } |
437 | } | 442 | } |
438 | 443 | ||
439 | void ViewManager::createViewFactories() | 444 | void ViewManager::createViewFactories() |
440 | { | 445 | { |
441 | #ifndef KAB_EMBEDDED | 446 | #ifndef KAB_EMBEDDED |
442 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); | 447 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); |
443 | KTrader::OfferList::ConstIterator it; | 448 | KTrader::OfferList::ConstIterator it; |
444 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 449 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
445 | if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) | 450 | if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) |
446 | continue; | 451 | continue; |
447 | 452 | ||
448 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); | 453 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); |
449 | 454 | ||
450 | if ( !factory ) { | 455 | if ( !factory ) { |
451 | kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; | 456 | kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; |
452 | continue; | 457 | continue; |
453 | } | 458 | } |
454 | 459 | ||
455 | ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); | 460 | ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); |
456 | 461 | ||
457 | if ( !viewFactory ) { | 462 | if ( !viewFactory ) { |
458 | kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; | 463 | kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; |
459 | continue; | 464 | continue; |
460 | } | 465 | } |
461 | 466 | ||
462 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 467 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
463 | } | 468 | } |
464 | 469 | ||
465 | #else //KAB_EMBEDDED | 470 | #else //KAB_EMBEDDED |
466 | ViewFactory* viewFactory = new IconViewFactory(); | 471 | ViewFactory* viewFactory = new IconViewFactory(); |
467 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 472 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
468 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 473 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
469 | 474 | ||
470 | viewFactory = new TableViewFactory(); | 475 | viewFactory = new TableViewFactory(); |
471 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 476 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
472 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 477 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
473 | 478 | ||
474 | viewFactory = new CardViewFactory(); | 479 | viewFactory = new CardViewFactory(); |
475 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 480 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
476 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 481 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
477 | 482 | ||
478 | #endif //KAB_EMBEDDED | 483 | #endif //KAB_EMBEDDED |
479 | 484 | ||
480 | } | 485 | } |
481 | 486 | ||
482 | void ViewManager::dropped( QDropEvent *e ) | 487 | void ViewManager::dropped( QDropEvent *e ) |
483 | { | 488 | { |
484 | kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; | 489 | kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; |
485 | 490 | ||
486 | #ifndef KAB_EMBEDDED | 491 | #ifndef KAB_EMBEDDED |
487 | 492 | ||
488 | QString clipText, vcards; | 493 | QString clipText, vcards; |
489 | KURL::List urls; | 494 | KURL::List urls; |
490 | 495 | ||
491 | if ( KURLDrag::decode( e, urls) ) { | 496 | if ( KURLDrag::decode( e, urls) ) { |
492 | KURL::List::Iterator it = urls.begin(); | 497 | KURL::List::Iterator it = urls.begin(); |
493 | int c = urls.count(); | 498 | int c = urls.count(); |
494 | if ( c > 1 ) { | 499 | if ( c > 1 ) { |
495 | QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); | 500 | QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); |
496 | if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { | 501 | if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { |
497 | for ( ; it != urls.end(); ++it ) | 502 | for ( ; it != urls.end(); ++it ) |
498 | emit urlDropped( *it ); | 503 | emit urlDropped( *it ); |
499 | } | 504 | } |
500 | } else if ( c == 1 ) | 505 | } else if ( c == 1 ) |
501 | emit urlDropped( *it ); | 506 | emit urlDropped( *it ); |
502 | } else if ( KVCardDrag::decode( e, vcards ) ) { | 507 | } else if ( KVCardDrag::decode( e, vcards ) ) { |
503 | KABC::Addressee addr; | 508 | KABC::Addressee addr; |
504 | KABC::VCardConverter converter; | 509 | KABC::VCardConverter converter; |
505 | QStringList list = QStringList::split( "\r\n\r\n", vcards ); | 510 | QStringList list = QStringList::split( "\r\n\r\n", vcards ); |
506 | QStringList::Iterator it; | 511 | QStringList::Iterator it; |
507 | for ( it = list.begin(); it != list.end(); ++it ) { | 512 | for ( it = list.begin(); it != list.end(); ++it ) { |
508 | if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { | 513 | if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { |
509 | KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); | 514 | KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); |
510 | if ( a.isEmpty() ) { | 515 | if ( a.isEmpty() ) { |
511 | mCore->addressBook()->insertAddressee( addr ); | 516 | mCore->addressBook()->insertAddressee( addr ); |
512 | emit modified(); | 517 | emit modified(); |
513 | } | 518 | } |
514 | } | 519 | } |
515 | } | 520 | } |
516 | 521 | ||
517 | mActiveView->refresh(); | 522 | mActiveView->refresh(); |
518 | } | 523 | } |
519 | #else //KAB_EMBEDDED | 524 | #else //KAB_EMBEDDED |
520 | qDebug("ViewManager::dropped() has to be changed!!" ); | 525 | qDebug("ViewManager::dropped() has to be changed!!" ); |
521 | #endif //KAB_EMBEDDED | 526 | #endif //KAB_EMBEDDED |
522 | 527 | ||
523 | } | 528 | } |
524 | 529 | ||
525 | void ViewManager::startDrag() | 530 | void ViewManager::startDrag() |
526 | { | 531 | { |
527 | kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; | 532 | kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; |
528 | 533 | ||
529 | #ifndef KAB_EMBEDDED | 534 | #ifndef KAB_EMBEDDED |
530 | 535 | ||
531 | // Get the list of all the selected addressees | 536 | // Get the list of all the selected addressees |
532 | KABC::Addressee::List addrList; | 537 | KABC::Addressee::List addrList; |
533 | QStringList uidList = selectedUids(); | 538 | QStringList uidList = selectedUids(); |
534 | QStringList::Iterator iter; | 539 | QStringList::Iterator iter; |
535 | for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) | 540 | for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) |
536 | addrList.append( mCore->addressBook()->findByUid( *iter ) ); | 541 | addrList.append( mCore->addressBook()->findByUid( *iter ) ); |
537 | 542 | ||
538 | KMultipleDrag *drag = new KMultipleDrag( this ); | 543 | KMultipleDrag *drag = new KMultipleDrag( this ); |
539 | drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); | 544 | drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); |
540 | KABC::Addressee::List::Iterator it; | 545 | KABC::Addressee::List::Iterator it; |
541 | QStringList vcards; | 546 | QStringList vcards; |
542 | for ( it = addrList.begin(); it != addrList.end(); ++it ) { | 547 | for ( it = addrList.begin(); it != addrList.end(); ++it ) { |
543 | QString vcard = QString::null; | 548 | QString vcard = QString::null; |
544 | KABC::VCardConverter converter; | 549 | KABC::VCardConverter converter; |
545 | if ( converter.addresseeToVCard( *it, vcard ) ) | 550 | if ( converter.addresseeToVCard( *it, vcard ) ) |
546 | vcards.append( vcard ); | 551 | vcards.append( vcard ); |
547 | } | 552 | } |
548 | drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); | 553 | drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); |
549 | 554 | ||
550 | drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); | 555 | drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); |
551 | drag->dragCopy(); | 556 | drag->dragCopy(); |
552 | 557 | ||
553 | #else //KAB_EMBEDDED | 558 | #else //KAB_EMBEDDED |
554 | qDebug("ViewManager::startDrag() has to be changed!!" ); | 559 | qDebug("ViewManager::startDrag() has to be changed!!" ); |
555 | #endif //KAB_EMBEDDED | 560 | #endif //KAB_EMBEDDED |
556 | 561 | ||
557 | } | 562 | } |
558 | void ViewManager::doSearch( const QString& s,KABC::Field *field ) | 563 | void ViewManager::doSearch( const QString& s,KABC::Field *field ) |
559 | { | 564 | { |
560 | if ( mActiveView ) | 565 | if ( mActiveView ) |
561 | mActiveView->doSearch( s, field ); | 566 | mActiveView->doSearch( s, field ); |
562 | 567 | ||
563 | } | 568 | } |
564 | void ViewManager::setActiveFilter( int index ) | 569 | void ViewManager::setActiveFilter( int index ) |
565 | { | 570 | { |
566 | Filter currentFilter; | 571 | Filter currentFilter; |
567 | 572 | ||
568 | if ( ( index - 1 ) < 0 ) | 573 | if ( ( index - 1 ) < 0 ) |
569 | currentFilter = Filter(); | 574 | currentFilter = Filter(); |
570 | else | 575 | else |
571 | currentFilter = mFilterList[ index - 1 ]; | 576 | currentFilter = mFilterList[ index - 1 ]; |
572 | 577 | ||
573 | // Check if we have a view. Since the filter combo is created before | 578 | // Check if we have a view. Since the filter combo is created before |
574 | // the view, this slot could be called before there is a valid view. | 579 | // the view, this slot could be called before there is a valid view. |
575 | if ( mActiveView ) { | 580 | if ( mActiveView ) { |
576 | mActiveView->setFilter( currentFilter ); | 581 | mActiveView->setFilter( currentFilter ); |
577 | mActiveView->refresh(); | 582 | mActiveView->refresh(); |
578 | emit selected( QString::null ); | 583 | emit selected( QString::null ); |
579 | } | 584 | } |
580 | } | 585 | } |
581 | 586 | ||
582 | void ViewManager::configureFilters() | 587 | void ViewManager::configureFilters() |
583 | { | 588 | { |
584 | FilterDialog dlg( this ); | 589 | FilterDialog dlg( this ); |
585 | 590 | ||
586 | dlg.setFilters( mFilterList ); | 591 | dlg.setFilters( mFilterList ); |
587 | 592 | ||
588 | if ( dlg.exec() ) | 593 | if ( dlg.exec() ) |
589 | mFilterList = dlg.filters(); | 594 | mFilterList = dlg.filters(); |
590 | 595 | ||
591 | uint pos = mActionSelectFilter->currentItem(); | 596 | uint pos = mActionSelectFilter->currentItem(); |
592 | mActionSelectFilter->setItems( filterNames() ); | 597 | mActionSelectFilter->setItems( filterNames() ); |
593 | mActionSelectFilter->setCurrentItem( pos ); | 598 | mActionSelectFilter->setCurrentItem( pos ); |
594 | setActiveFilter( pos ); | 599 | setActiveFilter( pos ); |
595 | } | 600 | } |
596 | 601 | ||
597 | QStringList ViewManager::filterNames() const | 602 | QStringList ViewManager::filterNames() const |
598 | { | 603 | { |
599 | QStringList names( i18n( "No Filter" ) ); | 604 | QStringList names( i18n( "No Filter" ) ); |
600 | 605 | ||
601 | Filter::List::ConstIterator it; | 606 | Filter::List::ConstIterator it; |
602 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) | 607 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) |
603 | names.append( (*it).name() ); | 608 | names.append( (*it).name() ); |
604 | 609 | ||
605 | return names; | 610 | return names; |
606 | } | 611 | } |
607 | 612 | ||
608 | int ViewManager::filterPosition( const QString &name ) const | 613 | int ViewManager::filterPosition( const QString &name ) const |
609 | { | 614 | { |
610 | int pos = 0; | 615 | int pos = 0; |
611 | 616 | ||
612 | Filter::List::ConstIterator it; | 617 | Filter::List::ConstIterator it; |
613 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) | 618 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) |
614 | if ( name == (*it).name() ) | 619 | if ( name == (*it).name() ) |
615 | return pos + 1; | 620 | return pos + 1; |
616 | 621 | ||
617 | return 0; | 622 | return 0; |
618 | } | 623 | } |
619 | 624 | ||
620 | void ViewManager::initActions() | 625 | void ViewManager::initActions() |
621 | { | 626 | { |
622 | //US <ActionList name="view_loadedviews"/> | 627 | //US <ActionList name="view_loadedviews"/> |
623 | //US <Separator/> | 628 | //US <Separator/> |
624 | 629 | ||
625 | #ifdef KAB_EMBEDDED | 630 | #ifdef KAB_EMBEDDED |
626 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); | 631 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); |
627 | QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); | 632 | QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); |
628 | QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); | 633 | QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); |
629 | #endif //KAB_EMBEDDED | 634 | #endif //KAB_EMBEDDED |
630 | 635 | ||
631 | mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); | 636 | mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); |
632 | #if KDE_VERSION >= 309 | 637 | #if KDE_VERSION >= 309 |
633 | mActionSelectView->setMenuAccelsEnabled( false ); | 638 | mActionSelectView->setMenuAccelsEnabled( false ); |
634 | #endif | 639 | #endif |
635 | connect( mActionSelectView, SIGNAL( activated( const QString& ) ), | 640 | connect( mActionSelectView, SIGNAL( activated( const QString& ) ), |
636 | SLOT( setActiveView( const QString& ) ) ); | 641 | SLOT( setActiveView( const QString& ) ) ); |
637 | 642 | ||
638 | 643 | ||
639 | #ifdef KAB_EMBEDDED | 644 | #ifdef KAB_EMBEDDED |
640 | mActionSelectView->plug(viewmenu); | 645 | mActionSelectView->plug(viewmenu); |
641 | viewmenu->insertSeparator(); | 646 | viewmenu->insertSeparator(); |
642 | #endif //KAB_EMBEDDED | 647 | #endif //KAB_EMBEDDED |
643 | 648 | ||
644 | KAction *action; | 649 | KAction *action; |
645 | 650 | ||
646 | action = new KAction( i18n( "Modify View..." ), "configure", 0, this, | 651 | action = new KAction( i18n( "Modify View..." ), "configure", 0, this, |
647 | SLOT( editView() ), mCore->actionCollection(), "view_modify" ); | 652 | SLOT( editView() ), mCore->actionCollection(), "view_modify" ); |
648 | #ifndef KAB_EMBEDDED | 653 | #ifndef KAB_EMBEDDED |
649 | action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); | 654 | action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); |
650 | #else //KAB_EMBEDDED | 655 | #else //KAB_EMBEDDED |
651 | action->plug(viewmenu); | 656 | action->plug(viewmenu); |
652 | #endif //KAB_EMBEDDED | 657 | #endif //KAB_EMBEDDED |
653 | 658 | ||
654 | action = new KAction( i18n( "Add View..." ), "window_new", 0, this, | 659 | action = new KAction( i18n( "Add View..." ), "window_new", 0, this, |
655 | SLOT( addView() ), mCore->actionCollection(), "view_add" ); | 660 | SLOT( addView() ), mCore->actionCollection(), "view_add" ); |
656 | #ifndef KAB_EMBEDDED | 661 | #ifndef KAB_EMBEDDED |
657 | action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) ); | 662 | action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) ); |
658 | #else //KAB_EMBEDDED | 663 | #else //KAB_EMBEDDED |
659 | action->plug(viewmenu); | 664 | action->plug(viewmenu); |
660 | #endif //KAB_EMBEDDED | 665 | #endif //KAB_EMBEDDED |
661 | 666 | ||
662 | mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, | 667 | mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, |
663 | this, SLOT( deleteView() ), | 668 | this, SLOT( deleteView() ), |
664 | mCore->actionCollection(), "view_delete" ); | 669 | mCore->actionCollection(), "view_delete" ); |
665 | #ifndef KAB_EMBEDDED | 670 | #ifndef KAB_EMBEDDED |
666 | mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); | 671 | mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); |
667 | #else //KAB_EMBEDDED | 672 | #else //KAB_EMBEDDED |
668 | mActionDeleteView->plug(viewmenu); | 673 | mActionDeleteView->plug(viewmenu); |
669 | viewmenu->insertSeparator(); | 674 | viewmenu->insertSeparator(); |
670 | #endif //KAB_EMBEDDED | 675 | #endif //KAB_EMBEDDED |
671 | 676 | ||
672 | #ifndef KAB_EMBEDDED | 677 | #ifndef KAB_EMBEDDED |
673 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, | 678 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, |
674 | SLOT( refreshView(const QString &) ), mCore->actionCollection(), | 679 | SLOT( refreshView(const QString &) ), mCore->actionCollection(), |
675 | "view_refresh" ); | 680 | "view_refresh" ); |
676 | action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); | 681 | action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); |
677 | #else //KAB_EMBEDDED | 682 | #else //KAB_EMBEDDED |
678 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, | 683 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, |
679 | SLOT( refreshView()), mCore->actionCollection(), | 684 | SLOT( refreshView()), mCore->actionCollection(), |
680 | "view_refresh" ); | 685 | "view_refresh" ); |
681 | action->plug(viewmenu); | 686 | action->plug(viewmenu); |
682 | viewmenu->insertSeparator(); | 687 | viewmenu->insertSeparator(); |
683 | #endif //KAB_EMBEDDED | 688 | #endif //KAB_EMBEDDED |
684 | 689 | ||
685 | action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, | 690 | action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, |
686 | SLOT( configureFilters() ), mCore->actionCollection(), | 691 | SLOT( configureFilters() ), mCore->actionCollection(), |
687 | "options_edit_filters" ); | 692 | "options_edit_filters" ); |
688 | 693 | ||
689 | mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); | 694 | mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); |
690 | 695 | ||
691 | #if KDE_VERSION >= 309 | 696 | #if KDE_VERSION >= 309 |
692 | mActionSelectFilter->setMenuAccelsEnabled( false ); | 697 | mActionSelectFilter->setMenuAccelsEnabled( false ); |
693 | #endif | 698 | #endif |
694 | connect( mActionSelectFilter, SIGNAL( activated( int ) ), | 699 | connect( mActionSelectFilter, SIGNAL( activated( int ) ), |
695 | SLOT( setActiveFilter( int ) ) ); | 700 | SLOT( setActiveFilter( int ) ) ); |
696 | 701 | ||
697 | #ifdef KAB_EMBEDDED | 702 | #ifdef KAB_EMBEDDED |
698 | action->plug(settingsmenu); | 703 | action->plug(settingsmenu); |
699 | mActionSelectFilter->plug(viewmenu); | 704 | mActionSelectFilter->plug(viewmenu); |
700 | #endif //KAB_EMBEDDED | 705 | #endif //KAB_EMBEDDED |
701 | 706 | ||
702 | } | 707 | } |
703 | 708 | ||
704 | void ViewManager::initGUI() | 709 | void ViewManager::initGUI() |
705 | { | 710 | { |
706 | QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); | 711 | QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); |
707 | mViewWidgetStack = new QWidgetStack( this ); | 712 | mViewWidgetStack = new QWidgetStack( this ); |
708 | layout->addWidget( mViewWidgetStack ); | 713 | layout->addWidget( mViewWidgetStack ); |
709 | } | 714 | } |
710 | 715 | ||
711 | #ifndef KAB_EMBEDDED | 716 | #ifndef KAB_EMBEDDED |
712 | #include "viewmanager.moc" | 717 | #include "viewmanager.moc" |
713 | #endif //KAB_EMBEDDED | 718 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h index 585f4e9..a03a83f 100644 --- a/kaddressbook/viewmanager.h +++ b/kaddressbook/viewmanager.h | |||
@@ -1,156 +1,157 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef VIEWMANAGER_H | 24 | #ifndef VIEWMANAGER_H |
25 | #define VIEWMANAGER_H | 25 | #define VIEWMANAGER_H |
26 | 26 | ||
27 | #include <qwidget.h> | 27 | #include <qwidget.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <kaddressbookview.h> | 29 | #include <kaddressbookview.h> |
30 | #include <qdict.h> | 30 | #include <qdict.h> |
31 | 31 | ||
32 | class KAction; | 32 | class KAction; |
33 | class KSelectAction; | 33 | class KSelectAction; |
34 | 34 | ||
35 | class KABCore; | 35 | class KABCore; |
36 | class QWidgetStack; | 36 | class QWidgetStack; |
37 | class QDropEvent; | 37 | class QDropEvent; |
38 | 38 | ||
39 | namespace KABC { class AddressBook; } | 39 | namespace KABC { class AddressBook; } |
40 | 40 | ||
41 | /** | 41 | /** |
42 | The view manager manages the views and everything related to them. The | 42 | The view manager manages the views and everything related to them. The |
43 | manager will load the views at startup and display a view when told to | 43 | manager will load the views at startup and display a view when told to |
44 | make one active. | 44 | make one active. |
45 | 45 | ||
46 | The view manager will also create and manage all dialogs directly related to | 46 | The view manager will also create and manage all dialogs directly related to |
47 | views (ie: AddView, ConfigureView, DeleteView, etc). | 47 | views (ie: AddView, ConfigureView, DeleteView, etc). |
48 | */ | 48 | */ |
49 | class ViewManager : public QWidget | 49 | class ViewManager : public QWidget |
50 | { | 50 | { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | public: | 52 | public: |
53 | ViewManager( KABCore *core, QWidget *parent, const char *name = 0 ); | 53 | ViewManager( KABCore *core, QWidget *parent, const char *name = 0 ); |
54 | ~ViewManager(); | 54 | ~ViewManager(); |
55 | 55 | ||
56 | void restoreSettings(); | 56 | void restoreSettings(); |
57 | void saveSettings(); | 57 | void saveSettings(); |
58 | void doSearch( const QString& s ,KABC::Field *field ); | 58 | void doSearch( const QString& s ,KABC::Field *field ); |
59 | 59 | ||
60 | void unloadViews(); | 60 | void unloadViews(); |
61 | KSelectAction * getFilterAction() { return mActionSelectFilter; } | 61 | KSelectAction * getFilterAction() { return mActionSelectFilter; } |
62 | 62 | ||
63 | QStringList selectedUids() const; | 63 | QStringList selectedUids() const; |
64 | QStringList selectedEmails() const; | 64 | QStringList selectedEmails() const; |
65 | KABC::Addressee::List selectedAddressees() const; | 65 | KABC::Addressee::List selectedAddressees() const; |
66 | void setListSelected(QStringList); | 66 | void setListSelected(QStringList); |
67 | void setFocusAV(); | ||
67 | 68 | ||
68 | public slots: | 69 | public slots: |
69 | void scrollUP(); | 70 | void scrollUP(); |
70 | void scrollDOWN(); | 71 | void scrollDOWN(); |
71 | 72 | ||
72 | //US void setSelected( const QString &uid = QString::null, bool selected = true ); | 73 | //US void setSelected( const QString &uid = QString::null, bool selected = true ); |
73 | void setSelected( const QString &uid, bool); | 74 | void setSelected( const QString &uid, bool); |
74 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 75 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
75 | void setSelected(); | 76 | void setSelected(); |
76 | 77 | ||
77 | 78 | ||
78 | 79 | ||
79 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 80 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
80 | void refreshView(); | 81 | void refreshView(); |
81 | void refreshView( const QString &uid); | 82 | void refreshView( const QString &uid); |
82 | 83 | ||
83 | void editView(); | 84 | void editView(); |
84 | void deleteView(); | 85 | void deleteView(); |
85 | void addView(); | 86 | void addView(); |
86 | 87 | ||
87 | protected slots: | 88 | protected slots: |
88 | /** | 89 | /** |
89 | Called whenever the user drops something in the active view. | 90 | Called whenever the user drops something in the active view. |
90 | This method will try to decode what was dropped, and if it was | 91 | This method will try to decode what was dropped, and if it was |
91 | a valid addressee, add it to the addressbook. | 92 | a valid addressee, add it to the addressbook. |
92 | */ | 93 | */ |
93 | void dropped( QDropEvent* ); | 94 | void dropped( QDropEvent* ); |
94 | 95 | ||
95 | /** | 96 | /** |
96 | Called whenever the user attempts to start a drag in the view. | 97 | Called whenever the user attempts to start a drag in the view. |
97 | This method will convert all the selected addressees into text (vcard) | 98 | This method will convert all the selected addressees into text (vcard) |
98 | and create a drag object. | 99 | and create a drag object. |
99 | */ | 100 | */ |
100 | void startDrag(); | 101 | void startDrag(); |
101 | 102 | ||
102 | signals: | 103 | signals: |
103 | /** | 104 | /** |
104 | Emitted whenever the user selects an entry in the view. | 105 | Emitted whenever the user selects an entry in the view. |
105 | */ | 106 | */ |
106 | void selected( const QString &uid ); | 107 | void selected( const QString &uid ); |
107 | void deleteRequest( ); | 108 | void deleteRequest( ); |
108 | 109 | ||
109 | /** | 110 | /** |
110 | Emitted whenever the user activates an entry in the view. | 111 | Emitted whenever the user activates an entry in the view. |
111 | */ | 112 | */ |
112 | void executed( const QString &uid ); | 113 | void executed( const QString &uid ); |
113 | 114 | ||
114 | /** | 115 | /** |
115 | Emitted whenever the address book is modified in some way. | 116 | Emitted whenever the address book is modified in some way. |
116 | */ | 117 | */ |
117 | void modified(); | 118 | void modified(); |
118 | 119 | ||
119 | /** | 120 | /** |
120 | Emitted whenever a url is dragged on a view. | 121 | Emitted whenever a url is dragged on a view. |
121 | */ | 122 | */ |
122 | void urlDropped( const KURL& ); | 123 | void urlDropped( const KURL& ); |
123 | 124 | ||
124 | private slots: | 125 | private slots: |
125 | void setActiveView( const QString &name ); | 126 | void setActiveView( const QString &name ); |
126 | void setActiveFilter( int index ); | 127 | void setActiveFilter( int index ); |
127 | void configureFilters(); | 128 | void configureFilters(); |
128 | 129 | ||
129 | private: | 130 | private: |
130 | void createViewFactories(); | 131 | void createViewFactories(); |
131 | QStringList filterNames() const; | 132 | QStringList filterNames() const; |
132 | int filterPosition( const QString &name ) const; | 133 | int filterPosition( const QString &name ) const; |
133 | QStringList viewNames() const; | 134 | QStringList viewNames() const; |
134 | int viewPosition( const QString &name ) const; | 135 | int viewPosition( const QString &name ) const; |
135 | void initActions(); | 136 | void initActions(); |
136 | void initGUI(); | 137 | void initGUI(); |
137 | 138 | ||
138 | KABCore *mCore; | 139 | KABCore *mCore; |
139 | 140 | ||
140 | Filter mCurrentFilter; | 141 | Filter mCurrentFilter; |
141 | Filter::List mFilterList; | 142 | Filter::List mFilterList; |
142 | 143 | ||
143 | QDict<KAddressBookView> mViewDict; | 144 | QDict<KAddressBookView> mViewDict; |
144 | QDict<ViewFactory> mViewFactoryDict; | 145 | QDict<ViewFactory> mViewFactoryDict; |
145 | QStringList mViewNameList; | 146 | QStringList mViewNameList; |
146 | 147 | ||
147 | QWidgetStack *mViewWidgetStack; | 148 | QWidgetStack *mViewWidgetStack; |
148 | KAddressBookView *mActiveView; | 149 | KAddressBookView *mActiveView; |
149 | 150 | ||
150 | KAction *mActionDeleteView; | 151 | KAction *mActionDeleteView; |
151 | KSelectAction *mActionSelectFilter; | 152 | KSelectAction *mActionSelectFilter; |
152 | KSelectAction *mActionSelectView; | 153 | KSelectAction *mActionSelectView; |
153 | 154 | ||
154 | }; | 155 | }; |
155 | 156 | ||
156 | #endif | 157 | #endif |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 326db88..6e61351 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -162,1793 +162,1793 @@ class KOBeamPrefs : public QDialog | |||
162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
163 | lay->addWidget( ok ); | 163 | lay->addWidget( ok ); |
164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
165 | lay->addWidget( cancel ); | 165 | lay->addWidget( cancel ); |
166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
168 | resize( 200, 200 ); | 168 | resize( 200, 200 ); |
169 | } | 169 | } |
170 | 170 | ||
171 | bool beamVcal() { return vcal->isChecked(); } | 171 | bool beamVcal() { return vcal->isChecked(); } |
172 | bool beamLocal() { return local->isChecked(); } | 172 | bool beamLocal() { return local->isChecked(); } |
173 | private: | 173 | private: |
174 | QRadioButton* vcal, *ical, *local, *tz; | 174 | QRadioButton* vcal, *ical, *local, *tz; |
175 | }; | 175 | }; |
176 | class KOCatPrefs : public QDialog | 176 | class KOCatPrefs : public QDialog |
177 | { | 177 | { |
178 | public: | 178 | public: |
179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
180 | QDialog( parent, name, true ) | 180 | QDialog( parent, name, true ) |
181 | { | 181 | { |
182 | setCaption( i18n("Manage new Categories") ); | 182 | setCaption( i18n("Manage new Categories") ); |
183 | QVBoxLayout* lay = new QVBoxLayout( this ); | 183 | QVBoxLayout* lay = new QVBoxLayout( this ); |
184 | lay->setSpacing( 3 ); | 184 | lay->setSpacing( 3 ); |
185 | lay->setMargin( 3 ); | 185 | lay->setMargin( 3 ); |
186 | 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 ); | 186 | 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 ); |
187 | lay->addWidget( lab ); | 187 | lay->addWidget( lab ); |
188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
189 | lay->addWidget( format ); | 189 | lay->addWidget( format ); |
190 | format->setExclusive ( true ) ; | 190 | format->setExclusive ( true ) ; |
191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
193 | addCatBut->setChecked( true ); | 193 | addCatBut->setChecked( true ); |
194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
195 | lay->addWidget( ok ); | 195 | lay->addWidget( ok ); |
196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
197 | lay->addWidget( cancel ); | 197 | lay->addWidget( cancel ); |
198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
200 | resize( 200, 200 ); | 200 | resize( 200, 200 ); |
201 | } | 201 | } |
202 | 202 | ||
203 | bool addCat() { return addCatBut->isChecked(); } | 203 | bool addCat() { return addCatBut->isChecked(); } |
204 | private: | 204 | private: |
205 | QRadioButton* addCatBut; | 205 | QRadioButton* addCatBut; |
206 | }; | 206 | }; |
207 | 207 | ||
208 | 208 | ||
209 | 209 | ||
210 | CalendarView::CalendarView( CalendarResources *calendar, | 210 | CalendarView::CalendarView( CalendarResources *calendar, |
211 | QWidget *parent, const char *name ) | 211 | QWidget *parent, const char *name ) |
212 | : CalendarViewBase( parent, name ), | 212 | : CalendarViewBase( parent, name ), |
213 | mCalendar( calendar ), | 213 | mCalendar( calendar ), |
214 | mResourceManager( calendar->resourceManager() ) | 214 | mResourceManager( calendar->resourceManager() ) |
215 | { | 215 | { |
216 | 216 | ||
217 | mEventEditor = 0; | 217 | mEventEditor = 0; |
218 | mTodoEditor = 0; | 218 | mTodoEditor = 0; |
219 | 219 | ||
220 | init(); | 220 | init(); |
221 | } | 221 | } |
222 | 222 | ||
223 | CalendarView::CalendarView( Calendar *calendar, | 223 | CalendarView::CalendarView( Calendar *calendar, |
224 | QWidget *parent, const char *name ) | 224 | QWidget *parent, const char *name ) |
225 | : CalendarViewBase( parent, name ), | 225 | : CalendarViewBase( parent, name ), |
226 | mCalendar( calendar ), | 226 | mCalendar( calendar ), |
227 | mResourceManager( 0 ) | 227 | mResourceManager( 0 ) |
228 | { | 228 | { |
229 | 229 | ||
230 | mEventEditor = 0; | 230 | mEventEditor = 0; |
231 | mTodoEditor = 0; | 231 | mTodoEditor = 0; |
232 | init();} | 232 | init();} |
233 | 233 | ||
234 | void CalendarView::init() | 234 | void CalendarView::init() |
235 | { | 235 | { |
236 | beamDialog = new KOBeamPrefs(); | 236 | beamDialog = new KOBeamPrefs(); |
237 | mDatePickerMode = 0; | 237 | mDatePickerMode = 0; |
238 | mCurrentSyncDevice = ""; | 238 | mCurrentSyncDevice = ""; |
239 | writeLocale(); | 239 | writeLocale(); |
240 | mViewManager = new KOViewManager( this ); | 240 | mViewManager = new KOViewManager( this ); |
241 | mDialogManager = new KODialogManager( this ); | 241 | mDialogManager = new KODialogManager( this ); |
242 | mEventViewerDialog = 0; | 242 | mEventViewerDialog = 0; |
243 | mModified = false; | 243 | mModified = false; |
244 | mReadOnly = false; | 244 | mReadOnly = false; |
245 | mSelectedIncidence = 0; | 245 | mSelectedIncidence = 0; |
246 | mCalPrinter = 0; | 246 | mCalPrinter = 0; |
247 | mFilters.setAutoDelete(true); | 247 | mFilters.setAutoDelete(true); |
248 | 248 | ||
249 | mCalendar->registerObserver( this ); | 249 | mCalendar->registerObserver( this ); |
250 | // TODO: Make sure that view is updated, when calendar is changed. | 250 | // TODO: Make sure that view is updated, when calendar is changed. |
251 | 251 | ||
252 | mStorage = new FileStorage( mCalendar ); | 252 | mStorage = new FileStorage( mCalendar ); |
253 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 253 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
254 | 254 | ||
255 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 255 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
256 | #ifndef KORG_NOSPLITTER | 256 | #ifndef KORG_NOSPLITTER |
257 | // create the main layout frames. | 257 | // create the main layout frames. |
258 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 258 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
259 | topLayout->addWidget(mPanner); | 259 | topLayout->addWidget(mPanner); |
260 | 260 | ||
261 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 261 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
262 | "CalendarView::LeftFrame"); | 262 | "CalendarView::LeftFrame"); |
263 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 263 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
264 | 264 | ||
265 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 265 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
266 | "CalendarView::DateNavigator", QDate::currentDate() ); | 266 | "CalendarView::DateNavigator", QDate::currentDate() ); |
267 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 267 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
268 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 268 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
269 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 269 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
270 | 270 | ||
271 | #ifdef KORG_NORESOURCEVIEW | 271 | #ifdef KORG_NORESOURCEVIEW |
272 | mResourceView = 0; | 272 | mResourceView = 0; |
273 | #else | 273 | #else |
274 | if ( mResourceManager ) { | 274 | if ( mResourceManager ) { |
275 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 275 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
276 | mResourceView->updateView(); | 276 | mResourceView->updateView(); |
277 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 277 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
278 | SLOT( updateView() ) ); | 278 | SLOT( updateView() ) ); |
279 | } else { | 279 | } else { |
280 | mResourceView = 0; | 280 | mResourceView = 0; |
281 | } | 281 | } |
282 | #endif | 282 | #endif |
283 | QWidget *rightBox = new QWidget( mPanner ); | 283 | QWidget *rightBox = new QWidget( mPanner ); |
284 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 284 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
285 | 285 | ||
286 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 286 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
287 | rightLayout->addWidget( mNavigatorBar ); | 287 | rightLayout->addWidget( mNavigatorBar ); |
288 | 288 | ||
289 | mRightFrame = new QWidgetStack( rightBox ); | 289 | mRightFrame = new QWidgetStack( rightBox ); |
290 | rightLayout->addWidget( mRightFrame, 1 ); | 290 | rightLayout->addWidget( mRightFrame, 1 ); |
291 | 291 | ||
292 | mLeftFrame = mLeftSplitter; | 292 | mLeftFrame = mLeftSplitter; |
293 | #else | 293 | #else |
294 | QWidget *mainBox = new QWidget( this ); | 294 | QWidget *mainBox = new QWidget( this ); |
295 | QWidget *leftFrame = new QWidget( mainBox ); | 295 | QWidget *leftFrame = new QWidget( mainBox ); |
296 | 296 | ||
297 | QBoxLayout * mainBoxLayout; | 297 | QBoxLayout * mainBoxLayout; |
298 | QBoxLayout * leftFrameLayout; | 298 | QBoxLayout * leftFrameLayout; |
299 | if ( KOPrefs::instance()->mVerticalScreen ) { | 299 | if ( KOPrefs::instance()->mVerticalScreen ) { |
300 | mainBoxLayout = new QVBoxLayout(mainBox); | 300 | mainBoxLayout = new QVBoxLayout(mainBox); |
301 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 301 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
302 | } else { | 302 | } else { |
303 | mainBoxLayout = new QHBoxLayout(mainBox); | 303 | mainBoxLayout = new QHBoxLayout(mainBox); |
304 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 304 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
305 | } | 305 | } |
306 | topLayout->addWidget( mainBox ); | 306 | topLayout->addWidget( mainBox ); |
307 | mainBoxLayout->addWidget (leftFrame); | 307 | mainBoxLayout->addWidget (leftFrame); |
308 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 308 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
309 | "CalendarView::DateNavigator", QDate::currentDate()); | 309 | "CalendarView::DateNavigator", QDate::currentDate()); |
310 | // mDateNavigator->blockSignals( true ); | 310 | // mDateNavigator->blockSignals( true ); |
311 | leftFrameLayout->addWidget( mDateNavigator ); | 311 | leftFrameLayout->addWidget( mDateNavigator ); |
312 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 312 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
313 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); | 313 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); |
314 | 314 | ||
315 | if ( QApplication::desktop()->width() < 480 ) { | 315 | if ( QApplication::desktop()->width() < 480 ) { |
316 | leftFrameLayout->addWidget(mFilterView); | 316 | leftFrameLayout->addWidget(mFilterView); |
317 | leftFrameLayout->addWidget(mTodoList, 2 ); | 317 | leftFrameLayout->addWidget(mTodoList, 2 ); |
318 | 318 | ||
319 | } else { | 319 | } else { |
320 | leftFrameLayout->addWidget(mTodoList,2 ); | 320 | leftFrameLayout->addWidget(mTodoList,2 ); |
321 | leftFrameLayout->addWidget(mFilterView ); | 321 | leftFrameLayout->addWidget(mFilterView ); |
322 | } | 322 | } |
323 | mFilterView->hide(); | 323 | mFilterView->hide(); |
324 | QWidget *rightBox = new QWidget( mainBox ); | 324 | QWidget *rightBox = new QWidget( mainBox ); |
325 | mainBoxLayout->addWidget ( rightBox, 10 ); | 325 | mainBoxLayout->addWidget ( rightBox, 10 ); |
326 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 326 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
327 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 327 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
328 | mRightFrame = new QWidgetStack( rightBox ); | 328 | mRightFrame = new QWidgetStack( rightBox ); |
329 | rightLayout->addWidget( mNavigatorBar ); | 329 | rightLayout->addWidget( mNavigatorBar ); |
330 | rightLayout->addWidget( mRightFrame, 10 ); | 330 | rightLayout->addWidget( mRightFrame, 10 ); |
331 | 331 | ||
332 | mLeftFrame = leftFrame; | 332 | mLeftFrame = leftFrame; |
333 | if ( KOPrefs::instance()->mVerticalScreen ) { | 333 | if ( KOPrefs::instance()->mVerticalScreen ) { |
334 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 334 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
335 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 335 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
336 | } else { | 336 | } else { |
337 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 337 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
338 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 338 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
339 | } | 339 | } |
340 | 340 | ||
341 | //qDebug("Calendarview Size %d %d ", width(), height()); | 341 | //qDebug("Calendarview Size %d %d ", width(), height()); |
342 | #endif | 342 | #endif |
343 | 343 | ||
344 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 344 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
345 | SLOT( showDates( const KCal::DateList & ) ) ); | 345 | SLOT( showDates( const KCal::DateList & ) ) ); |
346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
347 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 347 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
348 | 348 | ||
349 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 349 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
350 | mNavigator, SLOT( selectPreviousYear() ) ); | 350 | mNavigator, SLOT( selectPreviousYear() ) ); |
351 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 351 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
352 | mNavigator, SLOT( selectNextYear() ) ); | 352 | mNavigator, SLOT( selectNextYear() ) ); |
353 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 353 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
354 | mNavigator, SLOT( selectPreviousMonth() ) ); | 354 | mNavigator, SLOT( selectPreviousMonth() ) ); |
355 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 355 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
356 | mNavigator, SLOT( selectNextMonth() ) ); | 356 | mNavigator, SLOT( selectNextMonth() ) ); |
357 | 357 | ||
358 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 358 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
359 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 359 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
360 | 360 | ||
361 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 361 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
362 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 362 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
363 | 363 | ||
364 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 364 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
365 | mNavigator, SLOT( selectPreviousYear() ) ); | 365 | mNavigator, SLOT( selectPreviousYear() ) ); |
366 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 366 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
367 | mNavigator, SLOT( selectNextYear() ) ); | 367 | mNavigator, SLOT( selectNextYear() ) ); |
368 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 368 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
369 | mNavigator, SLOT( selectPreviousMonth() ) ); | 369 | mNavigator, SLOT( selectPreviousMonth() ) ); |
370 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 370 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
371 | mNavigator, SLOT( selectNextMonth() ) ); | 371 | mNavigator, SLOT( selectNextMonth() ) ); |
372 | 372 | ||
373 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 373 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
374 | mNavigator, SLOT( selectPrevious() ) ); | 374 | mNavigator, SLOT( selectPrevious() ) ); |
375 | connect( mDateNavigator, SIGNAL( goNext() ), | 375 | connect( mDateNavigator, SIGNAL( goNext() ), |
376 | mNavigator, SLOT( selectNext() ) ); | 376 | mNavigator, SLOT( selectNext() ) ); |
377 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 377 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
378 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 378 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
379 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 379 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
381 | 381 | ||
382 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 382 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
383 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 383 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
384 | 384 | ||
385 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 385 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
386 | SLOT( eventAdded( Event *) ) ); | 386 | SLOT( eventAdded( Event *) ) ); |
387 | 387 | ||
388 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 388 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
389 | 389 | ||
390 | connect( this, SIGNAL( configChanged() ), | 390 | connect( this, SIGNAL( configChanged() ), |
391 | mDateNavigator, SLOT( updateConfig() ) ); | 391 | mDateNavigator, SLOT( updateConfig() ) ); |
392 | 392 | ||
393 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 393 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
394 | SLOT( newTodo() ) ); | 394 | SLOT( newTodo() ) ); |
395 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 395 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
396 | SLOT( newSubTodo( Todo * ) ) ); | 396 | SLOT( newSubTodo( Todo * ) ) ); |
397 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 397 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
398 | SLOT( editTodo( Todo * ) ) ); | 398 | SLOT( editTodo( Todo * ) ) ); |
399 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 399 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
400 | SLOT( showTodo( Todo *) ) ); | 400 | SLOT( showTodo( Todo *) ) ); |
401 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 401 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
402 | SLOT( deleteTodo( Todo *) ) ); | 402 | SLOT( deleteTodo( Todo *) ) ); |
403 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 403 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
404 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 404 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
405 | SLOT( purgeCompleted() ) ); | 405 | SLOT( purgeCompleted() ) ); |
406 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 406 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
407 | SIGNAL( todoModified( Todo *, int ) ) ); | 407 | SIGNAL( todoModified( Todo *, int ) ) ); |
408 | 408 | ||
409 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 409 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
410 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 410 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
411 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 411 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
412 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 412 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
413 | 413 | ||
414 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 414 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
415 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 415 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
416 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 416 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
417 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 417 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
418 | 418 | ||
419 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 419 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
420 | this, SLOT ( todo_unsub( Todo * ) ) ); | 420 | this, SLOT ( todo_unsub( Todo * ) ) ); |
421 | 421 | ||
422 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 422 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
423 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 423 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
424 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 424 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
425 | SLOT( updateTodo( Todo *, int ) ) ); | 425 | SLOT( updateTodo( Todo *, int ) ) ); |
426 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 426 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
427 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 427 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
428 | 428 | ||
429 | 429 | ||
430 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 430 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
431 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 431 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
432 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 432 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
433 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 433 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
434 | 434 | ||
435 | 435 | ||
436 | 436 | ||
437 | 437 | ||
438 | 438 | ||
439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
440 | SLOT(checkClipboard())); | 440 | SLOT(checkClipboard())); |
441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
442 | SLOT( processTodoListSelection( Incidence * ) ) ); | 442 | SLOT( processTodoListSelection( Incidence * ) ) ); |
443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
444 | 444 | ||
445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
446 | 446 | ||
447 | mDateFrame = new QVBox(0,0,WType_Popup); | 447 | mDateFrame = new QVBox(0,0,WType_Popup); |
448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
450 | mDateFrame->setLineWidth(3); | 450 | mDateFrame->setLineWidth(3); |
451 | mDateFrame->hide(); | 451 | mDateFrame->hide(); |
452 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 452 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
454 | 454 | ||
455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
456 | 456 | ||
457 | mEventEditor = mDialogManager->getEventEditor(); | 457 | mEventEditor = mDialogManager->getEventEditor(); |
458 | mTodoEditor = mDialogManager->getTodoEditor(); | 458 | mTodoEditor = mDialogManager->getTodoEditor(); |
459 | 459 | ||
460 | mFlagEditDescription = false; | 460 | mFlagEditDescription = false; |
461 | 461 | ||
462 | mSuspendTimer = new QTimer( this ); | 462 | mSuspendTimer = new QTimer( this ); |
463 | mAlarmTimer = new QTimer( this ); | 463 | mAlarmTimer = new QTimer( this ); |
464 | mRecheckAlarmTimer = new QTimer( this ); | 464 | mRecheckAlarmTimer = new QTimer( this ); |
465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
468 | mAlarmDialog = new AlarmDialog( this ); | 468 | mAlarmDialog = new AlarmDialog( this ); |
469 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 469 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
470 | mAlarmDialog->setServerNotification( false ); | 470 | mAlarmDialog->setServerNotification( false ); |
471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
472 | 472 | ||
473 | 473 | ||
474 | #ifndef DESKTOP_VERSION | 474 | #ifndef DESKTOP_VERSION |
475 | //US listen for arriving address resultsets | 475 | //US listen for arriving address resultsets |
476 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 476 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
477 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 477 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
478 | #endif | 478 | #endif |
479 | 479 | ||
480 | } | 480 | } |
481 | 481 | ||
482 | 482 | ||
483 | CalendarView::~CalendarView() | 483 | CalendarView::~CalendarView() |
484 | { | 484 | { |
485 | // kdDebug() << "~CalendarView()" << endl; | 485 | // kdDebug() << "~CalendarView()" << endl; |
486 | //qDebug("CalendarView::~CalendarView() "); | 486 | //qDebug("CalendarView::~CalendarView() "); |
487 | delete mDialogManager; | 487 | delete mDialogManager; |
488 | delete mViewManager; | 488 | delete mViewManager; |
489 | delete mStorage; | 489 | delete mStorage; |
490 | delete mDateFrame ; | 490 | delete mDateFrame ; |
491 | delete beamDialog; | 491 | delete beamDialog; |
492 | //kdDebug() << "~CalendarView() done" << endl; | 492 | //kdDebug() << "~CalendarView() done" << endl; |
493 | } | 493 | } |
494 | void CalendarView::timerAlarm() | 494 | void CalendarView::timerAlarm() |
495 | { | 495 | { |
496 | //qDebug("CalendarView::timerAlarm() "); | 496 | //qDebug("CalendarView::timerAlarm() "); |
497 | computeAlarm(mAlarmNotification ); | 497 | computeAlarm(mAlarmNotification ); |
498 | } | 498 | } |
499 | 499 | ||
500 | void CalendarView::suspendAlarm() | 500 | void CalendarView::suspendAlarm() |
501 | { | 501 | { |
502 | //qDebug(" CalendarView::suspendAlarm() "); | 502 | //qDebug(" CalendarView::suspendAlarm() "); |
503 | computeAlarm(mSuspendAlarmNotification ); | 503 | computeAlarm(mSuspendAlarmNotification ); |
504 | 504 | ||
505 | } | 505 | } |
506 | 506 | ||
507 | void CalendarView::startAlarm( QString mess , QString filename) | 507 | void CalendarView::startAlarm( QString mess , QString filename) |
508 | { | 508 | { |
509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
511 | 511 | ||
512 | } | 512 | } |
513 | 513 | ||
514 | void CalendarView::checkNextTimerAlarm() | 514 | void CalendarView::checkNextTimerAlarm() |
515 | { | 515 | { |
516 | mCalendar->checkAlarmForIncidence( 0, true ); | 516 | mCalendar->checkAlarmForIncidence( 0, true ); |
517 | } | 517 | } |
518 | 518 | ||
519 | void CalendarView::computeAlarm( QString msg ) | 519 | void CalendarView::computeAlarm( QString msg ) |
520 | { | 520 | { |
521 | 521 | ||
522 | QString mess = msg; | 522 | QString mess = msg; |
523 | QString mAlarmMessage = mess.mid( 9 ); | 523 | QString mAlarmMessage = mess.mid( 9 ); |
524 | QString filename = MainWindow::resourcePath(); | 524 | QString filename = MainWindow::resourcePath(); |
525 | filename += "koalarm.wav"; | 525 | filename += "koalarm.wav"; |
526 | QString tempfilename; | 526 | QString tempfilename; |
527 | if ( mess.left( 13 ) == "suspend_alarm") { | 527 | if ( mess.left( 13 ) == "suspend_alarm") { |
528 | bool error = false; | 528 | bool error = false; |
529 | int len = mess.mid( 13 ).find("+++"); | 529 | int len = mess.mid( 13 ).find("+++"); |
530 | if ( len < 2 ) | 530 | if ( len < 2 ) |
531 | error = true; | 531 | error = true; |
532 | else { | 532 | else { |
533 | tempfilename = mess.mid( 13, len ); | 533 | tempfilename = mess.mid( 13, len ); |
534 | if ( !QFile::exists( tempfilename ) ) | 534 | if ( !QFile::exists( tempfilename ) ) |
535 | error = true; | 535 | error = true; |
536 | } | 536 | } |
537 | if ( ! error ) { | 537 | if ( ! error ) { |
538 | filename = tempfilename; | 538 | filename = tempfilename; |
539 | } | 539 | } |
540 | mAlarmMessage = mess.mid( 13+len+3 ); | 540 | mAlarmMessage = mess.mid( 13+len+3 ); |
541 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 541 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
542 | startAlarm( mAlarmMessage, filename); | 542 | startAlarm( mAlarmMessage, filename); |
543 | return; | 543 | return; |
544 | } | 544 | } |
545 | if ( mess.left( 11 ) == "timer_alarm") { | 545 | if ( mess.left( 11 ) == "timer_alarm") { |
546 | //mTimerTime = 0; | 546 | //mTimerTime = 0; |
547 | startAlarm( mess.mid( 11 ), filename ); | 547 | startAlarm( mess.mid( 11 ), filename ); |
548 | return; | 548 | return; |
549 | } | 549 | } |
550 | if ( mess.left( 10 ) == "proc_alarm") { | 550 | if ( mess.left( 10 ) == "proc_alarm") { |
551 | bool error = false; | 551 | bool error = false; |
552 | int len = mess.mid( 10 ).find("+++"); | 552 | int len = mess.mid( 10 ).find("+++"); |
553 | if ( len < 2 ) | 553 | if ( len < 2 ) |
554 | error = true; | 554 | error = true; |
555 | else { | 555 | else { |
556 | tempfilename = mess.mid( 10, len ); | 556 | tempfilename = mess.mid( 10, len ); |
557 | if ( !QFile::exists( tempfilename ) ) | 557 | if ( !QFile::exists( tempfilename ) ) |
558 | error = true; | 558 | error = true; |
559 | } | 559 | } |
560 | if ( error ) { | 560 | if ( error ) { |
561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
562 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 562 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
563 | } else { | 563 | } else { |
564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
565 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 565 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
566 | #ifndef _WIN32_ | 566 | #ifndef _WIN32_ |
567 | if ( vfork () == 0 ) { | 567 | if ( vfork () == 0 ) { |
568 | execl ( tempfilename.latin1(), 0 ); | 568 | execl ( tempfilename.latin1(), 0 ); |
569 | return; | 569 | return; |
570 | } | 570 | } |
571 | #else | 571 | #else |
572 | QProcess* p = new QProcess(); | 572 | QProcess* p = new QProcess(); |
573 | p->addArgument( tempfilename.latin1() ); | 573 | p->addArgument( tempfilename.latin1() ); |
574 | p->start(); | 574 | p->start(); |
575 | return; | 575 | return; |
576 | #endif | 576 | #endif |
577 | 577 | ||
578 | return; | 578 | return; |
579 | } | 579 | } |
580 | 580 | ||
581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
582 | } | 582 | } |
583 | if ( mess.left( 11 ) == "audio_alarm") { | 583 | if ( mess.left( 11 ) == "audio_alarm") { |
584 | bool error = false; | 584 | bool error = false; |
585 | int len = mess.mid( 11 ).find("+++"); | 585 | int len = mess.mid( 11 ).find("+++"); |
586 | if ( len < 2 ) | 586 | if ( len < 2 ) |
587 | error = true; | 587 | error = true; |
588 | else { | 588 | else { |
589 | tempfilename = mess.mid( 11, len ); | 589 | tempfilename = mess.mid( 11, len ); |
590 | if ( !QFile::exists( tempfilename ) ) | 590 | if ( !QFile::exists( tempfilename ) ) |
591 | error = true; | 591 | error = true; |
592 | } | 592 | } |
593 | if ( ! error ) { | 593 | if ( ! error ) { |
594 | filename = tempfilename; | 594 | filename = tempfilename; |
595 | } | 595 | } |
596 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 596 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
597 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 597 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
598 | } | 598 | } |
599 | if ( mess.left( 9 ) == "cal_alarm") { | 599 | if ( mess.left( 9 ) == "cal_alarm") { |
600 | mAlarmMessage = mess.mid( 9 ) ; | 600 | mAlarmMessage = mess.mid( 9 ) ; |
601 | } | 601 | } |
602 | 602 | ||
603 | startAlarm( mAlarmMessage, filename ); | 603 | startAlarm( mAlarmMessage, filename ); |
604 | 604 | ||
605 | 605 | ||
606 | } | 606 | } |
607 | 607 | ||
608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
609 | { | 609 | { |
610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
611 | 611 | ||
612 | mSuspendAlarmNotification = noti; | 612 | mSuspendAlarmNotification = noti; |
613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
615 | mSuspendTimer->start( ms , true ); | 615 | mSuspendTimer->start( ms , true ); |
616 | 616 | ||
617 | } | 617 | } |
618 | 618 | ||
619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
620 | { | 620 | { |
621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
623 | #ifndef DESKTOP_VERSION | 623 | #ifndef DESKTOP_VERSION |
624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
625 | #endif | 625 | #endif |
626 | return; | 626 | return; |
627 | } | 627 | } |
628 | int maxSec; | 628 | int maxSec; |
629 | //maxSec = 5; //testing only | 629 | //maxSec = 5; //testing only |
630 | maxSec = 86400+3600; // one day+1hour | 630 | maxSec = 86400+3600; // one day+1hour |
631 | mAlarmNotification = noti; | 631 | mAlarmNotification = noti; |
632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
633 | if ( sec > maxSec ) { | 633 | if ( sec > maxSec ) { |
634 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 634 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
636 | return; | 636 | return; |
637 | } else { | 637 | } else { |
638 | mRecheckAlarmTimer->stop(); | 638 | mRecheckAlarmTimer->stop(); |
639 | } | 639 | } |
640 | //qDebug("Alarm timer started with secs: %d ", sec); | 640 | //qDebug("Alarm timer started with secs: %d ", sec); |
641 | mAlarmTimer->start( sec *1000 , true ); | 641 | mAlarmTimer->start( sec *1000 , true ); |
642 | 642 | ||
643 | } | 643 | } |
644 | // called by mRecheckAlarmTimer to get next alarm | 644 | // called by mRecheckAlarmTimer to get next alarm |
645 | // we need this, because a QTimer has only a max range of 25 days | 645 | // we need this, because a QTimer has only a max range of 25 days |
646 | void CalendarView::recheckTimerAlarm() | 646 | void CalendarView::recheckTimerAlarm() |
647 | { | 647 | { |
648 | mAlarmTimer->stop(); | 648 | mAlarmTimer->stop(); |
649 | mRecheckAlarmTimer->stop(); | 649 | mRecheckAlarmTimer->stop(); |
650 | mCalendar->checkAlarmForIncidence( 0, true ); | 650 | mCalendar->checkAlarmForIncidence( 0, true ); |
651 | } | 651 | } |
652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
653 | { | 653 | { |
654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
656 | #ifndef DESKTOP_VERSION | 656 | #ifndef DESKTOP_VERSION |
657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
658 | #endif | 658 | #endif |
659 | return; | 659 | return; |
660 | } | 660 | } |
661 | mAlarmTimer->stop(); | 661 | mAlarmTimer->stop(); |
662 | } | 662 | } |
663 | void CalendarView::selectWeekNum ( int num ) | 663 | void CalendarView::selectWeekNum ( int num ) |
664 | { | 664 | { |
665 | dateNavigator()->selectWeek( num ); | 665 | dateNavigator()->selectWeek( num ); |
666 | mViewManager->showWeekView(); | 666 | mViewManager->showWeekView(); |
667 | } | 667 | } |
668 | KOViewManager *CalendarView::viewManager() | 668 | KOViewManager *CalendarView::viewManager() |
669 | { | 669 | { |
670 | return mViewManager; | 670 | return mViewManager; |
671 | } | 671 | } |
672 | 672 | ||
673 | KODialogManager *CalendarView::dialogManager() | 673 | KODialogManager *CalendarView::dialogManager() |
674 | { | 674 | { |
675 | return mDialogManager; | 675 | return mDialogManager; |
676 | } | 676 | } |
677 | 677 | ||
678 | QDate CalendarView::startDate() | 678 | QDate CalendarView::startDate() |
679 | { | 679 | { |
680 | DateList dates = mNavigator->selectedDates(); | 680 | DateList dates = mNavigator->selectedDates(); |
681 | 681 | ||
682 | return dates.first(); | 682 | return dates.first(); |
683 | } | 683 | } |
684 | 684 | ||
685 | QDate CalendarView::endDate() | 685 | QDate CalendarView::endDate() |
686 | { | 686 | { |
687 | DateList dates = mNavigator->selectedDates(); | 687 | DateList dates = mNavigator->selectedDates(); |
688 | 688 | ||
689 | return dates.last(); | 689 | return dates.last(); |
690 | } | 690 | } |
691 | 691 | ||
692 | 692 | ||
693 | void CalendarView::createPrinter() | 693 | void CalendarView::createPrinter() |
694 | { | 694 | { |
695 | #ifndef KORG_NOPRINTER | 695 | #ifndef KORG_NOPRINTER |
696 | if (!mCalPrinter) { | 696 | if (!mCalPrinter) { |
697 | mCalPrinter = new CalPrinter(this, mCalendar); | 697 | mCalPrinter = new CalPrinter(this, mCalendar); |
698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
699 | } | 699 | } |
700 | #endif | 700 | #endif |
701 | } | 701 | } |
702 | 702 | ||
703 | 703 | ||
704 | //KOPrefs::instance()->mWriteBackFile | 704 | //KOPrefs::instance()->mWriteBackFile |
705 | //KOPrefs::instance()->mWriteBackExistingOnly | 705 | //KOPrefs::instance()->mWriteBackExistingOnly |
706 | 706 | ||
707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
713 | 713 | ||
714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
715 | { | 715 | { |
716 | 716 | ||
717 | // 0 equal | 717 | // 0 equal |
718 | // 1 take local | 718 | // 1 take local |
719 | // 2 take remote | 719 | // 2 take remote |
720 | // 3 cancel | 720 | // 3 cancel |
721 | QDateTime lastSync = mLastCalendarSync; | 721 | QDateTime lastSync = mLastCalendarSync; |
722 | QDateTime localMod = local->lastModified(); | 722 | QDateTime localMod = local->lastModified(); |
723 | QDateTime remoteMod = remote->lastModified(); | 723 | QDateTime remoteMod = remote->lastModified(); |
724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
725 | bool remCh, locCh; | 725 | bool remCh, locCh; |
726 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 726 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
727 | //if ( remCh ) | 727 | //if ( remCh ) |
728 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 728 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
729 | locCh = ( localMod > mLastCalendarSync ); | 729 | locCh = ( localMod > mLastCalendarSync ); |
730 | if ( !remCh && ! locCh ) { | 730 | if ( !remCh && ! locCh ) { |
731 | //qDebug("both not changed "); | 731 | //qDebug("both not changed "); |
732 | lastSync = localMod.addDays(1); | 732 | lastSync = localMod.addDays(1); |
733 | if ( mode <= SYNC_PREF_ASK ) | 733 | if ( mode <= SYNC_PREF_ASK ) |
734 | return 0; | 734 | return 0; |
735 | } else { | 735 | } else { |
736 | if ( locCh ) { | 736 | if ( locCh ) { |
737 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 737 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
738 | lastSync = localMod.addDays( -1 ); | 738 | lastSync = localMod.addDays( -1 ); |
739 | if ( !remCh ) | 739 | if ( !remCh ) |
740 | remoteMod = ( lastSync.addDays( -1 ) ); | 740 | remoteMod = ( lastSync.addDays( -1 ) ); |
741 | } else { | 741 | } else { |
742 | //qDebug(" not loc changed "); | 742 | //qDebug(" not loc changed "); |
743 | lastSync = localMod.addDays( 1 ); | 743 | lastSync = localMod.addDays( 1 ); |
744 | if ( remCh ) | 744 | if ( remCh ) |
745 | remoteMod =( lastSync.addDays( 1 ) ); | 745 | remoteMod =( lastSync.addDays( 1 ) ); |
746 | 746 | ||
747 | } | 747 | } |
748 | } | 748 | } |
749 | full = true; | 749 | full = true; |
750 | if ( mode < SYNC_PREF_ASK ) | 750 | if ( mode < SYNC_PREF_ASK ) |
751 | mode = SYNC_PREF_ASK; | 751 | mode = SYNC_PREF_ASK; |
752 | } else { | 752 | } else { |
753 | if ( localMod == remoteMod ) | 753 | if ( localMod == remoteMod ) |
754 | // if ( local->revision() == remote->revision() ) | 754 | // if ( local->revision() == remote->revision() ) |
755 | return 0; | 755 | return 0; |
756 | 756 | ||
757 | } | 757 | } |
758 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 758 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
759 | 759 | ||
760 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 760 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
761 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 761 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
762 | //full = true; //debug only | 762 | //full = true; //debug only |
763 | if ( full ) { | 763 | if ( full ) { |
764 | bool equ = false; | 764 | bool equ = false; |
765 | if ( local->type() == "Event" ) { | 765 | if ( local->type() == "Event" ) { |
766 | equ = (*((Event*) local) == *((Event*) remote)); | 766 | equ = (*((Event*) local) == *((Event*) remote)); |
767 | } | 767 | } |
768 | else if ( local->type() =="Todo" ) | 768 | else if ( local->type() =="Todo" ) |
769 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 769 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
770 | else if ( local->type() =="Journal" ) | 770 | else if ( local->type() =="Journal" ) |
771 | equ = (*((Journal*) local) == *((Journal*) remote)); | 771 | equ = (*((Journal*) local) == *((Journal*) remote)); |
772 | if ( equ ) { | 772 | if ( equ ) { |
773 | //qDebug("equal "); | 773 | //qDebug("equal "); |
774 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 774 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
775 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 775 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
776 | } | 776 | } |
777 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 777 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
778 | return 0; | 778 | return 0; |
779 | 779 | ||
780 | }//else //debug only | 780 | }//else //debug only |
781 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 781 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
782 | } | 782 | } |
783 | int result; | 783 | int result; |
784 | bool localIsNew; | 784 | bool localIsNew; |
785 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 785 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
786 | 786 | ||
787 | if ( full && mode < SYNC_PREF_NEWEST ) | 787 | if ( full && mode < SYNC_PREF_NEWEST ) |
788 | mode = SYNC_PREF_ASK; | 788 | mode = SYNC_PREF_ASK; |
789 | 789 | ||
790 | switch( mode ) { | 790 | switch( mode ) { |
791 | case SYNC_PREF_LOCAL: | 791 | case SYNC_PREF_LOCAL: |
792 | if ( lastSync > remoteMod ) | 792 | if ( lastSync > remoteMod ) |
793 | return 1; | 793 | return 1; |
794 | if ( lastSync > localMod ) | 794 | if ( lastSync > localMod ) |
795 | return 2; | 795 | return 2; |
796 | return 1; | 796 | return 1; |
797 | break; | 797 | break; |
798 | case SYNC_PREF_REMOTE: | 798 | case SYNC_PREF_REMOTE: |
799 | if ( lastSync > remoteMod ) | 799 | if ( lastSync > remoteMod ) |
800 | return 1; | 800 | return 1; |
801 | if ( lastSync > localMod ) | 801 | if ( lastSync > localMod ) |
802 | return 2; | 802 | return 2; |
803 | return 2; | 803 | return 2; |
804 | break; | 804 | break; |
805 | case SYNC_PREF_NEWEST: | 805 | case SYNC_PREF_NEWEST: |
806 | if ( localMod > remoteMod ) | 806 | if ( localMod > remoteMod ) |
807 | return 1; | 807 | return 1; |
808 | else | 808 | else |
809 | return 2; | 809 | return 2; |
810 | break; | 810 | break; |
811 | case SYNC_PREF_ASK: | 811 | case SYNC_PREF_ASK: |
812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
813 | if ( lastSync > remoteMod ) | 813 | if ( lastSync > remoteMod ) |
814 | return 1; | 814 | return 1; |
815 | if ( lastSync > localMod ) | 815 | if ( lastSync > localMod ) |
816 | return 2; | 816 | return 2; |
817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
818 | localIsNew = localMod >= remoteMod; | 818 | localIsNew = localMod >= remoteMod; |
819 | if ( localIsNew ) | 819 | if ( localIsNew ) |
820 | getEventViewerDialog()->setColorMode( 1 ); | 820 | getEventViewerDialog()->setColorMode( 1 ); |
821 | else | 821 | else |
822 | getEventViewerDialog()->setColorMode( 2 ); | 822 | getEventViewerDialog()->setColorMode( 2 ); |
823 | getEventViewerDialog()->setIncidence(local); | 823 | getEventViewerDialog()->setIncidence(local); |
824 | if ( localIsNew ) | 824 | if ( localIsNew ) |
825 | getEventViewerDialog()->setColorMode( 2 ); | 825 | getEventViewerDialog()->setColorMode( 2 ); |
826 | else | 826 | else |
827 | getEventViewerDialog()->setColorMode( 1 ); | 827 | getEventViewerDialog()->setColorMode( 1 ); |
828 | getEventViewerDialog()->addIncidence(remote); | 828 | getEventViewerDialog()->addIncidence(remote); |
829 | getEventViewerDialog()->setColorMode( 0 ); | 829 | getEventViewerDialog()->setColorMode( 0 ); |
830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
832 | getEventViewerDialog()->showMe(); | 832 | getEventViewerDialog()->showMe(); |
833 | result = getEventViewerDialog()->executeS( localIsNew ); | 833 | result = getEventViewerDialog()->executeS( localIsNew ); |
834 | return result; | 834 | return result; |
835 | 835 | ||
836 | break; | 836 | break; |
837 | case SYNC_PREF_FORCE_LOCAL: | 837 | case SYNC_PREF_FORCE_LOCAL: |
838 | return 1; | 838 | return 1; |
839 | break; | 839 | break; |
840 | case SYNC_PREF_FORCE_REMOTE: | 840 | case SYNC_PREF_FORCE_REMOTE: |
841 | return 2; | 841 | return 2; |
842 | break; | 842 | break; |
843 | 843 | ||
844 | default: | 844 | default: |
845 | // SYNC_PREF_TAKE_BOTH not implemented | 845 | // SYNC_PREF_TAKE_BOTH not implemented |
846 | break; | 846 | break; |
847 | } | 847 | } |
848 | return 0; | 848 | return 0; |
849 | } | 849 | } |
850 | Event* CalendarView::getLastSyncEvent() | 850 | Event* CalendarView::getLastSyncEvent() |
851 | { | 851 | { |
852 | Event* lse; | 852 | Event* lse; |
853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
855 | if (!lse) { | 855 | if (!lse) { |
856 | lse = new Event(); | 856 | lse = new Event(); |
857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
858 | QString sum = ""; | 858 | QString sum = ""; |
859 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 859 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
860 | sum = "E: "; | 860 | sum = "E: "; |
861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
862 | lse->setDtStart( mLastCalendarSync ); | 862 | lse->setDtStart( mLastCalendarSync ); |
863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
864 | lse->setCategories( i18n("SyncEvent") ); | 864 | lse->setCategories( i18n("SyncEvent") ); |
865 | lse->setReadOnly( true ); | 865 | lse->setReadOnly( true ); |
866 | mCalendar->addEvent( lse ); | 866 | mCalendar->addEvent( lse ); |
867 | } | 867 | } |
868 | 868 | ||
869 | return lse; | 869 | return lse; |
870 | 870 | ||
871 | } | 871 | } |
872 | 872 | ||
873 | // we check, if the to delete event has a id for a profile | 873 | // we check, if the to delete event has a id for a profile |
874 | // if yes, we set this id in the profile to delete | 874 | // if yes, we set this id in the profile to delete |
875 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 875 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
876 | { | 876 | { |
877 | if ( lastSync.count() == 0 ) { | 877 | if ( lastSync.count() == 0 ) { |
878 | //qDebug(" lastSync.count() == 0"); | 878 | //qDebug(" lastSync.count() == 0"); |
879 | return; | 879 | return; |
880 | } | 880 | } |
881 | if ( toDelete->type() == "Journal" ) | 881 | if ( toDelete->type() == "Journal" ) |
882 | return; | 882 | return; |
883 | 883 | ||
884 | Event* eve = lastSync.first(); | 884 | Event* eve = lastSync.first(); |
885 | 885 | ||
886 | while ( eve ) { | 886 | while ( eve ) { |
887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
888 | if ( !id.isEmpty() ) { | 888 | if ( !id.isEmpty() ) { |
889 | QString des = eve->description(); | 889 | QString des = eve->description(); |
890 | QString pref = "e"; | 890 | QString pref = "e"; |
891 | if ( toDelete->type() == "Todo" ) | 891 | if ( toDelete->type() == "Todo" ) |
892 | pref = "t"; | 892 | pref = "t"; |
893 | des += pref+ id + ","; | 893 | des += pref+ id + ","; |
894 | eve->setReadOnly( false ); | 894 | eve->setReadOnly( false ); |
895 | eve->setDescription( des ); | 895 | eve->setDescription( des ); |
896 | //qDebug("setdes %s ", des.latin1()); | 896 | //qDebug("setdes %s ", des.latin1()); |
897 | eve->setReadOnly( true ); | 897 | eve->setReadOnly( true ); |
898 | } | 898 | } |
899 | eve = lastSync.next(); | 899 | eve = lastSync.next(); |
900 | } | 900 | } |
901 | 901 | ||
902 | } | 902 | } |
903 | void CalendarView::checkExternalId( Incidence * inc ) | 903 | void CalendarView::checkExternalId( Incidence * inc ) |
904 | { | 904 | { |
905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
906 | checkExternSyncEvent( lastSync, inc ); | 906 | checkExternSyncEvent( lastSync, inc ); |
907 | 907 | ||
908 | } | 908 | } |
909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
910 | { | 910 | { |
911 | bool syncOK = true; | 911 | bool syncOK = true; |
912 | int addedEvent = 0; | 912 | int addedEvent = 0; |
913 | int addedEventR = 0; | 913 | int addedEventR = 0; |
914 | int deletedEventR = 0; | 914 | int deletedEventR = 0; |
915 | int deletedEventL = 0; | 915 | int deletedEventL = 0; |
916 | int changedLocal = 0; | 916 | int changedLocal = 0; |
917 | int changedRemote = 0; | 917 | int changedRemote = 0; |
918 | //QPtrList<Event> el = local->rawEvents(); | 918 | //QPtrList<Event> el = local->rawEvents(); |
919 | Event* eventR; | 919 | Event* eventR; |
920 | QString uid; | 920 | QString uid; |
921 | int take; | 921 | int take; |
922 | Event* eventL; | 922 | Event* eventL; |
923 | Event* eventRSync; | 923 | Event* eventRSync; |
924 | Event* eventLSync; | 924 | Event* eventLSync; |
925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
927 | bool fullDateRange = false; | 927 | bool fullDateRange = false; |
928 | local->resetTempSyncStat(); | 928 | local->resetTempSyncStat(); |
929 | mLastCalendarSync = QDateTime::currentDateTime(); | 929 | mLastCalendarSync = QDateTime::currentDateTime(); |
930 | if ( mSyncKDE ) { | 930 | if ( mSyncManager->syncWithDesktop() ) { |
931 | remote->resetPilotStat(1); | 931 | remote->resetPilotStat(1); |
932 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 932 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
933 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 933 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
934 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 934 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
935 | } else { | 935 | } else { |
936 | qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); | 936 | qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); |
937 | } | 937 | } |
938 | } | 938 | } |
939 | QDateTime modifiedCalendar = mLastCalendarSync;; | 939 | QDateTime modifiedCalendar = mLastCalendarSync;; |
940 | eventLSync = getLastSyncEvent(); | 940 | eventLSync = getLastSyncEvent(); |
941 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 941 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
942 | if ( eventR ) { | 942 | if ( eventR ) { |
943 | eventRSync = (Event*) eventR->clone(); | 943 | eventRSync = (Event*) eventR->clone(); |
944 | remote->deleteEvent(eventR ); | 944 | remote->deleteEvent(eventR ); |
945 | 945 | ||
946 | } else { | 946 | } else { |
947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncKDE) { | 947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
948 | eventRSync = (Event*)eventLSync->clone(); | 948 | eventRSync = (Event*)eventLSync->clone(); |
949 | } else { | 949 | } else { |
950 | fullDateRange = true; | 950 | fullDateRange = true; |
951 | eventRSync = new Event(); | 951 | eventRSync = new Event(); |
952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
954 | eventRSync->setDtStart( mLastCalendarSync ); | 954 | eventRSync->setDtStart( mLastCalendarSync ); |
955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
956 | eventRSync->setCategories( i18n("SyncEvent") ); | 956 | eventRSync->setCategories( i18n("SyncEvent") ); |
957 | } | 957 | } |
958 | } | 958 | } |
959 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 959 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
960 | fullDateRange = true; | 960 | fullDateRange = true; |
961 | 961 | ||
962 | if ( ! fullDateRange ) { | 962 | if ( ! fullDateRange ) { |
963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
964 | 964 | ||
965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
967 | fullDateRange = true; | 967 | fullDateRange = true; |
968 | } | 968 | } |
969 | } | 969 | } |
970 | if ( mSyncKDE ) { | 970 | if ( mSyncManager->syncWithDesktop() ) { |
971 | fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync ); | 971 | fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync ); |
972 | } | 972 | } |
973 | if ( fullDateRange ) | 973 | if ( fullDateRange ) |
974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
975 | else | 975 | else |
976 | mLastCalendarSync = eventLSync->dtStart(); | 976 | mLastCalendarSync = eventLSync->dtStart(); |
977 | // for resyncing if own file has changed | 977 | // for resyncing if own file has changed |
978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
979 | mLastCalendarSync = loadedFileVersion; | 979 | mLastCalendarSync = loadedFileVersion; |
980 | //qDebug("setting mLastCalendarSync "); | 980 | //qDebug("setting mLastCalendarSync "); |
981 | } | 981 | } |
982 | //qDebug("*************************** "); | 982 | //qDebug("*************************** "); |
983 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 983 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
984 | QPtrList<Incidence> er = remote->rawIncidences(); | 984 | QPtrList<Incidence> er = remote->rawIncidences(); |
985 | Incidence* inR = er.first(); | 985 | Incidence* inR = er.first(); |
986 | Incidence* inL; | 986 | Incidence* inL; |
987 | QProgressBar bar( er.count(),0 ); | 987 | QProgressBar bar( er.count(),0 ); |
988 | bar.setCaption (i18n("Syncing - close to abort!") ); | 988 | bar.setCaption (i18n("Syncing - close to abort!") ); |
989 | 989 | ||
990 | int w = 300; | 990 | int w = 300; |
991 | if ( QApplication::desktop()->width() < 320 ) | 991 | if ( QApplication::desktop()->width() < 320 ) |
992 | w = 220; | 992 | w = 220; |
993 | int h = bar.sizeHint().height() ; | 993 | int h = bar.sizeHint().height() ; |
994 | int dw = QApplication::desktop()->width(); | 994 | int dw = QApplication::desktop()->width(); |
995 | int dh = QApplication::desktop()->height(); | 995 | int dh = QApplication::desktop()->height(); |
996 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 996 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
997 | bar.show(); | 997 | bar.show(); |
998 | int modulo = (er.count()/10)+1; | 998 | int modulo = (er.count()/10)+1; |
999 | int incCounter = 0; | 999 | int incCounter = 0; |
1000 | while ( inR ) { | 1000 | while ( inR ) { |
1001 | if ( ! bar.isVisible() ) | 1001 | if ( ! bar.isVisible() ) |
1002 | return false; | 1002 | return false; |
1003 | if ( incCounter % modulo == 0 ) | 1003 | if ( incCounter % modulo == 0 ) |
1004 | bar.setProgress( incCounter ); | 1004 | bar.setProgress( incCounter ); |
1005 | ++incCounter; | 1005 | ++incCounter; |
1006 | uid = inR->uid(); | 1006 | uid = inR->uid(); |
1007 | bool skipIncidence = false; | 1007 | bool skipIncidence = false; |
1008 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1008 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1009 | skipIncidence = true; | 1009 | skipIncidence = true; |
1010 | QString idS; | 1010 | QString idS; |
1011 | qApp->processEvents(); | 1011 | qApp->processEvents(); |
1012 | if ( !skipIncidence ) { | 1012 | if ( !skipIncidence ) { |
1013 | inL = local->incidence( uid ); | 1013 | inL = local->incidence( uid ); |
1014 | if ( inL ) { // maybe conflict - same uid in both calendars | 1014 | if ( inL ) { // maybe conflict - same uid in both calendars |
1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1017 | if ( take == 3 ) | 1017 | if ( take == 3 ) |
1018 | return false; | 1018 | return false; |
1019 | if ( take == 1 ) {// take local | 1019 | if ( take == 1 ) {// take local |
1020 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1020 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1022 | else | 1022 | else |
1023 | idS = inR->IDStr(); | 1023 | idS = inR->IDStr(); |
1024 | remote->deleteIncidence( inR ); | 1024 | remote->deleteIncidence( inR ); |
1025 | inR = inL->clone(); | 1025 | inR = inL->clone(); |
1026 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1026 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1027 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1027 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1028 | inR->setIDStr( idS ); | 1028 | inR->setIDStr( idS ); |
1029 | remote->addIncidence( inR ); | 1029 | remote->addIncidence( inR ); |
1030 | if ( mSyncKDE ) | 1030 | if ( mSyncManager->syncWithDesktop() ) |
1031 | inR->setPilotId( 2 ); | 1031 | inR->setPilotId( 2 ); |
1032 | ++changedRemote; | 1032 | ++changedRemote; |
1033 | } else { | 1033 | } else { |
1034 | idS = inL->IDStr(); | 1034 | idS = inL->IDStr(); |
1035 | int pid = inL->pilotId(); | 1035 | int pid = inL->pilotId(); |
1036 | local->deleteIncidence( inL ); | 1036 | local->deleteIncidence( inL ); |
1037 | inL = inR->clone(); | 1037 | inL = inR->clone(); |
1038 | if ( mSyncKDE ) | 1038 | if ( mSyncManager->syncWithDesktop() ) |
1039 | inL->setPilotId( pid ); | 1039 | inL->setPilotId( pid ); |
1040 | inL->setIDStr( idS ); | 1040 | inL->setIDStr( idS ); |
1041 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1041 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1042 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1042 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1043 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1043 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1044 | } | 1044 | } |
1045 | local->addIncidence( inL ); | 1045 | local->addIncidence( inL ); |
1046 | ++changedLocal; | 1046 | ++changedLocal; |
1047 | } | 1047 | } |
1048 | } | 1048 | } |
1049 | } else { // no conflict | 1049 | } else { // no conflict |
1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1051 | QString des = eventLSync->description(); | 1051 | QString des = eventLSync->description(); |
1052 | QString pref = "e"; | 1052 | QString pref = "e"; |
1053 | if ( inR->type() == "Todo" ) | 1053 | if ( inR->type() == "Todo" ) |
1054 | pref = "t"; | 1054 | pref = "t"; |
1055 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1055 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1057 | //remote->deleteIncidence( inR ); | 1057 | //remote->deleteIncidence( inR ); |
1058 | ++deletedEventR; | 1058 | ++deletedEventR; |
1059 | } else { | 1059 | } else { |
1060 | inR->setLastModified( modifiedCalendar ); | 1060 | inR->setLastModified( modifiedCalendar ); |
1061 | inL = inR->clone(); | 1061 | inL = inR->clone(); |
1062 | inL->setIDStr( ":" ); | 1062 | inL->setIDStr( ":" ); |
1063 | local->addIncidence( inL ); | 1063 | local->addIncidence( inL ); |
1064 | ++addedEvent; | 1064 | ++addedEvent; |
1065 | } | 1065 | } |
1066 | } else { | 1066 | } else { |
1067 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1067 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1068 | inR->setLastModified( modifiedCalendar ); | 1068 | inR->setLastModified( modifiedCalendar ); |
1069 | inL = inR->clone(); | 1069 | inL = inR->clone(); |
1070 | inL->setIDStr( ":" ); | 1070 | inL->setIDStr( ":" ); |
1071 | local->addIncidence( inL ); | 1071 | local->addIncidence( inL ); |
1072 | ++addedEvent; | 1072 | ++addedEvent; |
1073 | } else { | 1073 | } else { |
1074 | checkExternSyncEvent(eventRSyncSharp, inR); | 1074 | checkExternSyncEvent(eventRSyncSharp, inR); |
1075 | remote->deleteIncidence( inR ); | 1075 | remote->deleteIncidence( inR ); |
1076 | ++deletedEventR; | 1076 | ++deletedEventR; |
1077 | } | 1077 | } |
1078 | } | 1078 | } |
1079 | } | 1079 | } |
1080 | } | 1080 | } |
1081 | inR = er.next(); | 1081 | inR = er.next(); |
1082 | } | 1082 | } |
1083 | QPtrList<Incidence> el = local->rawIncidences(); | 1083 | QPtrList<Incidence> el = local->rawIncidences(); |
1084 | inL = el.first(); | 1084 | inL = el.first(); |
1085 | modulo = (el.count()/10)+1; | 1085 | modulo = (el.count()/10)+1; |
1086 | bar.setCaption (i18n("Add / remove events") ); | 1086 | bar.setCaption (i18n("Add / remove events") ); |
1087 | bar.setTotalSteps ( el.count() ) ; | 1087 | bar.setTotalSteps ( el.count() ) ; |
1088 | bar.show(); | 1088 | bar.show(); |
1089 | incCounter = 0; | 1089 | incCounter = 0; |
1090 | 1090 | ||
1091 | while ( inL ) { | 1091 | while ( inL ) { |
1092 | 1092 | ||
1093 | qApp->processEvents(); | 1093 | qApp->processEvents(); |
1094 | if ( ! bar.isVisible() ) | 1094 | if ( ! bar.isVisible() ) |
1095 | return false; | 1095 | return false; |
1096 | if ( incCounter % modulo == 0 ) | 1096 | if ( incCounter % modulo == 0 ) |
1097 | bar.setProgress( incCounter ); | 1097 | bar.setProgress( incCounter ); |
1098 | ++incCounter; | 1098 | ++incCounter; |
1099 | uid = inL->uid(); | 1099 | uid = inL->uid(); |
1100 | bool skipIncidence = false; | 1100 | bool skipIncidence = false; |
1101 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1101 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1102 | skipIncidence = true; | 1102 | skipIncidence = true; |
1103 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1103 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1104 | skipIncidence = true; | 1104 | skipIncidence = true; |
1105 | if ( !skipIncidence ) { | 1105 | if ( !skipIncidence ) { |
1106 | inR = remote->incidence( uid ); | 1106 | inR = remote->incidence( uid ); |
1107 | if ( ! inR ) { | 1107 | if ( ! inR ) { |
1108 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1108 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1109 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1109 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1110 | checkExternSyncEvent(eventLSyncSharp, inL); | 1110 | checkExternSyncEvent(eventLSyncSharp, inL); |
1111 | local->deleteIncidence( inL ); | 1111 | local->deleteIncidence( inL ); |
1112 | ++deletedEventL; | 1112 | ++deletedEventL; |
1113 | } else { | 1113 | } else { |
1114 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1114 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1115 | inL->removeID(mCurrentSyncDevice ); | 1115 | inL->removeID(mCurrentSyncDevice ); |
1116 | ++addedEventR; | 1116 | ++addedEventR; |
1117 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1117 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1118 | inL->setLastModified( modifiedCalendar ); | 1118 | inL->setLastModified( modifiedCalendar ); |
1119 | inR = inL->clone(); | 1119 | inR = inL->clone(); |
1120 | inR->setIDStr( ":" ); | 1120 | inR->setIDStr( ":" ); |
1121 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1121 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1122 | remote->addIncidence( inR ); | 1122 | remote->addIncidence( inR ); |
1123 | } | 1123 | } |
1124 | } | 1124 | } |
1125 | } else { | 1125 | } else { |
1126 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1126 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1127 | checkExternSyncEvent(eventLSyncSharp, inL); | 1127 | checkExternSyncEvent(eventLSyncSharp, inL); |
1128 | local->deleteIncidence( inL ); | 1128 | local->deleteIncidence( inL ); |
1129 | ++deletedEventL; | 1129 | ++deletedEventL; |
1130 | } else { | 1130 | } else { |
1131 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1131 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1132 | ++addedEventR; | 1132 | ++addedEventR; |
1133 | inL->setLastModified( modifiedCalendar ); | 1133 | inL->setLastModified( modifiedCalendar ); |
1134 | inR = inL->clone(); | 1134 | inR = inL->clone(); |
1135 | inR->setIDStr( ":" ); | 1135 | inR->setIDStr( ":" ); |
1136 | remote->addIncidence( inR ); | 1136 | remote->addIncidence( inR ); |
1137 | } | 1137 | } |
1138 | } | 1138 | } |
1139 | } | 1139 | } |
1140 | } | 1140 | } |
1141 | } | 1141 | } |
1142 | inL = el.next(); | 1142 | inL = el.next(); |
1143 | } | 1143 | } |
1144 | int delFut = 0; | 1144 | int delFut = 0; |
1145 | int remRem = 0; | 1145 | int remRem = 0; |
1146 | if ( mSyncManager->mWriteBackInFuture ) { | 1146 | if ( mSyncManager->mWriteBackInFuture ) { |
1147 | er = remote->rawIncidences(); | 1147 | er = remote->rawIncidences(); |
1148 | remRem = er.count(); | 1148 | remRem = er.count(); |
1149 | inR = er.first(); | 1149 | inR = er.first(); |
1150 | QDateTime dt; | 1150 | QDateTime dt; |
1151 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1151 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1152 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); | 1152 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1153 | while ( inR ) { | 1153 | while ( inR ) { |
1154 | if ( inR->type() == "Todo" ) { | 1154 | if ( inR->type() == "Todo" ) { |
1155 | Todo * t = (Todo*)inR; | 1155 | Todo * t = (Todo*)inR; |
1156 | if ( t->hasDueDate() ) | 1156 | if ( t->hasDueDate() ) |
1157 | dt = t->dtDue(); | 1157 | dt = t->dtDue(); |
1158 | else | 1158 | else |
1159 | dt = cur.addSecs( 62 ); | 1159 | dt = cur.addSecs( 62 ); |
1160 | } | 1160 | } |
1161 | else if (inR->type() == "Event" ) { | 1161 | else if (inR->type() == "Event" ) { |
1162 | bool ok; | 1162 | bool ok; |
1163 | dt = inR->getNextOccurence( cur, &ok ); | 1163 | dt = inR->getNextOccurence( cur, &ok ); |
1164 | if ( !ok ) | 1164 | if ( !ok ) |
1165 | dt = cur.addSecs( -62 ); | 1165 | dt = cur.addSecs( -62 ); |
1166 | } | 1166 | } |
1167 | else | 1167 | else |
1168 | dt = inR->dtStart(); | 1168 | dt = inR->dtStart(); |
1169 | if ( dt < cur || dt > end ) { | 1169 | if ( dt < cur || dt > end ) { |
1170 | remote->deleteIncidence( inR ); | 1170 | remote->deleteIncidence( inR ); |
1171 | ++delFut; | 1171 | ++delFut; |
1172 | } | 1172 | } |
1173 | inR = er.next(); | 1173 | inR = er.next(); |
1174 | } | 1174 | } |
1175 | } | 1175 | } |
1176 | bar.hide(); | 1176 | bar.hide(); |
1177 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1177 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1178 | eventLSync->setReadOnly( false ); | 1178 | eventLSync->setReadOnly( false ); |
1179 | eventLSync->setDtStart( mLastCalendarSync ); | 1179 | eventLSync->setDtStart( mLastCalendarSync ); |
1180 | eventRSync->setDtStart( mLastCalendarSync ); | 1180 | eventRSync->setDtStart( mLastCalendarSync ); |
1181 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1181 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1182 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1182 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1183 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1183 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1184 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1184 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1185 | eventLSync->setReadOnly( true ); | 1185 | eventLSync->setReadOnly( true ); |
1186 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncKDE) // kde is abnormal... | 1186 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1187 | remote->addEvent( eventRSync ); | 1187 | remote->addEvent( eventRSync ); |
1188 | else | 1188 | else |
1189 | delete eventRSync; | 1189 | delete eventRSync; |
1190 | QString mes; | 1190 | QString mes; |
1191 | 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 ); | 1191 | 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 ); |
1192 | QString delmess; | 1192 | QString delmess; |
1193 | if ( delFut ) { | 1193 | if ( delFut ) { |
1194 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1194 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1195 | mes += delmess; | 1195 | mes += delmess; |
1196 | } | 1196 | } |
1197 | if ( mSyncManager->mShowSyncSummary ) { | 1197 | if ( mSyncManager->mShowSyncSummary ) { |
1198 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1198 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1199 | } | 1199 | } |
1200 | qDebug( mes ); | 1200 | qDebug( mes ); |
1201 | mCalendar->checkAlarmForIncidence( 0, true ); | 1201 | mCalendar->checkAlarmForIncidence( 0, true ); |
1202 | return syncOK; | 1202 | return syncOK; |
1203 | } | 1203 | } |
1204 | 1204 | ||
1205 | void CalendarView::setSyncDevice( QString s ) | 1205 | void CalendarView::setSyncDevice( QString s ) |
1206 | { | 1206 | { |
1207 | mCurrentSyncDevice= s; | 1207 | mCurrentSyncDevice= s; |
1208 | } | 1208 | } |
1209 | void CalendarView::setSyncName( QString s ) | 1209 | void CalendarView::setSyncName( QString s ) |
1210 | { | 1210 | { |
1211 | mCurrentSyncName= s; | 1211 | mCurrentSyncName= s; |
1212 | } | 1212 | } |
1213 | bool CalendarView::syncCalendar(QString filename, int mode) | 1213 | bool CalendarView::syncCalendar(QString filename, int mode) |
1214 | { | 1214 | { |
1215 | //qDebug("syncCalendar %s ", filename.latin1()); | 1215 | //qDebug("syncCalendar %s ", filename.latin1()); |
1216 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1216 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1217 | CalendarLocal* calendar = new CalendarLocal(); | 1217 | CalendarLocal* calendar = new CalendarLocal(); |
1218 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1218 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1219 | FileStorage* storage = new FileStorage( calendar ); | 1219 | FileStorage* storage = new FileStorage( calendar ); |
1220 | bool syncOK = false; | 1220 | bool syncOK = false; |
1221 | storage->setFileName( filename ); | 1221 | storage->setFileName( filename ); |
1222 | // qDebug("loading ... "); | 1222 | // qDebug("loading ... "); |
1223 | if ( storage->load() ) { | 1223 | if ( storage->load() ) { |
1224 | getEventViewerDialog()->setSyncMode( true ); | 1224 | getEventViewerDialog()->setSyncMode( true ); |
1225 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1225 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1226 | getEventViewerDialog()->setSyncMode( false ); | 1226 | getEventViewerDialog()->setSyncMode( false ); |
1227 | if ( syncOK ) { | 1227 | if ( syncOK ) { |
1228 | if ( mSyncManager->mWriteBackFile ) | 1228 | if ( mSyncManager->mWriteBackFile ) |
1229 | { | 1229 | { |
1230 | storage->setSaveFormat( new ICalFormat() ); | 1230 | storage->setSaveFormat( new ICalFormat() ); |
1231 | storage->save(); | 1231 | storage->save(); |
1232 | } | 1232 | } |
1233 | } | 1233 | } |
1234 | setModified( true ); | 1234 | setModified( true ); |
1235 | } | 1235 | } |
1236 | delete storage; | 1236 | delete storage; |
1237 | delete calendar; | 1237 | delete calendar; |
1238 | if ( syncOK ) | 1238 | if ( syncOK ) |
1239 | updateView(); | 1239 | updateView(); |
1240 | return syncOK; | 1240 | return syncOK; |
1241 | } | 1241 | } |
1242 | 1242 | ||
1243 | void CalendarView::syncExternal( int mode ) | 1243 | void CalendarView::syncExternal( int mode ) |
1244 | { | 1244 | { |
1245 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1245 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1246 | 1246 | ||
1247 | qApp->processEvents(); | 1247 | qApp->processEvents(); |
1248 | CalendarLocal* calendar = new CalendarLocal(); | 1248 | CalendarLocal* calendar = new CalendarLocal(); |
1249 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1249 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1250 | bool syncOK = false; | 1250 | bool syncOK = false; |
1251 | bool loadSuccess = false; | 1251 | bool loadSuccess = false; |
1252 | PhoneFormat* phoneFormat = 0; | 1252 | PhoneFormat* phoneFormat = 0; |
1253 | emit tempDisableBR(true); | 1253 | emit tempDisableBR(true); |
1254 | #ifndef DESKTOP_VERSION | 1254 | #ifndef DESKTOP_VERSION |
1255 | SharpFormat* sharpFormat = 0; | 1255 | SharpFormat* sharpFormat = 0; |
1256 | if ( mode == 0 ) { // sharp | 1256 | if ( mode == 0 ) { // sharp |
1257 | sharpFormat = new SharpFormat () ; | 1257 | sharpFormat = new SharpFormat () ; |
1258 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1258 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1259 | 1259 | ||
1260 | } else | 1260 | } else |
1261 | #endif | 1261 | #endif |
1262 | if ( mode == 1 ) { // phone | 1262 | if ( mode == 1 ) { // phone |
1263 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1263 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1264 | mSyncManager->mPhoneDevice, | 1264 | mSyncManager->mPhoneDevice, |
1265 | mSyncManager->mPhoneConnection, | 1265 | mSyncManager->mPhoneConnection, |
1266 | mSyncManager->mPhoneModel); | 1266 | mSyncManager->mPhoneModel); |
1267 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1267 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1268 | 1268 | ||
1269 | } else { | 1269 | } else { |
1270 | emit tempDisableBR(false); | 1270 | emit tempDisableBR(false); |
1271 | return; | 1271 | return; |
1272 | } | 1272 | } |
1273 | if ( loadSuccess ) { | 1273 | if ( loadSuccess ) { |
1274 | getEventViewerDialog()->setSyncMode( true ); | 1274 | getEventViewerDialog()->setSyncMode( true ); |
1275 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1275 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1276 | getEventViewerDialog()->setSyncMode( false ); | 1276 | getEventViewerDialog()->setSyncMode( false ); |
1277 | qApp->processEvents(); | 1277 | qApp->processEvents(); |
1278 | if ( syncOK ) { | 1278 | if ( syncOK ) { |
1279 | if ( mSyncManager->mWriteBackFile ) | 1279 | if ( mSyncManager->mWriteBackFile ) |
1280 | { | 1280 | { |
1281 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1281 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1282 | Incidence* inc = iL.first(); | 1282 | Incidence* inc = iL.first(); |
1283 | if ( phoneFormat ) { | 1283 | if ( phoneFormat ) { |
1284 | while ( inc ) { | 1284 | while ( inc ) { |
1285 | inc->removeID(mCurrentSyncDevice); | 1285 | inc->removeID(mCurrentSyncDevice); |
1286 | inc = iL.next(); | 1286 | inc = iL.next(); |
1287 | } | 1287 | } |
1288 | } | 1288 | } |
1289 | #ifndef DESKTOP_VERSION | 1289 | #ifndef DESKTOP_VERSION |
1290 | if ( sharpFormat ) | 1290 | if ( sharpFormat ) |
1291 | sharpFormat->save(calendar); | 1291 | sharpFormat->save(calendar); |
1292 | #endif | 1292 | #endif |
1293 | if ( phoneFormat ) | 1293 | if ( phoneFormat ) |
1294 | phoneFormat->save(calendar); | 1294 | phoneFormat->save(calendar); |
1295 | iL = calendar->rawIncidences(); | 1295 | iL = calendar->rawIncidences(); |
1296 | inc = iL.first(); | 1296 | inc = iL.first(); |
1297 | Incidence* loc; | 1297 | Incidence* loc; |
1298 | while ( inc ) { | 1298 | while ( inc ) { |
1299 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1299 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1300 | loc = mCalendar->incidence(inc->uid() ); | 1300 | loc = mCalendar->incidence(inc->uid() ); |
1301 | if ( loc ) { | 1301 | if ( loc ) { |
1302 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1302 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1303 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1303 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1304 | } | 1304 | } |
1305 | } | 1305 | } |
1306 | inc = iL.next(); | 1306 | inc = iL.next(); |
1307 | } | 1307 | } |
1308 | Incidence* lse = getLastSyncEvent(); | 1308 | Incidence* lse = getLastSyncEvent(); |
1309 | if ( lse ) { | 1309 | if ( lse ) { |
1310 | lse->setReadOnly( false ); | 1310 | lse->setReadOnly( false ); |
1311 | lse->setDescription( "" ); | 1311 | lse->setDescription( "" ); |
1312 | lse->setReadOnly( true ); | 1312 | lse->setReadOnly( true ); |
1313 | } | 1313 | } |
1314 | } | 1314 | } |
1315 | } | 1315 | } |
1316 | setModified( true ); | 1316 | setModified( true ); |
1317 | } else { | 1317 | } else { |
1318 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1318 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1319 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1319 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1320 | question, i18n("Ok")) ; | 1320 | question, i18n("Ok")) ; |
1321 | 1321 | ||
1322 | } | 1322 | } |
1323 | delete calendar; | 1323 | delete calendar; |
1324 | updateView(); | 1324 | updateView(); |
1325 | emit tempDisableBR(false); | 1325 | emit tempDisableBR(false); |
1326 | return ;//syncOK; | 1326 | return ;//syncOK; |
1327 | 1327 | ||
1328 | } | 1328 | } |
1329 | 1329 | ||
1330 | bool CalendarView::importBday() | 1330 | bool CalendarView::importBday() |
1331 | { | 1331 | { |
1332 | #ifndef KORG_NOKABC | 1332 | #ifndef KORG_NOKABC |
1333 | 1333 | ||
1334 | #ifdef DESKTOP_VERSION | 1334 | #ifdef DESKTOP_VERSION |
1335 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1335 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1336 | KABC::AddressBook::Iterator it; | 1336 | KABC::AddressBook::Iterator it; |
1337 | int count = 0; | 1337 | int count = 0; |
1338 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1338 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1339 | ++count; | 1339 | ++count; |
1340 | } | 1340 | } |
1341 | QProgressBar bar(count,0 ); | 1341 | QProgressBar bar(count,0 ); |
1342 | int w = 300; | 1342 | int w = 300; |
1343 | if ( QApplication::desktop()->width() < 320 ) | 1343 | if ( QApplication::desktop()->width() < 320 ) |
1344 | w = 220; | 1344 | w = 220; |
1345 | int h = bar.sizeHint().height() ; | 1345 | int h = bar.sizeHint().height() ; |
1346 | int dw = QApplication::desktop()->width(); | 1346 | int dw = QApplication::desktop()->width(); |
1347 | int dh = QApplication::desktop()->height(); | 1347 | int dh = QApplication::desktop()->height(); |
1348 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1348 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1349 | bar.show(); | 1349 | bar.show(); |
1350 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1350 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1351 | qApp->processEvents(); | 1351 | qApp->processEvents(); |
1352 | count = 0; | 1352 | count = 0; |
1353 | int addCount = 0; | 1353 | int addCount = 0; |
1354 | KCal::Attendee* a = 0; | 1354 | KCal::Attendee* a = 0; |
1355 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1355 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1356 | if ( ! bar.isVisible() ) | 1356 | if ( ! bar.isVisible() ) |
1357 | return false; | 1357 | return false; |
1358 | bar.setProgress( count++ ); | 1358 | bar.setProgress( count++ ); |
1359 | qApp->processEvents(); | 1359 | qApp->processEvents(); |
1360 | //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() ); |
1361 | if ( (*it).birthday().date().isValid() ){ | 1361 | if ( (*it).birthday().date().isValid() ){ |
1362 | 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()) ; |
1363 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1363 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1364 | ++addCount; | 1364 | ++addCount; |
1365 | } | 1365 | } |
1366 | 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"); |
1367 | if ( anni.isValid() ){ | 1367 | if ( anni.isValid() ){ |
1368 | 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()) ; |
1369 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1369 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1370 | ++addCount; | 1370 | ++addCount; |
1371 | } | 1371 | } |
1372 | } | 1372 | } |
1373 | updateView(); | 1373 | updateView(); |
1374 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1374 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1375 | #else //DESKTOP_VERSION | 1375 | #else //DESKTOP_VERSION |
1376 | 1376 | ||
1377 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1377 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1378 | // the result should now arrive through method insertBirthdays | 1378 | // the result should now arrive through method insertBirthdays |
1379 | 1379 | ||
1380 | #endif //DESKTOP_VERSION | 1380 | #endif //DESKTOP_VERSION |
1381 | 1381 | ||
1382 | #endif //KORG_NOKABC | 1382 | #endif //KORG_NOKABC |
1383 | 1383 | ||
1384 | 1384 | ||
1385 | return true; | 1385 | return true; |
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1388 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1389 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1389 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1390 | const QStringList& anniversaryList, const QStringList& realNameList, | 1390 | const QStringList& anniversaryList, const QStringList& realNameList, |
1391 | const QStringList& emailList, const QStringList& assembledNameList, | 1391 | const QStringList& emailList, const QStringList& assembledNameList, |
1392 | const QStringList& uidList) | 1392 | const QStringList& uidList) |
1393 | { | 1393 | { |
1394 | qDebug("CalendarView::insertBirthdays"); | 1394 | qDebug("CalendarView::insertBirthdays"); |
1395 | if (uid == this->name()) | 1395 | if (uid == this->name()) |
1396 | { | 1396 | { |
1397 | int count = birthdayList.count(); | 1397 | int count = birthdayList.count(); |
1398 | int addCount = 0; | 1398 | int addCount = 0; |
1399 | KCal::Attendee* a = 0; | 1399 | KCal::Attendee* a = 0; |
1400 | 1400 | ||
1401 | qDebug("CalView 1 %i", count); | 1401 | qDebug("CalView 1 %i", count); |
1402 | 1402 | ||
1403 | QProgressBar bar(count,0 ); | 1403 | QProgressBar bar(count,0 ); |
1404 | int w = 300; | 1404 | int w = 300; |
1405 | if ( QApplication::desktop()->width() < 320 ) | 1405 | if ( QApplication::desktop()->width() < 320 ) |
1406 | w = 220; | 1406 | w = 220; |
1407 | int h = bar.sizeHint().height() ; | 1407 | int h = bar.sizeHint().height() ; |
1408 | int dw = QApplication::desktop()->width(); | 1408 | int dw = QApplication::desktop()->width(); |
1409 | int dh = QApplication::desktop()->height(); | 1409 | int dh = QApplication::desktop()->height(); |
1410 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1410 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1411 | bar.show(); | 1411 | bar.show(); |
1412 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1412 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1413 | qApp->processEvents(); | 1413 | qApp->processEvents(); |
1414 | 1414 | ||
1415 | QDate birthday; | 1415 | QDate birthday; |
1416 | QDate anniversary; | 1416 | QDate anniversary; |
1417 | QString realName; | 1417 | QString realName; |
1418 | QString email; | 1418 | QString email; |
1419 | QString assembledName; | 1419 | QString assembledName; |
1420 | QString uid; | 1420 | QString uid; |
1421 | bool ok = true; | 1421 | bool ok = true; |
1422 | for ( int i = 0; i < count; i++) | 1422 | for ( int i = 0; i < count; i++) |
1423 | { | 1423 | { |
1424 | if ( ! bar.isVisible() ) | 1424 | if ( ! bar.isVisible() ) |
1425 | return; | 1425 | return; |
1426 | bar.setProgress( i ); | 1426 | bar.setProgress( i ); |
1427 | qApp->processEvents(); | 1427 | qApp->processEvents(); |
1428 | 1428 | ||
1429 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1429 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1430 | if (!ok) { | 1430 | if (!ok) { |
1431 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1431 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1432 | } | 1432 | } |
1433 | 1433 | ||
1434 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1434 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1435 | if (!ok) { | 1435 | if (!ok) { |
1436 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1436 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1437 | } | 1437 | } |
1438 | realName = realNameList[i]; | 1438 | realName = realNameList[i]; |
1439 | email = emailList[i]; | 1439 | email = emailList[i]; |
1440 | assembledName = assembledNameList[i]; | 1440 | assembledName = assembledNameList[i]; |
1441 | uid = uidList[i]; | 1441 | uid = uidList[i]; |
1442 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1442 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1443 | 1443 | ||
1444 | if ( birthday.isValid() ){ | 1444 | if ( birthday.isValid() ){ |
1445 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1445 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1446 | KCal::Attendee::ReqParticipant,uid) ; | 1446 | KCal::Attendee::ReqParticipant,uid) ; |
1447 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1447 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1448 | ++addCount; | 1448 | ++addCount; |
1449 | } | 1449 | } |
1450 | 1450 | ||
1451 | if ( anniversary.isValid() ){ | 1451 | if ( anniversary.isValid() ){ |
1452 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1452 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1453 | KCal::Attendee::ReqParticipant,uid) ; | 1453 | KCal::Attendee::ReqParticipant,uid) ; |
1454 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1454 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1455 | ++addCount; | 1455 | ++addCount; |
1456 | } | 1456 | } |
1457 | } | 1457 | } |
1458 | 1458 | ||
1459 | updateView(); | 1459 | updateView(); |
1460 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1460 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1461 | 1461 | ||
1462 | } | 1462 | } |
1463 | 1463 | ||
1464 | } | 1464 | } |
1465 | 1465 | ||
1466 | 1466 | ||
1467 | 1467 | ||
1468 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1468 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1469 | { | 1469 | { |
1470 | //qDebug("addAnni "); | 1470 | //qDebug("addAnni "); |
1471 | Event * ev = new Event(); | 1471 | Event * ev = new Event(); |
1472 | if ( a ) { | 1472 | if ( a ) { |
1473 | ev->addAttendee( a ); | 1473 | ev->addAttendee( a ); |
1474 | } | 1474 | } |
1475 | QString kind; | 1475 | QString kind; |
1476 | if ( birthday ) | 1476 | if ( birthday ) |
1477 | kind = i18n( "Birthday" ); | 1477 | kind = i18n( "Birthday" ); |
1478 | else | 1478 | else |
1479 | kind = i18n( "Anniversary" ); | 1479 | kind = i18n( "Anniversary" ); |
1480 | ev->setSummary( name + " - " + kind ); | 1480 | ev->setSummary( name + " - " + kind ); |
1481 | ev->setOrganizer(a->email()); | 1481 | ev->setOrganizer(a->email()); |
1482 | ev->setCategories( kind ); | 1482 | ev->setCategories( kind ); |
1483 | ev->setDtStart( QDateTime(date) ); | 1483 | ev->setDtStart( QDateTime(date) ); |
1484 | ev->setDtEnd( QDateTime(date) ); | 1484 | ev->setDtEnd( QDateTime(date) ); |
1485 | ev->setFloats( true ); | 1485 | ev->setFloats( true ); |
1486 | Recurrence * rec = ev->recurrence(); | 1486 | Recurrence * rec = ev->recurrence(); |
1487 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1487 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1488 | rec->addYearlyNum( date.month() ); | 1488 | rec->addYearlyNum( date.month() ); |
1489 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1489 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1490 | delete ev; | 1490 | delete ev; |
1491 | return false; | 1491 | return false; |
1492 | } | 1492 | } |
1493 | return true; | 1493 | return true; |
1494 | 1494 | ||
1495 | } | 1495 | } |
1496 | bool CalendarView::importQtopia( const QString &categories, | 1496 | bool CalendarView::importQtopia( const QString &categories, |
1497 | const QString &datebook, | 1497 | const QString &datebook, |
1498 | const QString &todolist ) | 1498 | const QString &todolist ) |
1499 | { | 1499 | { |
1500 | 1500 | ||
1501 | QtopiaFormat qtopiaFormat; | 1501 | QtopiaFormat qtopiaFormat; |
1502 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1502 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1503 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1503 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1504 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1504 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1505 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1505 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1506 | 1506 | ||
1507 | updateView(); | 1507 | updateView(); |
1508 | return true; | 1508 | return true; |
1509 | 1509 | ||
1510 | #if 0 | 1510 | #if 0 |
1511 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1511 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1512 | mCurrentSyncDevice = "qtopia-XML"; | 1512 | mCurrentSyncDevice = "qtopia-XML"; |
1513 | if ( mSyncManager->mAskForPreferences ) | 1513 | if ( mSyncManager->mAskForPreferences ) |
1514 | edit_sync_options(); | 1514 | edit_sync_options(); |
1515 | qApp->processEvents(); | 1515 | qApp->processEvents(); |
1516 | CalendarLocal* calendar = new CalendarLocal(); | 1516 | CalendarLocal* calendar = new CalendarLocal(); |
1517 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1517 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1518 | bool syncOK = false; | 1518 | bool syncOK = false; |
1519 | QtopiaFormat qtopiaFormat; | 1519 | QtopiaFormat qtopiaFormat; |
1520 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1520 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1521 | bool loadOk = true; | 1521 | bool loadOk = true; |
1522 | if ( !categories.isEmpty() ) | 1522 | if ( !categories.isEmpty() ) |
1523 | loadOk = qtopiaFormat.load( calendar, categories ); | 1523 | loadOk = qtopiaFormat.load( calendar, categories ); |
1524 | if ( loadOk && !datebook.isEmpty() ) | 1524 | if ( loadOk && !datebook.isEmpty() ) |
1525 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1525 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1526 | if ( loadOk && !todolist.isEmpty() ) | 1526 | if ( loadOk && !todolist.isEmpty() ) |
1527 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1527 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1528 | 1528 | ||
1529 | if ( loadOk ) { | 1529 | if ( loadOk ) { |
1530 | getEventViewerDialog()->setSyncMode( true ); | 1530 | getEventViewerDialog()->setSyncMode( true ); |
1531 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1531 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1532 | getEventViewerDialog()->setSyncMode( false ); | 1532 | getEventViewerDialog()->setSyncMode( false ); |
1533 | qApp->processEvents(); | 1533 | qApp->processEvents(); |
1534 | if ( syncOK ) { | 1534 | if ( syncOK ) { |
1535 | if ( mSyncManager->mWriteBackFile ) | 1535 | if ( mSyncManager->mWriteBackFile ) |
1536 | { | 1536 | { |
1537 | // write back XML file | 1537 | // write back XML file |
1538 | 1538 | ||
1539 | } | 1539 | } |
1540 | setModified( true ); | 1540 | setModified( true ); |
1541 | } | 1541 | } |
1542 | } else { | 1542 | } else { |
1543 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1543 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1544 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1544 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1545 | question, i18n("Ok")) ; | 1545 | question, i18n("Ok")) ; |
1546 | } | 1546 | } |
1547 | delete calendar; | 1547 | delete calendar; |
1548 | updateView(); | 1548 | updateView(); |
1549 | return syncOK; | 1549 | return syncOK; |
1550 | 1550 | ||
1551 | 1551 | ||
1552 | #endif | 1552 | #endif |
1553 | 1553 | ||
1554 | } | 1554 | } |
1555 | 1555 | ||
1556 | void CalendarView::setSyncEventsReadOnly() | 1556 | void CalendarView::setSyncEventsReadOnly() |
1557 | { | 1557 | { |
1558 | Event * ev; | 1558 | Event * ev; |
1559 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1559 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1560 | ev = eL.first(); | 1560 | ev = eL.first(); |
1561 | while ( ev ) { | 1561 | while ( ev ) { |
1562 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1562 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1563 | ev->setReadOnly( true ); | 1563 | ev->setReadOnly( true ); |
1564 | ev = eL.next(); | 1564 | ev = eL.next(); |
1565 | } | 1565 | } |
1566 | } | 1566 | } |
1567 | bool CalendarView::openCalendar(QString filename, bool merge) | 1567 | bool CalendarView::openCalendar(QString filename, bool merge) |
1568 | { | 1568 | { |
1569 | 1569 | ||
1570 | if (filename.isEmpty()) { | 1570 | if (filename.isEmpty()) { |
1571 | return false; | 1571 | return false; |
1572 | } | 1572 | } |
1573 | 1573 | ||
1574 | if (!QFile::exists(filename)) { | 1574 | if (!QFile::exists(filename)) { |
1575 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1575 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1576 | return false; | 1576 | return false; |
1577 | } | 1577 | } |
1578 | 1578 | ||
1579 | globalFlagBlockAgenda = 1; | 1579 | globalFlagBlockAgenda = 1; |
1580 | if (!merge) mCalendar->close(); | 1580 | if (!merge) mCalendar->close(); |
1581 | 1581 | ||
1582 | mStorage->setFileName( filename ); | 1582 | mStorage->setFileName( filename ); |
1583 | 1583 | ||
1584 | if ( mStorage->load() ) { | 1584 | if ( mStorage->load() ) { |
1585 | if ( merge ) ;//setModified( true ); | 1585 | if ( merge ) ;//setModified( true ); |
1586 | else { | 1586 | else { |
1587 | //setModified( true ); | 1587 | //setModified( true ); |
1588 | mViewManager->setDocumentId( filename ); | 1588 | mViewManager->setDocumentId( filename ); |
1589 | mDialogManager->setDocumentId( filename ); | 1589 | mDialogManager->setDocumentId( filename ); |
1590 | mTodoList->setDocumentId( filename ); | 1590 | mTodoList->setDocumentId( filename ); |
1591 | } | 1591 | } |
1592 | globalFlagBlockAgenda = 2; | 1592 | globalFlagBlockAgenda = 2; |
1593 | // if ( getLastSyncEvent() ) | 1593 | // if ( getLastSyncEvent() ) |
1594 | // getLastSyncEvent()->setReadOnly( true ); | 1594 | // getLastSyncEvent()->setReadOnly( true ); |
1595 | mCalendar->reInitAlarmSettings(); | 1595 | mCalendar->reInitAlarmSettings(); |
1596 | setSyncEventsReadOnly(); | 1596 | setSyncEventsReadOnly(); |
1597 | updateUnmanagedViews(); | 1597 | updateUnmanagedViews(); |
1598 | updateView(); | 1598 | updateView(); |
1599 | if ( filename != MainWindow::defaultFileName() ) { | 1599 | if ( filename != MainWindow::defaultFileName() ) { |
1600 | saveCalendar( MainWindow::defaultFileName() ); | 1600 | saveCalendar( MainWindow::defaultFileName() ); |
1601 | } else { | 1601 | } else { |
1602 | QFileInfo finf ( MainWindow::defaultFileName()); | 1602 | QFileInfo finf ( MainWindow::defaultFileName()); |
1603 | if ( finf.exists() ) { | 1603 | if ( finf.exists() ) { |
1604 | setLoadedFileVersion( finf.lastModified () ); | 1604 | setLoadedFileVersion( finf.lastModified () ); |
1605 | } | 1605 | } |
1606 | } | 1606 | } |
1607 | return true; | 1607 | return true; |
1608 | } else { | 1608 | } else { |
1609 | // while failing to load, the calendar object could | 1609 | // while failing to load, the calendar object could |
1610 | // have become partially populated. Clear it out. | 1610 | // have become partially populated. Clear it out. |
1611 | if ( !merge ) { | 1611 | if ( !merge ) { |
1612 | mCalendar->close(); | 1612 | mCalendar->close(); |
1613 | mViewManager->setDocumentId( filename ); | 1613 | mViewManager->setDocumentId( filename ); |
1614 | mDialogManager->setDocumentId( filename ); | 1614 | mDialogManager->setDocumentId( filename ); |
1615 | mTodoList->setDocumentId( filename ); | 1615 | mTodoList->setDocumentId( filename ); |
1616 | } | 1616 | } |
1617 | 1617 | ||
1618 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1618 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1619 | 1619 | ||
1620 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1620 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1621 | globalFlagBlockAgenda = 2; | 1621 | globalFlagBlockAgenda = 2; |
1622 | mCalendar->reInitAlarmSettings(); | 1622 | mCalendar->reInitAlarmSettings(); |
1623 | setSyncEventsReadOnly(); | 1623 | setSyncEventsReadOnly(); |
1624 | updateUnmanagedViews(); | 1624 | updateUnmanagedViews(); |
1625 | updateView(); | 1625 | updateView(); |
1626 | } | 1626 | } |
1627 | return false; | 1627 | return false; |
1628 | } | 1628 | } |
1629 | void CalendarView::showOpenError() | 1629 | void CalendarView::showOpenError() |
1630 | { | 1630 | { |
1631 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1631 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1632 | } | 1632 | } |
1633 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1633 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1634 | { | 1634 | { |
1635 | loadedFileVersion = dt; | 1635 | loadedFileVersion = dt; |
1636 | } | 1636 | } |
1637 | bool CalendarView::checkFileChanged(QString fn) | 1637 | bool CalendarView::checkFileChanged(QString fn) |
1638 | { | 1638 | { |
1639 | QFileInfo finf ( fn ); | 1639 | QFileInfo finf ( fn ); |
1640 | if ( !finf.exists() ) | 1640 | if ( !finf.exists() ) |
1641 | return true; | 1641 | return true; |
1642 | QDateTime dt = finf.lastModified (); | 1642 | QDateTime dt = finf.lastModified (); |
1643 | if ( dt <= loadedFileVersion ) | 1643 | if ( dt <= loadedFileVersion ) |
1644 | return false; | 1644 | return false; |
1645 | return true; | 1645 | return true; |
1646 | 1646 | ||
1647 | } | 1647 | } |
1648 | void CalendarView::watchSavedFile() | 1648 | void CalendarView::watchSavedFile() |
1649 | { | 1649 | { |
1650 | QFileInfo finf ( MainWindow::defaultFileName()); | 1650 | QFileInfo finf ( MainWindow::defaultFileName()); |
1651 | if ( !finf.exists() ) | 1651 | if ( !finf.exists() ) |
1652 | return; | 1652 | return; |
1653 | QDateTime dt = finf.lastModified (); | 1653 | QDateTime dt = finf.lastModified (); |
1654 | if ( dt < loadedFileVersion ) { | 1654 | if ( dt < loadedFileVersion ) { |
1655 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1655 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1656 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1656 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1657 | return; | 1657 | return; |
1658 | } | 1658 | } |
1659 | loadedFileVersion = dt; | 1659 | loadedFileVersion = dt; |
1660 | } | 1660 | } |
1661 | 1661 | ||
1662 | bool CalendarView::checkFileVersion(QString fn) | 1662 | bool CalendarView::checkFileVersion(QString fn) |
1663 | { | 1663 | { |
1664 | QFileInfo finf ( fn ); | 1664 | QFileInfo finf ( fn ); |
1665 | if ( !finf.exists() ) | 1665 | if ( !finf.exists() ) |
1666 | return true; | 1666 | return true; |
1667 | QDateTime dt = finf.lastModified (); | 1667 | QDateTime dt = finf.lastModified (); |
1668 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1668 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1669 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1669 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1670 | if ( dt <= loadedFileVersion ) | 1670 | if ( dt <= loadedFileVersion ) |
1671 | return true; | 1671 | return true; |
1672 | 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, true)) , | 1672 | 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, true)) , |
1673 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1673 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1674 | i18n("Sync+save")); | 1674 | i18n("Sync+save")); |
1675 | 1675 | ||
1676 | if ( km == KMessageBox::Cancel ) | 1676 | if ( km == KMessageBox::Cancel ) |
1677 | return false; | 1677 | return false; |
1678 | if ( km == KMessageBox::Yes ) | 1678 | if ( km == KMessageBox::Yes ) |
1679 | return true; | 1679 | return true; |
1680 | 1680 | ||
1681 | setSyncDevice("deleteaftersync" ); | 1681 | setSyncDevice("deleteaftersync" ); |
1682 | mSyncManager->mAskForPreferences = true; | 1682 | mSyncManager->mAskForPreferences = true; |
1683 | mSyncManager->mSyncAlgoPrefs = 3; | 1683 | mSyncManager->mSyncAlgoPrefs = 3; |
1684 | mSyncManager->mWriteBackFile = false; | 1684 | mSyncManager->mWriteBackFile = false; |
1685 | mSyncManager->mWriteBackExistingOnly = false; | 1685 | mSyncManager->mWriteBackExistingOnly = false; |
1686 | mSyncManager->mShowSyncSummary = false; | 1686 | mSyncManager->mShowSyncSummary = false; |
1687 | syncCalendar( fn, 3 ); | 1687 | syncCalendar( fn, 3 ); |
1688 | Event * e = getLastSyncEvent(); | 1688 | Event * e = getLastSyncEvent(); |
1689 | mCalendar->deleteEvent ( e ); | 1689 | mCalendar->deleteEvent ( e ); |
1690 | updateView(); | 1690 | updateView(); |
1691 | return true; | 1691 | return true; |
1692 | } | 1692 | } |
1693 | 1693 | ||
1694 | bool CalendarView::saveCalendar( QString filename ) | 1694 | bool CalendarView::saveCalendar( QString filename ) |
1695 | { | 1695 | { |
1696 | 1696 | ||
1697 | // Store back all unsaved data into calendar object | 1697 | // Store back all unsaved data into calendar object |
1698 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1698 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1699 | if ( mViewManager->currentView() ) | 1699 | if ( mViewManager->currentView() ) |
1700 | mViewManager->currentView()->flushView(); | 1700 | mViewManager->currentView()->flushView(); |
1701 | 1701 | ||
1702 | 1702 | ||
1703 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1703 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1704 | mStorage->setSaveFormat( new ICalFormat() ); | 1704 | mStorage->setSaveFormat( new ICalFormat() ); |
1705 | mStorage->setFileName( filename ); | 1705 | mStorage->setFileName( filename ); |
1706 | bool success; | 1706 | bool success; |
1707 | success = mStorage->save(); | 1707 | success = mStorage->save(); |
1708 | if ( !success ) { | 1708 | if ( !success ) { |
1709 | return false; | 1709 | return false; |
1710 | } | 1710 | } |
1711 | if ( filename == MainWindow::defaultFileName() ) { | 1711 | if ( filename == MainWindow::defaultFileName() ) { |
1712 | setLoadedFileVersion( lfv ); | 1712 | setLoadedFileVersion( lfv ); |
1713 | watchSavedFile(); | 1713 | watchSavedFile(); |
1714 | } | 1714 | } |
1715 | return true; | 1715 | return true; |
1716 | } | 1716 | } |
1717 | 1717 | ||
1718 | void CalendarView::closeCalendar() | 1718 | void CalendarView::closeCalendar() |
1719 | { | 1719 | { |
1720 | 1720 | ||
1721 | // child windows no longer valid | 1721 | // child windows no longer valid |
1722 | emit closingDown(); | 1722 | emit closingDown(); |
1723 | 1723 | ||
1724 | mCalendar->close(); | 1724 | mCalendar->close(); |
1725 | setModified(false); | 1725 | setModified(false); |
1726 | updateView(); | 1726 | updateView(); |
1727 | } | 1727 | } |
1728 | 1728 | ||
1729 | void CalendarView::archiveCalendar() | 1729 | void CalendarView::archiveCalendar() |
1730 | { | 1730 | { |
1731 | mDialogManager->showArchiveDialog(); | 1731 | mDialogManager->showArchiveDialog(); |
1732 | } | 1732 | } |
1733 | 1733 | ||
1734 | 1734 | ||
1735 | void CalendarView::readSettings() | 1735 | void CalendarView::readSettings() |
1736 | { | 1736 | { |
1737 | 1737 | ||
1738 | 1738 | ||
1739 | // mViewManager->showAgendaView(); | 1739 | // mViewManager->showAgendaView(); |
1740 | QString str; | 1740 | QString str; |
1741 | //qDebug("CalendarView::readSettings() "); | 1741 | //qDebug("CalendarView::readSettings() "); |
1742 | // read settings from the KConfig, supplying reasonable | 1742 | // read settings from the KConfig, supplying reasonable |
1743 | // defaults where none are to be found | 1743 | // defaults where none are to be found |
1744 | KConfig *config = KOGlobals::config(); | 1744 | KConfig *config = KOGlobals::config(); |
1745 | #ifndef KORG_NOSPLITTER | 1745 | #ifndef KORG_NOSPLITTER |
1746 | config->setGroup("KOrganizer Geometry"); | 1746 | config->setGroup("KOrganizer Geometry"); |
1747 | 1747 | ||
1748 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1748 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1749 | if (sizes.count() != 2) { | 1749 | if (sizes.count() != 2) { |
1750 | sizes << mDateNavigator->minimumSizeHint().width(); | 1750 | sizes << mDateNavigator->minimumSizeHint().width(); |
1751 | sizes << 300; | 1751 | sizes << 300; |
1752 | } | 1752 | } |
1753 | mPanner->setSizes(sizes); | 1753 | mPanner->setSizes(sizes); |
1754 | 1754 | ||
1755 | sizes = config->readIntListEntry("Separator2"); | 1755 | sizes = config->readIntListEntry("Separator2"); |
1756 | if ( ( mResourceView && sizes.count() == 4 ) || | 1756 | if ( ( mResourceView && sizes.count() == 4 ) || |
1757 | ( !mResourceView && sizes.count() == 3 ) ) { | 1757 | ( !mResourceView && sizes.count() == 3 ) ) { |
1758 | mLeftSplitter->setSizes(sizes); | 1758 | mLeftSplitter->setSizes(sizes); |
1759 | } | 1759 | } |
1760 | #endif | 1760 | #endif |
1761 | globalFlagBlockAgenda = 1; | 1761 | globalFlagBlockAgenda = 1; |
1762 | mViewManager->showAgendaView(); | 1762 | mViewManager->showAgendaView(); |
1763 | //mViewManager->readSettings( config ); | 1763 | //mViewManager->readSettings( config ); |
1764 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1764 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1765 | readFilterSettings(config); | 1765 | readFilterSettings(config); |
1766 | config->setGroup( "Views" ); | 1766 | config->setGroup( "Views" ); |
1767 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1767 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1768 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1768 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1769 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1769 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1770 | else mNavigator->selectDates( dateCount ); | 1770 | else mNavigator->selectDates( dateCount ); |
1771 | // mViewManager->readSettings( config ); | 1771 | // mViewManager->readSettings( config ); |
1772 | updateConfig(); | 1772 | updateConfig(); |
1773 | globalFlagBlockAgenda = 2; | 1773 | globalFlagBlockAgenda = 2; |
1774 | mViewManager->readSettings( config ); | 1774 | mViewManager->readSettings( config ); |
1775 | #ifdef DESKTOP_VERSION | 1775 | #ifdef DESKTOP_VERSION |
1776 | config->setGroup("WidgetLayout"); | 1776 | config->setGroup("WidgetLayout"); |
1777 | QStringList list; | 1777 | QStringList list; |
1778 | list = config->readListEntry("MainLayout"); | 1778 | list = config->readListEntry("MainLayout"); |
1779 | int x,y,w,h; | 1779 | int x,y,w,h; |
1780 | if ( ! list.isEmpty() ) { | 1780 | if ( ! list.isEmpty() ) { |
1781 | x = list[0].toInt(); | 1781 | x = list[0].toInt(); |
1782 | y = list[1].toInt(); | 1782 | y = list[1].toInt(); |
1783 | w = list[2].toInt(); | 1783 | w = list[2].toInt(); |
1784 | h = list[3].toInt(); | 1784 | h = list[3].toInt(); |
1785 | topLevelWidget()->setGeometry(x,y,w,h); | 1785 | topLevelWidget()->setGeometry(x,y,w,h); |
1786 | 1786 | ||
1787 | } else { | 1787 | } else { |
1788 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1788 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1789 | } | 1789 | } |
1790 | list = config->readListEntry("EditEventLayout"); | 1790 | list = config->readListEntry("EditEventLayout"); |
1791 | if ( ! list.isEmpty() ) { | 1791 | if ( ! list.isEmpty() ) { |
1792 | x = list[0].toInt(); | 1792 | x = list[0].toInt(); |
1793 | y = list[1].toInt(); | 1793 | y = list[1].toInt(); |
1794 | w = list[2].toInt(); | 1794 | w = list[2].toInt(); |
1795 | h = list[3].toInt(); | 1795 | h = list[3].toInt(); |
1796 | mEventEditor->setGeometry(x,y,w,h); | 1796 | mEventEditor->setGeometry(x,y,w,h); |
1797 | 1797 | ||
1798 | } | 1798 | } |
1799 | list = config->readListEntry("EditTodoLayout"); | 1799 | list = config->readListEntry("EditTodoLayout"); |
1800 | if ( ! list.isEmpty() ) { | 1800 | if ( ! list.isEmpty() ) { |
1801 | x = list[0].toInt(); | 1801 | x = list[0].toInt(); |
1802 | y = list[1].toInt(); | 1802 | y = list[1].toInt(); |
1803 | w = list[2].toInt(); | 1803 | w = list[2].toInt(); |
1804 | h = list[3].toInt(); | 1804 | h = list[3].toInt(); |
1805 | mTodoEditor->setGeometry(x,y,w,h); | 1805 | mTodoEditor->setGeometry(x,y,w,h); |
1806 | 1806 | ||
1807 | } | 1807 | } |
1808 | list = config->readListEntry("ViewerLayout"); | 1808 | list = config->readListEntry("ViewerLayout"); |
1809 | if ( ! list.isEmpty() ) { | 1809 | if ( ! list.isEmpty() ) { |
1810 | x = list[0].toInt(); | 1810 | x = list[0].toInt(); |
1811 | y = list[1].toInt(); | 1811 | y = list[1].toInt(); |
1812 | w = list[2].toInt(); | 1812 | w = list[2].toInt(); |
1813 | h = list[3].toInt(); | 1813 | h = list[3].toInt(); |
1814 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1814 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1815 | } | 1815 | } |
1816 | #endif | 1816 | #endif |
1817 | 1817 | ||
1818 | } | 1818 | } |
1819 | 1819 | ||
1820 | 1820 | ||
1821 | void CalendarView::writeSettings() | 1821 | void CalendarView::writeSettings() |
1822 | { | 1822 | { |
1823 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1823 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1824 | 1824 | ||
1825 | KConfig *config = KOGlobals::config(); | 1825 | KConfig *config = KOGlobals::config(); |
1826 | 1826 | ||
1827 | #ifndef KORG_NOSPLITTER | 1827 | #ifndef KORG_NOSPLITTER |
1828 | config->setGroup("KOrganizer Geometry"); | 1828 | config->setGroup("KOrganizer Geometry"); |
1829 | 1829 | ||
1830 | QValueList<int> list = mPanner->sizes(); | 1830 | QValueList<int> list = mPanner->sizes(); |
1831 | config->writeEntry("Separator1",list); | 1831 | config->writeEntry("Separator1",list); |
1832 | 1832 | ||
1833 | list = mLeftSplitter->sizes(); | 1833 | list = mLeftSplitter->sizes(); |
1834 | config->writeEntry("Separator2",list); | 1834 | config->writeEntry("Separator2",list); |
1835 | #endif | 1835 | #endif |
1836 | 1836 | ||
1837 | mViewManager->writeSettings( config ); | 1837 | mViewManager->writeSettings( config ); |
1838 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1838 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1839 | mDialogManager->writeSettings( config ); | 1839 | mDialogManager->writeSettings( config ); |
1840 | //KOPrefs::instance()->usrWriteConfig(); | 1840 | //KOPrefs::instance()->usrWriteConfig(); |
1841 | KOPrefs::instance()->writeConfig(); | 1841 | KOPrefs::instance()->writeConfig(); |
1842 | 1842 | ||
1843 | writeFilterSettings(config); | 1843 | writeFilterSettings(config); |
1844 | 1844 | ||
1845 | config->setGroup( "Views" ); | 1845 | config->setGroup( "Views" ); |
1846 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1846 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1847 | 1847 | ||
1848 | #ifdef DESKTOP_VERSION | 1848 | #ifdef DESKTOP_VERSION |
1849 | config->setGroup("WidgetLayout"); | 1849 | config->setGroup("WidgetLayout"); |
1850 | QStringList list ;//= config->readListEntry("MainLayout"); | 1850 | QStringList list ;//= config->readListEntry("MainLayout"); |
1851 | int x,y,w,h; | 1851 | int x,y,w,h; |
1852 | QWidget* wid; | 1852 | QWidget* wid; |
1853 | wid = topLevelWidget(); | 1853 | wid = topLevelWidget(); |
1854 | x = wid->geometry().x(); | 1854 | x = wid->geometry().x(); |
1855 | y = wid->geometry().y(); | 1855 | y = wid->geometry().y(); |
1856 | w = wid->width(); | 1856 | w = wid->width(); |
1857 | h = wid->height(); | 1857 | h = wid->height(); |
1858 | list.clear(); | 1858 | list.clear(); |
1859 | list << QString::number( x ); | 1859 | list << QString::number( x ); |
1860 | list << QString::number( y ); | 1860 | list << QString::number( y ); |
1861 | list << QString::number( w ); | 1861 | list << QString::number( w ); |
1862 | list << QString::number( h ); | 1862 | list << QString::number( h ); |
1863 | config->writeEntry("MainLayout",list ); | 1863 | config->writeEntry("MainLayout",list ); |
1864 | 1864 | ||
1865 | wid = mEventEditor; | 1865 | wid = mEventEditor; |
1866 | x = wid->geometry().x(); | 1866 | x = wid->geometry().x(); |
1867 | y = wid->geometry().y(); | 1867 | y = wid->geometry().y(); |
1868 | w = wid->width(); | 1868 | w = wid->width(); |
1869 | h = wid->height(); | 1869 | h = wid->height(); |
1870 | list.clear(); | 1870 | list.clear(); |
1871 | list << QString::number( x ); | 1871 | list << QString::number( x ); |
1872 | list << QString::number( y ); | 1872 | list << QString::number( y ); |
1873 | list << QString::number( w ); | 1873 | list << QString::number( w ); |
1874 | list << QString::number( h ); | 1874 | list << QString::number( h ); |
1875 | config->writeEntry("EditEventLayout",list ); | 1875 | config->writeEntry("EditEventLayout",list ); |
1876 | 1876 | ||
1877 | wid = mTodoEditor; | 1877 | wid = mTodoEditor; |
1878 | x = wid->geometry().x(); | 1878 | x = wid->geometry().x(); |
1879 | y = wid->geometry().y(); | 1879 | y = wid->geometry().y(); |
1880 | w = wid->width(); | 1880 | w = wid->width(); |
1881 | h = wid->height(); | 1881 | h = wid->height(); |
1882 | list.clear(); | 1882 | list.clear(); |
1883 | list << QString::number( x ); | 1883 | list << QString::number( x ); |
1884 | list << QString::number( y ); | 1884 | list << QString::number( y ); |
1885 | list << QString::number( w ); | 1885 | list << QString::number( w ); |
1886 | list << QString::number( h ); | 1886 | list << QString::number( h ); |
1887 | config->writeEntry("EditTodoLayout",list ); | 1887 | config->writeEntry("EditTodoLayout",list ); |
1888 | wid = getEventViewerDialog(); | 1888 | wid = getEventViewerDialog(); |
1889 | x = wid->geometry().x(); | 1889 | x = wid->geometry().x(); |
1890 | y = wid->geometry().y(); | 1890 | y = wid->geometry().y(); |
1891 | w = wid->width(); | 1891 | w = wid->width(); |
1892 | h = wid->height(); | 1892 | h = wid->height(); |
1893 | list.clear(); | 1893 | list.clear(); |
1894 | list << QString::number( x ); | 1894 | list << QString::number( x ); |
1895 | list << QString::number( y ); | 1895 | list << QString::number( y ); |
1896 | list << QString::number( w ); | 1896 | list << QString::number( w ); |
1897 | list << QString::number( h ); | 1897 | list << QString::number( h ); |
1898 | config->writeEntry("ViewerLayout",list ); | 1898 | config->writeEntry("ViewerLayout",list ); |
1899 | wid = mDialogManager->getSearchDialog(); | 1899 | wid = mDialogManager->getSearchDialog(); |
1900 | if ( wid ) { | 1900 | if ( wid ) { |
1901 | x = wid->geometry().x(); | 1901 | x = wid->geometry().x(); |
1902 | y = wid->geometry().y(); | 1902 | y = wid->geometry().y(); |
1903 | w = wid->width(); | 1903 | w = wid->width(); |
1904 | h = wid->height(); | 1904 | h = wid->height(); |
1905 | list.clear(); | 1905 | list.clear(); |
1906 | list << QString::number( x ); | 1906 | list << QString::number( x ); |
1907 | list << QString::number( y ); | 1907 | list << QString::number( y ); |
1908 | list << QString::number( w ); | 1908 | list << QString::number( w ); |
1909 | list << QString::number( h ); | 1909 | list << QString::number( h ); |
1910 | config->writeEntry("SearchLayout",list ); | 1910 | config->writeEntry("SearchLayout",list ); |
1911 | } | 1911 | } |
1912 | #endif | 1912 | #endif |
1913 | 1913 | ||
1914 | 1914 | ||
1915 | config->sync(); | 1915 | config->sync(); |
1916 | } | 1916 | } |
1917 | 1917 | ||
1918 | void CalendarView::readFilterSettings(KConfig *config) | 1918 | void CalendarView::readFilterSettings(KConfig *config) |
1919 | { | 1919 | { |
1920 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1920 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1921 | 1921 | ||
1922 | mFilters.clear(); | 1922 | mFilters.clear(); |
1923 | 1923 | ||
1924 | config->setGroup("General"); | 1924 | config->setGroup("General"); |
1925 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1925 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1926 | 1926 | ||
1927 | QStringList::ConstIterator it = filterList.begin(); | 1927 | QStringList::ConstIterator it = filterList.begin(); |
1928 | QStringList::ConstIterator end = filterList.end(); | 1928 | QStringList::ConstIterator end = filterList.end(); |
1929 | while(it != end) { | 1929 | while(it != end) { |
1930 | // kdDebug() << " filter: " << (*it) << endl; | 1930 | // kdDebug() << " filter: " << (*it) << endl; |
1931 | 1931 | ||
1932 | CalFilter *filter; | 1932 | CalFilter *filter; |
1933 | filter = new CalFilter(*it); | 1933 | filter = new CalFilter(*it); |
1934 | config->setGroup("Filter_" + (*it)); | 1934 | config->setGroup("Filter_" + (*it)); |
1935 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1935 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1936 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1936 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1937 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1937 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1938 | mFilters.append(filter); | 1938 | mFilters.append(filter); |
1939 | 1939 | ||
1940 | ++it; | 1940 | ++it; |
1941 | } | 1941 | } |
1942 | 1942 | ||
1943 | if (mFilters.count() == 0) { | 1943 | if (mFilters.count() == 0) { |
1944 | CalFilter *filter = new CalFilter(i18n("Default")); | 1944 | CalFilter *filter = new CalFilter(i18n("Default")); |
1945 | mFilters.append(filter); | 1945 | mFilters.append(filter); |
1946 | } | 1946 | } |
1947 | mFilterView->updateFilters(); | 1947 | mFilterView->updateFilters(); |
1948 | config->setGroup("FilterView"); | 1948 | config->setGroup("FilterView"); |
1949 | 1949 | ||
1950 | mFilterView->blockSignals(true); | 1950 | mFilterView->blockSignals(true); |
1951 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1951 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1952 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1952 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1953 | mFilterView->blockSignals(false); | 1953 | mFilterView->blockSignals(false); |
1954 | // We do it manually to avoid it being done twice by the above calls | 1954 | // We do it manually to avoid it being done twice by the above calls |
@@ -2980,801 +2980,798 @@ void CalendarView::action_mail() | |||
2980 | #if 0 | 2980 | #if 0 |
2981 | Event *anEvent = 0; | 2981 | Event *anEvent = 0; |
2982 | if (mViewManager->currentView()->isEventView()) { | 2982 | if (mViewManager->currentView()->isEventView()) { |
2983 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 2983 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
2984 | } | 2984 | } |
2985 | 2985 | ||
2986 | if (!anEvent) { | 2986 | if (!anEvent) { |
2987 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2987 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2988 | return; | 2988 | return; |
2989 | } | 2989 | } |
2990 | if(anEvent->attendeeCount() == 0 ) { | 2990 | if(anEvent->attendeeCount() == 0 ) { |
2991 | KMessageBox::sorry(this, | 2991 | KMessageBox::sorry(this, |
2992 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2992 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2993 | return; | 2993 | return; |
2994 | } | 2994 | } |
2995 | 2995 | ||
2996 | mailobject.emailEvent(anEvent); | 2996 | mailobject.emailEvent(anEvent); |
2997 | #endif | 2997 | #endif |
2998 | } | 2998 | } |
2999 | 2999 | ||
3000 | 3000 | ||
3001 | void CalendarView::schedule_publish(Incidence *incidence) | 3001 | void CalendarView::schedule_publish(Incidence *incidence) |
3002 | { | 3002 | { |
3003 | Event *event = 0; | 3003 | Event *event = 0; |
3004 | Todo *todo = 0; | 3004 | Todo *todo = 0; |
3005 | 3005 | ||
3006 | if (incidence == 0) { | 3006 | if (incidence == 0) { |
3007 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3007 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3008 | if (incidence == 0) { | 3008 | if (incidence == 0) { |
3009 | incidence = mTodoList->selectedIncidences().first(); | 3009 | incidence = mTodoList->selectedIncidences().first(); |
3010 | } | 3010 | } |
3011 | } | 3011 | } |
3012 | if ( incidence && incidence->type() == "Event" ) { | 3012 | if ( incidence && incidence->type() == "Event" ) { |
3013 | event = static_cast<Event *>(incidence); | 3013 | event = static_cast<Event *>(incidence); |
3014 | } else { | 3014 | } else { |
3015 | if ( incidence && incidence->type() == "Todo" ) { | 3015 | if ( incidence && incidence->type() == "Todo" ) { |
3016 | todo = static_cast<Todo *>(incidence); | 3016 | todo = static_cast<Todo *>(incidence); |
3017 | } | 3017 | } |
3018 | } | 3018 | } |
3019 | 3019 | ||
3020 | if (!event && !todo) { | 3020 | if (!event && !todo) { |
3021 | KMessageBox::sorry(this,i18n("No event selected.")); | 3021 | KMessageBox::sorry(this,i18n("No event selected.")); |
3022 | return; | 3022 | return; |
3023 | } | 3023 | } |
3024 | 3024 | ||
3025 | PublishDialog *publishdlg = new PublishDialog(); | 3025 | PublishDialog *publishdlg = new PublishDialog(); |
3026 | if (incidence->attendeeCount()>0) { | 3026 | if (incidence->attendeeCount()>0) { |
3027 | QPtrList<Attendee> attendees = incidence->attendees(); | 3027 | QPtrList<Attendee> attendees = incidence->attendees(); |
3028 | attendees.first(); | 3028 | attendees.first(); |
3029 | while ( attendees.current()!=0 ) { | 3029 | while ( attendees.current()!=0 ) { |
3030 | publishdlg->addAttendee(attendees.current()); | 3030 | publishdlg->addAttendee(attendees.current()); |
3031 | attendees.next(); | 3031 | attendees.next(); |
3032 | } | 3032 | } |
3033 | } | 3033 | } |
3034 | bool send = true; | 3034 | bool send = true; |
3035 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3035 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3036 | if ( publishdlg->exec() != QDialog::Accepted ) | 3036 | if ( publishdlg->exec() != QDialog::Accepted ) |
3037 | send = false; | 3037 | send = false; |
3038 | } | 3038 | } |
3039 | if ( send ) { | 3039 | if ( send ) { |
3040 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3040 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3041 | if ( event ) { | 3041 | if ( event ) { |
3042 | Event *ev = new Event(*event); | 3042 | Event *ev = new Event(*event); |
3043 | ev->registerObserver(0); | 3043 | ev->registerObserver(0); |
3044 | ev->clearAttendees(); | 3044 | ev->clearAttendees(); |
3045 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3045 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3046 | delete(ev); | 3046 | delete(ev); |
3047 | } | 3047 | } |
3048 | } else { | 3048 | } else { |
3049 | if ( todo ) { | 3049 | if ( todo ) { |
3050 | Todo *ev = new Todo(*todo); | 3050 | Todo *ev = new Todo(*todo); |
3051 | ev->registerObserver(0); | 3051 | ev->registerObserver(0); |
3052 | ev->clearAttendees(); | 3052 | ev->clearAttendees(); |
3053 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3053 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3054 | delete(ev); | 3054 | delete(ev); |
3055 | } | 3055 | } |
3056 | } | 3056 | } |
3057 | } | 3057 | } |
3058 | } | 3058 | } |
3059 | delete publishdlg; | 3059 | delete publishdlg; |
3060 | } | 3060 | } |
3061 | 3061 | ||
3062 | void CalendarView::schedule_request(Incidence *incidence) | 3062 | void CalendarView::schedule_request(Incidence *incidence) |
3063 | { | 3063 | { |
3064 | schedule(Scheduler::Request,incidence); | 3064 | schedule(Scheduler::Request,incidence); |
3065 | } | 3065 | } |
3066 | 3066 | ||
3067 | void CalendarView::schedule_refresh(Incidence *incidence) | 3067 | void CalendarView::schedule_refresh(Incidence *incidence) |
3068 | { | 3068 | { |
3069 | schedule(Scheduler::Refresh,incidence); | 3069 | schedule(Scheduler::Refresh,incidence); |
3070 | } | 3070 | } |
3071 | 3071 | ||
3072 | void CalendarView::schedule_cancel(Incidence *incidence) | 3072 | void CalendarView::schedule_cancel(Incidence *incidence) |
3073 | { | 3073 | { |
3074 | schedule(Scheduler::Cancel,incidence); | 3074 | schedule(Scheduler::Cancel,incidence); |
3075 | } | 3075 | } |
3076 | 3076 | ||
3077 | void CalendarView::schedule_add(Incidence *incidence) | 3077 | void CalendarView::schedule_add(Incidence *incidence) |
3078 | { | 3078 | { |
3079 | schedule(Scheduler::Add,incidence); | 3079 | schedule(Scheduler::Add,incidence); |
3080 | } | 3080 | } |
3081 | 3081 | ||
3082 | void CalendarView::schedule_reply(Incidence *incidence) | 3082 | void CalendarView::schedule_reply(Incidence *incidence) |
3083 | { | 3083 | { |
3084 | schedule(Scheduler::Reply,incidence); | 3084 | schedule(Scheduler::Reply,incidence); |
3085 | } | 3085 | } |
3086 | 3086 | ||
3087 | void CalendarView::schedule_counter(Incidence *incidence) | 3087 | void CalendarView::schedule_counter(Incidence *incidence) |
3088 | { | 3088 | { |
3089 | schedule(Scheduler::Counter,incidence); | 3089 | schedule(Scheduler::Counter,incidence); |
3090 | } | 3090 | } |
3091 | 3091 | ||
3092 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3092 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3093 | { | 3093 | { |
3094 | schedule(Scheduler::Declinecounter,incidence); | 3094 | schedule(Scheduler::Declinecounter,incidence); |
3095 | } | 3095 | } |
3096 | 3096 | ||
3097 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3097 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3098 | { | 3098 | { |
3099 | QDateTime start = QDateTime::currentDateTime(); | 3099 | QDateTime start = QDateTime::currentDateTime(); |
3100 | QDateTime end = start.addDays(daysToPublish); | 3100 | QDateTime end = start.addDays(daysToPublish); |
3101 | 3101 | ||
3102 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3102 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3103 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3103 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3104 | 3104 | ||
3105 | 3105 | ||
3106 | PublishDialog *publishdlg = new PublishDialog(); | 3106 | PublishDialog *publishdlg = new PublishDialog(); |
3107 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3107 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3108 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3108 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3109 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3109 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3110 | delete(freebusy); | 3110 | delete(freebusy); |
3111 | } | 3111 | } |
3112 | } | 3112 | } |
3113 | delete publishdlg; | 3113 | delete publishdlg; |
3114 | } | 3114 | } |
3115 | 3115 | ||
3116 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3116 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3117 | { | 3117 | { |
3118 | Event *event = 0; | 3118 | Event *event = 0; |
3119 | Todo *todo = 0; | 3119 | Todo *todo = 0; |
3120 | 3120 | ||
3121 | if (incidence == 0) { | 3121 | if (incidence == 0) { |
3122 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3122 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3123 | if (incidence == 0) { | 3123 | if (incidence == 0) { |
3124 | incidence = mTodoList->selectedIncidences().first(); | 3124 | incidence = mTodoList->selectedIncidences().first(); |
3125 | } | 3125 | } |
3126 | } | 3126 | } |
3127 | if ( incidence && incidence->type() == "Event" ) { | 3127 | if ( incidence && incidence->type() == "Event" ) { |
3128 | event = static_cast<Event *>(incidence); | 3128 | event = static_cast<Event *>(incidence); |
3129 | } | 3129 | } |
3130 | if ( incidence && incidence->type() == "Todo" ) { | 3130 | if ( incidence && incidence->type() == "Todo" ) { |
3131 | todo = static_cast<Todo *>(incidence); | 3131 | todo = static_cast<Todo *>(incidence); |
3132 | } | 3132 | } |
3133 | 3133 | ||
3134 | if (!event && !todo) { | 3134 | if (!event && !todo) { |
3135 | KMessageBox::sorry(this,i18n("No event selected.")); | 3135 | KMessageBox::sorry(this,i18n("No event selected.")); |
3136 | return; | 3136 | return; |
3137 | } | 3137 | } |
3138 | 3138 | ||
3139 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3139 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3140 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3140 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3141 | return; | 3141 | return; |
3142 | } | 3142 | } |
3143 | 3143 | ||
3144 | Event *ev = 0; | 3144 | Event *ev = 0; |
3145 | if (event) ev = new Event(*event); | 3145 | if (event) ev = new Event(*event); |
3146 | Todo *to = 0; | 3146 | Todo *to = 0; |
3147 | if (todo) to = new Todo(*todo); | 3147 | if (todo) to = new Todo(*todo); |
3148 | 3148 | ||
3149 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3149 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3150 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3150 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3151 | if (!me) { | 3151 | if (!me) { |
3152 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3152 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3153 | return; | 3153 | return; |
3154 | } | 3154 | } |
3155 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3155 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3156 | StatusDialog *statdlg = new StatusDialog(this); | 3156 | StatusDialog *statdlg = new StatusDialog(this); |
3157 | if (!statdlg->exec()==QDialog::Accepted) return; | 3157 | if (!statdlg->exec()==QDialog::Accepted) return; |
3158 | me->setStatus( statdlg->status() ); | 3158 | me->setStatus( statdlg->status() ); |
3159 | delete(statdlg); | 3159 | delete(statdlg); |
3160 | } | 3160 | } |
3161 | Attendee *menew = new Attendee(*me); | 3161 | Attendee *menew = new Attendee(*me); |
3162 | if (ev) { | 3162 | if (ev) { |
3163 | ev->clearAttendees(); | 3163 | ev->clearAttendees(); |
3164 | ev->addAttendee(menew,false); | 3164 | ev->addAttendee(menew,false); |
3165 | } else { | 3165 | } else { |
3166 | if (to) { | 3166 | if (to) { |
3167 | todo->clearAttendees(); | 3167 | todo->clearAttendees(); |
3168 | todo->addAttendee(menew,false); | 3168 | todo->addAttendee(menew,false); |
3169 | } | 3169 | } |
3170 | } | 3170 | } |
3171 | } | 3171 | } |
3172 | 3172 | ||
3173 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3173 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3174 | if (ev) { | 3174 | if (ev) { |
3175 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3175 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3176 | } else { | 3176 | } else { |
3177 | if (to) { | 3177 | if (to) { |
3178 | if ( !dlg->addMessage(to,method) ) delete(to); | 3178 | if ( !dlg->addMessage(to,method) ) delete(to); |
3179 | } | 3179 | } |
3180 | } | 3180 | } |
3181 | } | 3181 | } |
3182 | 3182 | ||
3183 | void CalendarView::openAddressbook() | 3183 | void CalendarView::openAddressbook() |
3184 | { | 3184 | { |
3185 | KRun::runCommand("kaddressbook"); | 3185 | KRun::runCommand("kaddressbook"); |
3186 | } | 3186 | } |
3187 | 3187 | ||
3188 | void CalendarView::setModified(bool modified) | 3188 | void CalendarView::setModified(bool modified) |
3189 | { | 3189 | { |
3190 | if ( modified ) | 3190 | if ( modified ) |
3191 | emit signalmodified(); | 3191 | emit signalmodified(); |
3192 | if (mModified != modified) { | 3192 | if (mModified != modified) { |
3193 | mModified = modified; | 3193 | mModified = modified; |
3194 | emit modifiedChanged(mModified); | 3194 | emit modifiedChanged(mModified); |
3195 | } | 3195 | } |
3196 | } | 3196 | } |
3197 | 3197 | ||
3198 | bool CalendarView::isReadOnly() | 3198 | bool CalendarView::isReadOnly() |
3199 | { | 3199 | { |
3200 | return mReadOnly; | 3200 | return mReadOnly; |
3201 | } | 3201 | } |
3202 | 3202 | ||
3203 | void CalendarView::setReadOnly(bool readOnly) | 3203 | void CalendarView::setReadOnly(bool readOnly) |
3204 | { | 3204 | { |
3205 | if (mReadOnly != readOnly) { | 3205 | if (mReadOnly != readOnly) { |
3206 | mReadOnly = readOnly; | 3206 | mReadOnly = readOnly; |
3207 | emit readOnlyChanged(mReadOnly); | 3207 | emit readOnlyChanged(mReadOnly); |
3208 | } | 3208 | } |
3209 | } | 3209 | } |
3210 | 3210 | ||
3211 | bool CalendarView::isModified() | 3211 | bool CalendarView::isModified() |
3212 | { | 3212 | { |
3213 | return mModified; | 3213 | return mModified; |
3214 | } | 3214 | } |
3215 | 3215 | ||
3216 | void CalendarView::printSetup() | 3216 | void CalendarView::printSetup() |
3217 | { | 3217 | { |
3218 | #ifndef KORG_NOPRINTER | 3218 | #ifndef KORG_NOPRINTER |
3219 | createPrinter(); | 3219 | createPrinter(); |
3220 | 3220 | ||
3221 | mCalPrinter->setupPrinter(); | 3221 | mCalPrinter->setupPrinter(); |
3222 | #endif | 3222 | #endif |
3223 | } | 3223 | } |
3224 | 3224 | ||
3225 | void CalendarView::print() | 3225 | void CalendarView::print() |
3226 | { | 3226 | { |
3227 | #ifndef KORG_NOPRINTER | 3227 | #ifndef KORG_NOPRINTER |
3228 | createPrinter(); | 3228 | createPrinter(); |
3229 | 3229 | ||
3230 | DateList tmpDateList = mNavigator->selectedDates(); | 3230 | DateList tmpDateList = mNavigator->selectedDates(); |
3231 | mCalPrinter->print(CalPrinter::Month, | 3231 | mCalPrinter->print(CalPrinter::Month, |
3232 | tmpDateList.first(), tmpDateList.last()); | 3232 | tmpDateList.first(), tmpDateList.last()); |
3233 | #endif | 3233 | #endif |
3234 | } | 3234 | } |
3235 | 3235 | ||
3236 | void CalendarView::printPreview() | 3236 | void CalendarView::printPreview() |
3237 | { | 3237 | { |
3238 | #ifndef KORG_NOPRINTER | 3238 | #ifndef KORG_NOPRINTER |
3239 | kdDebug() << "CalendarView::printPreview()" << endl; | 3239 | kdDebug() << "CalendarView::printPreview()" << endl; |
3240 | 3240 | ||
3241 | createPrinter(); | 3241 | createPrinter(); |
3242 | 3242 | ||
3243 | DateList tmpDateList = mNavigator->selectedDates(); | 3243 | DateList tmpDateList = mNavigator->selectedDates(); |
3244 | 3244 | ||
3245 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3245 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3246 | tmpDateList.last()); | 3246 | tmpDateList.last()); |
3247 | #endif | 3247 | #endif |
3248 | } | 3248 | } |
3249 | 3249 | ||
3250 | void CalendarView::exportICalendar() | 3250 | void CalendarView::exportICalendar() |
3251 | { | 3251 | { |
3252 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3252 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3253 | 3253 | ||
3254 | // Force correct extension | 3254 | // Force correct extension |
3255 | if (filename.right(4) != ".ics") filename += ".ics"; | 3255 | if (filename.right(4) != ".ics") filename += ".ics"; |
3256 | 3256 | ||
3257 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3257 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3258 | storage.save(); | 3258 | storage.save(); |
3259 | } | 3259 | } |
3260 | 3260 | ||
3261 | bool CalendarView::exportVCalendar( QString filename ) | 3261 | bool CalendarView::exportVCalendar( QString filename ) |
3262 | { | 3262 | { |
3263 | if (mCalendar->journals().count() > 0) { | 3263 | if (mCalendar->journals().count() > 0) { |
3264 | int result = KMessageBox::warningContinueCancel(this, | 3264 | int result = KMessageBox::warningContinueCancel(this, |
3265 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3265 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3266 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3266 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3267 | true); | 3267 | true); |
3268 | if (result != KMessageBox::Continue) return false; | 3268 | if (result != KMessageBox::Continue) return false; |
3269 | } | 3269 | } |
3270 | 3270 | ||
3271 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3271 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3272 | 3272 | ||
3273 | // Force correct extension | 3273 | // Force correct extension |
3274 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3274 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3275 | 3275 | ||
3276 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3276 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3277 | return storage.save(); | 3277 | return storage.save(); |
3278 | 3278 | ||
3279 | } | 3279 | } |
3280 | 3280 | ||
3281 | void CalendarView::eventUpdated(Incidence *) | 3281 | void CalendarView::eventUpdated(Incidence *) |
3282 | { | 3282 | { |
3283 | setModified(); | 3283 | setModified(); |
3284 | // Don't call updateView here. The code, which has caused the update of the | 3284 | // Don't call updateView here. The code, which has caused the update of the |
3285 | // event is responsible for updating the view. | 3285 | // event is responsible for updating the view. |
3286 | // updateView(); | 3286 | // updateView(); |
3287 | } | 3287 | } |
3288 | 3288 | ||
3289 | void CalendarView::adaptNavigationUnits() | 3289 | void CalendarView::adaptNavigationUnits() |
3290 | { | 3290 | { |
3291 | if (mViewManager->currentView()->isEventView()) { | 3291 | if (mViewManager->currentView()->isEventView()) { |
3292 | int days = mViewManager->currentView()->currentDateCount(); | 3292 | int days = mViewManager->currentView()->currentDateCount(); |
3293 | if (days == 1) { | 3293 | if (days == 1) { |
3294 | emit changeNavStringPrev(i18n("&Previous Day")); | 3294 | emit changeNavStringPrev(i18n("&Previous Day")); |
3295 | emit changeNavStringNext(i18n("&Next Day")); | 3295 | emit changeNavStringNext(i18n("&Next Day")); |
3296 | } else { | 3296 | } else { |
3297 | emit changeNavStringPrev(i18n("&Previous Week")); | 3297 | emit changeNavStringPrev(i18n("&Previous Week")); |
3298 | emit changeNavStringNext(i18n("&Next Week")); | 3298 | emit changeNavStringNext(i18n("&Next Week")); |
3299 | } | 3299 | } |
3300 | } | 3300 | } |
3301 | } | 3301 | } |
3302 | 3302 | ||
3303 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3303 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3304 | { | 3304 | { |
3305 | if ( incidence ) mTodoList->clearSelection(); | 3305 | if ( incidence ) mTodoList->clearSelection(); |
3306 | processIncidenceSelection( incidence ); | 3306 | processIncidenceSelection( incidence ); |
3307 | } | 3307 | } |
3308 | 3308 | ||
3309 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3309 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3310 | { | 3310 | { |
3311 | if ( incidence && mViewManager->currentView() ) { | 3311 | if ( incidence && mViewManager->currentView() ) { |
3312 | mViewManager->currentView()->clearSelection(); | 3312 | mViewManager->currentView()->clearSelection(); |
3313 | } | 3313 | } |
3314 | processIncidenceSelection( incidence ); | 3314 | processIncidenceSelection( incidence ); |
3315 | } | 3315 | } |
3316 | 3316 | ||
3317 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3317 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3318 | { | 3318 | { |
3319 | if ( incidence == mSelectedIncidence ) return; | 3319 | if ( incidence == mSelectedIncidence ) return; |
3320 | 3320 | ||
3321 | mSelectedIncidence = incidence; | 3321 | mSelectedIncidence = incidence; |
3322 | 3322 | ||
3323 | emit incidenceSelected( mSelectedIncidence ); | 3323 | emit incidenceSelected( mSelectedIncidence ); |
3324 | 3324 | ||
3325 | if ( incidence && incidence->type() == "Event" ) { | 3325 | if ( incidence && incidence->type() == "Event" ) { |
3326 | Event *event = static_cast<Event *>( incidence ); | 3326 | Event *event = static_cast<Event *>( incidence ); |
3327 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3327 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3328 | emit organizerEventsSelected( true ); | 3328 | emit organizerEventsSelected( true ); |
3329 | } else { | 3329 | } else { |
3330 | emit organizerEventsSelected(false); | 3330 | emit organizerEventsSelected(false); |
3331 | } | 3331 | } |
3332 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3332 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3333 | KOPrefs::instance()->email() ) ) { | 3333 | KOPrefs::instance()->email() ) ) { |
3334 | emit groupEventsSelected( true ); | 3334 | emit groupEventsSelected( true ); |
3335 | } else { | 3335 | } else { |
3336 | emit groupEventsSelected(false); | 3336 | emit groupEventsSelected(false); |
3337 | } | 3337 | } |
3338 | return; | 3338 | return; |
3339 | } else { | 3339 | } else { |
3340 | if ( incidence && incidence->type() == "Todo" ) { | 3340 | if ( incidence && incidence->type() == "Todo" ) { |
3341 | emit todoSelected( true ); | 3341 | emit todoSelected( true ); |
3342 | Todo *event = static_cast<Todo *>( incidence ); | 3342 | Todo *event = static_cast<Todo *>( incidence ); |
3343 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3343 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3344 | emit organizerEventsSelected( true ); | 3344 | emit organizerEventsSelected( true ); |
3345 | } else { | 3345 | } else { |
3346 | emit organizerEventsSelected(false); | 3346 | emit organizerEventsSelected(false); |
3347 | } | 3347 | } |
3348 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3348 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3349 | KOPrefs::instance()->email() ) ) { | 3349 | KOPrefs::instance()->email() ) ) { |
3350 | emit groupEventsSelected( true ); | 3350 | emit groupEventsSelected( true ); |
3351 | } else { | 3351 | } else { |
3352 | emit groupEventsSelected(false); | 3352 | emit groupEventsSelected(false); |
3353 | } | 3353 | } |
3354 | return; | 3354 | return; |
3355 | } else { | 3355 | } else { |
3356 | emit todoSelected( false ); | 3356 | emit todoSelected( false ); |
3357 | emit organizerEventsSelected(false); | 3357 | emit organizerEventsSelected(false); |
3358 | emit groupEventsSelected(false); | 3358 | emit groupEventsSelected(false); |
3359 | } | 3359 | } |
3360 | return; | 3360 | return; |
3361 | } | 3361 | } |
3362 | 3362 | ||
3363 | /* if ( incidence && incidence->type() == "Todo" ) { | 3363 | /* if ( incidence && incidence->type() == "Todo" ) { |
3364 | emit todoSelected( true ); | 3364 | emit todoSelected( true ); |
3365 | } else { | 3365 | } else { |
3366 | emit todoSelected( false ); | 3366 | emit todoSelected( false ); |
3367 | }*/ | 3367 | }*/ |
3368 | } | 3368 | } |
3369 | 3369 | ||
3370 | 3370 | ||
3371 | void CalendarView::checkClipboard() | 3371 | void CalendarView::checkClipboard() |
3372 | { | 3372 | { |
3373 | #ifndef KORG_NODND | 3373 | #ifndef KORG_NODND |
3374 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3374 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3375 | emit pasteEnabled(true); | 3375 | emit pasteEnabled(true); |
3376 | } else { | 3376 | } else { |
3377 | emit pasteEnabled(false); | 3377 | emit pasteEnabled(false); |
3378 | } | 3378 | } |
3379 | #endif | 3379 | #endif |
3380 | } | 3380 | } |
3381 | 3381 | ||
3382 | void CalendarView::showDates(const DateList &selectedDates) | 3382 | void CalendarView::showDates(const DateList &selectedDates) |
3383 | { | 3383 | { |
3384 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3384 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3385 | 3385 | ||
3386 | if ( mViewManager->currentView() ) { | 3386 | if ( mViewManager->currentView() ) { |
3387 | updateView( selectedDates.first(), selectedDates.last() ); | 3387 | updateView( selectedDates.first(), selectedDates.last() ); |
3388 | } else { | 3388 | } else { |
3389 | mViewManager->showAgendaView(); | 3389 | mViewManager->showAgendaView(); |
3390 | } | 3390 | } |
3391 | 3391 | ||
3392 | QString selDates; | 3392 | QString selDates; |
3393 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3393 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3394 | if (selectedDates.first() < selectedDates.last() ) | 3394 | if (selectedDates.first() < selectedDates.last() ) |
3395 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3395 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3396 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3396 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3397 | 3397 | ||
3398 | } | 3398 | } |
3399 | 3399 | ||
3400 | QPtrList<CalFilter> CalendarView::filters() | 3400 | QPtrList<CalFilter> CalendarView::filters() |
3401 | { | 3401 | { |
3402 | return mFilters; | 3402 | return mFilters; |
3403 | 3403 | ||
3404 | } | 3404 | } |
3405 | void CalendarView::editFilters() | 3405 | void CalendarView::editFilters() |
3406 | { | 3406 | { |
3407 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3407 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3408 | 3408 | ||
3409 | CalFilter *filter = mFilters.first(); | 3409 | CalFilter *filter = mFilters.first(); |
3410 | while(filter) { | 3410 | while(filter) { |
3411 | kdDebug() << " Filter: " << filter->name() << endl; | 3411 | kdDebug() << " Filter: " << filter->name() << endl; |
3412 | filter = mFilters.next(); | 3412 | filter = mFilters.next(); |
3413 | } | 3413 | } |
3414 | 3414 | ||
3415 | mDialogManager->showFilterEditDialog(&mFilters); | 3415 | mDialogManager->showFilterEditDialog(&mFilters); |
3416 | } | 3416 | } |
3417 | void CalendarView::toggleFilter() | 3417 | void CalendarView::toggleFilter() |
3418 | { | 3418 | { |
3419 | showFilter(! mFilterView->isVisible()); | 3419 | showFilter(! mFilterView->isVisible()); |
3420 | } | 3420 | } |
3421 | 3421 | ||
3422 | KOFilterView *CalendarView::filterView() | 3422 | KOFilterView *CalendarView::filterView() |
3423 | { | 3423 | { |
3424 | return mFilterView; | 3424 | return mFilterView; |
3425 | } | 3425 | } |
3426 | void CalendarView::selectFilter( int fil ) | 3426 | void CalendarView::selectFilter( int fil ) |
3427 | { | 3427 | { |
3428 | mFilterView->setSelectedFilter( fil ); | 3428 | mFilterView->setSelectedFilter( fil ); |
3429 | } | 3429 | } |
3430 | void CalendarView::showFilter(bool visible) | 3430 | void CalendarView::showFilter(bool visible) |
3431 | { | 3431 | { |
3432 | if (visible) mFilterView->show(); | 3432 | if (visible) mFilterView->show(); |
3433 | else mFilterView->hide(); | 3433 | else mFilterView->hide(); |
3434 | } | 3434 | } |
3435 | void CalendarView::toggleFilerEnabled( ) | 3435 | void CalendarView::toggleFilerEnabled( ) |
3436 | { | 3436 | { |
3437 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3437 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3438 | if ( !mFilterView->filtersEnabled() ) | 3438 | if ( !mFilterView->filtersEnabled() ) |
3439 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3439 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3440 | 3440 | ||
3441 | } | 3441 | } |
3442 | void CalendarView::updateFilter() | 3442 | void CalendarView::updateFilter() |
3443 | { | 3443 | { |
3444 | CalFilter *filter = mFilterView->selectedFilter(); | 3444 | CalFilter *filter = mFilterView->selectedFilter(); |
3445 | if (filter) { | 3445 | if (filter) { |
3446 | if (mFilterView->filtersEnabled()) { | 3446 | if (mFilterView->filtersEnabled()) { |
3447 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3447 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3448 | filter->setEnabled(true); | 3448 | filter->setEnabled(true); |
3449 | } | 3449 | } |
3450 | else filter->setEnabled(false); | 3450 | else filter->setEnabled(false); |
3451 | mCalendar->setFilter(filter); | 3451 | mCalendar->setFilter(filter); |
3452 | updateView(); | 3452 | updateView(); |
3453 | } | 3453 | } |
3454 | } | 3454 | } |
3455 | 3455 | ||
3456 | void CalendarView::filterEdited() | 3456 | void CalendarView::filterEdited() |
3457 | { | 3457 | { |
3458 | mFilterView->updateFilters(); | 3458 | mFilterView->updateFilters(); |
3459 | updateFilter(); | 3459 | updateFilter(); |
3460 | writeSettings(); | 3460 | writeSettings(); |
3461 | } | 3461 | } |
3462 | 3462 | ||
3463 | 3463 | ||
3464 | void CalendarView::takeOverEvent() | 3464 | void CalendarView::takeOverEvent() |
3465 | { | 3465 | { |
3466 | Incidence *incidence = currentSelection(); | 3466 | Incidence *incidence = currentSelection(); |
3467 | 3467 | ||
3468 | if (!incidence) return; | 3468 | if (!incidence) return; |
3469 | 3469 | ||
3470 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3470 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3471 | incidence->recreate(); | 3471 | incidence->recreate(); |
3472 | incidence->setReadOnly(false); | 3472 | incidence->setReadOnly(false); |
3473 | 3473 | ||
3474 | updateView(); | 3474 | updateView(); |
3475 | } | 3475 | } |
3476 | 3476 | ||
3477 | void CalendarView::takeOverCalendar() | 3477 | void CalendarView::takeOverCalendar() |
3478 | { | 3478 | { |
3479 | // TODO: Create Calendar::allIncidences() function and use it here | 3479 | // TODO: Create Calendar::allIncidences() function and use it here |
3480 | 3480 | ||
3481 | QPtrList<Event> events = mCalendar->events(); | 3481 | QPtrList<Event> events = mCalendar->events(); |
3482 | for(uint i=0; i<events.count(); ++i) { | 3482 | for(uint i=0; i<events.count(); ++i) { |
3483 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3483 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3484 | events.at(i)->recreate(); | 3484 | events.at(i)->recreate(); |
3485 | events.at(i)->setReadOnly(false); | 3485 | events.at(i)->setReadOnly(false); |
3486 | } | 3486 | } |
3487 | 3487 | ||
3488 | QPtrList<Todo> todos = mCalendar->todos(); | 3488 | QPtrList<Todo> todos = mCalendar->todos(); |
3489 | for(uint i=0; i<todos.count(); ++i) { | 3489 | for(uint i=0; i<todos.count(); ++i) { |
3490 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3490 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3491 | todos.at(i)->recreate(); | 3491 | todos.at(i)->recreate(); |
3492 | todos.at(i)->setReadOnly(false); | 3492 | todos.at(i)->setReadOnly(false); |
3493 | } | 3493 | } |
3494 | 3494 | ||
3495 | QPtrList<Journal> journals = mCalendar->journals(); | 3495 | QPtrList<Journal> journals = mCalendar->journals(); |
3496 | for(uint i=0; i<journals.count(); ++i) { | 3496 | for(uint i=0; i<journals.count(); ++i) { |
3497 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3497 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3498 | journals.at(i)->recreate(); | 3498 | journals.at(i)->recreate(); |
3499 | journals.at(i)->setReadOnly(false); | 3499 | journals.at(i)->setReadOnly(false); |
3500 | } | 3500 | } |
3501 | 3501 | ||
3502 | updateView(); | 3502 | updateView(); |
3503 | } | 3503 | } |
3504 | 3504 | ||
3505 | void CalendarView::showIntro() | 3505 | void CalendarView::showIntro() |
3506 | { | 3506 | { |
3507 | kdDebug() << "To be implemented." << endl; | 3507 | kdDebug() << "To be implemented." << endl; |
3508 | } | 3508 | } |
3509 | 3509 | ||
3510 | QWidgetStack *CalendarView::viewStack() | 3510 | QWidgetStack *CalendarView::viewStack() |
3511 | { | 3511 | { |
3512 | return mRightFrame; | 3512 | return mRightFrame; |
3513 | } | 3513 | } |
3514 | 3514 | ||
3515 | QWidget *CalendarView::leftFrame() | 3515 | QWidget *CalendarView::leftFrame() |
3516 | { | 3516 | { |
3517 | return mLeftFrame; | 3517 | return mLeftFrame; |
3518 | } | 3518 | } |
3519 | 3519 | ||
3520 | DateNavigator *CalendarView::dateNavigator() | 3520 | DateNavigator *CalendarView::dateNavigator() |
3521 | { | 3521 | { |
3522 | return mNavigator; | 3522 | return mNavigator; |
3523 | } | 3523 | } |
3524 | 3524 | ||
3525 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3525 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3526 | { | 3526 | { |
3527 | return mDateNavigator; | 3527 | return mDateNavigator; |
3528 | } | 3528 | } |
3529 | void CalendarView::toggleDateNavigatorWidget() | 3529 | void CalendarView::toggleDateNavigatorWidget() |
3530 | { | 3530 | { |
3531 | if (mDateNavigator->isVisible()) | 3531 | if (mDateNavigator->isVisible()) |
3532 | mDateNavigator->hide(); | 3532 | mDateNavigator->hide(); |
3533 | else | 3533 | else |
3534 | mDateNavigator->show(); | 3534 | mDateNavigator->show(); |
3535 | } | 3535 | } |
3536 | void CalendarView::addView(KOrg::BaseView *view) | 3536 | void CalendarView::addView(KOrg::BaseView *view) |
3537 | { | 3537 | { |
3538 | mViewManager->addView(view); | 3538 | mViewManager->addView(view); |
3539 | } | 3539 | } |
3540 | 3540 | ||
3541 | void CalendarView::showView(KOrg::BaseView *view) | 3541 | void CalendarView::showView(KOrg::BaseView *view) |
3542 | { | 3542 | { |
3543 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3543 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3544 | } | 3544 | } |
3545 | 3545 | ||
3546 | Incidence *CalendarView::currentSelection() | 3546 | Incidence *CalendarView::currentSelection() |
3547 | { | 3547 | { |
3548 | return mViewManager->currentSelection(); | 3548 | return mViewManager->currentSelection(); |
3549 | } | 3549 | } |
3550 | void CalendarView::toggleAllDaySize() | 3550 | void CalendarView::toggleAllDaySize() |
3551 | { | 3551 | { |
3552 | /* | 3552 | /* |
3553 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3553 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3554 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3554 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3555 | else | 3555 | else |
3556 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3556 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3557 | */ | 3557 | */ |
3558 | viewManager()->agendaView()->toggleAllDay(); | 3558 | viewManager()->agendaView()->toggleAllDay(); |
3559 | } | 3559 | } |
3560 | void CalendarView::toggleExpand() | 3560 | void CalendarView::toggleExpand() |
3561 | { | 3561 | { |
3562 | // if ( mLeftFrame->isHidden() ) { | 3562 | // if ( mLeftFrame->isHidden() ) { |
3563 | // mLeftFrame->show(); | 3563 | // mLeftFrame->show(); |
3564 | // emit calendarViewExpanded( false ); | 3564 | // emit calendarViewExpanded( false ); |
3565 | // } else { | 3565 | // } else { |
3566 | // mLeftFrame->hide(); | 3566 | // mLeftFrame->hide(); |
3567 | // emit calendarViewExpanded( true ); | 3567 | // emit calendarViewExpanded( true ); |
3568 | // } | 3568 | // } |
3569 | 3569 | ||
3570 | globalFlagBlockAgenda = 1; | 3570 | globalFlagBlockAgenda = 1; |
3571 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3571 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3572 | globalFlagBlockAgenda = 5; | 3572 | globalFlagBlockAgenda = 5; |
3573 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3573 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3574 | //mViewManager->showView( 0, true ); | 3574 | //mViewManager->showView( 0, true ); |
3575 | } | 3575 | } |
3576 | 3576 | ||
3577 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3577 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3578 | { | 3578 | { |
3579 | setModified( modified ); | 3579 | setModified( modified ); |
3580 | } | 3580 | } |
3581 | 3581 | ||
3582 | Todo *CalendarView::selectedTodo() | 3582 | Todo *CalendarView::selectedTodo() |
3583 | { | 3583 | { |
3584 | Incidence *incidence = currentSelection(); | 3584 | Incidence *incidence = currentSelection(); |
3585 | if ( incidence && incidence->type() == "Todo" ) { | 3585 | if ( incidence && incidence->type() == "Todo" ) { |
3586 | return static_cast<Todo *>( incidence ); | 3586 | return static_cast<Todo *>( incidence ); |
3587 | } | 3587 | } |
3588 | 3588 | ||
3589 | incidence = mTodoList->selectedIncidences().first(); | 3589 | incidence = mTodoList->selectedIncidences().first(); |
3590 | if ( incidence && incidence->type() == "Todo" ) { | 3590 | if ( incidence && incidence->type() == "Todo" ) { |
3591 | return static_cast<Todo *>( incidence ); | 3591 | return static_cast<Todo *>( incidence ); |
3592 | } | 3592 | } |
3593 | 3593 | ||
3594 | return 0; | 3594 | return 0; |
3595 | } | 3595 | } |
3596 | 3596 | ||
3597 | void CalendarView::dialogClosing(Incidence *in) | 3597 | void CalendarView::dialogClosing(Incidence *in) |
3598 | { | 3598 | { |
3599 | // mDialogList.remove(in); | 3599 | // mDialogList.remove(in); |
3600 | } | 3600 | } |
3601 | 3601 | ||
3602 | void CalendarView::showIncidence() | 3602 | void CalendarView::showIncidence() |
3603 | { | 3603 | { |
3604 | Incidence *incidence = currentSelection(); | 3604 | Incidence *incidence = currentSelection(); |
3605 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3605 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3606 | if ( incidence ) { | 3606 | if ( incidence ) { |
3607 | ShowIncidenceVisitor v; | 3607 | ShowIncidenceVisitor v; |
3608 | v.act( incidence, this ); | 3608 | v.act( incidence, this ); |
3609 | } | 3609 | } |
3610 | } | 3610 | } |
3611 | void CalendarView::editIncidenceDescription() | 3611 | void CalendarView::editIncidenceDescription() |
3612 | { | 3612 | { |
3613 | mFlagEditDescription = true; | 3613 | mFlagEditDescription = true; |
3614 | editIncidence(); | 3614 | editIncidence(); |
3615 | mFlagEditDescription = false; | 3615 | mFlagEditDescription = false; |
3616 | } | 3616 | } |
3617 | void CalendarView::editIncidence() | 3617 | void CalendarView::editIncidence() |
3618 | { | 3618 | { |
3619 | // qDebug("editIncidence() "); | 3619 | // qDebug("editIncidence() "); |
3620 | Incidence *incidence = currentSelection(); | 3620 | Incidence *incidence = currentSelection(); |
3621 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3621 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3622 | if ( incidence ) { | 3622 | if ( incidence ) { |
3623 | EditIncidenceVisitor v; | 3623 | EditIncidenceVisitor v; |
3624 | v.act( incidence, this ); | 3624 | v.act( incidence, this ); |
3625 | } | 3625 | } |
3626 | } | 3626 | } |
3627 | 3627 | ||
3628 | void CalendarView::deleteIncidence() | 3628 | void CalendarView::deleteIncidence() |
3629 | { | 3629 | { |
3630 | Incidence *incidence = currentSelection(); | 3630 | Incidence *incidence = currentSelection(); |
3631 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3631 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3632 | if ( incidence ) { | 3632 | if ( incidence ) { |
3633 | deleteIncidence(incidence); | 3633 | deleteIncidence(incidence); |
3634 | } | 3634 | } |
3635 | } | 3635 | } |
3636 | 3636 | ||
3637 | void CalendarView::showIncidence(Incidence *incidence) | 3637 | void CalendarView::showIncidence(Incidence *incidence) |
3638 | { | 3638 | { |
3639 | if ( incidence ) { | 3639 | if ( incidence ) { |
3640 | ShowIncidenceVisitor v; | 3640 | ShowIncidenceVisitor v; |
3641 | v.act( incidence, this ); | 3641 | v.act( incidence, this ); |
3642 | } | 3642 | } |
3643 | } | 3643 | } |
3644 | 3644 | ||
3645 | void CalendarView::editIncidence(Incidence *incidence) | 3645 | void CalendarView::editIncidence(Incidence *incidence) |
3646 | { | 3646 | { |
3647 | if ( incidence ) { | 3647 | if ( incidence ) { |
3648 | 3648 | ||
3649 | EditIncidenceVisitor v; | 3649 | EditIncidenceVisitor v; |
3650 | v.act( incidence, this ); | 3650 | v.act( incidence, this ); |
3651 | 3651 | ||
3652 | } | 3652 | } |
3653 | } | 3653 | } |
3654 | 3654 | ||
3655 | void CalendarView::deleteIncidence(Incidence *incidence) | 3655 | void CalendarView::deleteIncidence(Incidence *incidence) |
3656 | { | 3656 | { |
3657 | //qDebug(" CalendarView::deleteIncidence "); | 3657 | //qDebug(" CalendarView::deleteIncidence "); |
3658 | if ( incidence ) { | 3658 | if ( incidence ) { |
3659 | DeleteIncidenceVisitor v; | 3659 | DeleteIncidenceVisitor v; |
3660 | v.act( incidence, this ); | 3660 | v.act( incidence, this ); |
3661 | } | 3661 | } |
3662 | } | 3662 | } |
3663 | 3663 | ||
3664 | 3664 | ||
3665 | void CalendarView::lookForOutgoingMessages() | 3665 | void CalendarView::lookForOutgoingMessages() |
3666 | { | 3666 | { |
3667 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3667 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3668 | ogd->loadMessages(); | 3668 | ogd->loadMessages(); |
3669 | } | 3669 | } |
3670 | 3670 | ||
3671 | void CalendarView::lookForIncomingMessages() | 3671 | void CalendarView::lookForIncomingMessages() |
3672 | { | 3672 | { |
3673 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3673 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3674 | icd->retrieve(); | 3674 | icd->retrieve(); |
3675 | } | 3675 | } |
3676 | 3676 | ||
3677 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3677 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3678 | { | 3678 | { |
3679 | bool deleteTodo = true; | 3679 | bool deleteTodo = true; |
3680 | QPtrList<Incidence> subTodos; | 3680 | QPtrList<Incidence> subTodos; |
3681 | Incidence *aTodo; | 3681 | Incidence *aTodo; |
3682 | subTodos = t->relations(); | 3682 | subTodos = t->relations(); |
3683 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3683 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3684 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3684 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3685 | deleteTodo = false; | 3685 | deleteTodo = false; |
3686 | } | 3686 | } |
3687 | if ( deleteTodo ) { | 3687 | if ( deleteTodo ) { |
3688 | if ( t->isCompleted() ) { | 3688 | if ( t->isCompleted() ) { |
3689 | checkExternalId( t ); | 3689 | checkExternalId( t ); |
3690 | mCalendar->deleteTodo( t ); | 3690 | mCalendar->deleteTodo( t ); |
3691 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3691 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3692 | } | 3692 | } |
3693 | else | 3693 | else |
3694 | deleteTodo = false; | 3694 | deleteTodo = false; |
3695 | } | 3695 | } |
3696 | return deleteTodo; | 3696 | return deleteTodo; |
3697 | 3697 | ||
3698 | } | 3698 | } |
3699 | void CalendarView::purgeCompleted() | 3699 | void CalendarView::purgeCompleted() |
3700 | { | 3700 | { |
3701 | int result = KMessageBox::warningContinueCancel(this, | 3701 | int result = KMessageBox::warningContinueCancel(this, |
3702 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3702 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3703 | 3703 | ||
3704 | if (result == KMessageBox::Continue) { | 3704 | if (result == KMessageBox::Continue) { |
3705 | 3705 | ||
3706 | QPtrList<Todo> todoCal; | 3706 | QPtrList<Todo> todoCal; |
3707 | QPtrList<Todo> rootTodos; | 3707 | QPtrList<Todo> rootTodos; |
3708 | //QPtrList<Incidence> rel; | 3708 | //QPtrList<Incidence> rel; |
3709 | Todo *aTodo;//, *rTodo; | 3709 | Todo *aTodo;//, *rTodo; |
3710 | Incidence *rIncidence; | 3710 | Incidence *rIncidence; |
3711 | bool childDelete = false; | 3711 | bool childDelete = false; |
3712 | bool deletedOne = true; | 3712 | bool deletedOne = true; |
3713 | todoCal = calendar()->todos(); | 3713 | todoCal = calendar()->todos(); |
3714 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3714 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3715 | if ( !aTodo->relatedTo() ) | 3715 | if ( !aTodo->relatedTo() ) |
3716 | rootTodos.append( aTodo ); | 3716 | rootTodos.append( aTodo ); |
3717 | } | 3717 | } |
3718 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3718 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3719 | removeCompletedSubTodos( aTodo ); | 3719 | removeCompletedSubTodos( aTodo ); |
3720 | } | 3720 | } |
3721 | 3721 | ||
3722 | updateView(); | 3722 | updateView(); |
3723 | } | 3723 | } |
3724 | } | 3724 | } |
3725 | 3725 | ||
3726 | void CalendarView::slotCalendarChanged() | 3726 | void CalendarView::slotCalendarChanged() |
3727 | { | 3727 | { |
3728 | ; | 3728 | ; |
3729 | } | 3729 | } |
3730 | 3730 | ||
3731 | NavigatorBar *CalendarView::navigatorBar() | 3731 | NavigatorBar *CalendarView::navigatorBar() |
3732 | { | 3732 | { |
3733 | return mNavigatorBar; | 3733 | return mNavigatorBar; |
3734 | } | 3734 | } |
3735 | 3735 | ||
3736 | 3736 | ||
3737 | 3737 | ||
3738 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3738 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3739 | { | 3739 | { |
3740 | //qDebug(" alendarView::keyPressEvent "); | 3740 | //qDebug(" alendarView::keyPressEvent "); |
3741 | e->ignore(); | 3741 | e->ignore(); |
3742 | } | 3742 | } |
3743 | 3743 | ||
3744 | 3744 | ||
3745 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3745 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3746 | { | 3746 | { |
3747 | // mSyncManager = manager; | 3747 | // mSyncManager = manager; |
3748 | mSyncKDE = false; | ||
3749 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3748 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3750 | qDebug("SyncKDE request detected!"); | 3749 | qDebug("SyncKDE request detected!"); |
3751 | mSyncKDE = true; | ||
3752 | } | 3750 | } |
3753 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3751 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3754 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3752 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3755 | return syncCalendar( filename, mode ); | 3753 | return syncCalendar( filename, mode ); |
3756 | } | 3754 | } |
3757 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3755 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3758 | { | 3756 | { |
3759 | mSyncKDE = false; | ||
3760 | //mSyncManager = manager; | 3757 | //mSyncManager = manager; |
3761 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3758 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3762 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3759 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3763 | if ( resource == "sharp" ) | 3760 | if ( resource == "sharp" ) |
3764 | syncExternal( 0 ); | 3761 | syncExternal( 0 ); |
3765 | if ( resource == "phone" ) | 3762 | if ( resource == "phone" ) |
3766 | syncExternal( 1 ); | 3763 | syncExternal( 1 ); |
3767 | // pending setmodified | 3764 | // pending setmodified |
3768 | return true; | 3765 | return true; |
3769 | } | 3766 | } |
3770 | void CalendarView::setSyncManager(KSyncManager* manager) | 3767 | void CalendarView::setSyncManager(KSyncManager* manager) |
3771 | { | 3768 | { |
3772 | mSyncManager = manager; | 3769 | mSyncManager = manager; |
3773 | } | 3770 | } |
3774 | 3771 | ||
3775 | void CalendarView::removeSyncInfo( QString syncProfile) | 3772 | void CalendarView::removeSyncInfo( QString syncProfile) |
3776 | { | 3773 | { |
3777 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); | 3774 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); |
3778 | mCalendar->removeSyncInfo( syncProfile ); | 3775 | mCalendar->removeSyncInfo( syncProfile ); |
3779 | 3776 | ||
3780 | } | 3777 | } |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index acc20d6..437a51c 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,606 +1,605 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 | 3 | Copyright (c) 2000, 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program 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 | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef CALENDARVIEW_H | 24 | #ifndef CALENDARVIEW_H |
25 | #define CALENDARVIEW_H | 25 | #define CALENDARVIEW_H |
26 | 26 | ||
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qmap.h> | 32 | #include <qmap.h> |
33 | #ifndef DESKTOP_VERSION | 33 | #ifndef DESKTOP_VERSION |
34 | #include <qtopia/ir.h> | 34 | #include <qtopia/ir.h> |
35 | #else | 35 | #else |
36 | #define Ir char | 36 | #define Ir char |
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendar.h> | 38 | #include <libkcal/calendar.h> |
39 | #include <libkcal/scheduler.h> | 39 | #include <libkcal/scheduler.h> |
40 | #include <libkcal/calendarresources.h> | 40 | #include <libkcal/calendarresources.h> |
41 | #include <libkcal/resourcecalendar.h> | 41 | #include <libkcal/resourcecalendar.h> |
42 | 42 | ||
43 | #include <korganizer/calendarviewbase.h> | 43 | #include <korganizer/calendarviewbase.h> |
44 | 44 | ||
45 | #include <ksyncmanager.h> | 45 | #include <ksyncmanager.h> |
46 | 46 | ||
47 | class QWidgetStack; | 47 | class QWidgetStack; |
48 | class QSplitter; | 48 | class QSplitter; |
49 | 49 | ||
50 | class CalPrinter; | 50 | class CalPrinter; |
51 | class KOFilterView; | 51 | class KOFilterView; |
52 | class KOViewManager; | 52 | class KOViewManager; |
53 | class KODialogManager; | 53 | class KODialogManager; |
54 | class KOTodoView; | 54 | class KOTodoView; |
55 | class KDateNavigator; | 55 | class KDateNavigator; |
56 | class DateNavigator; | 56 | class DateNavigator; |
57 | class KOIncidenceEditor; | 57 | class KOIncidenceEditor; |
58 | class KDatePicker; | 58 | class KDatePicker; |
59 | class ResourceView; | 59 | class ResourceView; |
60 | class NavigatorBar; | 60 | class NavigatorBar; |
61 | class KOEventEditor; | 61 | class KOEventEditor; |
62 | class KOTodoEditor ; | 62 | class KOTodoEditor ; |
63 | class KOEventViewerDialog; | 63 | class KOEventViewerDialog; |
64 | class KOBeamPrefs; | 64 | class KOBeamPrefs; |
65 | class KSyncProfile; | 65 | class KSyncProfile; |
66 | class AlarmDialog; | 66 | class AlarmDialog; |
67 | class KCal::Attendee; | 67 | class KCal::Attendee; |
68 | 68 | ||
69 | namespace KCal { class FileStorage; } | 69 | namespace KCal { class FileStorage; } |
70 | 70 | ||
71 | using namespace KCal; | 71 | using namespace KCal; |
72 | 72 | ||
73 | /** | 73 | /** |
74 | This is the main calendar widget. It provides the different vies on t he | 74 | This is the main calendar widget. It provides the different vies on t he |
75 | calendar data as well as the date navigator. It also handles synchronisation | 75 | calendar data as well as the date navigator. It also handles synchronisation |
76 | of the different views and controls the different dialogs like preferences, | 76 | of the different views and controls the different dialogs like preferences, |
77 | event editor, search dialog etc. | 77 | event editor, search dialog etc. |
78 | 78 | ||
79 | @short main calendar view widget | 79 | @short main calendar view widget |
80 | @author Cornelius Schumacher | 80 | @author Cornelius Schumacher |
81 | */ | 81 | */ |
82 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface | 82 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface |
83 | { | 83 | { |
84 | Q_OBJECT | 84 | Q_OBJECT |
85 | public: | 85 | public: |
86 | /** | 86 | /** |
87 | Constructs a new calendar view widget. | 87 | Constructs a new calendar view widget. |
88 | 88 | ||
89 | @param calendar calendar document | 89 | @param calendar calendar document |
90 | @param parent parent window | 90 | @param parent parent window |
91 | @param name Qt internal widget object name | 91 | @param name Qt internal widget object name |
92 | */ | 92 | */ |
93 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 93 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
94 | const char *name = 0 ); | 94 | const char *name = 0 ); |
95 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 95 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
96 | const char *name = 0 ); | 96 | const char *name = 0 ); |
97 | virtual ~CalendarView(); | 97 | virtual ~CalendarView(); |
98 | 98 | ||
99 | Calendar *calendar() { return mCalendar; } | 99 | Calendar *calendar() { return mCalendar; } |
100 | 100 | ||
101 | KOViewManager *viewManager(); | 101 | KOViewManager *viewManager(); |
102 | KODialogManager *dialogManager(); | 102 | KODialogManager *dialogManager(); |
103 | 103 | ||
104 | QDate startDate(); | 104 | QDate startDate(); |
105 | QDate endDate(); | 105 | QDate endDate(); |
106 | 106 | ||
107 | QWidgetStack *viewStack(); | 107 | QWidgetStack *viewStack(); |
108 | QWidget *leftFrame(); | 108 | QWidget *leftFrame(); |
109 | NavigatorBar *navigatorBar(); | 109 | NavigatorBar *navigatorBar(); |
110 | 110 | ||
111 | DateNavigator *dateNavigator(); | 111 | DateNavigator *dateNavigator(); |
112 | KDateNavigator *dateNavigatorWidget(); | 112 | KDateNavigator *dateNavigatorWidget(); |
113 | 113 | ||
114 | void addView(KOrg::BaseView *); | 114 | void addView(KOrg::BaseView *); |
115 | void showView(KOrg::BaseView *); | 115 | void showView(KOrg::BaseView *); |
116 | KOEventViewerDialog* getEventViewerDialog(); | 116 | KOEventViewerDialog* getEventViewerDialog(); |
117 | Incidence *currentSelection(); | 117 | Incidence *currentSelection(); |
118 | 118 | ||
119 | signals: | 119 | signals: |
120 | void tempDisableBR(bool); | 120 | void tempDisableBR(bool); |
121 | /** This todo has been modified */ | 121 | /** This todo has been modified */ |
122 | void todoModified(Todo *, int); | 122 | void todoModified(Todo *, int); |
123 | 123 | ||
124 | /** when change is made to options dialog, the topwidget will catch this | 124 | /** when change is made to options dialog, the topwidget will catch this |
125 | * and emit this signal which notifies all widgets which have registered | 125 | * and emit this signal which notifies all widgets which have registered |
126 | * for notification to update their settings. */ | 126 | * for notification to update their settings. */ |
127 | void configChanged(); | 127 | void configChanged(); |
128 | /** emitted when the topwidget is closing down, so that any attached | 128 | /** emitted when the topwidget is closing down, so that any attached |
129 | child windows can also close. */ | 129 | child windows can also close. */ |
130 | void closingDown(); | 130 | void closingDown(); |
131 | /** emitted right before we die */ | 131 | /** emitted right before we die */ |
132 | void closed(QWidget *); | 132 | void closed(QWidget *); |
133 | 133 | ||
134 | /** Emitted when state of modified flag changes */ | 134 | /** Emitted when state of modified flag changes */ |
135 | void modifiedChanged(bool); | 135 | void modifiedChanged(bool); |
136 | void signalmodified(); | 136 | void signalmodified(); |
137 | 137 | ||
138 | /** Emitted when state of read-only flag changes */ | 138 | /** Emitted when state of read-only flag changes */ |
139 | void readOnlyChanged(bool); | 139 | void readOnlyChanged(bool); |
140 | 140 | ||
141 | /** Emitted when the unit of navigation changes */ | 141 | /** Emitted when the unit of navigation changes */ |
142 | void changeNavStringPrev(const QString &); | 142 | void changeNavStringPrev(const QString &); |
143 | void changeNavStringNext(const QString &); | 143 | void changeNavStringNext(const QString &); |
144 | 144 | ||
145 | /** Emitted when state of events selection has changed and user is organizer*/ | 145 | /** Emitted when state of events selection has changed and user is organizer*/ |
146 | void organizerEventsSelected(bool); | 146 | void organizerEventsSelected(bool); |
147 | /** Emitted when state of events selection has changed and user is attendee*/ | 147 | /** Emitted when state of events selection has changed and user is attendee*/ |
148 | void groupEventsSelected(bool); | 148 | void groupEventsSelected(bool); |
149 | /** | 149 | /** |
150 | Emitted when an incidence gets selected. If the selection is cleared the | 150 | Emitted when an incidence gets selected. If the selection is cleared the |
151 | signal is emitted with 0 as argument. | 151 | signal is emitted with 0 as argument. |
152 | */ | 152 | */ |
153 | void incidenceSelected( Incidence * ); | 153 | void incidenceSelected( Incidence * ); |
154 | /** Emitted, when a todoitem is selected or deselected. */ | 154 | /** Emitted, when a todoitem is selected or deselected. */ |
155 | void todoSelected( bool ); | 155 | void todoSelected( bool ); |
156 | 156 | ||
157 | /** | 157 | /** |
158 | Emitted, when clipboard content changes. Parameter indicates if paste | 158 | Emitted, when clipboard content changes. Parameter indicates if paste |
159 | is possible or not. | 159 | is possible or not. |
160 | */ | 160 | */ |
161 | void pasteEnabled(bool); | 161 | void pasteEnabled(bool); |
162 | 162 | ||
163 | /** Emitted, when the number of incoming messages has changed. */ | 163 | /** Emitted, when the number of incoming messages has changed. */ |
164 | void numIncomingChanged(int); | 164 | void numIncomingChanged(int); |
165 | 165 | ||
166 | /** Emitted, when the number of outgoing messages has changed. */ | 166 | /** Emitted, when the number of outgoing messages has changed. */ |
167 | void numOutgoingChanged(int); | 167 | void numOutgoingChanged(int); |
168 | 168 | ||
169 | /** Send status message, which can e.g. be displayed in the status bar. */ | 169 | /** Send status message, which can e.g. be displayed in the status bar. */ |
170 | void statusMessage(const QString &); | 170 | void statusMessage(const QString &); |
171 | 171 | ||
172 | void calendarViewExpanded( bool ); | 172 | void calendarViewExpanded( bool ); |
173 | void updateSearchDialog(); | 173 | void updateSearchDialog(); |
174 | 174 | ||
175 | 175 | ||
176 | public slots: | 176 | public slots: |
177 | void showOpenError(); | 177 | void showOpenError(); |
178 | void watchSavedFile(); | 178 | void watchSavedFile(); |
179 | void recheckTimerAlarm(); | 179 | void recheckTimerAlarm(); |
180 | void checkNextTimerAlarm(); | 180 | void checkNextTimerAlarm(); |
181 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 181 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
182 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 182 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
183 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 183 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
184 | 184 | ||
185 | /** options dialog made a changed to the configuration. we catch this | 185 | /** options dialog made a changed to the configuration. we catch this |
186 | * and notify all widgets which need to update their configuration. */ | 186 | * and notify all widgets which need to update their configuration. */ |
187 | void updateConfig(); | 187 | void updateConfig(); |
188 | 188 | ||
189 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 189 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
190 | const QStringList& anniversaryList, const QStringList& realNameList, | 190 | const QStringList& anniversaryList, const QStringList& realNameList, |
191 | const QStringList& emailList, const QStringList& assembledNameList, | 191 | const QStringList& emailList, const QStringList& assembledNameList, |
192 | const QStringList& uidList); | 192 | const QStringList& uidList); |
193 | 193 | ||
194 | /** | 194 | /** |
195 | Load calendar from file \a filename. If \a merge is true, load | 195 | Load calendar from file \a filename. If \a merge is true, load |
196 | calendar into existing one, if it is false, clear calendar, before | 196 | calendar into existing one, if it is false, clear calendar, before |
197 | loading. Return true, if calendar could be successfully loaded. | 197 | loading. Return true, if calendar could be successfully loaded. |
198 | */ | 198 | */ |
199 | bool openCalendar(QString filename, bool merge=false); | 199 | bool openCalendar(QString filename, bool merge=false); |
200 | bool syncCalendar(QString filename,int mode = 0 ); | 200 | bool syncCalendar(QString filename,int mode = 0 ); |
201 | 201 | ||
202 | /** | 202 | /** |
203 | Save calendar data to file. Return true if calendar could be | 203 | Save calendar data to file. Return true if calendar could be |
204 | successfully saved. | 204 | successfully saved. |
205 | */ | 205 | */ |
206 | bool saveCalendar(QString filename); | 206 | bool saveCalendar(QString filename); |
207 | 207 | ||
208 | /** | 208 | /** |
209 | Close calendar. Clear calendar data and reset views to display an empty | 209 | Close calendar. Clear calendar data and reset views to display an empty |
210 | calendar. | 210 | calendar. |
211 | */ | 211 | */ |
212 | void closeCalendar(); | 212 | void closeCalendar(); |
213 | 213 | ||
214 | /** Archive old events of calendar */ | 214 | /** Archive old events of calendar */ |
215 | void archiveCalendar(); | 215 | void archiveCalendar(); |
216 | 216 | ||
217 | void showIncidence(); | 217 | void showIncidence(); |
218 | void editIncidence(); | 218 | void editIncidence(); |
219 | void editIncidenceDescription(); | 219 | void editIncidenceDescription(); |
220 | void deleteIncidence(); | 220 | void deleteIncidence(); |
221 | void cloneIncidence(); | 221 | void cloneIncidence(); |
222 | void moveIncidence(); | 222 | void moveIncidence(); |
223 | void beamIncidence(); | 223 | void beamIncidence(); |
224 | void toggleCancelIncidence(); | 224 | void toggleCancelIncidence(); |
225 | 225 | ||
226 | /** create an editeventwin with supplied date/time, and if bool is true, | 226 | /** create an editeventwin with supplied date/time, and if bool is true, |
227 | * make the event take all day. */ | 227 | * make the event take all day. */ |
228 | void newEvent(QDateTime, QDateTime, bool allDay = false); | 228 | void newEvent(QDateTime, QDateTime, bool allDay = false); |
229 | void newEvent(QDateTime fh); | 229 | void newEvent(QDateTime fh); |
230 | void newEvent(QDate dt); | 230 | void newEvent(QDate dt); |
231 | /** create new event without having a date hint. Takes current date as | 231 | /** create new event without having a date hint. Takes current date as |
232 | default hint. */ | 232 | default hint. */ |
233 | void newEvent(); | 233 | void newEvent(); |
234 | void newFloatingEvent(); | 234 | void newFloatingEvent(); |
235 | 235 | ||
236 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 236 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
237 | void showIncidence(Incidence *); | 237 | void showIncidence(Incidence *); |
238 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 238 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
239 | void editIncidence(Incidence *); | 239 | void editIncidence(Incidence *); |
240 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 240 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
241 | void deleteIncidence(Incidence *); | 241 | void deleteIncidence(Incidence *); |
242 | void cloneIncidence(Incidence *); | 242 | void cloneIncidence(Incidence *); |
243 | void cancelIncidence(Incidence *); | 243 | void cancelIncidence(Incidence *); |
244 | /** Create an editor for the supplied event. */ | 244 | /** Create an editor for the supplied event. */ |
245 | void editEvent(Event *); | 245 | void editEvent(Event *); |
246 | /** Delete the supplied event. */ | 246 | /** Delete the supplied event. */ |
247 | void deleteEvent(Event *); | 247 | void deleteEvent(Event *); |
248 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 248 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
249 | found. */ | 249 | found. */ |
250 | bool deleteEvent(const QString &uid); | 250 | bool deleteEvent(const QString &uid); |
251 | /** Create a read-only viewer dialog for the supplied event. */ | 251 | /** Create a read-only viewer dialog for the supplied event. */ |
252 | void showEvent(Event *); | 252 | void showEvent(Event *); |
253 | 253 | ||
254 | void editJournal(Journal *); | 254 | void editJournal(Journal *); |
255 | void showJournal(Journal *); | 255 | void showJournal(Journal *); |
256 | void deleteJournal(Journal *); | 256 | void deleteJournal(Journal *); |
257 | /** Create an editor dialog for a todo */ | 257 | /** Create an editor dialog for a todo */ |
258 | void editTodo(Todo *); | 258 | void editTodo(Todo *); |
259 | /** Create a read-only viewer dialog for the supplied todo */ | 259 | /** Create a read-only viewer dialog for the supplied todo */ |
260 | void showTodo(Todo *); | 260 | void showTodo(Todo *); |
261 | /** create new todo */ | 261 | /** create new todo */ |
262 | void newTodo(); | 262 | void newTodo(); |
263 | /** create new todo with a parent todo */ | 263 | /** create new todo with a parent todo */ |
264 | void newSubTodo(); | 264 | void newSubTodo(); |
265 | /** create new todo with a parent todo */ | 265 | /** create new todo with a parent todo */ |
266 | void newSubTodo(Todo *); | 266 | void newSubTodo(Todo *); |
267 | /** Delete todo */ | 267 | /** Delete todo */ |
268 | void deleteTodo(Todo *); | 268 | void deleteTodo(Todo *); |
269 | 269 | ||
270 | 270 | ||
271 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 271 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
272 | * emitted as result. */ | 272 | * emitted as result. */ |
273 | void checkClipboard(); | 273 | void checkClipboard(); |
274 | 274 | ||
275 | /** using the KConfig associated with the kapp variable, read in the | 275 | /** using the KConfig associated with the kapp variable, read in the |
276 | * settings from the config file. | 276 | * settings from the config file. |
277 | */ | 277 | */ |
278 | void readSettings(); | 278 | void readSettings(); |
279 | 279 | ||
280 | /** write current state to config file. */ | 280 | /** write current state to config file. */ |
281 | void writeSettings(); | 281 | void writeSettings(); |
282 | 282 | ||
283 | /** read settings for calendar filters */ | 283 | /** read settings for calendar filters */ |
284 | void readFilterSettings(KConfig *config); | 284 | void readFilterSettings(KConfig *config); |
285 | 285 | ||
286 | /** write settings for calendar filters */ | 286 | /** write settings for calendar filters */ |
287 | void writeFilterSettings(KConfig *config); | 287 | void writeFilterSettings(KConfig *config); |
288 | 288 | ||
289 | /** passes on the message that an event has changed to the currently | 289 | /** passes on the message that an event has changed to the currently |
290 | * activated view so that it can make appropriate display changes. */ | 290 | * activated view so that it can make appropriate display changes. */ |
291 | void changeEventDisplay(Event *, int); | 291 | void changeEventDisplay(Event *, int); |
292 | void changeIncidenceDisplay(Incidence *, int); | 292 | void changeIncidenceDisplay(Incidence *, int); |
293 | void changeTodoDisplay(Todo *, int); | 293 | void changeTodoDisplay(Todo *, int); |
294 | 294 | ||
295 | void eventAdded(Event *); | 295 | void eventAdded(Event *); |
296 | void eventChanged(Event *); | 296 | void eventChanged(Event *); |
297 | void eventToBeDeleted(Event *); | 297 | void eventToBeDeleted(Event *); |
298 | void eventDeleted(); | 298 | void eventDeleted(); |
299 | 299 | ||
300 | void todoAdded(Todo *); | 300 | void todoAdded(Todo *); |
301 | void todoChanged(Todo *); | 301 | void todoChanged(Todo *); |
302 | void todoToBeDeleted(Todo *); | 302 | void todoToBeDeleted(Todo *); |
303 | void todoDeleted(); | 303 | void todoDeleted(); |
304 | 304 | ||
305 | void updateView(const QDate &start, const QDate &end); | 305 | void updateView(const QDate &start, const QDate &end); |
306 | void updateView(); | 306 | void updateView(); |
307 | 307 | ||
308 | /** Full update of visible todo views */ | 308 | /** Full update of visible todo views */ |
309 | void updateTodoViews(); | 309 | void updateTodoViews(); |
310 | 310 | ||
311 | void updateUnmanagedViews(); | 311 | void updateUnmanagedViews(); |
312 | 312 | ||
313 | /** cut the current appointment to the clipboard */ | 313 | /** cut the current appointment to the clipboard */ |
314 | void edit_cut(); | 314 | void edit_cut(); |
315 | 315 | ||
316 | /** copy the current appointment(s) to the clipboard */ | 316 | /** copy the current appointment(s) to the clipboard */ |
317 | void edit_copy(); | 317 | void edit_copy(); |
318 | 318 | ||
319 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 319 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
320 | void edit_paste(); | 320 | void edit_paste(); |
321 | 321 | ||
322 | /** edit viewing and configuration options. */ | 322 | /** edit viewing and configuration options. */ |
323 | void edit_options(); | 323 | void edit_options(); |
324 | /** | 324 | /** |
325 | Functions for printing, previewing a print, and setting up printing | 325 | Functions for printing, previewing a print, and setting up printing |
326 | parameters. | 326 | parameters. |
327 | */ | 327 | */ |
328 | void print(); | 328 | void print(); |
329 | void printSetup(); | 329 | void printSetup(); |
330 | void printPreview(); | 330 | void printPreview(); |
331 | 331 | ||
332 | /** Export as iCalendar file */ | 332 | /** Export as iCalendar file */ |
333 | void exportICalendar(); | 333 | void exportICalendar(); |
334 | 334 | ||
335 | /** Export as vCalendar file */ | 335 | /** Export as vCalendar file */ |
336 | bool exportVCalendar( QString fn); | 336 | bool exportVCalendar( QString fn); |
337 | 337 | ||
338 | /** pop up a dialog to show an existing appointment. */ | 338 | /** pop up a dialog to show an existing appointment. */ |
339 | void appointment_show(); | 339 | void appointment_show(); |
340 | /** | 340 | /** |
341 | * pop up an Appointment Dialog to edit an existing appointment.Get | 341 | * pop up an Appointment Dialog to edit an existing appointment.Get |
342 | * information on the appointment from the list of unique IDs that is | 342 | * information on the appointment from the list of unique IDs that is |
343 | * currently in the View, called currIds. | 343 | * currently in the View, called currIds. |
344 | */ | 344 | */ |
345 | void appointment_edit(); | 345 | void appointment_edit(); |
346 | /** | 346 | /** |
347 | * pop up dialog confirming deletion of currently selected event in the | 347 | * pop up dialog confirming deletion of currently selected event in the |
348 | * View. | 348 | * View. |
349 | */ | 349 | */ |
350 | void appointment_delete(); | 350 | void appointment_delete(); |
351 | 351 | ||
352 | /** mails the currently selected event to a particular user as a vCalendar | 352 | /** mails the currently selected event to a particular user as a vCalendar |
353 | attachment. */ | 353 | attachment. */ |
354 | void action_mail(); | 354 | void action_mail(); |
355 | 355 | ||
356 | /* frees a subtodo from it's relation */ | 356 | /* frees a subtodo from it's relation */ |
357 | void todo_unsub( Todo * ); | 357 | void todo_unsub( Todo * ); |
358 | void todo_resub( Todo * parent, Todo * sub ); | 358 | void todo_resub( Todo * parent, Todo * sub ); |
359 | 359 | ||
360 | /** Take ownership of selected event. */ | 360 | /** Take ownership of selected event. */ |
361 | void takeOverEvent(); | 361 | void takeOverEvent(); |
362 | 362 | ||
363 | /** Take ownership of all events in calendar. */ | 363 | /** Take ownership of all events in calendar. */ |
364 | void takeOverCalendar(); | 364 | void takeOverCalendar(); |
365 | 365 | ||
366 | /** query whether or not the calendar is "dirty". */ | 366 | /** query whether or not the calendar is "dirty". */ |
367 | bool isModified(); | 367 | bool isModified(); |
368 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 368 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
369 | void setModified(bool modified=true); | 369 | void setModified(bool modified=true); |
370 | 370 | ||
371 | /** query if the calendar is read-only. */ | 371 | /** query if the calendar is read-only. */ |
372 | bool isReadOnly(); | 372 | bool isReadOnly(); |
373 | /** set state of calendar to read-only */ | 373 | /** set state of calendar to read-only */ |
374 | void setReadOnly(bool readOnly=true); | 374 | void setReadOnly(bool readOnly=true); |
375 | 375 | ||
376 | void eventUpdated(Incidence *); | 376 | void eventUpdated(Incidence *); |
377 | 377 | ||
378 | /* iTIP scheduling actions */ | 378 | /* iTIP scheduling actions */ |
379 | void schedule_publish(Incidence *incidence = 0); | 379 | void schedule_publish(Incidence *incidence = 0); |
380 | void schedule_request(Incidence *incidence = 0); | 380 | void schedule_request(Incidence *incidence = 0); |
381 | void schedule_refresh(Incidence *incidence = 0); | 381 | void schedule_refresh(Incidence *incidence = 0); |
382 | void schedule_cancel(Incidence *incidence = 0); | 382 | void schedule_cancel(Incidence *incidence = 0); |
383 | void schedule_add(Incidence *incidence = 0); | 383 | void schedule_add(Incidence *incidence = 0); |
384 | void schedule_reply(Incidence *incidence = 0); | 384 | void schedule_reply(Incidence *incidence = 0); |
385 | void schedule_counter(Incidence *incidence = 0); | 385 | void schedule_counter(Incidence *incidence = 0); |
386 | void schedule_declinecounter(Incidence *incidence = 0); | 386 | void schedule_declinecounter(Incidence *incidence = 0); |
387 | void schedule_publish_freebusy(int daysToPublish = 30); | 387 | void schedule_publish_freebusy(int daysToPublish = 30); |
388 | 388 | ||
389 | void openAddressbook(); | 389 | void openAddressbook(); |
390 | 390 | ||
391 | void editFilters(); | 391 | void editFilters(); |
392 | void toggleFilerEnabled(); | 392 | void toggleFilerEnabled(); |
393 | QPtrList<CalFilter> filters(); | 393 | QPtrList<CalFilter> filters(); |
394 | void toggleFilter(); | 394 | void toggleFilter(); |
395 | void showFilter(bool visible); | 395 | void showFilter(bool visible); |
396 | void updateFilter(); | 396 | void updateFilter(); |
397 | void filterEdited(); | 397 | void filterEdited(); |
398 | void selectFilter( int ); | 398 | void selectFilter( int ); |
399 | KOFilterView *filterView(); | 399 | KOFilterView *filterView(); |
400 | 400 | ||
401 | void showIntro(); | 401 | void showIntro(); |
402 | 402 | ||
403 | /** Move the curdatepient view date to today */ | 403 | /** Move the curdatepient view date to today */ |
404 | void goToday(); | 404 | void goToday(); |
405 | 405 | ||
406 | /** Move to the next date(s) in the current view */ | 406 | /** Move to the next date(s) in the current view */ |
407 | void goNext(); | 407 | void goNext(); |
408 | 408 | ||
409 | /** Move to the previous date(s) in the current view */ | 409 | /** Move to the previous date(s) in the current view */ |
410 | void goPrevious(); | 410 | void goPrevious(); |
411 | /** Move to the next date(s) in the current view */ | 411 | /** Move to the next date(s) in the current view */ |
412 | void goNextMonth(); | 412 | void goNextMonth(); |
413 | 413 | ||
414 | /** Move to the previous date(s) in the current view */ | 414 | /** Move to the previous date(s) in the current view */ |
415 | void goPreviousMonth(); | 415 | void goPreviousMonth(); |
416 | 416 | ||
417 | void toggleExpand(); | 417 | void toggleExpand(); |
418 | void toggleDateNavigatorWidget(); | 418 | void toggleDateNavigatorWidget(); |
419 | void toggleAllDaySize(); | 419 | void toggleAllDaySize(); |
420 | void dialogClosing(Incidence *); | 420 | void dialogClosing(Incidence *); |
421 | 421 | ||
422 | /** Look for new messages in the inbox */ | 422 | /** Look for new messages in the inbox */ |
423 | void lookForIncomingMessages(); | 423 | void lookForIncomingMessages(); |
424 | /** Look for new messages in the outbox */ | 424 | /** Look for new messages in the outbox */ |
425 | void lookForOutgoingMessages(); | 425 | void lookForOutgoingMessages(); |
426 | 426 | ||
427 | void processMainViewSelection( Incidence * ); | 427 | void processMainViewSelection( Incidence * ); |
428 | void processTodoListSelection( Incidence * ); | 428 | void processTodoListSelection( Incidence * ); |
429 | 429 | ||
430 | void processIncidenceSelection( Incidence * ); | 430 | void processIncidenceSelection( Incidence * ); |
431 | 431 | ||
432 | void purgeCompleted(); | 432 | void purgeCompleted(); |
433 | bool removeCompletedSubTodos( Todo* ); | 433 | bool removeCompletedSubTodos( Todo* ); |
434 | void slotCalendarChanged(); | 434 | void slotCalendarChanged(); |
435 | bool importBday(); | 435 | bool importBday(); |
436 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 436 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
437 | bool importQtopia( const QString &categoriesFile, | 437 | bool importQtopia( const QString &categoriesFile, |
438 | const QString &datebookFile, | 438 | const QString &datebookFile, |
439 | const QString &tasklistFile ); | 439 | const QString &tasklistFile ); |
440 | void syncExternal( int mode ); | 440 | void syncExternal( int mode ); |
441 | void slotSelectPickerDate( QDate ) ; | 441 | void slotSelectPickerDate( QDate ) ; |
442 | void showDatePicker( ) ; | 442 | void showDatePicker( ) ; |
443 | void moveIncidence(Incidence *) ; | 443 | void moveIncidence(Incidence *) ; |
444 | void beamIncidence(Incidence *) ; | 444 | void beamIncidence(Incidence *) ; |
445 | void beamCalendar() ; | 445 | void beamCalendar() ; |
446 | void beamFilteredCalendar() ; | 446 | void beamFilteredCalendar() ; |
447 | void beamIncidenceList(QPtrList<Incidence>) ; | 447 | void beamIncidenceList(QPtrList<Incidence>) ; |
448 | void manageCategories(); | 448 | void manageCategories(); |
449 | int addCategories(); | 449 | int addCategories(); |
450 | void removeCategories(); | 450 | void removeCategories(); |
451 | void setSyncDevice( QString ); | 451 | void setSyncDevice( QString ); |
452 | void setSyncName( QString ); | 452 | void setSyncName( QString ); |
453 | protected slots: | 453 | protected slots: |
454 | void timerAlarm(); | 454 | void timerAlarm(); |
455 | void suspendAlarm(); | 455 | void suspendAlarm(); |
456 | void beamDone( Ir *ir ); | 456 | void beamDone( Ir *ir ); |
457 | /** Select a view or adapt the current view to display the specified dates. */ | 457 | /** Select a view or adapt the current view to display the specified dates. */ |
458 | void showDates( const KCal::DateList & ); | 458 | void showDates( const KCal::DateList & ); |
459 | void selectWeekNum ( int ); | 459 | void selectWeekNum ( int ); |
460 | 460 | ||
461 | public: | 461 | public: |
462 | // show a standard warning | 462 | // show a standard warning |
463 | // returns KMsgBox::yesNoCancel() | 463 | // returns KMsgBox::yesNoCancel() |
464 | int msgCalModified(); | 464 | int msgCalModified(); |
465 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 465 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
466 | 466 | ||
467 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 467 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
468 | virtual void removeSyncInfo( QString syncProfile); | 468 | virtual void removeSyncInfo( QString syncProfile); |
469 | void setSyncManager(KSyncManager* manager); | 469 | void setSyncManager(KSyncManager* manager); |
470 | void setLoadedFileVersion(QDateTime); | 470 | void setLoadedFileVersion(QDateTime); |
471 | bool checkFileVersion(QString fn); | 471 | bool checkFileVersion(QString fn); |
472 | bool checkFileChanged(QString fn); | 472 | bool checkFileChanged(QString fn); |
473 | Event* getLastSyncEvent(); | 473 | Event* getLastSyncEvent(); |
474 | /** Adapt navigation units correpsonding to step size of navigation of the | 474 | /** Adapt navigation units correpsonding to step size of navigation of the |
475 | * current view. | 475 | * current view. |
476 | */ | 476 | */ |
477 | void adaptNavigationUnits(); | 477 | void adaptNavigationUnits(); |
478 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 478 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
479 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 479 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
480 | //Attendee* getYourAttendee(Event *event); | 480 | //Attendee* getYourAttendee(Event *event); |
481 | protected: | 481 | protected: |
482 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 482 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
483 | 483 | ||
484 | // returns KMsgBox::OKCandel() | 484 | // returns KMsgBox::OKCandel() |
485 | int msgItemDelete(); | 485 | int msgItemDelete(); |
486 | void showEventEditor(); | 486 | void showEventEditor(); |
487 | void showTodoEditor(); | 487 | void showTodoEditor(); |
488 | void writeLocale(); | 488 | void writeLocale(); |
489 | Todo *selectedTodo(); | 489 | Todo *selectedTodo(); |
490 | 490 | ||
491 | private: | 491 | private: |
492 | bool mSyncKDE; | ||
493 | KSyncManager* mSyncManager; | 492 | KSyncManager* mSyncManager; |
494 | AlarmDialog * mAlarmDialog; | 493 | AlarmDialog * mAlarmDialog; |
495 | QString mAlarmNotification; | 494 | QString mAlarmNotification; |
496 | QString mSuspendAlarmNotification; | 495 | QString mSuspendAlarmNotification; |
497 | QTimer* mSuspendTimer; | 496 | QTimer* mSuspendTimer; |
498 | QTimer* mAlarmTimer; | 497 | QTimer* mAlarmTimer; |
499 | QTimer* mRecheckAlarmTimer; | 498 | QTimer* mRecheckAlarmTimer; |
500 | void computeAlarm( QString ); | 499 | void computeAlarm( QString ); |
501 | void startAlarm( QString, QString ); | 500 | void startAlarm( QString, QString ); |
502 | void setSyncEventsReadOnly(); | 501 | void setSyncEventsReadOnly(); |
503 | 502 | ||
504 | QDateTime loadedFileVersion; | 503 | QDateTime loadedFileVersion; |
505 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 504 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
506 | void checkExternalId( Incidence * inc ); | 505 | void checkExternalId( Incidence * inc ); |
507 | int mGlobalSyncMode; | 506 | int mGlobalSyncMode; |
508 | QString mCurrentSyncDevice; | 507 | QString mCurrentSyncDevice; |
509 | QString mCurrentSyncName; | 508 | QString mCurrentSyncName; |
510 | KOBeamPrefs* beamDialog; | 509 | KOBeamPrefs* beamDialog; |
511 | void init(); | 510 | void init(); |
512 | int mDatePickerMode; | 511 | int mDatePickerMode; |
513 | bool mFlagEditDescription; | 512 | bool mFlagEditDescription; |
514 | QDateTime mLastCalendarSync; | 513 | QDateTime mLastCalendarSync; |
515 | void createPrinter(); | 514 | void createPrinter(); |
516 | 515 | ||
517 | void calendarModified( bool, Calendar * ); | 516 | void calendarModified( bool, Calendar * ); |
518 | 517 | ||
519 | CalPrinter *mCalPrinter; | 518 | CalPrinter *mCalPrinter; |
520 | 519 | ||
521 | QSplitter *mPanner; | 520 | QSplitter *mPanner; |
522 | QSplitter *mLeftSplitter; | 521 | QSplitter *mLeftSplitter; |
523 | QWidget *mLeftFrame; | 522 | QWidget *mLeftFrame; |
524 | QWidgetStack *mRightFrame; | 523 | QWidgetStack *mRightFrame; |
525 | 524 | ||
526 | KDatePicker* mDatePicker; | 525 | KDatePicker* mDatePicker; |
527 | QVBox* mDateFrame; | 526 | QVBox* mDateFrame; |
528 | NavigatorBar *mNavigatorBar; | 527 | NavigatorBar *mNavigatorBar; |
529 | 528 | ||
530 | KDateNavigator *mDateNavigator; // widget showing small month view. | 529 | KDateNavigator *mDateNavigator; // widget showing small month view. |
531 | 530 | ||
532 | KOFilterView *mFilterView; | 531 | KOFilterView *mFilterView; |
533 | 532 | ||
534 | ResourceView *mResourceView; | 533 | ResourceView *mResourceView; |
535 | 534 | ||
536 | // calendar object for this viewing instance | 535 | // calendar object for this viewing instance |
537 | Calendar *mCalendar; | 536 | Calendar *mCalendar; |
538 | 537 | ||
539 | CalendarResourceManager *mResourceManager; | 538 | CalendarResourceManager *mResourceManager; |
540 | 539 | ||
541 | FileStorage *mStorage; | 540 | FileStorage *mStorage; |
542 | 541 | ||
543 | DateNavigator *mNavigator; | 542 | DateNavigator *mNavigator; |
544 | 543 | ||
545 | KOViewManager *mViewManager; | 544 | KOViewManager *mViewManager; |
546 | KODialogManager *mDialogManager; | 545 | KODialogManager *mDialogManager; |
547 | 546 | ||
548 | // Calendar filters | 547 | // Calendar filters |
549 | QPtrList<CalFilter> mFilters; | 548 | QPtrList<CalFilter> mFilters; |
550 | 549 | ||
551 | // various housekeeping variables. | 550 | // various housekeeping variables. |
552 | bool mModified; // flag indicating if calendar is modified | 551 | bool mModified; // flag indicating if calendar is modified |
553 | bool mReadOnly; // flag indicating if calendar is read-only | 552 | bool mReadOnly; // flag indicating if calendar is read-only |
554 | QDate mSaveSingleDate; | 553 | QDate mSaveSingleDate; |
555 | 554 | ||
556 | Incidence *mSelectedIncidence; | 555 | Incidence *mSelectedIncidence; |
557 | Incidence *mMoveIncidence; | 556 | Incidence *mMoveIncidence; |
558 | KOTodoView *mTodoList; | 557 | KOTodoView *mTodoList; |
559 | KOEventEditor * mEventEditor; | 558 | KOEventEditor * mEventEditor; |
560 | KOTodoEditor * mTodoEditor; | 559 | KOTodoEditor * mTodoEditor; |
561 | KOEventViewerDialog * mEventViewerDialog; | 560 | KOEventViewerDialog * mEventViewerDialog; |
562 | void keyPressEvent ( QKeyEvent *e) ; | 561 | void keyPressEvent ( QKeyEvent *e) ; |
563 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 562 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
564 | }; | 563 | }; |
565 | 564 | ||
566 | 565 | ||
567 | class CalendarViewVisitor : public Incidence::Visitor | 566 | class CalendarViewVisitor : public Incidence::Visitor |
568 | { | 567 | { |
569 | public: | 568 | public: |
570 | CalendarViewVisitor() : mView( 0 ) {} | 569 | CalendarViewVisitor() : mView( 0 ) {} |
571 | 570 | ||
572 | bool act( Incidence *incidence, CalendarView *view ) | 571 | bool act( Incidence *incidence, CalendarView *view ) |
573 | { | 572 | { |
574 | mView = view; | 573 | mView = view; |
575 | return incidence->accept( *this ); | 574 | return incidence->accept( *this ); |
576 | } | 575 | } |
577 | 576 | ||
578 | protected: | 577 | protected: |
579 | CalendarView *mView; | 578 | CalendarView *mView; |
580 | }; | 579 | }; |
581 | 580 | ||
582 | class ShowIncidenceVisitor : public CalendarViewVisitor | 581 | class ShowIncidenceVisitor : public CalendarViewVisitor |
583 | { | 582 | { |
584 | protected: | 583 | protected: |
585 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 584 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
586 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 585 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
587 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 586 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
588 | }; | 587 | }; |
589 | 588 | ||
590 | class EditIncidenceVisitor : public CalendarViewVisitor | 589 | class EditIncidenceVisitor : public CalendarViewVisitor |
591 | { | 590 | { |
592 | protected: | 591 | protected: |
593 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 592 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
594 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 593 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
595 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 594 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
596 | }; | 595 | }; |
597 | 596 | ||
598 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 597 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
599 | { | 598 | { |
600 | protected: | 599 | protected: |
601 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 600 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
602 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 601 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
603 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 602 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
604 | }; | 603 | }; |
605 | 604 | ||
606 | #endif | 605 | #endif |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index e09050e..17e6c75 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1,1408 +1,1428 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
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 | // $Id$ | 21 | // $Id$ |
22 | 22 | ||
23 | #include "ksyncmanager.h" | 23 | #include "ksyncmanager.h" |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | 31 | ||
32 | #include "ksyncprofile.h" | 32 | #include "ksyncprofile.h" |
33 | #include "ksyncprefsdialog.h" | 33 | #include "ksyncprefsdialog.h" |
34 | #include "kpimprefs.h" | 34 | #include "kpimprefs.h" |
35 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
39 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
42 | #include <qbuttongroup.h> | 42 | #include <qbuttongroup.h> |
43 | #include <qtimer.h> | 43 | #include <qtimer.h> |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qapplication.h> | 45 | #include <qapplication.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #include <qlabel.h> | 50 | #include <qlabel.h> |
51 | #include <qcheckbox.h> | 51 | #include <qcheckbox.h> |
52 | 52 | ||
53 | #include <klocale.h> | 53 | #include <klocale.h> |
54 | #include <kglobal.h> | 54 | #include <kglobal.h> |
55 | #include <kconfig.h> | 55 | #include <kconfig.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | 57 | ||
58 | QDateTime KSyncManager::mRequestedSyncEvent; | 58 | QDateTime KSyncManager::mRequestedSyncEvent; |
59 | 59 | ||
60 | 60 | ||
61 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) | 61 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) |
62 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) | 62 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) |
63 | { | 63 | { |
64 | mServerSocket = 0; | 64 | mServerSocket = 0; |
65 | bar = new QProgressBar ( 1, 0 ); | 65 | bar = new QProgressBar ( 1, 0 ); |
66 | bar->setCaption (""); | 66 | bar->setCaption (""); |
67 | 67 | ||
68 | int w = 300; | 68 | int w = 300; |
69 | if ( QApplication::desktop()->width() < 320 ) | 69 | if ( QApplication::desktop()->width() < 320 ) |
70 | w = 220; | 70 | w = 220; |
71 | int h = bar->sizeHint().height() ; | 71 | int h = bar->sizeHint().height() ; |
72 | int dw = QApplication::desktop()->width(); | 72 | int dw = QApplication::desktop()->width(); |
73 | int dh = QApplication::desktop()->height(); | 73 | int dh = QApplication::desktop()->height(); |
74 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 74 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
75 | if ( mPrefs->mPassiveSyncAutoStart ) | 75 | if ( mPrefs->mPassiveSyncAutoStart ) |
76 | enableQuick( false ); | 76 | enableQuick( false ); |
77 | 77 | ||
78 | } | 78 | } |
79 | 79 | ||
80 | KSyncManager::~KSyncManager() | 80 | KSyncManager::~KSyncManager() |
81 | { | 81 | { |
82 | delete bar; | 82 | delete bar; |
83 | } | 83 | } |
84 | 84 | ||
85 | 85 | ||
86 | void KSyncManager::fillSyncMenu() | 86 | void KSyncManager::fillSyncMenu() |
87 | { | 87 | { |
88 | if ( mSyncMenu->count() ) | 88 | if ( mSyncMenu->count() ) |
89 | mSyncMenu->clear(); | 89 | mSyncMenu->clear(); |
90 | 90 | ||
91 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 91 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
92 | mSyncMenu->insertSeparator(); | 92 | mSyncMenu->insertSeparator(); |
93 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); | 93 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); |
94 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); | 94 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); |
95 | clearMenu->insertItem( i18n("For all profiles"), 1 ); | 95 | clearMenu->insertItem( i18n("For all profiles"), 1 ); |
96 | clearMenu->insertSeparator(); | 96 | clearMenu->insertSeparator(); |
97 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); | 97 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); |
98 | mSyncMenu->insertSeparator(); | 98 | mSyncMenu->insertSeparator(); |
99 | if ( mServerSocket == 0 ) { | 99 | if ( mServerSocket == 0 ) { |
100 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 100 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
101 | } else { | 101 | } else { |
102 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 102 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
103 | } | 103 | } |
104 | mSyncMenu->insertSeparator(); | 104 | mSyncMenu->insertSeparator(); |
105 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 105 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
106 | mSyncMenu->insertSeparator(); | 106 | mSyncMenu->insertSeparator(); |
107 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 107 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
108 | config.setGroup("General"); | 108 | config.setGroup("General"); |
109 | QStringList prof = config.readListEntry("SyncProfileNames"); | 109 | QStringList prof = config.readListEntry("SyncProfileNames"); |
110 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 110 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
111 | if ( prof.count() < 2 ) { | 111 | if ( prof.count() < 2 ) { |
112 | prof.clear(); | 112 | prof.clear(); |
113 | QString externalName; | 113 | QString externalName; |
114 | #ifdef DESKTOP_VERSION | 114 | #ifdef DESKTOP_VERSION |
115 | #ifdef _WIN32_ | 115 | #ifdef _WIN32_ |
116 | externalName = "OutLook(not_implemented)"; | 116 | externalName = "OutLook(not_implemented)"; |
117 | #else | 117 | #else |
118 | externalName = "KDE_Desktop"; | 118 | externalName = "KDE_Desktop"; |
119 | #endif | 119 | #endif |
120 | #else | 120 | #else |
121 | externalName = "Sharp_DTM"; | 121 | externalName = "Sharp_DTM"; |
122 | #endif | 122 | #endif |
123 | prof << externalName; | 123 | prof << externalName; |
124 | prof << i18n("Local_file"); | 124 | prof << i18n("Local_file"); |
125 | prof << i18n("Last_file"); | 125 | prof << i18n("Last_file"); |
126 | KSyncProfile* temp = new KSyncProfile (); | 126 | KSyncProfile* temp = new KSyncProfile (); |
127 | temp->setName( prof[0] ); | 127 | temp->setName( prof[0] ); |
128 | temp->writeConfig(&config); | 128 | temp->writeConfig(&config); |
129 | temp->setName( prof[1] ); | 129 | temp->setName( prof[1] ); |
130 | temp->writeConfig(&config); | 130 | temp->writeConfig(&config); |
131 | temp->setName( prof[2] ); | 131 | temp->setName( prof[2] ); |
132 | temp->writeConfig(&config); | 132 | temp->writeConfig(&config); |
133 | config.setGroup("General"); | 133 | config.setGroup("General"); |
134 | config.writeEntry("SyncProfileNames",prof); | 134 | config.writeEntry("SyncProfileNames",prof); |
135 | config.writeEntry("ExternSyncProfiles",externalName); | 135 | config.writeEntry("ExternSyncProfiles",externalName); |
136 | config.sync(); | 136 | config.sync(); |
137 | delete temp; | 137 | delete temp; |
138 | } | 138 | } |
139 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 139 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
140 | mSyncProfileNames = prof; | 140 | mSyncProfileNames = prof; |
141 | unsigned int i; | 141 | unsigned int i; |
142 | for ( i = 0; i < prof.count(); ++i ) { | 142 | for ( i = 0; i < prof.count(); ++i ) { |
143 | mSyncMenu->insertItem( prof[i], 1000+i ); | 143 | mSyncMenu->insertItem( prof[i], 1000+i ); |
144 | clearMenu->insertItem( prof[i], 1000+i ); | 144 | clearMenu->insertItem( prof[i], 1000+i ); |
145 | if ( i == 2 ) | 145 | if ( i == 2 ) |
146 | mSyncMenu->insertSeparator(); | 146 | mSyncMenu->insertSeparator(); |
147 | } | 147 | } |
148 | QDir app_dir; | 148 | QDir app_dir; |
149 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 149 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
150 | if ( mTargetApp == PWMPI) { | 150 | if ( mTargetApp == PWMPI) { |
151 | mSyncMenu->removeItem( 1000 ); | 151 | mSyncMenu->removeItem( 1000 ); |
152 | clearMenu->removeItem( 1000 ); | 152 | clearMenu->removeItem( 1000 ); |
153 | } | 153 | } |
154 | #ifndef DESKTOP_VERSION | 154 | #ifndef DESKTOP_VERSION |
155 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 155 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
156 | mSyncMenu->removeItem( 1000 ); | 156 | mSyncMenu->removeItem( 1000 ); |
157 | clearMenu->removeItem( 1000 ); | 157 | clearMenu->removeItem( 1000 ); |
158 | } | 158 | } |
159 | #endif | 159 | #endif |
160 | mSyncMenu->removeItem( 1002 ); | 160 | mSyncMenu->removeItem( 1002 ); |
161 | clearMenu->removeItem( 1002 ); | 161 | clearMenu->removeItem( 1002 ); |
162 | } | 162 | } |
163 | void KSyncManager::slotClearMenu( int action ) | 163 | void KSyncManager::slotClearMenu( int action ) |
164 | { | 164 | { |
165 | QString syncDevice; | 165 | QString syncDevice; |
166 | if ( action > 999 ) { | 166 | if ( action > 999 ) { |
167 | syncDevice = mSyncProfileNames[action - 1000] ; | 167 | syncDevice = mSyncProfileNames[action - 1000] ; |
168 | } | 168 | } |
169 | 169 | ||
170 | 170 | ||
171 | 171 | ||
172 | int result = 0; | 172 | int result = 0; |
173 | QString sd; | 173 | QString sd; |
174 | if ( syncDevice.isEmpty() ) | 174 | if ( syncDevice.isEmpty() ) |
175 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); | 175 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); |
176 | else | 176 | else |
177 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); | 177 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); |
178 | 178 | ||
179 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, | 179 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, |
180 | 0, 1 ); | 180 | 0, 1 ); |
181 | if ( result ) | 181 | if ( result ) |
182 | return; | 182 | return; |
183 | mImplementation->removeSyncInfo( syncDevice ); | 183 | mImplementation->removeSyncInfo( syncDevice ); |
184 | } | 184 | } |
185 | void KSyncManager::slotSyncMenu( int action ) | 185 | void KSyncManager::slotSyncMenu( int action ) |
186 | { | 186 | { |
187 | qDebug("syncaction %d ", action); | 187 | qDebug("syncaction %d ", action); |
188 | if ( action == 5000 ) | 188 | if ( action == 5000 ) |
189 | return; | 189 | return; |
190 | mSyncWithDesktop = false; | ||
190 | if ( action == 0 ) { | 191 | if ( action == 0 ) { |
191 | 192 | ||
192 | // seems to be a Qt2 event handling bug | 193 | // seems to be a Qt2 event handling bug |
193 | // syncmenu.clear causes a segfault at first time | 194 | // syncmenu.clear causes a segfault at first time |
194 | // when we call it after the main event loop, it is ok | 195 | // when we call it after the main event loop, it is ok |
195 | // same behaviour when calling OM/Pi via QCOP for the first time | 196 | // same behaviour when calling OM/Pi via QCOP for the first time |
196 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 197 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
197 | //confSync(); | 198 | //confSync(); |
198 | 199 | ||
199 | return; | 200 | return; |
200 | } | 201 | } |
201 | if ( action == 1 ) { | 202 | if ( action == 1 ) { |
202 | multiSync( true ); | 203 | multiSync( true ); |
203 | return; | 204 | return; |
204 | } | 205 | } |
205 | if ( action == 2 ) { | 206 | if ( action == 2 ) { |
206 | enableQuick(); | 207 | enableQuick(); |
207 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 208 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
208 | return; | 209 | return; |
209 | } | 210 | } |
210 | if ( action == 3 ) { | 211 | if ( action == 3 ) { |
211 | delete mServerSocket; | 212 | delete mServerSocket; |
212 | mServerSocket = 0; | 213 | mServerSocket = 0; |
213 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 214 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
214 | return; | 215 | return; |
215 | } | 216 | } |
216 | 217 | ||
217 | if (blockSave()) | 218 | if (blockSave()) |
218 | return; | 219 | return; |
219 | 220 | ||
220 | setBlockSave(true); | 221 | setBlockSave(true); |
221 | bool silent = false; | 222 | bool silent = false; |
222 | if ( action == 999 ) { | 223 | if ( action == 999 ) { |
223 | //special mode for silent syncing | 224 | //special mode for silent syncing |
224 | action = 1000; | 225 | action = 1000; |
225 | silent = true; | 226 | silent = true; |
226 | } | 227 | } |
227 | 228 | ||
228 | mCurrentSyncProfile = action - 1000 ; | 229 | mCurrentSyncProfile = action - 1000 ; |
229 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 230 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
230 | mCurrentSyncName = mLocalMachineName ; | 231 | mCurrentSyncName = mLocalMachineName ; |
231 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 232 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
232 | KSyncProfile* temp = new KSyncProfile (); | 233 | KSyncProfile* temp = new KSyncProfile (); |
233 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 234 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
234 | temp->readConfig(&config); | 235 | temp->readConfig(&config); |
235 | if (silent) { | 236 | if (silent) { |
236 | mAskForPreferences = false; | 237 | mAskForPreferences = false; |
237 | mShowSyncSummary = false; | 238 | mShowSyncSummary = false; |
238 | mWriteBackFile = true; | 239 | mWriteBackFile = true; |
239 | mSyncAlgoPrefs = 2;// take newest | 240 | mSyncAlgoPrefs = 2;// take newest |
240 | } | 241 | } |
241 | else { | 242 | else { |
242 | mAskForPreferences = temp->getAskForPreferences(); | 243 | mAskForPreferences = temp->getAskForPreferences(); |
243 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 244 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
244 | mWriteBackFile = temp->getWriteBackFile(); | 245 | mWriteBackFile = temp->getWriteBackFile(); |
245 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 246 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
246 | } | 247 | } |
247 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 248 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
248 | mIsKapiFile = temp->getIsKapiFile(); | 249 | mIsKapiFile = temp->getIsKapiFile(); |
249 | mWriteBackInFuture = 0; | 250 | mWriteBackInFuture = 0; |
250 | if ( temp->getWriteBackFuture() ) | 251 | if ( temp->getWriteBackFuture() ) |
251 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 252 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
252 | 253 | ||
253 | if ( action == 1000 ) { | 254 | if ( action == 1000 ) { |
255 | mIsKapiFile = false; | ||
254 | #ifdef DESKTOP_VERSION | 256 | #ifdef DESKTOP_VERSION |
255 | syncKDE(); | 257 | syncKDE(); |
256 | #else | 258 | #else |
257 | syncSharp(); | 259 | syncSharp(); |
258 | #endif | 260 | #endif |
259 | 261 | ||
260 | } else if ( action == 1001 ) { | 262 | } else if ( action == 1001 ) { |
261 | syncLocalFile(); | 263 | syncLocalFile(); |
262 | 264 | ||
263 | } else if ( action == 1002 ) { | 265 | } else if ( action == 1002 ) { |
264 | mWriteBackFile = false; | 266 | mWriteBackFile = false; |
265 | mAskForPreferences = false; | 267 | mAskForPreferences = false; |
266 | mShowSyncSummary = false; | 268 | mShowSyncSummary = false; |
267 | mSyncAlgoPrefs = 3; | 269 | mSyncAlgoPrefs = 3; |
268 | quickSyncLocalFile(); | 270 | quickSyncLocalFile(); |
269 | 271 | ||
270 | } else if ( action >= 1003 ) { | 272 | } else if ( action >= 1003 ) { |
271 | if ( temp->getIsLocalFileSync() ) { | 273 | if ( temp->getIsLocalFileSync() ) { |
272 | switch(mTargetApp) | 274 | switch(mTargetApp) |
273 | { | 275 | { |
274 | case (KAPI): | 276 | case (KAPI): |
275 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 277 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
276 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 278 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
277 | break; | 279 | break; |
278 | case (KOPI): | 280 | case (KOPI): |
279 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 281 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
280 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 282 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
281 | break; | 283 | break; |
282 | case (PWMPI): | 284 | case (PWMPI): |
283 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 285 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
284 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 286 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
285 | break; | 287 | break; |
286 | default: | 288 | default: |
287 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 289 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
288 | break; | 290 | break; |
289 | 291 | ||
290 | } | 292 | } |
291 | } else { | 293 | } else { |
292 | if ( temp->getIsPhoneSync() ) { | 294 | if ( temp->getIsPhoneSync() ) { |
293 | mPhoneDevice = temp->getPhoneDevice( ) ; | 295 | mPhoneDevice = temp->getPhoneDevice( ) ; |
294 | mPhoneConnection = temp->getPhoneConnection( ); | 296 | mPhoneConnection = temp->getPhoneConnection( ); |
295 | mPhoneModel = temp->getPhoneModel( ); | 297 | mPhoneModel = temp->getPhoneModel( ); |
296 | syncPhone(); | 298 | syncPhone(); |
297 | } else if ( temp->getIsPiSync() ) { | 299 | } else if ( temp->getIsPiSync() ) { |
298 | if ( mTargetApp == KAPI ) { | 300 | if ( mTargetApp == KAPI ) { |
299 | mPassWordPiSync = temp->getRemotePwAB(); | 301 | mPassWordPiSync = temp->getRemotePwAB(); |
300 | mActiveSyncPort = temp->getRemotePortAB(); | 302 | mActiveSyncPort = temp->getRemotePortAB(); |
301 | mActiveSyncIP = temp->getRemoteIPAB(); | 303 | mActiveSyncIP = temp->getRemoteIPAB(); |
302 | } else if ( mTargetApp == KOPI ) { | 304 | } else if ( mTargetApp == KOPI ) { |
303 | mPassWordPiSync = temp->getRemotePw(); | 305 | mPassWordPiSync = temp->getRemotePw(); |
304 | mActiveSyncPort = temp->getRemotePort(); | 306 | mActiveSyncPort = temp->getRemotePort(); |
305 | mActiveSyncIP = temp->getRemoteIP(); | 307 | mActiveSyncIP = temp->getRemoteIP(); |
306 | } else { | 308 | } else { |
307 | mPassWordPiSync = temp->getRemotePwPWM(); | 309 | mPassWordPiSync = temp->getRemotePwPWM(); |
308 | mActiveSyncPort = temp->getRemotePortPWM(); | 310 | mActiveSyncPort = temp->getRemotePortPWM(); |
309 | mActiveSyncIP = temp->getRemoteIPPWM(); | 311 | mActiveSyncIP = temp->getRemoteIPPWM(); |
310 | } | 312 | } |
311 | syncPi(); | 313 | syncPi(); |
312 | while ( !mPisyncFinished ) { | 314 | while ( !mPisyncFinished ) { |
313 | //qDebug("waiting "); | 315 | //qDebug("waiting "); |
314 | qApp->processEvents(); | 316 | qApp->processEvents(); |
315 | } | 317 | } |
316 | } else | 318 | } else |
317 | syncRemote( temp ); | 319 | syncRemote( temp ); |
318 | 320 | ||
319 | } | 321 | } |
320 | } | 322 | } |
321 | delete temp; | 323 | delete temp; |
322 | setBlockSave(false); | 324 | setBlockSave(false); |
323 | } | 325 | } |
324 | 326 | ||
325 | void KSyncManager::enableQuick( bool ask ) | 327 | void KSyncManager::enableQuick( bool ask ) |
326 | { | 328 | { |
327 | bool autoStart; | 329 | bool autoStart; |
328 | bool changed = false; | 330 | bool changed = false; |
329 | if ( ask ) { | 331 | if ( ask ) { |
330 | QDialog dia ( 0, "input-dialog", true ); | 332 | QDialog dia ( 0, "input-dialog", true ); |
331 | QLineEdit lab ( &dia ); | 333 | QLineEdit lab ( &dia ); |
332 | QVBoxLayout lay( &dia ); | 334 | QVBoxLayout lay( &dia ); |
333 | lab.setText( mPrefs->mPassiveSyncPort ); | 335 | lab.setText( mPrefs->mPassiveSyncPort ); |
334 | lay.setMargin(7); | 336 | lay.setMargin(7); |
335 | lay.setSpacing(7); | 337 | lay.setSpacing(7); |
336 | int po = 9197+mTargetApp; | 338 | int po = 9197+mTargetApp; |
337 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); | 339 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); |
338 | lay.addWidget( &label); | 340 | lay.addWidget( &label); |
339 | lay.addWidget( &lab); | 341 | lay.addWidget( &lab); |
340 | 342 | ||
341 | QLineEdit lepw ( &dia ); | 343 | QLineEdit lepw ( &dia ); |
342 | lepw.setText( mPrefs->mPassiveSyncPw ); | 344 | lepw.setText( mPrefs->mPassiveSyncPw ); |
343 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 345 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
344 | lay.addWidget( &label2); | 346 | lay.addWidget( &label2); |
345 | lay.addWidget( &lepw); | 347 | lay.addWidget( &lepw); |
346 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); | 348 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); |
347 | lay.addWidget( &autostart); | 349 | lay.addWidget( &autostart); |
348 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); | 350 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); |
349 | #ifdef DESKTOP_VERSION | 351 | #ifdef DESKTOP_VERSION |
350 | #ifdef _WIN32_ | 352 | #ifdef _WIN32_ |
351 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); | 353 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); |
352 | #else | 354 | #else |
353 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); | 355 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); |
354 | #endif | 356 | #endif |
355 | lay.addWidget( &syncdesktop); | 357 | lay.addWidget( &syncdesktop); |
356 | #else | 358 | #else |
357 | mPrefs->mPassiveSyncWithDesktop = false; | 359 | mPrefs->mPassiveSyncWithDesktop = false; |
358 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); | 360 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); |
359 | syncdesktop.hide(); | 361 | syncdesktop.hide(); |
360 | #endif | 362 | #endif |
361 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); | 363 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); |
362 | 364 | ||
363 | dia.setFixedSize( 230,120 ); | 365 | dia.setFixedSize( 230,120 ); |
364 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 366 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
365 | QPushButton pb ( "OK", &dia); | 367 | QPushButton pb ( "OK", &dia); |
366 | lay.addWidget( &pb ); | 368 | lay.addWidget( &pb ); |
367 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 369 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
368 | dia.show(); | 370 | dia.show(); |
369 | if ( ! dia.exec() ) | 371 | if ( ! dia.exec() ) |
370 | return; | 372 | return; |
371 | dia.hide(); | 373 | dia.hide(); |
372 | qApp->processEvents(); | 374 | qApp->processEvents(); |
373 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { | 375 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { |
374 | changed = true; | 376 | changed = true; |
375 | mPrefs->mPassiveSyncPw = lepw.text(); | 377 | mPrefs->mPassiveSyncPw = lepw.text(); |
376 | } | 378 | } |
377 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { | 379 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { |
378 | mPrefs->mPassiveSyncPort = lab.text(); | 380 | mPrefs->mPassiveSyncPort = lab.text(); |
379 | changed = true; | 381 | changed = true; |
380 | } | 382 | } |
381 | autoStart = autostart.isChecked(); | 383 | autoStart = autostart.isChecked(); |
382 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { | 384 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { |
383 | changed = true; | 385 | changed = true; |
384 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); | 386 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); |
385 | } | 387 | } |
386 | } | 388 | } |
387 | else | 389 | else |
388 | autoStart = mPrefs->mPassiveSyncAutoStart; | 390 | autoStart = mPrefs->mPassiveSyncAutoStart; |
389 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) | 391 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) |
390 | changed = true; | 392 | changed = true; |
391 | bool ok; | 393 | bool ok; |
392 | mPrefs->mPassiveSyncAutoStart = false; | 394 | mPrefs->mPassiveSyncAutoStart = false; |
393 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); | 395 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); |
394 | if ( ! ok ) { | 396 | if ( ! ok ) { |
395 | KMessageBox::information( 0, i18n("No valid port")); | 397 | KMessageBox::information( 0, i18n("No valid port")); |
396 | return; | 398 | return; |
397 | } | 399 | } |
398 | //qDebug("port %d ", port); | 400 | //qDebug("port %d ", port); |
399 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | 401 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); |
400 | mServerSocket->setFileName( defaultFileName() ); | 402 | mServerSocket->setFileName( defaultFileName() ); |
401 | //qDebug("connected "); | 403 | //qDebug("connected "); |
402 | if ( !mServerSocket->ok() ) { | 404 | if ( !mServerSocket->ok() ) { |
403 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); | 405 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); |
404 | delete mServerSocket; | 406 | delete mServerSocket; |
405 | mServerSocket = 0; | 407 | mServerSocket = 0; |
406 | return; | 408 | return; |
407 | } | 409 | } |
408 | mPrefs->mPassiveSyncAutoStart = autoStart; | 410 | mPrefs->mPassiveSyncAutoStart = autoStart; |
409 | if ( changed ) { | 411 | if ( changed ) { |
410 | mPrefs->writeConfig(); | 412 | mPrefs->writeConfig(); |
411 | } | 413 | } |
412 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 414 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
413 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 415 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
414 | } | 416 | } |
415 | 417 | ||
416 | void KSyncManager::syncLocalFile() | 418 | void KSyncManager::syncLocalFile() |
417 | { | 419 | { |
418 | 420 | ||
419 | QString fn =mPrefs->mLastSyncedLocalFile; | 421 | QString fn =mPrefs->mLastSyncedLocalFile; |
420 | QString ext; | 422 | QString ext; |
421 | 423 | ||
422 | switch(mTargetApp) | 424 | switch(mTargetApp) |
423 | { | 425 | { |
424 | case (KAPI): | 426 | case (KAPI): |
425 | ext = "(*.vcf)"; | 427 | ext = "(*.vcf)"; |
426 | break; | 428 | break; |
427 | case (KOPI): | 429 | case (KOPI): |
428 | ext = "(*.ics/*.vcs)"; | 430 | ext = "(*.ics/*.vcs)"; |
429 | break; | 431 | break; |
430 | case (PWMPI): | 432 | case (PWMPI): |
431 | ext = "(*.pwm)"; | 433 | ext = "(*.pwm)"; |
432 | break; | 434 | break; |
433 | default: | 435 | default: |
434 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); | 436 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); |
435 | break; | 437 | break; |
436 | 438 | ||
437 | } | 439 | } |
438 | 440 | ||
439 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 441 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
440 | if ( fn == "" ) | 442 | if ( fn == "" ) |
441 | return; | 443 | return; |
442 | if ( syncWithFile( fn, false ) ) { | 444 | if ( syncWithFile( fn, false ) ) { |
443 | qDebug("syncLocalFile() successful "); | 445 | qDebug("syncLocalFile() successful "); |
444 | } | 446 | } |
445 | 447 | ||
446 | } | 448 | } |
447 | 449 | ||
448 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 450 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
449 | { | 451 | { |
450 | bool ret = false; | 452 | bool ret = false; |
451 | QFileInfo info; | 453 | QFileInfo info; |
452 | info.setFile( fn ); | 454 | info.setFile( fn ); |
453 | QString mess; | 455 | QString mess; |
454 | bool loadbup = true; | 456 | bool loadbup = true; |
455 | if ( !info. exists() ) { | 457 | if ( !info. exists() ) { |
456 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 458 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
457 | int result = QMessageBox::warning( mParent, i18n("Warning!"), | 459 | int result = QMessageBox::warning( mParent, i18n("Warning!"), |
458 | mess ); | 460 | mess ); |
459 | return ret; | 461 | return ret; |
460 | } | 462 | } |
461 | int result = 0; | 463 | int result = 0; |
462 | if ( !quick ) { | 464 | if ( !quick ) { |
463 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 465 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
464 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 466 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
465 | mess, | 467 | mess, |
466 | i18n("Sync"), i18n("Cancel"), 0, | 468 | i18n("Sync"), i18n("Cancel"), 0, |
467 | 0, 1 ); | 469 | 0, 1 ); |
468 | if ( result ) | 470 | if ( result ) |
469 | return false; | 471 | return false; |
470 | } | 472 | } |
471 | if ( mAskForPreferences ) | 473 | if ( mAskForPreferences ) |
472 | if ( !edit_sync_options()) { | 474 | if ( !edit_sync_options()) { |
473 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 475 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
474 | return false; | 476 | return false; |
475 | } | 477 | } |
476 | if ( result == 0 ) { | 478 | if ( result == 0 ) { |
477 | //qDebug("Now sycing ... "); | 479 | //qDebug("Now sycing ... "); |
478 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 480 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
479 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 481 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
480 | else | 482 | else |
481 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 483 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
482 | if ( ! quick ) | 484 | if ( ! quick ) |
483 | mPrefs->mLastSyncedLocalFile = fn; | 485 | mPrefs->mLastSyncedLocalFile = fn; |
484 | } | 486 | } |
485 | return ret; | 487 | return ret; |
486 | } | 488 | } |
487 | 489 | ||
488 | void KSyncManager::quickSyncLocalFile() | 490 | void KSyncManager::quickSyncLocalFile() |
489 | { | 491 | { |
490 | 492 | ||
491 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { | 493 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { |
492 | qDebug("quick syncLocalFile() successful "); | 494 | qDebug("quick syncLocalFile() successful "); |
493 | 495 | ||
494 | } | 496 | } |
495 | } | 497 | } |
496 | 498 | ||
497 | void KSyncManager::multiSync( bool askforPrefs ) | 499 | void KSyncManager::multiSync( bool askforPrefs ) |
498 | { | 500 | { |
499 | if (blockSave()) | 501 | if (blockSave()) |
500 | return; | 502 | return; |
501 | setBlockSave(true); | 503 | setBlockSave(true); |
502 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 504 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
503 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 505 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
504 | question, | 506 | question, |
505 | i18n("Yes"), i18n("No"), | 507 | i18n("Yes"), i18n("No"), |
506 | 0, 0 ) != 0 ) { | 508 | 0, 0 ) != 0 ) { |
507 | setBlockSave(false); | 509 | setBlockSave(false); |
508 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 510 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
509 | return; | 511 | return; |
510 | } | 512 | } |
511 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 513 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
512 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 514 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
513 | if ( askforPrefs ) { | 515 | if ( askforPrefs ) { |
514 | if ( !edit_sync_options()) { | 516 | if ( !edit_sync_options()) { |
515 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 517 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
516 | return; | 518 | return; |
517 | } | 519 | } |
518 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 520 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
519 | } | 521 | } |
520 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 522 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
521 | qApp->processEvents(); | 523 | qApp->processEvents(); |
522 | int num = ringSync() ; | 524 | int num = ringSync() ; |
523 | if ( num > 1 ) | 525 | if ( num > 1 ) |
524 | ringSync(); | 526 | ringSync(); |
525 | setBlockSave(false); | 527 | setBlockSave(false); |
526 | if ( num ) | 528 | if ( num ) |
527 | emit save(); | 529 | emit save(); |
528 | if ( num ) | 530 | if ( num ) |
529 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 531 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
530 | else | 532 | else |
531 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 533 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
532 | return; | 534 | return; |
533 | } | 535 | } |
534 | 536 | ||
535 | int KSyncManager::ringSync() | 537 | int KSyncManager::ringSync() |
536 | { | 538 | { |
537 | int syncedProfiles = 0; | 539 | int syncedProfiles = 0; |
538 | unsigned int i; | 540 | unsigned int i; |
539 | QTime timer; | 541 | QTime timer; |
540 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 542 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
541 | QStringList syncProfileNames = mSyncProfileNames; | 543 | QStringList syncProfileNames = mSyncProfileNames; |
542 | KSyncProfile* temp = new KSyncProfile (); | 544 | KSyncProfile* temp = new KSyncProfile (); |
543 | mAskForPreferences = false; | 545 | mAskForPreferences = false; |
544 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 546 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
545 | mCurrentSyncProfile = i; | 547 | mCurrentSyncProfile = i; |
546 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 548 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
547 | temp->readConfig(&config); | 549 | temp->readConfig(&config); |
548 | 550 | ||
549 | bool includeInRingSync; | 551 | bool includeInRingSync; |
550 | switch(mTargetApp) | 552 | switch(mTargetApp) |
551 | { | 553 | { |
552 | case (KAPI): | 554 | case (KAPI): |
553 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 555 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
554 | break; | 556 | break; |
555 | case (KOPI): | 557 | case (KOPI): |
556 | includeInRingSync = temp->getIncludeInRingSync(); | 558 | includeInRingSync = temp->getIncludeInRingSync(); |
557 | break; | 559 | break; |
558 | case (PWMPI): | 560 | case (PWMPI): |
559 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 561 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
560 | break; | 562 | break; |
561 | default: | 563 | default: |
562 | qDebug("KSyncManager::ringSync: invalid apptype selected"); | 564 | qDebug("KSyncManager::ringSync: invalid apptype selected"); |
563 | break; | 565 | break; |
564 | 566 | ||
565 | } | 567 | } |
566 | 568 | ||
567 | 569 | ||
568 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 570 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
569 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 571 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
570 | ++syncedProfiles; | 572 | ++syncedProfiles; |
571 | // mAskForPreferences = temp->getAskForPreferences(); | 573 | // mAskForPreferences = temp->getAskForPreferences(); |
572 | mWriteBackFile = temp->getWriteBackFile(); | 574 | mWriteBackFile = temp->getWriteBackFile(); |
573 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 575 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
574 | mWriteBackInFuture = 0; | 576 | mWriteBackInFuture = 0; |
575 | if ( temp->getWriteBackFuture() ) | 577 | if ( temp->getWriteBackFuture() ) |
576 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 578 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
577 | mShowSyncSummary = false; | 579 | mShowSyncSummary = false; |
578 | mCurrentSyncDevice = syncProfileNames[i] ; | 580 | mCurrentSyncDevice = syncProfileNames[i] ; |
579 | mCurrentSyncName = mLocalMachineName; | 581 | mCurrentSyncName = mLocalMachineName; |
580 | if ( i == 0 ) { | 582 | if ( i == 0 ) { |
581 | #ifdef DESKTOP_VERSION | 583 | #ifdef DESKTOP_VERSION |
582 | syncKDE(); | 584 | syncKDE(); |
583 | #else | 585 | #else |
584 | syncSharp(); | 586 | syncSharp(); |
585 | #endif | 587 | #endif |
586 | } else { | 588 | } else { |
587 | if ( temp->getIsLocalFileSync() ) { | 589 | if ( temp->getIsLocalFileSync() ) { |
588 | switch(mTargetApp) | 590 | switch(mTargetApp) |
589 | { | 591 | { |
590 | case (KAPI): | 592 | case (KAPI): |
591 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 593 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
592 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 594 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
593 | break; | 595 | break; |
594 | case (KOPI): | 596 | case (KOPI): |
595 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 597 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
596 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 598 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
597 | break; | 599 | break; |
598 | case (PWMPI): | 600 | case (PWMPI): |
599 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 601 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
600 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 602 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
601 | break; | 603 | break; |
602 | default: | 604 | default: |
603 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 605 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
604 | break; | 606 | break; |
605 | } | 607 | } |
606 | } else { | 608 | } else { |
607 | if ( temp->getIsPhoneSync() ) { | 609 | if ( temp->getIsPhoneSync() ) { |
608 | mPhoneDevice = temp->getPhoneDevice( ) ; | 610 | mPhoneDevice = temp->getPhoneDevice( ) ; |
609 | mPhoneConnection = temp->getPhoneConnection( ); | 611 | mPhoneConnection = temp->getPhoneConnection( ); |
610 | mPhoneModel = temp->getPhoneModel( ); | 612 | mPhoneModel = temp->getPhoneModel( ); |
611 | syncPhone(); | 613 | syncPhone(); |
612 | } else if ( temp->getIsPiSync() ) { | 614 | } else if ( temp->getIsPiSync() ) { |
613 | if ( mTargetApp == KAPI ) { | 615 | if ( mTargetApp == KAPI ) { |
614 | mPassWordPiSync = temp->getRemotePwAB(); | 616 | mPassWordPiSync = temp->getRemotePwAB(); |
615 | mActiveSyncPort = temp->getRemotePortAB(); | 617 | mActiveSyncPort = temp->getRemotePortAB(); |
616 | mActiveSyncIP = temp->getRemoteIPAB(); | 618 | mActiveSyncIP = temp->getRemoteIPAB(); |
617 | } else if ( mTargetApp == KOPI ) { | 619 | } else if ( mTargetApp == KOPI ) { |
618 | mPassWordPiSync = temp->getRemotePw(); | 620 | mPassWordPiSync = temp->getRemotePw(); |
619 | mActiveSyncPort = temp->getRemotePort(); | 621 | mActiveSyncPort = temp->getRemotePort(); |
620 | mActiveSyncIP = temp->getRemoteIP(); | 622 | mActiveSyncIP = temp->getRemoteIP(); |
621 | } else { | 623 | } else { |
622 | mPassWordPiSync = temp->getRemotePwPWM(); | 624 | mPassWordPiSync = temp->getRemotePwPWM(); |
623 | mActiveSyncPort = temp->getRemotePortPWM(); | 625 | mActiveSyncPort = temp->getRemotePortPWM(); |
624 | mActiveSyncIP = temp->getRemoteIPPWM(); | 626 | mActiveSyncIP = temp->getRemoteIPPWM(); |
625 | } | 627 | } |
626 | syncPi(); | 628 | syncPi(); |
627 | while ( !mPisyncFinished ) { | 629 | while ( !mPisyncFinished ) { |
628 | //qDebug("waiting "); | 630 | //qDebug("waiting "); |
629 | qApp->processEvents(); | 631 | qApp->processEvents(); |
630 | } | 632 | } |
631 | timer.start(); | 633 | timer.start(); |
632 | while ( timer.elapsed () < 2000 ) { | 634 | while ( timer.elapsed () < 2000 ) { |
633 | qApp->processEvents(); | 635 | qApp->processEvents(); |
634 | } | 636 | } |
635 | } else | 637 | } else |
636 | syncRemote( temp, false ); | 638 | syncRemote( temp, false ); |
637 | 639 | ||
638 | } | 640 | } |
639 | } | 641 | } |
640 | timer.start(); | 642 | timer.start(); |
641 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 643 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
642 | while ( timer.elapsed () < 2000 ) { | 644 | while ( timer.elapsed () < 2000 ) { |
643 | qApp->processEvents(); | 645 | qApp->processEvents(); |
644 | #ifndef _WIN32_ | 646 | #ifndef _WIN32_ |
645 | sleep (1); | 647 | sleep (1); |
646 | #endif | 648 | #endif |
647 | } | 649 | } |
648 | 650 | ||
649 | } | 651 | } |
650 | 652 | ||
651 | } | 653 | } |
652 | delete temp; | 654 | delete temp; |
653 | return syncedProfiles; | 655 | return syncedProfiles; |
654 | } | 656 | } |
655 | 657 | ||
656 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 658 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
657 | { | 659 | { |
658 | QString question; | 660 | QString question; |
659 | if ( ask ) { | 661 | if ( ask ) { |
660 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 662 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
661 | if ( QMessageBox::information( mParent, i18n("Sync"), | 663 | if ( QMessageBox::information( mParent, i18n("Sync"), |
662 | question, | 664 | question, |
663 | i18n("Yes"), i18n("No"), | 665 | i18n("Yes"), i18n("No"), |
664 | 0, 0 ) != 0 ) | 666 | 0, 0 ) != 0 ) |
665 | return; | 667 | return; |
666 | } | 668 | } |
667 | 669 | ||
668 | QString preCommand; | 670 | QString preCommand; |
669 | QString localTempFile; | 671 | QString localTempFile; |
670 | QString postCommand; | 672 | QString postCommand; |
671 | 673 | ||
672 | switch(mTargetApp) | 674 | switch(mTargetApp) |
673 | { | 675 | { |
674 | case (KAPI): | 676 | case (KAPI): |
675 | preCommand = prof->getPreSyncCommandAB(); | 677 | preCommand = prof->getPreSyncCommandAB(); |
676 | postCommand = prof->getPostSyncCommandAB(); | 678 | postCommand = prof->getPostSyncCommandAB(); |
677 | localTempFile = prof->getLocalTempFileAB(); | 679 | localTempFile = prof->getLocalTempFileAB(); |
678 | break; | 680 | break; |
679 | case (KOPI): | 681 | case (KOPI): |
680 | preCommand = prof->getPreSyncCommand(); | 682 | preCommand = prof->getPreSyncCommand(); |
681 | postCommand = prof->getPostSyncCommand(); | 683 | postCommand = prof->getPostSyncCommand(); |
682 | localTempFile = prof->getLocalTempFile(); | 684 | localTempFile = prof->getLocalTempFile(); |
683 | break; | 685 | break; |
684 | case (PWMPI): | 686 | case (PWMPI): |
685 | preCommand = prof->getPreSyncCommandPWM(); | 687 | preCommand = prof->getPreSyncCommandPWM(); |
686 | postCommand = prof->getPostSyncCommandPWM(); | 688 | postCommand = prof->getPostSyncCommandPWM(); |
687 | localTempFile = prof->getLocalTempFilePWM(); | 689 | localTempFile = prof->getLocalTempFilePWM(); |
688 | break; | 690 | break; |
689 | default: | 691 | default: |
690 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); | 692 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); |
691 | break; | 693 | break; |
692 | } | 694 | } |
693 | 695 | ||
694 | 696 | ||
695 | int fi; | 697 | int fi; |
696 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { | 698 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { |
697 | QString pwd = getPassword(); | 699 | QString pwd = getPassword(); |
698 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); | 700 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); |
699 | 701 | ||
700 | } | 702 | } |
701 | int maxlen = 30; | 703 | int maxlen = 30; |
702 | if ( QApplication::desktop()->width() > 320 ) | 704 | if ( QApplication::desktop()->width() > 320 ) |
703 | maxlen += 25; | 705 | maxlen += 25; |
704 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); | 706 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); |
705 | int fileSize = 0; | 707 | int fileSize = 0; |
706 | int result = system ( preCommand ); | 708 | int result = system ( preCommand ); |
707 | // 0 : okay | 709 | // 0 : okay |
708 | // 256: no such file or dir | 710 | // 256: no such file or dir |
709 | // | 711 | // |
710 | qDebug("Sync: Remote copy result(0 = okay): %d ",result ); | 712 | qDebug("Sync: Remote copy result(0 = okay): %d ",result ); |
711 | if ( result != 0 ) { | 713 | if ( result != 0 ) { |
712 | unsigned int len = maxlen; | 714 | unsigned int len = maxlen; |
713 | while ( len < preCommand.length() ) { | 715 | while ( len < preCommand.length() ) { |
714 | preCommand.insert( len , "\n" ); | 716 | preCommand.insert( len , "\n" ); |
715 | len += maxlen +2; | 717 | len += maxlen +2; |
716 | } | 718 | } |
717 | 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 (preCommand) ; | 719 | 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 (preCommand) ; |
718 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 720 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
719 | question, | 721 | question, |
720 | i18n("Okay!")) ; | 722 | i18n("Okay!")) ; |
721 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); | 723 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); |
722 | return; | 724 | return; |
723 | } | 725 | } |
724 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); | 726 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); |
725 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 727 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
726 | 728 | ||
727 | if ( syncWithFile( localTempFile, true ) ) { | 729 | if ( syncWithFile( localTempFile, true ) ) { |
728 | 730 | ||
729 | if ( mWriteBackFile ) { | 731 | if ( mWriteBackFile ) { |
730 | int fi; | 732 | int fi; |
731 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 733 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
732 | QString pwd = getPassword(); | 734 | QString pwd = getPassword(); |
733 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 735 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
734 | 736 | ||
735 | } | 737 | } |
736 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); | 738 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); |
737 | result = system ( postCommand ); | 739 | result = system ( postCommand ); |
738 | qDebug("Sync:Writing back file result: %d ", result); | 740 | qDebug("Sync:Writing back file result: %d ", result); |
739 | if ( result != 0 ) { | 741 | if ( result != 0 ) { |
740 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 742 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
741 | return; | 743 | return; |
742 | } else { | 744 | } else { |
743 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 745 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
744 | } | 746 | } |
745 | } | 747 | } |
746 | } | 748 | } |
747 | return; | 749 | return; |
748 | } | 750 | } |
749 | bool KSyncManager::edit_pisync_options() | 751 | bool KSyncManager::edit_pisync_options() |
750 | { | 752 | { |
751 | QDialog dia( mParent, "dia", true ); | 753 | QDialog dia( mParent, "dia", true ); |
752 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); | 754 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); |
753 | QVBoxLayout lay ( &dia ); | 755 | QVBoxLayout lay ( &dia ); |
754 | lay.setSpacing( 5 ); | 756 | lay.setSpacing( 5 ); |
755 | lay.setMargin( 3 ); | 757 | lay.setMargin( 3 ); |
756 | QLabel lab1 ( i18n("Password for remote access:"), &dia); | 758 | QLabel lab1 ( i18n("Password for remote access:"), &dia); |
757 | lay.addWidget( &lab1 ); | 759 | lay.addWidget( &lab1 ); |
758 | QLineEdit le1 (&dia ); | 760 | QLineEdit le1 (&dia ); |
759 | lay.addWidget( &le1 ); | 761 | lay.addWidget( &le1 ); |
760 | QLabel lab2 ( i18n("Remote IP address:"), &dia); | 762 | QLabel lab2 ( i18n("Remote IP address:"), &dia); |
761 | lay.addWidget( &lab2 ); | 763 | lay.addWidget( &lab2 ); |
762 | QLineEdit le2 (&dia ); | 764 | QLineEdit le2 (&dia ); |
763 | lay.addWidget( &le2 ); | 765 | lay.addWidget( &le2 ); |
764 | QLabel lab3 ( i18n("Remote port number:"), &dia); | 766 | QLabel lab3 ( i18n("Remote port number:"), &dia); |
765 | lay.addWidget( &lab3 ); | 767 | lay.addWidget( &lab3 ); |
766 | QLineEdit le3 (&dia ); | 768 | QLineEdit le3 (&dia ); |
767 | lay.addWidget( &le3 ); | 769 | lay.addWidget( &le3 ); |
768 | QPushButton pb ( "OK", &dia); | 770 | QPushButton pb ( "OK", &dia); |
769 | lay.addWidget( &pb ); | 771 | lay.addWidget( &pb ); |
770 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 772 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
771 | le1.setText( mPassWordPiSync ); | 773 | le1.setText( mPassWordPiSync ); |
772 | le2.setText( mActiveSyncIP ); | 774 | le2.setText( mActiveSyncIP ); |
773 | le3.setText( mActiveSyncPort ); | 775 | le3.setText( mActiveSyncPort ); |
774 | if ( dia.exec() ) { | 776 | if ( dia.exec() ) { |
775 | mPassWordPiSync = le1.text(); | 777 | mPassWordPiSync = le1.text(); |
776 | mActiveSyncPort = le3.text(); | 778 | mActiveSyncPort = le3.text(); |
777 | mActiveSyncIP = le2.text(); | 779 | mActiveSyncIP = le2.text(); |
778 | return true; | 780 | return true; |
779 | } | 781 | } |
780 | return false; | 782 | return false; |
781 | } | 783 | } |
782 | bool KSyncManager::edit_sync_options() | 784 | bool KSyncManager::edit_sync_options() |
783 | { | 785 | { |
784 | 786 | ||
785 | QDialog dia( mParent, "dia", true ); | 787 | QDialog dia( mParent, "dia", true ); |
786 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 788 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
787 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 789 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
788 | QVBoxLayout lay ( &dia ); | 790 | QVBoxLayout lay ( &dia ); |
789 | lay.setSpacing( 2 ); | 791 | lay.setSpacing( 2 ); |
790 | lay.setMargin( 3 ); | 792 | lay.setMargin( 3 ); |
791 | lay.addWidget(&gr); | 793 | lay.addWidget(&gr); |
792 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 794 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
793 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 795 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
794 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 796 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
795 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 797 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
796 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 798 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
797 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 799 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
798 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 800 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
799 | QPushButton pb ( "OK", &dia); | 801 | QPushButton pb ( "OK", &dia); |
800 | lay.addWidget( &pb ); | 802 | lay.addWidget( &pb ); |
801 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 803 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
802 | switch ( mSyncAlgoPrefs ) { | 804 | switch ( mSyncAlgoPrefs ) { |
803 | case 0: | 805 | case 0: |
804 | loc.setChecked( true); | 806 | loc.setChecked( true); |
805 | break; | 807 | break; |
806 | case 1: | 808 | case 1: |
807 | rem.setChecked( true ); | 809 | rem.setChecked( true ); |
808 | break; | 810 | break; |
809 | case 2: | 811 | case 2: |
810 | newest.setChecked( true); | 812 | newest.setChecked( true); |
811 | break; | 813 | break; |
812 | case 3: | 814 | case 3: |
813 | ask.setChecked( true); | 815 | ask.setChecked( true); |
814 | break; | 816 | break; |
815 | case 4: | 817 | case 4: |
816 | f_loc.setChecked( true); | 818 | f_loc.setChecked( true); |
817 | break; | 819 | break; |
818 | case 5: | 820 | case 5: |
819 | f_rem.setChecked( true); | 821 | f_rem.setChecked( true); |
820 | break; | 822 | break; |
821 | case 6: | 823 | case 6: |
822 | // both.setChecked( true); | 824 | // both.setChecked( true); |
823 | break; | 825 | break; |
824 | default: | 826 | default: |
825 | break; | 827 | break; |
826 | } | 828 | } |
827 | if ( dia.exec() ) { | 829 | if ( dia.exec() ) { |
828 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 830 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
829 | return true; | 831 | return true; |
830 | } | 832 | } |
831 | return false; | 833 | return false; |
832 | } | 834 | } |
833 | 835 | ||
834 | QString KSyncManager::getPassword( ) | 836 | QString KSyncManager::getPassword( ) |
835 | { | 837 | { |
836 | QString retfile = ""; | 838 | QString retfile = ""; |
837 | QDialog dia ( mParent, "input-dialog", true ); | 839 | QDialog dia ( mParent, "input-dialog", true ); |
838 | QLineEdit lab ( &dia ); | 840 | QLineEdit lab ( &dia ); |
839 | lab.setEchoMode( QLineEdit::Password ); | 841 | lab.setEchoMode( QLineEdit::Password ); |
840 | QVBoxLayout lay( &dia ); | 842 | QVBoxLayout lay( &dia ); |
841 | lay.setMargin(7); | 843 | lay.setMargin(7); |
842 | lay.setSpacing(7); | 844 | lay.setSpacing(7); |
843 | lay.addWidget( &lab); | 845 | lay.addWidget( &lab); |
844 | dia.setFixedSize( 230,50 ); | 846 | dia.setFixedSize( 230,50 ); |
845 | dia.setCaption( i18n("Enter password") ); | 847 | dia.setCaption( i18n("Enter password") ); |
846 | QPushButton pb ( "OK", &dia); | 848 | QPushButton pb ( "OK", &dia); |
847 | lay.addWidget( &pb ); | 849 | lay.addWidget( &pb ); |
848 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 850 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
849 | dia.show(); | 851 | dia.show(); |
850 | int res = dia.exec(); | 852 | int res = dia.exec(); |
851 | if ( res ) | 853 | if ( res ) |
852 | retfile = lab.text(); | 854 | retfile = lab.text(); |
853 | dia.hide(); | 855 | dia.hide(); |
854 | qApp->processEvents(); | 856 | qApp->processEvents(); |
855 | return retfile; | 857 | return retfile; |
856 | 858 | ||
857 | } | 859 | } |
858 | 860 | ||
859 | 861 | ||
860 | void KSyncManager::confSync() | 862 | void KSyncManager::confSync() |
861 | { | 863 | { |
862 | static KSyncPrefsDialog* sp = 0; | 864 | static KSyncPrefsDialog* sp = 0; |
863 | if ( ! sp ) { | 865 | if ( ! sp ) { |
864 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 866 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
865 | } | 867 | } |
866 | sp->usrReadConfig(); | 868 | sp->usrReadConfig(); |
867 | #ifndef DESKTOP_VERSION | 869 | #ifndef DESKTOP_VERSION |
868 | sp->showMaximized(); | 870 | sp->showMaximized(); |
869 | #else | 871 | #else |
870 | sp->show(); | 872 | sp->show(); |
871 | #endif | 873 | #endif |
872 | sp->exec(); | 874 | sp->exec(); |
873 | QStringList oldSyncProfileNames = mSyncProfileNames; | 875 | QStringList oldSyncProfileNames = mSyncProfileNames; |
874 | mSyncProfileNames = sp->getSyncProfileNames(); | 876 | mSyncProfileNames = sp->getSyncProfileNames(); |
875 | mLocalMachineName = sp->getLocalMachineName (); | 877 | mLocalMachineName = sp->getLocalMachineName (); |
876 | int ii; | 878 | int ii; |
877 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { | 879 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { |
878 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) | 880 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) |
879 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); | 881 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); |
880 | } | 882 | } |
881 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 883 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
882 | } | 884 | } |
883 | void KSyncManager::syncKDE() | 885 | void KSyncManager::syncKDE() |
884 | { | 886 | { |
887 | mSyncWithDesktop = true; | ||
885 | emit save(); | 888 | emit save(); |
886 | switch(mTargetApp) | 889 | switch(mTargetApp) |
887 | { | 890 | { |
888 | case (KAPI): | 891 | case (KAPI): |
889 | 892 | { | |
893 | #ifdef DESKTOP_VERSION | ||
894 | QString command = qApp->applicationDirPath () + "/kdeabdump"; | ||
895 | #else | ||
896 | QString command = "kdeabdump"; | ||
897 | #endif | ||
898 | if ( ! QFile::exists ( command ) ) | ||
899 | command = "kdeabdump"; | ||
900 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; | ||
901 | system ( command.latin1()); | ||
902 | if ( syncWithFile( fileName,true ) ) { | ||
903 | if ( mWriteBackFile ) { | ||
904 | command += " --read"; | ||
905 | system ( command.latin1()); | ||
906 | } | ||
907 | } | ||
908 | |||
909 | } | ||
890 | break; | 910 | break; |
891 | case (KOPI): | 911 | case (KOPI): |
892 | { | 912 | { |
893 | #ifdef DESKTOP_VERSION | 913 | #ifdef DESKTOP_VERSION |
894 | QString command = qApp->applicationDirPath () + "/kdecaldump"; | 914 | QString command = qApp->applicationDirPath () + "/kdecaldump"; |
895 | #else | 915 | #else |
896 | QString command = "kdecaldump"; | 916 | QString command = "kdecaldump"; |
897 | #endif | 917 | #endif |
898 | if ( ! QFile::exists ( command ) ) | 918 | if ( ! QFile::exists ( command ) ) |
899 | command = "kdecaldump"; | 919 | command = "kdecaldump"; |
900 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 920 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
901 | system ( command.latin1()); | 921 | system ( command.latin1()); |
902 | if ( syncWithFile( fileName,true ) ) { | 922 | if ( syncWithFile( fileName,true ) ) { |
903 | if ( mWriteBackFile ) { | 923 | if ( mWriteBackFile ) { |
904 | command += " --read"; | 924 | command += " --read"; |
905 | system ( command.latin1()); | 925 | system ( command.latin1()); |
906 | } | 926 | } |
907 | } | 927 | } |
908 | 928 | ||
909 | } | 929 | } |
910 | break; | 930 | break; |
911 | case (PWMPI): | 931 | case (PWMPI): |
912 | 932 | ||
913 | break; | 933 | break; |
914 | default: | 934 | default: |
915 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 935 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
916 | break; | 936 | break; |
917 | 937 | ||
918 | } | 938 | } |
919 | } | 939 | } |
920 | 940 | ||
921 | void KSyncManager::syncSharp() | 941 | void KSyncManager::syncSharp() |
922 | { | 942 | { |
923 | 943 | ||
924 | if ( ! syncExternalApplication("sharp") ) | 944 | if ( ! syncExternalApplication("sharp") ) |
925 | qDebug("ERROR sync sharp "); | 945 | qDebug("ERROR sync sharp "); |
926 | } | 946 | } |
927 | 947 | ||
928 | bool KSyncManager::syncExternalApplication(QString resource) | 948 | bool KSyncManager::syncExternalApplication(QString resource) |
929 | { | 949 | { |
930 | 950 | ||
931 | emit save(); | 951 | emit save(); |
932 | 952 | ||
933 | if ( mAskForPreferences ) | 953 | if ( mAskForPreferences ) |
934 | if ( !edit_sync_options()) { | 954 | if ( !edit_sync_options()) { |
935 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 955 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
936 | return false; | 956 | return false; |
937 | } | 957 | } |
938 | 958 | ||
939 | qDebug("Sync extern %s", resource.latin1()); | 959 | qDebug("Sync extern %s", resource.latin1()); |
940 | 960 | ||
941 | bool syncOK = mImplementation->syncExternal(this, resource); | 961 | bool syncOK = mImplementation->syncExternal(this, resource); |
942 | 962 | ||
943 | return syncOK; | 963 | return syncOK; |
944 | 964 | ||
945 | } | 965 | } |
946 | 966 | ||
947 | void KSyncManager::syncPhone() | 967 | void KSyncManager::syncPhone() |
948 | { | 968 | { |
949 | 969 | ||
950 | syncExternalApplication("phone"); | 970 | syncExternalApplication("phone"); |
951 | 971 | ||
952 | } | 972 | } |
953 | 973 | ||
954 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 974 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
955 | { | 975 | { |
956 | if (!bar->isVisible()) | 976 | if (!bar->isVisible()) |
957 | { | 977 | { |
958 | bar->setCaption (caption); | 978 | bar->setCaption (caption); |
959 | bar->setTotalSteps ( total ) ; | 979 | bar->setTotalSteps ( total ) ; |
960 | 980 | ||
961 | bar->show(); | 981 | bar->show(); |
962 | } | 982 | } |
963 | 983 | ||
964 | bar->setProgress( percentage ); | 984 | bar->setProgress( percentage ); |
965 | } | 985 | } |
966 | 986 | ||
967 | void KSyncManager::hideProgressBar() | 987 | void KSyncManager::hideProgressBar() |
968 | { | 988 | { |
969 | bar->hide(); | 989 | bar->hide(); |
970 | } | 990 | } |
971 | 991 | ||
972 | bool KSyncManager::isProgressBarCanceled() | 992 | bool KSyncManager::isProgressBarCanceled() |
973 | { | 993 | { |
974 | return !bar->isVisible(); | 994 | return !bar->isVisible(); |
975 | } | 995 | } |
976 | 996 | ||
977 | QString KSyncManager::syncFileName() | 997 | QString KSyncManager::syncFileName() |
978 | { | 998 | { |
979 | 999 | ||
980 | QString fn = "tempfile"; | 1000 | QString fn = "tempfile"; |
981 | switch(mTargetApp) | 1001 | switch(mTargetApp) |
982 | { | 1002 | { |
983 | case (KAPI): | 1003 | case (KAPI): |
984 | fn = "tempsyncab.vcf"; | 1004 | fn = "tempsyncab.vcf"; |
985 | break; | 1005 | break; |
986 | case (KOPI): | 1006 | case (KOPI): |
987 | fn = "tempsynccal.ics"; | 1007 | fn = "tempsynccal.ics"; |
988 | break; | 1008 | break; |
989 | case (PWMPI): | 1009 | case (PWMPI): |
990 | fn = "tempsyncpw.pwm"; | 1010 | fn = "tempsyncpw.pwm"; |
991 | break; | 1011 | break; |
992 | default: | 1012 | default: |
993 | break; | 1013 | break; |
994 | } | 1014 | } |
995 | #ifdef _WIN32_ | 1015 | #ifdef _WIN32_ |
996 | return locateLocal( "tmp", fn ); | 1016 | return locateLocal( "tmp", fn ); |
997 | #else | 1017 | #else |
998 | return (QString( "/tmp/" )+ fn ); | 1018 | return (QString( "/tmp/" )+ fn ); |
999 | #endif | 1019 | #endif |
1000 | } | 1020 | } |
1001 | 1021 | ||
1002 | void KSyncManager::syncPi() | 1022 | void KSyncManager::syncPi() |
1003 | { | 1023 | { |
1004 | mPisyncFinished = false; | 1024 | mPisyncFinished = false; |
1005 | qApp->processEvents(); | 1025 | qApp->processEvents(); |
1006 | if ( mAskForPreferences ) | 1026 | if ( mAskForPreferences ) |
1007 | if ( !edit_pisync_options()) { | 1027 | if ( !edit_pisync_options()) { |
1008 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1028 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1009 | return; | 1029 | return; |
1010 | } | 1030 | } |
1011 | bool ok; | 1031 | bool ok; |
1012 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 1032 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
1013 | if ( ! ok ) { | 1033 | if ( ! ok ) { |
1014 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 1034 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
1015 | return; | 1035 | return; |
1016 | } | 1036 | } |
1017 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); | 1037 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); |
1018 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 1038 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1019 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); | 1039 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); |
1020 | commandSocket->readFile( syncFileName() ); | 1040 | commandSocket->readFile( syncFileName() ); |
1021 | } | 1041 | } |
1022 | 1042 | ||
1023 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 1043 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
1024 | { | 1044 | { |
1025 | //enum { success, errorW, errorR, quiet }; | 1045 | //enum { success, errorW, errorR, quiet }; |
1026 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { | 1046 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { |
1027 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 1047 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
1028 | delete s; | 1048 | delete s; |
1029 | if ( state == KCommandSocket::errorR ) { | 1049 | if ( state == KCommandSocket::errorR ) { |
1030 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 1050 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
1031 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1051 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1032 | commandSocket->sendStop(); | 1052 | commandSocket->sendStop(); |
1033 | } | 1053 | } |
1034 | mPisyncFinished = true; | 1054 | mPisyncFinished = true; |
1035 | return; | 1055 | return; |
1036 | 1056 | ||
1037 | } else if ( state == KCommandSocket::errorW ) { | 1057 | } else if ( state == KCommandSocket::errorW ) { |
1038 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 1058 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
1039 | mPisyncFinished = true; | 1059 | mPisyncFinished = true; |
1040 | 1060 | ||
1041 | } else if ( state == KCommandSocket::successR ) { | 1061 | } else if ( state == KCommandSocket::successR ) { |
1042 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 1062 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
1043 | 1063 | ||
1044 | } else if ( state == KCommandSocket::successW ) { | 1064 | } else if ( state == KCommandSocket::successW ) { |
1045 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 1065 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
1046 | mPisyncFinished = true; | 1066 | mPisyncFinished = true; |
1047 | } | 1067 | } |
1048 | 1068 | ||
1049 | delete s; | 1069 | delete s; |
1050 | } | 1070 | } |
1051 | 1071 | ||
1052 | void KSyncManager::readFileFromSocket() | 1072 | void KSyncManager::readFileFromSocket() |
1053 | { | 1073 | { |
1054 | QString fileName = syncFileName(); | 1074 | QString fileName = syncFileName(); |
1055 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); | 1075 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
1056 | if ( ! syncWithFile( fileName , true ) ) { | 1076 | if ( ! syncWithFile( fileName , true ) ) { |
1057 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); | 1077 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); |
1058 | mPisyncFinished = true; | 1078 | mPisyncFinished = true; |
1059 | return; | 1079 | return; |
1060 | } | 1080 | } |
1061 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 1081 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
1062 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1082 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1063 | if ( mWriteBackFile ) | 1083 | if ( mWriteBackFile ) |
1064 | commandSocket->writeFile( fileName ); | 1084 | commandSocket->writeFile( fileName ); |
1065 | else { | 1085 | else { |
1066 | commandSocket->sendStop(); | 1086 | commandSocket->sendStop(); |
1067 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 1087 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
1068 | mPisyncFinished = true; | 1088 | mPisyncFinished = true; |
1069 | } | 1089 | } |
1070 | } | 1090 | } |
1071 | 1091 | ||
1072 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 1092 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
1073 | { | 1093 | { |
1074 | mPassWord = pw; | 1094 | mPassWord = pw; |
1075 | mSocket = 0; | 1095 | mSocket = 0; |
1076 | mSyncActionDialog = 0; | 1096 | mSyncActionDialog = 0; |
1077 | blockRC = false; | 1097 | blockRC = false; |
1078 | }; | 1098 | }; |
1079 | 1099 | ||
1080 | void KServerSocket::newConnection ( int socket ) | 1100 | void KServerSocket::newConnection ( int socket ) |
1081 | { | 1101 | { |
1082 | // qDebug("KServerSocket:New connection %d ", socket); | 1102 | // qDebug("KServerSocket:New connection %d ", socket); |
1083 | if ( mSocket ) { | 1103 | if ( mSocket ) { |
1084 | qDebug("KServerSocket::newConnection Socket deleted! "); | 1104 | qDebug("KServerSocket::newConnection Socket deleted! "); |
1085 | delete mSocket; | 1105 | delete mSocket; |
1086 | mSocket = 0; | 1106 | mSocket = 0; |
1087 | } | 1107 | } |
1088 | mSocket = new QSocket( this ); | 1108 | mSocket = new QSocket( this ); |
1089 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 1109 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
1090 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 1110 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
1091 | mSocket->setSocket( socket ); | 1111 | mSocket->setSocket( socket ); |
1092 | } | 1112 | } |
1093 | 1113 | ||
1094 | void KServerSocket::discardClient() | 1114 | void KServerSocket::discardClient() |
1095 | { | 1115 | { |
1096 | //qDebug(" KServerSocket::discardClient()"); | 1116 | //qDebug(" KServerSocket::discardClient()"); |
1097 | if ( mSocket ) { | 1117 | if ( mSocket ) { |
1098 | delete mSocket; | 1118 | delete mSocket; |
1099 | mSocket = 0; | 1119 | mSocket = 0; |
1100 | } | 1120 | } |
1101 | //emit endConnect(); | 1121 | //emit endConnect(); |
1102 | } | 1122 | } |
1103 | void KServerSocket::readClient() | 1123 | void KServerSocket::readClient() |
1104 | { | 1124 | { |
1105 | if ( blockRC ) | 1125 | if ( blockRC ) |
1106 | return; | 1126 | return; |
1107 | if ( mSocket == 0 ) { | 1127 | if ( mSocket == 0 ) { |
1108 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); | 1128 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); |
1109 | return; | 1129 | return; |
1110 | } | 1130 | } |
1111 | //qDebug("KServerSocket::readClient()"); | 1131 | //qDebug("KServerSocket::readClient()"); |
1112 | if ( mSocket->canReadLine() ) { | 1132 | if ( mSocket->canReadLine() ) { |
1113 | QString line = mSocket->readLine(); | 1133 | QString line = mSocket->readLine(); |
1114 | //qDebug("KServerSocket readline: %s ", line.latin1()); | 1134 | //qDebug("KServerSocket readline: %s ", line.latin1()); |
1115 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | 1135 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); |
1116 | if ( tokens[0] == "GET" ) { | 1136 | if ( tokens[0] == "GET" ) { |
1117 | if ( tokens[1] == mPassWord ) { | 1137 | if ( tokens[1] == mPassWord ) { |
1118 | //emit sendFile( mSocket ); | 1138 | //emit sendFile( mSocket ); |
1119 | bool ok = false; | 1139 | bool ok = false; |
1120 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); | 1140 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); |
1121 | if ( ok ) | 1141 | if ( ok ) |
1122 | KSyncManager::mRequestedSyncEvent = dt; | 1142 | KSyncManager::mRequestedSyncEvent = dt; |
1123 | else | 1143 | else |
1124 | KSyncManager::mRequestedSyncEvent = QDateTime(); | 1144 | KSyncManager::mRequestedSyncEvent = QDateTime(); |
1125 | send_file(); | 1145 | send_file(); |
1126 | } | 1146 | } |
1127 | else { | 1147 | else { |
1128 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); | 1148 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); |
1129 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 1149 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
1130 | } | 1150 | } |
1131 | } | 1151 | } |
1132 | if ( tokens[0] == "PUT" ) { | 1152 | if ( tokens[0] == "PUT" ) { |
1133 | if ( tokens[1] == mPassWord ) { | 1153 | if ( tokens[1] == mPassWord ) { |
1134 | //emit getFile( mSocket ); | 1154 | //emit getFile( mSocket ); |
1135 | blockRC = true; | 1155 | blockRC = true; |
1136 | get_file(); | 1156 | get_file(); |
1137 | } | 1157 | } |
1138 | else { | 1158 | else { |
1139 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); | 1159 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); |
1140 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 1160 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
1141 | } | 1161 | } |
1142 | } | 1162 | } |
1143 | if ( tokens[0] == "STOP" ) { | 1163 | if ( tokens[0] == "STOP" ) { |
1144 | //emit endConnect(); | 1164 | //emit endConnect(); |
1145 | end_connect(); | 1165 | end_connect(); |
1146 | } | 1166 | } |
1147 | } | 1167 | } |
1148 | } | 1168 | } |
1149 | void KServerSocket::end_connect() | 1169 | void KServerSocket::end_connect() |
1150 | { | 1170 | { |
1151 | delete mSyncActionDialog; | 1171 | delete mSyncActionDialog; |
1152 | mSyncActionDialog = 0; | 1172 | mSyncActionDialog = 0; |
1153 | } | 1173 | } |
1154 | void KServerSocket::send_file() | 1174 | void KServerSocket::send_file() |
1155 | { | 1175 | { |
1156 | //qDebug("MainWindow::sendFile(QSocket* s) "); | 1176 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
1157 | if ( mSyncActionDialog ) | 1177 | if ( mSyncActionDialog ) |
1158 | delete mSyncActionDialog; | 1178 | delete mSyncActionDialog; |
1159 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 1179 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
1160 | mSyncActionDialog->setCaption(i18n("Received sync request")); | 1180 | mSyncActionDialog->setCaption(i18n("Received sync request")); |
1161 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | 1181 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); |
1162 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 1182 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
1163 | lay->addWidget( label); | 1183 | lay->addWidget( label); |
1164 | lay->setMargin(7); | 1184 | lay->setMargin(7); |
1165 | lay->setSpacing(7); | 1185 | lay->setSpacing(7); |
1166 | mSyncActionDialog->setFixedSize( 230, 120); | 1186 | mSyncActionDialog->setFixedSize( 230, 120); |
1167 | mSyncActionDialog->show(); | 1187 | mSyncActionDialog->show(); |
1168 | mSyncActionDialog->raise(); | 1188 | mSyncActionDialog->raise(); |
1169 | emit request_file(); | 1189 | emit request_file(); |
1170 | qApp->processEvents(); | 1190 | qApp->processEvents(); |
1171 | QString fileName = mFileName; | 1191 | QString fileName = mFileName; |
1172 | QFile file( fileName ); | 1192 | QFile file( fileName ); |
1173 | if (!file.open( IO_ReadOnly ) ) { | 1193 | if (!file.open( IO_ReadOnly ) ) { |
1174 | delete mSyncActionDialog; | 1194 | delete mSyncActionDialog; |
1175 | mSyncActionDialog = 0; | 1195 | mSyncActionDialog = 0; |
1176 | qDebug("KSS::error open file "); | 1196 | qDebug("KSS::error open file "); |
1177 | mSocket->close(); | 1197 | mSocket->close(); |
1178 | if ( mSocket->state() == QSocket::Idle ) | 1198 | if ( mSocket->state() == QSocket::Idle ) |
1179 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1199 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1180 | return ; | 1200 | return ; |
1181 | 1201 | ||
1182 | } | 1202 | } |
1183 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | 1203 | mSyncActionDialog->setCaption( i18n("Sending file...") ); |
1184 | QTextStream ts( &file ); | 1204 | QTextStream ts( &file ); |
1185 | ts.setEncoding( QTextStream::Latin1 ); | 1205 | ts.setEncoding( QTextStream::Latin1 ); |
1186 | 1206 | ||
1187 | QTextStream os( mSocket ); | 1207 | QTextStream os( mSocket ); |
1188 | os.setEncoding( QTextStream::Latin1 ); | 1208 | os.setEncoding( QTextStream::Latin1 ); |
1189 | while ( ! ts.atEnd() ) { | 1209 | while ( ! ts.atEnd() ) { |
1190 | os << ts.readLine() << "\r\n"; | 1210 | os << ts.readLine() << "\r\n"; |
1191 | } | 1211 | } |
1192 | //os << ts.read(); | 1212 | //os << ts.read(); |
1193 | file.close(); | 1213 | file.close(); |
1194 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 1214 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
1195 | mSocket->close(); | 1215 | mSocket->close(); |
1196 | if ( mSocket->state() == QSocket::Idle ) | 1216 | if ( mSocket->state() == QSocket::Idle ) |
1197 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1217 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1198 | } | 1218 | } |
1199 | void KServerSocket::get_file() | 1219 | void KServerSocket::get_file() |
1200 | { | 1220 | { |
1201 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 1221 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
1202 | 1222 | ||
1203 | piTime.start(); | 1223 | piTime.start(); |
1204 | piFileString = ""; | 1224 | piFileString = ""; |
1205 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 1225 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
1206 | } | 1226 | } |
1207 | 1227 | ||
1208 | 1228 | ||
1209 | void KServerSocket::readBackFileFromSocket() | 1229 | void KServerSocket::readBackFileFromSocket() |
1210 | { | 1230 | { |
1211 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 1231 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
1212 | while ( mSocket->canReadLine () ) { | 1232 | while ( mSocket->canReadLine () ) { |
1213 | piTime.restart(); | 1233 | piTime.restart(); |
1214 | QString line = mSocket->readLine (); | 1234 | QString line = mSocket->readLine (); |
1215 | piFileString += line; | 1235 | piFileString += line; |
1216 | //qDebug("readline: %s ", line.latin1()); | 1236 | //qDebug("readline: %s ", line.latin1()); |
1217 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 1237 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
1218 | 1238 | ||
1219 | } | 1239 | } |
1220 | if ( piTime.elapsed () < 3000 ) { | 1240 | if ( piTime.elapsed () < 3000 ) { |
1221 | // wait for more | 1241 | // wait for more |
1222 | //qDebug("waitformore "); | 1242 | //qDebug("waitformore "); |
1223 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 1243 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
1224 | return; | 1244 | return; |
1225 | } | 1245 | } |
1226 | QString fileName = mFileName; | 1246 | QString fileName = mFileName; |
1227 | QFile file ( fileName ); | 1247 | QFile file ( fileName ); |
1228 | if (!file.open( IO_WriteOnly ) ) { | 1248 | if (!file.open( IO_WriteOnly ) ) { |
1229 | delete mSyncActionDialog; | 1249 | delete mSyncActionDialog; |
1230 | mSyncActionDialog = 0; | 1250 | mSyncActionDialog = 0; |
1231 | qDebug("KSS:Error open read back file "); | 1251 | qDebug("KSS:Error open read back file "); |
1232 | piFileString = ""; | 1252 | piFileString = ""; |
1233 | emit file_received( false ); | 1253 | emit file_received( false ); |
1234 | blockRC = false; | 1254 | blockRC = false; |
1235 | return ; | 1255 | return ; |
1236 | 1256 | ||
1237 | } | 1257 | } |
1238 | 1258 | ||
1239 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1259 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1240 | QTextStream ts ( &file ); | 1260 | QTextStream ts ( &file ); |
1241 | ts.setEncoding( QTextStream::Latin1 ); | 1261 | ts.setEncoding( QTextStream::Latin1 ); |
1242 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 1262 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
1243 | ts << piFileString; | 1263 | ts << piFileString; |
1244 | mSocket->close(); | 1264 | mSocket->close(); |
1245 | if ( mSocket->state() == QSocket::Idle ) | 1265 | if ( mSocket->state() == QSocket::Idle ) |
1246 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1266 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1247 | file.close(); | 1267 | file.close(); |
1248 | piFileString = ""; | 1268 | piFileString = ""; |
1249 | emit file_received( true ); | 1269 | emit file_received( true ); |
1250 | delete mSyncActionDialog; | 1270 | delete mSyncActionDialog; |
1251 | mSyncActionDialog = 0; | 1271 | mSyncActionDialog = 0; |
1252 | blockRC = false; | 1272 | blockRC = false; |
1253 | 1273 | ||
1254 | } | 1274 | } |
1255 | 1275 | ||
1256 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) | 1276 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) |
1257 | { | 1277 | { |
1258 | mPassWord = password; | 1278 | mPassWord = password; |
1259 | mSocket = 0; | 1279 | mSocket = 0; |
1260 | mPort = port; | 1280 | mPort = port; |
1261 | mHost = host; | 1281 | mHost = host; |
1262 | 1282 | ||
1263 | mRetVal = quiet; | 1283 | mRetVal = quiet; |
1264 | mTimerSocket = new QTimer ( this ); | 1284 | mTimerSocket = new QTimer ( this ); |
1265 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); | 1285 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); |
1266 | } | 1286 | } |
1267 | void KCommandSocket::readFile( QString fn ) | 1287 | void KCommandSocket::readFile( QString fn ) |
1268 | { | 1288 | { |
1269 | if ( !mSocket ) { | 1289 | if ( !mSocket ) { |
1270 | mSocket = new QSocket( this ); | 1290 | mSocket = new QSocket( this ); |
1271 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | 1291 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); |
1272 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1292 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1273 | } | 1293 | } |
1274 | mFileString = ""; | 1294 | mFileString = ""; |
1275 | mFileName = fn; | 1295 | mFileName = fn; |
1276 | mFirst = true; | 1296 | mFirst = true; |
1277 | mSocket->connectToHost( mHost, mPort ); | 1297 | mSocket->connectToHost( mHost, mPort ); |
1278 | QTextStream os( mSocket ); | 1298 | QTextStream os( mSocket ); |
1279 | os.setEncoding( QTextStream::Latin1 ); | 1299 | os.setEncoding( QTextStream::Latin1 ); |
1280 | 1300 | ||
1281 | QString curDt = KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); | 1301 | QString curDt = KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); |
1282 | os << "GET " << mPassWord << curDt <<"\r\n"; | 1302 | os << "GET " << mPassWord << curDt <<"\r\n"; |
1283 | mTimerSocket->start( 20000 ); | 1303 | mTimerSocket->start( 20000 ); |
1284 | } | 1304 | } |
1285 | 1305 | ||
1286 | void KCommandSocket::writeFile( QString fileName ) | 1306 | void KCommandSocket::writeFile( QString fileName ) |
1287 | { | 1307 | { |
1288 | if ( !mSocket ) { | 1308 | if ( !mSocket ) { |
1289 | mSocket = new QSocket( this ); | 1309 | mSocket = new QSocket( this ); |
1290 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1310 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1291 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); | 1311 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); |
1292 | } | 1312 | } |
1293 | mFileName = fileName ; | 1313 | mFileName = fileName ; |
1294 | mSocket->connectToHost( mHost, mPort ); | 1314 | mSocket->connectToHost( mHost, mPort ); |
1295 | } | 1315 | } |
1296 | void KCommandSocket::writeFileToSocket() | 1316 | void KCommandSocket::writeFileToSocket() |
1297 | { | 1317 | { |
1298 | QFile file2( mFileName ); | 1318 | QFile file2( mFileName ); |
1299 | if (!file2.open( IO_ReadOnly ) ) { | 1319 | if (!file2.open( IO_ReadOnly ) ) { |
1300 | mRetVal= errorW; | 1320 | mRetVal= errorW; |
1301 | mSocket->close(); | 1321 | mSocket->close(); |
1302 | if ( mSocket->state() == QSocket::Idle ) | 1322 | if ( mSocket->state() == QSocket::Idle ) |
1303 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1323 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1304 | return ; | 1324 | return ; |
1305 | } | 1325 | } |
1306 | QTextStream ts2( &file2 ); | 1326 | QTextStream ts2( &file2 ); |
1307 | ts2.setEncoding( QTextStream::Latin1 ); | 1327 | ts2.setEncoding( QTextStream::Latin1 ); |
1308 | QTextStream os2( mSocket ); | 1328 | QTextStream os2( mSocket ); |
1309 | os2.setEncoding( QTextStream::Latin1 ); | 1329 | os2.setEncoding( QTextStream::Latin1 ); |
1310 | os2 << "PUT " << mPassWord << "\r\n";; | 1330 | os2 << "PUT " << mPassWord << "\r\n";; |
1311 | while ( ! ts2.atEnd() ) { | 1331 | while ( ! ts2.atEnd() ) { |
1312 | os2 << ts2.readLine() << "\r\n"; | 1332 | os2 << ts2.readLine() << "\r\n"; |
1313 | } | 1333 | } |
1314 | mRetVal= successW; | 1334 | mRetVal= successW; |
1315 | file2.close(); | 1335 | file2.close(); |
1316 | mSocket->close(); | 1336 | mSocket->close(); |
1317 | if ( mSocket->state() == QSocket::Idle ) | 1337 | if ( mSocket->state() == QSocket::Idle ) |
1318 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1338 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1319 | } | 1339 | } |
1320 | void KCommandSocket::sendStop() | 1340 | void KCommandSocket::sendStop() |
1321 | { | 1341 | { |
1322 | if ( !mSocket ) { | 1342 | if ( !mSocket ) { |
1323 | mSocket = new QSocket( this ); | 1343 | mSocket = new QSocket( this ); |
1324 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1344 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1325 | } | 1345 | } |
1326 | mSocket->connectToHost( mHost, mPort ); | 1346 | mSocket->connectToHost( mHost, mPort ); |
1327 | QTextStream os2( mSocket ); | 1347 | QTextStream os2( mSocket ); |
1328 | os2.setEncoding( QTextStream::Latin1 ); | 1348 | os2.setEncoding( QTextStream::Latin1 ); |
1329 | os2 << "STOP\r\n"; | 1349 | os2 << "STOP\r\n"; |
1330 | mSocket->close(); | 1350 | mSocket->close(); |
1331 | if ( mSocket->state() == QSocket::Idle ) | 1351 | if ( mSocket->state() == QSocket::Idle ) |
1332 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1352 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1333 | } | 1353 | } |
1334 | 1354 | ||
1335 | void KCommandSocket::startReadFileFromSocket() | 1355 | void KCommandSocket::startReadFileFromSocket() |
1336 | { | 1356 | { |
1337 | if ( ! mFirst ) | 1357 | if ( ! mFirst ) |
1338 | return; | 1358 | return; |
1339 | mFirst = false; | 1359 | mFirst = false; |
1340 | mTimerSocket->stop(); | 1360 | mTimerSocket->stop(); |
1341 | mFileString = ""; | 1361 | mFileString = ""; |
1342 | mTime.start(); | 1362 | mTime.start(); |
1343 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | 1363 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); |
1344 | 1364 | ||
1345 | } | 1365 | } |
1346 | void KCommandSocket::readFileFromSocket() | 1366 | void KCommandSocket::readFileFromSocket() |
1347 | { | 1367 | { |
1348 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | 1368 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); |
1349 | while ( mSocket->canReadLine () ) { | 1369 | while ( mSocket->canReadLine () ) { |
1350 | mTime.restart(); | 1370 | mTime.restart(); |
1351 | QString line = mSocket->readLine (); | 1371 | QString line = mSocket->readLine (); |
1352 | mFileString += line; | 1372 | mFileString += line; |
1353 | //qDebug("readline: %s ", line.latin1()); | 1373 | //qDebug("readline: %s ", line.latin1()); |
1354 | } | 1374 | } |
1355 | if ( mTime.elapsed () < 3000 ) { | 1375 | if ( mTime.elapsed () < 3000 ) { |
1356 | // wait for more | 1376 | // wait for more |
1357 | //qDebug("waitformore "); | 1377 | //qDebug("waitformore "); |
1358 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | 1378 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); |
1359 | return; | 1379 | return; |
1360 | } | 1380 | } |
1361 | QString fileName = mFileName; | 1381 | QString fileName = mFileName; |
1362 | QFile file ( fileName ); | 1382 | QFile file ( fileName ); |
1363 | if (!file.open( IO_WriteOnly ) ) { | 1383 | if (!file.open( IO_WriteOnly ) ) { |
1364 | mFileString = ""; | 1384 | mFileString = ""; |
1365 | mRetVal = errorR; | 1385 | mRetVal = errorR; |
1366 | qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); | 1386 | qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); |
1367 | deleteSocket(); | 1387 | deleteSocket(); |
1368 | return ; | 1388 | return ; |
1369 | 1389 | ||
1370 | } | 1390 | } |
1371 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1391 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1372 | QTextStream ts ( &file ); | 1392 | QTextStream ts ( &file ); |
1373 | ts.setEncoding( QTextStream::Latin1 ); | 1393 | ts.setEncoding( QTextStream::Latin1 ); |
1374 | ts << mFileString; | 1394 | ts << mFileString; |
1375 | file.close(); | 1395 | file.close(); |
1376 | mFileString = ""; | 1396 | mFileString = ""; |
1377 | mRetVal = successR; | 1397 | mRetVal = successR; |
1378 | mSocket->close(); | 1398 | mSocket->close(); |
1379 | // if state is not idle, deleteSocket(); is called via | 1399 | // if state is not idle, deleteSocket(); is called via |
1380 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1400 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1381 | if ( mSocket->state() == QSocket::Idle ) | 1401 | if ( mSocket->state() == QSocket::Idle ) |
1382 | deleteSocket(); | 1402 | deleteSocket(); |
1383 | } | 1403 | } |
1384 | 1404 | ||
1385 | void KCommandSocket::deleteSocket() | 1405 | void KCommandSocket::deleteSocket() |
1386 | { | 1406 | { |
1387 | //qDebug("KCommandSocket::deleteSocket() "); | 1407 | //qDebug("KCommandSocket::deleteSocket() "); |
1388 | if ( mTimerSocket->isActive () ) { | 1408 | if ( mTimerSocket->isActive () ) { |
1389 | mTimerSocket->stop(); | 1409 | mTimerSocket->stop(); |
1390 | mRetVal = errorTO; | 1410 | mRetVal = errorTO; |
1391 | qDebug("Connection to remote host timed out"); | 1411 | qDebug("Connection to remote host timed out"); |
1392 | if ( mSocket ) { | 1412 | if ( mSocket ) { |
1393 | mSocket->close(); | 1413 | mSocket->close(); |
1394 | //if ( mSocket->state() == QSocket::Idle ) | 1414 | //if ( mSocket->state() == QSocket::Idle ) |
1395 | // deleteSocket(); | 1415 | // deleteSocket(); |
1396 | delete mSocket; | 1416 | delete mSocket; |
1397 | mSocket = 0; | 1417 | mSocket = 0; |
1398 | } | 1418 | } |
1399 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | 1419 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); |
1400 | emit commandFinished( this, mRetVal ); | 1420 | emit commandFinished( this, mRetVal ); |
1401 | return; | 1421 | return; |
1402 | } | 1422 | } |
1403 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | 1423 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); |
1404 | if ( mSocket) | 1424 | if ( mSocket) |
1405 | delete mSocket; | 1425 | delete mSocket; |
1406 | mSocket = 0; | 1426 | mSocket = 0; |
1407 | emit commandFinished( this, mRetVal ); | 1427 | emit commandFinished( this, mRetVal ); |
1408 | } | 1428 | } |
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 2af891b..6da0ee4 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -1,214 +1,216 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
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 | $Id$ | 20 | $Id$ |
21 | */ | 21 | */ |
22 | #ifndef _KSYNCMANAGER_H | 22 | #ifndef _KSYNCMANAGER_H |
23 | #define _KSYNCMANAGER_H | 23 | #define _KSYNCMANAGER_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qsocket.h> | 27 | #include <qsocket.h> |
28 | #include <qdatetime.h> | 28 | #include <qdatetime.h> |
29 | #include <qserversocket.h> | 29 | #include <qserversocket.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | 32 | ||
33 | class QPopupMenu; | 33 | class QPopupMenu; |
34 | class KSyncProfile; | 34 | class KSyncProfile; |
35 | class KPimPrefs; | 35 | class KPimPrefs; |
36 | class QWidget; | 36 | class QWidget; |
37 | class KSyncManager; | 37 | class KSyncManager; |
38 | class KSyncInterface; | 38 | class KSyncInterface; |
39 | class QProgressBar; | 39 | class QProgressBar; |
40 | 40 | ||
41 | 41 | ||
42 | class KServerSocket : public QServerSocket | 42 | class KServerSocket : public QServerSocket |
43 | { | 43 | { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | 45 | ||
46 | public: | 46 | public: |
47 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); | 47 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); |
48 | 48 | ||
49 | void newConnection ( int socket ) ; | 49 | void newConnection ( int socket ) ; |
50 | void setFileName( QString fn ) {mFileName = fn;}; | 50 | void setFileName( QString fn ) {mFileName = fn;}; |
51 | signals: | 51 | signals: |
52 | void file_received( bool ); | 52 | void file_received( bool ); |
53 | void request_file(); | 53 | void request_file(); |
54 | void saveFile(); | 54 | void saveFile(); |
55 | void endConnect(); | 55 | void endConnect(); |
56 | private slots: | 56 | private slots: |
57 | void discardClient(); | 57 | void discardClient(); |
58 | void readClient(); | 58 | void readClient(); |
59 | void readBackFileFromSocket(); | 59 | void readBackFileFromSocket(); |
60 | private : | 60 | private : |
61 | bool blockRC; | 61 | bool blockRC; |
62 | void send_file(); | 62 | void send_file(); |
63 | void get_file(); | 63 | void get_file(); |
64 | void end_connect(); | 64 | void end_connect(); |
65 | QDialog* mSyncActionDialog; | 65 | QDialog* mSyncActionDialog; |
66 | QSocket* mSocket; | 66 | QSocket* mSocket; |
67 | QString mPassWord; | 67 | QString mPassWord; |
68 | QString mFileName; | 68 | QString mFileName; |
69 | QTime piTime; | 69 | QTime piTime; |
70 | QString piFileString; | 70 | QString piFileString; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | class KCommandSocket : public QObject | 73 | class KCommandSocket : public QObject |
74 | { | 74 | { |
75 | Q_OBJECT | 75 | Q_OBJECT |
76 | public: | 76 | public: |
77 | enum state { successR, errorR, successW, errorW, errorTO, quiet }; | 77 | enum state { successR, errorR, successW, errorW, errorTO, quiet }; |
78 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); | 78 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); |
79 | void readFile( QString ); | 79 | void readFile( QString ); |
80 | void writeFile( QString ); | 80 | void writeFile( QString ); |
81 | void sendStop(); | 81 | void sendStop(); |
82 | 82 | ||
83 | signals: | 83 | signals: |
84 | void commandFinished( KCommandSocket*, int ); | 84 | void commandFinished( KCommandSocket*, int ); |
85 | private slots: | 85 | private slots: |
86 | void startReadFileFromSocket(); | 86 | void startReadFileFromSocket(); |
87 | void readFileFromSocket(); | 87 | void readFileFromSocket(); |
88 | void deleteSocket(); | 88 | void deleteSocket(); |
89 | void writeFileToSocket(); | 89 | void writeFileToSocket(); |
90 | private : | 90 | private : |
91 | QSocket* mSocket; | 91 | QSocket* mSocket; |
92 | QString mPassWord; | 92 | QString mPassWord; |
93 | Q_UINT16 mPort; | 93 | Q_UINT16 mPort; |
94 | QString mHost; | 94 | QString mHost; |
95 | QString mFileName; | 95 | QString mFileName; |
96 | QTimer* mTimerSocket; | 96 | QTimer* mTimerSocket; |
97 | int mRetVal; | 97 | int mRetVal; |
98 | QTime mTime; | 98 | QTime mTime; |
99 | QString mFileString; | 99 | QString mFileString; |
100 | bool mFirst; | 100 | bool mFirst; |
101 | }; | 101 | }; |
102 | 102 | ||
103 | 103 | ||
104 | class KSyncManager : public QObject | 104 | class KSyncManager : public QObject |
105 | { | 105 | { |
106 | Q_OBJECT | 106 | Q_OBJECT |
107 | 107 | ||
108 | public: | 108 | public: |
109 | enum TargetApp { | 109 | enum TargetApp { |
110 | KOPI = 0, | 110 | KOPI = 0, |
111 | KAPI = 1, | 111 | KAPI = 1, |
112 | PWMPI = 2 }; | 112 | PWMPI = 2 }; |
113 | 113 | ||
114 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); | 114 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); |
115 | ~KSyncManager() ; | 115 | ~KSyncManager() ; |
116 | 116 | ||
117 | void multiSync( bool askforPrefs ); | 117 | void multiSync( bool askforPrefs ); |
118 | bool blockSave() { return mBlockSaveFlag; } | 118 | bool blockSave() { return mBlockSaveFlag; } |
119 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } | 119 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } |
120 | void setDefaultFileName( QString s) { mDefFileName = s ;} | 120 | void setDefaultFileName( QString s) { mDefFileName = s ;} |
121 | QString defaultFileName() { return mDefFileName ;} | 121 | QString defaultFileName() { return mDefFileName ;} |
122 | QString syncFileName(); | 122 | QString syncFileName(); |
123 | void enableQuick( bool ask = true); | 123 | void enableQuick( bool ask = true); |
124 | 124 | ||
125 | bool syncWithDesktop () { return mSyncWithDesktop;} | ||
125 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } | 126 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } |
126 | QString getCurrentSyncName() { return mCurrentSyncName; } | 127 | QString getCurrentSyncName() { return mCurrentSyncName; } |
127 | 128 | ||
128 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); | 129 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); |
129 | void hideProgressBar(); | 130 | void hideProgressBar(); |
130 | bool isProgressBarCanceled(); | 131 | bool isProgressBarCanceled(); |
131 | 132 | ||
132 | // sync stuff | 133 | // sync stuff |
133 | QString mLocalMachineName; | 134 | QString mLocalMachineName; |
134 | QStringList mExternSyncProfiles; | 135 | QStringList mExternSyncProfiles; |
135 | QStringList mSyncProfileNames; | 136 | QStringList mSyncProfileNames; |
136 | bool mAskForPreferences; | 137 | bool mAskForPreferences; |
137 | bool mShowSyncSummary; | 138 | bool mShowSyncSummary; |
138 | bool mIsKapiFile; | 139 | bool mIsKapiFile; |
139 | bool mWriteBackExistingOnly; | 140 | bool mWriteBackExistingOnly; |
140 | int mSyncAlgoPrefs; | 141 | int mSyncAlgoPrefs; |
141 | bool mWriteBackFile; | 142 | bool mWriteBackFile; |
142 | int mWriteBackInFuture; | 143 | int mWriteBackInFuture; |
143 | QString mPhoneDevice; | 144 | QString mPhoneDevice; |
144 | QString mPhoneConnection; | 145 | QString mPhoneConnection; |
145 | QString mPhoneModel; | 146 | QString mPhoneModel; |
146 | QString mPassWordPiSync; | 147 | QString mPassWordPiSync; |
147 | QString mActiveSyncPort; | 148 | QString mActiveSyncPort; |
148 | QString mActiveSyncIP ; | 149 | QString mActiveSyncIP ; |
149 | static QDateTime mRequestedSyncEvent; | 150 | static QDateTime mRequestedSyncEvent; |
150 | 151 | ||
151 | signals: | 152 | signals: |
152 | void save(); | 153 | void save(); |
153 | void request_file(); | 154 | void request_file(); |
154 | void getFile( bool ); | 155 | void getFile( bool ); |
155 | 156 | ||
156 | public slots: | 157 | public slots: |
157 | void slotSyncMenu( int ); | 158 | void slotSyncMenu( int ); |
158 | void slotClearMenu( int action ); | 159 | void slotClearMenu( int action ); |
159 | void deleteCommandSocket(KCommandSocket*s, int state); | 160 | void deleteCommandSocket(KCommandSocket*s, int state); |
160 | void readFileFromSocket(); | 161 | void readFileFromSocket(); |
161 | void fillSyncMenu(); | 162 | void fillSyncMenu(); |
162 | 163 | ||
163 | private: | 164 | private: |
164 | void syncPi(); | 165 | void syncPi(); |
165 | KServerSocket * mServerSocket; | 166 | KServerSocket * mServerSocket; |
166 | KPimPrefs* mPrefs; | 167 | KPimPrefs* mPrefs; |
167 | QString mDefFileName; | 168 | QString mDefFileName; |
168 | QString mCurrentSyncDevice; | 169 | QString mCurrentSyncDevice; |
169 | QString mCurrentSyncName; | 170 | QString mCurrentSyncName; |
170 | void quickSyncLocalFile(); | 171 | void quickSyncLocalFile(); |
171 | bool syncWithFile( QString fn , bool quick ); | 172 | bool syncWithFile( QString fn , bool quick ); |
172 | void syncLocalFile(); | 173 | void syncLocalFile(); |
173 | void syncPhone(); | 174 | void syncPhone(); |
174 | void syncSharp(); | 175 | void syncSharp(); |
175 | void syncKDE(); | 176 | void syncKDE(); |
176 | bool syncExternalApplication(QString); | 177 | bool syncExternalApplication(QString); |
177 | int mCurrentSyncProfile ; | 178 | int mCurrentSyncProfile ; |
178 | void syncRemote( KSyncProfile* prof, bool ask = true); | 179 | void syncRemote( KSyncProfile* prof, bool ask = true); |
179 | bool edit_sync_options(); | 180 | bool edit_sync_options(); |
180 | bool edit_pisync_options(); | 181 | bool edit_pisync_options(); |
181 | int ringSync(); | 182 | int ringSync(); |
182 | QString getPassword( ); | 183 | QString getPassword( ); |
183 | bool mPisyncFinished; | 184 | bool mPisyncFinished; |
184 | bool mBlockSaveFlag; | 185 | bool mBlockSaveFlag; |
185 | QWidget* mParent; | 186 | QWidget* mParent; |
186 | KSyncInterface* mImplementation; | 187 | KSyncInterface* mImplementation; |
187 | TargetApp mTargetApp; | 188 | TargetApp mTargetApp; |
188 | QPopupMenu* mSyncMenu; | 189 | QPopupMenu* mSyncMenu; |
189 | QProgressBar* bar; | 190 | QProgressBar* bar; |
191 | bool mSyncWithDesktop; | ||
190 | 192 | ||
191 | private slots: | 193 | private slots: |
192 | void confSync(); | 194 | void confSync(); |
193 | 195 | ||
194 | 196 | ||
195 | }; | 197 | }; |
196 | 198 | ||
197 | 199 | ||
198 | class KSyncInterface | 200 | class KSyncInterface |
199 | { | 201 | { |
200 | public : | 202 | public : |
201 | virtual void removeSyncInfo( QString syncProfile) = 0; | 203 | virtual void removeSyncInfo( QString syncProfile) = 0; |
202 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; | 204 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; |
203 | virtual bool syncExternal(KSyncManager* manager, QString resource) | 205 | virtual bool syncExternal(KSyncManager* manager, QString resource) |
204 | { | 206 | { |
205 | // empty implementation, because some syncable applications do not | 207 | // empty implementation, because some syncable applications do not |
206 | // have an external(sharpdtm) syncmode, like pwmanager. | 208 | // have an external(sharpdtm) syncmode, like pwmanager. |
207 | return false; | 209 | return false; |
208 | } | 210 | } |
209 | 211 | ||
210 | 212 | ||
211 | }; | 213 | }; |
212 | 214 | ||
213 | 215 | ||
214 | #endif | 216 | #endif |