Medical Imaging Interaction Toolkit  2024.06.00
Medical Imaging Interaction Toolkit
berry::MenuManager Class Reference

#include <berryMenuManager.h>

Inheritance diagram for berry::MenuManager:
Collaboration diagram for berry::MenuManager:

Public Member Functions

 berryObjectMacro (MenuManager)
 
Q_SIGNAL void AboutToShow (IMenuManager *mm)
 
Q_SIGNAL void AboutToHide (IMenuManager *mm)
 
 MenuManager (const QString &text, const QString &id=QString())
 
 ~MenuManager () override
 
 MenuManager (const QString &text, const QIcon &image, const QString &id)
 
bool IsDirty () const override
 
QMenu * CreateContextMenu (QWidget *parent)
 
QMenuBar * CreateMenuBar (QWidget *parent)
 
void AddMenuListener (QObject *listener) override
 
void RemoveMenuListener (QObject *listener) override
 
void Fill (QStatusBar *parent) override
 
void Fill (QToolBar *parent, QAction *index) override
 
void Fill (QMenu *parent, QAction *before) override
 
void Fill (QMenuBar *parent, QAction *before) override
 
IMenuManager::Pointer FindMenuUsingPath (const QString &path) const override
 
IContributionItem::Pointer FindUsingPath (const QString &path) const override
 
QString GetId () const override
 
QMenu * GetMenu () const
 
QString GetMenuText () const
 
QIcon GetImage () const
 
SmartPointer< IContributionManagerOverridesGetOverrides () override
 
IContributionManagerGetParent () const
 
bool GetRemoveAllWhenShown () const override
 
bool IsDynamic () const override
 
bool IsEnabled () const override
 
bool IsGroupMarker () const override
 
bool IsSeparator () const override
 
bool IsVisible () const override
 
void MarkDirty () override
 
void SaveWidgetState () override
 
void SetOverrides (SmartPointer< IContributionManagerOverrides > newOverrides)
 
void SetParent (IContributionManager *manager) override
 
void SetRemoveAllWhenShown (bool removeAll) override
 
void SetVisible (bool visible) override
 
void SetCommandId (const QString &definitionId)
 
void Update () override
 
void Update (const QString &property) override
 
void Update (bool force) override
 
void UpdateAll (bool force) override
 
- Public Member Functions inherited from berry::ContributionManager
 berryObjectMacro (berry::ContributionManager)
 
 ~ContributionManager () override
 
void Add (QAction *action, const QString &id) override
 
void Add (const SmartPointer< IContributionItem > &item) override
 
void AppendToGroup (const QString &groupName, QAction *action, const QString &id) override
 
void AppendToGroup (const QString &groupName, const SmartPointer< IContributionItem > &item) override
 
SmartPointer< IContributionItemFind (const QString &id) const override
 
QList< SmartPointer< IContributionItem > > GetItems () const override
 
int GetSize ()
 
int IndexOf (const QString &id)
 
void Insert (int index, const SmartPointer< IContributionItem > &item)
 
void InsertAfter (const QString &ID, const SmartPointer< IContributionItem > &item) override
 
void InsertBefore (const QString &ID, const SmartPointer< IContributionItem > &item) override
 
bool IsEmpty () const override
 
void PrependToGroup (const QString &groupName, const SmartPointer< IContributionItem > &item) override
 
SmartPointer< IContributionItemRemove (const QString &ID) override
 
SmartPointer< IContributionItemRemove (const SmartPointer< IContributionItem > &item) override
 
void RemoveAll () override
 
bool ReplaceItem (const QString &identifier, const SmartPointer< IContributionItem > &replacementItem)
 
void SetOverrides (const SmartPointer< IContributionManagerOverrides > &newOverrides)
 
- Public Member Functions inherited from berry::IContributionManager
 berryObjectMacro (berry::IContributionManager)
 
- Public Member Functions inherited from berry::Object
virtual QString GetClassName () const
 
virtual Reflection::TypeInfo GetTypeInfo () const
 
virtual QList< Reflection::TypeInfoGetSuperclasses () const
 
virtual void Delete ()
 
QDebug Print (QDebug os, Indent Indent=0) const
 
virtual QString ToString () const
 
virtual uint HashCode () const
 
virtual bool operator< (const Object *) const
 
void Register () const
 
void UnRegister (bool del=true) const
 
int GetReferenceCount () const
 
void SetReferenceCount (int)
 
void AddDestroyListener (const MessageAbstractDelegate<> &delegate) const
 
void RemoveDestroyListener (const MessageAbstractDelegate<> &delegate) const
 
virtual bool operator== (const Object *) const
 
