Index: src/UIElements/Qt4/QtMainWindow.cpp
===================================================================
--- src/UIElements/Qt4/QtMainWindow.cpp	(revision 5813ac0cc79578b47db146eb94c5be04a9e6ac7b)
+++ src/UIElements/Qt4/QtMainWindow.cpp	(revision b59da6e8dbaa0c9c1ed4e190d2b7cd4ccec6152a)
@@ -39,9 +39,5 @@
 #include "Actions/ActionRegistry.hpp"
 #include "Actions/ValueStorage.hpp"
-#include "Menu/MenuDescription.hpp"
-#include "Menu/Menu.hpp"
 #include "Menu/Qt4/QtMenu.hpp"
-#include "Menu/ActionMenuItem.hpp"
-#include "Menu/SubMenuItem.hpp"
 #include "Views/Qt4/QtWorldView.hpp"
 #include "Views/Qt4/GLMoleculeView.hpp"
@@ -60,13 +56,6 @@
   molecule3dDisplay = new GLMoleculeView();
 
-  MenuBar = menuBar();
-
-  // populate menus and add actions
-  {
-    QtMenuReferenceMap NametoTextMenuMap; // contains token to menu reference map
-    MenuShortcutMap ShortcutMap;
-    populateMenu(NametoTextMenuMap, ShortcutMap);
-    populateMenuWithActions(NametoTextMenuMap, ShortcutMap);
-  }
+  MainMenu = new QtMenu<QMenuBar>(menuBar(), "");
+  MainMenu->init();
 
   setCentralWidget(splitter1);
@@ -93,114 +82,2 @@
 }
 
