summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views
authorzautrix <zautrix>2005-08-22 15:42:41 (UTC)
committer zautrix <zautrix>2005-08-22 15:42:41 (UTC)
commit1d82d044bbdedd407f6d08305522187ffd256552 (patch) (unidiff)
tree08f5651d72548b643ed012e5f6ad938b36d1ae3f /kaddressbook/views
parentf516a558e6d18982a54152b28ca3da78fe76e3fc (diff)
downloadkdepimpi-1d82d044bbdedd407f6d08305522187ffd256552.zip
kdepimpi-1d82d044bbdedd407f6d08305522187ffd256552.tar.gz
kdepimpi-1d82d044bbdedd407f6d08305522187ffd256552.tar.bz2
kapi search fix
Diffstat (limited to 'kaddressbook/views') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp22
-rw-r--r--kaddressbook/views/kaddressbookiconview.cpp39
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp16
3 files changed, 70 insertions, 7 deletions
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp
index ca21016..b503652 100644
--- a/kaddressbook/views/kaddressbookcardview.cpp
+++ b/kaddressbook/views/kaddressbookcardview.cpp
@@ -284,108 +284,126 @@ void KAddressBookCardView::readConfig(KConfig *config)
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()) == 0) 318 if (re.search(field->value( *it ).lower()) == 0)
319#else 319#else
320 if (re.match(field->value( *it ).lower()) == 0) 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 bool match = false;
332 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 333 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
333#if QT_VERSION >= 0x030000 334#if QT_VERSION >= 0x030000
334 if (re.search((*fieldIt)->value( *it ).lower()) == 0) 335 if (re.search((*fieldIt)->value( *it ).lower()) == 0)
335#else 336#else
336 if (re.match((*fieldIt)->value( *it ).lower()) == 0) 337 if (re.match((*fieldIt)->value( *it ).lower()) == 0)
337#endif 338#endif
338 { 339 {
339 new AddresseeCardViewItem(fields(), mShowEmptyFields, 340 new AddresseeCardViewItem(fields(), mShowEmptyFields,
340 addressBook(), *it, mCardView); 341 addressBook(), *it, mCardView);
342 match = true;
341 break; 343 break;
342 } 344 }
343 } 345 }
346 if ( ! match ) {
347 if ( (*it).matchPhoneNumber( &re ) ) {
348 new AddresseeCardViewItem(fields(), mShowEmptyFields,
349 addressBook(), *it, mCardView);
350 match = true;
351 break;
352 }
353 }
354 if ( ! match ) {
355 if ( (*it).matchAddress( &re ) ) {
356 new AddresseeCardViewItem(fields(), mShowEmptyFields,
357 addressBook(), *it, mCardView);
358 match = true;
359 break;
360 }
361 }
344 } 362 }
345 } 363 }
346 mCardView->viewport()->setUpdatesEnabled( true ); 364 mCardView->viewport()->setUpdatesEnabled( true );
347 mCardView->viewport()->update(); 365 mCardView->viewport()->update();
348 if ( mCardView->firstItem() ) { 366 if ( mCardView->firstItem() ) {
349 mCardView->setCurrentItem ( mCardView->firstItem() ); 367 mCardView->setCurrentItem ( mCardView->firstItem() );
350 mCardView->setSelected ( mCardView->firstItem() , true ); 368 mCardView->setSelected ( mCardView->firstItem() , true );
351 } 369 }
352 else 370 else
353 emit selected(QString::null); 371 emit selected(QString::null);
354} 372}
355QStringList KAddressBookCardView::selectedUids() 373QStringList KAddressBookCardView::selectedUids()
356{ 374{
357 QStringList uidList; 375 QStringList uidList;
358 CardViewItem *item; 376 CardViewItem *item;
359 AddresseeCardViewItem *aItem; 377 AddresseeCardViewItem *aItem;
360 378
361 for (item = mCardView->firstItem(); item; item = item->nextItem()) 379 for (item = mCardView->firstItem(); item; item = item->nextItem())
362 { 380 {
363 if (item->isSelected()) 381 if (item->isSelected())
364 { 382 {
365#ifndef KAB_EMBEDDED 383#ifndef KAB_EMBEDDED
366 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 384 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
367#else //KAB_EMBEDDED 385#else //KAB_EMBEDDED
368 aItem = (AddresseeCardViewItem*)(item); 386 aItem = (AddresseeCardViewItem*)(item);
369#endif //KAB_EMBEDDED 387#endif //KAB_EMBEDDED
370 if (aItem) 388 if (aItem)
371 uidList << aItem->addressee().uid(); 389 uidList << aItem->addressee().uid();
372 } 390 }
373 } 391 }
374 392
375 return uidList; 393 return uidList;
376} 394}
377 395
378void KAddressBookCardView::refresh(QString uid) 396void KAddressBookCardView::refresh(QString uid)
379{ 397{
380 CardViewItem *item; 398 CardViewItem *item;
381 AddresseeCardViewItem *aItem; 399 AddresseeCardViewItem *aItem;
382 400
383 if (uid.isNull()) 401 if (uid.isNull())
384 { 402 {
385 // Rebuild the view 403 // Rebuild the view
386 mCardView->viewport()->setUpdatesEnabled( false ); 404 mCardView->viewport()->setUpdatesEnabled( false );
387 mCardView->clear(); 405 mCardView->clear();
388 406
389 KABC::Addressee::List addresseeList = addressees(); 407 KABC::Addressee::List addresseeList = addressees();
390 KABC::Addressee::List::Iterator iter; 408 KABC::Addressee::List::Iterator iter;
391 for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) 409 for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter)
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp
index 4bbdf1d..d6ddec3 100644
--- a/kaddressbook/views/kaddressbookiconview.cpp
+++ b/kaddressbook/views/kaddressbookiconview.cpp
@@ -105,116 +105,129 @@ void AddresseeIconView::itemDropped(QDropEvent *e,
105 emit addresseeDropped(e); 105 emit addresseeDropped(e);
106} 106}
107 107
108QDragObject *AddresseeIconView::dragObject() 108QDragObject *AddresseeIconView::dragObject()
109{ 109{
110 emit startAddresseeDrag(); 110 emit startAddresseeDrag();
111 111
112 // We never want IconView to start the drag 112 // We never want IconView to start the drag
113 return 0; 113 return 0;
114} 114}
115//////////////////////////////// 115////////////////////////////////
116// AddresseeIconViewItem (internal class) 116// AddresseeIconViewItem (internal class)
117#ifndef KAB_EMBEDDED 117#ifndef KAB_EMBEDDED
118class AddresseeIconViewItem : public KIconViewItem 118class AddresseeIconViewItem : public KIconViewItem
119#else //KAB_EMBEDDED 119#else //KAB_EMBEDDED
120class AddresseeIconViewItem : public QIconViewItem 120class AddresseeIconViewItem : public QIconViewItem
121#endif //KAB_EMBEDDED 121#endif //KAB_EMBEDDED
122{ 122{
123 public: 123 public:
124#ifndef KAB_EMBEDDED 124#ifndef KAB_EMBEDDED
125 AddresseeIconViewItem(const KABC::Field::List &fields, 125 AddresseeIconViewItem(const KABC::Field::List &fields,
126 KABC::AddressBook *doc, const KABC::Addressee &a, 126 KABC::AddressBook *doc, const KABC::Addressee &a,
127 QIconView *parent) 127 QIconView *parent)
128 : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) 128 : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a)
129#else //KAB_EMBEDDED 129#else //KAB_EMBEDDED
130 AddresseeIconViewItem(const KABC::Field::List &fields, 130 AddresseeIconViewItem(const KABC::Field::List &fields,
131 KABC::AddressBook *doc, const KABC::Addressee &a, 131 KABC::AddressBook *doc, const KABC::Addressee &a,
132 QIconView *parent) 132 QIconView *parent)
133 : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) 133 : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a)
134#endif //KAB_EMBEDDED 134#endif //KAB_EMBEDDED
135 { 135 {
136 if ( mFields.isEmpty() ) { 136 if ( mFields.isEmpty() ) {
137 mFields = KABC::Field::defaultFields(); 137 mFields = KABC::Field::defaultFields();
138 } 138 }
139 refresh(); 139 refresh();
140 } 140 }
141 141
142 const KABC::Addressee &addressee() const { return mAddressee; } 142 const KABC::Addressee &addressee() const { return mAddressee; }
143 143
144 void refresh() 144 void refresh()
145 { 145 {
146 // Update our addressee, since it may have changed elsewhere 146 // Update our addressee, since it may have changed elsewhere
147 mAddressee = mDocument->findByUid(mAddressee.uid()); 147 mAddressee = mDocument->findByUid(mAddressee.uid());
148 148
149 if (!mAddressee.isEmpty()) 149 if (!mAddressee.isEmpty())
150 setText( mAddressee.givenName() + " " + mAddressee.familyName() ); 150 setText( mAddressee.givenName() + " " + mAddressee.familyName() );
151 151
152 QPixmap icon; 152 QPixmap icon;
153 QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) ); 153
154 KABC::Picture pic = mAddressee.photo(); 154 KABC::Picture pic = mAddressee.photo();
155 if ( pic.data().isNull() ) 155 if ( pic.data().isNull() )
156 pic = mAddressee.logo(); 156 pic = mAddressee.logo();
157 157
158 if ( pic.isIntern() && !pic.data().isNull() ) { 158 if ( pic.isIntern() && !pic.data().isNull() ) {
159 QImage img = pic.data(); 159 QImage img = pic.data();
160#ifndef KAB_EMBEDDED 160#ifndef KAB_EMBEDDED
161 if ( img.width() > img.height() ) 161 if ( img.width() > img.height() )
162 icon = img.scaleWidth( 32 ); 162 icon = img.scaleWidth( 32 );
163 else 163 else
164 icon = img.scaleHeight( 32 ); 164 icon = img.scaleHeight( 32 );
165#else //KAB_EMBEDDED 165#else //KAB_EMBEDDED
166
167 int wid = pic.data().width();
168 int hei = pic.data().height();
169 int max = 48;
170 if ( wid > max || hei > max ) {
171 if ( wid > hei ) {
172 hei = (hei*max)/wid;
173 wid = max;
174 } else {
175 wid = (wid*max)/hei;
176 hei = max;
177 }
178 }
166 qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); 179 qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor");
167 icon.convertFromImage(img.smoothScale(32, 32)); 180 icon.convertFromImage(img.smoothScale(wid, hei));
168#endif //KAB_EMBEDDED 181#endif //KAB_EMBEDDED
169 182
170 } else 183 } else {
171 icon = defaultIcon; 184 icon = KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 );
172 185 }
173 setPixmap( icon ); 186 setPixmap( icon );
174 } 187 }
175 188
176 private: 189 private:
177 KABC::Field::List mFields; 190 KABC::Field::List mFields;
178 KABC::AddressBook *mDocument; 191 KABC::AddressBook *mDocument;
179 KABC::Addressee mAddressee; 192 KABC::Addressee mAddressee;
180}; 193};
181 194
182/////////////////////////////// 195///////////////////////////////
183// KAddressBookView 196// KAddressBookView
184 197
185KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, 198KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab,
186 QWidget *parent, const char *name) 199 QWidget *parent, const char *name)
187 : KAddressBookView( ab, parent, name ) 200 : KAddressBookView( ab, parent, name )
188{ 201{
189 // Init the GUI 202 // Init the GUI
190 QVBoxLayout *layout = new QVBoxLayout(viewWidget()); 203 QVBoxLayout *layout = new QVBoxLayout(viewWidget());
191 204
192 mIconView = new AddresseeIconView(viewWidget(), "mIconView"); 205 mIconView = new AddresseeIconView(viewWidget(), "mIconView");
193 layout->addWidget(mIconView); 206 layout->addWidget(mIconView);
194 207
195 // Connect up the signals 208 // Connect up the signals
196 209
197//US method executed is part of KIconView 210//US method executed is part of KIconView
198//US connect(mIconView, SIGNAL(executed(QIconViewItem *)), 211//US connect(mIconView, SIGNAL(executed(QIconViewItem *)),
199//US this, SLOT(addresseeExecuted(QIconViewItem *))); 212//US this, SLOT(addresseeExecuted(QIconViewItem *)));
200 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 213 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
201 this, SLOT(addresseeExecuted(QIconViewItem *))); 214 this, SLOT(addresseeExecuted(QIconViewItem *)));
202 215
203 connect(mIconView, SIGNAL(selectionChanged()), 216 connect(mIconView, SIGNAL(selectionChanged()),
204 this, SLOT(addresseeSelected())); 217 this, SLOT(addresseeSelected()));
205 connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), 218 connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)),
206 this, SIGNAL(dropped(QDropEvent*))); 219 this, SIGNAL(dropped(QDropEvent*)));
207 connect(mIconView, SIGNAL(startAddresseeDrag()), 220 connect(mIconView, SIGNAL(startAddresseeDrag()),
208 this, SIGNAL(startDrag())); 221 this, SIGNAL(startDrag()));
209} 222}
210 223
211KAddressBookIconView::~KAddressBookIconView() 224KAddressBookIconView::~KAddressBookIconView()
212{ 225{
213} 226}
214void KAddressBookIconView::setFocusAV() 227void KAddressBookIconView::setFocusAV()
215{ 228{
216 if ( mIconView ) 229 if ( mIconView )
217 mIconView->setFocus(); 230 mIconView->setFocus();
218} 231}
219 232
220 233
@@ -238,106 +251,122 @@ void KAddressBookIconView::readConfig(KConfig *config)
238 disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 251 disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
239 this, SLOT(addresseeExecuted(QIconViewItem *))); 252 this, SLOT(addresseeExecuted(QIconViewItem *)));
240 253
241//US method executed is part of KIconView. Use selectionChanged instead 254//US method executed is part of KIconView. Use selectionChanged instead
242/*US 255/*US
243 if (KABPrefs::instance()->mHonorSingleClick) 256 if (KABPrefs::instance()->mHonorSingleClick)
244 connect(mIconView, SIGNAL(executed(QIconViewItem *)), 257 connect(mIconView, SIGNAL(executed(QIconViewItem *)),
245 this, SLOT(addresseeExecuted(QIconViewItem *))); 258 this, SLOT(addresseeExecuted(QIconViewItem *)));
246 else 259 else
247 connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), 260 connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)),
248 this, SLOT(addresseeExecuted(QIconViewItem *))); 261 this, SLOT(addresseeExecuted(QIconViewItem *)));
249*/ 262*/
250 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 263 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
251 this, SLOT(addresseeExecuted(QIconViewItem *))); 264 this, SLOT(addresseeExecuted(QIconViewItem *)));
252 265
253} 266}
254void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) 267void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field )
255{ 268{
256 mIconView->clear(); 269 mIconView->clear();
257 mIconList.clear(); 270 mIconList.clear();
258 if ( s.isEmpty() || s == "*" ) { 271 if ( s.isEmpty() || s == "*" ) {
259 refresh(); 272 refresh();
260 return; 273 return;
261 } 274 }
262 QRegExp re = getRegExp( s ); 275 QRegExp re = getRegExp( s );
263 if (!re.isValid()) 276 if (!re.isValid())
264 return; 277 return;
265 KABC::Addressee::List addresseeList = addressees(); 278 KABC::Addressee::List addresseeList = addressees();
266 KABC::Addressee::List::Iterator it; 279 KABC::Addressee::List::Iterator it;
267 if ( field ) { 280 if ( field ) {
268 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 281 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
269 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 282 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
270 continue; 283 continue;
271#if QT_VERSION >= 0x030000 284#if QT_VERSION >= 0x030000
272 if (re.search(field->value( *it ).lower()) == 0) 285 if (re.search(field->value( *it ).lower()) == 0)
273#else 286#else
274 if (re.match(field->value( *it ).lower()) == 0) 287 if (re.match(field->value( *it ).lower()) == 0)
275#endif 288#endif
276 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 289 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
277 290
278 291
279 } 292 }
280 } else { 293 } else {
281 KABC::Field::List fieldList = allFields(); 294 KABC::Field::List fieldList = allFields();
282 KABC::Field::List::ConstIterator fieldIt; 295 KABC::Field::List::ConstIterator fieldIt;
283 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 296 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
284 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 297 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
285 continue; 298 continue;
299 bool match = false;
286 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 300 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
287#if QT_VERSION >= 0x030000 301#if QT_VERSION >= 0x030000
288 if (re.search((*fieldIt)->value( *it ).lower()) == 0) 302 if (re.search((*fieldIt)->value( *it ).lower()) == 0)
289#else 303#else
290 if (re.match((*fieldIt)->value( *it ).lower()) == 0) 304 if (re.match((*fieldIt)->value( *it ).lower()) == 0)
291#endif 305#endif
292 { 306 {
293 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 307 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
308 match = true;
294 break; 309 break;
295 } 310 }
311 }
312 if ( ! match ) {
313 if ( (*it).matchPhoneNumber( &re ) ) {
314 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
315 match = true;
316 break;
317 }
318 }
319 if ( ! match ) {
320 if ( (*it).matchAddress( &re ) ) {
321 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
322 match = true;
323 break;
324 }
296 } 325 }
297 } 326 }
298 } 327 }
299 mIconView->arrangeItemsInGrid( true ); 328 mIconView->arrangeItemsInGrid( true );
300 if ( mIconView->firstItem() ) { 329 if ( mIconView->firstItem() ) {
301 mIconView->setCurrentItem ( mIconView->firstItem() ); 330 mIconView->setCurrentItem ( mIconView->firstItem() );
302 mIconView->setSelected ( mIconView->firstItem() , true ); 331 mIconView->setSelected ( mIconView->firstItem() , true );
303 } 332 }
304 else 333 else
305 emit selected(QString::null); 334 emit selected(QString::null);
306} 335}
307QStringList KAddressBookIconView::selectedUids() 336QStringList KAddressBookIconView::selectedUids()
308{ 337{
309 QStringList uidList; 338 QStringList uidList;
310 QIconViewItem *item; 339 QIconViewItem *item;
311 AddresseeIconViewItem *aItem; 340 AddresseeIconViewItem *aItem;
312 341
313 for (item = mIconView->firstItem(); item; item = item->nextItem()) 342 for (item = mIconView->firstItem(); item; item = item->nextItem())
314 { 343 {
315 if (item->isSelected()) 344 if (item->isSelected())
316 { 345 {
317#ifndef KAB_EMBEDDED 346#ifndef KAB_EMBEDDED
318 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 347 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
319#else //KAB_EMBEDDED 348#else //KAB_EMBEDDED
320 aItem = (AddresseeIconViewItem*)(item); 349 aItem = (AddresseeIconViewItem*)(item);
321#endif //KAB_EMBEDDED 350#endif //KAB_EMBEDDED
322 if (aItem) 351 if (aItem)
323 uidList << aItem->addressee().uid(); 352 uidList << aItem->addressee().uid();
324 } 353 }
325 } 354 }
326 355
327 return uidList; 356 return uidList;
328} 357}
329 358
330void KAddressBookIconView::refresh(QString uid) 359void KAddressBookIconView::refresh(QString uid)
331{ 360{
332 QIconViewItem *item; 361 QIconViewItem *item;
333 AddresseeIconViewItem *aItem; 362 AddresseeIconViewItem *aItem;
334 363
335 if ( uid.isNull() ) { 364 if ( uid.isNull() ) {
336 // Rebuild the view 365 // Rebuild the view
337 mIconView->clear(); 366 mIconView->clear();
338 mIconList.clear(); 367 mIconList.clear();
339 368
340 KABC::Addressee::List addresseeList = addressees(); 369 KABC::Addressee::List addresseeList = addressees();
341 KABC::Addressee::List::Iterator iter; 370 KABC::Addressee::List::Iterator iter;
342 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) { 371 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) {
343 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) 372 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") )
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index 348f491..02fc40a 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -125,108 +125,124 @@ void KAddressBookTableView::reconstructListView()
125 // qDebug("KAddressBookTableView::reconstructListView double"); 125 // qDebug("KAddressBookTableView::reconstructListView double");
126 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 126 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
127 this, SLOT(addresseeExecuted(QListViewItem*))); 127 this, SLOT(addresseeExecuted(QListViewItem*)));
128 } 128 }
129 connect(mListView, SIGNAL(returnPressed(QListViewItem*)), 129 connect(mListView, SIGNAL(returnPressed(QListViewItem*)),
130 this, SLOT(addresseeExecuted(QListViewItem*))); 130 this, SLOT(addresseeExecuted(QListViewItem*)));
131 connect(mListView, SIGNAL(signalDelete()), 131 connect(mListView, SIGNAL(signalDelete()),
132 this, SLOT(addresseeDeleted())); 132 this, SLOT(addresseeDeleted()));
133 133
134//US performceimprovement. Refresh is done from the outside 134//US performceimprovement. Refresh is done from the outside
135//US refresh(); 135//US refresh();
136 136
137 mListView->setSorting( 0, true ); 137 mListView->setSorting( 0, true );
138 mainLayout->addWidget( mListView ); 138 mainLayout->addWidget( mListView );
139 mainLayout->activate(); 139 mainLayout->activate();
140 mListView->show(); 140 mListView->show();
141} 141}
142 142
143void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) 143void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
144{ 144{
145 mListView->clear(); 145 mListView->clear();
146 if ( s.isEmpty() || s == "*" ) { 146 if ( s.isEmpty() || s == "*" ) {
147 refresh(); 147 refresh();
148 return; 148 return;
149 } 149 }
150 QRegExp re = getRegExp( s ); 150 QRegExp re = getRegExp( s );
151 if (!re.isValid()) 151 if (!re.isValid())
152 return; 152 return;
153 KABC::Addressee::List addresseeList = addressees(); 153 KABC::Addressee::List addresseeList = addressees();
154 KABC::Addressee::List::Iterator it; 154 KABC::Addressee::List::Iterator it;
155 if ( field ) { 155 if ( field ) {
156 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 156 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
157 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 157 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
158 continue; 158 continue;
159#if QT_VERSION >= 0x030000 159#if QT_VERSION >= 0x030000
160 if (re.search(field->value( *it ).lower()) == 0) 160 if (re.search(field->value( *it ).lower()) == 0)
161#else 161#else
162 if (re.match(field->value( *it ).lower()) == 0) 162 if (re.match(field->value( *it ).lower()) == 0)
163#endif 163#endif
164 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 164 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
165 165
166 } 166 }
167 } else { 167 } else {
168 KABC::Field::List fieldList = allFields(); 168 KABC::Field::List fieldList = allFields();
169 KABC::Field::List::ConstIterator fieldIt; 169 KABC::Field::List::ConstIterator fieldIt;
170 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 170 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
171 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 171 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
172 continue; 172 continue;
173 bool match = false;
173 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 174 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
174#if QT_VERSION >= 0x030000 175#if QT_VERSION >= 0x030000
175 if (re.search((*fieldIt)->value( *it ).lower()) == 0) 176 if (re.search((*fieldIt)->value( *it ).lower()) == 0)
176#else 177#else
177 if (re.match((*fieldIt)->value( *it ).lower()) == 0) 178 if (re.match((*fieldIt)->value( *it ).lower()) == 0)
178#endif 179#endif
179 { 180 {
180 //qDebug("match %s %s %s", pattern.latin1(), (*fieldIt)->value( *it ).latin1(), (*fieldIt)->label().latin1() ); 181 //qDebug("match %s %s %s", pattern.latin1(), (*fieldIt)->value( *it ).latin1(), (*fieldIt)->label().latin1() );
181 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 182 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
183 match = true;
182 break; 184 break;
183 } 185 }
184 } 186 }
187 if ( ! match ) {
188 if ( (*it).matchPhoneNumber( &re ) ) {
189 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
190 match = true;
191 break;
192 }
193 }
194 if ( ! match ) {
195 if ( (*it).matchAddress( &re ) ) {
196 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
197 match = true;
198 break;
199 }
200 }
185 } 201 }
186 } 202 }
187 // Sometimes the background pixmap gets messed up when we add lots 203 // Sometimes the background pixmap gets messed up when we add lots
188 // of items. 204 // of items.
189 //mListView->repaint(); 205 //mListView->repaint();
190 if ( mListView->firstChild() ) { 206 if ( mListView->firstChild() ) {
191 mListView->setCurrentItem ( mListView->firstChild() ); 207 mListView->setCurrentItem ( mListView->firstChild() );
192 mListView->setSelected ( mListView->firstChild(), true ); 208 mListView->setSelected ( mListView->firstChild(), true );
193 } 209 }
194 else 210 else
195 emit selected(QString::null); 211 emit selected(QString::null);
196 212
197} 213}
198void KAddressBookTableView::writeConfig(KConfig *config) 214void KAddressBookTableView::writeConfig(KConfig *config)
199{ 215{
200 KAddressBookView::writeConfig(config); 216 KAddressBookView::writeConfig(config);
201 217
202 mListView->saveLayout(config, config->group()); 218 mListView->saveLayout(config, config->group());
203} 219}
204 220
205void KAddressBookTableView::readConfig(KConfig *config) 221void KAddressBookTableView::readConfig(KConfig *config)
206{ 222{
207 KAddressBookView::readConfig( config ); 223 KAddressBookView::readConfig( config );
208 // The config could have changed the fields, so we need to reconstruct 224 // The config could have changed the fields, so we need to reconstruct
209 // the listview. 225 // the listview.
210 reconstructListView(); 226 reconstructListView();
211 227
212 // costum colors? 228 // costum colors?
213 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 229 if ( config->readBoolEntry( "EnableCustomColors", false ) )
214 { 230 {
215 QPalette p( mListView->palette() ); 231 QPalette p( mListView->palette() );
216 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 232 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
217 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 233 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
218 c = p.color(QPalette::Normal, QColorGroup::Text ); 234 c = p.color(QPalette::Normal, QColorGroup::Text );
219 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 235 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
220 c = p.color(QPalette::Normal, QColorGroup::Button ); 236 c = p.color(QPalette::Normal, QColorGroup::Button );
221 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 237 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
222 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 238 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
223 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 239 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
224 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 240 c = p.color(QPalette::Normal, QColorGroup::Highlight );
225 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 241 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
226 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 242 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
227 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 243 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
228#ifndef KAB_EMBEDDED 244#ifndef KAB_EMBEDDED
229 c = KGlobalSettings::alternateBackgroundColor(); 245 c = KGlobalSettings::alternateBackgroundColor();
230#else //KAB_EMBEDDED 246#else //KAB_EMBEDDED
231 c = QColor(240, 240, 240); 247 c = QColor(240, 240, 240);
232#endif //KAB_EMBEDDED 248#endif //KAB_EMBEDDED