fw4spl
QtMenuBarContainer.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2016.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include <QMenuBar>
8 
9 #include "fwGuiQt/container/QtMenuBarContainer.hpp"
10 
11 namespace fwGuiQt
12 {
13 namespace container
14 {
15 
16 //-----------------------------------------------------------------------------
17 
18 QtMenuBarContainer::QtMenuBarContainer(::fwGui::GuiBaseObject::Key key) noexcept : m_menuBar(0)
19 {
20 }
21 
22 //-----------------------------------------------------------------------------
23 
24 QtMenuBarContainer::~QtMenuBarContainer() noexcept
25 {
26 }
27 
28 //-----------------------------------------------------------------------------
29 
30 void QtMenuBarContainer::clean()
31 {
32  SLM_ASSERT("The Qt MenuBar is not yet initialized, cleaning is thus impossible", m_menuBar);
33 
34  m_menuBar->clear();
35 
36  QList<QMenu *> list = m_menuBar->findChildren<QMenu *>();
37  Q_FOREACH (QMenu *m, list)
38  {
39  m->hide();
40  delete m;
41  }
42 }
43 
44 //-----------------------------------------------------------------------------
45 
46 void QtMenuBarContainer::destroyContainer()
47 {
48  SLM_ASSERT("The Qt MenuBar is not yet initialized", m_menuBar);
49 
50  QList<QMenu *> allMenu = m_menuBar->findChildren<QMenu *>();
51  OSLM_ASSERT("MenuBar container must be empty ( " << allMenu.count() << " menus).", allMenu.empty());
52 
53  m_menuBar->hide();
54  delete m_menuBar;
55 }
56 
57 //-----------------------------------------------------------------------------
58 
59 void QtMenuBarContainer::setQtMenuBar(QMenuBar *menuBar)
60 {
61  this->m_menuBar = menuBar;
62 }
63 
64 //-----------------------------------------------------------------------------
65 
66 QMenuBar* QtMenuBarContainer::getQtMenuBar()
67 {
68  return this->m_menuBar;
69 }
70 
71 //-----------------------------------------------------------------------------
72 
73 } // namespace container
74 } // namespace fwGuiQt
#define OSLM_ASSERT(message, cond)
work like &#39;assert&#39; from &#39;cassert&#39;, with in addition a message logged by spylog (with FATAL loglevel) ...
Definition: spyLog.hpp:310
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
The namespace fwGuiQt contains classes which provide the implementation of the Gui using Qt library...
Definition: WindowLevel.hpp:32
#define SLM_ASSERT(message, cond)
work like &#39;assert&#39; from &#39;cassert&#39;, with in addition a message logged by spylog (with FATAL loglevel) ...
Definition: spyLog.hpp:308