summaryrefslogtreecommitdiffabout
path: root/kaddressbook/phoneeditwidget.cpp
Unidiff
Diffstat (limited to 'kaddressbook/phoneeditwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/phoneeditwidget.cpp37
1 files changed, 22 insertions, 15 deletions
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp
index b20275d..997fc05 100644
--- a/kaddressbook/phoneeditwidget.cpp
+++ b/kaddressbook/phoneeditwidget.cpp
@@ -72,64 +72,72 @@ PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name )
72 connect(addBut,SIGNAL(clicked()),SLOT(addNumber())); 72 connect(addBut,SIGNAL(clicked()),SLOT(addNumber()));
73 //QLabel * temp = new QLabel( i18n("Phone Type"), hb ); 73 //QLabel * temp = new QLabel( i18n("Phone Type"), hb );
74 QLabel *temp = new QLabel( i18n("Phone Number"),hb ); 74 QLabel *temp = new QLabel( i18n("Phone Number"),hb );
75 temp->setAlignment( Qt::AlignCenter ); 75 temp->setAlignment( Qt::AlignCenter );
76 temp->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); 76 temp->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) );
77 hbLayout->add( temp ); 77 hbLayout->add( temp );
78 appendEditCombo();
79 appendEditCombo();
80 appendEditCombo();
81 setDefaults(); 78 setDefaults();
79 mTypeNumberEditList.setAutoDelete( true );
82} 80}
83 81
84PhoneEditWidget::~PhoneEditWidget() 82PhoneEditWidget::~PhoneEditWidget()
85{ 83{
86} 84}
87void PhoneEditWidget::setDefaults() 85void PhoneEditWidget::setDefaults()
88{ 86{
89 PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); 87 mTypeNumberEditList.clear();
88 PhoneTypeNumberEdit* edit = appendEditCombo();
90 KABC::PhoneNumber phoneNumber; 89 KABC::PhoneNumber phoneNumber;
91 phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref ); 90 phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref );
92 edit->setPhoneNumber( phoneNumber ); 91 edit->setPhoneNumber( phoneNumber );
93 edit = mTypeNumberEditList.next(); 92 edit = appendEditCombo();
94 phoneNumber.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref ); 93 phoneNumber.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref );
95 edit->setPhoneNumber( phoneNumber ); 94 edit->setPhoneNumber( phoneNumber );
96 edit = mTypeNumberEditList.next(); 95 edit = appendEditCombo();
97 phoneNumber.setType( KABC::PhoneNumber::Cell ); 96 phoneNumber.setType( KABC::PhoneNumber::Cell );
98 edit->setPhoneNumber( phoneNumber ); 97 edit->setPhoneNumber( phoneNumber );
99 edit = mTypeNumberEditList.next(); 98
100 while ( edit ) {
101 edit->hide();
102 edit = mTypeNumberEditList.next();
103 }
104} 99}
105void PhoneEditWidget::addNumber() 100void PhoneEditWidget::addNumber()
106{ 101{
107 102
108} 103}
109PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo() 104PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo()
110{ 105{
111 PhoneTypeNumberEdit* edit = new PhoneTypeNumberEdit( mw ); 106 PhoneTypeNumberEdit* edit = new PhoneTypeNumberEdit( mw );
112 connect ( edit, SIGNAL ( typeChange( int , int) ), this, SIGNAL ( typeChange( int , int)) ); 107 connect ( edit, SIGNAL ( typeChange( int , int) ), this, SIGNAL ( typeChange( int , int)) );
113 connect ( edit, SIGNAL ( modified() ), this, SIGNAL ( modified() ) ); 108 connect ( edit, SIGNAL ( modified() ), this, SIGNAL ( modified() ) );
109 connect ( edit, SIGNAL ( deleteMe( PhoneTypeNumberEdit* ) ), this, SLOT ( deleteEdit( PhoneTypeNumberEdit*) ) );
114 connect ( this, SIGNAL ( typeChange( int , int)), edit, SLOT ( typeExternalChanged( int, int)) ); 110 connect ( this, SIGNAL ( typeChange( int , int)), edit, SLOT ( typeExternalChanged( int, int)) );
115 111
116 mainLayout->add( edit ); 112 mainLayout->add( edit );
117 mTypeNumberEditList.append( edit ); 113 mTypeNumberEditList.append( edit );
118 return edit; 114 return edit;
119} 115}
120 116
117void PhoneEditWidget::deleteEdit( PhoneTypeNumberEdit* ew )
118{
119 mPendingDelete = ew;
120 QTimer::singleShot( 0, this, SLOT ( pendingDelete() ) );
121}
122void PhoneEditWidget::pendingDelete()
123{
124 mTypeNumberEditList.removeRef( mPendingDelete );
125 emit modified();
126}
127
121void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li ) 128void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li )
122{ 129{
123 if ( li.isEmpty() ) { 130 if ( li.isEmpty() ) {
124 setDefaults(); 131 setDefaults();
125 return; 132 return;
126 } 133 }
134 mTypeNumberEditList.clear();
127 KABC::PhoneNumber::List::Iterator it; 135 KABC::PhoneNumber::List::Iterator it;
128 KABC::PhoneNumber::List list = li; 136 KABC::PhoneNumber::List list = li;
129 PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); 137 PhoneTypeNumberEdit* edit = 0;//mTypeNumberEditList.first();
130 for ( it = list.begin(); it != list.end(); ++it ) { 138 for ( it = list.begin(); it != list.end(); ++it ) {
131 if ( edit ) { 139 if ( edit ) {
132 edit->setPhoneNumber( (*it ) ); 140 edit->setPhoneNumber( (*it ) );
133 edit = mTypeNumberEditList.next(); 141 edit = mTypeNumberEditList.next();
134 } else { 142 } else {
135 PhoneTypeNumberEdit* editNew = appendEditCombo(); 143 PhoneTypeNumberEdit* editNew = appendEditCombo();
@@ -137,14 +145,12 @@ void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li )
137 } 145 }
138 } 146 }
139 while ( edit ) { 147 while ( edit ) {
140 edit->hide(); 148 edit->hide();
141 edit = mTypeNumberEditList.next(); 149 edit = mTypeNumberEditList.next();
142 } 150 }
143 //mainLayout->invalidate ();
144 mw->update();
145} 151}
146KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() 152KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers()
147{ 153{
148 KABC::PhoneNumber::List retList; 154 KABC::PhoneNumber::List retList;
149 155
150 PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); 156 PhoneTypeNumberEdit* edit = mTypeNumberEditList.first();
@@ -512,12 +518,13 @@ PhoneEditDialog::PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *
512 resize( 400, 400 ); 518 resize( 400, 400 );
513 mChanged = false; 519 mChanged = false;
514} 520}
515 521
516PhoneEditDialog::~PhoneEditDialog() 522PhoneEditDialog::~PhoneEditDialog()
517{ 523{
524 qDebug("PhoneEditDialog::~PhoneEditDialog() ");
518} 525}
519 526
520void PhoneEditDialog::slotAddPhoneNumber() 527void PhoneEditDialog::slotAddPhoneNumber()
521{ 528{
522 KABC::PhoneNumber tmp( "", 0 ); 529 KABC::PhoneNumber tmp( "", 0 );
523 PhoneTypeDialog dlg( tmp, this ); 530 PhoneTypeDialog dlg( tmp, this );