summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2005-03-31 11:26:51 (UTC)
committer zautrix <zautrix>2005-03-31 11:26:51 (UTC)
commitc0fa26aa3b33c293853bdd7d028ddb0545e33c85 (patch) (unidiff)
tree12bbb65fb6d235415bd7a7007c1e019ccfcf97ac /kaddressbook
parentf39d5000ed2f9a436ee94cbd42f840651afa89d6 (diff)
downloadkdepimpi-c0fa26aa3b33c293853bdd7d028ddb0545e33c85.zip
kdepimpi-c0fa26aa3b33c293853bdd7d028ddb0545e33c85.tar.gz
kdepimpi-c0fa26aa3b33c293853bdd7d028ddb0545e33c85.tar.bz2
many fixes
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/emaileditwidget.cpp2
-rw-r--r--kaddressbook/phoneeditwidget.cpp37
2 files changed, 32 insertions, 7 deletions
diff --git a/kaddressbook/emaileditwidget.cpp b/kaddressbook/emaileditwidget.cpp
index 0e01b02..e72face 100644
--- a/kaddressbook/emaileditwidget.cpp
+++ b/kaddressbook/emaileditwidget.cpp
@@ -180,24 +180,25 @@ EmailEditDialog::EmailEditDialog( const QStringList &list, QWidget *parent,
180qDebug("EmailEditDialog::EmailEditDialog has to be changed (lowPrio)"); 180qDebug("EmailEditDialog::EmailEditDialog has to be changed (lowPrio)");
181//US must be fixed !!! 181//US must be fixed !!!
182/* 182/*
183 if ( items.remove( "" ) > 0 ) 183 if ( items.remove( "" ) > 0 )
184 mChanged = true; 184 mChanged = true;
185 else 185 else
186 mChanged = false; 186 mChanged = false;
187*/ 187*/
188 188
189 mEmailListBox->insertStringList( items ); 189 mEmailListBox->insertStringList( items );
190 // set default state 190 // set default state
191 selectionChanged( -1 ); 191 selectionChanged( -1 );
192 mEmailEdit->setFocus();
192 193
193#ifndef KAB_EMBEDDED 194#ifndef KAB_EMBEDDED
194 KAcceleratorManager::manage( this ); 195 KAcceleratorManager::manage( this );
195#else //KAB_EMBEDDED 196#else //KAB_EMBEDDED
196//US qDebug("EmailEditDialog::EmailEditDialog has to be changed"); 197//US qDebug("EmailEditDialog::EmailEditDialog has to be changed");
197#endif //KAB_EMBEDDED 198#endif //KAB_EMBEDDED
198 199
199} 200}
200 201
201EmailEditDialog::~EmailEditDialog() 202EmailEditDialog::~EmailEditDialog()
202{ 203{
203} 204}
@@ -216,24 +217,25 @@ void EmailEditDialog::add()
216{ 217{
217 mEmailListBox->insertItem( mEmailEdit->text() ); 218 mEmailListBox->insertItem( mEmailEdit->text() );
218 219
219 mEmailEdit->clear(); 220 mEmailEdit->clear();
220 mEmailEdit->setFocus(); 221 mEmailEdit->setFocus();
221 222
222 mChanged = true; 223 mChanged = true;
223} 224}
224 225
225void EmailEditDialog::edit() 226void EmailEditDialog::edit()
226{ 227{
227 mEmailEdit->setText( mEmailListBox->currentText() ); 228 mEmailEdit->setText( mEmailListBox->currentText() );
229 mEmailListBox->removeItem( mEmailListBox->currentItem() );
228 mEmailEdit->setFocus(); 230 mEmailEdit->setFocus();
229} 231}
230 232
231void EmailEditDialog::remove() 233void EmailEditDialog::remove()
232{ 234{
233 QString address = mEmailListBox->currentText(); 235 QString address = mEmailListBox->currentText();
234 236
235 QString text = i18n( "<qt>Are you sure that you want to remove the email address <b>%1</b>?</qt>" ).arg( address ); 237 QString text = i18n( "<qt>Are you sure that you want to remove the email address <b>%1</b>?</qt>" ).arg( address );
236 QString caption = i18n( "Confirm Remove" ); 238 QString caption = i18n( "Confirm Remove" );
237 239
238 if ( KMessageBox::questionYesNo( this, text, caption ) == KMessageBox::Yes ) { 240 if ( KMessageBox::questionYesNo( this, text, caption ) == KMessageBox::Yes ) {
239 mEmailListBox->removeItem( mEmailListBox->currentItem() ); 241 mEmailListBox->removeItem( mEmailListBox->currentItem() );
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp
index 19bb676..a435959 100644
--- a/kaddressbook/phoneeditwidget.cpp
+++ b/kaddressbook/phoneeditwidget.cpp
@@ -204,25 +204,26 @@ KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers()
204 if ( !(*it).number().isEmpty() ) 204 if ( !(*it).number().isEmpty() )
205 retList.append( *it ); 205 retList.append( *it );
206 206
207 return retList; 207 return retList;
208} 208}
209 209
210void PhoneEditWidget::edit() 210void 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 mPhoneList = dlg.phoneNumbers(); 216 KABC::PhoneNumber::List list = dlg.phoneNumbers();
217 setPhoneNumbers( list );
217 updateCombos(); 218 updateCombos();
218 updateLineEdits(); 219 updateLineEdits();
219 emit modified(); 220 emit modified();
220 } 221 }
221 } 222 }
222} 223}
223 224
224void PhoneEditWidget::updatePrefEdit() 225void PhoneEditWidget::updatePrefEdit()
225{ 226{
226 updateEdit( mPrefCombo ); 227 updateEdit( mPrefCombo );
227} 228}
228 229
@@ -329,25 +330,28 @@ public:
329 QString number() { return ""; } 330 QString number() { return ""; }
330 331
331 KABC::PhoneNumber phoneNumber() { return mPhoneNumber; } 332 KABC::PhoneNumber phoneNumber() { return mPhoneNumber; }
332 333
333private: 334private:
334 void makeText(); 335 void makeText();
335 336
336 KABC::PhoneNumber mPhoneNumber; 337 KABC::PhoneNumber mPhoneNumber;
337}; 338};
338 339
339PhoneViewItem::PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ) 340PhoneViewItem::PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number )
340 : QListViewItem( parent ), mPhoneNumber( number ) 341 : QListViewItem( parent ), mPhoneNumber( number )
341{ 342{
343#ifdef DESKTOP_VERSION
344 setRenameEnabled ( 0, true );
345#endif
342 makeText(); 346 makeText();
343} 347}
344 348
345void PhoneViewItem::makeText() 349void PhoneViewItem::makeText()
346{ 350{
347 /** 351 /**
348 * Will be used in future versions of kaddressbook/libkabc 352 * Will be used in future versions of kaddressbook/libkabc
349 353
350 setText( 0, mPhoneNumber.country() ); 354 setText( 0, mPhoneNumber.country() );
351 setText( 1, mPhoneNumber.region() ); 355 setText( 1, mPhoneNumber.region() );
352 setText( 2, mPhoneNumber.number() ); 356 setText( 2, mPhoneNumber.number() );
353 setText( 3, mPhoneNumber.typeLabel() ); 357 setText( 3, mPhoneNumber.typeLabel() );
@@ -397,29 +401,46 @@ PhoneEditDialog::PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *
397} 401}
398 402
399PhoneEditDialog::~PhoneEditDialog() 403PhoneEditDialog::~PhoneEditDialog()
400{ 404{
401} 405}
402 406
403void PhoneEditDialog::slotAddPhoneNumber() 407void PhoneEditDialog::slotAddPhoneNumber()
404{ 408{
405 KABC::PhoneNumber tmp( "", 0 ); 409 KABC::PhoneNumber tmp( "", 0 );
406 PhoneTypeDialog dlg( tmp, this ); 410 PhoneTypeDialog dlg( tmp, this );
407 411
408 if ( dlg.exec() ) { 412 if ( dlg.exec() ) {
409 KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); 413 QListViewItem* i = mListView->firstChild();
410 mPhoneNumberList.append( phoneNumber ); 414 KABC::PhoneNumber phoneNumber = dlg.phoneNumber();
411 new PhoneViewItem( mListView, phoneNumber ); 415 bool insert = true;
412 416 while ( i ) {
413 mChanged = true; 417 PhoneViewItem* p = ( PhoneViewItem* ) i;
418 KABC::PhoneNumber pn = p->phoneNumber();
419 if ( (pn.type() | KABC::PhoneNumber::Pref) == (phoneNumber.type() | KABC::PhoneNumber::Pref) ) {
420 if ( p->text(0).isEmpty()) {
421 p->setPhoneNumber( phoneNumber );
422 mPhoneNumberList.remove( pn );
423 mPhoneNumberList.append( phoneNumber );
424 insert = false;
425 break;
426 }
427 }
428 i = i->nextSibling();
429 }
430 if ( insert ) {
431 mPhoneNumberList.append( phoneNumber );
432 new PhoneViewItem( mListView, phoneNumber );
433 }
434 mChanged = true;
414 } 435 }
415} 436}
416 437
417void PhoneEditDialog::slotRemovePhoneNumber() 438void PhoneEditDialog::slotRemovePhoneNumber()
418{ 439{
419 PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); 440 PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() );
420 if ( !item ) 441 if ( !item )
421 return; 442 return;
422 443
423 mPhoneNumberList.remove( item->phoneNumber() ); 444 mPhoneNumberList.remove( item->phoneNumber() );
424 QListViewItem *currItem = mListView->currentItem(); 445 QListViewItem *currItem = mListView->currentItem();
425 mListView->takeItem( currItem ); 446 mListView->takeItem( currItem );
@@ -495,24 +516,26 @@ PhoneTypeDialog::PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber,
495 516
496 KABC::PhoneNumber::TypeList::Iterator it; 517 KABC::PhoneNumber::TypeList::Iterator it;
497 for ( it = mTypeList.begin(); it != mTypeList.end(); ++it ) 518 for ( it = mTypeList.begin(); it != mTypeList.end(); ++it )
498 new QCheckBox( KABC::PhoneNumber::typeLabel( *it ), mGroup ); 519 new QCheckBox( KABC::PhoneNumber::typeLabel( *it ), mGroup );
499 520
500 for ( int i = 0; i < mGroup->count(); ++i ) { 521 for ( int i = 0; i < mGroup->count(); ++i ) {
501 int type = mPhoneNumber.type(); 522 int type = mPhoneNumber.type();
502 QCheckBox *box = (QCheckBox*)mGroup->find( i ); 523 QCheckBox *box = (QCheckBox*)mGroup->find( i );
503 box->setChecked( type & mTypeList[ i ] ); 524 box->setChecked( type & mTypeList[ i ] );
504 } 525 }
505 526
506 mPreferredBox->setChecked( mPhoneNumber.type() & KABC::PhoneNumber::Pref ); 527 mPreferredBox->setChecked( mPhoneNumber.type() & KABC::PhoneNumber::Pref );
528 mNumber->setFocus();
529 mNumber->setSelection( 0, 1024);
507} 530}
508 531
509KABC::PhoneNumber PhoneTypeDialog::phoneNumber() 532KABC::PhoneNumber PhoneTypeDialog::phoneNumber()
510{ 533{
511 mPhoneNumber.setNumber( mNumber->text() ); 534 mPhoneNumber.setNumber( mNumber->text() );
512 535
513 int type = 0; 536 int type = 0;
514 for ( int i = 0; i < mGroup->count(); ++i ) { 537 for ( int i = 0; i < mGroup->count(); ++i ) {
515 QCheckBox *box = (QCheckBox*)mGroup->find( i ); 538 QCheckBox *box = (QCheckBox*)mGroup->find( i );
516 if ( box->isChecked() ) 539 if ( box->isChecked() )
517 type += mTypeList[ i ]; 540 type += mTypeList[ i ];
518 } 541 }