- Public Member Functions inherited from berry::IMenuManager
 berryObjectMacro (berry::IMenuManager)
 
- Public Member Functions inherited from berry::IContributionItem
 berryObjectMacro (berry::IContributionItem)
 

Protected Member Functions

void DoItemFill (IContributionItem::Pointer ci, QAction *before)
 
void Update (bool force, bool recursive)
 
- Protected Member Functions inherited from berry::ContributionManager
 ContributionManager ()
 
virtual bool AllowItem (IContributionItem *itemToAdd)
 
void DumpStatistics ()
 
bool HasDynamicItems () const
 
int IndexOf (const SmartPointer< IContributionItem > &item) const
 
void ItemAdded (const SmartPointer< IContributionItem > &item)
 
void ItemRemoved (const SmartPointer< IContributionItem > &item)
 
void SetDirty (bool dirty)
 
void InternalSetItems (const QList< SmartPointer< IContributionItem > > &items)
 
- Protected Member Functions inherited from berry::Object
 Object ()
 
virtual ~Object ()
 
virtual QDebug PrintSelf (QDebug os, Indent indent) const
 
virtual QDebug PrintHeader (QDebug os, Indent indent) const
 
virtual QDebug PrintTrailer (QDebug os, Indent indent) const
 

Protected Attributes

bool visible
 
- Protected Attributes inherited from berry::Object
QAtomicInt m_ReferenceCount
 
QMutex m_ReferenceCountLock
 

Additional Inherited Members

- Public Types inherited from berry::Object
typedef Object Self
 
typedef berry::SmartPointer< SelfPointer
 
typedef berry::SmartPointer< const SelfConstPointer
 
typedef berry::WeakPointer< SelfWeakPtr
 
typedef berry::WeakPointer< const SelfConstWeakPtr
 
- Static Public Member Functions inherited from berry::Object
static const char * GetStaticClassName ()
 
static Reflection::TypeInfo GetStaticTypeInfo ()
 
static QList< Reflection::TypeInfoGetStaticSuperclasses ()
 

Detailed Description

A menu manager is a contribution manager which realizes itself and its items in a menu control; either as a menu bar, a sub-menu, or a context menu.

This class may be instantiated; it may also be subclassed.

Definition at line 37 of file berryMenuManager.h.

Constructor & Destructor Documentation

◆ MenuManager() [1/2]

berry::MenuManager::MenuManager ( const QString &  text,
const QString &  id = QString() 
)

Creates a menu manager with the given text and id. Typically no text is given when creating a context menu. Supply a text and id for creating a sub-menu, where it needs to be referred to by the id.

Parameters
textthe text for the menu, or "" if none
idthe menu id, or "" if it is to have no id

◆ ~MenuManager()

berry::MenuManager::~MenuManager ( )
override

◆ MenuManager() [2/2]

berry::MenuManager::MenuManager ( const QString &  text,
const QIcon &  image,
const QString &  id 
)

Creates a menu manager with the given text, image, and id. Typically used for creating a sub-menu, where it needs to be referred to by id.

Parameters
textthe text for the menu, or "" if none
imagethe image for the menu, or ImageDescriptor::Pointer(0) if none
idthe menu id, or "" if it is to have no id

Member Function Documentation

◆ AboutToHide()

Q_SIGNAL void berry::MenuManager::AboutToHide ( IMenuManager mm)

◆ AboutToShow()

Q_SIGNAL void berry::MenuManager::AboutToShow ( IMenuManager mm)

◆ AddMenuListener()

void berry::MenuManager::AddMenuListener ( QObject *  listener)
overridevirtual

Adds a menu listener to this menu. Has no effect if an identical listener is already registered.

Parameters
listenera menu listener

Implements berry::IMenuManager.

◆ berryObjectMacro()

berry::MenuManager::berryObjectMacro ( MenuManager  )

◆ CreateContextMenu()

QMenu* berry::MenuManager::CreateContextMenu ( QWidget *  parent)

Creates and returns a Qt menu control for this menu, and installs all registered contributions. Does not create a new control if one already exists.

Note that the menu is not expected to be dynamic.

Parameters
parentthe parent control
Returns
the menu control

◆ CreateMenuBar()

QMenuBar* berry::MenuManager::CreateMenuBar ( QWidget *  parent)

Creates and returns a Qt menu bar control for this menu, for use in the given QWidget, and installs all registered contributions. Does not create a new control if one already exists.

Parameters
parentthe parent decorations
Returns
the menu control
Since
2.1

◆ DoItemFill()

void berry::MenuManager::DoItemFill ( IContributionItem::Pointer  ci,
QAction *  before 
)
protected

