SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Public Types | Signals | Public Member Functions | Static Public Attributes | Protected Slots | Protected Member Functions | Protected Attributes | List of all members
qtOperationAction Class Reference

A QAction for users to request an operation. More...

#include <qtOperationAction.h>

Inheritance diagram for qtOperationAction:
[legend]
Collaboration diagram for qtOperationAction:
[legend]

Public Types

using ActionFunctor = std::function< void(qtOperationAction *)>
 A function that takes an operation action as its input.
 

Signals

void acceptDefaults ()
 
void editParameters ()
 

Public Member Functions

 qtOperationAction (const std::shared_ptr< smtk::operation::Manager > &operationManager, const std::shared_ptr< smtk::view::Manager > &viewManager, smtk::operation::Operation::Index typeIndex, qtOperationTypeModel *parent=nullptr)
 
std::string name () const
 The label of the operation (or the operation's type-name if no label is provided).
 
smtk::operation::Operation::Index operationIndex () const
 The type-index of the operation.
 
QPointer< qtOperationTypeModeloperationModel () const
 The model to which the type-index of this action applies.
 
Qt::ToolButtonStyle buttonStyle () const
 Set/get the style of button this action creates (whether to include text, icon, or both).
 
void setButtonStyle (Qt::ToolButtonStyle style)
 
void forceStyle (Qt::ToolButtonStyle buttonStyle, ActionFunctor functor)
 Force the style of widgets created by this icon to be distinct. More...
 

Static Public Attributes

static constexpr int longPress = 200
 

Protected Slots

void parameterTimerElapsed ()
 
void defaultAction ()
 Called by QToolButton widgets attached to this action. More...
 

Protected Member Functions

QWidget * createWidget (QWidget *parent) override
 
void deleteWidget (QWidget *widget) override
 
bool eventFilter (QObject *watched, QEvent *event) override
 
void setOperationName (const std::string &label)
 Take an operation label and turn it into something something appropriate for a button. More...
 

Protected Attributes

QPointer< qtOperationTypeModelm_model
 The operation-type model for which this action was created.
 
smtk::operation::Operation::Index m_typeIndex
 The operation type-index (essentially the row in m_model).
 
std::string m_operationName
 A label for the operation.
 
smtk::attribute::utility::EditableParameters m_editableParameters
 Whether the operation has editable parameters.
 
QTimer m_timer
 A timer used to detect long-presses/double-clicks of buttons.
 
Qt::ToolButtonStyle m_style { Qt::ToolButtonTextBesideIcon }
 Setting that dictates how createWidget() decorates the button it creates.
 
bool m_toolButton { false }
 Setting indicating whether to create a push-button or a tool-button.
 

Detailed Description

A QAction for users to request an operation.

This class adapts an operation manager and operation type-index into a QWidgetAction for menus, toolbars, and tool-buttons. Depending on the operation's metadata, users may run the operation with its default parameters immediately and/or edit parameters before running the operation.

Member Function Documentation

◆ defaultAction

void qtOperationAction::defaultAction ( )
protectedslot

Called by QToolButton widgets attached to this action.

If the operation has any editable parameters, this method will emit editParameters(). Otherwise, it will emit acceptDefaults().

◆ forceStyle()

void qtOperationAction::forceStyle ( Qt::ToolButtonStyle  buttonStyle,
ActionFunctor  functor 
)

Force the style of widgets created by this icon to be distinct.

Inside the functor you provide, the button style (i.e., whether to include text, an icon, or both) will be the specified style. This is used to force toolbar buttons to be distinct from toolbox buttons.

The functor is passed a pointer to "this" so that you need not capture the action.

◆ setOperationName()

void qtOperationAction::setOperationName ( const std::string &  label)
protected

Take an operation label and turn it into something something appropriate for a button.

This method removes anything to the left of double-colons ("::") or space-separated dashes (" - "), then finds the space character closest to the center of the string and turns it into a line break.


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