author | zautrix <zautrix> | 2005-03-31 11:26:51 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-31 11:26:51 (UTC) |
commit | c0fa26aa3b33c293853bdd7d028ddb0545e33c85 (patch) (side-by-side diff) | |
tree | 12bbb65fb6d235415bd7a7007c1e019ccfcf97ac /kaddressbook/phoneeditwidget.cpp | |
parent | f39d5000ed2f9a436ee94cbd42f840651afa89d6 (diff) | |
download | kdepimpi-c0fa26aa3b33c293853bdd7d028ddb0545e33c85.zip kdepimpi-c0fa26aa3b33c293853bdd7d028ddb0545e33c85.tar.gz kdepimpi-c0fa26aa3b33c293853bdd7d028ddb0545e33c85.tar.bz2 |
many fixes
Diffstat (limited to 'kaddressbook/phoneeditwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/phoneeditwidget.cpp | 37 |
1 files changed, 30 insertions, 7 deletions
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() if ( !(*it).number().isEmpty() ) retList.append( *it ); return retList; } void PhoneEditWidget::edit() { PhoneEditDialog dlg( mPhoneList, this ); if ( dlg.exec() ) { if ( dlg.changed() ) { - mPhoneList = dlg.phoneNumbers(); + KABC::PhoneNumber::List list = dlg.phoneNumbers(); + setPhoneNumbers( list ); updateCombos(); updateLineEdits(); emit modified(); } } } void PhoneEditWidget::updatePrefEdit() { updateEdit( mPrefCombo ); } @@ -329,25 +330,28 @@ public: QString number() { return ""; } KABC::PhoneNumber phoneNumber() { return mPhoneNumber; } private: void makeText(); KABC::PhoneNumber mPhoneNumber; }; PhoneViewItem::PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ) : QListViewItem( parent ), mPhoneNumber( number ) -{ +{ +#ifdef DESKTOP_VERSION + setRenameEnabled ( 0, true ); +#endif makeText(); } void PhoneViewItem::makeText() { /** * Will be used in future versions of kaddressbook/libkabc setText( 0, mPhoneNumber.country() ); setText( 1, mPhoneNumber.region() ); setText( 2, mPhoneNumber.number() ); setText( 3, mPhoneNumber.typeLabel() ); @@ -397,29 +401,46 @@ PhoneEditDialog::PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget * } PhoneEditDialog::~PhoneEditDialog() { } void PhoneEditDialog::slotAddPhoneNumber() { KABC::PhoneNumber tmp( "", 0 ); PhoneTypeDialog dlg( tmp, this ); if ( dlg.exec() ) { - KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); - mPhoneNumberList.append( phoneNumber ); - new PhoneViewItem( mListView, phoneNumber ); - - mChanged = true; + QListViewItem* i = mListView->firstChild(); + KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); + bool insert = true; + while ( i ) { + PhoneViewItem* p = ( PhoneViewItem* ) i; + KABC::PhoneNumber pn = p->phoneNumber(); + if ( (pn.type() | KABC::PhoneNumber::Pref) == (phoneNumber.type() | KABC::PhoneNumber::Pref) ) { + if ( p->text(0).isEmpty()) { + p->setPhoneNumber( phoneNumber ); + mPhoneNumberList.remove( pn ); + mPhoneNumberList.append( phoneNumber ); + insert = false; + break; + } + } + i = i->nextSibling(); + } + if ( insert ) { + mPhoneNumberList.append( phoneNumber ); + new PhoneViewItem( mListView, phoneNumber ); + } + mChanged = true; } } void PhoneEditDialog::slotRemovePhoneNumber() { PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); if ( !item ) return; mPhoneNumberList.remove( item->phoneNumber() ); QListViewItem *currItem = mListView->currentItem(); mListView->takeItem( currItem ); @@ -495,24 +516,26 @@ PhoneTypeDialog::PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, KABC::PhoneNumber::TypeList::Iterator it; for ( it = mTypeList.begin(); it != mTypeList.end(); ++it ) new QCheckBox( KABC::PhoneNumber::typeLabel( *it ), mGroup ); for ( int i = 0; i < mGroup->count(); ++i ) { int type = mPhoneNumber.type(); QCheckBox *box = (QCheckBox*)mGroup->find( i ); box->setChecked( type & mTypeList[ i ] ); } mPreferredBox->setChecked( mPhoneNumber.type() & KABC::PhoneNumber::Pref ); + mNumber->setFocus(); + mNumber->setSelection( 0, 1024); } KABC::PhoneNumber PhoneTypeDialog::phoneNumber() { mPhoneNumber.setNumber( mNumber->text() ); int type = 0; for ( int i = 0; i < mGroup->count(); ++i ) { QCheckBox *box = (QCheckBox*)mGroup->find( i ); if ( box->isChecked() ) type += mTypeList[ i ]; } |