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