Medical Imaging Interaction Toolkit  2023.12.99-ed252ae7
Medical Imaging Interaction Toolkit
berry::ContributionManager Class Reference

#include <berryContributionManager.h>

Inheritance diagram for berry::ContributionManager:
Collaboration diagram for berry::ContributionManager:

Public Member Functions

 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 ()
 
SmartPointer< IContributionManagerOverridesGetOverrides () override
 
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 IsDirty () const override
 
bool IsEmpty () const override
 
void MarkDirty () 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 Update (bool force)=0
 
- 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
 

Protected Member Functions

 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
 

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 ()
 
- Protected Attributes inherited from berry::Object
QAtomicInt m_ReferenceCount
 
QMutex m_ReferenceCountLock
 

Detailed Description

Abstract base class for all contribution managers, and standard implementation of IContributionManager. This class provides functionality common across the specific managers defined by this framework.

This class maintains a list of contribution items and a dirty flag, both as internal state. In addition to providing implementations of most IContributionManager methods, this class automatically coalesces adjacent separators, hides beginning and ending separators, and deals with dynamically changing sets of contributions. When the set of contributions does change dynamically, the changes are propagated to the control via the update method, which subclasses must implement.

Note: A ContributionItem cannot be shared between different ContributionManagers.

Definition at line 42 of file berryContributionManager.h.

Constructor & Destructor Documentation

◆ ~ContributionManager()

berry::ContributionManager::~ContributionManager ( )
override

◆ ContributionManager()

berry::ContributionManager::ContributionManager ( )
protected

Creates a new contribution manager.

Member Function Documentation

◆ Add() [1/2]

void berry::ContributionManager::Add ( const SmartPointer< IContributionItem > &  item)
overridevirtual

Adds a contribution item to this manager.

Parameters
itemthe contribution item, this cannot be null

Implements berry::IContributionManager.

◆ Add() [2/2]

void berry::ContributionManager::Add ( QAction *  action,
const QString &  id 
)
overridevirtual

Adds an action as a contribution item to this manager. Equivalent to Add(IContributionItem::Pointer(new QActionContributionItem(action, id))).

Parameters
actionthe action, this cannot be null
idthe unique action id

Implements berry::IContributionManager.

◆ AllowItem()

virtual bool berry::ContributionManager::AllowItem ( IContributionItem itemToAdd)
protectedvirtual

This method allows subclasses of ContributionManager to prevent certain items in the contributions list. ContributionManager will either block or allow an addition based on the result of this method call. This can be used to prevent duplication, for example.

Parameters
itemToAddThe contribution item to be added; may be null.
Returns
true if the addition should be allowed; false otherwise. The default implementation allows all items.

◆ AppendToGroup() [1/2]

void berry::ContributionManager::AppendToGroup ( const QString &  groupName,
const SmartPointer< IContributionItem > &  item 
)
overridevirtual

Adds a contribution item to this manager at the end of the group with the given name.

Parameters
groupNamethe name of the group
itemthe contribution item
Exceptions
ctkInvalidArgumentExceptionif there is no group with the given name

Implements berry::IContributionManager.

◆ AppendToGroup() [2/2]

void berry::ContributionManager::AppendToGroup ( const QString &  groupName,
QAction *  action,
const QString &  id 
)
overridevirtual

Adds a contribution item for the given action at the end of the group with the given name. Equivalent to AppendToGroup(groupName,IContributionItem::Pointer(new QActionContributionItem(action, id))).

Parameters
groupNamethe name of the group
actionthe action
idthe unique action id
Exceptions
ctkInvalidArgumentExceptionif there is no group with the given name

Implements berry::IContributionManager.

◆ berryObjectMacro()

berry::ContributionManager::berryObjectMacro ( berry::ContributionManager  )

◆ DumpStatistics()

void berry::ContributionManager::DumpStatistics ( )
protected

Internal debug method for printing statistics about this manager to cout.

◆ Find()

SmartPointer<IContributionItem> berry::ContributionManager::Find ( const QString &  id) const
overridevirtual

Finds the contribution item with the given id.

Parameters
idthe contribution item id
Returns
the contribution item, or null if no item with the given id can be found

Implements berry::IContributionManager.

◆ GetItems()

QList<SmartPointer<IContributionItem> > berry::ContributionManager::GetItems ( ) const
overridevirtual

Returns all contribution items known to this manager.

Returns
a list of contribution items

Implements berry::IContributionManager.

◆ GetOverrides()

SmartPointer<IContributionManagerOverrides> berry::ContributionManager::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.

Implements berry::IContributionManager.

Reimplemented in berry::MenuManager.

◆ GetSize()

int berry::ContributionManager::GetSize ( )

Return the number of contributions in this manager.

Returns
the number of contributions in this manager

◆ HasDynamicItems()

bool berry::ContributionManager::HasDynamicItems ( ) const
protected

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

Returns
true if this manager contains dynamic items, and false otherwise

◆ IndexOf() [1/2]

int berry::ContributionManager::IndexOf ( const QString &  id)

Returns the index of the item with the given id.

Parameters
idThe id of the item whose index is requested.
Returns
int the index or -1 if the item is not found

