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

kabc

  • sources
  • kde-4.12
  • kdepimlibs
  • 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 <klocalizedstring.h>
24 #include <kconfiggroup.h>
25 
26 #include <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  QStringList::ConstIterator end( list.end() );
59  for ( it = list.begin(); it != end; ++it ) {
60  if ( !( *it ).isEmpty() ) {
61  container.insert( *it );
62  }
63  }
64 }
65 
66 void AddresseeHelper::initSettings()
67 {
68  mTitles.clear();
69  mSuffixes.clear();
70  mPrefixes.clear();
71 
72  mTitles.insert( i18n( "Dr." ) );
73  mTitles.insert( i18n( "Miss" ) );
74  mTitles.insert( i18n( "Mr." ) );
75  mTitles.insert( i18n( "Mrs." ) );
76  mTitles.insert( i18n( "Ms." ) );
77  mTitles.insert( i18n( "Prof." ) );
78 
79  mSuffixes.insert( i18n( "I" ) );
80  mSuffixes.insert( i18n( "II" ) );
81  mSuffixes.insert( i18n( "III" ) );
82  mSuffixes.insert( i18n( "Jr." ) );
83  mSuffixes.insert( i18n( "Sr." ) );
84 
85  mPrefixes.insert( QLatin1String( "van" ) );
86  mPrefixes.insert( QLatin1String( "von" ) );
87  mPrefixes.insert( QLatin1String( "de" ) );
88 
89  KConfig _config( QLatin1String( "kabcrc" ), KConfig::NoGlobals );
90  KConfigGroup config(&_config, "General" );
91 
92  addToSet( config.readEntry( "Prefixes", QStringList() ), mTitles );
93  addToSet( config.readEntry( "Inclusions", QStringList() ), mPrefixes );
94  addToSet( config.readEntry( "Suffixes", QStringList() ), mSuffixes );
95  mTradeAsFamilyName = config.readEntry( "TradeAsFamilyName", true );
96 }
97 
98 bool AddresseeHelper::containsTitle( const QString &title ) const
99 {
100  return mTitles.contains( title );
101 }
102 
103 bool AddresseeHelper::containsPrefix( const QString &prefix ) const
104 {
105  return mPrefixes.contains( prefix );
106 }
107 
108 bool AddresseeHelper::containsSuffix( const QString &suffix ) const
109 {
110  return mSuffixes.contains( suffix );
111 }
112 
113 bool AddresseeHelper::tradeAsFamilyName() const
114 {
115  return mTradeAsFamilyName;
116 }
117 
KABC::AddresseeHelper::initSettings
void initSettings()
Recreates the static data and reparses the configuration.
Definition: addresseehelper.cpp:66
KABC::AddresseeHelper::containsPrefix
bool containsPrefix(const QString &prefix) const
Queries the list of inclusions.
Definition: addresseehelper.cpp:103
KABC::AddresseeHelper
This singleton class stores static data, which is shared by all Addressee objects.
Definition: addresseehelper.h:54
KABC::AddresseeHelper::containsSuffix
bool containsSuffix(const QString &suffix) const
Queries the list of honoric suffixes.
Definition: addresseehelper.cpp:108
KABC::AddresseeHelper::containsTitle
bool containsTitle(const QString &title) const
Queries the list of honoric prefixes.
Definition: addresseehelper.cpp:98
KABC::AddresseeHelper::self
static AddresseeHelper * self()
Singleton interface to this class.
Definition: addresseehelper.cpp:34
KABC::AddresseeHelper::tradeAsFamilyName
bool tradeAsFamilyName() const
Returns whether or not a single name component should be interpreted as a family name.
Definition: addresseehelper.cpp:113
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:01:05 by doxygen 1.8.7 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 API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



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