-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index 107be59..6fcd73f 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp | |||
@@ -149,359 +149,359 @@ void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) | |||
149 | { | 149 | { |
150 | #ifndef KAB_EMBEDDED | 150 | #ifndef KAB_EMBEDDED |
151 | if (QTextDrag::canDecode(e)) | 151 | if (QTextDrag::canDecode(e)) |
152 | e->accept(); | 152 | e->accept(); |
153 | #else //KAB_EMBEDDED | 153 | #else //KAB_EMBEDDED |
154 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); | 154 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); |
155 | #endif //KAB_EMBEDDED | 155 | #endif //KAB_EMBEDDED |
156 | } | 156 | } |
157 | 157 | ||
158 | void AddresseeCardView::dropEvent(QDropEvent *e) | 158 | void AddresseeCardView::dropEvent(QDropEvent *e) |
159 | { | 159 | { |
160 | emit addresseeDropped(e); | 160 | emit addresseeDropped(e); |
161 | } | 161 | } |
162 | 162 | ||
163 | void AddresseeCardView::startDrag() | 163 | void AddresseeCardView::startDrag() |
164 | { | 164 | { |
165 | emit startAddresseeDrag(); | 165 | emit startAddresseeDrag(); |
166 | } | 166 | } |
167 | 167 | ||
168 | 168 | ||
169 | /////////////////////////////// | 169 | /////////////////////////////// |
170 | // KAddressBookCardView | 170 | // KAddressBookCardView |
171 | 171 | ||
172 | KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, | 172 | KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, |
173 | QWidget *parent, const char *name ) | 173 | QWidget *parent, const char *name ) |
174 | : KAddressBookView( ab, parent, name ) | 174 | : KAddressBookView( ab, parent, name ) |
175 | { | 175 | { |
176 | mShowEmptyFields = false; | 176 | mShowEmptyFields = false; |
177 | 177 | ||
178 | // Init the GUI | 178 | // Init the GUI |
179 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); | 179 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); |
180 | 180 | ||
181 | mCardView = new AddresseeCardView(viewWidget(), "mCardView"); | 181 | mCardView = new AddresseeCardView(viewWidget(), "mCardView"); |
182 | mCardView->setSelectionMode(CardView::Extended); | 182 | mCardView->setSelectionMode(CardView::Extended); |
183 | layout->addWidget(mCardView); | 183 | layout->addWidget(mCardView); |
184 | 184 | ||
185 | // Connect up the signals | 185 | // Connect up the signals |
186 | connect(mCardView, SIGNAL(executed(CardViewItem *)), | 186 | connect(mCardView, SIGNAL(executed(CardViewItem *)), |
187 | this, SLOT(addresseeExecuted(CardViewItem *))); | 187 | this, SLOT(addresseeExecuted(CardViewItem *))); |
188 | connect(mCardView, SIGNAL(selectionChanged()), | 188 | connect(mCardView, SIGNAL(selectionChanged()), |
189 | this, SLOT(addresseeSelected())); | 189 | this, SLOT(addresseeSelected())); |
190 | connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), | 190 | connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), |
191 | this, SIGNAL(dropped(QDropEvent*))); | 191 | this, SIGNAL(dropped(QDropEvent*))); |
192 | connect(mCardView, SIGNAL(startAddresseeDrag()), | 192 | connect(mCardView, SIGNAL(startAddresseeDrag()), |
193 | this, SIGNAL(startDrag())); | 193 | this, SIGNAL(startDrag())); |
194 | connect(this, SIGNAL(printView()), | 194 | connect(this, SIGNAL(printView()), |
195 | mCardView , SLOT(printMe())); | 195 | mCardView , SLOT(printMe())); |
196 | } | 196 | } |
197 | 197 | ||
198 | KAddressBookCardView::~KAddressBookCardView() | 198 | KAddressBookCardView::~KAddressBookCardView() |
199 | { | 199 | { |
200 | } | 200 | } |
201 | void KAddressBookCardView::setFocusAV() | 201 | void KAddressBookCardView::setFocusAV() |
202 | { | 202 | { |
203 | if ( mCardView ) | 203 | if ( mCardView ) |
204 | mCardView->setFocus(); | 204 | mCardView->setFocus(); |
205 | 205 | ||
206 | } | 206 | } |
207 | void KAddressBookCardView::scrollUP() | 207 | void KAddressBookCardView::scrollUP() |
208 | { | 208 | { |
209 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); | 209 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); |
210 | QApplication::postEvent( mCardView, ev ); | 210 | QApplication::postEvent( mCardView, ev ); |
211 | 211 | ||
212 | } | 212 | } |
213 | void KAddressBookCardView::scrollDOWN() | 213 | void KAddressBookCardView::scrollDOWN() |
214 | { | 214 | { |
215 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); | 215 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); |
216 | QApplication::postEvent( mCardView, ev ); | 216 | QApplication::postEvent( mCardView, ev ); |
217 | } | 217 | } |
218 | void KAddressBookCardView::readConfig(KConfig *config) | 218 | void KAddressBookCardView::readConfig(KConfig *config) |
219 | { | 219 | { |
220 | KAddressBookView::readConfig(config); | 220 | KAddressBookView::readConfig(config); |
221 | 221 | ||
222 | // costum colors? | 222 | // costum colors? |
223 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 223 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
224 | { | 224 | { |
225 | QPalette p( mCardView->palette() ); | 225 | QPalette p( mCardView->palette() ); |
226 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 226 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
227 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 227 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
228 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 228 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
229 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 229 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
230 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 230 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
231 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 231 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
232 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 232 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
233 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 233 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
234 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 234 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
235 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 235 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
236 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 236 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
237 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 237 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
238 | mCardView->viewport()->setPalette( p ); | 238 | mCardView->viewport()->setPalette( p ); |
239 | } | 239 | } |
240 | else | 240 | else |
241 | { | 241 | { |
242 | // needed if turned off during a session. | 242 | // needed if turned off during a session. |
243 | mCardView->viewport()->setPalette( mCardView->palette() ); | 243 | mCardView->viewport()->setPalette( mCardView->palette() ); |
244 | } | 244 | } |
245 | 245 | ||
246 | //custom fonts? | 246 | //custom fonts? |
247 | QFont f( font() ); | 247 | QFont f( font() ); |
248 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 248 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
249 | { | 249 | { |
250 | mCardView->setFont( config->readFontEntry( "TextFont", &f) ); | 250 | mCardView->setFont( config->readFontEntry( "TextFont", &f) ); |
251 | f.setBold( true ); | 251 | f.setBold( true ); |
252 | mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 252 | mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
253 | } | 253 | } |
254 | else | 254 | else |
255 | { | 255 | { |
256 | mCardView->setFont( f ); | 256 | mCardView->setFont( f ); |
257 | f.setBold( true ); | 257 | f.setBold( true ); |
258 | mCardView->setHeaderFont( f ); | 258 | mCardView->setHeaderFont( f ); |
259 | } | 259 | } |
260 | 260 | ||
261 | mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); | 261 | mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); |
262 | mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", | 262 | mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", |
263 | true)); | 263 | true)); |
264 | mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); | 264 | mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); |
265 | mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); | 265 | mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); |
266 | 266 | ||
267 | mCardView->setShowEmptyFields( mShowEmptyFields ); | 267 | mCardView->setShowEmptyFields( mShowEmptyFields ); |
268 | 268 | ||
269 | mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); | 269 | mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); |
270 | mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); | 270 | mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); |
271 | mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); | 271 | mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); |
272 | mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); | 272 | mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); |
273 | 273 | ||
274 | #if 0 | 274 | #if 0 |
275 | // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven | 275 | // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven |
276 | disconnect(mCardView, SIGNAL(executed(CardViewItem *)), | 276 | disconnect(mCardView, SIGNAL(executed(CardViewItem *)), |
277 | this, SLOT(addresseeExecuted(CardViewItem *))); | 277 | this, SLOT(addresseeExecuted(CardViewItem *))); |
278 | 278 | ||
279 | if (KABPrefs::instance()->mHonorSingleClick) | 279 | if (KABPrefs::instance()->mHonorSingleClick) |
280 | connect(mCardView, SIGNAL(executed(CardViewItem *)), | 280 | connect(mCardView, SIGNAL(executed(CardViewItem *)), |
281 | this, SLOT(addresseeExecuted(CardViewItem *))); | 281 | this, SLOT(addresseeExecuted(CardViewItem *))); |
282 | else | 282 | else |
283 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), | 283 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), |
284 | this, SLOT(addresseeExecuted(CardViewItem *))); | 284 | this, SLOT(addresseeExecuted(CardViewItem *))); |
285 | #endif | 285 | #endif |
286 | 286 | ||
287 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), | 287 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), |
288 | this, SLOT(addresseeExecuted(CardViewItem *))); | 288 | this, SLOT(addresseeExecuted(CardViewItem *))); |
289 | } | 289 | } |
290 | 290 | ||
291 | void KAddressBookCardView::writeConfig( KConfig *config ) | 291 | void KAddressBookCardView::writeConfig( KConfig *config ) |
292 | { | 292 | { |
293 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); | 293 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); |
294 | KAddressBookView::writeConfig( config ); | 294 | KAddressBookView::writeConfig( config ); |
295 | } | 295 | } |
296 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) | 296 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) |
297 | { | 297 | { |
298 | mCardView->clear(); | 298 | mCardView->clear(); |
299 | if ( s.isEmpty() || s == "*" ) { | 299 | if ( s.isEmpty() || s == "*" ) { |
300 | refresh(); | 300 | refresh(); |
301 | return; | 301 | return; |
302 | } | 302 | } |
303 | QString pattern = s.lower()+"*"; | 303 | QString pattern = s.lower()+"*"; |
304 | QRegExp re; | 304 | QRegExp re; |
305 | re.setWildcard(true); // most people understand these better. | 305 | re.setWildcard(true); // most people understand these better. |
306 | re.setCaseSensitive(false); | 306 | re.setCaseSensitive(false); |
307 | re.setPattern( pattern ); | 307 | re.setPattern( pattern ); |
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 >= 300 | 317 | #if QT_VERSION >= 300 |
318 | if (re.search(field->value( *it ).lower()) != -1) | 318 | if (re.search(field->value( *it ).lower()) != -1) |
319 | #else | 319 | #else |
320 | if (re.match(field->value( *it ).lower()) != -1) | 320 | if (re.match(field->value( *it ).lower()) != -1) |
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 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 332 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
333 | #if QT_VERSION >= 300 | 333 | #if QT_VERSION >= 300 |
334 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 334 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
335 | #else | 335 | #else |
336 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 336 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
337 | #endif | 337 | #endif |
338 | { | 338 | { |
339 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | 339 | new AddresseeCardViewItem(fields(), mShowEmptyFields, |
340 | addressBook(), *it, mCardView); | 340 | addressBook(), *it, mCardView); |
341 | continue; | 341 | break; |
342 | } | 342 | } |
343 | } | 343 | } |
344 | } | 344 | } |
345 | } | 345 | } |
346 | mCardView->viewport()->setUpdatesEnabled( true ); | 346 | mCardView->viewport()->setUpdatesEnabled( true ); |
347 | mCardView->viewport()->update(); | 347 | mCardView->viewport()->update(); |
348 | if ( mCardView->firstItem() ) { | 348 | if ( mCardView->firstItem() ) { |
349 | mCardView->setCurrentItem ( mCardView->firstItem() ); | 349 | mCardView->setCurrentItem ( mCardView->firstItem() ); |
350 | mCardView->setSelected ( mCardView->firstItem() , true ); | 350 | mCardView->setSelected ( mCardView->firstItem() , true ); |
351 | } | 351 | } |
352 | else | 352 | else |
353 | emit selected(QString::null); | 353 | emit selected(QString::null); |
354 | } | 354 | } |
355 | QStringList KAddressBookCardView::selectedUids() | 355 | QStringList KAddressBookCardView::selectedUids() |
356 | { | 356 | { |
357 | QStringList uidList; | 357 | QStringList uidList; |
358 | CardViewItem *item; | 358 | CardViewItem *item; |
359 | AddresseeCardViewItem *aItem; | 359 | AddresseeCardViewItem *aItem; |
360 | 360 | ||
361 | for (item = mCardView->firstItem(); item; item = item->nextItem()) | 361 | for (item = mCardView->firstItem(); item; item = item->nextItem()) |
362 | { | 362 | { |
363 | if (item->isSelected()) | 363 | if (item->isSelected()) |
364 | { | 364 | { |
365 | #ifndef KAB_EMBEDDED | 365 | #ifndef KAB_EMBEDDED |
366 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 366 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
367 | #else //KAB_EMBEDDED | 367 | #else //KAB_EMBEDDED |
368 | aItem = (AddresseeCardViewItem*)(item); | 368 | aItem = (AddresseeCardViewItem*)(item); |
369 | #endif //KAB_EMBEDDED | 369 | #endif //KAB_EMBEDDED |
370 | if (aItem) | 370 | if (aItem) |
371 | uidList << aItem->addressee().uid(); | 371 | uidList << aItem->addressee().uid(); |
372 | } | 372 | } |
373 | } | 373 | } |
374 | 374 | ||
375 | return uidList; | 375 | return uidList; |
376 | } | 376 | } |
377 | 377 | ||
378 | void KAddressBookCardView::refresh(QString uid) | 378 | void KAddressBookCardView::refresh(QString uid) |
379 | { | 379 | { |
380 | CardViewItem *item; | 380 | CardViewItem *item; |
381 | AddresseeCardViewItem *aItem; | 381 | AddresseeCardViewItem *aItem; |
382 | 382 | ||
383 | if (uid.isNull()) | 383 | if (uid.isNull()) |
384 | { | 384 | { |
385 | // Rebuild the view | 385 | // Rebuild the view |
386 | mCardView->viewport()->setUpdatesEnabled( false ); | 386 | mCardView->viewport()->setUpdatesEnabled( false ); |
387 | mCardView->clear(); | 387 | mCardView->clear(); |
388 | 388 | ||
389 | KABC::Addressee::List addresseeList = addressees(); | 389 | KABC::Addressee::List addresseeList = addressees(); |
390 | KABC::Addressee::List::Iterator iter; | 390 | KABC::Addressee::List::Iterator iter; |
391 | for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) | 391 | for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) |
392 | { | 392 | { |
393 | if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) | 393 | if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) |
394 | continue; | 394 | continue; |
395 | aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, | 395 | aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, |
396 | addressBook(), *iter, mCardView); | 396 | addressBook(), *iter, mCardView); |
397 | } | 397 | } |
398 | mCardView->viewport()->setUpdatesEnabled( true ); | 398 | mCardView->viewport()->setUpdatesEnabled( true ); |
399 | mCardView->viewport()->update(); | 399 | mCardView->viewport()->update(); |
400 | 400 | ||
401 | // by default nothing is selected | 401 | // by default nothing is selected |
402 | emit selected(QString::null); | 402 | emit selected(QString::null); |
403 | } | 403 | } |
404 | else | 404 | else |
405 | { | 405 | { |
406 | // Try to find the one to refresh | 406 | // Try to find the one to refresh |
407 | bool found = false; | 407 | bool found = false; |
408 | for (item = mCardView->firstItem(); item && !found; | 408 | for (item = mCardView->firstItem(); item && !found; |
409 | item = item->nextItem()) | 409 | item = item->nextItem()) |
410 | { | 410 | { |
411 | #ifndef KAB_EMBEDDED | 411 | #ifndef KAB_EMBEDDED |
412 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 412 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
413 | #else //KAB_EMBEDDED | 413 | #else //KAB_EMBEDDED |
414 | aItem = (AddresseeCardViewItem*)(item); | 414 | aItem = (AddresseeCardViewItem*)(item); |
415 | #endif //KAB_EMBEDDED | 415 | #endif //KAB_EMBEDDED |
416 | 416 | ||
417 | if ((aItem) && (aItem->addressee().uid() == uid)) | 417 | if ((aItem) && (aItem->addressee().uid() == uid)) |
418 | { | 418 | { |
419 | aItem->refresh(); | 419 | aItem->refresh(); |
420 | found = true; | 420 | found = true; |
421 | } | 421 | } |
422 | } | 422 | } |
423 | } | 423 | } |
424 | } | 424 | } |
425 | 425 | ||
426 | void KAddressBookCardView::setSelected(QString uid, bool selected) | 426 | void KAddressBookCardView::setSelected(QString uid, bool selected) |
427 | { | 427 | { |
428 | CardViewItem *item; | 428 | CardViewItem *item; |
429 | AddresseeCardViewItem *aItem; | 429 | AddresseeCardViewItem *aItem; |
430 | 430 | ||
431 | if (uid.isNull()) | 431 | if (uid.isNull()) |
432 | { | 432 | { |
433 | mCardView->selectAll(selected); | 433 | mCardView->selectAll(selected); |
434 | } | 434 | } |
435 | else | 435 | else |
436 | { | 436 | { |
437 | bool found = false; | 437 | bool found = false; |
438 | for (item = mCardView->firstItem(); item && !found; | 438 | for (item = mCardView->firstItem(); item && !found; |
439 | item = item->nextItem()) | 439 | item = item->nextItem()) |
440 | { | 440 | { |
441 | #ifndef KAB_EMBEDDED | 441 | #ifndef KAB_EMBEDDED |
442 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 442 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
443 | #else //KAB_EMBEDDED | 443 | #else //KAB_EMBEDDED |
444 | aItem = (AddresseeCardViewItem*)(item); | 444 | aItem = (AddresseeCardViewItem*)(item); |
445 | #endif //KAB_EMBEDDED | 445 | #endif //KAB_EMBEDDED |
446 | 446 | ||
447 | if ((aItem) && (aItem->addressee().uid() == uid)) | 447 | if ((aItem) && (aItem->addressee().uid() == uid)) |
448 | { | 448 | { |
449 | mCardView->setSelected(aItem, selected); | 449 | mCardView->setSelected(aItem, selected); |
450 | mCardView->ensureItemVisible(item); | 450 | mCardView->ensureItemVisible(item); |
451 | found = true; | 451 | found = true; |
452 | } | 452 | } |
453 | } | 453 | } |
454 | } | 454 | } |
455 | } | 455 | } |
456 | 456 | ||
457 | //US added an additional method without parameter | 457 | //US added an additional method without parameter |
458 | void KAddressBookCardView::setSelected() | 458 | void KAddressBookCardView::setSelected() |
459 | { | 459 | { |
460 | setSelected(QString::null, true); | 460 | setSelected(QString::null, true); |
461 | } | 461 | } |
462 | 462 | ||
463 | void KAddressBookCardView::addresseeExecuted(CardViewItem *item) | 463 | void KAddressBookCardView::addresseeExecuted(CardViewItem *item) |
464 | { | 464 | { |
465 | #ifndef KAB_EMBEDDED | 465 | #ifndef KAB_EMBEDDED |
466 | AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 466 | AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
467 | #else //KAB_EMBEDDED | 467 | #else //KAB_EMBEDDED |
468 | AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); | 468 | AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); |
469 | #endif //KAB_EMBEDDED | 469 | #endif //KAB_EMBEDDED |
470 | if (aItem) | 470 | if (aItem) |
471 | { | 471 | { |
472 | //kdDebug()<<"... even has a valid item:)"<<endl; | 472 | //kdDebug()<<"... even has a valid item:)"<<endl; |
473 | emit executed(aItem->addressee().uid()); | 473 | emit executed(aItem->addressee().uid()); |
474 | } | 474 | } |
475 | } | 475 | } |
476 | 476 | ||
477 | void KAddressBookCardView::addresseeSelected() | 477 | void KAddressBookCardView::addresseeSelected() |
478 | { | 478 | { |
479 | CardViewItem *item; | 479 | CardViewItem *item; |
480 | AddresseeCardViewItem *aItem; | 480 | AddresseeCardViewItem *aItem; |
481 | 481 | ||
482 | bool found = false; | 482 | bool found = false; |
483 | for (item = mCardView->firstItem(); item && !found; | 483 | for (item = mCardView->firstItem(); item && !found; |
484 | item = item->nextItem()) | 484 | item = item->nextItem()) |
485 | { | 485 | { |
486 | if (item->isSelected()) | 486 | if (item->isSelected()) |
487 | { | 487 | { |
488 | #ifndef KAB_EMBEDDED | 488 | #ifndef KAB_EMBEDDED |
489 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 489 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
490 | #else //KAB_EMBEDDED | 490 | #else //KAB_EMBEDDED |
491 | aItem = (AddresseeCardViewItem*)(item); | 491 | aItem = (AddresseeCardViewItem*)(item); |
492 | #endif //KAB_EMBEDDED | 492 | #endif //KAB_EMBEDDED |
493 | if ( aItem ) | 493 | if ( aItem ) |
494 | { | 494 | { |
495 | emit selected(aItem->addressee().uid()); | 495 | emit selected(aItem->addressee().uid()); |
496 | found = true; | 496 | found = true; |
497 | } | 497 | } |
498 | } | 498 | } |
499 | } | 499 | } |
500 | 500 | ||
501 | if (!found) | 501 | if (!found) |
502 | emit selected(QString::null); | 502 | emit selected(QString::null); |
503 | 503 | ||
504 | } | 504 | } |
505 | #ifndef KAB_EMBEDDED | 505 | #ifndef KAB_EMBEDDED |
506 | #include "kaddressbookcardview.moc" | 506 | #include "kaddressbookcardview.moc" |
507 | #endif //KAB_EMBEDDED | 507 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp index faeda06..ef0a23a 100644 --- a/kaddressbook/views/kaddressbookiconview.cpp +++ b/kaddressbook/views/kaddressbookiconview.cpp | |||
@@ -106,351 +106,351 @@ void AddresseeIconView::itemDropped(QDropEvent *e, | |||
106 | } | 106 | } |
107 | 107 | ||
108 | QDragObject *AddresseeIconView::dragObject() | 108 | QDragObject *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 |
118 | class AddresseeIconViewItem : public KIconViewItem | 118 | class AddresseeIconViewItem : public KIconViewItem |
119 | #else //KAB_EMBEDDED | 119 | #else //KAB_EMBEDDED |
120 | class AddresseeIconViewItem : public QIconViewItem | 120 | class 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 | QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) ); |
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 | qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); | 166 | qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); |
167 | icon.convertFromImage(img.smoothScale(32, 32)); | 167 | icon.convertFromImage(img.smoothScale(32, 32)); |
168 | #endif //KAB_EMBEDDED | 168 | #endif //KAB_EMBEDDED |
169 | 169 | ||
170 | } else | 170 | } else |
171 | icon = defaultIcon; | 171 | icon = defaultIcon; |
172 | 172 | ||
173 | setPixmap( icon ); | 173 | setPixmap( icon ); |
174 | } | 174 | } |
175 | 175 | ||
176 | private: | 176 | private: |
177 | KABC::Field::List mFields; | 177 | KABC::Field::List mFields; |
178 | KABC::AddressBook *mDocument; | 178 | KABC::AddressBook *mDocument; |
179 | KABC::Addressee mAddressee; | 179 | KABC::Addressee mAddressee; |
180 | }; | 180 | }; |
181 | 181 | ||
182 | /////////////////////////////// | 182 | /////////////////////////////// |
183 | // KAddressBookView | 183 | // KAddressBookView |
184 | 184 | ||
185 | KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, | 185 | KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, |
186 | QWidget *parent, const char *name) | 186 | QWidget *parent, const char *name) |
187 | : KAddressBookView( ab, parent, name ) | 187 | : KAddressBookView( ab, parent, name ) |
188 | { | 188 | { |
189 | // Init the GUI | 189 | // Init the GUI |
190 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); | 190 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); |
191 | 191 | ||
192 | mIconView = new AddresseeIconView(viewWidget(), "mIconView"); | 192 | mIconView = new AddresseeIconView(viewWidget(), "mIconView"); |
193 | layout->addWidget(mIconView); | 193 | layout->addWidget(mIconView); |
194 | 194 | ||
195 | // Connect up the signals | 195 | // Connect up the signals |
196 | 196 | ||
197 | //US method executed is part of KIconView | 197 | //US method executed is part of KIconView |
198 | //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), | 198 | //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), |
199 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); | 199 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); |
200 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 200 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
201 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 201 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
202 | 202 | ||
203 | connect(mIconView, SIGNAL(selectionChanged()), | 203 | connect(mIconView, SIGNAL(selectionChanged()), |
204 | this, SLOT(addresseeSelected())); | 204 | this, SLOT(addresseeSelected())); |
205 | connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), | 205 | connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), |
206 | this, SIGNAL(dropped(QDropEvent*))); | 206 | this, SIGNAL(dropped(QDropEvent*))); |
207 | connect(mIconView, SIGNAL(startAddresseeDrag()), | 207 | connect(mIconView, SIGNAL(startAddresseeDrag()), |
208 | this, SIGNAL(startDrag())); | 208 | this, SIGNAL(startDrag())); |
209 | } | 209 | } |
210 | 210 | ||
211 | KAddressBookIconView::~KAddressBookIconView() | 211 | KAddressBookIconView::~KAddressBookIconView() |
212 | { | 212 | { |
213 | } | 213 | } |
214 | void KAddressBookIconView::setFocusAV() | 214 | void KAddressBookIconView::setFocusAV() |
215 | { | 215 | { |
216 | if ( mIconView ) | 216 | if ( mIconView ) |
217 | mIconView->setFocus(); | 217 | mIconView->setFocus(); |
218 | } | 218 | } |
219 | 219 | ||
220 | 220 | ||
221 | void KAddressBookIconView::scrollUP() | 221 | void 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 | } |
226 | void KAddressBookIconView::scrollDOWN() | 226 | void 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 | } |
231 | void KAddressBookIconView::readConfig(KConfig *config) | 231 | void 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 | } |
254 | void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) | 254 | void 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-") ) | 273 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
274 | continue; | 274 | continue; |
275 | #if QT_VERSION >= 300 | 275 | #if QT_VERSION >= 300 |
276 | if (re.search(field->value( *it ).lower()) != -1) | 276 | if (re.search(field->value( *it ).lower()) != -1) |
277 | #else | 277 | #else |
278 | if (re.match(field->value( *it ).lower()) != -1) | 278 | if (re.match(field->value( *it ).lower()) != -1) |
279 | #endif | 279 | #endif |
280 | mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); | 280 | mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); |
281 | 281 | ||
282 | 282 | ||
283 | } | 283 | } |
284 | } else { | 284 | } else { |
285 | KABC::Field::List fieldList = allFields(); | 285 | KABC::Field::List fieldList = allFields(); |
286 | KABC::Field::List::ConstIterator fieldIt; | 286 | KABC::Field::List::ConstIterator fieldIt; |
287 | 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-") ) | 288 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
289 | continue; | 289 | continue; |
290 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 290 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
291 | #if QT_VERSION >= 300 | 291 | #if QT_VERSION >= 300 |
292 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 292 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
293 | #else | 293 | #else |
294 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 294 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
295 | #endif | 295 | #endif |
296 | { | 296 | { |
297 | mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); | 297 | mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); |
298 | continue; | 298 | break; |
299 | } | 299 | } |
300 | } | 300 | } |
301 | } | 301 | } |
302 | } | 302 | } |
303 | mIconView->arrangeItemsInGrid( true ); | 303 | mIconView->arrangeItemsInGrid( true ); |
304 | if ( mIconView->firstItem() ) { | 304 | if ( mIconView->firstItem() ) { |
305 | mIconView->setCurrentItem ( mIconView->firstItem() ); | 305 | mIconView->setCurrentItem ( mIconView->firstItem() ); |
306 | mIconView->setSelected ( mIconView->firstItem() , true ); | 306 | mIconView->setSelected ( mIconView->firstItem() , true ); |
307 | } | 307 | } |
308 | else | 308 | else |
309 | emit selected(QString::null); | 309 | emit selected(QString::null); |
310 | } | 310 | } |
311 | QStringList KAddressBookIconView::selectedUids() | 311 | QStringList KAddressBookIconView::selectedUids() |
312 | { | 312 | { |
313 | QStringList uidList; | 313 | QStringList uidList; |
314 | QIconViewItem *item; | 314 | QIconViewItem *item; |
315 | AddresseeIconViewItem *aItem; | 315 | AddresseeIconViewItem *aItem; |
316 | 316 | ||
317 | for (item = mIconView->firstItem(); item; item = item->nextItem()) | 317 | for (item = mIconView->firstItem(); item; item = item->nextItem()) |
318 | { | 318 | { |
319 | if (item->isSelected()) | 319 | if (item->isSelected()) |
320 | { | 320 | { |
321 | #ifndef KAB_EMBEDDED | 321 | #ifndef KAB_EMBEDDED |
322 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 322 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
323 | #else //KAB_EMBEDDED | 323 | #else //KAB_EMBEDDED |
324 | aItem = (AddresseeIconViewItem*)(item); | 324 | aItem = (AddresseeIconViewItem*)(item); |
325 | #endif //KAB_EMBEDDED | 325 | #endif //KAB_EMBEDDED |
326 | if (aItem) | 326 | if (aItem) |
327 | uidList << aItem->addressee().uid(); | 327 | uidList << aItem->addressee().uid(); |
328 | } | 328 | } |
329 | } | 329 | } |
330 | 330 | ||
331 | return uidList; | 331 | return uidList; |
332 | } | 332 | } |
333 | 333 | ||
334 | void KAddressBookIconView::refresh(QString uid) | 334 | void KAddressBookIconView::refresh(QString uid) |
335 | { | 335 | { |
336 | QIconViewItem *item; | 336 | QIconViewItem *item; |
337 | AddresseeIconViewItem *aItem; | 337 | AddresseeIconViewItem *aItem; |
338 | 338 | ||
339 | if ( uid.isNull() ) { | 339 | if ( uid.isNull() ) { |
340 | // Rebuild the view | 340 | // Rebuild the view |
341 | mIconView->clear(); | 341 | mIconView->clear(); |
342 | mIconList.clear(); | 342 | mIconList.clear(); |
343 | 343 | ||
344 | KABC::Addressee::List addresseeList = addressees(); | 344 | KABC::Addressee::List addresseeList = addressees(); |
345 | KABC::Addressee::List::Iterator iter; | 345 | KABC::Addressee::List::Iterator iter; |
346 | for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) { | 346 | for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) { |
347 | 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-") ) |
348 | continue; | 348 | continue; |
349 | aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); | 349 | aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); |
350 | } | 350 | } |
351 | 351 | ||
352 | mIconView->arrangeItemsInGrid( true ); | 352 | mIconView->arrangeItemsInGrid( true ); |
353 | 353 | ||
354 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) | 354 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) |
355 | { | 355 | { |
356 | #ifndef KAB_EMBEDDED | 356 | #ifndef KAB_EMBEDDED |
357 | AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); | 357 | AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); |
358 | #else //KAB_EMBEDDED | 358 | #else //KAB_EMBEDDED |
359 | AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); | 359 | AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); |
360 | #endif //KAB_EMBEDDED | 360 | #endif //KAB_EMBEDDED |
361 | mIconList.append( aivi ); | 361 | mIconList.append( aivi ); |
362 | } | 362 | } |
363 | 363 | ||
364 | } else { | 364 | } else { |
365 | // Try to find the one to refresh | 365 | // Try to find the one to refresh |
366 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { | 366 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { |
367 | #ifndef KAB_EMBEDDED | 367 | #ifndef KAB_EMBEDDED |
368 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 368 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
369 | #else //KAB_EMBEDDED | 369 | #else //KAB_EMBEDDED |
370 | aItem = (AddresseeIconViewItem*)(item); | 370 | aItem = (AddresseeIconViewItem*)(item); |
371 | #endif //KAB_EMBEDDED | 371 | #endif //KAB_EMBEDDED |
372 | if ((aItem) && (aItem->addressee().uid() == uid)) { | 372 | if ((aItem) && (aItem->addressee().uid() == uid)) { |
373 | aItem->refresh(); | 373 | aItem->refresh(); |
374 | mIconView->arrangeItemsInGrid( true ); | 374 | mIconView->arrangeItemsInGrid( true ); |
375 | return; | 375 | return; |
376 | } | 376 | } |
377 | } | 377 | } |
378 | refresh( QString::null ); | 378 | refresh( QString::null ); |
379 | } | 379 | } |
380 | } | 380 | } |
381 | 381 | ||
382 | void KAddressBookIconView::setSelected(QString uid, bool selected) | 382 | void KAddressBookIconView::setSelected(QString uid, bool selected) |
383 | { | 383 | { |
384 | QIconViewItem *item; | 384 | QIconViewItem *item; |
385 | AddresseeIconViewItem *aItem; | 385 | AddresseeIconViewItem *aItem; |
386 | 386 | ||
387 | if (uid.isNull()) | 387 | if (uid.isNull()) |
388 | { | 388 | { |
389 | mIconView->selectAll(selected); | 389 | mIconView->selectAll(selected); |
390 | } | 390 | } |
391 | else | 391 | else |
392 | { | 392 | { |
393 | bool found = false; | 393 | bool found = false; |
394 | for (item = mIconView->firstItem(); item && !found; | 394 | for (item = mIconView->firstItem(); item && !found; |
395 | item = item->nextItem()) | 395 | item = item->nextItem()) |
396 | { | 396 | { |
397 | #ifndef KAB_EMBEDDED | 397 | #ifndef KAB_EMBEDDED |
398 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 398 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
399 | #else //KAB_EMBEDDED | 399 | #else //KAB_EMBEDDED |
400 | aItem = (AddresseeIconViewItem*)(item); | 400 | aItem = (AddresseeIconViewItem*)(item); |
401 | #endif //KAB_EMBEDDED | 401 | #endif //KAB_EMBEDDED |
402 | 402 | ||
403 | if ((aItem) && (aItem->addressee().uid() == uid)) | 403 | if ((aItem) && (aItem->addressee().uid() == uid)) |
404 | { | 404 | { |
405 | mIconView->setSelected(aItem, selected); | 405 | mIconView->setSelected(aItem, selected); |
406 | mIconView->ensureItemVisible( aItem ); | 406 | mIconView->ensureItemVisible( aItem ); |
407 | found = true; | 407 | found = true; |
408 | } | 408 | } |
409 | } | 409 | } |
410 | } | 410 | } |
411 | } | 411 | } |
412 | 412 | ||
413 | void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) | 413 | void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) |
414 | { | 414 | { |
415 | #ifndef KAB_EMBEDDED | 415 | #ifndef KAB_EMBEDDED |
416 | AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 416 | AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
417 | #else //KAB_EMBEDDED | 417 | #else //KAB_EMBEDDED |
418 | AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); | 418 | AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); |
419 | #endif //KAB_EMBEDDED | 419 | #endif //KAB_EMBEDDED |
420 | 420 | ||
421 | if (aItem) { | 421 | if (aItem) { |
422 | emit executed(aItem->addressee().uid()); | 422 | emit executed(aItem->addressee().uid()); |
423 | } | 423 | } |
424 | } | 424 | } |
425 | 425 | ||
426 | void KAddressBookIconView::addresseeSelected() | 426 | void KAddressBookIconView::addresseeSelected() |
427 | { | 427 | { |
428 | QIconViewItem *item; | 428 | QIconViewItem *item; |
429 | AddresseeIconViewItem *aItem; | 429 | AddresseeIconViewItem *aItem; |
430 | 430 | ||
431 | bool found = false; | 431 | bool found = false; |
432 | for (item = mIconView->firstItem(); item && !found; | 432 | for (item = mIconView->firstItem(); item && !found; |
433 | item = item->nextItem()) | 433 | item = item->nextItem()) |
434 | { | 434 | { |
435 | if (item->isSelected()) | 435 | if (item->isSelected()) |
436 | { | 436 | { |
437 | #ifndef KAB_EMBEDDED | 437 | #ifndef KAB_EMBEDDED |
438 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 438 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
439 | #else //KAB_EMBEDDED | 439 | #else //KAB_EMBEDDED |
440 | aItem = (AddresseeIconViewItem*)(item); | 440 | aItem = (AddresseeIconViewItem*)(item); |
441 | #endif //KAB_EMBEDDED | 441 | #endif //KAB_EMBEDDED |
442 | if (aItem) | 442 | if (aItem) |
443 | { | 443 | { |
444 | emit selected(aItem->addressee().uid()); | 444 | emit selected(aItem->addressee().uid()); |
445 | found = true; | 445 | found = true; |
446 | } | 446 | } |
447 | } | 447 | } |
448 | } | 448 | } |
449 | 449 | ||
450 | if (!found) | 450 | if (!found) |
451 | emit selected(QString::null); | 451 | emit selected(QString::null); |
452 | } | 452 | } |
453 | 453 | ||
454 | #ifndef KAB_EMBEDDED | 454 | #ifndef KAB_EMBEDDED |
455 | #include "kaddressbookiconview.moc" | 455 | #include "kaddressbookiconview.moc" |
456 | #endif //KAB_EMBEDDED | 456 | #endif //KAB_EMBEDDED |