File indexing completed on 2024-11-24 04:50:42

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