File indexing completed on 2025-01-05 04:47:09
0001 /* 0002 * SPDX-FileCopyrightText: 2011-2024 Laurent Montel <montel@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 #pragma once 0007 0008 #include "collection.h" 0009 #include "standardactionmanager.h" 0010 #include <QModelIndex> 0011 #include <QStringList> 0012 0013 class QMenu; 0014 class QAbstractItemModel; 0015 class QAction; 0016 /** 0017 * @short A class to manage recent selected folder. 0018 * 0019 * @author Montel Laurent <montel@kde.org> 0020 * @since 4.8 0021 */ 0022 0023 namespace Akonadi 0024 { 0025 class RecentCollectionAction : public QObject 0026 { 0027 Q_OBJECT 0028 public: 0029 /** 0030 * Creates a new collection recent action 0031 */ 0032 explicit RecentCollectionAction(Akonadi::StandardActionManager::Type type, 0033 const Akonadi::Collection::List &selectedCollectionsList, 0034 const QAbstractItemModel *model, 0035 QMenu *menu); 0036 /** 0037 * Destroys the collection recent action. 0038 */ 0039 ~RecentCollectionAction() override; 0040 0041 /** 0042 * Add new collection. Will create a new item. 0043 */ 0044 void addRecentCollection(StandardActionManager::Type type, Akonadi::Collection::Id id); 0045 0046 void cleanRecentCollection(); 0047 0048 /** 0049 * Add a new collection to the global list. 0050 * 0051 * @param id the collection ID 0052 * @since 5.18 0053 */ 0054 static QStringList addRecentCollection(Akonadi::Collection::Id id); 0055 0056 private: 0057 void fillRecentCollection(Akonadi::StandardActionManager::Type type, const Akonadi::Collection::List &selectedCollectionsList); 0058 QString actionName(QModelIndex index); 0059 bool clear(); 0060 0061 private: 0062 QStringList mListRecentCollection; 0063 QMenu *const mMenu; 0064 const QAbstractItemModel *mModel = nullptr; 0065 QAction *mRecentAction = nullptr; 0066 bool needToDeleteMenu = false; 0067 }; 0068 }