Fix game:addSpawnShapesByZone
[ryzomcore.git] / studio / src / plugins / core / menu_manager.cpp
blob1e808ed7d73e1a01134608f205737d4710970e36
1 // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2011 Dzmitry KAMIAHIN (dnk-88) <dnk-88@tut.by>
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2010 Winch Gate Property Limited
6 // Copyright (C) 2014 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
7 //
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as
10 // published by the Free Software Foundation, either version 3 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 // Project includes
22 #include "menu_manager.h"
24 // NeL includes
25 #include <nel/misc/debug.h>
27 namespace Core
29 struct MenuManagerPrivate
31 MenuManagerPrivate(): m_menuBar(0) {}
32 QMenuBar *m_menuBar;
33 typedef QHash<QString, QMenu *> IdMenuMap;
34 IdMenuMap m_menuMap;
35 typedef QHash<QString, QAction *> IdActionMap;
36 IdActionMap m_actionMap;
39 MenuManager::MenuManager(QMenuBar *menuBar, QObject *parent)
40 : QObject(parent),
41 d(new MenuManagerPrivate())
43 d->m_menuBar = menuBar;
46 MenuManager::~MenuManager()
48 d->m_menuMap.clear();
49 delete d;
52 void MenuManager::registerMenu(QMenu *menu, const QString &id)
54 menu->setObjectName(id);
55 d->m_menuMap.insert(id, menu);
58 void MenuManager::registerAction(QAction *action, const QString &id)
60 action->setObjectName(id);
61 d->m_actionMap.insert(id, action);
64 QMenu *MenuManager::menu(const QString &id) const
66 QMenu *result = 0;
67 if (!d->m_menuMap.contains(id))
68 nlwarning("QMenu %s not found", id.toUtf8().constData());
69 else
70 result = d->m_menuMap.value(id);
71 return result;
74 QAction *MenuManager::action(const QString &id) const
76 QAction *result = 0;
77 if (!d->m_actionMap.contains(id))
78 nlwarning("QAction %s not found", id.toUtf8().constData());
79 else
80 result = d->m_actionMap.value(id);
81 return result;
84 void MenuManager::unregisterMenu(const QString &id)
86 d->m_menuMap.remove(id);
89 void MenuManager::unregisterAction(const QString &id)
91 d->m_actionMap.remove(id);
94 QMenuBar *MenuManager::menuBar() const
96 return d->m_menuBar;
99 } /* namespace Core */