summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-29 11:41:57 (UTC)
committer zautrix <zautrix>2004-10-29 11:41:57 (UTC)
commit8c55eb6afe84ef69bb284d384a0c9f1ef1484ad8 (patch) (unidiff)
treeeda3f48b2a157146d936afef45d0a72f864fedcd
parent443116d2682cd221c25201926e35d825170bdbbd (diff)
downloadkdepimpi-8c55eb6afe84ef69bb284d384a0c9f1ef1484ad8.zip
kdepimpi-8c55eb6afe84ef69bb284d384a0c9f1ef1484ad8.tar.gz
kdepimpi-8c55eb6afe84ef69bb284d384a0c9f1ef1484ad8.tar.bz2
fix of excluding last sync addreessees in search
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp4
-rw-r--r--kaddressbook/views/kaddressbookiconview.cpp4
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp6
3 files changed, 13 insertions, 1 deletions
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp
index 15f154e..2c9b162 100644
--- a/kaddressbook/views/kaddressbookcardview.cpp
+++ b/kaddressbook/views/kaddressbookcardview.cpp
@@ -222,141 +222,145 @@ void KAddressBookCardView::readConfig(KConfig *config)
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
262void KAddressBookCardView::writeConfig( KConfig *config ) 262void 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}
267void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) 267void 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-") )
287 continue;
286#if QT_VERSION >= 300 288#if QT_VERSION >= 300
287 if (re.search(field->value( *it ).lower()) != -1) 289 if (re.search(field->value( *it ).lower()) != -1)
288#else 290#else
289 if (re.match(field->value( *it ).lower()) != -1) 291 if (re.match(field->value( *it ).lower()) != -1)
290#endif 292#endif
291 new AddresseeCardViewItem(fields(), mShowEmptyFields, 293 new AddresseeCardViewItem(fields(), mShowEmptyFields,
292 addressBook(), *it, mCardView); 294 addressBook(), *it, mCardView);
293 295
294 } 296 }
295 } else { 297 } else {
296 KABC::Field::List fieldList = fields(); 298 KABC::Field::List fieldList = fields();
297 KABC::Field::List::ConstIterator fieldIt; 299 KABC::Field::List::ConstIterator fieldIt;
298 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-") )
302 continue;
299 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 303 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
300#if QT_VERSION >= 300 304#if QT_VERSION >= 300
301 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 305 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
302#else 306#else
303 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 307 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
304#endif 308#endif
305 { 309 {
306 new AddresseeCardViewItem(fields(), mShowEmptyFields, 310 new AddresseeCardViewItem(fields(), mShowEmptyFields,
307 addressBook(), *it, mCardView); 311 addressBook(), *it, mCardView);
308 continue; 312 continue;
309 } 313 }
310 } 314 }
311 } 315 }
312 } 316 }
313 mCardView->viewport()->setUpdatesEnabled( true ); 317 mCardView->viewport()->setUpdatesEnabled( true );
314 mCardView->viewport()->update(); 318 mCardView->viewport()->update();
315 if ( mCardView->firstItem() ) { 319 if ( mCardView->firstItem() ) {
316 mCardView->setCurrentItem ( mCardView->firstItem() ); 320 mCardView->setCurrentItem ( mCardView->firstItem() );
317 mCardView->setSelected ( mCardView->firstItem() , true ); 321 mCardView->setSelected ( mCardView->firstItem() , true );
318 } 322 }
319 else 323 else
320 emit selected(QString::null); 324 emit selected(QString::null);
321} 325}
322QStringList KAddressBookCardView::selectedUids() 326QStringList KAddressBookCardView::selectedUids()
323{ 327{
324 QStringList uidList; 328 QStringList uidList;
325 CardViewItem *item; 329 CardViewItem *item;
326 AddresseeCardViewItem *aItem; 330 AddresseeCardViewItem *aItem;
327 331
328 for (item = mCardView->firstItem(); item; item = item->nextItem()) 332 for (item = mCardView->firstItem(); item; item = item->nextItem())
329 { 333 {
330 if (item->isSelected()) 334 if (item->isSelected())
331 { 335 {
332#ifndef KAB_EMBEDDED 336#ifndef KAB_EMBEDDED
333 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 337 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
334#else //KAB_EMBEDDED 338#else //KAB_EMBEDDED
335 aItem = (AddresseeCardViewItem*)(item); 339 aItem = (AddresseeCardViewItem*)(item);
336#endif //KAB_EMBEDDED 340#endif //KAB_EMBEDDED
337 if (aItem) 341 if (aItem)
338 uidList << aItem->addressee().uid(); 342 uidList << aItem->addressee().uid();
339 } 343 }
340 } 344 }
341 345
342 return uidList; 346 return uidList;
343} 347}
344 348
345void KAddressBookCardView::refresh(QString uid) 349void KAddressBookCardView::refresh(QString uid)
346{ 350{
347 CardViewItem *item; 351 CardViewItem *item;
348 AddresseeCardViewItem *aItem; 352 AddresseeCardViewItem *aItem;
349 353
350 if (uid.isNull()) 354 if (uid.isNull())
351 { 355 {
352 // Rebuild the view 356 // Rebuild the view
353 mCardView->viewport()->setUpdatesEnabled( false ); 357 mCardView->viewport()->setUpdatesEnabled( false );
354 mCardView->clear(); 358 mCardView->clear();
355 359
356 KABC::Addressee::List addresseeList = addressees(); 360 KABC::Addressee::List addresseeList = addressees();
357 KABC::Addressee::List::Iterator iter; 361 KABC::Addressee::List::Iterator iter;
358 for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) 362 for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter)
359 { 363 {
360 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-") )
361 continue; 365 continue;
362 aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, 366 aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields,
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp
index 41c3cb2..0ce56c8 100644
--- a/kaddressbook/views/kaddressbookiconview.cpp
+++ b/kaddressbook/views/kaddressbookiconview.cpp
@@ -209,141 +209,145 @@ KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab,
209} 209}
210 210
211KAddressBookIconView::~KAddressBookIconView() 211KAddressBookIconView::~KAddressBookIconView()
212{ 212{
213} 213}
214void KAddressBookIconView::setFocusAV() 214void KAddressBookIconView::setFocusAV()
215{ 215{
216 if ( mIconView ) 216 if ( mIconView )
217 mIconView->setFocus(); 217 mIconView->setFocus();
218} 218}
219 219
220 220
221void KAddressBookIconView::scrollUP() 221void KAddressBookIconView::scrollUP()
222{ 222{
223 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 223 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
224 QApplication::postEvent( mIconView, ev ); 224 QApplication::postEvent( mIconView, ev );
225} 225}
226void KAddressBookIconView::scrollDOWN() 226void KAddressBookIconView::scrollDOWN()
227{ 227{
228 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 228 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
229 QApplication::postEvent( mIconView, ev ); 229 QApplication::postEvent( mIconView, ev );
230} 230}
231void KAddressBookIconView::readConfig(KConfig *config) 231void KAddressBookIconView::readConfig(KConfig *config)
232{ 232{
233 KAddressBookView::readConfig(config); 233 KAddressBookView::readConfig(config);
234 234
235//US method executed is part of KIconView 235//US method executed is part of KIconView
236//US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), 236//US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)),
237//US this, SLOT(addresseeExecuted(QIconViewItem *))); 237//US this, SLOT(addresseeExecuted(QIconViewItem *)));
238 disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 238 disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
239 this, SLOT(addresseeExecuted(QIconViewItem *))); 239 this, SLOT(addresseeExecuted(QIconViewItem *)));
240 240
241//US method executed is part of KIconView. Use selectionChanged instead 241//US method executed is part of KIconView. Use selectionChanged instead
242/*US 242/*US
243 if (KABPrefs::instance()->mHonorSingleClick) 243 if (KABPrefs::instance()->mHonorSingleClick)
244 connect(mIconView, SIGNAL(executed(QIconViewItem *)), 244 connect(mIconView, SIGNAL(executed(QIconViewItem *)),
245 this, SLOT(addresseeExecuted(QIconViewItem *))); 245 this, SLOT(addresseeExecuted(QIconViewItem *)));
246 else 246 else
247 connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), 247 connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)),
248 this, SLOT(addresseeExecuted(QIconViewItem *))); 248 this, SLOT(addresseeExecuted(QIconViewItem *)));
249*/ 249*/
250 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 250 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
251 this, SLOT(addresseeExecuted(QIconViewItem *))); 251 this, SLOT(addresseeExecuted(QIconViewItem *)));
252 252
253} 253}
254void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) 254void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field )
255{ 255{
256 mIconView->clear(); 256 mIconView->clear();
257 mIconList.clear(); 257 mIconList.clear();
258 if ( s.isEmpty() || s == "*" ) { 258 if ( s.isEmpty() || s == "*" ) {
259 refresh(); 259 refresh();
260 return; 260 return;
261 } 261 }
262 QString pattern = s.lower()+"*"; 262 QString pattern = s.lower()+"*";
263 QRegExp re; 263 QRegExp re;
264 re.setWildcard(true); // most people understand these better. 264 re.setWildcard(true); // most people understand these better.
265 re.setCaseSensitive(false); 265 re.setCaseSensitive(false);
266 re.setPattern( pattern ); 266 re.setPattern( pattern );
267 if (!re.isValid()) 267 if (!re.isValid())
268 return; 268 return;
269 KABC::Addressee::List addresseeList = addressees(); 269 KABC::Addressee::List addresseeList = addressees();
270 KABC::Addressee::List::Iterator it; 270 KABC::Addressee::List::Iterator it;
271 if ( field ) { 271 if ( field ) {
272 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 272 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
273 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
274 continue;
273#if QT_VERSION >= 300 275#if QT_VERSION >= 300
274 if (re.search(field->value( *it ).lower()) != -1) 276 if (re.search(field->value( *it ).lower()) != -1)
275#else 277#else
276 if (re.match(field->value( *it ).lower()) != -1) 278 if (re.match(field->value( *it ).lower()) != -1)
277#endif 279#endif
278 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 280 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
279 281
280 282
281 } 283 }
282 } else { 284 } else {
283 KABC::Field::List fieldList = fields(); 285 KABC::Field::List fieldList = fields();
284 KABC::Field::List::ConstIterator fieldIt; 286 KABC::Field::List::ConstIterator fieldIt;
285 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 287 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
288 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
289 continue;
286 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 290 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
287#if QT_VERSION >= 300 291#if QT_VERSION >= 300
288 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 292 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
289#else 293#else
290 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 294 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
291#endif 295#endif
292 { 296 {
293 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 297 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
294 continue; 298 continue;
295 } 299 }
296 } 300 }
297 } 301 }
298 } 302 }
299 mIconView->arrangeItemsInGrid( true ); 303 mIconView->arrangeItemsInGrid( true );
300 if ( mIconView->firstItem() ) { 304 if ( mIconView->firstItem() ) {
301 mIconView->setCurrentItem ( mIconView->firstItem() ); 305 mIconView->setCurrentItem ( mIconView->firstItem() );
302 mIconView->setSelected ( mIconView->firstItem() , true ); 306 mIconView->setSelected ( mIconView->firstItem() , true );
303 } 307 }
304 else 308 else
305 emit selected(QString::null); 309 emit selected(QString::null);
306} 310}
307QStringList KAddressBookIconView::selectedUids() 311QStringList KAddressBookIconView::selectedUids()
308{ 312{
309 QStringList uidList; 313 QStringList uidList;
310 QIconViewItem *item; 314 QIconViewItem *item;
311 AddresseeIconViewItem *aItem; 315 AddresseeIconViewItem *aItem;
312 316
313 for (item = mIconView->firstItem(); item; item = item->nextItem()) 317 for (item = mIconView->firstItem(); item; item = item->nextItem())
314 { 318 {
315 if (item->isSelected()) 319 if (item->isSelected())
316 { 320 {
317#ifndef KAB_EMBEDDED 321#ifndef KAB_EMBEDDED
318 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 322 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
319#else //KAB_EMBEDDED 323#else //KAB_EMBEDDED
320 aItem = (AddresseeIconViewItem*)(item); 324 aItem = (AddresseeIconViewItem*)(item);
321#endif //KAB_EMBEDDED 325#endif //KAB_EMBEDDED
322 if (aItem) 326 if (aItem)
323 uidList << aItem->addressee().uid(); 327 uidList << aItem->addressee().uid();
324 } 328 }
325 } 329 }
326 330
327 return uidList; 331 return uidList;
328} 332}
329 333
330void KAddressBookIconView::refresh(QString uid) 334void KAddressBookIconView::refresh(QString uid)
331{ 335{
332 QIconViewItem *item; 336 QIconViewItem *item;
333 AddresseeIconViewItem *aItem; 337 AddresseeIconViewItem *aItem;
334 338
335 if ( uid.isNull() ) { 339 if ( uid.isNull() ) {
336 // Rebuild the view 340 // Rebuild the view
337 mIconView->clear(); 341 mIconView->clear();
338 mIconList.clear(); 342 mIconList.clear();
339 343
340 KABC::Addressee::List addresseeList = addressees(); 344 KABC::Addressee::List addresseeList = addressees();
341 KABC::Addressee::List::Iterator iter; 345 KABC::Addressee::List::Iterator iter;
342 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) { 346 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) {
343 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) 347 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") )
344 continue; 348 continue;
345 aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); 349 aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView );
346 } 350 }
347 351
348 mIconView->arrangeItemsInGrid( true ); 352 mIconView->arrangeItemsInGrid( true );
349 353
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index 6f20e05..89053c2 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -90,141 +90,145 @@ void KAddressBookTableView::reconstructListView()
90 mListView = new ContactListView( this, addressBook(), viewWidget() ); 90 mListView = new ContactListView( this, addressBook(), viewWidget() );
91 91
92 //US set singleClick manually, because it is no global configparameter in embedded space 92 //US set singleClick manually, because it is no global configparameter in embedded space
93 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); 93 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick);
94 94
95 // Add the columns 95 // Add the columns
96 KABC::Field::List fieldList = fields(); 96 KABC::Field::List fieldList = fields();
97 KABC::Field::List::ConstIterator it; 97 KABC::Field::List::ConstIterator it;
98 98
99 int c = 0; 99 int c = 0;
100 for( it = fieldList.begin(); it != fieldList.end(); ++it ) { 100 for( it = fieldList.begin(); it != fieldList.end(); ++it ) {
101 mListView->addColumn( (*it)->label() ); 101 mListView->addColumn( (*it)->label() );
102 mListView->setColumnWidthMode(c++, QListView::Manual); 102 mListView->setColumnWidthMode(c++, QListView::Manual);
103//US 103//US
104 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); 104 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1());
105 } 105 }
106 106
107 connect(mListView, SIGNAL(selectionChanged()), 107 connect(mListView, SIGNAL(selectionChanged()),
108 this, SLOT(addresseeSelected())); 108 this, SLOT(addresseeSelected()));
109 connect(mListView, SIGNAL(startAddresseeDrag()), this, 109 connect(mListView, SIGNAL(startAddresseeDrag()), this,
110 SIGNAL(startDrag())); 110 SIGNAL(startDrag()));
111 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 111 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
112 SIGNAL(dropped(QDropEvent*))); 112 SIGNAL(dropped(QDropEvent*)));
113 113
114 if (KABPrefs::instance()->mHonorSingleClick) { 114 if (KABPrefs::instance()->mHonorSingleClick) {
115 // qDebug("KAddressBookTableView::reconstructListView single"); 115 // qDebug("KAddressBookTableView::reconstructListView single");
116 connect(mListView, SIGNAL(executed(QListViewItem*)), 116 connect(mListView, SIGNAL(executed(QListViewItem*)),
117 this, SLOT(addresseeExecuted(QListViewItem*))); 117 this, SLOT(addresseeExecuted(QListViewItem*)));
118 } else { 118 } else {
119 // qDebug("KAddressBookTableView::reconstructListView double"); 119 // qDebug("KAddressBookTableView::reconstructListView double");
120 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 120 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
121 this, SLOT(addresseeExecuted(QListViewItem*))); 121 this, SLOT(addresseeExecuted(QListViewItem*)));
122 } 122 }
123 connect(mListView, SIGNAL(returnPressed(QListViewItem*)), 123 connect(mListView, SIGNAL(returnPressed(QListViewItem*)),
124 this, SLOT(addresseeExecuted(QListViewItem*))); 124 this, SLOT(addresseeExecuted(QListViewItem*)));
125 connect(mListView, SIGNAL(signalDelete()), 125 connect(mListView, SIGNAL(signalDelete()),
126 this, SLOT(addresseeDeleted())); 126 this, SLOT(addresseeDeleted()));
127 127
128//US performceimprovement. Refresh is done from the outside 128//US performceimprovement. Refresh is done from the outside
129//US refresh(); 129//US refresh();
130 130
131 mListView->setSorting( 0, true ); 131 mListView->setSorting( 0, true );
132 mainLayout->addWidget( mListView ); 132 mainLayout->addWidget( mListView );
133 mainLayout->activate(); 133 mainLayout->activate();
134 mListView->show(); 134 mListView->show();
135} 135}
136 136
137void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) 137void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
138{ 138{
139 mListView->clear(); 139 mListView->clear();
140 if ( s.isEmpty() || s == "*" ) { 140 if ( s.isEmpty() || s == "*" ) {
141 refresh(); 141 refresh();
142 return; 142 return;
143 } 143 }
144 QString pattern = s.lower()+"*"; 144 QString pattern = s.lower()+"*";
145 QRegExp re; 145 QRegExp re;
146 re.setWildcard(true); // most people understand these better. 146 re.setWildcard(true); // most people understand these better.
147 re.setCaseSensitive(false); 147 re.setCaseSensitive(false);
148 re.setPattern( pattern ); 148 re.setPattern( pattern );
149 if (!re.isValid()) 149 if (!re.isValid())
150 return; 150 return;
151 KABC::Addressee::List addresseeList = addressees(); 151 KABC::Addressee::List addresseeList = addressees();
152 KABC::Addressee::List::Iterator it; 152 KABC::Addressee::List::Iterator it;
153 if ( field ) { 153 if ( field ) {
154 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 154 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
155 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
156 continue;
155#if QT_VERSION >= 300 157#if QT_VERSION >= 300
156 if (re.search(field->value( *it ).lower()) != -1) 158 if (re.search(field->value( *it ).lower()) != -1)
157#else 159#else
158 if (re.match(field->value( *it ).lower()) != -1) 160 if (re.match(field->value( *it ).lower()) != -1)
159#endif 161#endif
160 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 162 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
161 163
162 } 164 }
163 } else { 165 } else {
164 KABC::Field::List fieldList = fields(); 166 KABC::Field::List fieldList = fields();
165 KABC::Field::List::ConstIterator fieldIt; 167 KABC::Field::List::ConstIterator fieldIt;
166 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 168 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
169 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
170 continue;
167 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 171 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
168#if QT_VERSION >= 300 172#if QT_VERSION >= 300
169 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 173 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
170#else 174#else
171 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 175 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
172#endif 176#endif
173 { 177 {
174 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 178 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
175 break; 179 break;
176 } 180 }
177 } 181 }
178 } 182 }
179 } 183 }
180 // Sometimes the background pixmap gets messed up when we add lots 184 // Sometimes the background pixmap gets messed up when we add lots
181 // of items. 185 // of items.
182 mListView->repaint(); 186 mListView->repaint();
183 if ( mListView->firstChild() ) { 187 if ( mListView->firstChild() ) {
184 mListView->setCurrentItem ( mListView->firstChild() ); 188 mListView->setCurrentItem ( mListView->firstChild() );
185 mListView->setSelected ( mListView->firstChild(), true ); 189 mListView->setSelected ( mListView->firstChild(), true );
186 } 190 }
187 else 191 else
188 emit selected(QString::null); 192 emit selected(QString::null);
189 193
190} 194}
191void KAddressBookTableView::writeConfig(KConfig *config) 195void KAddressBookTableView::writeConfig(KConfig *config)
192{ 196{
193 KAddressBookView::writeConfig(config); 197 KAddressBookView::writeConfig(config);
194 198
195 mListView->saveLayout(config, config->group()); 199 mListView->saveLayout(config, config->group());
196} 200}
197 201
198void KAddressBookTableView::readConfig(KConfig *config) 202void KAddressBookTableView::readConfig(KConfig *config)
199{ 203{
200 KAddressBookView::readConfig( config ); 204 KAddressBookView::readConfig( config );
201 // The config could have changed the fields, so we need to reconstruct 205 // The config could have changed the fields, so we need to reconstruct
202 // the listview. 206 // the listview.
203 reconstructListView(); 207 reconstructListView();
204 208
205 // costum colors? 209 // costum colors?
206 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 210 if ( config->readBoolEntry( "EnableCustomColors", false ) )
207 { 211 {
208 QPalette p( mListView->palette() ); 212 QPalette p( mListView->palette() );
209 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 213 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
210 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 214 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
211 c = p.color(QPalette::Normal, QColorGroup::Text ); 215 c = p.color(QPalette::Normal, QColorGroup::Text );
212 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 216 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
213 c = p.color(QPalette::Normal, QColorGroup::Button ); 217 c = p.color(QPalette::Normal, QColorGroup::Button );
214 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 218 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
215 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 219 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
216 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 220 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
217 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 221 c = p.color(QPalette::Normal, QColorGroup::Highlight );
218 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 222 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
219 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 223 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
220 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 224 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
221#ifndef KAB_EMBEDDED 225#ifndef KAB_EMBEDDED
222 c = KGlobalSettings::alternateBackgroundColor(); 226 c = KGlobalSettings::alternateBackgroundColor();
223#else //KAB_EMBEDDED 227#else //KAB_EMBEDDED
224 c = QColor(240, 240, 240); 228 c = QColor(240, 240, 240);
225#endif //KAB_EMBEDDED 229#endif //KAB_EMBEDDED
226 c = config->readColorEntry ("AlternatingBackgroundColor", &c); 230 c = config->readColorEntry ("AlternatingBackgroundColor", &c);
227 mListView->setAlternateColor(c); 231 mListView->setAlternateColor(c);
228 232
229 233
230 //US mListView->viewport()->setPalette( p ); 234 //US mListView->viewport()->setPalette( p );