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

#include <berryMenuManager.h>

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

Public Member Functions

Q_SIGNAL void AboutToShow (IMenuManager *mm)
 
Q_SIGNAL void AboutToHide (IMenuManager *mm)
 
 MenuManager (const QString &text=QString(), const QString &id=QString())
 
 ~MenuManager ()
 
 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()
 
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) virtual void Add(QAction *action
 
- 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) virtual void AddMenuListener(QObject *listener)=0
 
- Public Member Functions inherited from berry::IContributionItem
 berryObjectMacro (berry::IContributionItem) virtual void Fill(QStatusBar *parent)=0
 

Public Attributes

berryObjectMacro(MenuManager) private QMenuProxy * menu
 
QAction * menuItem
 
QString menuText
 
QIcon image
 
SmartPointer< IContributionManagerOverridesoverrides
 
IContributionManagerparent
 
bool removeAllWhenShown
 
QString definitionId
 
- Public Attributes inherited from berry::IContributionManager
const QString & id
 

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 41 of file berryMenuManager.h.

Constructor & Destructor Documentation

berry::MenuManager::MenuManager ( const QString &  text = QString(),
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

Definition at line 127 of file berryMenuManager.cpp.

berry::MenuManager::~MenuManager ( )

Definition at line 148 of file berryMenuManager.cpp.

References menu.

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

Definition at line 135 of file berryMenuManager.cpp.

Member Function Documentation

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

Referenced by AddMenuListener().

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

Referenced by AddMenuListener().

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

Definition at line 173 of file berryMenuManager.cpp.

References AboutToHide(), and AboutToShow().

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

Definition at line 153 of file berryMenuManager.cpp.

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

Definition at line 163 of file berryMenuManager.cpp.

References Update().

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.
indexThe position the fill() method should start inserting at.

Definition at line 486 of file berryMenuManager.cpp.

Referenced by Update().

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

Definition at line 184 of file berryMenuManager.cpp.

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
indexthe index where the controls are inserted, or -1 to insert at the end

Implements berry::IContributionItem.

Definition at line 188 of file berryMenuManager.cpp.

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
indexthe index where the controls are inserted, or -1 to insert at the end

Implements berry::IContributionItem.

Definition at line 192 of file berryMenuManager.cpp.

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
indexthe index where the controls are inserted, or -1 to insert at the end

Implements berry::IContributionItem.

Definition at line 197 of file berryMenuManager.cpp.

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.

Definition at line 229 of file berryMenuManager.cpp.

References berry::SmartPointer< TObjectType >::Cast(), and 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.

Definition at line 239 of file berryMenuManager.cpp.

References berry::SmartPointer< TObjectType >::Cast(), berry::ContributionManager::Find(), and berry::IContributionManager::id.

Referenced by FindMenuUsingPath().

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.

Definition at line 262 of file berryMenuManager.cpp.

References berry::IContributionManager::id.

QIcon berry::MenuManager::GetImage ( void  ) const

Returns the image for this menu as an image descriptor.

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

Definition at line 292 of file berryMenuManager.cpp.

References image.

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

Returns the SWT menu control for this menu manager.

Returns
the menu control

Definition at line 267 of file berryMenuManager.cpp.

QString berry::MenuManager::GetMenuText ( ) const

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

Returns
the menu text

Definition at line 272 of file berryMenuManager.cpp.

References definitionId, and menuText.

Referenced by Update().

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.

Definition at line 297 of file berryMenuManager.cpp.

References overrides, and berry::ContributionManager::SetOverrides().

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

Returns the parent contribution manager of this manger.

Returns
the parent contribution manager

Definition at line 314 of file berryMenuManager.cpp.

References parent.

Referenced by MarkDirty().

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.

Definition at line 319 of file berryMenuManager.cpp.

References removeAllWhenShown.

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.

Definition at line 143 of file berryMenuManager.cpp.

References berry::ContributionManager::IsDirty().

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.

Definition at line 324 of file berryMenuManager.cpp.

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.

Definition at line 329 of file berryMenuManager.cpp.

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.

Definition at line 334 of file berryMenuManager.cpp.

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.

Definition at line 339 of file berryMenuManager.cpp.

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

Returns whether this contribution item is visibile within its manager.

Returns
true if this item is visible, and false otherwise

Implements berry::IContributionItem.

Definition at line 344 of file berryMenuManager.cpp.

References berry::ContributionManager::GetItems(), removeAllWhenShown, and visible.

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.

Definition at line 371 of file berryMenuManager.cpp.

References GetParent(), berry::ContributionManager::MarkDirty(), and berry::IContributionManager::MarkDirty().

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.

Definition at line 179 of file berryMenuManager.cpp.

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.

Definition at line 388 of file berryMenuManager.cpp.

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

Definition at line 413 of file berryMenuManager.cpp.

References definitionId.

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

Sets the overrides for this contribution manager

Parameters
newOverridesthe overrides for the items of this manager

Definition at line 392 of file berryMenuManager.cpp.

References overrides, and berry::ContributionManager::SetOverrides().

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

Sets the parent manager of this item

Parameters
parentthe parent contribution manager

Implements berry::IContributionItem.

Definition at line 398 of file berryMenuManager.cpp.

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.

Definition at line 403 of file berryMenuManager.cpp.

References removeAllWhenShown.

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

Sets whether this contribution item is visibile within its manager.

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

Implements berry::IContributionItem.

Definition at line 408 of file berryMenuManager.cpp.

References visible.

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.

Definition at line 418 of file berryMenuManager.cpp.

Referenced by CreateMenuBar(), Update(), and UpdateAll().

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.

Definition at line 423 of file berryMenuManager.cpp.

References berry::ContributionManager::GetItems(), GetMenuText(), berry::QActionProperties::IMAGE, image, and berry::QActionProperties::TEXT.

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.

Definition at line 449 of file berryMenuManager.cpp.

References Update().

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

Definition at line 498 of file berryMenuManager.cpp.

References berry::SmartPointer< TObjectType >::Cast(), DoItemFill(), berry::ContributionManager::GetItems(), berry::ContributionManager::IsDirty(), and berry::ContributionManager::SetDirty().

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.

Definition at line 454 of file berryMenuManager.cpp.

References Update().

Member Data Documentation

QString berry::MenuManager::definitionId

allows a submenu to display a shortcut key. This is often used with the QuickMenu command or action which can pop up a menu using the shortcut.

Definition at line 100 of file berryMenuManager.h.

Referenced by GetMenuText(), and SetCommandId().

QIcon berry::MenuManager::image

The image for a sub-menu.

Definition at line 78 of file berryMenuManager.h.

Referenced by GetImage(), and Update().

berryObjectMacro (MenuManager) private QMenuProxy* berry::MenuManager::menu

The menu id. The menu control; null before creation and after disposal.

Definition at line 47 of file berryMenuManager.h.

Referenced by ~MenuManager().

QAction* berry::MenuManager::menuItem

Definition at line 61 of file berryMenuManager.h.

QString berry::MenuManager::menuText

The menu item widget; null before creation and after disposal. This field is used when this menu manager is a sub-menu. The text for a sub-menu.

Definition at line 73 of file berryMenuManager.h.

Referenced by GetMenuText().

SmartPointer<IContributionManagerOverrides> berry::MenuManager::overrides

The overrides for items of this manager

Definition at line 83 of file berryMenuManager.h.

Referenced by GetOverrides(), and SetOverrides().

IContributionManager* berry::MenuManager::parent

The parent contribution manager.

Definition at line 88 of file berryMenuManager.h.

Referenced by GetParent().

bool berry::MenuManager::removeAllWhenShown

Indicates whether removeAll should be called just before the menu is displayed.

Definition at line 94 of file berryMenuManager.h.

Referenced by GetRemoveAllWhenShown(), IsVisible(), and SetRemoveAllWhenShown().

bool berry::MenuManager::visible
protected

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

Definition at line 113 of file berryMenuManager.h.

Referenced by IsVisible(), and SetVisible().


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