Index: src/UIElements/Menu/Qt4/QtMenu.cpp
===================================================================
--- src/UIElements/Menu/Qt4/QtMenu.cpp	(revision 4cf323d81658274e55e522306030678b93d2c779)
+++ 	(revision )
@@ -1,69 +1,0 @@
-/*
- * Project: MoleCuilder
- * Description: creates and alters molecular systems
- * Copyright (C)  2010 University of Bonn. All rights reserved.
- * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
- */
-
-/*
- * QtMenu.cpp
- *
- *  Created on: Jan 15, 2010
- *      Author: crueger
- */
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "Menu/Qt4/QtMenu.hpp"
-
-#include <Qt/qaction.h>
-
-#include "Helpers/MemDebug.hpp"
-
-#include "Menu/MenuItem.hpp"
-
-QtMenu::QtMenu(const char * _title) :
-  QMenu(_title)
-{}
-
-QtMenu::~QtMenu()
-{
-  // yay... Just like Mario Bros.
-  for(list<QtMenuPipe*>::iterator it=plumbing.begin(); it != plumbing.end(); it++)
-    delete (*it);
-}
-
-void QtMenu::addItem(MenuItem* item) {
-  const string description = item->getDescription();
-  QAction *action = addAction(QString(description.c_str()));
-  QtMenuPipe *pipe = new QtMenuPipe(item,action);
-  QObject::connect(action, SIGNAL(triggered()),pipe,SLOT(called()));
-  plumbing.push_back(pipe);
-}
-
-void QtMenu::removeItem(MenuItem* item) {
-  list<QtMenuPipe*>::iterator iter;
-  for(iter=plumbing.begin(); iter!=plumbing.end(); iter++){
-    delete (*iter);
-  }
-}
-
-void QtMenu::display() {
-
-}
-
-QtMenuPipe::QtMenuPipe(MenuItem *_item, QAction *_action) :
-    theItem(_item), theAction(_action)
-{}
-
-QtMenuPipe::~QtMenuPipe() {
-  delete theAction;
-  delete theItem;
-}
-
-void QtMenuPipe::called() {
-  theItem->doTrigger();
-}
Index: src/UIElements/Menu/Qt4/QtMenu.hpp
===================================================================
--- src/UIElements/Menu/Qt4/QtMenu.hpp	(revision 4cf323d81658274e55e522306030678b93d2c779)
+++ src/UIElements/Menu/Qt4/QtMenu.hpp	(revision b59da6e8dbaa0c9c1ed4e190d2b7cd4ccec6152a)
@@ -2,49 +2,118 @@
  * QtMenu.hpp
  *
- *  Created on: Jan 15, 2010
- *      Author: crueger
+ *  Created on: Nov 5, 2010
+ *      Author: heber
  */
 
-#ifndef QTMENU_HPP_
-#define QTMENU_HPP_
+#ifndef MENUINTERFACEQT_HPP_
+#define MENUINTERFACEQT_HPP_
 
+#include <Qt/qaction.h>
+
+#include <iostream>
 #include <list>
-
-#include <QtGui/QMenu>
-#include <QtCore/QObject>
+#include <map>
+#include <string>
 
 #include "Menu/Menu.hpp"
+#include "Menu/MenuInterface.hpp"
+#include "Menu/Qt4/QtMenuPipe.hpp"
 
