-rw-r--r-- | kaddressbook/nameeditdialog.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/kaddressbook/nameeditdialog.cpp b/kaddressbook/nameeditdialog.cpp index f5dba0f..199f3d6 100644 --- a/kaddressbook/nameeditdialog.cpp +++ b/kaddressbook/nameeditdialog.cpp | |||
@@ -111,185 +111,190 @@ NameEditDialog::NameEditDialog( const KABC::Addressee &addr, int type, | |||
111 | connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( modified() ) ); | 111 | connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( modified() ) ); |
112 | layout->addMultiCellWidget( mParseBox, 6, 6, 0, 2 ); | 112 | layout->addMultiCellWidget( mParseBox, 6, 6, 0, 2 ); |
113 | 113 | ||
114 | // Fill in the values | 114 | // Fill in the values |
115 | mFamilyNameEdit->setText( addr.familyName() ); | 115 | mFamilyNameEdit->setText( addr.familyName() ); |
116 | mGivenNameEdit->setText( addr.givenName() ); | 116 | mGivenNameEdit->setText( addr.givenName() ); |
117 | mAdditionalNameEdit->setText( addr.additionalName() ); | 117 | mAdditionalNameEdit->setText( addr.additionalName() ); |
118 | mFormattedNameEdit->setText( addr.formattedName() ); | 118 | mFormattedNameEdit->setText( addr.formattedName() ); |
119 | 119 | ||
120 | // Prefix and suffix combos | 120 | // Prefix and suffix combos |
121 | //US KConfig config( "kabcrc" ); | 121 | //US KConfig config( "kabcrc" ); |
122 | KConfig config( locateLocal("config", "kabcrc") ); | 122 | KConfig config( locateLocal("config", "kabcrc") ); |
123 | config.setGroup( "General" ); | 123 | config.setGroup( "General" ); |
124 | 124 | ||
125 | QStringList sTitle; | 125 | QStringList sTitle; |
126 | sTitle += i18n( "Dr." ); | 126 | sTitle += i18n( "Dr." ); |
127 | sTitle += i18n( "Miss" ); | 127 | sTitle += i18n( "Miss" ); |
128 | sTitle += i18n( "Mr." ); | 128 | sTitle += i18n( "Mr." ); |
129 | sTitle += i18n( "Mrs." ); | 129 | sTitle += i18n( "Mrs." ); |
130 | sTitle += i18n( "Ms." ); | 130 | sTitle += i18n( "Ms." ); |
131 | sTitle += i18n( "Prof." ); | 131 | sTitle += i18n( "Prof." ); |
132 | sTitle += config.readListEntry( "Prefixes" ); | 132 | sTitle += config.readListEntry( "Prefixes" ); |
133 | sTitle.sort(); | 133 | sTitle.sort(); |
134 | 134 | ||
135 | QStringList sSuffix; | 135 | QStringList sSuffix; |
136 | sSuffix += i18n( "I" ); | 136 | sSuffix += i18n( "I" ); |
137 | sSuffix += i18n( "II" ); | 137 | sSuffix += i18n( "II" ); |
138 | sSuffix += i18n( "III" ); | 138 | sSuffix += i18n( "III" ); |
139 | sSuffix += i18n( "Jr." ); | 139 | sSuffix += i18n( "Jr." ); |
140 | sSuffix += i18n( "Sr." ); | 140 | sSuffix += i18n( "Sr." ); |
141 | sSuffix += config.readListEntry( "Suffixes" ); | 141 | sSuffix += config.readListEntry( "Suffixes" ); |
142 | sSuffix.sort(); | 142 | sSuffix.sort(); |
143 | 143 | ||
144 | mPrefixCombo->insertStringList( sTitle ); | 144 | mPrefixCombo->insertStringList( sTitle ); |
145 | mSuffixCombo->insertStringList( sSuffix ); | 145 | mSuffixCombo->insertStringList( sSuffix ); |
146 | 146 | ||
147 | #ifndef KAB_EMBEDDED | 147 | #ifndef KAB_EMBEDDED |
148 | mPrefixCombo->setCurrentText( addr.prefix() ); | 148 | mPrefixCombo->setCurrentText( addr.prefix() ); |
149 | mSuffixCombo->setCurrentText( addr.suffix() ); | 149 | mSuffixCombo->setCurrentText( addr.suffix() ); |
150 | #else //KAB_EMBEDDED | 150 | #else //KAB_EMBEDDED |
151 | mPrefixCombo->setEditText( addr.prefix() ); | 151 | mPrefixCombo->setEditText( addr.prefix() ); |
152 | mSuffixCombo->setEditText( addr.suffix() ); | 152 | mSuffixCombo->setEditText( addr.suffix() ); |
153 | #endif //KAB_EMBEDDED | 153 | #endif //KAB_EMBEDDED |
154 | 154 | ||
155 | AddresseeConfig::instance()->setUid( addr.uid() ); | 155 | AddresseeConfig::instance()->setUid( addr.uid() ); |
156 | mParseBox->setChecked( AddresseeConfig::instance()->automaticNameParsing() ); | 156 | mParseBox->setChecked( AddresseeConfig::instance()->automaticNameParsing() ); |
157 | 157 | ||
158 | #ifndef KAB_EMBEDDED | 158 | #ifndef KAB_EMBEDDED |
159 | KAcceleratorManager::manage( this ); | 159 | KAcceleratorManager::manage( this ); |
160 | #endif //KAB_EMBEDDED | 160 | #endif //KAB_EMBEDDED |
161 | 161 | ||
162 | connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); | 162 | connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); |
163 | connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); | 163 | connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); |
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 | QString retval; |
229 | switch ( type ) { | 229 | switch ( type ) { |
230 | case SimpleName: | 230 | case SimpleName: |
231 | retval = addr.givenName() + " " + addr.familyName(); | 231 | retval = addr.givenName() + " " + addr.familyName(); |
232 | break; | 232 | break; |
233 | case FullName: | 233 | case FullName: |
234 | retval =addr.prefix() + " " + addr.givenName() + " " + | 234 | retval =addr.prefix() + " " + addr.givenName() + " " + |
235 | addr.additionalName() + " " + addr.familyName() + " " + | 235 | addr.additionalName() + " " + addr.familyName() + " " + |
236 | addr.suffix(); | 236 | addr.suffix(); |
237 | break; | 237 | break; |
238 | case ReverseName: | 238 | case ReverseName: |
239 | retval = addr.familyName() + ", " + addr.givenName(); | 239 | if ( !addr.familyName().isEmpty() ) { |
240 | retval = addr.familyName(); | ||
241 | if ( !addr.givenName().isEmpty() ) | ||
242 | retval += ", " + addr.givenName(); | ||
243 | } else | ||
244 | retval = addr.givenName(); | ||
240 | break; | 245 | break; |
241 | default: | 246 | default: |
242 | return ""; | 247 | return ""; |
243 | break; | 248 | break; |
244 | } | 249 | } |
245 | return retval.stripWhiteSpace (); | 250 | return retval.stripWhiteSpace (); |
246 | } | 251 | } |
247 | 252 | ||
248 | void NameEditDialog::parseBoxChanged( bool value ) | 253 | void NameEditDialog::parseBoxChanged( bool value ) |
249 | { | 254 | { |
250 | //AddresseeConfig::instance()->setUid( addr.uid() ); | 255 | //AddresseeConfig::instance()->setUid( addr.uid() ); |
251 | AddresseeConfig::instance()->setAutomaticNameParsing( value ); | 256 | AddresseeConfig::instance()->setAutomaticNameParsing( value ); |
252 | } | 257 | } |
253 | 258 | ||
254 | void NameEditDialog::typeChanged( int pos ) | 259 | void NameEditDialog::typeChanged( int pos ) |
255 | { | 260 | { |
256 | mFormattedNameEdit->setEnabled( pos == 0 ); | 261 | mFormattedNameEdit->setEnabled( pos == 0 ); |
257 | } | 262 | } |
258 | 263 | ||
259 | void NameEditDialog::modified() | 264 | void NameEditDialog::modified() |
260 | { | 265 | { |
261 | mChanged = true; | 266 | mChanged = true; |
262 | } | 267 | } |
263 | 268 | ||
264 | void NameEditDialog::updateTypeCombo() | 269 | void NameEditDialog::updateTypeCombo() |
265 | { | 270 | { |
266 | KABC::Addressee addr; | 271 | KABC::Addressee addr; |
267 | addr.setPrefix( mPrefixCombo->currentText() ); | 272 | addr.setPrefix( mPrefixCombo->currentText() ); |
268 | addr.setGivenName( mGivenNameEdit->text() ); | 273 | addr.setGivenName( mGivenNameEdit->text() ); |
269 | addr.setAdditionalName( mAdditionalNameEdit->text() ); | 274 | addr.setAdditionalName( mAdditionalNameEdit->text() ); |
270 | addr.setFamilyName( mFamilyNameEdit->text() ); | 275 | addr.setFamilyName( mFamilyNameEdit->text() ); |
271 | addr.setSuffix( mSuffixCombo->currentText() ); | 276 | addr.setSuffix( mSuffixCombo->currentText() ); |
272 | 277 | ||
273 | int pos = mFormattedNameCombo->currentItem(); | 278 | int pos = mFormattedNameCombo->currentItem(); |
274 | 279 | ||
275 | mFormattedNameCombo->clear(); | 280 | mFormattedNameCombo->clear(); |
276 | mFormattedNameCombo->insertItem( i18n( "Custom" ) ); | 281 | mFormattedNameCombo->insertItem( i18n( "Custom" ) ); |
277 | mFormattedNameCombo->insertItem( formattedName( addr, SimpleName ) ); | 282 | mFormattedNameCombo->insertItem( formattedName( addr, SimpleName ) ); |
278 | mFormattedNameCombo->insertItem( formattedName( addr, FullName ) ); | 283 | mFormattedNameCombo->insertItem( formattedName( addr, FullName ) ); |
279 | mFormattedNameCombo->insertItem( formattedName( addr, ReverseName ) ); | 284 | mFormattedNameCombo->insertItem( formattedName( addr, ReverseName ) ); |
280 | 285 | ||
281 | mFormattedNameCombo->setCurrentItem( pos ); | 286 | mFormattedNameCombo->setCurrentItem( pos ); |
282 | } | 287 | } |
283 | 288 | ||
284 | void NameEditDialog::slotHelp() | 289 | void NameEditDialog::slotHelp() |
285 | { | 290 | { |
286 | #ifndef KAB_EMBEDDED | 291 | #ifndef KAB_EMBEDDED |
287 | kapp->invokeHelp( "managing-contacts-automatic-nameparsing" ); | 292 | kapp->invokeHelp( "managing-contacts-automatic-nameparsing" ); |
288 | #else //KAB_EMBEDDED | 293 | #else //KAB_EMBEDDED |
289 | qDebug("NameEditDialog::slotHelp Help is not supported yet"); | 294 | qDebug("NameEditDialog::slotHelp Help is not supported yet"); |
290 | #endif //KAB_EMBEDDED | 295 | #endif //KAB_EMBEDDED |
291 | } | 296 | } |
292 | 297 | ||
293 | #ifndef KAB_EMBEDDED | 298 | #ifndef KAB_EMBEDDED |
294 | #include "nameeditdialog.moc" | 299 | #include "nameeditdialog.moc" |
295 | #endif //KAB_EMBEDDED | 300 | #endif //KAB_EMBEDDED |