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 | |
15 | namespace 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 | * |
46 | * \internal |
47 | */ |
48 | class AddresseeHelper |
49 | { |
50 | public: |
51 | /*! |
52 | * Singleton interface to this class |
53 | * |
54 | * Returns a pointer to the unique instance of this class. |
55 | */ |
56 | static AddresseeHelper *self(); |
57 | |
58 | /*! |
59 | * Queries the list of honoric prefixes. |
60 | * |
61 | * \a title the honoric prefix to search for |
62 | * |
63 | * Returns \c true, if \a title was found in the list, |
64 | * \c false otherwise |
65 | */ |
66 | Q_REQUIRED_RESULT bool containsTitle(const QString &title) const; |
67 | |
68 | /*! |
69 | * Queries the list of inclusions. |
70 | * |
71 | * \a prefix the inclusion to search for |
72 | * |
73 | * Returns \c true, if \a prefix was found in the list, |
74 | * \c false otherwise |
75 | */ |
76 | Q_REQUIRED_RESULT bool containsPrefix(const QString &prefix) const; |
77 | |
78 | /*! |
79 | * Queries the list of honoric suffixes. |
80 | * |
81 | * \a suffix the honoric suffix to search for |
82 | * |
83 | * Returns \c true, if \a suffix was found in the list, |
84 | * \c false otherwise |
85 | */ |
86 | Q_REQUIRED_RESULT bool containsSuffix(const QString &suffix) const; |
87 | |
88 | /*! |
89 | * Returns whether or not a single name component should |
90 | * be interpreted as a family name. |
91 | * |
92 | * Returns \c true if single name component is a family name, |
93 | * \c false otherwise. |
94 | */ |
95 | Q_REQUIRED_RESULT bool treatAsFamilyName() const; |
96 | |
97 | AddresseeHelper(); |
98 | |
99 | ~AddresseeHelper(); |
100 | |
101 | private: |
102 | /*! |
103 | * Recreates the static data and reparses the configuration. |
104 | */ |
105 | void initSettings(); |
106 | |
107 | QSet<QString> mTitles; |
108 | QSet<QString> mPrefixes; |
109 | QSet<QString> mSuffixes; |
110 | bool mTreatAsFamilyName; |
111 | }; |
112 | } |
113 | |
114 | #endif |
115 | |