Use qtpaths directly
[kdepim.git] / kmail / foldershortcutactionmanager.h
blob23e2cad1d432a3149c1dfb621874ccb66e27aac5
1 /* Copyright 2010 Thomas McGuire <mcguire@kde.org>
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public License as
5 published by the Free Software Foundation; either version 2 of
6 the License or (at your option) version 3 or any later version
7 accepted by the membership of KDE e.V. (or its successor approved
8 by the membership of KDE e.V.), which shall act as a proxy
9 defined in Section 14 of version 3 of the license.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef FOLDERSHORTCUTACTIONMANAGER_H
20 #define FOLDERSHORTCUTACTIONMANAGER_H
22 #include "kmail_export.h"
24 #include <AkonadiCore/Collection>
26 #include <QHash>
27 #include <QModelIndex>
28 #include <QObject>
30 class QAction;
32 class KActionCollection;
34 namespace KMail
37 class FolderShortcutCommand : public QObject
39 Q_OBJECT
41 public:
42 FolderShortcutCommand(QWidget *mainwidget, const Akonadi::Collection &col);
43 ~FolderShortcutCommand();
45 public Q_SLOTS:
46 void start();
47 /** Assign a QAction to the command which is used to trigger it. This
48 * action will be deleted along with the command, so you don't need to
49 * keep track of it separately. */
50 void setAction(QAction *);
52 Q_SIGNALS:
53 void selectCollectionFolder(const Akonadi::Collection &col);
55 private:
56 Akonadi::Collection mCollectionFolder;
57 QWidget *mMainWidget;
58 QAction *mAction;
61 class KMAIL_EXPORT FolderShortcutActionManager : public QObject
63 Q_OBJECT
65 public:
66 explicit FolderShortcutActionManager(QWidget *parent, KActionCollection *actionCollection);
67 void createActions();
69 public Q_SLOTS:
71 /**
72 * Updates the shortcut action for this collection. Call this when a shortcut was
73 * added, removed or changed.
75 void shortcutChanged(const Akonadi::Collection &collection);
77 private Q_SLOTS:
78 /**
79 * Removes the shortcut actions associated with a folder.
81 void slotCollectionRemoved(const Akonadi::Collection &collection);
83 void slotRowsInserted(const QModelIndex &parent, int start, int end);
85 private:
86 void updateShortcutsForIndex(const QModelIndex &parent, int start, int end);
87 QHash< Akonadi::Collection::Id, FolderShortcutCommand * > mFolderShortcutCommands;
88 KActionCollection *mActionCollection;
89 QWidget *mParent;
94 #endif