author | zautrix <zautrix> | 2005-10-28 14:43:31 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-28 14:43:31 (UTC) |
commit | ab099bc1be027fe01dc252a9d7a0f8821e782d65 (patch) (unidiff) | |
tree | 85bfb03f334da60dffcc52d54202f51d0f947e3f /kaddressbook | |
parent | caaa030d8bc2aa82c53e5d30abc314b992d7226f (diff) | |
download | kdepimpi-ab099bc1be027fe01dc252a9d7a0f8821e782d65.zip kdepimpi-ab099bc1be027fe01dc252a9d7a0f8821e782d65.tar.gz kdepimpi-ab099bc1be027fe01dc252a9d7a0f8821e782d65.tar.bz2 |
fixxxx
-rw-r--r-- | kaddressbook/phoneeditwidget.cpp | 33 |
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 | |||
@@ -139,80 +139,89 @@ void PhoneEditWidget::addNumber() | |||
139 | } | 139 | } |
140 | PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo() | 140 | PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo() |
141 | { | 141 | { |
142 | PhoneTypeNumberEdit* edit = new PhoneTypeNumberEdit( mw ); | 142 | PhoneTypeNumberEdit* edit = new PhoneTypeNumberEdit( mw ); |
143 | connect ( edit, SIGNAL ( typeChange( int , int) ), this, SIGNAL ( typeChange( int , int)) ); | 143 | connect ( edit, SIGNAL ( typeChange( int , int) ), this, SIGNAL ( typeChange( int , int)) ); |
144 | connect ( edit, SIGNAL ( modified() ), this, SIGNAL ( modified() ) ); | 144 | connect ( edit, SIGNAL ( modified() ), this, SIGNAL ( modified() ) ); |
145 | connect ( edit, SIGNAL ( deleteMe( PhoneTypeNumberEdit* ) ), this, SLOT ( deleteEdit( PhoneTypeNumberEdit*) ) ); | 145 | connect ( edit, SIGNAL ( deleteMe( PhoneTypeNumberEdit* ) ), this, SLOT ( deleteEdit( PhoneTypeNumberEdit*) ) ); |
146 | connect ( this, SIGNAL ( typeChange( int , int)), edit, SLOT ( typeExternalChanged( int, int)) ); | 146 | connect ( this, SIGNAL ( typeChange( int , int)), edit, SLOT ( typeExternalChanged( int, int)) ); |
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 | ||
153 | void PhoneEditWidget::deleteEdit( PhoneTypeNumberEdit* ew ) | 153 | void 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 | } |
158 | void PhoneEditWidget::pendingDelete() | 158 | void PhoneEditWidget::pendingDelete() |
159 | { | 159 | { |
160 | mTypeNumberEditList.removeRef( mPendingDelete ); | 160 | mTypeNumberEditList.removeRef( mPendingDelete ); |
161 | emit modified(); | 161 | emit modified(); |
162 | } | 162 | } |
163 | 163 | ||
164 | void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li ) | 164 | void 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 | } |
188 | KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() | 197 | KABC::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 |
204 | PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) | 213 | PhoneEditWidget::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 | ||
211 | 220 | ||
212 | 221 | ||
213 | QLabel* label = new QLabel( this ); | 222 | QLabel* label = new QLabel( this ); |
214 | //US loadIcon call is ambiguous. Add one more parameter | 223 | //US loadIcon call is ambiguous. Add one more parameter |
215 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); | 224 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); |
216 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); | 225 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); |
217 | label->setAlignment( AlignCenter ); | 226 | label->setAlignment( AlignCenter ); |
218 | //US layout->addMultiCellWidget( label, 0, 1, 3, 3 ); | 227 | //US layout->addMultiCellWidget( label, 0, 1, 3, 3 ); |