File indexing completed on 2025-01-05 04:58:17

0001 /*
0002  * SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
0003  * SPDX-FileCopyrightText: 2010 Tobias Koenig <tokoe@kdab.com>
0004  *
0005  * SPDX-License-Identifier: GPL-2.0-or-later
0006  */
0007 
0008 #pragma once
0009 
0010 #include "pimcommonakonadi_private_export.h"
0011 
0012 #include <Akonadi/Collection>
0013 
0014 #include <QObject>
0015 
0016 class QAbstractItemModel;
0017 class QAction;
0018 class QItemSelectionModel;
0019 
0020 namespace PimCommon
0021 {
0022 class PIMCOMMONAKONADI_TESTS_EXPORT AclManager : public QObject
0023 {
0024     Q_OBJECT
0025 
0026     Q_PROPERTY(Akonadi::Collection collection READ collection WRITE setCollection NOTIFY collectionChanged)
0027     Q_PROPERTY(QAbstractItemModel *model READ model)
0028     Q_PROPERTY(QItemSelectionModel *selectionModel READ selectionModel)
0029     Q_PROPERTY(QAction *addAction READ addAction)
0030     Q_PROPERTY(QAction *editAction READ editAction)
0031     Q_PROPERTY(QAction *deleteAction READ deleteAction)
0032 
0033 public:
0034     /**
0035      * Creates a new ACL manager.
0036      *
0037      * @param parent The parent object.
0038      */
0039     explicit AclManager(QObject *parent = nullptr);
0040 
0041     /**
0042      * Destroys the ACL manager.
0043      */
0044     ~AclManager() override;
0045 
0046     /**
0047      * Sets the @p collection whose ACL will be managed.
0048      */
0049     void setCollection(const Akonadi::Collection &collection);
0050 
0051     /**
0052      * Sets the @p collection whose ACL are managed.
0053      */
0054     [[nodiscard]] Akonadi::Collection collection() const;
0055 
0056     /**
0057      * Returns the model that represents the ACL of the managed collection.
0058      */
0059     [[nodiscard]] QAbstractItemModel *model() const;
0060 
0061     /**
0062      * Returns the selection model that is used by the manager to select the
0063      * ACL entry to work on.
0064      */
0065     [[nodiscard]] QItemSelectionModel *selectionModel() const;
0066 
0067     /**
0068      * Returns the action that handles adding new ACL entries.
0069      */
0070     [[nodiscard]] QAction *addAction() const;
0071 
0072     /**
0073      * Returns the action that handles editing the currently selected ACL entry.
0074      */
0075     [[nodiscard]] QAction *editAction() const;
0076 
0077     /**
0078      * Returns the action that handles deleting the currently selected ACL entry.
0079      */
0080     [[nodiscard]] QAction *deleteAction() const;
0081 
0082     void setChanged(bool b);
0083 public Q_SLOTS:
0084     /**
0085      * Saves the changes of the ACL back to the collection.
0086      */
0087     void save(bool recursive);
0088 
0089 Q_SIGNALS:
0090     /**
0091      * This signal is emitted whenever the collection whose ACL will
0092      * be managed has changed.
0093      */
0094     void collectionChanged(const Akonadi::Collection &collection);
0095 
0096     void collectionCanBeAdministrated(bool canAdmin);
0097 
0098 private:
0099     //@cond PRIVATE
0100     class AclManagerPrivate;
0101     std::unique_ptr<AclManagerPrivate> const d;
0102     //@endcond
0103 };
0104 }