File indexing completed on 2024-11-24 04:39:34

0001 /*
0002     This file is part of Contact Editor.
0003 
0004     SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #pragma once
0010 
0011 #include "akonadi-contact-widgets_export.h"
0012 #include <QVariant>
0013 
0014 #include <memory>
0015 
0016 namespace Akonadi
0017 {
0018 class ContactMetaDataBasePrivate;
0019 
0020 /**
0021  * @short A helper class for storing contact specific settings.
0022  */
0023 class AKONADI_CONTACT_WIDGETS_EXPORT ContactMetaDataBase
0024 {
0025 public:
0026     /**
0027      * Creates a contact meta data object.
0028      */
0029     ContactMetaDataBase();
0030 
0031     /**
0032      * Destroys the contact meta data object.
0033      */
0034     ~ContactMetaDataBase();
0035 
0036     /**
0037      * Loads the meta data for the given @p contact.
0038      */
0039     void loadMetaData(const QVariantMap &metaData);
0040 
0041     /**
0042      * Stores the meta data to the given @p contact.
0043      */
0044     [[nodiscard]] QVariantMap storeMetaData() const;
0045 
0046     /**
0047      * Sets the mode that is used for the display
0048      * name of that contact.
0049      */
0050     void setDisplayNameMode(int mode);
0051 
0052     /**
0053      * Returns the mode that is used for the display
0054      * name of that contact.
0055      */
0056     [[nodiscard]] int displayNameMode() const;
0057 
0058     /**
0059      * Sets the @p descriptions of the custom fields of that contact.
0060      * @param descriptions the descriptions to set
0061      * The description list contains a QVariantMap for each custom field
0062      * with the following keys:
0063      *   - key   (string) The identifier of the field
0064      *   - title (string) The i18n'ed title of the field
0065      *   - type  (string) The type description of the field
0066      *     Possible values for type description are
0067      *       - text
0068      *       - numeric
0069      *       - boolean
0070      *       - date
0071      *       - time
0072      *       - datetime
0073      */
0074     void setCustomFieldDescriptions(const QVariantList &descriptions);
0075 
0076     /**
0077      * Returns the descriptions of the custom fields of the contact.
0078      */
0079     [[nodiscard]] QVariantList customFieldDescriptions() const;
0080 
0081 private:
0082     //@cond PRIVATE
0083     Q_DISABLE_COPY(ContactMetaDataBase)
0084 
0085     std::unique_ptr<ContactMetaDataBasePrivate> const d;
0086     //@endcond
0087 };
0088 }