digiKam
Digikam::ContextMenuHelper Class Reference

A helper class to add actions and special menus to the context menu. More...

+ Inheritance diagram for Digikam::ContextMenuHelper:

Classes

class  Private
 

Public Types

typedef const QList< qlonglong > imageIds
 

Signals

void signalAddNewTagFromABCMenu (const QString &)
 
void signalAddToExistingQueue (int)
 
void signalAssignColorLabel (int)
 
void signalAssignPickLabel (int)
 
void signalAssignRating (int)
 
void signalAssignTag (int)
 
void signalCreateGroup ()
 
void signalCreateGroupByFilename ()
 
void signalCreateGroupByTime ()
 
void signalCreateGroupByTimelapse ()
 
void signalGotoAlbum (const ItemInfo &)
 
void signalGotoDate (const ItemInfo &)
 
void signalGotoTag (int)
 
void signalPopupTagsView ()
 
void signalRemoveFromGroup ()
 
void signalRemoveTag (int)
 
void signalSetThumbnail (const ItemInfo &)
 
void signalUngroup ()
 

Public Member Functions

void addAction (const QString &name, bool addDisabled=false)
 
void addAction (QAction *const action, bool addDisabled=false)
 
void addAction (QAction *const action, QObject *const recv, const char *const slot, bool addDisabled=false)
 
void addActionDeleteAlbum (AlbumModificationHelper *const helper, PAlbum *const album)
 
void addActionDeleteFaceTag (TagModificationHelper *const helper, TAlbum *const tag)
 
void addActionDeleteFaceTags (TagModificationHelper *const helper, const QList< TAlbum * > &tags)
 
void addActionDeleteTag (TagModificationHelper *const helper, TAlbum *const tag)
 
void addActionDeleteTags (TagModificationHelper *const helper, const QList< TAlbum * > &tags)
 
void addActionEditAlbum (AlbumModificationHelper *const helper, PAlbum *const album)
 
void addActionEditTag (TagModificationHelper *const helper, TAlbum *const tag)
 
void addActionNewAlbum (AlbumModificationHelper *const helper, PAlbum *const parentAlbum=nullptr)
 
void addActionNewTag (TagModificationHelper *const helper, TAlbum *const parentTag=nullptr)
 
void addActionRenameAlbum (AlbumModificationHelper *const helper, PAlbum *const album)
 
void addActionResetAlbumIcon (AlbumModificationHelper *const helper, PAlbum *const album)
 
void addActionTagsToFaceTags (TagModificationHelper *const helper, const QList< TAlbum * > &tags)
 
void addActionTagToFaceTag (TagModificationHelper *const helper, TAlbum *const tag)
 
void addAlbumCheckUncheckActions (Album *const album)
 
void addAssignTagsMenu (const imageIds &ids)
 
void addCreateTagFromAddressbookMenu ()
 
void addExportMenu ()
 
void addGotoMenu (const imageIds &ids)
 
void addGroupActions (const imageIds &ids)
 
void addGroupMenu (const imageIds &ids, const QList< QAction * > &extraMenuItems=QList< QAction * >())
 
void addImportMenu ()
 
void addIQSAction (QObject *const recv, const char *const slot)
 
void addLabelsAction ()
 
void addOpenAndNavigateActions (const imageIds &ids, bool lightTable=false)
 
void addQueueManagerMenu ()
 
void addRemoveTagsMenu (const imageIds &ids)
 
void addSeparator ()
 
void addServicesMenu (const QList< QUrl > &selectedItems)
 
void addStandardActionCopy (QObject *const recv, const char *const slot)
 
void addStandardActionCut (QObject *const recv, const char *const slot)
 
void addStandardActionItemDelete (QObject *const recv, const char *const slot, int quantity=1)
 
void addStandardActionLightTable ()
 
void addStandardActionPaste (QObject *const recv, const char *const slot)
 
void addStandardActionThumbnail (const imageIds &ids, Album *const album)
 
