-rw-r--r-- | kabc/addressee.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 6b282e2..4cdd5e5 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -740,157 +740,161 @@ QString Addressee::logoLabel() void Addressee::setPhoto( const Picture &photo ) { if ( photo == mData->photo ) return; detach(); mData->empty = false; mData->photo = photo; } Picture Addressee::photo() const { return mData->photo; } QString Addressee::photoLabel() { return i18n("Photo"); } void Addressee::setSound( const Sound &sound ) { if ( sound == mData->sound ) return; detach(); mData->empty = false; mData->sound = sound; } Sound Addressee::sound() const { return mData->sound; } QString Addressee::soundLabel() { return i18n("Sound"); } void Addressee::setAgent( const Agent &agent ) { if ( agent == mData->agent ) return; detach(); mData->empty = false; mData->agent = agent; } Agent Addressee::agent() const { return mData->agent; } QString Addressee::agentLabel() { return i18n("Agent"); } void Addressee::setNameFromString( const QString &str ) { setFormattedName( str ); setName( str ); - QStringList titles; + static bool first = true; + static QStringList titles; + static QStringList suffixes; + static QStringList prefixes; + + if ( first ) { + first = false; titles += i18n( "Dr." ); titles += i18n( "Miss" ); titles += i18n( "Mr." ); titles += i18n( "Mrs." ); titles += i18n( "Ms." ); titles += i18n( "Prof." ); - QStringList suffixes; suffixes += i18n( "I" ); suffixes += i18n( "II" ); suffixes += i18n( "III" ); suffixes += i18n( "Jr." ); suffixes += i18n( "Sr." ); - QStringList prefixes; prefixes += "van"; prefixes += "von"; prefixes += "de"; -//US KConfig config( "kabcrc" ); KConfig config( locateLocal( "config", "kabcrc") ); config.setGroup( "General" ); titles += config.readListEntry( "Prefixes" ); titles.remove( "" ); prefixes += config.readListEntry( "Inclusions" ); prefixes.remove( "" ); suffixes += config.readListEntry( "Suffixes" ); suffixes.remove( "" ); + } // clear all name parts setPrefix( "" ); setGivenName( "" ); setAdditionalName( "" ); setFamilyName( "" ); setSuffix( "" ); if ( str.isEmpty() ) return; int i = str.find(','); if( i < 0 ) { QStringList parts = QStringList::split( " ", str ); int leftOffset = 0; int rightOffset = parts.count() - 1; QString suffix; while ( rightOffset >= 0 ) { if ( suffixes.contains( parts[ rightOffset ] ) ) { suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); rightOffset--; } else break; } setSuffix( suffix ); if ( rightOffset < 0 ) return; if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); rightOffset--; } else setFamilyName( parts[ rightOffset ] ); QString prefix; while ( leftOffset < rightOffset ) { if ( titles.contains( parts[ leftOffset ] ) ) { prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); leftOffset++; } else break; } setPrefix( prefix ); if ( leftOffset < rightOffset ) { setGivenName( parts[ leftOffset ] ); leftOffset++; } QString additionalName; while ( leftOffset < rightOffset ) { additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); leftOffset++; } setAdditionalName( additionalName ); } else { QString part1 = str.left( i ); QString part2 = str.mid( i + 1 ); QStringList parts = QStringList::split( " ", part1 ); int leftOffset = 0; int rightOffset = parts.count() - 1; |