-rw-r--r-- | kaddressbook/phoneeditwidget.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp index a435959..2bce39a 100644 --- a/kaddressbook/phoneeditwidget.cpp +++ b/kaddressbook/phoneeditwidget.cpp | |||
@@ -207,347 +207,350 @@ KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() | |||
207 | return retList; | 207 | return retList; |
208 | } | 208 | } |
209 | 209 | ||
210 | void PhoneEditWidget::edit() | 210 | void PhoneEditWidget::edit() |
211 | { | 211 | { |
212 | PhoneEditDialog dlg( mPhoneList, this ); | 212 | PhoneEditDialog dlg( mPhoneList, this ); |
213 | 213 | ||
214 | if ( dlg.exec() ) { | 214 | if ( dlg.exec() ) { |
215 | if ( dlg.changed() ) { | 215 | if ( dlg.changed() ) { |
216 | KABC::PhoneNumber::List list = dlg.phoneNumbers(); | 216 | KABC::PhoneNumber::List list = dlg.phoneNumbers(); |
217 | setPhoneNumbers( list ); | 217 | setPhoneNumbers( list ); |
218 | updateCombos(); | 218 | updateCombos(); |
219 | updateLineEdits(); | 219 | updateLineEdits(); |
220 | emit modified(); | 220 | emit modified(); |
221 | } | 221 | } |
222 | } | 222 | } |
223 | } | 223 | } |
224 | 224 | ||
225 | void PhoneEditWidget::updatePrefEdit() | 225 | void PhoneEditWidget::updatePrefEdit() |
226 | { | 226 | { |
227 | updateEdit( mPrefCombo ); | 227 | updateEdit( mPrefCombo ); |
228 | } | 228 | } |
229 | 229 | ||
230 | void PhoneEditWidget::updateSecondEdit() | 230 | void PhoneEditWidget::updateSecondEdit() |
231 | { | 231 | { |
232 | updateEdit( mSecondCombo ); | 232 | updateEdit( mSecondCombo ); |
233 | } | 233 | } |
234 | 234 | ||
235 | void PhoneEditWidget::updateThirdEdit() | 235 | void PhoneEditWidget::updateThirdEdit() |
236 | { | 236 | { |
237 | updateEdit( mThirdCombo ); | 237 | updateEdit( mThirdCombo ); |
238 | } | 238 | } |
239 | 239 | ||
240 | void PhoneEditWidget::updateFourthEdit() | 240 | void PhoneEditWidget::updateFourthEdit() |
241 | { | 241 | { |
242 | updateEdit( mFourthCombo ); | 242 | updateEdit( mFourthCombo ); |
243 | } | 243 | } |
244 | 244 | ||
245 | void PhoneEditWidget::updateEdit( PhoneTypeCombo *combo ) | 245 | void PhoneEditWidget::updateEdit( PhoneTypeCombo *combo ) |
246 | { | 246 | { |
247 | QLineEdit *edit = combo->lineEdit(); | 247 | QLineEdit *edit = combo->lineEdit(); |
248 | if ( !edit ) | 248 | if ( !edit ) |
249 | return; | 249 | return; |
250 | 250 | ||
251 | #if 0 | 251 | #if 0 |
252 | if ( edit == mPrefEdit ) kdDebug(5720) << " prefEdit" << endl; | 252 | if ( edit == mPrefEdit ) kdDebug(5720) << " prefEdit" << endl; |
253 | if ( edit == mSecondEdit ) kdDebug(5720) << " secondEdit" << endl; | 253 | if ( edit == mSecondEdit ) kdDebug(5720) << " secondEdit" << endl; |
254 | if ( edit == mThirdEdit ) kdDebug(5720) << " thirdEdit" << endl; | 254 | if ( edit == mThirdEdit ) kdDebug(5720) << " thirdEdit" << endl; |
255 | if ( edit == mFourthEdit ) kdDebug(5720) << " fourthEdit" << endl; | 255 | if ( edit == mFourthEdit ) kdDebug(5720) << " fourthEdit" << endl; |
256 | #endif | 256 | #endif |
257 | 257 | ||
258 | PhoneNumber::List::Iterator it = combo->selectedElement(); | 258 | PhoneNumber::List::Iterator it = combo->selectedElement(); |
259 | if ( it != mPhoneList.end() ) { | 259 | if ( it != mPhoneList.end() ) { |
260 | edit->setText( (*it).number() ); | 260 | edit->setText( (*it).number() ); |
261 | } else { | 261 | } else { |
262 | kdDebug(5720) << "PhoneEditWidget::updateEdit(): no selected element" << endl; | 262 | kdDebug(5720) << "PhoneEditWidget::updateEdit(): no selected element" << endl; |
263 | } | 263 | } |
264 | } | 264 | } |
265 | 265 | ||
266 | void PhoneEditWidget::slotPrefEditChanged() | 266 | void PhoneEditWidget::slotPrefEditChanged() |
267 | { | 267 | { |
268 | updatePhoneNumber( mPrefCombo ); | 268 | updatePhoneNumber( mPrefCombo ); |
269 | } | 269 | } |
270 | 270 | ||
271 | void PhoneEditWidget::slotSecondEditChanged() | 271 | void PhoneEditWidget::slotSecondEditChanged() |
272 | { | 272 | { |
273 | updatePhoneNumber( mSecondCombo ); | 273 | updatePhoneNumber( mSecondCombo ); |
274 | } | 274 | } |
275 | 275 | ||
276 | void PhoneEditWidget::slotThirdEditChanged() | 276 | void PhoneEditWidget::slotThirdEditChanged() |
277 | { | 277 | { |
278 | updatePhoneNumber( mThirdCombo ); | 278 | updatePhoneNumber( mThirdCombo ); |
279 | } | 279 | } |
280 | 280 | ||
281 | void PhoneEditWidget::slotFourthEditChanged() | 281 | void PhoneEditWidget::slotFourthEditChanged() |
282 | { | 282 | { |
283 | updatePhoneNumber( mFourthCombo ); | 283 | updatePhoneNumber( mFourthCombo ); |
284 | } | 284 | } |
285 | 285 | ||
286 | void PhoneEditWidget::updatePhoneNumber( PhoneTypeCombo *combo ) | 286 | void PhoneEditWidget::updatePhoneNumber( PhoneTypeCombo *combo ) |
287 | { | 287 | { |
288 | QLineEdit *edit = combo->lineEdit(); | 288 | QLineEdit *edit = combo->lineEdit(); |
289 | if ( !edit ) return; | 289 | if ( !edit ) return; |
290 | 290 | ||
291 | PhoneNumber::List::Iterator it = combo->selectedElement(); | 291 | PhoneNumber::List::Iterator it = combo->selectedElement(); |
292 | if ( it != mPhoneList.end() ) { | 292 | if ( it != mPhoneList.end() ) { |
293 | (*it).setNumber( edit->text() ); | 293 | (*it).setNumber( edit->text() ); |
294 | } | 294 | } |
295 | 295 | ||
296 | updateOtherEdit( combo, mPrefCombo ); | 296 | updateOtherEdit( combo, mPrefCombo ); |
297 | updateOtherEdit( combo, mSecondCombo ); | 297 | updateOtherEdit( combo, mSecondCombo ); |
298 | updateOtherEdit( combo, mThirdCombo ); | 298 | updateOtherEdit( combo, mThirdCombo ); |
299 | updateOtherEdit( combo, mFourthCombo ); | 299 | updateOtherEdit( combo, mFourthCombo ); |
300 | 300 | ||
301 | emit modified(); | 301 | emit modified(); |
302 | } | 302 | } |
303 | 303 | ||
304 | void PhoneEditWidget::updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo ) | 304 | void PhoneEditWidget::updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo ) |
305 | { | 305 | { |
306 | if ( combo == otherCombo ) return; | 306 | if ( combo == otherCombo ) return; |
307 | 307 | ||
308 | if ( combo->currentItem() == otherCombo->currentItem() ) { | 308 | if ( combo->currentItem() == otherCombo->currentItem() ) { |
309 | updateEdit( otherCombo ); | 309 | updateEdit( otherCombo ); |
310 | } | 310 | } |
311 | } | 311 | } |
312 | 312 | ||
313 | /////////////////////////////////////////// | 313 | /////////////////////////////////////////// |
314 | // PhoneEditDialog | 314 | // PhoneEditDialog |
315 | 315 | ||
316 | class PhoneViewItem : public QListViewItem | 316 | class PhoneViewItem : public QListViewItem |
317 | { | 317 | { |
318 | public: | 318 | public: |
319 | PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ); | 319 | PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ); |
320 | 320 | ||
321 | void setPhoneNumber( const KABC::PhoneNumber &number ) | 321 | void setPhoneNumber( const KABC::PhoneNumber &number ) |
322 | { | 322 | { |
323 | mPhoneNumber = number; | 323 | mPhoneNumber = number; |
324 | makeText(); | 324 | makeText(); |
325 | } | 325 | } |
326 | 326 | ||
327 | QString key() { return mPhoneNumber.id(); } | 327 | QString key() { return mPhoneNumber.id(); } |
328 | QString country() { return ""; } | 328 | QString country() { return ""; } |
329 | QString region() { return ""; } | 329 | QString region() { return ""; } |
330 | QString number() { return ""; } | 330 | QString number() { return ""; } |
331 | 331 | ||
332 | KABC::PhoneNumber phoneNumber() { return mPhoneNumber; } | 332 | KABC::PhoneNumber phoneNumber() { return mPhoneNumber; } |
333 | 333 | ||
334 | private: | 334 | private: |
335 | void makeText(); | 335 | void makeText(); |
336 | 336 | ||
337 | KABC::PhoneNumber mPhoneNumber; | 337 | KABC::PhoneNumber mPhoneNumber; |
338 | }; | 338 | }; |
339 | 339 | ||
340 | PhoneViewItem::PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ) | 340 | PhoneViewItem::PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ) |
341 | : QListViewItem( parent ), mPhoneNumber( number ) | 341 | : QListViewItem( parent ), mPhoneNumber( number ) |
342 | { | 342 | { |
343 | #ifdef DESKTOP_VERSION | 343 | #ifdef DESKTOP_VERSION |
344 | setRenameEnabled ( 0, true ); | 344 | setRenameEnabled ( 0, true ); |
345 | #endif | 345 | #endif |
346 | makeText(); | 346 | makeText(); |
347 | } | 347 | } |
348 | 348 | ||
349 | void PhoneViewItem::makeText() | 349 | void PhoneViewItem::makeText() |
350 | { | 350 | { |
351 | /** | 351 | /** |
352 | * Will be used in future versions of kaddressbook/libkabc | 352 | * Will be used in future versions of kaddressbook/libkabc |
353 | 353 | ||
354 | setText( 0, mPhoneNumber.country() ); | 354 | setText( 0, mPhoneNumber.country() ); |
355 | setText( 1, mPhoneNumber.region() ); | 355 | setText( 1, mPhoneNumber.region() ); |
356 | setText( 2, mPhoneNumber.number() ); | 356 | setText( 2, mPhoneNumber.number() ); |
357 | setText( 3, mPhoneNumber.typeLabel() ); | 357 | setText( 3, mPhoneNumber.typeLabel() ); |
358 | */ | 358 | */ |
359 | 359 | ||
360 | setText( 0, mPhoneNumber.number() ); | 360 | setText( 0, mPhoneNumber.number() ); |
361 | setText( 1, mPhoneNumber.typeLabel() ); | 361 | setText( 1, mPhoneNumber.typeLabel() ); |
362 | } | 362 | } |
363 | 363 | ||
364 | PhoneEditDialog::PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name ) | 364 | PhoneEditDialog::PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name ) |
365 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Numbers" ), | 365 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Numbers" ), |
366 | KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, | 366 | KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, |
367 | parent, name, true) | 367 | parent, name, true) |
368 | { | 368 | { |
369 | mPhoneNumberList = list; | 369 | mPhoneNumberList = list; |
370 | 370 | ||
371 | QWidget *page = plainPage(); | 371 | QWidget *page = plainPage(); |
372 | 372 | ||
373 | QGridLayout *layout = new QGridLayout( page, 1, 2 ); | 373 | QGridLayout *layout = new QGridLayout( page, 1, 2 ); |
374 | layout->setSpacing( spacingHint() ); | 374 | layout->setSpacing( spacingHint() ); |
375 | 375 | ||
376 | mListView = new KListView( page ); | 376 | mListView = new KListView( page ); |
377 | mListView->setAllColumnsShowFocus( true ); | 377 | mListView->setAllColumnsShowFocus( true ); |
378 | mListView->addColumn( i18n( "Number" ) ); | 378 | mListView->addColumn( i18n( "Number" ) ); |
379 | mListView->addColumn( i18n( "Type" ) ); | 379 | mListView->addColumn( i18n( "Type" ) ); |
380 | 380 | ||
381 | KButtonBox *buttonBox = new KButtonBox( page, Vertical ); | 381 | KButtonBox *buttonBox = new KButtonBox( page, Vertical ); |
382 | 382 | ||
383 | buttonBox->addButton( i18n( "&Add..." ), this, SLOT( slotAddPhoneNumber() ) ); | 383 | buttonBox->addButton( i18n( "&Add..." ), this, SLOT( slotAddPhoneNumber() ) ); |
384 | mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( slotEditPhoneNumber() ) ); | 384 | mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( slotEditPhoneNumber() ) ); |
385 | mEditButton->setEnabled( false ); | 385 | mEditButton->setEnabled( false ); |
386 | mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( slotRemovePhoneNumber() ) ); | 386 | mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( slotRemovePhoneNumber() ) ); |
387 | mRemoveButton->setEnabled( false ); | 387 | mRemoveButton->setEnabled( false ); |
388 | buttonBox->layout(); | 388 | buttonBox->layout(); |
389 | 389 | ||
390 | layout->addWidget( mListView, 0, 0 ); | 390 | layout->addWidget( mListView, 0, 0 ); |
391 | layout->addWidget( buttonBox, 0, 1 ); | 391 | layout->addWidget( buttonBox, 0, 1 ); |
392 | 392 | ||
393 | connect( mListView, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged()) ); | 393 | connect( mListView, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged()) ); |
394 | connect( mListView, SIGNAL(doubleClicked( QListViewItem *, const QPoint &, int )), this, SLOT( slotEditPhoneNumber())); | 394 | connect( mListView, SIGNAL(doubleClicked( QListViewItem *, const QPoint &, int )), this, SLOT( slotEditPhoneNumber())); |
395 | 395 | ||
396 | KABC::PhoneNumber::List::Iterator it; | 396 | KABC::PhoneNumber::List::Iterator it; |
397 | for ( it = mPhoneNumberList.begin(); it != mPhoneNumberList.end(); ++it ) | 397 | for ( it = mPhoneNumberList.begin(); it != mPhoneNumberList.end(); ++it ) |
398 | new PhoneViewItem( mListView, *it ); | 398 | new PhoneViewItem( mListView, *it ); |
399 | 399 | if (QApplication::desktop()->width() < 480 ) | |
400 | showMaximized(); | ||
401 | else | ||
402 | resize( 400, 400 ); | ||
400 | mChanged = false; | 403 | mChanged = false; |
401 | } | 404 | } |
402 | 405 | ||
403 | PhoneEditDialog::~PhoneEditDialog() | 406 | PhoneEditDialog::~PhoneEditDialog() |
404 | { | 407 | { |
405 | } | 408 | } |
406 | 409 | ||
407 | void PhoneEditDialog::slotAddPhoneNumber() | 410 | void PhoneEditDialog::slotAddPhoneNumber() |
408 | { | 411 | { |
409 | KABC::PhoneNumber tmp( "", 0 ); | 412 | KABC::PhoneNumber tmp( "", 0 ); |
410 | PhoneTypeDialog dlg( tmp, this ); | 413 | PhoneTypeDialog dlg( tmp, this ); |
411 | 414 | ||
412 | if ( dlg.exec() ) { | 415 | if ( dlg.exec() ) { |
413 | QListViewItem* i = mListView->firstChild(); | 416 | QListViewItem* i = mListView->firstChild(); |
414 | KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); | 417 | KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); |
415 | bool insert = true; | 418 | bool insert = true; |
416 | while ( i ) { | 419 | while ( i ) { |
417 | PhoneViewItem* p = ( PhoneViewItem* ) i; | 420 | PhoneViewItem* p = ( PhoneViewItem* ) i; |
418 | KABC::PhoneNumber pn = p->phoneNumber(); | 421 | KABC::PhoneNumber pn = p->phoneNumber(); |
419 | if ( (pn.type() | KABC::PhoneNumber::Pref) == (phoneNumber.type() | KABC::PhoneNumber::Pref) ) { | 422 | if ( (pn.type() | KABC::PhoneNumber::Pref) == (phoneNumber.type() | KABC::PhoneNumber::Pref) ) { |
420 | if ( p->text(0).isEmpty()) { | 423 | if ( p->text(0).isEmpty()) { |
421 | p->setPhoneNumber( phoneNumber ); | 424 | p->setPhoneNumber( phoneNumber ); |
422 | mPhoneNumberList.remove( pn ); | 425 | mPhoneNumberList.remove( pn ); |
423 | mPhoneNumberList.append( phoneNumber ); | 426 | mPhoneNumberList.append( phoneNumber ); |
424 | insert = false; | 427 | insert = false; |
425 | break; | 428 | break; |
426 | } | 429 | } |
427 | } | 430 | } |
428 | i = i->nextSibling(); | 431 | i = i->nextSibling(); |
429 | } | 432 | } |
430 | if ( insert ) { | 433 | if ( insert ) { |
431 | mPhoneNumberList.append( phoneNumber ); | 434 | mPhoneNumberList.append( phoneNumber ); |
432 | new PhoneViewItem( mListView, phoneNumber ); | 435 | new PhoneViewItem( mListView, phoneNumber ); |
433 | } | 436 | } |
434 | mChanged = true; | 437 | mChanged = true; |
435 | } | 438 | } |
436 | } | 439 | } |
437 | 440 | ||
438 | void PhoneEditDialog::slotRemovePhoneNumber() | 441 | void PhoneEditDialog::slotRemovePhoneNumber() |
439 | { | 442 | { |
440 | PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); | 443 | PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); |
441 | if ( !item ) | 444 | if ( !item ) |
442 | return; | 445 | return; |
443 | 446 | ||
444 | mPhoneNumberList.remove( item->phoneNumber() ); | 447 | mPhoneNumberList.remove( item->phoneNumber() ); |
445 | QListViewItem *currItem = mListView->currentItem(); | 448 | QListViewItem *currItem = mListView->currentItem(); |
446 | mListView->takeItem( currItem ); | 449 | mListView->takeItem( currItem ); |
447 | delete currItem; | 450 | delete currItem; |
448 | 451 | ||
449 | mChanged = true; | 452 | mChanged = true; |
450 | } | 453 | } |
451 | 454 | ||
452 | void PhoneEditDialog::slotEditPhoneNumber() | 455 | void PhoneEditDialog::slotEditPhoneNumber() |
453 | { | 456 | { |
454 | PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); | 457 | PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); |
455 | if ( !item ) | 458 | if ( !item ) |
456 | return; | 459 | return; |
457 | 460 | ||
458 | PhoneTypeDialog dlg( item->phoneNumber(), this ); | 461 | PhoneTypeDialog dlg( item->phoneNumber(), this ); |
459 | 462 | ||
460 | if ( dlg.exec() ) { | 463 | if ( dlg.exec() ) { |
461 | slotRemovePhoneNumber(); | 464 | slotRemovePhoneNumber(); |
462 | KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); | 465 | KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); |
463 | mPhoneNumberList.append( phoneNumber ); | 466 | mPhoneNumberList.append( phoneNumber ); |
464 | new PhoneViewItem( mListView, phoneNumber ); | 467 | new PhoneViewItem( mListView, phoneNumber ); |
465 | 468 | ||
466 | mChanged = true; | 469 | mChanged = true; |
467 | } | 470 | } |
468 | } | 471 | } |
469 | 472 | ||
470 | void PhoneEditDialog::slotSelectionChanged() | 473 | void PhoneEditDialog::slotSelectionChanged() |
471 | { | 474 | { |
472 | bool state = ( mListView->currentItem() != 0 ); | 475 | bool state = ( mListView->currentItem() != 0 ); |
473 | 476 | ||
474 | mRemoveButton->setEnabled( state ); | 477 | mRemoveButton->setEnabled( state ); |
475 | mEditButton->setEnabled( state ); | 478 | mEditButton->setEnabled( state ); |
476 | } | 479 | } |
477 | 480 | ||
478 | const KABC::PhoneNumber::List &PhoneEditDialog::phoneNumbers() | 481 | const KABC::PhoneNumber::List &PhoneEditDialog::phoneNumbers() |
479 | { | 482 | { |
480 | return mPhoneNumberList; | 483 | return mPhoneNumberList; |
481 | } | 484 | } |
482 | 485 | ||
483 | bool PhoneEditDialog::changed() const | 486 | bool PhoneEditDialog::changed() const |
484 | { | 487 | { |
485 | return mChanged; | 488 | return mChanged; |
486 | } | 489 | } |
487 | 490 | ||
488 | /////////////////////////////////////////// | 491 | /////////////////////////////////////////// |
489 | // PhoneTypeDialog | 492 | // PhoneTypeDialog |
490 | PhoneTypeDialog::PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, | 493 | PhoneTypeDialog::PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, |
491 | QWidget *parent, const char *name) | 494 | QWidget *parent, const char *name) |
492 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Number" ), | 495 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Number" ), |
493 | KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, | 496 | KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, |
494 | parent, name, true), mPhoneNumber( phoneNumber ) | 497 | parent, name, true), mPhoneNumber( phoneNumber ) |
495 | { | 498 | { |
496 | QWidget *page = plainPage(); | 499 | QWidget *page = plainPage(); |
497 | QLabel *label = 0; | 500 | QLabel *label = 0; |
498 | QGridLayout *layout = new QGridLayout( page, 3, 2, marginHint(), spacingHint() ); | 501 | QGridLayout *layout = new QGridLayout( page, 3, 2, marginHint(), spacingHint() ); |
499 | 502 | ||
500 | label = new QLabel( i18n( "Number:" ), page ); | 503 | label = new QLabel( i18n( "Number:" ), page ); |
501 | layout->addWidget( label, 0, 0 ); | 504 | layout->addWidget( label, 0, 0 ); |
502 | mNumber = new KLineEdit( page ); | 505 | mNumber = new KLineEdit( page ); |
503 | layout->addWidget( mNumber, 0, 1 ); | 506 | layout->addWidget( mNumber, 0, 1 ); |
504 | 507 | ||
505 | mPreferredBox = new QCheckBox( i18n( "This is the preferred phone number" ), page ); | 508 | mPreferredBox = new QCheckBox( i18n( "This is the preferred phone number" ), page ); |
506 | layout->addMultiCellWidget( mPreferredBox, 1, 1, 0, 1 ); | 509 | layout->addMultiCellWidget( mPreferredBox, 1, 1, 0, 1 ); |
507 | 510 | ||
508 | mGroup = new QButtonGroup( 2, Horizontal, i18n( "Types" ), page ); | 511 | mGroup = new QButtonGroup( 2, Horizontal, i18n( "Types" ), page ); |
509 | layout->addMultiCellWidget( mGroup, 2, 2, 0, 1 ); | 512 | layout->addMultiCellWidget( mGroup, 2, 2, 0, 1 ); |
510 | 513 | ||
511 | // fill widgets | 514 | // fill widgets |
512 | mNumber->setText( mPhoneNumber.number() ); | 515 | mNumber->setText( mPhoneNumber.number() ); |
513 | 516 | ||
514 | mTypeList = KABC::PhoneNumber::typeList(); | 517 | mTypeList = KABC::PhoneNumber::typeList(); |
515 | mTypeList.remove( KABC::PhoneNumber::Pref ); | 518 | mTypeList.remove( KABC::PhoneNumber::Pref ); |
516 | 519 | ||
517 | KABC::PhoneNumber::TypeList::Iterator it; | 520 | KABC::PhoneNumber::TypeList::Iterator it; |
518 | for ( it = mTypeList.begin(); it != mTypeList.end(); ++it ) | 521 | for ( it = mTypeList.begin(); it != mTypeList.end(); ++it ) |
519 | new QCheckBox( KABC::PhoneNumber::typeLabel( *it ), mGroup ); | 522 | new QCheckBox( KABC::PhoneNumber::typeLabel( *it ), mGroup ); |
520 | 523 | ||
521 | for ( int i = 0; i < mGroup->count(); ++i ) { | 524 | for ( int i = 0; i < mGroup->count(); ++i ) { |
522 | int type = mPhoneNumber.type(); | 525 | int type = mPhoneNumber.type(); |
523 | QCheckBox *box = (QCheckBox*)mGroup->find( i ); | 526 | QCheckBox *box = (QCheckBox*)mGroup->find( i ); |
524 | box->setChecked( type & mTypeList[ i ] ); | 527 | box->setChecked( type & mTypeList[ i ] ); |
525 | } | 528 | } |
526 | 529 | ||
527 | mPreferredBox->setChecked( mPhoneNumber.type() & KABC::PhoneNumber::Pref ); | 530 | mPreferredBox->setChecked( mPhoneNumber.type() & KABC::PhoneNumber::Pref ); |
528 | mNumber->setFocus(); | 531 | mNumber->setFocus(); |
529 | mNumber->setSelection( 0, 1024); | 532 | mNumber->setSelection( 0, 1024); |
530 | } | 533 | } |
531 | 534 | ||
532 | KABC::PhoneNumber PhoneTypeDialog::phoneNumber() | 535 | KABC::PhoneNumber PhoneTypeDialog::phoneNumber() |
533 | { | 536 | { |
534 | mPhoneNumber.setNumber( mNumber->text() ); | 537 | mPhoneNumber.setNumber( mNumber->text() ); |
535 | 538 | ||
536 | int type = 0; | 539 | int type = 0; |
537 | for ( int i = 0; i < mGroup->count(); ++i ) { | 540 | for ( int i = 0; i < mGroup->count(); ++i ) { |
538 | QCheckBox *box = (QCheckBox*)mGroup->find( i ); | 541 | QCheckBox *box = (QCheckBox*)mGroup->find( i ); |
539 | if ( box->isChecked() ) | 542 | if ( box->isChecked() ) |
540 | type += mTypeList[ i ]; | 543 | type += mTypeList[ i ]; |
541 | } | 544 | } |
542 | 545 | ||
543 | if ( mPreferredBox->isChecked() ) | 546 | if ( mPreferredBox->isChecked() ) |
544 | mPhoneNumber.setType( type | KABC::PhoneNumber::Pref ); | 547 | mPhoneNumber.setType( type | KABC::PhoneNumber::Pref ); |
545 | else | 548 | else |
546 | mPhoneNumber.setType( type & ~KABC::PhoneNumber::Pref ); | 549 | mPhoneNumber.setType( type & ~KABC::PhoneNumber::Pref ); |
547 | 550 | ||
548 | return mPhoneNumber; | 551 | return mPhoneNumber; |
549 | } | 552 | } |
550 | 553 | ||
551 | #ifndef KAB_EMBEDDED | 554 | #ifndef KAB_EMBEDDED |
552 | #include "phoneeditwidget.moc" | 555 | #include "phoneeditwidget.moc" |
553 | #endif //KAB_EMBEDDED | 556 | #endif //KAB_EMBEDDED |