void addSubMenu (QMenu *subMenu)
 
 ContextMenuHelper (QMenu *const parent)
 
QAction * exec (const QPoint &pos, QAction *const at=nullptr)
 
void setAlbumModel (AbstractCheckableAlbumModel *const model)
 
void setItemFilterModel (ItemFilterModel *const model)
 
 ~ContextMenuHelper () override
 

Detailed Description

A helper class to add actions and special menus to the context menu.

The ContextMenuHelper class helps adding commonly used actions and menus. Use this class to add

  • actions from the actionCollection
  • standard actions (copy, paste, delete)
  • temporary actions
  • predefined special actions
  • predefined submenus to the menu.

All addAction() methods take a special parameter 'addDisabled'. This parameter controls if disabled actions are added to the menu. Normally adding disabled actions is turned off, to clean up the menu and make it more readable.

If the ContextMenuHelper class is used, you need to call its own exec() method, instead the one from the parent menu. This way signals from special menus can be emitted and connected to the appropriate slots.

Member Typedef Documentation

◆ imageIds

typedef const QList<qlonglong> Digikam::ContextMenuHelper::imageIds

Constructor & Destructor Documentation

◆ ContextMenuHelper()

Digikam::ContextMenuHelper::ContextMenuHelper ( QMenu *const  parent)
explicit

Constructs the helper class.

Parameters
parentthe menu the helper class is linked to

References Digikam::DigikamApp::instance(), Digikam::ContextMenuHelper::Private::parent, and Digikam::ContextMenuHelper::Private::stdActionCollection.

◆ ~ContextMenuHelper()

Digikam::ContextMenuHelper::~ContextMenuHelper ( )
override

Member Function Documentation

◆ addAction() [1/3]

void Digikam::ContextMenuHelper::addAction ( const QString &  name,
bool  addDisabled = false 
)

◆ addAction() [2/3]

void Digikam::ContextMenuHelper::addAction ( QAction *const  action,
bool  addDisabled = false 
)

Add a temporary action.

Sometimes it is necessary to define actions that only exist in the current context menu content. Use this method to add such an action.

Parameters
actionthe action to add
addDisabledif set, disabled actions are added to the menu

References Digikam::ContextMenuHelper::Private::parent.

◆ addAction() [3/3]

void Digikam::ContextMenuHelper::addAction ( QAction *const  action,
QObject *const  recv,
const char *const  slot,
bool  addDisabled = false 
)

Add a temporary action and assign it to a custom slot.

Use this method if you want to add a temporary action and immediately connect it to the receiving slot.

Parameters
actionthe action to add
recvthe receiver of the triggered action
slotthe slot to connect the triggered action to
addDisabledif set, disabled actions are added to the menu

References addAction().

◆ addActionDeleteAlbum()

◆ addActionDeleteFaceTag()

void Digikam::ContextMenuHelper::addActionDeleteFaceTag ( TagModificationHelper *const  helper,
TAlbum *const  tag 
)

Add action to delete tags from people sidebar.

References addAction(), and Digikam::TagModificationHelper::bindTag().

Referenced by Digikam::TagFolderView::addCustomContextMenuActions().

◆ addActionDeleteFaceTags()

void Digikam::ContextMenuHelper::addActionDeleteFaceTags ( TagModificationHelper *const  helper,
const QList< TAlbum * > &  tags 
)

◆ addActionDeleteTag()

void Digikam::ContextMenuHelper::addActionDeleteTag ( TagModificationHelper *const  helper,
TAlbum *const  tag 
)

◆ addActionDeleteTags()

void Digikam::ContextMenuHelper::addActionDeleteTags ( TagModificationHelper *const  helper,
const QList< TAlbum * > &  tags 
)

◆ addActionEditAlbum()

void Digikam::ContextMenuHelper::addActionEditAlbum ( AlbumModificationHelper *const  helper,
PAlbum *const  album 
)

◆ addActionEditTag()

