SciDAVis  1.D4
ActionManager.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : ActionManager.h
3  Project : SciDAVis
4  Description : Manages QActions and their shortcuts
5  --------------------------------------------------------------------
6  Copyright : (C) 2008-2009 Tilman Benkert (thzs*gmx.net)
7  (replace * with @ in the email addresses)
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 
30 #ifndef ACTIONMANAGER_H
31 #define ACTIONMANAGER_H
32 
33 #include <QObject>
34 #include <QAction>
35 #include <QList>
36 #include <QMap>
37 #include "lib/macros.h"
38 class QString;
39 class QKeySequence;
40 
42 
83 class ActionManager : public QObject
84 {
85  Q_OBJECT
86 
87  public:
88  ActionManager();
90 
91  void addAction(QAction * action, const QString& internal_name);
92  QList<QKeySequence> shortcuts(const QString& internal_name) const;
93  void setShortcuts(const QString& internal_name, const QList<QKeySequence>& sequences);
94  QString actionText(const QString& internal_name) const;
95  QList<QString> internalNames() const;
96  CLASS_ACCESSOR(QString, d_title, title, Title);
97 
98  public slots:
99  void removeAction(QAction * action);
100  void removeAction(QObject * action);
101 
102  private:
103  QMap< QString, QList<QAction *> * > d_action_registry;
104  QMap< QString, QList<QKeySequence> > d_action_shortcuts;
105  QMap< QString, QString > d_action_texts;
106  QString d_title;
107 };
108 
109 #endif // ACTIONMANAGER_H