-rw-r--r-- | core/pim/addressbook/abview.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp index 3af7663..0f4bd5f 100644 --- a/core/pim/addressbook/abview.cpp +++ b/core/pim/addressbook/abview.cpp | |||
@@ -222,238 +222,238 @@ void AbView::setShowByLetter( char c ) | |||
222 | query.setLastName( QString("%1*").arg(c) ); | 222 | query.setLastName( QString("%1*").arg(c) ); |
223 | m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards ); | 223 | m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards ); |
224 | clearForCategory(); | 224 | clearForCategory(); |
225 | m_curr_Contact = 0; | 225 | m_curr_Contact = 0; |
226 | } | 226 | } |
227 | updateView(); | 227 | updateView(); |
228 | } | 228 | } |
229 | 229 | ||
230 | void AbView::setListOrder( const QValueList<int>& ordered ) | 230 | void AbView::setListOrder( const QValueList<int>& ordered ) |
231 | { | 231 | { |
232 | m_orderedFields = ordered; | 232 | m_orderedFields = ordered; |
233 | updateView(); | 233 | updateView(); |
234 | } | 234 | } |
235 | 235 | ||
236 | 236 | ||
237 | QString AbView::showCategory() const | 237 | QString AbView::showCategory() const |
238 | { | 238 | { |
239 | return mCat.label( "Contacts", m_curr_category ); | 239 | return mCat.label( "Contacts", m_curr_category ); |
240 | } | 240 | } |
241 | 241 | ||
242 | void AbView::showPersonal( bool personal ) | 242 | void AbView::showPersonal( bool personal ) |
243 | { | 243 | { |
244 | qWarning ("void AbView::showPersonal( %d )", personal); | 244 | qWarning ("void AbView::showPersonal( %d )", personal); |
245 | 245 | ||
246 | if ( personal ){ | 246 | if ( personal ){ |
247 | 247 | ||
248 | if ( m_inPersonal ) | 248 | if ( m_inPersonal ) |
249 | return; | 249 | return; |
250 | 250 | ||
251 | // Now switch to vCard Backend and load data. | 251 | // Now switch to vCard Backend and load data. |
252 | // The current default backend will be stored | 252 | // The current default backend will be stored |
253 | // to avoid unneeded load/stores. | 253 | // to avoid unneeded load/stores. |
254 | m_storedDB = m_contactdb; | 254 | m_storedDB = m_contactdb; |
255 | 255 | ||
256 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 256 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
257 | addressbookPersonalVCardName() ); | 257 | addressbookPersonalVCardName() ); |
258 | m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 258 | m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
259 | 259 | ||
260 | m_inPersonal = true; | 260 | m_inPersonal = true; |
261 | m_curr_View = CardView; | 261 | m_curr_View = CardView; |
262 | 262 | ||
263 | }else{ | 263 | }else{ |
264 | 264 | ||
265 | if ( !m_inPersonal ) | 265 | if ( !m_inPersonal ) |
266 | return; | 266 | return; |
267 | 267 | ||
268 | // Remove vCard Backend and restore default | 268 | // Remove vCard Backend and restore default |
269 | m_contactdb->save(); | 269 | m_contactdb->save(); |
270 | delete m_contactdb; | 270 | delete m_contactdb; |
271 | 271 | ||
272 | m_contactdb = m_storedDB; | 272 | m_contactdb = m_storedDB; |
273 | m_storedDB = 0l; | 273 | m_storedDB = 0l; |
274 | 274 | ||
275 | m_curr_View = TableView; | 275 | m_curr_View = TableView; |
276 | m_inPersonal = false; | 276 | m_inPersonal = false; |
277 | 277 | ||
278 | } | 278 | } |
279 | load(); | 279 | load(); |
280 | } | 280 | } |
281 | 281 | ||
282 | QStringList AbView::categories() | 282 | QStringList AbView::categories() |
283 | { | 283 | { |
284 | mCat.load( categoryFileName() ); | 284 | mCat.load( categoryFileName() ); |
285 | QStringList categoryList = mCat.labels( "Contacts" ); | 285 | QStringList categoryList = mCat.labels( "Contacts" ); |
286 | return categoryList; | 286 | return categoryList; |
287 | } | 287 | } |
288 | 288 | ||
289 | // BEGIN: Slots | 289 | // BEGIN: Slots |
290 | void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, | 290 | void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, |
291 | bool , QString cat = QString::null ) | 291 | bool , QString cat = QString::null ) |
292 | { | 292 | { |
293 | qWarning( "void AbView::slotDoFind" ); | 293 | qWarning( "void AbView::slotDoFind" ); |
294 | 294 | ||
295 | // We reloading the data: Deselect Letterpicker | 295 | // We reloading the data: Deselect Letterpicker |
296 | emit signalClearLetterPicker(); | 296 | emit signalClearLetterPicker(); |
297 | 297 | ||
298 | // Use the current Category if nothing else selected | 298 | // Use the current Category if nothing else selected |
299 | int category = 0; | 299 | int category = 0; |
300 | 300 | ||
301 | if ( cat.isEmpty() ) | 301 | if ( cat.isEmpty() ) |
302 | category = m_curr_category; | 302 | category = m_curr_category; |
303 | else{ | 303 | else{ |
304 | category = mCat.id("Contacts", cat ); | 304 | category = mCat.id("Contacts", cat ); |
305 | } | 305 | } |
306 | 306 | ||
307 | qWarning ("Find in Category %d", category); | 307 | qWarning ("Find in Category %d", category); |
308 | 308 | ||
309 | QRegExp r( str ); | 309 | QRegExp r( str ); |
310 | r.setCaseSensitive( caseSensitive ); | 310 | r.setCaseSensitive( caseSensitive ); |
311 | r.setWildcard( !useRegExp ); | 311 | r.setWildcard( !useRegExp ); |
312 | 312 | ||
313 | // Get all matching entries out of the database | 313 | // Get all matching entries out of the database |
314 | m_list = m_contactdb->matchRegexp( r ); | 314 | m_list = m_contactdb->matchRegexp( r ); |
315 | 315 | ||
316 | qWarning( "found: %d", m_list.count() ); | 316 | qWarning( "found: %d", m_list.count() ); |
317 | if ( m_list.count() == 0 ){ | 317 | if ( m_list.count() == 0 ){ |
318 | emit signalNotFound(); | 318 | emit signalNotFound(); |
319 | return; | 319 | return; |
320 | } | 320 | } |
321 | 321 | ||
322 | // Now remove all contacts with wrong category (if any selected) | 322 | // Now remove all contacts with wrong category (if any selected) |
323 | // This algorithm is a litte bit ineffective, but | 323 | // This algorithm is a litte bit ineffective, but |
324 | // we will not have a lot of matching entries.. | 324 | // we will not have a lot of matching entries.. |
325 | clearForCategory(); | 325 | clearForCategory(); |
326 | 326 | ||
327 | // Now show all found entries | 327 | // Now show all found entries |
328 | updateView(); | 328 | updateView(); |
329 | } | 329 | } |
330 | 330 | ||
331 | void AbView::offSearch() | 331 | void AbView::offSearch() |
332 | { | 332 | { |
333 | m_inSearch = false; | 333 | m_inSearch = false; |
334 | 334 | ||
335 | load(); | 335 | load(); |
336 | } | 336 | } |
337 | 337 | ||
338 | void AbView::slotSwitch(){ | 338 | void AbView::slotSwitch(){ |
339 | qWarning("AbView::slotSwitch()"); | 339 | qWarning("AbView::slotSwitch()"); |
340 | 340 | ||
341 | m_prev_View = m_curr_View; | 341 | m_prev_View = m_curr_View; |
342 | switch ( (int) m_curr_View ){ | 342 | switch ( (int) m_curr_View ){ |
343 | case TableView: | 343 | case TableView: |
344 | qWarning("Switching to CardView"); | 344 | qWarning("Switching to CardView"); |
345 | m_curr_View = CardView; | 345 | m_curr_View = CardView; |
346 | break; | 346 | break; |
347 | case CardView: | 347 | case CardView: |
348 | qWarning("Switching to TableView"); | 348 | qWarning("Switching to TableView"); |
349 | m_curr_View = TableView; | 349 | m_curr_View = TableView; |
350 | break; | 350 | break; |
351 | } | 351 | } |
352 | updateView(); | 352 | updateView(); |
353 | 353 | ||
354 | } | 354 | } |
355 | 355 | ||
356 | // END: Slots | 356 | // END: Slots |
357 | 357 | ||
358 | void AbView::clearForCategory() | 358 | void AbView::clearForCategory() |
359 | { | 359 | { |
360 | OContactAccess::List::Iterator it; | 360 | OContactAccess::List::Iterator it; |
361 | // Now remove all contacts with wrong category if any category selected | 361 | // Now remove all contacts with wrong category if any category selected |
362 | 362 | ||
363 | OContactAccess::List allList = m_list; | 363 | OContactAccess::List allList = m_list; |
364 | if ( m_curr_category != -1 ){ | 364 | if ( m_curr_category != -1 ){ |
365 | for ( it = allList.begin(); it != allList.end(); ++it ){ | 365 | for ( it = allList.begin(); it != allList.end(); ++it ){ |
366 | if ( !contactCompare( *it, m_curr_category ) ){ | 366 | if ( !contactCompare( *it, m_curr_category ) ){ |
367 | qWarning("Removing %d", (*it).uid()); | 367 | qWarning("Removing %d", (*it).uid()); |
368 | m_list.remove( (*it).uid() ); | 368 | m_list.remove( (*it).uid() ); |
369 | } | 369 | } |
370 | } | 370 | } |
371 | } | 371 | } |
372 | 372 | ||
373 | } | 373 | } |
374 | 374 | ||
375 | bool AbView::contactCompare( const OContact &cnt, int category ) | 375 | bool AbView::contactCompare( const OContact &cnt, int category ) |
376 | { | 376 | { |
377 | qWarning ("bool AbView::contactCompare( const OContact &cnt, %d )", category); | 377 | qWarning ("bool AbView::contactCompare( const OContact &cnt, %d )", category); |
378 | 378 | ||
379 | bool returnMe; | 379 | bool returnMe; |
380 | QArray<int> cats; | 380 | QArray<int> cats; |
381 | cats = cnt.categories(); | 381 | cats = cnt.categories(); |
382 | 382 | ||
383 | qWarning ("Number of categories: %d", cats.count() ); | 383 | qWarning ("Number of categories: %d", cats.count() ); |
384 | 384 | ||
385 | returnMe = false; | 385 | returnMe = false; |
386 | if ( cats.count() == 0 && category == 0 ) | 386 | if ( cats.count() == 0 && category == 0 ) |
387 | // Contacts with no category will just shown on "All" and "Unfiled" | 387 | // Contacts with no category will just shown on "All" and "Unfiled" |
388 | returnMe = true; | 388 | returnMe = true; |
389 | else { | 389 | else { |
390 | int i; | 390 | int i; |
391 | for ( i = 0; i < int(cats.count()); i++ ) { | 391 | for ( i = 0; i < int(cats.count()); i++ ) { |
392 | qWarning("Comparing %d with %d",cats[i],category ); | 392 | qWarning("Comparing %d with %d",cats[i],category ); |
393 | if ( cats[i] == category ) { | 393 | if ( cats[i] == category ) { |
394 | returnMe = true; | 394 | returnMe = true; |
395 | break; | 395 | break; |
396 | } | 396 | } |
397 | } | 397 | } |
398 | } | 398 | } |
399 | qWarning ("Return: %d", returnMe); | 399 | qWarning ("Return: %d", returnMe); |
400 | return returnMe; | 400 | return returnMe; |
401 | } | 401 | } |
402 | 402 | ||
403 | // In Some rare cases we have to update all lists.. | 403 | // In Some rare cases we have to update all lists.. |
404 | void AbView::updateListinViews() | 404 | void AbView::updateListinViews() |
405 | { | 405 | { |
406 | m_abTable -> setContacts( m_list ); | 406 | m_abTable -> setContacts( m_list ); |
407 | m_ablabel -> setContacts( m_list ); | 407 | m_ablabel -> setContacts( m_list ); |
408 | } | 408 | } |
409 | 409 | ||
410 | void AbView::updateView() | 410 | void AbView::updateView() |
411 | { | 411 | { |
412 | qWarning("AbView::updateView()"); | 412 | qWarning("AbView::updateView()"); |
413 | 413 | ||
414 | // Feed all views with new lists | ||
415 | updateListinViews(); | ||
416 | |||
417 | if ( m_viewStack -> visibleWidget() ){ | 414 | if ( m_viewStack -> visibleWidget() ){ |
418 | m_viewStack -> visibleWidget() -> clearFocus(); | 415 | m_viewStack -> visibleWidget() -> clearFocus(); |
419 | } | 416 | } |
420 | 417 | ||
421 | // If we switching the view, we have to store some information | 418 | // If we switching the view, we have to store some information |
422 | if ( m_list.count() ){ | 419 | if ( m_list.count() ){ |
423 | switch ( (int) m_prev_View ) { | 420 | switch ( (int) m_prev_View ) { |
424 | case TableView: | 421 | case TableView: |
425 | m_curr_Contact = m_abTable -> currentEntry_UID(); | 422 | m_curr_Contact = m_abTable -> currentEntry_UID(); |
426 | break; | 423 | break; |
427 | case CardView: | 424 | case CardView: |
428 | m_curr_Contact = m_ablabel -> currentEntry_UID(); | 425 | m_curr_Contact = m_ablabel -> currentEntry_UID(); |
429 | break; | 426 | break; |
430 | } | 427 | } |
431 | }else | 428 | }else |
432 | m_curr_Contact = 0; | 429 | m_curr_Contact = 0; |
433 | 430 | ||
431 | // Feed all views with new lists | ||
432 | updateListinViews(); | ||
433 | |||
434 | // Inform the world that the view is changed | 434 | // Inform the world that the view is changed |
435 | if ( m_curr_View != m_prev_View ) | 435 | if ( m_curr_View != m_prev_View ) |
436 | emit signalViewSwitched ( (int) m_curr_View ); | 436 | emit signalViewSwitched ( (int) m_curr_View ); |
437 | 437 | ||
438 | m_prev_View = m_curr_View; | 438 | m_prev_View = m_curr_View; |
439 | 439 | ||
440 | // Switch to new View | 440 | // Switch to new View |
441 | switch ( (int) m_curr_View ) { | 441 | switch ( (int) m_curr_View ) { |
442 | case TableView: | 442 | case TableView: |
443 | m_abTable -> setChoiceSelection( m_orderedFields ); | 443 | m_abTable -> setChoiceSelection( m_orderedFields ); |
444 | if ( m_curr_Contact != 0 ) | 444 | if ( m_curr_Contact != 0 ) |
445 | m_abTable -> selectContact ( m_curr_Contact ); | 445 | m_abTable -> selectContact ( m_curr_Contact ); |
446 | m_abTable -> setFocus(); | 446 | m_abTable -> setFocus(); |
447 | break; | 447 | break; |
448 | case CardView: | 448 | case CardView: |
449 | if ( m_curr_Contact != 0 ) | 449 | if ( m_curr_Contact != 0 ) |
450 | m_ablabel -> selectContact( m_curr_Contact ); | 450 | m_ablabel -> selectContact( m_curr_Contact ); |
451 | m_ablabel -> setFocus(); | 451 | m_ablabel -> setFocus(); |
452 | break; | 452 | break; |
453 | } | 453 | } |
454 | 454 | ||
455 | // Raise the current View | 455 | // Raise the current View |
456 | m_viewStack -> raiseWidget( m_curr_View ); | 456 | m_viewStack -> raiseWidget( m_curr_View ); |
457 | } | 457 | } |
458 | 458 | ||
459 | 459 | ||