summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views/kaddressbookcardview.cpp
Unidiff
Diffstat (limited to 'kaddressbook/views/kaddressbookcardview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp
index 9c35fd6..ca21016 100644
--- a/kaddressbook/views/kaddressbookcardview.cpp
+++ b/kaddressbook/views/kaddressbookcardview.cpp
@@ -222,211 +222,211 @@ void KAddressBookCardView::scrollDOWN()
222void KAddressBookCardView::readConfig(KConfig *config) 222void KAddressBookCardView::readConfig(KConfig *config)
223{ 223{
224 KAddressBookView::readConfig(config); 224 KAddressBookView::readConfig(config);
225 225
226 // costum colors? 226 // costum colors?
227 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 227 if ( config->readBoolEntry( "EnableCustomColors", false ) )
228 { 228 {
229 QPalette p( mCardView->palette() ); 229 QPalette p( mCardView->palette() );
230 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 230 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
231 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 231 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
232 c = p.color(QPalette::Normal, QColorGroup::Text ); 232 c = p.color(QPalette::Normal, QColorGroup::Text );
233 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 233 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
234 c = p.color(QPalette::Normal, QColorGroup::Button ); 234 c = p.color(QPalette::Normal, QColorGroup::Button );
235 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 235 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
236 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 236 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
237 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 237 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
238 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 238 c = p.color(QPalette::Normal, QColorGroup::Highlight );
239 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 239 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
240 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 240 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
241 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 241 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
242 mCardView->viewport()->setPalette( p ); 242 mCardView->viewport()->setPalette( p );
243 } 243 }
244 else 244 else
245 { 245 {
246 // needed if turned off during a session. 246 // needed if turned off during a session.
247 mCardView->viewport()->setPalette( mCardView->palette() ); 247 mCardView->viewport()->setPalette( mCardView->palette() );
248 } 248 }
249 249
250 //custom fonts? 250 //custom fonts?
251 QFont f( font() ); 251 QFont f( font() );
252 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 252 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
253 { 253 {
254 mCardView->setFont( config->readFontEntry( "TextFont", &f) ); 254 mCardView->setFont( config->readFontEntry( "TextFont", &f) );
255 f.setBold( true ); 255 f.setBold( true );
256 mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 256 mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
257 } 257 }
258 else 258 else
259 { 259 {
260 mCardView->setFont( f ); 260 mCardView->setFont( f );
261 f.setBold( true ); 261 f.setBold( true );
262 mCardView->setHeaderFont( f ); 262 mCardView->setHeaderFont( f );
263 } 263 }
264 264
265 mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); 265 mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true));
266 mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", 266 mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators",
267 true)); 267 true));
268 mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); 268 mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false));
269 mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); 269 mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false);
270 270
271 mCardView->setShowEmptyFields( mShowEmptyFields ); 271 mCardView->setShowEmptyFields( mShowEmptyFields );
272 272
273 mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); 273 mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) );
274 mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); 274 mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) );
275 mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); 275 mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) );
276 mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); 276 mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) );
277 277
278#if 0 278#if 0
279 // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven 279 // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven
280 disconnect(mCardView, SIGNAL(executed(CardViewItem *)), 280 disconnect(mCardView, SIGNAL(executed(CardViewItem *)),
281 this, SLOT(addresseeExecuted(CardViewItem *))); 281 this, SLOT(addresseeExecuted(CardViewItem *)));
282 282
283 if (KABPrefs::instance()->mHonorSingleClick) 283 if (KABPrefs::instance()->mHonorSingleClick)
284 connect(mCardView, SIGNAL(executed(CardViewItem *)), 284 connect(mCardView, SIGNAL(executed(CardViewItem *)),
285 this, SLOT(addresseeExecuted(CardViewItem *))); 285 this, SLOT(addresseeExecuted(CardViewItem *)));
286 else 286 else
287 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), 287 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)),
288 this, SLOT(addresseeExecuted(CardViewItem *))); 288 this, SLOT(addresseeExecuted(CardViewItem *)));
289#endif 289#endif
290 290
291 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), 291 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)),
292 this, SLOT(addresseeExecuted(CardViewItem *))); 292 this, SLOT(addresseeExecuted(CardViewItem *)));
293} 293}
294 294
295void KAddressBookCardView::writeConfig( KConfig *config ) 295void KAddressBookCardView::writeConfig( KConfig *config )
296{ 296{
297 config->writeEntry( "ItemWidth", mCardView->itemWidth() ); 297 config->writeEntry( "ItemWidth", mCardView->itemWidth() );
298 KAddressBookView::writeConfig( config ); 298 KAddressBookView::writeConfig( config );
299} 299}
300void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) 300void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field )
301{ 301{
302 mCardView->clear(); 302 mCardView->clear();
303 if ( s.isEmpty() || s == "*" ) { 303 if ( s.isEmpty() || s == "*" ) {
304 refresh(); 304 refresh();
305 return; 305 return;
306 } 306 }
307 QRegExp re = getRegExp( s ); 307 QRegExp re = getRegExp( s );
308 if (!re.isValid()) 308 if (!re.isValid())
309 return; 309 return;
310 mCardView->viewport()->setUpdatesEnabled( false ); 310 mCardView->viewport()->setUpdatesEnabled( false );
311 KABC::Addressee::List addresseeList = addressees(); 311 KABC::Addressee::List addresseeList = addressees();
312 KABC::Addressee::List::Iterator it; 312 KABC::Addressee::List::Iterator it;
313 if ( field ) { 313 if ( field ) {
314 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 314 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
315 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 315 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
316 continue; 316 continue;
317#if QT_VERSION >= 0x030000 317#if QT_VERSION >= 0x030000
318 if (re.search(field->value( *it ).lower()) != -1) 318 if (re.search(field->value( *it ).lower()) == 0)
319#else 319#else
320 if (re.match(field->value( *it ).lower()) != -1) 320 if (re.match(field->value( *it ).lower()) == 0)
321#endif 321#endif
322 new AddresseeCardViewItem(fields(), mShowEmptyFields, 322 new AddresseeCardViewItem(fields(), mShowEmptyFields,
323 addressBook(), *it, mCardView); 323 addressBook(), *it, mCardView);
324 324
325 } 325 }
326 } else { 326 } else {
327 KABC::Field::List fieldList = allFields(); 327 KABC::Field::List fieldList = allFields();
328 KABC::Field::List::ConstIterator fieldIt; 328 KABC::Field::List::ConstIterator fieldIt;
329 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 329 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
330 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 330 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
331 continue; 331 continue;
332 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 332 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
333#if QT_VERSION >= 0x030000 333#if QT_VERSION >= 0x030000
334 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 334 if (re.search((*fieldIt)->value( *it ).lower()) == 0)
335#else 335#else
336 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 336 if (re.match((*fieldIt)->value( *it ).lower()) == 0)
337#endif 337#endif
338 { 338 {
339 new AddresseeCardViewItem(fields(), mShowEmptyFields, 339 new AddresseeCardViewItem(fields(), mShowEmptyFields,
340 addressBook(), *it, mCardView); 340 addressBook(), *it, mCardView);
341 break; 341 break;
342 } 342 }
343 } 343 }
344 } 344 }
345 } 345 }
346 mCardView->viewport()->setUpdatesEnabled( true ); 346 mCardView->viewport()->setUpdatesEnabled( true );
347 mCardView->viewport()->update(); 347 mCardView->viewport()->update();
348 if ( mCardView->firstItem() ) { 348 if ( mCardView->firstItem() ) {
349 mCardView->setCurrentItem ( mCardView->firstItem() ); 349 mCardView->setCurrentItem ( mCardView->firstItem() );
350 mCardView->setSelected ( mCardView->firstItem() , true ); 350 mCardView->setSelected ( mCardView->firstItem() , true );
351 } 351 }
352 else 352 else
353 emit selected(QString::null); 353 emit selected(QString::null);
354} 354}
355QStringList KAddressBookCardView::selectedUids() 355QStringList KAddressBookCardView::selectedUids()
356{ 356{
357 QStringList uidList; 357 QStringList uidList;
358 CardViewItem *item; 358 CardViewItem *item;
359 AddresseeCardViewItem *aItem; 359 AddresseeCardViewItem *aItem;
360 360
361 for (item = mCardView->firstItem(); item; item = item->nextItem()) 361 for (item = mCardView->firstItem(); item; item = item->nextItem())
362 { 362 {
363 if (item->isSelected()) 363 if (item->isSelected())
364 { 364 {
365#ifndef KAB_EMBEDDED 365#ifndef KAB_EMBEDDED
366 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 366 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
367#else //KAB_EMBEDDED 367#else //KAB_EMBEDDED
368 aItem = (AddresseeCardViewItem*)(item); 368 aItem = (AddresseeCardViewItem*)(item);
369#endif //KAB_EMBEDDED 369#endif //KAB_EMBEDDED
370 if (aItem) 370 if (aItem)
371 uidList << aItem->addressee().uid(); 371 uidList << aItem->addressee().uid();
372 } 372 }
373 } 373 }
374 374
375 return uidList; 375 return uidList;
376} 376}
377 377
378void KAddressBookCardView::refresh(QString uid) 378void KAddressBookCardView::refresh(QString uid)
379{ 379{
380 CardViewItem *item; 380 CardViewItem *item;
381 AddresseeCardViewItem *aItem; 381 AddresseeCardViewItem *aItem;
382 382
383 if (uid.isNull()) 383 if (uid.isNull())
384 { 384 {
385 // Rebuild the view 385 // Rebuild the view
386 mCardView->viewport()->setUpdatesEnabled( false ); 386 mCardView->viewport()->setUpdatesEnabled( false );
387 mCardView->clear(); 387 mCardView->clear();
388 388
389 KABC::Addressee::List addresseeList = addressees(); 389 KABC::Addressee::List addresseeList = addressees();
390 KABC::Addressee::List::Iterator iter; 390 KABC::Addressee::List::Iterator iter;
391 for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) 391 for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter)
392 { 392 {
393 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) 393 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") )
394 continue; 394 continue;
395 aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, 395 aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields,
396 addressBook(), *iter, mCardView); 396 addressBook(), *iter, mCardView);
397 } 397 }
398 mCardView->viewport()->setUpdatesEnabled( true ); 398 mCardView->viewport()->setUpdatesEnabled( true );
399 mCardView->viewport()->update(); 399 mCardView->viewport()->update();
400 400
401 // by default nothing is selected 401 // by default nothing is selected
402 emit selected(QString::null); 402 emit selected(QString::null);
403 } 403 }
404 else 404 else
405 { 405 {
406 // Try to find the one to refresh 406 // Try to find the one to refresh
407 bool found = false; 407 bool found = false;
408 for (item = mCardView->firstItem(); item && !found; 408 for (item = mCardView->firstItem(); item && !found;
409 item = item->nextItem()) 409 item = item->nextItem())
410 { 410 {
411#ifndef KAB_EMBEDDED 411#ifndef KAB_EMBEDDED
412 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 412 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
413#else //KAB_EMBEDDED 413#else //KAB_EMBEDDED
414 aItem = (AddresseeCardViewItem*)(item); 414 aItem = (AddresseeCardViewItem*)(item);
415#endif //KAB_EMBEDDED 415#endif //KAB_EMBEDDED
416 416
417 if ((aItem) && (aItem->addressee().uid() == uid)) 417 if ((aItem) && (aItem->addressee().uid() == uid))
418 { 418 {
419 aItem->refresh(); 419 aItem->refresh();
420 found = true; 420 found = true;
421 } 421 }
422 } 422 }
423 } 423 }
424} 424}
425 425
426void KAddressBookCardView::setSelected(QString uid, bool selected) 426void KAddressBookCardView::setSelected(QString uid, bool selected)
427{ 427{
428 CardViewItem *item; 428 CardViewItem *item;
429 AddresseeCardViewItem *aItem; 429 AddresseeCardViewItem *aItem;
430 430
431 if (uid.isNull()) 431 if (uid.isNull())
432 { 432 {