• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

kabc

addresseehelper.cpp

00001 /*
00002     This file is part of the KDE libraries
00003     Copyright (C) 2003 Carsten Pfeiffer <pfeiffer@kde.org>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation, version 2.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017     Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "addresseehelper.h"
00021 
00022 #include <kconfig.h>
00023 #include <klocale.h>
00024 #include <kconfiggroup.h>
00025 
00026 #include <QtGui/QApplication>
00027 #include <QtDBus/QtDBus>
00028 
00029 using namespace KABC;
00030 
00031 AddresseeHelper *AddresseeHelper::s_self;
00032 
00033 // static
00034 AddresseeHelper *AddresseeHelper::self()
00035 {
00036   if ( !s_self ) {
00037     s_self = new AddresseeHelper();
00038   }
00039 
00040   return s_self;
00041 }
00042 
00043 AddresseeHelper::AddresseeHelper()
00044   : QObject( qApp )
00045 {
00046   initSettings();
00047 
00048   QDBusConnection::sessionBus().connect( QString(), "/KABC",
00049                                          "org.kde.kabc.AddressBookConfig", "changed",
00050                                          this, SLOT(initSettings()));
00051 }
00052 
00053 // static
00054 void AddresseeHelper::addToSet( const QStringList &list, QSet<QString> &container )
00055 {
00056   QStringList::ConstIterator it;
00057   for ( it = list.begin(); it != list.end(); ++it ) {
00058     if ( !(*it).isEmpty() ) {
00059       container.insert( *it );
00060     }
00061   }
00062 }
00063 
00064 void AddresseeHelper::initSettings()
00065 {
00066   mTitles.clear();
00067   mSuffixes.clear();
00068   mPrefixes.clear();
00069 
00070   mTitles.insert( i18n( "Dr." ) );
00071   mTitles.insert( i18n( "Miss" ) );
00072   mTitles.insert( i18n( "Mr." ) );
00073   mTitles.insert( i18n( "Mrs." ) );
00074   mTitles.insert( i18n( "Ms." ) );
00075   mTitles.insert( i18n( "Prof." ) );
00076 
00077   mSuffixes.insert( i18n( "I" ) );
00078   mSuffixes.insert( i18n( "II" ) );
00079   mSuffixes.insert( i18n( "III" ) );
00080   mSuffixes.insert( i18n( "Jr." ) );
00081   mSuffixes.insert( i18n( "Sr." ) );
00082 
00083   mPrefixes.insert( "van" );
00084   mPrefixes.insert( "von" );
00085   mPrefixes.insert( "de" );
00086 
00087   KConfig _config( "kabcrc", KConfig::NoGlobals );
00088   KConfigGroup config(&_config, "General" );
00089 
00090   addToSet( config.readEntry( "Prefixes", QStringList() ), mTitles );
00091   addToSet( config.readEntry( "Inclusions", QStringList() ), mPrefixes );
00092   addToSet( config.readEntry( "Suffixes", QStringList() ), mSuffixes );
00093   mTradeAsFamilyName = config.readEntry( "TradeAsFamilyName", true );
00094 }
00095 
00096 bool AddresseeHelper::containsTitle( const QString &title ) const
00097 {
00098   return mTitles.contains( title );
00099 }
00100 
00101 bool AddresseeHelper::containsPrefix( const QString &prefix ) const
00102 {
00103   return mPrefixes.contains( prefix );
00104 }
00105 
00106 bool AddresseeHelper::containsSuffix( const QString &suffix ) const
00107 {
00108   return mSuffixes.contains( suffix );
00109 }
00110 
00111 bool AddresseeHelper::tradeAsFamilyName() const
00112 {
00113   return mTradeAsFamilyName;
00114 }
00115 
00116 #include "addresseehelper.moc"

kabc

Skip menu "kabc"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.5
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal