if ( !shortcutActionName.isEmpty() ) {
// Add action to the actions map
- QList<QtxAction*> actions = myShortcutActions.values( shortcutActionName );
- if ( !actions.contains(action) )
- myShortcutActions.insertMulti( shortcutActionName, action );
+ if ( !myShortcutActions.contains( shortcutActionName, action ) ) {
+ myShortcutActions.insert( shortcutActionName, action );
+ connect( action, SIGNAL( destroyed( QObject* ) ),
+ this, SLOT ( onActionDestroyed( QObject* ) ) );
+ }
QKeySequence keySeq = getShortcutByActionName( shortcutActionName );
action->setShortcut( keySeq );
action->setShortcut( keySeq );
}
}
+
+/*!
+ \brief Called when the corresponding action is destroyed.
+
+ Removes destroyed action from the actions list.
+
+ \param obj action being destroyed
+*/
+void SUIT_ShortcutMgr::onActionDestroyed( QObject* obj )
+{
+ QtxAction* anAction = (QtxAction*)obj;
+
+ if ( anAction )
+ myShortcutActions.remove( anAction->shortcutActionName(), anAction );
+}
#include "SUIT.h"
#include <QObject>
-#include <QMap>
+#include <QMultiMap>
class QtxAction;
*/
class SUIT_EXPORT SUIT_ShortcutMgr: public QObject
{
+ Q_OBJECT
public:
static void Init();
static SUIT_ShortcutMgr* getShortcutMgr();
SUIT_ShortcutMgr();
virtual ~SUIT_ShortcutMgr();
+private slots:
+ void onActionDestroyed( QObject* );
+
private:
virtual bool eventFilter( QObject* o, QEvent* e );
private:
static SUIT_ShortcutMgr* myShortcutMgr;
- QMap<QString, QtxAction*> myShortcutActions;
+ QMultiMap<QString, QtxAction*> myShortcutActions;
};
#if defined WIN32