void Digikam::ContextMenuHelper::addActionEditTag ( TagModificationHelper *const  helper,
TAlbum *const  tag 
)

◆ addActionNewAlbum()

void Digikam::ContextMenuHelper::addActionNewAlbum ( AlbumModificationHelper *const  helper,
PAlbum *const  parentAlbum = nullptr 
)

Add actions to add, remove or edit a tag. The tag modification helper is used to execute the action. You must set the parent tag to use on modification helper.

References addAction(), Digikam::AlbumModificationHelper::bindAlbum(), and Digikam::ContextMenuHelper::Private::copyFromMainCollection().

◆ addActionNewTag()

void Digikam::ContextMenuHelper::addActionNewTag ( TagModificationHelper *const  helper,
TAlbum *const  parentTag = nullptr 
)

Add actions to add, remove or edit a tag. The tag modification helper is used to execute the action. You must set the parent tag to use on modification helper.

References addAction(), and Digikam::TagModificationHelper::bindTag().

Referenced by Digikam::TagFolderView::addCustomContextMenuActions(), and Digikam::TagMngrTreeView::setContexMenuItems().

◆ addActionRenameAlbum()

◆ addActionResetAlbumIcon()

void Digikam::ContextMenuHelper::addActionResetAlbumIcon ( AlbumModificationHelper *const  helper,
PAlbum *const  album 
)

◆ addActionTagsToFaceTags()

void Digikam::ContextMenuHelper::addActionTagsToFaceTags ( TagModificationHelper *const  helper,
const QList< TAlbum * > &  tags 
)

◆ addActionTagToFaceTag()

void Digikam::ContextMenuHelper::addActionTagToFaceTag ( TagModificationHelper *const  helper,
TAlbum *const  tag 
)

◆ addAlbumCheckUncheckActions()

void Digikam::ContextMenuHelper::addAlbumCheckUncheckActions ( Album *const  album)

Add a Select and Deselect menu to check and uncheck albums. Note: Call setAlbumModel before, or this will have no effect.

References addSubMenu(), Digikam::ContextMenuHelper::Private::albumModel, Digikam::ContextMenuHelper::Private::parent, Digikam::Album::TAG, and Digikam::Album::type().

Referenced by Digikam::TagCheckView::addCustomContextMenuActions().

◆ addAssignTagsMenu()

void Digikam::ContextMenuHelper::addAssignTagsMenu ( const imageIds ids)

Add "Assign Tags" menu.

This menu will provide a list of all tags available so that they can be assigned to the current selected items.

To make this menu work, you need to run exec() from this class, otherwise the signals are not emitted and you will not be able to react on triggered actions from this menu. Make sure to connect the signals to the appropriate slots in the context menu handling method.

Parameters
idsthe selected items
See also
exec()
signalAssignTag()

References Digikam::ContextMenuHelper::Private::parent, Digikam::TagsPopupMenu::RECENTLYASSIGNED, signalAssignTag(), and signalPopupTagsView().

◆ addCreateTagFromAddressbookMenu()

void Digikam::ContextMenuHelper::addCreateTagFromAddressbookMenu ( )

Add a menu to create new tags from adressbook entries.

References Digikam::ContextMenuHelper::Private::parent, and signalAddNewTagFromABCMenu().

Referenced by Digikam::TagFolderView::addCustomContextMenuActions().

◆ addExportMenu()

◆ addGotoMenu()

void Digikam::ContextMenuHelper::addGotoMenu ( const imageIds ids)

Add the Goto menu.

This menu will provide the following actions for the given item:

  • Goto Album
  • Goto Date
  • Goto Tag To make this menu work, you need to run exec() from this class, otherwise the signals are not emitted and you will not be able to react on triggered actions from this menu. Make sure to connect the signals to the appropriate slots in the context menu handling method.
Parameters
imageIdsthe list of selected items
See also
exec()
signalGotoAlbum() signalGotoDate() signalGotoTag()

TODO:tags to be ported to multiple selection

