1 | /* |
2 | * Copyright (c) 2011 Laurent Montel <montel@kde.org> |
3 | * |
4 | * This library is free software; you can redistribute it and/or modify it |
5 | * under the terms of the GNU Library General Public License as published by |
6 | * the Free Software Foundation; either version 2 of the License, or (at your |
7 | * option) any later version. |
8 | * This library is distributed in the hope that it will be useful, but WITHOUT |
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public |
11 | * License for more details. |
12 | * |
13 | * You should have received a copy of the GNU Library General Public License |
14 | * along with this library; see the file COPYING.LIB. If not, write to the |
15 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
16 | * 02110-1301, USA. |
17 | */ |
18 | #ifndef RECENTCOLLECTIONACTION_P_H |
19 | #define RECENTCOLLECTIONACTION_P_H |
20 | |
21 | #include <QStringList> |
22 | #include <QModelIndex> |
23 | #include <akonadi/collection.h> |
24 | #include <ksharedconfig.h> |
25 | #include <akonadi/standardactionmanager.h> |
26 | class ; |
27 | class QAbstractItemModel; |
28 | class QAction; |
29 | /** |
30 | * @short A class to manage recent selected folder. |
31 | * |
32 | * @author Montel Laurent <montel@kde.org> |
33 | * @since 4.8 |
34 | */ |
35 | |
36 | namespace Akonadi { |
37 | class RecentCollectionAction : public QObject |
38 | { |
39 | Q_OBJECT |
40 | public: |
41 | /** |
42 | * Creates a new collection recent action |
43 | */ |
44 | explicit RecentCollectionAction(Akonadi::StandardActionManager::Type type, const Akonadi::Collection::List &selectedCollectionsList, const QAbstractItemModel *model, QMenu *); |
45 | /** |
46 | * Destroys the collection recent action. |
47 | */ |
48 | ~RecentCollectionAction(); |
49 | |
50 | /** |
51 | * Add new collection. Will create a new item. |
52 | */ |
53 | void addRecentCollection(StandardActionManager::Type type, Akonadi::Collection::Id id); |
54 | |
55 | void cleanRecentCollection(); |
56 | |
57 | private: |
58 | void writeConfig(); |
59 | void fillRecentCollection(Akonadi::StandardActionManager::Type type, const Akonadi::Collection::List &selectedCollectionsList); |
60 | QString actionName(QModelIndex index); |
61 | bool clear(); |
62 | |
63 | private: |
64 | QStringList mListRecentCollection; |
65 | QMenu *; |
66 | const QAbstractItemModel *mModel; |
67 | QAction *mRecentAction; |
68 | KSharedConfig::Ptr mAkonadiConfig; |
69 | }; |
70 | } |
71 | |
72 | #endif /* RECENTCOLLECTIONACTION_P_H */ |
73 | |