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

0001 /******************************************************************************
0002  *
0003  *  SPDX-FileCopyrightText: 2009 Szymon Stefanek <s.stefanek at gmail dot com>
0004  *
0005  *  SPDX-License-Identifier: LGPL-2.0-or-later
0006  *
0007  *****************************************************************************/
0008 
0009 #pragma once
0010 
0011 #include "akonadicore_export.h"
0012 #include "attribute.h"
0013 
0014 #include <memory>
0015 
0016 namespace Akonadi
0017 {
0018 class EntityHiddenAttributePrivate;
0019 
0020 /**
0021  * @short An Attribute that marks that an entity should be hidden in the UI.
0022  *
0023  * This class represents the attribute of all hidden items. The hidden
0024  * items shouldn't be displayed in UI applications (unless in some kind
0025  * of "debug" mode).
0026  *
0027  * Example:
0028  *
0029  * @code
0030  *
0031  * using namespace Akonadi;
0032  *
0033  * ...
0034  * // hide a collection by setting the hidden attribute
0035  * Collection collection = collectionFetchJob->collections().at(0);
0036  * collection.attribute<EntityHiddenAttribute>( Collection::AddIfMissing );
0037  * new CollectionModifyJob( collection, this ); // save back to storage
0038  *
0039  * // check if the collection is hidden
0040  * if ( collection.hasAttribute<EntityHiddenAttribute>() )
0041  *   qDebug() << "collection is hidden";
0042  * else
0043  *   qDebug() << "collection is visible";
0044  *
0045  * @endcode
0046  *
0047  * @author Szymon Stefanek <s.stefanek@gmail.com>
0048  * @see Akonadi::Attribute
0049  * @since 4.4
0050  */
0051 class AKONADICORE_EXPORT EntityHiddenAttribute : public Attribute
0052 {
0053 public:
0054     /**
0055      * Creates a new entity hidden attribute.
0056      */
0057     explicit EntityHiddenAttribute();
0058 
0059     /**
0060      * Destroys the entity hidden attribute.
0061      */
0062     ~EntityHiddenAttribute() override;
0063 
0064     /**
0065      * Reimplemented from Attribute
0066      */
0067     [[nodiscard]] QByteArray type() const override;
0068 
0069     /**
0070      * Reimplemented from Attribute
0071      */
0072     EntityHiddenAttribute *clone() const override;
0073 
0074     /**
0075      * Reimplemented from Attribute
0076      */
0077     [[nodiscard]] QByteArray serialized() const override;
0078 
0079     /**
0080      * Reimplemented from Attribute
0081      */
0082     void deserialize(const QByteArray &data) override;
0083 
0084 private:
0085     /// @cond PRIVATE
0086     const std::unique_ptr<EntityHiddenAttributePrivate> d;
0087     /// @endcond
0088 };
0089 
0090 } // namespace Akonadi