-/** Puts Qt's token, the ampersand, in front of the accelerator char in the menu name.
- * \param ShortcutMap map to all already present accelerator keys
- * \param MenuName Action of menu
- * \param ActionName Action of menu
- * \return name with ampersand added at the right place
- */
-std::string QtMainWindow::getNameWithAccelerator(MenuShortcutMap &ShortcutMap, const std::string &MenuName, const std::string &ActionName) const
-{
-  std::string newname;
-  bool Inserted = false;
-  std::pair < MenuShortcutMap::iterator, bool > Inserter;
-  for (std::string::const_iterator CharRunner = ActionName.begin(); CharRunner != ActionName.end(); ++CharRunner) {
-    if (!Inserted) {
-      Inserter = ShortcutMap.insert( std::pair<std::string, char> (MenuName, *CharRunner) );
-      if (Inserter.second) {
-        newname += '&';
-        Inserted = true;
-      }
-    }
-    newname += *CharRunner;
-  }
-  return newname;
-}
-
-/** Instantiate all menus.
- * \param NametoTextMenuMap lookup for token to menu reference
- */
-void QtMainWindow::populateMenu(QtMenuReferenceMap &NametoTextMenuMap, MenuShortcutMap &ShortcutMap)
-{
-  // go through all menus and create them
-  std::map <std::string, int> TopPositions;
-  TopPositions.insert( std::pair<std::string, int> ("", 0) ); // contains which position was added last
-  QtMenu *Menu = NULL;
-  MenuDescription menudescriptions;
-  std::set <char> ShortcutList;
-  bool CompleteFlag = false;
-  while (!CompleteFlag) {
-    CompleteFlag = true;
-    for(MenuDescription::const_iterator iter = menudescriptions.getBeginIter(); iter != menudescriptions.getEndIter(); ++iter) {
-      // skip when already present
-      if (NametoTextMenuMap.find(iter->first) == NametoTextMenuMap.end()) {
-        // have some short refs to infos
-        const std::string &MenuName = iter->first;
-        const std::string &TopName = iter->second.first;
-        const int &MenuPosition = iter->second.second;
-        std::cout << "MenuName is " << MenuName << ", TopName is " << TopName << " and Position is " << MenuPosition << std::endl;
-
-        // is it top level?
-        if (TopName == "") {
-          ASSERT(TopPositions.find(TopName) != TopPositions.end(),
-              "QtMainWindow::QtMainWindow() - "+TopName+" not present in TopPositions.");
-          if (MenuPosition-1 == TopPositions[TopName]) {
-            std::cout << "Creating top-level menu " << MenuName << " at position " << MenuPosition << std::endl;
-            Menu = new QtMenu(getNameWithAccelerator(ShortcutMap, TopName, MenuName).c_str());
-            MenuBar->addMenu(Menu);
-            NametoTextMenuMap.insert( pair <std::string, QtMenu *> (MenuName, Menu) );
-            CompleteFlag = false;
-            TopPositions[TopName] = MenuPosition;
-            TopPositions[MenuName] = 0;
-          }
-        }
-        // is it a submenu and the top-level menu is present?
-        else if (NametoTextMenuMap.find(TopName) != NametoTextMenuMap.end()) {
-          ASSERT(TopPositions.find(TopName) != TopPositions.end(),
-              "QtMainWindow::QtMainWindow() - "+TopName+" not present in TopPositions.");
-          if (MenuPosition-1 == TopPositions[TopName]) {
-            QtMenu *& TopMenu = NametoTextMenuMap[TopName];
-            std::cout << "Creating submenu " << MenuName << " to menu " << TopName << " at position " << MenuPosition << std::endl;
-            Menu = new QtMenu(getNameWithAccelerator(ShortcutMap, TopName, MenuName).c_str());
-            TopMenu->addMenu(Menu);
-            NametoTextMenuMap.insert( pair <std::string, QtMenu *> (MenuName, Menu) );
-            CompleteFlag = false;
-            TopPositions[TopName] = MenuPosition;
-          }
-        }
-      }
-    }
-  }
-}
-
-/** Instantiate all actions within the menus.
- * \param NametoTextMenuMap lookup for token to menu reference
- * \param ShortcutMap map for all shortcuts within one menu
- */
-void QtMainWindow::populateMenuWithActions(QtMenuReferenceMap &NametoTextMenuMap, MenuShortcutMap &ShortcutMap)
-{
-  typedef std::multimap <std::string, std::string> MenuMap;
-
-  // go through all menus
-  MenuDescription md;
-  MenuMap MenuItems = md.getMenuItemsMap();
-  QtMenu *Menu = NULL;
-  Action *ActionItem = NULL;
-  std::string OldMenuName;
-  for (MenuMap::const_iterator MenuRunner = MenuItems.begin(); MenuRunner != MenuItems.end(); ++MenuRunner) {
-    const std::string &ActionName = MenuRunner->second;
-    const std::string &MenuName = MenuRunner->first;
-    // add the actions to this menu
-    std::cout << " Adding " << ActionName << " to submenu " << MenuName << std::endl;
-    ActionItem = ActionRegistry::getInstance().getActionByName(ActionName);
-    ASSERT(NametoTextMenuMap.find(MenuName) != NametoTextMenuMap.end(),
-        "QtMainWindow::populateMenu() - cannot find reference for menu "+MenuName+" in NametoTextMenuMap.");
-    Menu = NametoTextMenuMap[MenuName];
-    //ASSERT(ShortcutMap.find(MenuName) != ShortcutMap.end(),
-      //  "QtMainWindow::populateMenuWithActions() - missing "+MenuName+" in ShortcutMap.");
-    new ActionMenuItem(
-        'a',
-        ActionItem->Traits.getDescription().c_str(),
-        Menu,
-        ActionItem);
-  }
-}
Index: src/UIElements/Qt4/QtMainWindow.hpp
===================================================================
--- src/UIElements/Qt4/QtMainWindow.hpp	(revision 5813ac0cc79578b47db146eb94c5be04a9e6ac7b)
+++ src/UIElements/Qt4/QtMainWindow.hpp	(revision b59da6e8dbaa0c9c1ed4e190d2b7cd4ccec6152a)
@@ -15,7 +15,8 @@
 #include <set>
 
+#include "Menu/Qt4/QtMenu.hpp"
+
 class QtWorldView;
 class StringView;
-class QtMenu;
 class GLMoleculeView;
 class QtMoleculeView;
@@ -34,11 +35,4 @@
 
 private:
-  typedef std::map <std::string, QtMenu *> QtMenuReferenceMap;
-  typedef std::map <std::string, char> MenuShortcutMap;
-
-  void populateMenu(QtMenuReferenceMap &NametoTextMenuMap, MenuShortcutMap &ShortcutMap);
-  void populateMenuWithActions(QtMenuReferenceMap &NametoTextMenuMap, MenuShortcutMap &ShortcutMap);
-  std::string getNameWithAccelerator(MenuShortcutMap &ShortcutMap, const std::string &MenuName, const std::string &ActionName) const;
-
   // All kinds of QTStuff used in this window
   QApplication *theApp;
@@ -47,5 +41,5 @@
   QtMoleculeView *moleculeDisplay;
   QtStatusBar *statusBar;
-  QMenuBar *MenuBar;
+  QtMenu<QMenuBar> *MainMenu;
 
 };
