-rw-r--r-- | kaddressbook/emaileditwidget.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/phoneeditwidget.cpp | 37 |
2 files changed, 32 insertions, 7 deletions
diff --git a/kaddressbook/emaileditwidget.cpp b/kaddressbook/emaileditwidget.cpp index 0e01b02..e72face 100644 --- a/kaddressbook/emaileditwidget.cpp +++ b/kaddressbook/emaileditwidget.cpp | |||
@@ -96,180 +96,182 @@ QStringList EmailEditWidget::emails() | |||
96 | { | 96 | { |
97 | if ( mEmailEdit->text().isEmpty() ) { | 97 | if ( mEmailEdit->text().isEmpty() ) { |
98 | if ( mEmailList.count() > 0 ) | 98 | if ( mEmailList.count() > 0 ) |
99 | mEmailList.remove( mEmailList.begin() ); | 99 | mEmailList.remove( mEmailList.begin() ); |
100 | } else { | 100 | } else { |
101 | if ( mEmailList.count() > 0 ) | 101 | if ( mEmailList.count() > 0 ) |
102 | mEmailList.remove( mEmailList.begin() ); | 102 | mEmailList.remove( mEmailList.begin() ); |
103 | 103 | ||
104 | mEmailList.prepend( mEmailEdit->text() ); | 104 | mEmailList.prepend( mEmailEdit->text() ); |
105 | } | 105 | } |
106 | 106 | ||
107 | return mEmailList; | 107 | return mEmailList; |
108 | } | 108 | } |
109 | 109 | ||
110 | void EmailEditWidget::edit() | 110 | void EmailEditWidget::edit() |
111 | { | 111 | { |
112 | EmailEditDialog dlg( mEmailList, this ); | 112 | EmailEditDialog dlg( mEmailList, this ); |
113 | 113 | ||
114 | if ( dlg.exec() ) { | 114 | if ( dlg.exec() ) { |
115 | if ( dlg.changed() ) { | 115 | if ( dlg.changed() ) { |
116 | mEmailList = dlg.emails(); | 116 | mEmailList = dlg.emails(); |
117 | mEmailEdit->setText( mEmailList[ 0 ] ); | 117 | mEmailEdit->setText( mEmailList[ 0 ] ); |
118 | emit modified(); | 118 | emit modified(); |
119 | } | 119 | } |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | void EmailEditWidget::textChanged( const QString &text ) | 123 | void EmailEditWidget::textChanged( const QString &text ) |
124 | { | 124 | { |
125 | if ( mEmailList.count() > 0 ) | 125 | if ( mEmailList.count() > 0 ) |
126 | mEmailList.remove( mEmailList.begin() ); | 126 | mEmailList.remove( mEmailList.begin() ); |
127 | 127 | ||
128 | mEmailList.prepend( text ); | 128 | mEmailList.prepend( text ); |
129 | } | 129 | } |
130 | 130 | ||
131 | 131 | ||
132 | EmailEditDialog::EmailEditDialog( const QStringList &list, QWidget *parent, | 132 | EmailEditDialog::EmailEditDialog( const QStringList &list, QWidget *parent, |
133 | const char *name ) | 133 | const char *name ) |
134 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Email Addresses" ), | 134 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Email Addresses" ), |
135 | KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, | 135 | KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, |
136 | parent, name, true ) | 136 | parent, name, true ) |
137 | { | 137 | { |
138 | QWidget *page = plainPage(); | 138 | QWidget *page = plainPage(); |
139 | 139 | ||
140 | QGridLayout *topLayout = new QGridLayout( page, 4, 3 ); | 140 | QGridLayout *topLayout = new QGridLayout( page, 4, 3 ); |
141 | 141 | ||
142 | QLabel *label = new QLabel( i18n( "Email address:" ), page ); | 142 | QLabel *label = new QLabel( i18n( "Email address:" ), page ); |
143 | topLayout->addWidget( label, 0, 0 ); | 143 | topLayout->addWidget( label, 0, 0 ); |
144 | 144 | ||
145 | mEmailEdit = new KLineEdit( page ); | 145 | mEmailEdit = new KLineEdit( page ); |
146 | label->setBuddy( mEmailEdit ); | 146 | label->setBuddy( mEmailEdit ); |
147 | topLayout->addWidget( mEmailEdit, 0, 1 ); | 147 | topLayout->addWidget( mEmailEdit, 0, 1 ); |
148 | connect( mEmailEdit, SIGNAL( returnPressed() ), SLOT( add() ) ); | 148 | connect( mEmailEdit, SIGNAL( returnPressed() ), SLOT( add() ) ); |
149 | connect( mEmailEdit, SIGNAL( textChanged( const QString& ) ), | 149 | connect( mEmailEdit, SIGNAL( textChanged( const QString& ) ), |
150 | SLOT( emailChanged() ) ); | 150 | SLOT( emailChanged() ) ); |
151 | 151 | ||
152 | mAddButton = new QPushButton( i18n( "Add" ), page ); | 152 | mAddButton = new QPushButton( i18n( "Add" ), page ); |
153 | mAddButton->setEnabled( false ); | 153 | mAddButton->setEnabled( false ); |
154 | connect( mAddButton, SIGNAL( clicked() ), SLOT( add() ) ); | 154 | connect( mAddButton, SIGNAL( clicked() ), SLOT( add() ) ); |
155 | topLayout->addWidget( mAddButton, 0, 2 ); | 155 | topLayout->addWidget( mAddButton, 0, 2 ); |
156 | 156 | ||
157 | mEmailListBox = new QListBox( page ); | 157 | mEmailListBox = new QListBox( page ); |
158 | 158 | ||
159 | // Make sure there is room for the scrollbar | 159 | // Make sure there is room for the scrollbar |
160 | mEmailListBox->setMinimumHeight( mEmailListBox->sizeHint().height() + 30 ); | 160 | mEmailListBox->setMinimumHeight( mEmailListBox->sizeHint().height() + 30 ); |
161 | connect( mEmailListBox, SIGNAL( highlighted( int ) ), | 161 | connect( mEmailListBox, SIGNAL( highlighted( int ) ), |
162 | SLOT( selectionChanged( int ) ) ); | 162 | SLOT( selectionChanged( int ) ) ); |
163 | topLayout->addMultiCellWidget( mEmailListBox, 1, 3, 0, 1 ); | 163 | topLayout->addMultiCellWidget( mEmailListBox, 1, 3, 0, 1 ); |
164 | 164 | ||
165 | mEditButton = new QPushButton( i18n( "Change" ), page ); | 165 | mEditButton = new QPushButton( i18n( "Change" ), page ); |
166 | connect( mEditButton, SIGNAL( clicked() ), SLOT( edit() ) ); | 166 | connect( mEditButton, SIGNAL( clicked() ), SLOT( edit() ) ); |
167 | topLayout->addWidget( mEditButton, 1, 2 ); | 167 | topLayout->addWidget( mEditButton, 1, 2 ); |
168 | 168 | ||
169 | mRemoveButton = new QPushButton( i18n( "Remove" ), page ); | 169 | mRemoveButton = new QPushButton( i18n( "Remove" ), page ); |
170 | connect( mRemoveButton, SIGNAL( clicked() ), SLOT( remove() ) ); | 170 | connect( mRemoveButton, SIGNAL( clicked() ), SLOT( remove() ) ); |
171 | topLayout->addWidget( mRemoveButton, 2, 2 ); | 171 | topLayout->addWidget( mRemoveButton, 2, 2 ); |
172 | 172 | ||
173 | mStandardButton = new QPushButton( i18n( "Set Standard" ), page ); | 173 | mStandardButton = new QPushButton( i18n( "Set Standard" ), page ); |
174 | connect( mStandardButton, SIGNAL( clicked() ), SLOT( standard() ) ); | 174 | connect( mStandardButton, SIGNAL( clicked() ), SLOT( standard() ) ); |
175 | topLayout->addWidget( mStandardButton, 3, 2 ); | 175 | topLayout->addWidget( mStandardButton, 3, 2 ); |
176 | 176 | ||
177 | topLayout->activate(); | 177 | topLayout->activate(); |
178 | QStringList items = list; | 178 | QStringList items = list; |
179 | 179 | ||
180 | qDebug("EmailEditDialog::EmailEditDialog has to be changed (lowPrio)"); | 180 | qDebug("EmailEditDialog::EmailEditDialog has to be changed (lowPrio)"); |
181 | //US must be fixed !!! | 181 | //US must be fixed !!! |
182 | /* | 182 | /* |
183 | if ( items.remove( "" ) > 0 ) | 183 | if ( items.remove( "" ) > 0 ) |
184 | mChanged = true; | 184 | mChanged = true; |
185 | else | 185 | else |
186 | mChanged = false; | 186 | mChanged = false; |
187 | */ | 187 | */ |
188 | 188 | ||
189 | mEmailListBox->insertStringList( items ); | 189 | mEmailListBox->insertStringList( items ); |
190 | // set default state | 190 | // set default state |
191 | selectionChanged( -1 ); | 191 | selectionChanged( -1 ); |
192 | mEmailEdit->setFocus(); | ||
192 | 193 | ||
193 | #ifndef KAB_EMBEDDED | 194 | #ifndef KAB_EMBEDDED |
194 | KAcceleratorManager::manage( this ); | 195 | KAcceleratorManager::manage( this ); |
195 | #else //KAB_EMBEDDED | 196 | #else //KAB_EMBEDDED |
196 | //US qDebug("EmailEditDialog::EmailEditDialog has to be changed"); | 197 | //US qDebug("EmailEditDialog::EmailEditDialog has to be changed"); |
197 | #endif //KAB_EMBEDDED | 198 | #endif //KAB_EMBEDDED |
198 | 199 | ||
199 | } | 200 | } |
200 | 201 | ||
201 | EmailEditDialog::~EmailEditDialog() | 202 | EmailEditDialog::~EmailEditDialog() |
202 | { | 203 | { |
203 | } | 204 | } |
204 | 205 | ||
205 | QStringList EmailEditDialog::emails() const | 206 | QStringList EmailEditDialog::emails() const |
206 | { | 207 | { |
207 | QStringList emails; | 208 | QStringList emails; |
208 | 209 | ||
209 | for ( uint i = 0; i < mEmailListBox->count(); ++i ) | 210 | for ( uint i = 0; i < mEmailListBox->count(); ++i ) |
210 | emails << mEmailListBox->text( i ); | 211 | emails << mEmailListBox->text( i ); |
211 | 212 | ||
212 | return emails; | 213 | return emails; |
213 | } | 214 | } |
214 | 215 | ||
215 | void EmailEditDialog::add() | 216 | void EmailEditDialog::add() |
216 | { | 217 | { |
217 | mEmailListBox->insertItem( mEmailEdit->text() ); | 218 | mEmailListBox->insertItem( mEmailEdit->text() ); |
218 | 219 | ||
219 | mEmailEdit->clear(); | 220 | mEmailEdit->clear(); |
220 | mEmailEdit->setFocus(); | 221 | mEmailEdit->setFocus(); |
221 | 222 | ||
222 | mChanged = true; | 223 | mChanged = true; |
223 | } | 224 | } |
224 | 225 | ||
225 | void EmailEditDialog::edit() | 226 | void EmailEditDialog::edit() |
226 | { | 227 | { |
227 | mEmailEdit->setText( mEmailListBox->currentText() ); | 228 | mEmailEdit->setText( mEmailListBox->currentText() ); |
229 | mEmailListBox->removeItem( mEmailListBox->currentItem() ); | ||
228 | mEmailEdit->setFocus(); | 230 | mEmailEdit->setFocus(); |
229 | } | 231 | } |
230 | 232 | ||
231 | void EmailEditDialog::remove() | 233 | void EmailEditDialog::remove() |
232 | { | 234 | { |
233 | QString address = mEmailListBox->currentText(); | 235 | QString address = mEmailListBox->currentText(); |
234 | 236 | ||
235 | QString text = i18n( "<qt>Are you sure that you want to remove the email address <b>%1</b>?</qt>" ).arg( address ); | 237 | QString text = i18n( "<qt>Are you sure that you want to remove the email address <b>%1</b>?</qt>" ).arg( address ); |
236 | QString caption = i18n( "Confirm Remove" ); | 238 | QString caption = i18n( "Confirm Remove" ); |
237 | 239 | ||
238 | if ( KMessageBox::questionYesNo( this, text, caption ) == KMessageBox::Yes ) { | 240 | if ( KMessageBox::questionYesNo( this, text, caption ) == KMessageBox::Yes ) { |
239 | mEmailListBox->removeItem( mEmailListBox->currentItem() ); | 241 | mEmailListBox->removeItem( mEmailListBox->currentItem() ); |
240 | mChanged = true; | 242 | mChanged = true; |
241 | } | 243 | } |
242 | } | 244 | } |
243 | 245 | ||
244 | bool EmailEditDialog::changed() const | 246 | bool EmailEditDialog::changed() const |
245 | { | 247 | { |
246 | return mChanged; | 248 | return mChanged; |
247 | } | 249 | } |
248 | 250 | ||
249 | void EmailEditDialog::standard() | 251 | void EmailEditDialog::standard() |
250 | { | 252 | { |
251 | QString text = mEmailListBox->currentText(); | 253 | QString text = mEmailListBox->currentText(); |
252 | mEmailListBox->removeItem( mEmailListBox->currentItem() ); | 254 | mEmailListBox->removeItem( mEmailListBox->currentItem() ); |
253 | mEmailListBox->insertItem( text, 0 ); | 255 | mEmailListBox->insertItem( text, 0 ); |
254 | mEmailListBox->setSelected( 0, true ); | 256 | mEmailListBox->setSelected( 0, true ); |
255 | 257 | ||
256 | mChanged = true; | 258 | mChanged = true; |
257 | } | 259 | } |
258 | 260 | ||
259 | void EmailEditDialog::selectionChanged( int index ) | 261 | void EmailEditDialog::selectionChanged( int index ) |
260 | { | 262 | { |
261 | bool value = ( index >= 0 ); // An item is selected | 263 | bool value = ( index >= 0 ); // An item is selected |
262 | 264 | ||
263 | mRemoveButton->setEnabled( value ); | 265 | mRemoveButton->setEnabled( value ); |
264 | mEditButton->setEnabled( value ); | 266 | mEditButton->setEnabled( value ); |
265 | mStandardButton->setEnabled( value ); | 267 | mStandardButton->setEnabled( value ); |
266 | } | 268 | } |
267 | 269 | ||
268 | void EmailEditDialog::emailChanged() | 270 | void EmailEditDialog::emailChanged() |
269 | { | 271 | { |
270 | mAddButton->setEnabled( !mEmailEdit->text().isEmpty() ); | 272 | mAddButton->setEnabled( !mEmailEdit->text().isEmpty() ); |
271 | } | 273 | } |
272 | 274 | ||
273 | #ifndef KAB_EMBEDDED | 275 | #ifndef KAB_EMBEDDED |
274 | #include "emaileditwidget.moc" | 276 | #include "emaileditwidget.moc" |
275 | #endif //KAB_EMBEDDED | 277 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp index 19bb676..a435959 100644 --- a/kaddressbook/phoneeditwidget.cpp +++ b/kaddressbook/phoneeditwidget.cpp | |||
@@ -120,411 +120,434 @@ PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) | |||
120 | mFourthCombo->setMaximumWidth( wid ); | 120 | mFourthCombo->setMaximumWidth( wid ); |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | connect( mPrefEdit, SIGNAL( textChanged( const QString& ) ), | 124 | connect( mPrefEdit, SIGNAL( textChanged( const QString& ) ), |
125 | SLOT( slotPrefEditChanged() ) ); | 125 | SLOT( slotPrefEditChanged() ) ); |
126 | connect( mSecondEdit, SIGNAL( textChanged( const QString& ) ), | 126 | connect( mSecondEdit, SIGNAL( textChanged( const QString& ) ), |
127 | SLOT( slotSecondEditChanged() ) ); | 127 | SLOT( slotSecondEditChanged() ) ); |
128 | connect( mThirdEdit, SIGNAL( textChanged( const QString& ) ), | 128 | connect( mThirdEdit, SIGNAL( textChanged( const QString& ) ), |
129 | SLOT( slotThirdEditChanged() ) ); | 129 | SLOT( slotThirdEditChanged() ) ); |
130 | connect( mFourthEdit, SIGNAL( textChanged( const QString& ) ), | 130 | connect( mFourthEdit, SIGNAL( textChanged( const QString& ) ), |
131 | SLOT( slotFourthEditChanged() ) ); | 131 | SLOT( slotFourthEditChanged() ) ); |
132 | 132 | ||
133 | connect( editButton, SIGNAL( clicked() ), SLOT( edit() ) ); | 133 | connect( editButton, SIGNAL( clicked() ), SLOT( edit() ) ); |
134 | 134 | ||
135 | connect( mPrefCombo, SIGNAL( activated( int ) ), | 135 | connect( mPrefCombo, SIGNAL( activated( int ) ), |
136 | SLOT( updatePrefEdit() ) ); | 136 | SLOT( updatePrefEdit() ) ); |
137 | connect( mSecondCombo, SIGNAL( activated( int ) ), | 137 | connect( mSecondCombo, SIGNAL( activated( int ) ), |
138 | SLOT( updateSecondEdit() ) ); | 138 | SLOT( updateSecondEdit() ) ); |
139 | connect( mThirdCombo, SIGNAL( activated( int ) ), | 139 | connect( mThirdCombo, SIGNAL( activated( int ) ), |
140 | SLOT( updateThirdEdit() ) ); | 140 | SLOT( updateThirdEdit() ) ); |
141 | connect( mFourthCombo, SIGNAL( activated( int ) ), | 141 | connect( mFourthCombo, SIGNAL( activated( int ) ), |
142 | SLOT( updateFourthEdit() ) ); | 142 | SLOT( updateFourthEdit() ) ); |
143 | } | 143 | } |
144 | 144 | ||
145 | PhoneEditWidget::~PhoneEditWidget() | 145 | PhoneEditWidget::~PhoneEditWidget() |
146 | { | 146 | { |
147 | } | 147 | } |
148 | 148 | ||
149 | void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &list ) | 149 | void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &list ) |
150 | { | 150 | { |
151 | mPhoneList.clear(); | 151 | mPhoneList.clear(); |
152 | 152 | ||
153 | // Insert types for existing numbers. | 153 | // Insert types for existing numbers. |
154 | mPrefCombo->insertTypeList( list ); | 154 | mPrefCombo->insertTypeList( list ); |
155 | 155 | ||
156 | QValueList<int> defaultTypes; | 156 | QValueList<int> defaultTypes; |
157 | defaultTypes << KABC::PhoneNumber::Home; | 157 | defaultTypes << KABC::PhoneNumber::Home; |
158 | defaultTypes << KABC::PhoneNumber::Work; | 158 | defaultTypes << KABC::PhoneNumber::Work; |
159 | defaultTypes << KABC::PhoneNumber::Cell; | 159 | defaultTypes << KABC::PhoneNumber::Cell; |
160 | defaultTypes << ( KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax ); | 160 | defaultTypes << ( KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax ); |
161 | defaultTypes << ( KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax ); | 161 | defaultTypes << ( KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax ); |
162 | 162 | ||
163 | // Insert default types. | 163 | // Insert default types. |
164 | // Doing this for mPrefCombo is enough because the list is shared by all | 164 | // Doing this for mPrefCombo is enough because the list is shared by all |
165 | // combos. | 165 | // combos. |
166 | QValueList<int>::ConstIterator it; | 166 | QValueList<int>::ConstIterator it; |
167 | for( it = defaultTypes.begin(); it != defaultTypes.end(); ++it ) { | 167 | for( it = defaultTypes.begin(); it != defaultTypes.end(); ++it ) { |
168 | if ( !mPrefCombo->hasType( *it ) ) | 168 | if ( !mPrefCombo->hasType( *it ) ) |
169 | mPrefCombo->insertType( list, *it, PhoneNumber( "", *it ) ); | 169 | mPrefCombo->insertType( list, *it, PhoneNumber( "", *it ) ); |
170 | } | 170 | } |
171 | 171 | ||
172 | updateCombos(); | 172 | updateCombos(); |
173 | 173 | ||
174 | mPrefCombo->selectType( defaultTypes[ 0 ] ); | 174 | mPrefCombo->selectType( defaultTypes[ 0 ] ); |
175 | mSecondCombo->selectType( defaultTypes[ 1 ] ); | 175 | mSecondCombo->selectType( defaultTypes[ 1 ] ); |
176 | mThirdCombo->selectType( defaultTypes[ 2 ] ); | 176 | mThirdCombo->selectType( defaultTypes[ 2 ] ); |
177 | mFourthCombo->selectType( defaultTypes[ 3 ] ); | 177 | mFourthCombo->selectType( defaultTypes[ 3 ] ); |
178 | 178 | ||
179 | updateLineEdits(); | 179 | updateLineEdits(); |
180 | } | 180 | } |
181 | 181 | ||
182 | void PhoneEditWidget::updateLineEdits() | 182 | void PhoneEditWidget::updateLineEdits() |
183 | { | 183 | { |
184 | updatePrefEdit(); | 184 | updatePrefEdit(); |
185 | updateSecondEdit(); | 185 | updateSecondEdit(); |
186 | updateThirdEdit(); | 186 | updateThirdEdit(); |
187 | updateFourthEdit(); | 187 | updateFourthEdit(); |
188 | } | 188 | } |
189 | 189 | ||
190 | void PhoneEditWidget::updateCombos() | 190 | void PhoneEditWidget::updateCombos() |
191 | { | 191 | { |
192 | mPrefCombo->updateTypes(); | 192 | mPrefCombo->updateTypes(); |
193 | mSecondCombo->updateTypes(); | 193 | mSecondCombo->updateTypes(); |
194 | mThirdCombo->updateTypes(); | 194 | mThirdCombo->updateTypes(); |
195 | mFourthCombo->updateTypes(); | 195 | mFourthCombo->updateTypes(); |
196 | } | 196 | } |
197 | 197 | ||
198 | KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() | 198 | KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() |
199 | { | 199 | { |
200 | KABC::PhoneNumber::List retList; | 200 | KABC::PhoneNumber::List retList; |
201 | 201 | ||
202 | KABC::PhoneNumber::List::Iterator it; | 202 | KABC::PhoneNumber::List::Iterator it; |
203 | for ( it = mPhoneList.begin(); it != mPhoneList.end(); ++it ) | 203 | for ( it = mPhoneList.begin(); it != mPhoneList.end(); ++it ) |
204 | if ( !(*it).number().isEmpty() ) | 204 | if ( !(*it).number().isEmpty() ) |
205 | retList.append( *it ); | 205 | retList.append( *it ); |
206 | 206 | ||
207 | return retList; | 207 | return retList; |
208 | } | 208 | } |
209 | 209 | ||
210 | void PhoneEditWidget::edit() | 210 | void PhoneEditWidget::edit() |
211 | { | 211 | { |
212 | PhoneEditDialog dlg( mPhoneList, this ); | 212 | PhoneEditDialog dlg( mPhoneList, this ); |
213 | 213 | ||
214 | if ( dlg.exec() ) { | 214 | if ( dlg.exec() ) { |
215 | if ( dlg.changed() ) { | 215 | if ( dlg.changed() ) { |
216 | mPhoneList = dlg.phoneNumbers(); | 216 | KABC::PhoneNumber::List list = dlg.phoneNumbers(); |
217 | setPhoneNumbers( list ); | ||
217 | updateCombos(); | 218 | updateCombos(); |
218 | updateLineEdits(); | 219 | updateLineEdits(); |
219 | emit modified(); | 220 | emit modified(); |
220 | } | 221 | } |
221 | } | 222 | } |
222 | } | 223 | } |
223 | 224 | ||
224 | void PhoneEditWidget::updatePrefEdit() | 225 | void PhoneEditWidget::updatePrefEdit() |
225 | { | 226 | { |
226 | updateEdit( mPrefCombo ); | 227 | updateEdit( mPrefCombo ); |
227 | } | 228 | } |
228 | 229 | ||
229 | void PhoneEditWidget::updateSecondEdit() | 230 | void PhoneEditWidget::updateSecondEdit() |
230 | { | 231 | { |
231 | updateEdit( mSecondCombo ); | 232 | updateEdit( mSecondCombo ); |
232 | } | 233 | } |
233 | 234 | ||
234 | void PhoneEditWidget::updateThirdEdit() | 235 | void PhoneEditWidget::updateThirdEdit() |
235 | { | 236 | { |
236 | updateEdit( mThirdCombo ); | 237 | updateEdit( mThirdCombo ); |
237 | } | 238 | } |
238 | 239 | ||
239 | void PhoneEditWidget::updateFourthEdit() | 240 | void PhoneEditWidget::updateFourthEdit() |
240 | { | 241 | { |
241 | updateEdit( mFourthCombo ); | 242 | updateEdit( mFourthCombo ); |
242 | } | 243 | } |
243 | 244 | ||
244 | void PhoneEditWidget::updateEdit( PhoneTypeCombo *combo ) | 245 | void PhoneEditWidget::updateEdit( PhoneTypeCombo *combo ) |
245 | { | 246 | { |
246 | QLineEdit *edit = combo->lineEdit(); | 247 | QLineEdit *edit = combo->lineEdit(); |
247 | if ( !edit ) | 248 | if ( !edit ) |
248 | return; | 249 | return; |
249 | 250 | ||
250 | #if 0 | 251 | #if 0 |
251 | if ( edit == mPrefEdit ) kdDebug(5720) << " prefEdit" << endl; | 252 | if ( edit == mPrefEdit ) kdDebug(5720) << " prefEdit" << endl; |
252 | if ( edit == mSecondEdit ) kdDebug(5720) << " secondEdit" << endl; | 253 | if ( edit == mSecondEdit ) kdDebug(5720) << " secondEdit" << endl; |
253 | if ( edit == mThirdEdit ) kdDebug(5720) << " thirdEdit" << endl; | 254 | if ( edit == mThirdEdit ) kdDebug(5720) << " thirdEdit" << endl; |
254 | if ( edit == mFourthEdit ) kdDebug(5720) << " fourthEdit" << endl; | 255 | if ( edit == mFourthEdit ) kdDebug(5720) << " fourthEdit" << endl; |
255 | #endif | 256 | #endif |
256 | 257 | ||
257 | PhoneNumber::List::Iterator it = combo->selectedElement(); | 258 | PhoneNumber::List::Iterator it = combo->selectedElement(); |
258 | if ( it != mPhoneList.end() ) { | 259 | if ( it != mPhoneList.end() ) { |
259 | edit->setText( (*it).number() ); | 260 | edit->setText( (*it).number() ); |
260 | } else { | 261 | } else { |
261 | kdDebug(5720) << "PhoneEditWidget::updateEdit(): no selected element" << endl; | 262 | kdDebug(5720) << "PhoneEditWidget::updateEdit(): no selected element" << endl; |
262 | } | 263 | } |
263 | } | 264 | } |
264 | 265 | ||
265 | void PhoneEditWidget::slotPrefEditChanged() | 266 | void PhoneEditWidget::slotPrefEditChanged() |
266 | { | 267 | { |
267 | updatePhoneNumber( mPrefCombo ); | 268 | updatePhoneNumber( mPrefCombo ); |
268 | } | 269 | } |
269 | 270 | ||
270 | void PhoneEditWidget::slotSecondEditChanged() | 271 | void PhoneEditWidget::slotSecondEditChanged() |
271 | { | 272 | { |
272 | updatePhoneNumber( mSecondCombo ); | 273 | updatePhoneNumber( mSecondCombo ); |
273 | } | 274 | } |
274 | 275 | ||
275 | void PhoneEditWidget::slotThirdEditChanged() | 276 | void PhoneEditWidget::slotThirdEditChanged() |
276 | { | 277 | { |
277 | updatePhoneNumber( mThirdCombo ); | 278 | updatePhoneNumber( mThirdCombo ); |
278 | } | 279 | } |
279 | 280 | ||
280 | void PhoneEditWidget::slotFourthEditChanged() | 281 | void PhoneEditWidget::slotFourthEditChanged() |
281 | { | 282 | { |
282 | updatePhoneNumber( mFourthCombo ); | 283 | updatePhoneNumber( mFourthCombo ); |
283 | } | 284 | } |
284 | 285 | ||
285 | void PhoneEditWidget::updatePhoneNumber( PhoneTypeCombo *combo ) | 286 | void PhoneEditWidget::updatePhoneNumber( PhoneTypeCombo *combo ) |
286 | { | 287 | { |
287 | QLineEdit *edit = combo->lineEdit(); | 288 | QLineEdit *edit = combo->lineEdit(); |
288 | if ( !edit ) return; | 289 | if ( !edit ) return; |
289 | 290 | ||
290 | PhoneNumber::List::Iterator it = combo->selectedElement(); | 291 | PhoneNumber::List::Iterator it = combo->selectedElement(); |
291 | if ( it != mPhoneList.end() ) { | 292 | if ( it != mPhoneList.end() ) { |
292 | (*it).setNumber( edit->text() ); | 293 | (*it).setNumber( edit->text() ); |
293 | } | 294 | } |
294 | 295 | ||
295 | updateOtherEdit( combo, mPrefCombo ); | 296 | updateOtherEdit( combo, mPrefCombo ); |
296 | updateOtherEdit( combo, mSecondCombo ); | 297 | updateOtherEdit( combo, mSecondCombo ); |
297 | updateOtherEdit( combo, mThirdCombo ); | 298 | updateOtherEdit( combo, mThirdCombo ); |
298 | updateOtherEdit( combo, mFourthCombo ); | 299 | updateOtherEdit( combo, mFourthCombo ); |
299 | 300 | ||
300 | emit modified(); | 301 | emit modified(); |
301 | } | 302 | } |
302 | 303 | ||
303 | void PhoneEditWidget::updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo ) | 304 | void PhoneEditWidget::updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo ) |
304 | { | 305 | { |
305 | if ( combo == otherCombo ) return; | 306 | if ( combo == otherCombo ) return; |
306 | 307 | ||
307 | if ( combo->currentItem() == otherCombo->currentItem() ) { | 308 | if ( combo->currentItem() == otherCombo->currentItem() ) { |
308 | updateEdit( otherCombo ); | 309 | updateEdit( otherCombo ); |
309 | } | 310 | } |
310 | } | 311 | } |
311 | 312 | ||
312 | /////////////////////////////////////////// | 313 | /////////////////////////////////////////// |
313 | // PhoneEditDialog | 314 | // PhoneEditDialog |
314 | 315 | ||
315 | class PhoneViewItem : public QListViewItem | 316 | class PhoneViewItem : public QListViewItem |
316 | { | 317 | { |
317 | public: | 318 | public: |
318 | PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ); | 319 | PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ); |
319 | 320 | ||
320 | void setPhoneNumber( const KABC::PhoneNumber &number ) | 321 | void setPhoneNumber( const KABC::PhoneNumber &number ) |
321 | { | 322 | { |
322 | mPhoneNumber = number; | 323 | mPhoneNumber = number; |
323 | makeText(); | 324 | makeText(); |
324 | } | 325 | } |
325 | 326 | ||
326 | QString key() { return mPhoneNumber.id(); } | 327 | QString key() { return mPhoneNumber.id(); } |
327 | QString country() { return ""; } | 328 | QString country() { return ""; } |
328 | QString region() { return ""; } | 329 | QString region() { return ""; } |
329 | QString number() { return ""; } | 330 | QString number() { return ""; } |
330 | 331 | ||
331 | KABC::PhoneNumber phoneNumber() { return mPhoneNumber; } | 332 | KABC::PhoneNumber phoneNumber() { return mPhoneNumber; } |
332 | 333 | ||
333 | private: | 334 | private: |
334 | void makeText(); | 335 | void makeText(); |
335 | 336 | ||
336 | KABC::PhoneNumber mPhoneNumber; | 337 | KABC::PhoneNumber mPhoneNumber; |
337 | }; | 338 | }; |
338 | 339 | ||
339 | PhoneViewItem::PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ) | 340 | PhoneViewItem::PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ) |
340 | : QListViewItem( parent ), mPhoneNumber( number ) | 341 | : QListViewItem( parent ), mPhoneNumber( number ) |
341 | { | 342 | { |
343 | #ifdef DESKTOP_VERSION | ||
344 | setRenameEnabled ( 0, true ); | ||
345 | #endif | ||
342 | makeText(); | 346 | makeText(); |
343 | } | 347 | } |
344 | 348 | ||
345 | void PhoneViewItem::makeText() | 349 | void PhoneViewItem::makeText() |
346 | { | 350 | { |
347 | /** | 351 | /** |
348 | * Will be used in future versions of kaddressbook/libkabc | 352 | * Will be used in future versions of kaddressbook/libkabc |
349 | 353 | ||
350 | setText( 0, mPhoneNumber.country() ); | 354 | setText( 0, mPhoneNumber.country() ); |
351 | setText( 1, mPhoneNumber.region() ); | 355 | setText( 1, mPhoneNumber.region() ); |
352 | setText( 2, mPhoneNumber.number() ); | 356 | setText( 2, mPhoneNumber.number() ); |
353 | setText( 3, mPhoneNumber.typeLabel() ); | 357 | setText( 3, mPhoneNumber.typeLabel() ); |
354 | */ | 358 | */ |
355 | 359 | ||
356 | setText( 0, mPhoneNumber.number() ); | 360 | setText( 0, mPhoneNumber.number() ); |
357 | setText( 1, mPhoneNumber.typeLabel() ); | 361 | setText( 1, mPhoneNumber.typeLabel() ); |
358 | } | 362 | } |
359 | 363 | ||
360 | PhoneEditDialog::PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name ) | 364 | PhoneEditDialog::PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name ) |
361 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Numbers" ), | 365 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Numbers" ), |
362 | KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, | 366 | KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, |
363 | parent, name, true) | 367 | parent, name, true) |
364 | { | 368 | { |
365 | mPhoneNumberList = list; | 369 | mPhoneNumberList = list; |
366 | 370 | ||
367 | QWidget *page = plainPage(); | 371 | QWidget *page = plainPage(); |
368 | 372 | ||
369 | QGridLayout *layout = new QGridLayout( page, 1, 2 ); | 373 | QGridLayout *layout = new QGridLayout( page, 1, 2 ); |
370 | layout->setSpacing( spacingHint() ); | 374 | layout->setSpacing( spacingHint() ); |
371 | 375 | ||
372 | mListView = new KListView( page ); | 376 | mListView = new KListView( page ); |
373 | mListView->setAllColumnsShowFocus( true ); | 377 | mListView->setAllColumnsShowFocus( true ); |
374 | mListView->addColumn( i18n( "Number" ) ); | 378 | mListView->addColumn( i18n( "Number" ) ); |
375 | mListView->addColumn( i18n( "Type" ) ); | 379 | mListView->addColumn( i18n( "Type" ) ); |
376 | 380 | ||
377 | KButtonBox *buttonBox = new KButtonBox( page, Vertical ); | 381 | KButtonBox *buttonBox = new KButtonBox( page, Vertical ); |
378 | 382 | ||
379 | buttonBox->addButton( i18n( "&Add..." ), this, SLOT( slotAddPhoneNumber() ) ); | 383 | buttonBox->addButton( i18n( "&Add..." ), this, SLOT( slotAddPhoneNumber() ) ); |
380 | mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( slotEditPhoneNumber() ) ); | 384 | mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( slotEditPhoneNumber() ) ); |
381 | mEditButton->setEnabled( false ); | 385 | mEditButton->setEnabled( false ); |
382 | mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( slotRemovePhoneNumber() ) ); | 386 | mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( slotRemovePhoneNumber() ) ); |
383 | mRemoveButton->setEnabled( false ); | 387 | mRemoveButton->setEnabled( false ); |
384 | buttonBox->layout(); | 388 | buttonBox->layout(); |
385 | 389 | ||
386 | layout->addWidget( mListView, 0, 0 ); | 390 | layout->addWidget( mListView, 0, 0 ); |
387 | layout->addWidget( buttonBox, 0, 1 ); | 391 | layout->addWidget( buttonBox, 0, 1 ); |
388 | 392 | ||
389 | connect( mListView, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged()) ); | 393 | connect( mListView, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged()) ); |
390 | connect( mListView, SIGNAL(doubleClicked( QListViewItem *, const QPoint &, int )), this, SLOT( slotEditPhoneNumber())); | 394 | connect( mListView, SIGNAL(doubleClicked( QListViewItem *, const QPoint &, int )), this, SLOT( slotEditPhoneNumber())); |
391 | 395 | ||
392 | KABC::PhoneNumber::List::Iterator it; | 396 | KABC::PhoneNumber::List::Iterator it; |
393 | for ( it = mPhoneNumberList.begin(); it != mPhoneNumberList.end(); ++it ) | 397 | for ( it = mPhoneNumberList.begin(); it != mPhoneNumberList.end(); ++it ) |
394 | new PhoneViewItem( mListView, *it ); | 398 | new PhoneViewItem( mListView, *it ); |
395 | 399 | ||
396 | mChanged = false; | 400 | mChanged = false; |
397 | } | 401 | } |
398 | 402 | ||
399 | PhoneEditDialog::~PhoneEditDialog() | 403 | PhoneEditDialog::~PhoneEditDialog() |
400 | { | 404 | { |
401 | } | 405 | } |
402 | 406 | ||
403 | void PhoneEditDialog::slotAddPhoneNumber() | 407 | void PhoneEditDialog::slotAddPhoneNumber() |
404 | { | 408 | { |
405 | KABC::PhoneNumber tmp( "", 0 ); | 409 | KABC::PhoneNumber tmp( "", 0 ); |
406 | PhoneTypeDialog dlg( tmp, this ); | 410 | PhoneTypeDialog dlg( tmp, this ); |
407 | 411 | ||
408 | if ( dlg.exec() ) { | 412 | if ( dlg.exec() ) { |
409 | KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); | 413 | QListViewItem* i = mListView->firstChild(); |
410 | mPhoneNumberList.append( phoneNumber ); | 414 | KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); |
411 | new PhoneViewItem( mListView, phoneNumber ); | 415 | bool insert = true; |
412 | 416 | while ( i ) { | |
413 | mChanged = true; | 417 | PhoneViewItem* p = ( PhoneViewItem* ) i; |
418 | KABC::PhoneNumber pn = p->phoneNumber(); | ||
419 | if ( (pn.type() | KABC::PhoneNumber::Pref) == (phoneNumber.type() | KABC::PhoneNumber::Pref) ) { | ||
420 | if ( p->text(0).isEmpty()) { | ||
421 | p->setPhoneNumber( phoneNumber ); | ||
422 | mPhoneNumberList.remove( pn ); | ||
423 | mPhoneNumberList.append( phoneNumber ); | ||
424 | insert = false; | ||
425 | break; | ||
426 | } | ||
427 | } | ||
428 | i = i->nextSibling(); | ||
429 | } | ||
430 | if ( insert ) { | ||
431 | mPhoneNumberList.append( phoneNumber ); | ||
432 | new PhoneViewItem( mListView, phoneNumber ); | ||
433 | } | ||
434 | mChanged = true; | ||
414 | } | 435 | } |
415 | } | 436 | } |
416 | 437 | ||
417 | void PhoneEditDialog::slotRemovePhoneNumber() | 438 | void PhoneEditDialog::slotRemovePhoneNumber() |
418 | { | 439 | { |
419 | PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); | 440 | PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); |
420 | if ( !item ) | 441 | if ( !item ) |
421 | return; | 442 | return; |
422 | 443 | ||
423 | mPhoneNumberList.remove( item->phoneNumber() ); | 444 | mPhoneNumberList.remove( item->phoneNumber() ); |
424 | QListViewItem *currItem = mListView->currentItem(); | 445 | QListViewItem *currItem = mListView->currentItem(); |
425 | mListView->takeItem( currItem ); | 446 | mListView->takeItem( currItem ); |
426 | delete currItem; | 447 | delete currItem; |
427 | 448 | ||
428 | mChanged = true; | 449 | mChanged = true; |
429 | } | 450 | } |
430 | 451 | ||
431 | void PhoneEditDialog::slotEditPhoneNumber() | 452 | void PhoneEditDialog::slotEditPhoneNumber() |
432 | { | 453 | { |
433 | PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); | 454 | PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); |
434 | if ( !item ) | 455 | if ( !item ) |
435 | return; | 456 | return; |
436 | 457 | ||
437 | PhoneTypeDialog dlg( item->phoneNumber(), this ); | 458 | PhoneTypeDialog dlg( item->phoneNumber(), this ); |
438 | 459 | ||
439 | if ( dlg.exec() ) { | 460 | if ( dlg.exec() ) { |
440 | slotRemovePhoneNumber(); | 461 | slotRemovePhoneNumber(); |
441 | KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); | 462 | KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); |
442 | mPhoneNumberList.append( phoneNumber ); | 463 | mPhoneNumberList.append( phoneNumber ); |
443 | new PhoneViewItem( mListView, phoneNumber ); | 464 | new PhoneViewItem( mListView, phoneNumber ); |
444 | 465 | ||
445 | mChanged = true; | 466 | mChanged = true; |
446 | } | 467 | } |
447 | } | 468 | } |
448 | 469 | ||
449 | void PhoneEditDialog::slotSelectionChanged() | 470 | void PhoneEditDialog::slotSelectionChanged() |
450 | { | 471 | { |
451 | bool state = ( mListView->currentItem() != 0 ); | 472 | bool state = ( mListView->currentItem() != 0 ); |
452 | 473 | ||
453 | mRemoveButton->setEnabled( state ); | 474 | mRemoveButton->setEnabled( state ); |
454 | mEditButton->setEnabled( state ); | 475 | mEditButton->setEnabled( state ); |
455 | } | 476 | } |
456 | 477 | ||
457 | const KABC::PhoneNumber::List &PhoneEditDialog::phoneNumbers() | 478 | const KABC::PhoneNumber::List &PhoneEditDialog::phoneNumbers() |
458 | { | 479 | { |
459 | return mPhoneNumberList; | 480 | return mPhoneNumberList; |
460 | } | 481 | } |
461 | 482 | ||
462 | bool PhoneEditDialog::changed() const | 483 | bool PhoneEditDialog::changed() const |
463 | { | 484 | { |
464 | return mChanged; | 485 | return mChanged; |
465 | } | 486 | } |
466 | 487 | ||
467 | /////////////////////////////////////////// | 488 | /////////////////////////////////////////// |
468 | // PhoneTypeDialog | 489 | // PhoneTypeDialog |
469 | PhoneTypeDialog::PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, | 490 | PhoneTypeDialog::PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, |
470 | QWidget *parent, const char *name) | 491 | QWidget *parent, const char *name) |
471 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Number" ), | 492 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Number" ), |
472 | KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, | 493 | KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, |
473 | parent, name, true), mPhoneNumber( phoneNumber ) | 494 | parent, name, true), mPhoneNumber( phoneNumber ) |
474 | { | 495 | { |
475 | QWidget *page = plainPage(); | 496 | QWidget *page = plainPage(); |
476 | QLabel *label = 0; | 497 | QLabel *label = 0; |
477 | QGridLayout *layout = new QGridLayout( page, 3, 2, marginHint(), spacingHint() ); | 498 | QGridLayout *layout = new QGridLayout( page, 3, 2, marginHint(), spacingHint() ); |
478 | 499 | ||
479 | label = new QLabel( i18n( "Number:" ), page ); | 500 | label = new QLabel( i18n( "Number:" ), page ); |
480 | layout->addWidget( label, 0, 0 ); | 501 | layout->addWidget( label, 0, 0 ); |
481 | mNumber = new KLineEdit( page ); | 502 | mNumber = new KLineEdit( page ); |
482 | layout->addWidget( mNumber, 0, 1 ); | 503 | layout->addWidget( mNumber, 0, 1 ); |
483 | 504 | ||
484 | mPreferredBox = new QCheckBox( i18n( "This is the preferred phone number" ), page ); | 505 | mPreferredBox = new QCheckBox( i18n( "This is the preferred phone number" ), page ); |
485 | layout->addMultiCellWidget( mPreferredBox, 1, 1, 0, 1 ); | 506 | layout->addMultiCellWidget( mPreferredBox, 1, 1, 0, 1 ); |
486 | 507 | ||
487 | mGroup = new QButtonGroup( 2, Horizontal, i18n( "Types" ), page ); | 508 | mGroup = new QButtonGroup( 2, Horizontal, i18n( "Types" ), page ); |
488 | layout->addMultiCellWidget( mGroup, 2, 2, 0, 1 ); | 509 | layout->addMultiCellWidget( mGroup, 2, 2, 0, 1 ); |
489 | 510 | ||
490 | // fill widgets | 511 | // fill widgets |
491 | mNumber->setText( mPhoneNumber.number() ); | 512 | mNumber->setText( mPhoneNumber.number() ); |
492 | 513 | ||
493 | mTypeList = KABC::PhoneNumber::typeList(); | 514 | mTypeList = KABC::PhoneNumber::typeList(); |
494 | mTypeList.remove( KABC::PhoneNumber::Pref ); | 515 | mTypeList.remove( KABC::PhoneNumber::Pref ); |
495 | 516 | ||
496 | KABC::PhoneNumber::TypeList::Iterator it; | 517 | KABC::PhoneNumber::TypeList::Iterator it; |
497 | for ( it = mTypeList.begin(); it != mTypeList.end(); ++it ) | 518 | for ( it = mTypeList.begin(); it != mTypeList.end(); ++it ) |
498 | new QCheckBox( KABC::PhoneNumber::typeLabel( *it ), mGroup ); | 519 | new QCheckBox( KABC::PhoneNumber::typeLabel( *it ), mGroup ); |
499 | 520 | ||
500 | for ( int i = 0; i < mGroup->count(); ++i ) { | 521 | for ( int i = 0; i < mGroup->count(); ++i ) { |
501 | int type = mPhoneNumber.type(); | 522 | int type = mPhoneNumber.type(); |
502 | QCheckBox *box = (QCheckBox*)mGroup->find( i ); | 523 | QCheckBox *box = (QCheckBox*)mGroup->find( i ); |
503 | box->setChecked( type & mTypeList[ i ] ); | 524 | box->setChecked( type & mTypeList[ i ] ); |
504 | } | 525 | } |
505 | 526 | ||
506 | mPreferredBox->setChecked( mPhoneNumber.type() & KABC::PhoneNumber::Pref ); | 527 | mPreferredBox->setChecked( mPhoneNumber.type() & KABC::PhoneNumber::Pref ); |
528 | mNumber->setFocus(); | ||
529 | mNumber->setSelection( 0, 1024); | ||
507 | } | 530 | } |
508 | 531 | ||
509 | KABC::PhoneNumber PhoneTypeDialog::phoneNumber() | 532 | KABC::PhoneNumber PhoneTypeDialog::phoneNumber() |
510 | { | 533 | { |
511 | mPhoneNumber.setNumber( mNumber->text() ); | 534 | mPhoneNumber.setNumber( mNumber->text() ); |
512 | 535 | ||
513 | int type = 0; | 536 | int type = 0; |
514 | for ( int i = 0; i < mGroup->count(); ++i ) { | 537 | for ( int i = 0; i < mGroup->count(); ++i ) { |
515 | QCheckBox *box = (QCheckBox*)mGroup->find( i ); | 538 | QCheckBox *box = (QCheckBox*)mGroup->find( i ); |
516 | if ( box->isChecked() ) | 539 | if ( box->isChecked() ) |
517 | type += mTypeList[ i ]; | 540 | type += mTypeList[ i ]; |
518 | } | 541 | } |
519 | 542 | ||
520 | if ( mPreferredBox->isChecked() ) | 543 | if ( mPreferredBox->isChecked() ) |
521 | mPhoneNumber.setType( type | KABC::PhoneNumber::Pref ); | 544 | mPhoneNumber.setType( type | KABC::PhoneNumber::Pref ); |
522 | else | 545 | else |
523 | mPhoneNumber.setType( type & ~KABC::PhoneNumber::Pref ); | 546 | mPhoneNumber.setType( type & ~KABC::PhoneNumber::Pref ); |
524 | 547 | ||
525 | return mPhoneNumber; | 548 | return mPhoneNumber; |
526 | } | 549 | } |
527 | 550 | ||
528 | #ifndef KAB_EMBEDDED | 551 | #ifndef KAB_EMBEDDED |
529 | #include "phoneeditwidget.moc" | 552 | #include "phoneeditwidget.moc" |
530 | #endif //KAB_EMBEDDED | 553 | #endif //KAB_EMBEDDED |