References addAction(), Digikam::ItemInfo::albumId(), Digikam::AlbumManager::currentAlbums(), Digikam::Album::DATE, Digikam::TagsPopupMenu::DISPLAY, Digikam::ContextMenuHelper::Private::gotoAlbumAction, Digikam::ContextMenuHelper::Private::gotoDateAction, Digikam::Album::id(), Digikam::AlbumManager::instance(), Digikam::ItemInfo::isNull(), Digikam::ContextMenuHelper::Private::parent, Digikam::Album::PHYSICAL, Digikam::ContextMenuHelper::Private::selectedIds, signalGotoTag(), and Digikam::Album::type().

Referenced by addOpenAndNavigateActions().

◆ addGroupActions()

void Digikam::ContextMenuHelper::addGroupActions ( const imageIds ids)

◆ addGroupMenu()

void Digikam::ContextMenuHelper::addGroupMenu ( const imageIds ids,
const QList< QAction * > &  extraMenuItems = QList<QAction*>() 
)

Add a "Group" menu. This menu will provide actions open, close, add to, remove from, or split a group.

addGroupActions will add the actions as a flat list, not in a submenu. Note: Call setItemFilterModel before to have Open/Close group actions.

References Digikam::ContextMenuHelper::Private::parent.

◆ addImportMenu()

◆ addIQSAction()

void Digikam::ContextMenuHelper::addIQSAction ( QObject *const  recv,
const char *const  slot 
)

Add the standard Image Quality Sorter action and connect it to the appropriate slot

Parameters
recvthe receiver of the triggered action
slotthe slot to connect the triggered action to

References addAction(), and Digikam::ContextMenuHelper::Private::parent.

◆ addLabelsAction()

void Digikam::ContextMenuHelper::addLabelsAction ( )

Add "Pick/Color/Rating Labels" action.

This action will provide methods to assign pick/color/rating labels to the currently selected items.

To make this menu work, you need to run exec() from this class, otherwise the signals are not emitted and you will not be able to react on triggered actions from this menu. Make sure to connect the signals to the appropriate slots in the context menu handling method.

See also
exec()
signalAssignPickLabel()
signalAssignColorLabel()
signalAssignRating()

References addSubMenu(), Digikam::ContextMenuHelper::Private::parent, signalAssignColorLabel(), signalAssignPickLabel(), and signalAssignRating().

◆ addOpenAndNavigateActions()

void Digikam::ContextMenuHelper::addOpenAndNavigateActions ( const imageIds ids,
bool  lightTable = false 
)

Add section for main views for opening and moving/going to albums.

This is a convenience function to ensure consistent menus and reduce code duplication.

Parameters
imageIdsthe list of selected items
lightTablefor the light table

References addAction(), addGotoMenu(), addServicesMenu(), and Digikam::ContextMenuHelper::Private::selectedItems.

◆ addQueueManagerMenu()

◆ addRemoveTagsMenu()

void Digikam::ContextMenuHelper::addRemoveTagsMenu ( const imageIds ids)

Add "Remove Tags" menu.

This menu will provide a list of all tags assigned to the current items. Actions triggered in here will remove the selected tag from the items.

To make this menu work, you need to run exec() from this class, otherwise the signals are not emitted and you will not be able to react on triggered actions from this menu. Make sure to connect the signals to the appropriate slots in the context menu handling method.

Parameters
idsthe selected items
See also
exec()
signalRemoveTag()

References Digikam::CoreDbAccess::db(), Digikam::CoreDB::getItemCommonTagIDs(), Digikam::TagsCache::instance(), Digikam::ContextMenuHelper::Private::parent, Digikam::TagsPopupMenu::REMOVE, and signalRemoveTag().

◆ addSeparator()

◆ addServicesMenu()

void Digikam::ContextMenuHelper::addServicesMenu ( const QList< QUrl > &  selectedItems)

Add the services menu to the menu.

The services menu is used to open the selected items in a different application. It will query the item for registered services and provide them in a submenu. The menu will be titled "Open With...".