◆ IndexOf() [2/2]

int berry::ContributionManager::IndexOf ( const SmartPointer< IContributionItem > &  item) const
protected

Returns the index of the object in the internal structure. This is different from indexOf(String id) since some contribution items may not have an id.

Parameters
itemThe contribution item
Returns
the index, or -1 if the item is not found

◆ Insert()

void berry::ContributionManager::Insert ( int  index,
const SmartPointer< IContributionItem > &  item 
)

Insert the item at the given index.

Parameters
indexThe index to be used for insertion
itemThe item to be inserted

◆ InsertAfter()

void berry::ContributionManager::InsertAfter ( const QString &  id,
const SmartPointer< IContributionItem > &  item 
)
overridevirtual

Inserts a contribution item after the item with the given id.

Parameters
idthe contribution item id
itemthe contribution item to insert
Exceptions
IllegalArgumentExceptionif there is no item with the given id

Implements berry::IContributionManager.

◆ InsertBefore()

void berry::ContributionManager::InsertBefore ( const QString &  id,
const SmartPointer< IContributionItem > &  item 
)
overridevirtual

Inserts a contribution item before the item with the given id.

Parameters
idthe contribution item id
itemthe contribution item to insert
Exceptions
IllegalArgumentExceptionif there is no item with the given id

Implements berry::IContributionManager.

◆ InternalSetItems()

void berry::ContributionManager::InternalSetItems ( const QList< SmartPointer< IContributionItem > > &  items)
protected

An internal method for setting the order of the contribution items.

Parameters
itemsthe contribution items in the specified order

◆ IsDirty()

bool berry::ContributionManager::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

Implements berry::IContributionManager.

Reimplemented in berry::MenuManager.

◆ IsEmpty()

bool berry::ContributionManager::IsEmpty ( ) const
overridevirtual

Returns whether this manager has any contribution items.

Returns
true if there are no items, and false otherwise

Implements berry::IContributionManager.

◆ ItemAdded()

void berry::ContributionManager::ItemAdded ( const SmartPointer< IContributionItem > &  item)
protected

The given item was added to the list of contributions. Marks the manager as dirty and updates the number of dynamic items, and the memento.

Parameters
itemthe item to be added

◆ ItemRemoved()

void berry::ContributionManager::ItemRemoved ( const SmartPointer< IContributionItem > &  item)
protected

The given item was removed from the list of contributions. Marks the manager as dirty and updates the number of dynamic items.

Parameters
itemremove given parent from list of contributions

◆ MarkDirty()

void berry::ContributionManager::MarkDirty ( )
overridevirtual

Marks this contribution manager as dirty.

Implements berry::IContributionManager.

Reimplemented in berry::MenuManager.

◆ PrependToGroup()

void berry::ContributionManager::PrependToGroup ( const QString &  groupName,
const SmartPointer< IContributionItem > &  item 
)
overridevirtual

Adds a contribution item to this manager at the beginning of the group with the given name.

Parameters
groupNamethe name of the group
itemthe contribution item
Exceptions
IllegalArgumentExceptionif there is no group with the given name

Implements berry::IContributionManager.

◆ Remove() [1/2]

SmartPointer<IContributionItem> berry::ContributionManager::Remove ( const QString &  id)
overridevirtual

Removes and returns the contribution item with the given id from this manager. Returns null if this manager has no contribution items with the given id.

Parameters
idthe contribution item id
Returns
the item that was found and removed, or null if none

Implements berry::IContributionManager.

◆ Remove() [2/2]

SmartPointer<IContributionItem> berry::ContributionManager::Remove ( const SmartPointer< IContributionItem > &  item)
overridevirtual

Removes the given contribution item from the contribution items known to this manager.

Parameters
itemthe contribution item
Returns
the item parameter if the item was removed, and null if it was not found

Implements berry::IContributionManager.

◆ RemoveAll()

void berry::ContributionManager::RemoveAll ( )
overridevirtual

Removes all contribution items from this manager.

Implements berry::IContributionManager.

◆ ReplaceItem()

bool berry::ContributionManager::ReplaceItem ( const QString &  identifier,
const SmartPointer< IContributionItem > &  replacementItem 
)

Replaces the item of the given identifier with another contribution item. This can be used, for example, to replace large contribution items with placeholders to avoid memory leaks. If the identifier cannot be found in the current list of items, then this does nothing. If multiple occurrences are found, then the replacement items is put in the first position and the other positions are removed.

Parameters
identifierThe identifier to look for in the list of contributions; should not be null.
replacementItemThe contribution item to replace the old item; must not be null. Use ContributionManager#Remove if that is what you want to do.
Returns
true if the given identifier can be

◆ SetDirty()

void berry::ContributionManager::SetDirty ( bool  dirty)
protected

Sets whether this manager is dirty. When dirty, the list of contributions is not accurately reflected in the corresponding widgets.

Parameters
dirtytrue if this manager is dirty, and false if it is up-to-date

◆ SetOverrides()

void berry::ContributionManager::SetOverrides ( const SmartPointer< IContributionManagerOverrides > &  newOverrides)

Sets the overrides for this contribution manager

Parameters
newOverridesthe overrides for the items of this manager

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