Diffstat (limited to 'kaddressbook/nameeditdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/nameeditdialog.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/kaddressbook/nameeditdialog.cpp b/kaddressbook/nameeditdialog.cpp index 8213c2b..f5dba0f 100644 --- a/kaddressbook/nameeditdialog.cpp +++ b/kaddressbook/nameeditdialog.cpp | |||
@@ -164,130 +164,132 @@ NameEditDialog::NameEditDialog( const KABC::Addressee &addr, int type, | |||
164 | connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); | 164 | connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); |
165 | connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); | 165 | connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); |
166 | connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); | 166 | connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); |
167 | connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); | 167 | connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); |
168 | connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); | 168 | connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); |
169 | connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); | 169 | connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); |
170 | connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); | 170 | connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); |
171 | connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); | 171 | connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); |
172 | connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( modified() ) ); | 172 | connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( modified() ) ); |
173 | connect( mFormattedNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); | 173 | connect( mFormattedNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); |
174 | 174 | ||
175 | updateTypeCombo(); | 175 | updateTypeCombo(); |
176 | mFormattedNameCombo->setCurrentItem( type ); | 176 | mFormattedNameCombo->setCurrentItem( type ); |
177 | 177 | ||
178 | 178 | ||
179 | mChanged = false; | 179 | mChanged = false; |
180 | } | 180 | } |
181 | 181 | ||
182 | NameEditDialog::~NameEditDialog() | 182 | NameEditDialog::~NameEditDialog() |
183 | { | 183 | { |
184 | } | 184 | } |
185 | 185 | ||
186 | QString NameEditDialog::familyName() const | 186 | QString NameEditDialog::familyName() const |
187 | { | 187 | { |
188 | return mFamilyNameEdit->text(); | 188 | return mFamilyNameEdit->text(); |
189 | } | 189 | } |
190 | 190 | ||
191 | QString NameEditDialog::givenName() const | 191 | QString NameEditDialog::givenName() const |
192 | { | 192 | { |
193 | return mGivenNameEdit->text(); | 193 | return mGivenNameEdit->text(); |
194 | } | 194 | } |
195 | 195 | ||
196 | QString NameEditDialog::prefix() const | 196 | QString NameEditDialog::prefix() const |
197 | { | 197 | { |
198 | return mPrefixCombo->currentText(); | 198 | return mPrefixCombo->currentText(); |
199 | } | 199 | } |
200 | 200 | ||
201 | QString NameEditDialog::suffix() const | 201 | QString NameEditDialog::suffix() const |
202 | { | 202 | { |
203 | return mSuffixCombo->currentText(); | 203 | return mSuffixCombo->currentText(); |
204 | } | 204 | } |
205 | 205 | ||
206 | QString NameEditDialog::additionalName() const | 206 | QString NameEditDialog::additionalName() const |
207 | { | 207 | { |
208 | return mAdditionalNameEdit->text(); | 208 | return mAdditionalNameEdit->text(); |
209 | } | 209 | } |
210 | 210 | ||
211 | QString NameEditDialog::customFormattedName() const | 211 | QString NameEditDialog::customFormattedName() const |
212 | { | 212 | { |
213 | return mFormattedNameEdit->text(); | 213 | return mFormattedNameEdit->text(); |
214 | } | 214 | } |
215 | 215 | ||
216 | int NameEditDialog::formattedNameType() const | 216 | int NameEditDialog::formattedNameType() const |
217 | { | 217 | { |
218 | return mFormattedNameCombo->currentItem(); | 218 | return mFormattedNameCombo->currentItem(); |
219 | } | 219 | } |
220 | 220 | ||
221 | bool NameEditDialog::changed() const | 221 | bool NameEditDialog::changed() const |
222 | { | 222 | { |
223 | return mChanged; | 223 | return mChanged; |
224 | } | 224 | } |
225 | 225 | ||
226 | QString NameEditDialog::formattedName( const KABC::Addressee &addr, int type ) | 226 | QString NameEditDialog::formattedName( const KABC::Addressee &addr, int type ) |
227 | { | 227 | { |
228 | QString retval; | ||
228 | switch ( type ) { | 229 | switch ( type ) { |
229 | case SimpleName: | 230 | case SimpleName: |
230 | return addr.givenName() + " " + addr.familyName(); | 231 | retval = addr.givenName() + " " + addr.familyName(); |
231 | break; | 232 | break; |
232 | case FullName: | 233 | case FullName: |
233 | return addr.prefix() + " " + addr.givenName() + " " + | 234 | retval =addr.prefix() + " " + addr.givenName() + " " + |
234 | addr.additionalName() + " " + addr.familyName() + " " + | 235 | addr.additionalName() + " " + addr.familyName() + " " + |
235 | addr.suffix(); | 236 | addr.suffix(); |
236 | break; | 237 | break; |
237 | case ReverseName: | 238 | case ReverseName: |
238 | return addr.familyName() + ", " + addr.givenName(); | 239 | retval = addr.familyName() + ", " + addr.givenName(); |
239 | break; | 240 | break; |
240 | default: | 241 | default: |
241 | return ""; | 242 | return ""; |
242 | break; | 243 | break; |
243 | } | 244 | } |
245 | return retval.stripWhiteSpace (); | ||
244 | } | 246 | } |
245 | 247 | ||
246 | void NameEditDialog::parseBoxChanged( bool value ) | 248 | void NameEditDialog::parseBoxChanged( bool value ) |
247 | { | 249 | { |
248 | //AddresseeConfig::instance()->setUid( addr.uid() ); | 250 | //AddresseeConfig::instance()->setUid( addr.uid() ); |
249 | AddresseeConfig::instance()->setAutomaticNameParsing( value ); | 251 | AddresseeConfig::instance()->setAutomaticNameParsing( value ); |
250 | } | 252 | } |
251 | 253 | ||
252 | void NameEditDialog::typeChanged( int pos ) | 254 | void NameEditDialog::typeChanged( int pos ) |
253 | { | 255 | { |
254 | mFormattedNameEdit->setEnabled( pos == 0 ); | 256 | mFormattedNameEdit->setEnabled( pos == 0 ); |
255 | } | 257 | } |
256 | 258 | ||
257 | void NameEditDialog::modified() | 259 | void NameEditDialog::modified() |
258 | { | 260 | { |
259 | mChanged = true; | 261 | mChanged = true; |
260 | } | 262 | } |
261 | 263 | ||
262 | void NameEditDialog::updateTypeCombo() | 264 | void NameEditDialog::updateTypeCombo() |
263 | { | 265 | { |
264 | KABC::Addressee addr; | 266 | KABC::Addressee addr; |
265 | addr.setPrefix( mPrefixCombo->currentText() ); | 267 | addr.setPrefix( mPrefixCombo->currentText() ); |
266 | addr.setGivenName( mGivenNameEdit->text() ); | 268 | addr.setGivenName( mGivenNameEdit->text() ); |
267 | addr.setAdditionalName( mAdditionalNameEdit->text() ); | 269 | addr.setAdditionalName( mAdditionalNameEdit->text() ); |
268 | addr.setFamilyName( mFamilyNameEdit->text() ); | 270 | addr.setFamilyName( mFamilyNameEdit->text() ); |
269 | addr.setSuffix( mSuffixCombo->currentText() ); | 271 | addr.setSuffix( mSuffixCombo->currentText() ); |
270 | 272 | ||
271 | int pos = mFormattedNameCombo->currentItem(); | 273 | int pos = mFormattedNameCombo->currentItem(); |
272 | 274 | ||
273 | mFormattedNameCombo->clear(); | 275 | mFormattedNameCombo->clear(); |
274 | mFormattedNameCombo->insertItem( i18n( "Custom" ) ); | 276 | mFormattedNameCombo->insertItem( i18n( "Custom" ) ); |
275 | mFormattedNameCombo->insertItem( formattedName( addr, SimpleName ) ); | 277 | mFormattedNameCombo->insertItem( formattedName( addr, SimpleName ) ); |
276 | mFormattedNameCombo->insertItem( formattedName( addr, FullName ) ); | 278 | mFormattedNameCombo->insertItem( formattedName( addr, FullName ) ); |
277 | mFormattedNameCombo->insertItem( formattedName( addr, ReverseName ) ); | 279 | mFormattedNameCombo->insertItem( formattedName( addr, ReverseName ) ); |
278 | 280 | ||
279 | mFormattedNameCombo->setCurrentItem( pos ); | 281 | mFormattedNameCombo->setCurrentItem( pos ); |
280 | } | 282 | } |
281 | 283 | ||
282 | void NameEditDialog::slotHelp() | 284 | void NameEditDialog::slotHelp() |
283 | { | 285 | { |
284 | #ifndef KAB_EMBEDDED | 286 | #ifndef KAB_EMBEDDED |
285 | kapp->invokeHelp( "managing-contacts-automatic-nameparsing" ); | 287 | kapp->invokeHelp( "managing-contacts-automatic-nameparsing" ); |
286 | #else //KAB_EMBEDDED | 288 | #else //KAB_EMBEDDED |
287 | qDebug("NameEditDialog::slotHelp Help is not supported yet"); | 289 | qDebug("NameEditDialog::slotHelp Help is not supported yet"); |
288 | #endif //KAB_EMBEDDED | 290 | #endif //KAB_EMBEDDED |
289 | } | 291 | } |
290 | 292 | ||
291 | #ifndef KAB_EMBEDDED | 293 | #ifndef KAB_EMBEDDED |
292 | #include "nameeditdialog.moc" | 294 | #include "nameeditdialog.moc" |
293 | #endif //KAB_EMBEDDED | 295 | #endif //KAB_EMBEDDED |