1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2003 Carsten Pfeiffer <pfeiffer@kde.org>
4
5 This SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KCONTACTS_ADDRESSEEHELPER_P_H
9#define KCONTACTS_ADDRESSEEHELPER_P_H
10
11#include "kcontacts_export.h"
12
13#include <QSet>
14
15namespace KContacts
16{
17
18// TODO KF6: unexport and turn into an implementation detail
19// this is unused externally, both as code as well as via the config file
20// so we only need this internally and can probably also drop the config
21// file access
22
23/**
24 * This singleton class stores static data, which is shared
25 * by all Addressee objects. It maintains three lists of
26 * strings, which can be queried using this class:
27 *
28 * - a list of honoric prefixes, like "Mrs.", "Prof." etc,
29 * see containsTitle()
30 * - a list of inclusions, such as "van" or "de", see
31 * containsPrefix()
32 * - a list of honoric suffixes, such as "I" or "Jr.", see
33 * containsSuffix()
34 *
35 * All of these lists have a hardcoded and a configurable
36 * part. The configurable part is found in @c kabcrc, group
37 * @c General, fields @c Prefixes, @c Inclusions, and
38 * @c Suffixes.
39 *
40 * In addition to the above, this class stores one conveniece
41 * setting: it stores whether or not a single name component
42 * should be interpreted as a family name (see
43 * treatAsFamilyName()). The corresponding configuration
44 * field is @c TreatAsFamilyName.
45 */
46class AddresseeHelper
47{
48public:
49 /**
50 * Singleton interface to this class
51 *
52 * @return a pointer to the unique instance of this class.
53 */
54 static AddresseeHelper *self();
55
56 /**
57 * Queries the list of honoric prefixes.
58 *
59 * @param title the honoric prefix to search for
60 * @return @c true, if @p title was found in the list,
61 * @c false otherwise
62 */
63 Q_REQUIRED_RESULT bool containsTitle(const QString &title) const;
64
65 /**
66 * Queries the list of inclusions.
67 *
68 * @param prefix the inclusion to search for
69 * @return @c true, if @p prefix was found in the list,
70 * @c false otherwise
71 */
72 Q_REQUIRED_RESULT bool containsPrefix(const QString &prefix) const;
73
74 /**
75 * Queries the list of honoric suffixes.
76 *
77 * @param suffix the honoric suffix to search for
78 * @return @c true, if @p suffix was found in the list,
79 * @c false otherwise
80 */
81 Q_REQUIRED_RESULT bool containsSuffix(const QString &suffix) const;
82
83 /**
84 * Returns whether or not a single name component should
85 * be interpreted as a family name.
86 *
87 * @return @c true if single name component is a family name,
88 * @c false otherwise.
89 */
90 Q_REQUIRED_RESULT bool treatAsFamilyName() const;
91
92 /** @internal */
93 AddresseeHelper();
94
95 ~AddresseeHelper();
96
97private:
98 /**
99 * Recreates the static data and reparses the configuration.
100 */
101 void initSettings();
102
103 QSet<QString> mTitles;
104 QSet<QString> mPrefixes;
105 QSet<QString> mSuffixes;
106 bool mTreatAsFamilyName;
107};
108}
109
110#endif
111

source code of kcontacts/src/addresseehelper_p.h