Parameters
selectedItemsthe list of selected items

References addAction(), Digikam::ContextMenuHelper::Private::parent, Digikam::DServiceMenu::servicesForOpenWith(), and Digikam::ContextMenuHelper::Private::servicesMap.

Referenced by addOpenAndNavigateActions().

◆ addStandardActionCopy()

void Digikam::ContextMenuHelper::addStandardActionCopy ( QObject *const  recv,
const char *const  slot 
)

Add the standard copy action and connect it to the appropriate slot

Parameters
recvthe receiver of the triggered action
slotthe slot to connect the triggered action to

References addAction(), Digikam::DXmlGuiWindow::buildStdAction(), Digikam::ContextMenuHelper::Private::parent, and Digikam::StdCopyAction.

◆ addStandardActionCut()

void Digikam::ContextMenuHelper::addStandardActionCut ( QObject *const  recv,
const char *const  slot 
)

Add the standard cut action and connect it to the appropriate slot

Parameters
recvthe receiver of the triggered action
slotthe slot to connect the triggered action to

References addAction(), Digikam::DXmlGuiWindow::buildStdAction(), Digikam::ContextMenuHelper::Private::parent, and Digikam::StdCutAction.

◆ addStandardActionItemDelete()

void Digikam::ContextMenuHelper::addStandardActionItemDelete ( QObject *const  recv,
const char *const  slot,
int  quantity = 1 
)

Add the standard delete action and connect it to the appropriate slot

Parameters
recvthe receiver of the triggered action
slotthe slot to connect the triggered action to
quantitythe number of the files that should be deleted. This parameter is used for the action name and is normally used when deleting more then one item.

References addAction(), and Digikam::ContextMenuHelper::Private::parent.

◆ addStandardActionLightTable()

void Digikam::ContextMenuHelper::addStandardActionLightTable ( )

Add the lighttable action to the menu.

Do not use addAction() to add the lighttable action, because we need to handle special cases here. Depending on whether the lighttable window has already been created and filled with items, we set different actions.

References addAction(), Digikam::LightTableWindow::lightTableWindow(), Digikam::LightTableWindow::lightTableWindowCreated(), and Digikam::ContextMenuHelper::Private::stdActionCollection.

◆ addStandardActionPaste()

void Digikam::ContextMenuHelper::addStandardActionPaste ( QObject *const  recv,
const char *const  slot 
)

Add the standard paste action and connect it to the appropriate slot

Parameters
recvthe receiver of the triggered action
slotthe slot to connect the triggered action to

References addAction(), Digikam::DXmlGuiWindow::buildStdAction(), Digikam::ContextMenuHelper::Private::parent, and Digikam::StdPasteAction.

◆ addStandardActionThumbnail()

void Digikam::ContextMenuHelper::addStandardActionThumbnail ( const imageIds ids,
Album *const  album 
)

Add the thumbnail action to the menu.

Do not use addAction() to add the thumbnail action, because we need to handle special cases here. Depending on whether the current view is album or icon view, we set different actions.

Parameters
idsthe selected items in the current view
albumthe current album the AlbumIconView is displaying

References addAction(), Digikam::ContextMenuHelper::Private::parent, Digikam::Album::PHYSICAL, Digikam::ContextMenuHelper::Private::setThumbnailAction, Digikam::Album::TAG, and Digikam::Album::type().

◆ addSubMenu()

void Digikam::ContextMenuHelper::addSubMenu ( QMenu *  subMenu)

Add a submenu to the parent context menu.

Parameters
subMenuthe submenu to be added

References Digikam::ContextMenuHelper::Private::parent.

Referenced by addAlbumCheckUncheckActions(), and addLabelsAction().

◆ exec()

QAction * Digikam::ContextMenuHelper::exec ( const QPoint &  pos,
QAction *const  at = nullptr 
)

Execute the registered parent menu and evaluate the triggered actions.

Always use this method instead the one from the parent menu. It will ensure that the signals are emitted and special cases are handled.

