summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views/kaddressbooktableview.cpp
Unidiff
Diffstat (limited to 'kaddressbook/views/kaddressbooktableview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index 1dc9198..fbfddba 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -184,192 +184,194 @@ void KAddressBookTableView::readConfig(KConfig *config)
184 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 184 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
185 c = p.color(QPalette::Normal, QColorGroup::Text ); 185 c = p.color(QPalette::Normal, QColorGroup::Text );
186 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 186 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
187 c = p.color(QPalette::Normal, QColorGroup::Button ); 187 c = p.color(QPalette::Normal, QColorGroup::Button );
188 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 188 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
189 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 189 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
190 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 190 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
191 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 191 c = p.color(QPalette::Normal, QColorGroup::Highlight );
192 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 192 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
193 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 193 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
194 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 194 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
195#ifndef KAB_EMBEDDED 195#ifndef KAB_EMBEDDED
196 c = KGlobalSettings::alternateBackgroundColor(); 196 c = KGlobalSettings::alternateBackgroundColor();
197#else //KAB_EMBEDDED 197#else //KAB_EMBEDDED
198 c = QColor(240, 240, 240); 198 c = QColor(240, 240, 240);
199#endif //KAB_EMBEDDED 199#endif //KAB_EMBEDDED
200 c = config->readColorEntry ("AlternatingBackgroundColor", &c); 200 c = config->readColorEntry ("AlternatingBackgroundColor", &c);
201 mListView->setAlternateColor(c); 201 mListView->setAlternateColor(c);
202 202
203 203
204 //US mListView->viewport()->setPalette( p ); 204 //US mListView->viewport()->setPalette( p );
205 mListView->setPalette( p ); 205 mListView->setPalette( p );
206 } 206 }
207 else 207 else
208 { 208 {
209 // needed if turned off during a session. 209 // needed if turned off during a session.
210 //US mListView->viewport()->setPalette( mListView->palette() ); 210 //US mListView->viewport()->setPalette( mListView->palette() );
211 mListView->setPalette( mListView->palette() ); 211 mListView->setPalette( mListView->palette() );
212 } 212 }
213 213
214 //custom fonts? 214 //custom fonts?
215 QFont f( font() ); 215 QFont f( font() );
216 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 216 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
217 { 217 {
218 mListView->setFont( config->readFontEntry( "TextFont", &f) ); 218 mListView->setFont( config->readFontEntry( "TextFont", &f) );
219 f.setBold( true ); 219 f.setBold( true );
220 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 220 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
221 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); 221 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) );
222 } 222 }
223 else 223 else
224 { 224 {
225 mListView->setFont( f ); 225 mListView->setFont( f );
226 f.setBold( true ); 226 f.setBold( true );
227 //US mListView->setHeaderFont( f ); 227 //US mListView->setHeaderFont( f );
228 mListView->header()->setFont( f ); 228 mListView->header()->setFont( f );
229 } 229 }
230 230
231 231
232 232
233 233
234 234
235 // Set the list view options 235 // Set the list view options
236 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", 236 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground",
237 true)); 237 true));
238 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); 238 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false));
239 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); 239 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true));
240 240
241 if (config->readBoolEntry("Background", false)) 241 if (config->readBoolEntry("Background", false))
242 mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); 242 mListView->setBackgroundPixmap(config->readEntry("BackgroundName"));
243 243
244 // Restore the layout of the listview 244 // Restore the layout of the listview
245 mListView->restoreLayout(config, config->group()); 245 mListView->restoreLayout(config, config->group());
246} 246}
247 247
248void KAddressBookTableView::refresh(QString uid) 248void KAddressBookTableView::refresh(QString uid)
249{ 249{
250 // For now just repopulate. In reality this method should 250 // For now just repopulate. In reality this method should
251 // check the value of uid, and if valid iterate through 251 // check the value of uid, and if valid iterate through
252 // the listview to find the entry, then tell it to refresh. 252 // the listview to find the entry, then tell it to refresh.
253 253
254 if (uid.isNull()) { 254 if (uid.isNull()) {
255 // Clear the list view 255 // Clear the list view
256 QString currentUID, nextUID; 256 QString currentUID, nextUID;
257#ifndef KAB_EMBEDDED 257#ifndef KAB_EMBEDDED
258 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); 258 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() );
259#else //KAB_EMBEDDED 259#else //KAB_EMBEDDED
260 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); 260 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() );
261#endif //KAB_EMBEDDED 261#endif //KAB_EMBEDDED
262 262
263 if ( currentItem ) { 263 if ( currentItem ) {
264#ifndef KAB_EMBEDDED 264#ifndef KAB_EMBEDDED
265 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); 265 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() );
266#else //KAB_EMBEDDED 266#else //KAB_EMBEDDED
267 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); 267 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() );
268#endif //KAB_EMBEDDED 268#endif //KAB_EMBEDDED
269 if ( nextItem ) 269 if ( nextItem )
270 nextUID = nextItem->addressee().uid(); 270 nextUID = nextItem->addressee().uid();
271 currentUID = currentItem->addressee().uid(); 271 currentUID = currentItem->addressee().uid();
272 } 272 }
273 273
274 mListView->clear(); 274 mListView->clear();
275 275
276 currentItem = 0; 276 currentItem = 0;
277 KABC::Addressee::List addresseeList = addressees(); 277 KABC::Addressee::List addresseeList = addressees();
278 KABC::Addressee::List::Iterator it; 278 KABC::Addressee::List::Iterator it;
279 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 279 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
280 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
281 continue;
280 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 282 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
281 if ( (*it).uid() == currentUID ) 283 if ( (*it).uid() == currentUID )
282 currentItem = item; 284 currentItem = item;
283 else if ( (*it).uid() == nextUID && !currentItem ) 285 else if ( (*it).uid() == nextUID && !currentItem )
284 currentItem = item; 286 currentItem = item;
285 } 287 }
286 288
287 // Sometimes the background pixmap gets messed up when we add lots 289 // Sometimes the background pixmap gets messed up when we add lots
288 // of items. 290 // of items.
289 mListView->repaint(); 291 mListView->repaint();
290 292
291 if ( currentItem ) { 293 if ( currentItem ) {
292 mListView->setCurrentItem( currentItem ); 294 mListView->setCurrentItem( currentItem );
293 mListView->ensureItemVisible( currentItem ); 295 mListView->ensureItemVisible( currentItem );
294 } 296 }
295 } else { 297 } else {
296 // Only need to update on entry. Iterate through and try to find it 298 // Only need to update on entry. Iterate through and try to find it
297 ContactListViewItem *ceItem; 299 ContactListViewItem *ceItem;
298 QListViewItemIterator it( mListView ); 300 QListViewItemIterator it( mListView );
299 while ( it.current() ) { 301 while ( it.current() ) {
300#ifndef KAB_EMBEDDED 302#ifndef KAB_EMBEDDED
301 ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); 303 ceItem = dynamic_cast<ContactListViewItem*>( it.current() );
302#else //KAB_EMBEDDED 304#else //KAB_EMBEDDED
303 ceItem = (ContactListViewItem*)( it.current() ); 305 ceItem = (ContactListViewItem*)( it.current() );
304#endif //KAB_EMBEDDED 306#endif //KAB_EMBEDDED
305 307
306 if ( ceItem && ceItem->addressee().uid() == uid ) { 308 if ( ceItem && ceItem->addressee().uid() == uid ) {
307 ceItem->refresh(); 309 ceItem->refresh();
308 return; 310 return;
309 } 311 }
310 ++it; 312 ++it;
311 } 313 }
312 314
313 refresh( QString::null ); 315 refresh( QString::null );
314 } 316 }
315} 317}
316 318
317QStringList KAddressBookTableView::selectedUids() 319QStringList KAddressBookTableView::selectedUids()
318{ 320{
319 QStringList uidList; 321 QStringList uidList;
320 QListViewItem *item; 322 QListViewItem *item;
321 ContactListViewItem *ceItem; 323 ContactListViewItem *ceItem;
322 324
323 for(item = mListView->firstChild(); item; item = item->itemBelow()) 325 for(item = mListView->firstChild(); item; item = item->itemBelow())
324 { 326 {
325 if (mListView->isSelected( item )) 327 if (mListView->isSelected( item ))
326 { 328 {
327#ifndef KAB_EMBEDDED 329#ifndef KAB_EMBEDDED
328 ceItem = dynamic_cast<ContactListViewItem*>(item); 330 ceItem = dynamic_cast<ContactListViewItem*>(item);
329#else //KAB_EMBEDDED 331#else //KAB_EMBEDDED
330 ceItem = (ContactListViewItem*)(item); 332 ceItem = (ContactListViewItem*)(item);
331#endif //KAB_EMBEDDED 333#endif //KAB_EMBEDDED
332 334
333 if (ceItem != 0L) 335 if (ceItem != 0L)
334 uidList << ceItem->addressee().uid(); 336 uidList << ceItem->addressee().uid();
335 } 337 }
336 } 338 }
337 if ( uidList.count() == 0 ) 339 if ( uidList.count() == 0 )
338 if ( mListView->currentItem() ) { 340 if ( mListView->currentItem() ) {
339 ceItem = (ContactListViewItem*)(mListView->currentItem()) ; 341 ceItem = (ContactListViewItem*)(mListView->currentItem()) ;
340 uidList << ceItem->addressee().uid(); 342 uidList << ceItem->addressee().uid();
341 } 343 }
342 344
343 return uidList; 345 return uidList;
344} 346}
345 347
346void KAddressBookTableView::setSelected(QString uid, bool selected) 348void KAddressBookTableView::setSelected(QString uid, bool selected)
347{ 349{
348 QListViewItem *item; 350 QListViewItem *item;
349 ContactListViewItem *ceItem; 351 ContactListViewItem *ceItem;
350 352
351 if (uid.isNull()) 353 if (uid.isNull())
352 { 354 {
353 mListView->selectAll(selected); 355 mListView->selectAll(selected);
354 } 356 }
355 else 357 else
356 { 358 {
357 for(item = mListView->firstChild(); item; item = item->itemBelow()) 359 for(item = mListView->firstChild(); item; item = item->itemBelow())
358 { 360 {
359#ifndef KAB_EMBEDDED 361#ifndef KAB_EMBEDDED
360 ceItem = dynamic_cast<ContactListViewItem*>(item); 362 ceItem = dynamic_cast<ContactListViewItem*>(item);
361#else //KAB_EMBEDDED 363#else //KAB_EMBEDDED
362 ceItem = (ContactListViewItem*)(item); 364 ceItem = (ContactListViewItem*)(item);
363#endif //KAB_EMBEDDED 365#endif //KAB_EMBEDDED
364 366
365 367
366 if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) 368 if ((ceItem != 0L) && (ceItem->addressee().uid() == uid))
367 { 369 {
368 mListView->setSelected(item, selected); 370 mListView->setSelected(item, selected);
369 371
370 if (selected) 372 if (selected)
371 mListView->ensureItemVisible(item); 373 mListView->ensureItemVisible(item);
372 } 374 }
373 } 375 }
374 } 376 }
375} 377}