File indexing completed on 2025-01-05 04:47:06
0001 /* 0002 SPDX-FileCopyrightText: 2010 Tobias Koenig <tokoe@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "collection.h" 0010 #include "item.h" 0011 0012 class QObject; 0013 0014 namespace Akonadi 0015 { 0016 /** 0017 * @short A helper class to manage action states. 0018 * 0019 * @author Tobias Koenig <tokoe@kde.org> 0020 */ 0021 class ActionStateManager 0022 { 0023 public: 0024 /* 0025 * Creates a new action state manager. 0026 */ 0027 explicit ActionStateManager() = default; 0028 0029 virtual ~ActionStateManager() = default; 0030 0031 /** 0032 * Updates the states according to the selected collections and items. 0033 * @param collections selected collections (from the folder tree) 0034 * @param favoriteCollections selected collections (among the ones marked as favorites) 0035 * @param items selected items 0036 */ 0037 void updateState(const Collection::List &collections, const Collection::List &favoriteCollections, const Item::List &items); 0038 0039 /** 0040 * Sets the @p receiver object that will actually update the states. 0041 * 0042 * The object must provide the following three slots: 0043 * - void enableAction( int, bool ) 0044 * - void updatePluralLabel( int, int ) 0045 * - bool isFavoriteCollection( const Akonadi::Collection& ) 0046 * @param receiver object that will actually update the states. 0047 */ 0048 void setReceiver(QObject *receiver); 0049 0050 protected: 0051 virtual bool isRootCollection(const Collection &collection) const; 0052 virtual bool isResourceCollection(const Collection &collection) const; 0053 virtual bool isFolderCollection(const Collection &collection) const; 0054 virtual bool isSpecialCollection(const Collection &collection) const; 0055 virtual bool isFavoriteCollection(const Collection &collection) const; 0056 virtual bool hasResourceCapability(const Collection &collection, const QString &capability) const; 0057 virtual bool collectionCanHaveItems(const Collection &collection) const; 0058 0059 virtual void enableAction(int action, bool state); 0060 virtual void updatePluralLabel(int action, int count); 0061 virtual void updateAlternatingAction(int action); 0062 0063 private: 0064 Q_DISABLE_COPY_MOVE(ActionStateManager) 0065 0066 QObject *mReceiver = nullptr; 0067 }; 0068 0069 }