• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.9.5 API Reference
  • KDE Home
  • Contact Us
 

kabc

  • kabc
addresseehelper.cpp
1 /*
2  This file is part of the KDE libraries
3  Copyright (C) 2003 Carsten Pfeiffer <pfeiffer@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation, version 2.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include "addresseehelper.h"
21 
22 #include <kconfig.h>
23 #include <klocale.h>
24 #include <kconfiggroup.h>
25 
26 #include <QtGui/QApplication>
27 #include <QtDBus/QtDBus>
28 
29 using namespace KABC;
30 
31 AddresseeHelper *AddresseeHelper::s_self;
32 
33 // static
34 AddresseeHelper *AddresseeHelper::self()
35 {
36  if ( !s_self ) {
37  s_self = new AddresseeHelper();
38  }
39 
40  return s_self;
41 }
42 
43 AddresseeHelper::AddresseeHelper()
44  : QObject( qApp )
45 {
46  initSettings();
47 
48  QDBusConnection::sessionBus().connect( QString(), QLatin1String( "/KABC" ),
49  QLatin1String( "org.kde.kabc.AddressBookConfig" ),
50  QLatin1String( "changed" ),
51  this, SLOT(initSettings()));
52 }
53 
54 // static
55 void AddresseeHelper::addToSet( const QStringList &list, QSet<QString> &container )
56 {
57  QStringList::ConstIterator it;
58  for ( it = list.begin(); it != list.end(); ++it ) {
59  if ( !(*it).isEmpty() ) {
60  container.insert( *it );
61  }
62  }
63 }
64 
65 void AddresseeHelper::initSettings()
66 {
67  mTitles.clear();
68  mSuffixes.clear();
69  mPrefixes.clear();
70 
71  mTitles.insert( i18n( "Dr." ) );
72  mTitles.insert( i18n( "Miss" ) );
73  mTitles.insert( i18n( "Mr." ) );
74  mTitles.insert( i18n( "Mrs." ) );
75  mTitles.insert( i18n( "Ms." ) );
76  mTitles.insert( i18n( "Prof." ) );
77 
78  mSuffixes.insert( i18n( "I" ) );
79  mSuffixes.insert( i18n( "II" ) );
80  mSuffixes.insert( i18n( "III" ) );
81  mSuffixes.insert( i18n( "Jr." ) );
82  mSuffixes.insert( i18n( "Sr." ) );
83 
84  mPrefixes.insert( QLatin1String( "van" ) );
85  mPrefixes.insert( QLatin1String( "von" ) );
86  mPrefixes.insert( QLatin1String( "de" ) );
87 
88  KConfig _config( QLatin1String( "kabcrc" ), KConfig::NoGlobals );
89  KConfigGroup config(&_config, "General" );
90 
91  addToSet( config.readEntry( "Prefixes", QStringList() ), mTitles );
92  addToSet( config.readEntry( "Inclusions", QStringList() ), mPrefixes );
93  addToSet( config.readEntry( "Suffixes", QStringList() ), mSuffixes );
94  mTradeAsFamilyName = config.readEntry( "TradeAsFamilyName", true );
95 }
96 
97 bool AddresseeHelper::containsTitle( const QString &title ) const
98 {
99  return mTitles.contains( title );
100 }
101 
102 bool AddresseeHelper::containsPrefix( const QString &prefix ) const
103 {
104  return mPrefixes.contains( prefix );
105 }
106 
107 bool AddresseeHelper::containsSuffix( const QString &suffix ) const
108 {
109  return mSuffixes.contains( suffix );
110 }
111 
112 bool AddresseeHelper::tradeAsFamilyName() const
113 {
114  return mTradeAsFamilyName;
115 }
116 
117 #include "addresseehelper.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jan 5 2013 19:47:45 by doxygen 1.8.1.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kabc

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

kdepimlibs-4.9.5 API Reference

Skip menu "kdepimlibs-4.9.5 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal