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
@@ -123,112 +123,121 @@ void PhoneEditWidget::bottomVisible()
123 sv->setContentsPos ( 0, 1024 ); 123 sv->setContentsPos ( 0, 1024 );
124} 124}
125void PhoneEditWidget::addNumber() 125void PhoneEditWidget::addNumber()
126{ 126{
127 int i = 0; 127 int i = 0;
128 while ( i < mPopupCount ) { 128 while ( i < mPopupCount ) {
129 mPopup->setItemEnabled( i, true ); 129 mPopup->setItemEnabled( i, true );
130 ++i; 130 ++i;
131 } 131 }
132 PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); 132 PhoneTypeNumberEdit* edit = mTypeNumberEditList.first();
133 while ( edit ) { 133 while ( edit ) {
134 if ( edit->currentType() < mPopupCount -1 ) 134 if ( edit->currentType() < mPopupCount -1 )
135 mPopup->setItemEnabled( edit->currentType(), false ); 135 mPopup->setItemEnabled( edit->currentType(), false );
136 edit = mTypeNumberEditList.next(); 136 edit = mTypeNumberEditList.next();
137 } 137 }
138 mPopup->popup( QCursor::pos() ); 138 mPopup->popup( QCursor::pos() );
139} 139}
140PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo() 140PhoneTypeNumberEdit* 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
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
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 );
219 layout->addWidget( label, 0, 0 ); 228 layout->addWidget( label, 0, 0 );
220 229
221 QPushButton *editButton = new QPushButton( i18n( "Edit Phone Numbers..." ), 230 QPushButton *editButton = new QPushButton( i18n( "Edit Phone Numbers..." ),
222 this ); 231 this );
223 if ( QApplication::desktop()->width() < 640 ) 232 if ( QApplication::desktop()->width() < 640 )
224 layout->addWidget( editButton, 0, 1 ); 233 layout->addWidget( editButton, 0, 1 );
225 else 234 else
226 layout->addMultiCellWidget( editButton, 0, 0, 1, 3); 235 layout->addMultiCellWidget( editButton, 0, 0, 1, 3);
227 236
228 mPrefCombo = new PhoneTypeCombo( mPhoneList, this ); 237 mPrefCombo = new PhoneTypeCombo( mPhoneList, this );
229 mPrefEdit = new KLineEdit( this ); 238 mPrefEdit = new KLineEdit( this );
230 //mPrefEdit->setMinimumWidth( int(mPrefEdit->sizeHint().width() * 1.5) ); 239 //mPrefEdit->setMinimumWidth( int(mPrefEdit->sizeHint().width() * 1.5) );
231 mPrefCombo->setLineEdit( mPrefEdit ); 240 mPrefCombo->setLineEdit( mPrefEdit );
232 layout->addWidget( mPrefCombo, 1, 0 ); 241 layout->addWidget( mPrefCombo, 1, 0 );
233 layout->addWidget( mPrefEdit, 1, 1 ); 242 layout->addWidget( mPrefEdit, 1, 1 );
234 int x = 1, y = 2; 243 int x = 1, y = 2;