File indexing completed on 2024-11-10 04:40:28

0001 /*
0002     SPDX-FileCopyrightText: 2008 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "akonadicore_export.h"
0010 #include "attribute.h"
0011 
0012 #include <QColor>
0013 #include <QIcon>
0014 
0015 #include <memory>
0016 
0017 namespace Akonadi
0018 {
0019 class EntityDisplayAttributePrivate;
0020 
0021 /**
0022  * @short Attribute that stores the properties that are used to display an entity.
0023  *
0024  * Display properties of a collection or item, such as translated names and icons.
0025  *
0026  * @author Volker Krause <vkrause@kde.org>
0027  * @since 4.2
0028  */
0029 class AKONADICORE_EXPORT EntityDisplayAttribute : public Attribute
0030 {
0031 public:
0032     /**
0033      * Creates a new entity display attribute.
0034      */
0035     explicit EntityDisplayAttribute();
0036 
0037     /**
0038      * Destroys the entity display attribute.
0039      */
0040     ~EntityDisplayAttribute() override;
0041 
0042     /**
0043      * Sets the @p name that should be used for display.
0044      */
0045     void setDisplayName(const QString &name);
0046 
0047     /**
0048      * Returns the name that should be used for display.
0049      * Users of this should fall back to Collection::name() if this is empty.
0050      */
0051     QString displayName() const;
0052 
0053     /**
0054      * Sets the icon @p name for the default icon.
0055      */
0056     void setIconName(const QString &name);
0057 
0058     /**
0059      * Returns the icon that should be used for this collection or item.
0060      */
0061     [[nodiscard]] QIcon icon() const;
0062 
0063     /**
0064      * Returns the icon name of the icon returned by icon().
0065      */
0066     [[nodiscard]] QString iconName() const;
0067 
0068     /**
0069      * Sets the icon @p name for the active icon.
0070      * @param name the icon name to use
0071      * @since 4.4
0072      */
0073     void setActiveIconName(const QString &name);
0074 
0075     /**
0076      * Returns the icon that should be used for this collection or item when active.
0077      * @since 4.4
0078      */
0079     [[nodiscard]] QIcon activeIcon() const;
0080 
0081     /**
0082      * Returns the icon name of an active item.
0083      * @since 4.4
0084      */
0085     [[nodiscard]] QString activeIconName() const;
0086 
0087     /**
0088      * Returns the backgroundColor or an invalid color if none is set.
0089      * @since 4.4
0090      */
0091     [[nodiscard]] QColor backgroundColor() const;
0092 
0093     /**
0094      * Sets the backgroundColor to @p color.
0095      * @param color the background color to use
0096      * @since 4.4
0097      */
0098     void setBackgroundColor(const QColor &color);
0099 
0100     /* reimpl */
0101     [[nodiscard]] QByteArray type() const override;
0102     EntityDisplayAttribute *clone() const override;
0103     QByteArray serialized() const override;
0104     void deserialize(const QByteArray &data) override;
0105 
0106 private:
0107     /// @cond PRIVATE
0108     const std::unique_ptr<EntityDisplayAttributePrivate> d;
0109     /// @endcond
0110 };
0111 
0112 } // namespace Akonadi