File indexing completed on 2024-03-24 15:26:11

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2003 Carsten Pfeiffer <pfeiffer@kde.org>
0004 
0005     This SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef KCONTACTS_ADDRESSEEHELPER_H
0009 #define KCONTACTS_ADDRESSEEHELPER_H
0010 
0011 #include "kcontacts_export.h"
0012 
0013 #include <QObject>
0014 
0015 namespace KContacts
0016 {
0017 class AddresseeHelperPrivate;
0018 
0019 // TODO KF6: unexport and turn into an implementation detail
0020 // this is unused externally, both as code as well as via the config file
0021 // so we only need this internally and can probably also drop the config
0022 // file access
0023 
0024 /**
0025  * This singleton class stores static data, which is shared
0026  * by all Addressee objects. It maintains three lists of
0027  * strings, which can be queried using this class:
0028  *
0029  * - a list of honoric prefixes, like "Mrs.", "Prof." etc,
0030  *   see containsTitle()
0031  * - a list of inclusions, such as "van" or "de", see
0032  *   containsPrefix()
0033  * - a list of honoric suffixes, such as "I" or "Jr.", see
0034  *   containsSuffix()
0035  *
0036  * All of these lists have a hardcoded and a configurable
0037  * part. The configurable part is found in @c kabcrc, group
0038  * @c General, fields @c Prefixes, @c Inclusions, and
0039  * @c Suffixes.
0040  *
0041  * In addition to the above, this class stores one conveniece
0042  * setting: it stores whether or not a single name component
0043  * should be interpreted as a family name (see
0044  * treatAsFamilyName()). The corresponding configuration
0045  * field is @c TreatAsFamilyName.
0046  *
0047  * @warning Do not use, to be removed from the public interface in KF6.
0048  */
0049 class KCONTACTS_EXPORT KCONTACTS_DEPRECATED_VERSION(5, 89, "unused externally") AddresseeHelper : public QObject
0050 {
0051     Q_OBJECT
0052 
0053 public:
0054     /**
0055      * Singleton interface to this class
0056      *
0057      * @return a pointer to the unique instance of this class.
0058      */
0059     static AddresseeHelper *self();
0060 
0061     /**
0062      * Queries the list of honoric prefixes.
0063      *
0064      * @param title the honoric prefix to search for
0065      * @return @c true, if @p title was found in the list,
0066      *         @c false otherwise
0067      */
0068     Q_REQUIRED_RESULT bool containsTitle(const QString &title) const;
0069 
0070     /**
0071      * Queries the list of inclusions.
0072      *
0073      * @param prefix the inclusion to search for
0074      * @return @c true, if @p prefix was found in the list,
0075      *         @c false otherwise
0076      */
0077     Q_REQUIRED_RESULT bool containsPrefix(const QString &prefix) const;
0078 
0079     /**
0080      * Queries the list of honoric suffixes.
0081      *
0082      * @param suffix the honoric suffix to search for
0083      * @return @c true, if @p suffix was found in the list,
0084      *         @c false otherwise
0085      */
0086     Q_REQUIRED_RESULT bool containsSuffix(const QString &suffix) const;
0087 
0088     /**
0089      * Returns whether or not a single name component should
0090      * be interpreted as a family name.
0091      *
0092      * @return @c true if single name component is a family name,
0093      *         @c false otherwise.
0094      */
0095     Q_REQUIRED_RESULT bool treatAsFamilyName() const;
0096 
0097     /** @internal */
0098     AddresseeHelper();
0099 
0100     ~AddresseeHelper() override;
0101 
0102 public Q_SLOTS:
0103     /**
0104      * Recreates the static data and reparses the configuration.
0105      */
0106     void initSettings();
0107 
0108 private:
0109     QScopedPointer<AddresseeHelperPrivate> d;
0110 };
0111 }
0112 
0113 #endif