-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 22 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.cpp | 39 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 16 |
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 | |||
@@ -320,36 +320,54 @@ void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) | |||
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 | } |
355 | QStringList KAddressBookCardView::selectedUids() | 373 | QStringList KAddressBookCardView::selectedUids() |
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 | |||
@@ -141,44 +141,57 @@ class AddresseeIconViewItem : public QIconViewItem | |||
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 | ||
@@ -274,34 +287,50 @@ void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) | |||
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 | } |
307 | QStringList KAddressBookIconView::selectedUids() | 336 | QStringList KAddressBookIconView::selectedUids() |
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 | |||
@@ -161,36 +161,52 @@ void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | |||
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 | ||