-class QtMenuPipe;
+/** QtMenu is a specialization of MenuInterface to Qt-like menus.
+ * I.e. with this interface we can access QMenu and QMenuBar.
+ * (The latter is the reason why we have to add this additional wrapping layer).
+ */
+template <class T>
+class QtMenu : virtual public MenuInterface, public Menu
+{
+public:
+  explicit QtMenu(const std::string &_token) :
+    MenuInterface(_token),
+    Menu(_token),
+    MenuInstance(new T(QString(getNameWithAccelerator(_token).c_str()))),
+    deleteMenu(true)
+  {}
 
-class QtMenu : public QMenu, public Menu
-{
-  Q_OBJECT
+  QtMenu(T *_Menu, const std::string &_token) :
+    MenuInterface(_token),
+    Menu(_token),
+    MenuInstance(_Menu),
+    deleteMenu(false)
+  {}
 
-public:
-  QtMenu(const char *);
-  virtual ~QtMenu();
+  virtual ~QtMenu()
+  {
+    for(std::list<QtMenuPipe*>::iterator it=plumbing.begin(); it != plumbing.end(); it++)
+      delete (*it);
 
-  virtual void addItem(MenuItem*);
-  virtual void removeItem(MenuItem*);
-  virtual void display();
+    if (deleteMenu)
+      delete MenuInstance;
+  }
+
+  T * const getMenuInstance()
+  {
+    return MenuInstance;
+  }
+
+protected:
+  // We need to have a reference of the Menu, as Qt returns reference to added menu as well
+  T *MenuInstance;
+
+  /** Puts Qt's token, the ampersand, in front of the accelerator char in the menu name.
+   * \param ActionName Action of menu
+   * \return name with ampersand added at the right place
+   */
+  std::string getNameWithAccelerator(const std::string &ActionName)
+  {
+    std::string newname;
+    bool Inserted = false;
+    std::pair < MenuShortcutMap::iterator, bool > Inserter;
+    for (std::string::const_iterator CharRunner = ActionName.begin();
+        CharRunner != ActionName.end();
+        ++CharRunner) {
+      std::cout << "Current char is " << *CharRunner << std::endl;
+      if (!Inserted) {
+        Inserter = ShortcutMap.insert(
+            std::pair<char, std::string > (*CharRunner, ActionName)
+            );
+        if (Inserter.second) {
+          std::cout << "Accelerator is " << *CharRunner << std::endl;
+          newname += '&';
+          Inserted = true;
+        }
+      }
+      newname += *CharRunner;
+    }
+    return newname;
+  }
+
 private:
-  list<QtMenuPipe*> plumbing;
+  bool deleteMenu;
+  std::list<QtMenuPipe*> plumbing;
+
+  typedef std::map <char, std::string> MenuShortcutMap;
+  MenuShortcutMap ShortcutMap;
+
+  virtual void addActionItem(const std::string &token, const std::string &description)
+  {
+    QAction *action = MenuInstance->addAction(QString(getNameWithAccelerator(description).c_str()));
+    QtMenuPipe *pipe = new QtMenuPipe(token,action);
+    QObject::connect(action, SIGNAL(triggered()),pipe,SLOT(called()));
+    plumbing.push_back(pipe);
+  }
+
+  virtual void addSeparatorItem()
+  {
+    MenuInstance->addSeparator();
+  }
+
+  virtual void addSubmenuItem(const std::string &token, const std::string &description)
+  {
+    QMenu *Menu = MenuInstance->addMenu(QString(token.c_str()));
+    QtMenu<QMenu> *NewMenu = new QtMenu<QMenu>(Menu, token);
+    NewMenu->init();
+  }
+
 };
 
-// This handles the plumbing from QT to internal Items
-// Slots from QT are redirected to internal methods.
-// This way methods can be used where no QT is available
-class QtMenuPipe : public QObject {
-  Q_OBJECT
-public:
-  QtMenuPipe(MenuItem*,QAction*);
-  virtual ~QtMenuPipe();
-public slots:
-  void called();
-private:
-  MenuItem *theItem;
-  QAction *theAction;
-};
-
-#endif /* QTMENU_HPP_ */
+#endif /* MENUINTERFACEQT_HPP_ */
Index: src/UIElements/Menu/Qt4/QtMenuPipe.cpp
===================================================================
--- src/UIElements/Menu/Qt4/QtMenuPipe.cpp	(revision b59da6e8dbaa0c9c1ed4e190d2b7cd4ccec6152a)
+++ src/UIElements/Menu/Qt4/QtMenuPipe.cpp	(revision b59da6e8dbaa0c9c1ed4e190d2b7cd4ccec6152a)
@@ -0,0 +1,40 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * QtMenuPipe.cpp
+ *
+ *  Created on: Nov 5, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <Qt/qaction.h>
+
+#include "Helpers/MemDebug.hpp"
+
+#include "QtMenuPipe.hpp"
+
+#include "Actions/ActionRegistry.hpp"
+#include "Actions/Action.hpp"
+
+QtMenuPipe::QtMenuPipe(const std::string &_ActionName, QAction *_action) :
+    ActionName(_ActionName), theAction(_action)
+{}
+
+QtMenuPipe::~QtMenuPipe() {
+  delete theAction;
+}
+
+void QtMenuPipe::called() {
+  Action* action = ActionRegistry::getInstance().getActionByName(ActionName);
+  action->call();
+}
Index: src/UIElements/Menu/Qt4/QtMenuPipe.hpp
===================================================================
--- src/UIElements/Menu/Qt4/QtMenuPipe.hpp	(revision b59da6e8dbaa0c9c1ed4e190d2b7cd4ccec6152a)
+++ src/UIElements/Menu/Qt4/QtMenuPipe.hpp	(revision b59da6e8dbaa0c9c1ed4e190d2b7cd4ccec6152a)
@@ -0,0 +1,32 @@
+/*
+ * QtMenuPipe.hpp
+ *
+ *  Created on: Nov 5, 2010
+ *      Author: heber
+ */
+
+#ifndef QTMENUPIPE_HPP_
+#define QTMENUPIPE_HPP_
+
+#include <QtCore/QObject>
+
+#include <string>
+
+class QAction;
+
+// This handles the plumbing from QT to internal Items
+// Slots from QT are redirected to internal methods.
+// This way methods can be used where no QT is available
+class QtMenuPipe : public QObject {
+  Q_OBJECT
+public:
+  QtMenuPipe(const std::string &,QAction*);
+  virtual ~QtMenuPipe();
+public slots:
+  void called();
+private:
+  const std::string ActionName;
+  QAction *theAction;
+};
+
+#endif /* QTMENUPIPE_HPP_ */
