summaryrefslogtreecommitdiffabout
path: root/kaddressbook/phoneeditwidget.cpp
Unidiff
Diffstat (limited to 'kaddressbook/phoneeditwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/phoneeditwidget.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp
index 9e7e221..66f0a5e 100644
--- a/kaddressbook/phoneeditwidget.cpp
+++ b/kaddressbook/phoneeditwidget.cpp
@@ -147,64 +147,73 @@ PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo()
147 147
148 mainLayout->add( edit ); 148 mainLayout->add( edit );
149 mTypeNumberEditList.append( edit ); 149 mTypeNumberEditList.append( edit );
150 return edit; 150 return edit;
151} 151}
152 152
153void PhoneEditWidget::deleteEdit( PhoneTypeNumberEdit* ew ) 153void PhoneEditWidget::deleteEdit( PhoneTypeNumberEdit* ew )
154{ 154{
155 mPendingDelete = ew; 155 mPendingDelete = ew;
156 QTimer::singleShot( 0, this, SLOT ( pendingDelete() ) ); 156 QTimer::singleShot( 0, this, SLOT ( pendingDelete() ) );
157} 157}
158void PhoneEditWidget::pendingDelete() 158void PhoneEditWidget::pendingDelete()
159{ 159{
160 mTypeNumberEditList.removeRef( mPendingDelete ); 160 mTypeNumberEditList.removeRef( mPendingDelete );
161 emit modified(); 161 emit modified();
162} 162}
163 163
164void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li ) 164void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li )
165{ 165{
166 if ( li.isEmpty() ) { 166 if ( li.isEmpty() ) {
167 setDefaults(); 167 setDefaults();
168 return; 168 return;
169 } 169 }
170 mTypeNumberEditList.clear(); 170 mTypeNumberEditList.clear();
171 KABC::PhoneNumber::List::Iterator it; 171 KABC::PhoneNumber::List::Iterator it;
172 KABC::PhoneNumber::List list = li; 172 KABC::PhoneNumber::List list2 = li;
173 PhoneTypeNumberEdit* edit = 0;//mTypeNumberEditList.first(); 173 KABC::PhoneNumber::List list ;
174
175 PhoneNumber::TypeList tList = PhoneNumber::supportedTypeList();
176 int i = 0;
177 int max = tList.count();
178 while ( i < max-1 ) {
179 for ( it = list2.begin(); it != list2.end(); ++it ) {
180 if ( (*it).type() == tList[i] ) {
181 list.append( (*it ) );
182 break;
183 }
184 }
185 ++i;
186 }
187 for ( it = list2.begin(); it != list2.end(); ++it ) {
188 if ( (*it).type() == tList[ max-1 ] )
189 list.append( (*it ) );
190 }
174 for ( it = list.begin(); it != list.end(); ++it ) { 191 for ( it = list.begin(); it != list.end(); ++it ) {
175 if ( edit ) {
176 edit->setPhoneNumber( (*it ) );
177 edit = mTypeNumberEditList.next();
178 } else {
179 PhoneTypeNumberEdit* editNew = appendEditCombo(); 192 PhoneTypeNumberEdit* editNew = appendEditCombo();
180 editNew->setPhoneNumber( (*it ) ); 193 editNew->setPhoneNumber( (*it ) );
181 }
182 }
183 while ( edit ) {
184 edit->hide();
185 edit = mTypeNumberEditList.next();
186 } 194 }
195
187} 196}
188KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() 197KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers()
189{ 198{
190 KABC::PhoneNumber::List retList; 199 KABC::PhoneNumber::List retList;
191 200
192 PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); 201 PhoneTypeNumberEdit* edit = mTypeNumberEditList.first();
193 while ( edit ) { 202 while ( edit ) {
194 if ( edit->isValid() ) { 203 if ( edit->isValid() ) {
195 retList.append( edit->phoneNumber()); 204 retList.append( edit->phoneNumber());
196 } 205 }
197 edit = mTypeNumberEditList.next(); 206 edit = mTypeNumberEditList.next();
198 207
199 } 208 }
200 return retList; 209 return retList;
201} 210}
202 211
203#if 0 212#if 0
204PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) 213PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name )
205 : QWidget( parent, name ) 214 : QWidget( parent, name )
206{ 215{
207 QGridLayout *layout = new QGridLayout( this, 4, 1 ); 216 QGridLayout *layout = new QGridLayout( this, 4, 1 );
208//US layout->setSpacing( KDialog::spacingHint() ); 217//US layout->setSpacing( KDialog::spacingHint() );
209 layout->setSpacing( KDialogBase::spacingHintSmall() ); 218 layout->setSpacing( KDialogBase::spacingHintSmall() );
210 219