Call an IContributionItem's fill method with the implementation's widget. The default is to use the Menu widget.
fill(Menu menu, int index)

Parameters
ciAn IContributionItem whose fill() method should be called.
beforeThe position the fill() method should start inserting at.

◆ Fill() [1/4]

void berry::MenuManager::Fill ( QMenu *  parent,
QAction *  before 
)
overridevirtual

Fills the given menu with controls representing this contribution item. Used by MenuManager.

Parameters
parentthe parent menu
before

Implements berry::IContributionItem.

◆ Fill() [2/4]

void berry::MenuManager::Fill ( QMenuBar *  parent,
QAction *  before 
)
overridevirtual

Fills the given menu bar with controls representing this contribution item. Used by MenuBarManager.

Parameters
parentthe parent menu
before

Implements berry::IContributionItem.

◆ Fill() [3/4]

void berry::MenuManager::Fill ( QStatusBar *  parent)
overridevirtual

Fills the given status bar control with controls representing this contribution item. Used by StatusLineManager.

Parameters
parentthe parent control

Implements berry::IContributionItem.

◆ Fill() [4/4]

void berry::MenuManager::Fill ( QToolBar *  parent,
QAction *  before 
)
overridevirtual

Fills the given tool bar with controls representing this contribution item. Used by ToolBarManager.

Parameters
parentthe parent tool bar
before

Implements berry::IContributionItem.

◆ FindMenuUsingPath()

IMenuManager::Pointer berry::MenuManager::FindMenuUsingPath ( const QString &  path) const
overridevirtual

Finds the manager for the menu at the given path. A path consists of contribution item ids separated by the separator character. The path separator character is '/'.

Convenience for findUsingPath(path) which extracts an IMenuManager if possible.

Parameters
paththe path string
Returns
the menu contribution item, or null if there is no such contribution item or if the item does not have an associated menu manager

Implements berry::IMenuManager.

◆ FindUsingPath()

IContributionItem::Pointer berry::MenuManager::FindUsingPath ( const QString &  path) const
overridevirtual

Finds the contribution item at the given path. A path consists of contribution item ids separated by the separator character. The path separator character is '/'.

Parameters
paththe path string
Returns
the contribution item, or null if there is no such contribution item

Implements berry::IMenuManager.

◆ GetId()

QString berry::MenuManager::GetId ( ) const
overridevirtual

Returns the menu id. The menu id is used when creating a contribution item for adding this menu as a sub menu of another.

Returns
the menu id

Implements berry::IContributionItem.

◆ GetImage()

QIcon berry::MenuManager::GetImage ( ) const

Returns the image for this menu as an image descriptor.

Returns
the image, or null if this menu has no image

◆ GetMenu()

QMenu* berry::MenuManager::GetMenu ( ) const

Returns the SWT menu control for this menu manager.

Returns
the menu control

◆ GetMenuText()

QString berry::MenuManager::GetMenuText ( ) const

Returns the text shown in the menu, potentially with a shortcut appended.

Returns
the menu text

◆ GetOverrides()

SmartPointer<IContributionManagerOverrides> berry::MenuManager::GetOverrides ( )
overridevirtual

The ContributionManager implementation of this method declared on IContributionManager returns the current overrides. If there is no overrides it lazily creates one which overrides no item state.

Reimplemented from berry::ContributionManager.

◆ GetParent()

IContributionManager* berry::MenuManager::GetParent ( ) const

Returns the parent contribution manager of this manager.

Returns
the parent contribution manager

◆ GetRemoveAllWhenShown()

bool berry::MenuManager::GetRemoveAllWhenShown ( ) const
overridevirtual

Returns whether all items should be removed when the menu is about to show, but before notifying menu listeners. The default is false.

Returns
true if all items should be removed when shown, false if not

Implements berry::IMenuManager.

◆ IsDirty()

bool berry::MenuManager::IsDirty ( ) const
overridevirtual

Returns whether the list of contributions has recently changed and has yet to be reflected in the corresponding widgets.

Returns
true if this manager is dirty, and false if it is up-to-date

Reimplemented from berry::ContributionManager.

◆ IsDynamic()

bool berry::MenuManager::IsDynamic ( ) const
overridevirtual

Returns whether this contribution item is dynamic. A dynamic contribution item contributes items conditionally, dependent on some internal state.

Returns
true if this item is dynamic, and false for normal items

Implements berry::IContributionItem.

◆ IsEnabled()

bool berry::MenuManager::IsEnabled ( ) const
overridevirtual

Returns whether this menu should be enabled or not. Used to enable the menu item containing this menu when it is realized as a sub-menu.

The default implementation of this framework method returns true. Subclasses may reimplement.

