Medical Imaging Interaction Toolkit  2016.11.0
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()
 
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 Add(QAction *action
 
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 ()
 
- Public Attributes inherited from berry::IContributionManager
const QString & id
 
- 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 46 of file berryContributionManager.h.

Constructor & Destructor Documentation

berry::ContributionManager::ContributionManager ( )
protected

Creates a new contribution manager.

Definition at line 281 of file berryContributionManager.cpp.

Member Function Documentation

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

Definition at line 32 of file berryContributionManager.cpp.

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.

Definition at line 38 of file berryContributionManager.cpp.

References AllowItem(), berry::SmartPointer< TObjectType >::GetPointer(), and ItemAdded().

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.

Definition at line 287 of file berryContributionManager.cpp.

Referenced by Add(), Insert(), InsertAfter(), InsertBefore(), and InternalSetItems().

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.

Definition at line 48 of file berryContributionManager.cpp.

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.

Definition at line 53 of file berryContributionManager.cpp.

berry::ContributionManager::berryObjectMacro ( berry::ContributionManager  )
void berry::ContributionManager::DumpStatistics ( )
protected

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

Definition at line 292 of file berryContributionManager.cpp.

References BERRY_INFO, IsDirty(), and berry::Object::ToString().

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.

Definition at line 58 of file berryContributionManager.cpp.

Referenced by berry::MenuManager::FindUsingPath(), InsertAfter(), InsertBefore(), and Remove().

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.

Definition at line 73 of file berryContributionManager.cpp.

Referenced by berry::MenuManager::IsVisible(), RemoveAll(), and berry::MenuManager::Update().

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.

Definition at line 83 of file berryContributionManager.cpp.

int berry::ContributionManager::GetSize ( )

Return the number of contributions in this manager.

Returns
the number of contributions in this manager

Definition at line 78 of file berryContributionManager.cpp.

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

Definition at line 310 of file berryContributionManager.cpp.

Referenced by IsDirty().

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

Definition at line 101 of file berryContributionManager.cpp.

Referenced by ReplaceItem().

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

Definition at line 315 of file berryContributionManager.cpp.

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

Definition at line 116 of file berryContributionManager.cpp.

References AllowItem(), berry::SmartPointer< TObjectType >::GetPointer(), and ItemAdded().

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.

Definition at line 130 of file berryContributionManager.cpp.

References AllowItem(), Find(), berry::SmartPointer< TObjectType >::GetPointer(), berry::SmartPointer< TObjectType >::IsNull(), and ItemAdded().

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.

Definition at line 149 of file berryContributionManager.cpp.

References AllowItem(), Find(), berry::SmartPointer< TObjectType >::GetPointer(), berry::SmartPointer< TObjectType >::IsNull(), and ItemAdded().

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

Definition at line 345 of file berryContributionManager.cpp.

References AllowItem().

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.

Definition at line 168 of file berryContributionManager.cpp.

References HasDynamicItems().

Referenced by DumpStatistics(), berry::MenuManager::IsDirty(), and berry::MenuManager::Update().

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.

Definition at line 187 of file berryContributionManager.cpp.

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

Definition at line 320 of file berryContributionManager.cpp.

References MarkDirty().

Referenced by Add(), Insert(), InsertAfter(), InsertBefore(), and ReplaceItem().

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

Definition at line 330 of file berryContributionManager.cpp.

References MarkDirty().

Referenced by Remove(), RemoveAll(), and ReplaceItem().

void berry::ContributionManager::MarkDirty ( )
overridevirtual

Marks this contribution manager as dirty.

Implements berry::IContributionManager.

Reimplemented in berry::MenuManager.

Definition at line 192 of file berryContributionManager.cpp.

References SetDirty().

Referenced by ItemAdded(), ItemRemoved(), berry::MenuManager::MarkDirty(), and RemoveAll().

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.

Definition at line 197 of file berryContributionManager.cpp.

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.

Definition at line 202 of file berryContributionManager.cpp.

References Find(), and berry::SmartPointer< TObjectType >::IsNull().

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.

Definition at line 212 of file berryContributionManager.cpp.

References ItemRemoved().

void berry::ContributionManager::RemoveAll ( )
overridevirtual

Removes all contribution items from this manager.

Implements berry::IContributionManager.

Definition at line 222 of file berryContributionManager.cpp.

References GetItems(), ItemRemoved(), and MarkDirty().

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 remove if that is what you want to do.
Returns
true if the given identifier can be;

Definition at line 234 of file berryContributionManager.cpp.

References IndexOf(), berry::SmartPointer< TObjectType >::IsNotNull(), ItemAdded(), and ItemRemoved().

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

Definition at line 340 of file berryContributionManager.cpp.

Referenced by MarkDirty(), and berry::MenuManager::Update().

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

Sets the overrides for this contribution manager

Parameters
newOverridesthe overrides for the items of this manager

Definition at line 276 of file berryContributionManager.cpp.

Referenced by berry::MenuManager::GetOverrides(), and berry::MenuManager::SetOverrides().


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