• Skip to content
  • Skip to link menu
KDE 4.3 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(), QLatin1String( "/KABC" ),
00049                                          QLatin1String( "org.kde.kabc.AddressBookConfig" ),
00050                                          QLatin1String( "changed" ),
00051                                          this, SLOT(initSettings()));
00052 }
00053 
00054 // static
00055 void AddresseeHelper::addToSet( const QStringList &list, QSet<QString> &container )
00056 {
00057   QStringList::ConstIterator it;
00058   for ( it = list.begin(); it != list.end(); ++it ) {
00059     if ( !(*it).isEmpty() ) {
00060       container.insert( *it );
00061     }
00062   }
00063 }
00064 
00065 void AddresseeHelper::initSettings()
00066 {
00067   mTitles.clear();
00068   mSuffixes.clear();
00069   mPrefixes.clear();
00070 
00071   mTitles.insert( i18n( "Dr." ) );
00072   mTitles.insert( i18n( "Miss" ) );
00073   mTitles.insert( i18n( "Mr." ) );
00074   mTitles.insert( i18n( "Mrs." ) );
00075   mTitles.insert( i18n( "Ms." ) );
00076   mTitles.insert( i18n( "Prof." ) );
00077 
00078   mSuffixes.insert( i18n( "I" ) );
00079   mSuffixes.insert( i18n( "II" ) );
00080   mSuffixes.insert( i18n( "III" ) );
00081   mSuffixes.insert( i18n( "Jr." ) );
00082   mSuffixes.insert( i18n( "Sr." ) );
00083 
00084   mPrefixes.insert( QLatin1String( "van" ) );
00085   mPrefixes.insert( QLatin1String( "von" ) );
00086   mPrefixes.insert( QLatin1String( "de" ) );
00087 
00088   KConfig _config( QLatin1String( "kabcrc" ), KConfig::NoGlobals );
00089   KConfigGroup config(&_config, "General" );
00090 
00091   addToSet( config.readEntry( "Prefixes", QStringList() ), mTitles );
00092   addToSet( config.readEntry( "Inclusions", QStringList() ), mPrefixes );
00093   addToSet( config.readEntry( "Suffixes", QStringList() ), mSuffixes );
00094   mTradeAsFamilyName = config.readEntry( "TradeAsFamilyName", true );
00095 }
00096 
00097 bool AddresseeHelper::containsTitle( const QString &title ) const
00098 {
00099   return mTitles.contains( title );
00100 }
00101 
00102 bool AddresseeHelper::containsPrefix( const QString &prefix ) const
00103 {
00104   return mPrefixes.contains( prefix );
00105 }
00106 
00107 bool AddresseeHelper::containsSuffix( const QString &suffix ) const
00108 {
00109   return mSuffixes.contains( suffix );
00110 }
00111 
00112 bool AddresseeHelper::tradeAsFamilyName() const
00113 {
00114   return mTradeAsFamilyName;
00115 }
00116 
00117 #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"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.9
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