Returns
true if enabled, and false if disabled

Implements berry::IMenuManager.

◆ IsGroupMarker()

bool berry::MenuManager::IsGroupMarker ( ) const
overridevirtual

Returns whether this contribution item is a group marker. This information is used when adding items to a group.

Returns
true if this item is a group marker, and false for normal items
See also
GroupMarker
IContributionManager::appendToGroup(String, IContributionItem)
IContributionManager::prependToGroup(String, IContributionItem)

Implements berry::IContributionItem.

◆ IsSeparator()

bool berry::MenuManager::IsSeparator ( ) const
overridevirtual

Returns whether this contribution item is a separator. This information is used to enable hiding of unnecessary separators.

Returns
true if this item is a separator, and false for normal items
See also
Separator

Implements berry::IContributionItem.

◆ IsVisible()

bool berry::MenuManager::IsVisible ( ) const
overridevirtual

Returns whether this contribution item is visible within its manager.

Returns
true if this item is visible, and false otherwise

Implements berry::IContributionItem.

◆ MarkDirty()

void berry::MenuManager::MarkDirty ( )
overridevirtual

The MenuManager implementation of this ContributionManager method also propagates the dirty flag up the parent chain.

Reimplemented from berry::ContributionManager.

◆ RemoveMenuListener()

void berry::MenuManager::RemoveMenuListener ( QObject *  listener)
overridevirtual

Removes the given menu listener from this menu. Has no effect if an identical listener is not registered.

Parameters
listenerthe menu listener

Implements berry::IMenuManager.

◆ SaveWidgetState()

void berry::MenuManager::SaveWidgetState ( )
overridevirtual

Saves any state information of the control(s) owned by this contribution item. The contribution manager calls this method before disposing of the controls.

Implements berry::IContributionItem.

◆ SetCommandId()

void berry::MenuManager::SetCommandId ( const QString &  definitionId)

Sets the command id of this action. This simply allows the menu item text to include a short cut if available. It can be used to notify a user of a key combination that will open a quick menu.

Parameters
definitionIdthe command definition id

◆ SetOverrides()

void berry::MenuManager::SetOverrides ( SmartPointer< IContributionManagerOverrides newOverrides)

Sets the overrides for this contribution manager

Parameters
newOverridesthe overrides for the items of this manager

◆ SetParent()

void berry::MenuManager::SetParent ( IContributionManager parent)
overridevirtual

Sets the parent manager of this item

Parameters
parentthe parent contribution manager

Implements berry::IContributionItem.

◆ SetRemoveAllWhenShown()

void berry::MenuManager::SetRemoveAllWhenShown ( bool  removeAll)
overridevirtual

Sets whether all items should be removed when the menu is about to show, but before notifying menu listeners.

Parameters
removeAlltrue if all items should be removed when shown, false if not

Implements berry::IMenuManager.

◆ SetVisible()

void berry::MenuManager::SetVisible ( bool  visible)
overridevirtual

Sets whether this contribution item is visible within its manager.

Parameters
visibletrue if this item should be visible, and false otherwise

Implements berry::IContributionItem.

◆ Update() [1/4]

void berry::MenuManager::Update ( )
overridevirtual

Updates any controls cached by this contribution item with any changes which have been made to this contribution item since the last update. Called by contribution manager update methods.

Implements berry::IContributionItem.

◆ Update() [2/4]

void berry::MenuManager::Update ( bool  force)
overridevirtual

The MenuManager implementation of this IContributionManager updates this menu, but not any of its submenus.

See also
UpdateAll

Implements berry::IContributionManager.

◆ Update() [3/4]

void berry::MenuManager::Update ( bool  force,
bool  recursive 
)
protected

Incrementally builds the menu from the contribution items. This method leaves out double separators and separators in the first or last position.

Parameters
forcetrue means update even if not dirty, and false for normal incremental updating
recursivetrue means recursively update all submenus, and false means just this menu

◆ Update() [4/4]

void berry::MenuManager::Update ( const QString &  id)
overridevirtual

Updates any controls cached by this contribution item with changes for the the given property.

Parameters
idthe id of the changed property

Implements berry::IContributionItem.

◆ UpdateAll()

void berry::MenuManager::UpdateAll ( bool  force)
overridevirtual

Incrementally builds the menu from the contribution items, and does so recursively for all submenus.

Parameters
forcetrue means update even if not dirty, and false for normal incremental updating

Implements berry::IMenuManager.

Member Data Documentation

◆ visible

bool berry::MenuManager::visible
protected

Indicates this item is visible in its manager; true by default.

Definition at line 109 of file berryMenuManager.h.


The documentation for this class was generated from the following file: