digiKam
Digikam::ActionItemModel Class Reference
+ Inheritance diagram for Digikam::ActionItemModel:

Public Types

enum  ExtraRoles { ItemActionRole = Qt::UserRole + 10 }
 
enum  MenuCategoryFlag { ToplevelMenuCategory = 1 << 0 , ParentMenuCategory = 1 << 1 , SortCategoriesAlphabetically = 1 << 10 , SortCategoriesByInsertionOrder = 1 << 11 }
 

Public Slots

void hover (const QModelIndex &index)
 
void toggle (const QModelIndex &index)
 
void trigger (const QModelIndex &index)
 

Public Member Functions

 ActionItemModel (QObject *const parent=nullptr)
 
QStandardItem * addAction (QAction *action, const QString &category, const QVariant &categorySorting=QVariant())
 
void addActions (QWidget *widget)
 
void addActions (QWidget *widget, const QList< QAction * > &actionWhiteList)
 
QStandardItem * addItem (const QString &text, const QIcon &decoration, const QVariant &category, const QVariant &categorySorting=QVariant())
 
QStandardItem * addItem (const QString &text, const QVariant &category, const QVariant &categorySorting=QVariant())
 
DCategorizedSortFilterProxyModelcreateFilterModel () override
 
QModelIndex indexForAction (QAction *action) const
 
QStandardItem * itemForAction (QAction *action) const
 
MenuCategoryMode mode () const
 
void setMode (MenuCategoryMode mode)
 

Static Public Member Functions

static QAction * actionForIndex (const QModelIndex &index)
 

Protected Slots

void slotActionChanged ()
 

Protected Member Functions

void setPropertiesFromAction (QStandardItem *item, QAction *action)
 

Protected Attributes

DCategorizedSortFilterProxyModelm_filterModel
 
MenuCategoryMode m_mode
 

Member Enumeration Documentation

◆ ExtraRoles

Enumerator
ItemActionRole 

◆ MenuCategoryFlag

Enumerator
ToplevelMenuCategory 

The toplevel menu's text is used as category.

ParentMenuCategory 

If the action is in a submenu, this menu's text is taken as category.

SortCategoriesAlphabetically 

Sort categories alphabetically by category name.

SortCategoriesByInsertionOrder 

Sort categories by the order they are added (found in the scanned menu)

Constructor & Destructor Documentation

◆ ActionItemModel()

Digikam::ActionItemModel::ActionItemModel ( QObject *const  parent = nullptr)
explicit

This class is a CategorizedItemModel based on QActions, taking an action's text and icon for display and decoration. It is possible to retrieve an action for an index, and to call the action's slots from a given index.

Member Function Documentation

◆ actionForIndex()

QAction * Digikam::ActionItemModel::actionForIndex ( const QModelIndex &  index)
static

Returns the action for the given index. The method can also be used for indices from proxy models.

References ItemActionRole.

Referenced by Digikam::ActionSortFilterProxyModel::filterAcceptsRow(), hover(), toggle(), and trigger().

◆ addAction()

QStandardItem * Digikam::ActionItemModel::addAction ( QAction *  action,
const QString &  category,
const QVariant &  categorySorting = QVariant() 
)

◆ addActions() [1/2]

void Digikam::ActionItemModel::addActions ( QWidget *  widget)

◆ addActions() [2/2]

void Digikam::ActionItemModel::addActions ( QWidget *  widget,
const QList< QAction * > &  actionWhiteList 
)

References m_mode.

◆ addItem() [1/2]

QStandardItem * Digikam::CategorizedItemModel::addItem ( const QString &  text,
const QIcon &  decoration,
const QVariant &  category,
const QVariant &  categorySorting = QVariant() 
)
inherited

◆ addItem() [2/2]

QStandardItem * Digikam::CategorizedItemModel::addItem ( const QString &  text,
const QVariant &  category,
const QVariant &  categorySorting = QVariant() 
)
inherited

◆ createFilterModel()

◆ hover

void Digikam::ActionItemModel::hover ( const QModelIndex &  index)
slot

These three slots will cause the slots of the referred action to be called. Connect here for example a view's signals. Note that you can also pass indices from proxy models.

References actionForIndex().

◆ indexForAction()

QModelIndex Digikam::ActionItemModel::indexForAction ( QAction *  action) const

References itemForAction().

◆ itemForAction()

QStandardItem * Digikam::ActionItemModel::itemForAction ( QAction *  action) const

Returns the action for the given index. Note: these methods perform O(n).

References ItemActionRole.

Referenced by indexForAction(), and slotActionChanged().

◆ mode()

ActionItemModel::MenuCategoryMode Digikam::ActionItemModel::mode ( ) const

References m_mode.

Referenced by setMode().

◆ setMode()

void Digikam::ActionItemModel::setMode ( MenuCategoryMode  mode)

◆ setPropertiesFromAction()

void Digikam::ActionItemModel::setPropertiesFromAction ( QStandardItem *  item,
QAction *  action 
)
protected

References ItemActionRole.

Referenced by addAction(), and slotActionChanged().

◆ slotActionChanged

void Digikam::ActionItemModel::slotActionChanged ( )
protectedslot

◆ toggle

void Digikam::ActionItemModel::toggle ( const QModelIndex &  index)
slot

References actionForIndex().

◆ trigger

void Digikam::ActionItemModel::trigger ( const QModelIndex &  index)
slot

References actionForIndex().

Member Data Documentation

◆ m_filterModel

DCategorizedSortFilterProxyModel* Digikam::ActionItemModel::m_filterModel
protected

◆ m_mode

MenuCategoryMode Digikam::ActionItemModel::m_mode
protected

Referenced by addActions(), mode(), and setMode().


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