Parameters
posposition of the triggered action in the registered menu
atthe action that should be at the position pos
Returns
the triggered action

References Digikam::ContextMenuHelper::Private::gotoAlbumAction, Digikam::ContextMenuHelper::Private::gotoDateAction, Digikam::ContextMenuHelper::Private::parent, Digikam::ContextMenuHelper::Private::queueActions, Digikam::ContextMenuHelper::Private::selectedIds, Digikam::ContextMenuHelper::Private::setThumbnailAction, signalAddToExistingQueue(), signalGotoAlbum(), signalGotoDate(), and signalSetThumbnail().

Referenced by Digikam::TagMngrListView::contextMenuEvent(), Digikam::TagMngrTreeView::contextMenuEvent(), and Digikam::TagFolderView::contextMenuEvent().

◆ setAlbumModel()

void Digikam::ContextMenuHelper::setAlbumModel ( AbstractCheckableAlbumModel *const  model)

Set an album model. The check/uncheck actions will operate directly on the model.

References Digikam::ContextMenuHelper::Private::albumModel.

Referenced by Digikam::TagCheckView::addCustomContextMenuActions().

◆ setItemFilterModel()

void Digikam::ContextMenuHelper::setItemFilterModel ( ItemFilterModel *const  model)

Set a filter model. Some of the group actions will operate directly on the model.

References Digikam::ContextMenuHelper::Private::imageFilterModel.

◆ signalAddNewTagFromABCMenu

void Digikam::ContextMenuHelper::signalAddNewTagFromABCMenu ( const QString &  )
signal

◆ signalAddToExistingQueue

void Digikam::ContextMenuHelper::signalAddToExistingQueue ( int  )
signal

Referenced by exec().

◆ signalAssignColorLabel

void Digikam::ContextMenuHelper::signalAssignColorLabel ( int  )
signal

Referenced by addLabelsAction().

◆ signalAssignPickLabel

void Digikam::ContextMenuHelper::signalAssignPickLabel ( int  )
signal

Referenced by addLabelsAction().

◆ signalAssignRating

void Digikam::ContextMenuHelper::signalAssignRating ( int  )
signal

Referenced by addLabelsAction().

◆ signalAssignTag

void Digikam::ContextMenuHelper::signalAssignTag ( int  )
signal

Referenced by addAssignTagsMenu().

◆ signalCreateGroup

void Digikam::ContextMenuHelper::signalCreateGroup ( )
signal

◆ signalCreateGroupByFilename

void Digikam::ContextMenuHelper::signalCreateGroupByFilename ( )
signal

◆ signalCreateGroupByTime

void Digikam::ContextMenuHelper::signalCreateGroupByTime ( )
signal

◆ signalCreateGroupByTimelapse

void Digikam::ContextMenuHelper::signalCreateGroupByTimelapse ( )
signal

◆ signalGotoAlbum

void Digikam::ContextMenuHelper::signalGotoAlbum ( const ItemInfo )
signal

Referenced by exec().

◆ signalGotoDate

void Digikam::ContextMenuHelper::signalGotoDate ( const ItemInfo )
signal

Referenced by exec().

◆ signalGotoTag

void Digikam::ContextMenuHelper::signalGotoTag ( int  )
signal

Referenced by addGotoMenu().

◆ signalPopupTagsView

void Digikam::ContextMenuHelper::signalPopupTagsView ( )
signal

Referenced by addAssignTagsMenu().

◆ signalRemoveFromGroup

void Digikam::ContextMenuHelper::signalRemoveFromGroup ( )
signal

◆ signalRemoveTag

void Digikam::ContextMenuHelper::signalRemoveTag ( int  )
signal

Referenced by addRemoveTagsMenu().

◆ signalSetThumbnail

void Digikam::ContextMenuHelper::signalSetThumbnail ( const ItemInfo )
signal

Referenced by exec().

◆ signalUngroup

void Digikam::ContextMenuHelper::signalUngroup ( )
signal

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