Class sh::actions::ActionsManager

class sh::actions::ActionsManager : public QObject, public sh::base::Singleton

Factory for actions which are valid for a given list of FileSystemNode and tools for placing actions in some gui elements.

Public Functions

void getActions(std::shared_ptr<ActionInstantiation> instantiation, std::function<void(QList<std::shared_ptr<ActionInstantiation>>, QList<std::shared_ptr<sh::actions::ActionInstantiation>>)> callback, std::function<void(std::shared_ptr<ActionInstantiation>)> initializedcallback = [](std::shared_ptr< ActionInstantiation >){})

Asychonously gets actions for a list of sh::filesystem::FilesystemNode.

Parameters
  • nodes: The list of nodes.

  • callback: This callback is called once the list is fetched.

  • initializedcallback: This callback is called for each result action after initialization.

void getDefaultAction(QList<std::shared_ptr<sh::actions::AbstractActionItem>> actionList, std::function<void(std::shared_ptr<sh::actions::ActionActionItem>)> callback)

Determines the default action for a given list of actions.

Parameters
  • actionList: The list of all available actions.

  • callback: This callback is called when the default action was found (with an already initialized action).

void getActionForShortcut(QList<std::shared_ptr<filesystem::FilesystemNode>> selectedNodes, std::shared_ptr<filesystem::FilesystemNode> folderNode, int key, Qt::KeyboardModifiers modifiers, std::function<void(std::shared_ptr<sh::actions::AbstractActionItem>)> callback)

Asychonously gets the action for a shortcut.

Parameters
  • selectedNodes: The nodes which are currently selected in the active fileview.

  • folderNode: The folder which is shown by the active fileview.

  • key: The keypress character code.

  • modifiers: The keypress modifiers.

  • callback: This callback is called when an action was found (with an already initialized action).

void registerActionFactory(std::shared_ptr<sh::actions::AbstractActionFactory> actionFactory)

Registers an action factory.

This makes an action implementation available in the toolbar and context menus.

QList<std::shared_ptr<sh::actions::ActionActionItem>> runningActions()

Returns a list of all currently running actions.

void doInitialize()

Executes singleton initialization.

void doShutdown()

Executes singleton shutdown.

void shutdown()

Shutdown down this singleton.

bool isAlive()

Returns if this singleton is alive (true until its shutdown begins).

Signals

void runningActionsChanged()

Emitted when the list of running actions changed.

Public Static Functions

QString selectionLabel(QList<std::shared_ptr<sh::filesystem::FilesystemNode>> selection)

Returns a short header label text for a node selection.

QString directoryLabel(std::shared_ptr<sh::filesystem::FilesystemNode> directory)

Returns a short header label text for a current directory.

void sortAndSeparateActions(QList<std::shared_ptr<ActionInstantiation>> *actions)

Sorts a lists of actionitems and adds separators between groups. Modifies the given list.

Private Functions

ActionsManager()
QList<std::shared_ptr<ActionInstantiation>> _getActions_raw(std::shared_ptr<ActionInstantiation> instantiation)
void _emit_runningActionsChanged()
void recursivelyInitializeAction(std::shared_ptr<sh::actions::ActionInstantiation> actsit, std::function<void(std::shared_ptr<sh::actions::ActionInstantiation>)> callback, QList<std::shared_ptr<sh::actions::ActionInstantiation>> sits = {}, )

Recursively initializes a list of action items and calls a callback for each action item recursively afterwards.

Parameters
  • actions: List of all action items to traverse.

  • callback: This callback is called for each action item (even indirectly in a subtree hierarchy).

void _getDefaultAction_helper(QList<std::shared_ptr<sh::actions::AbstractActionItem>> actionList, std::shared_ptr<GDAHstruct> gdah)

Internal helper for the public getDefaultAction() method.

std::shared_ptr<sh::actions::ActionsManager::RunningActionsCounter> _actionExecutionStarted(std::shared_ptr<sh::actions::ActionActionItem> action)

Helper for updating _runningactions. .

Private Members

QList<std::shared_ptr<sh::actions::AbstractActionFactory>> _actionfactories
QMutex _mutex_actionfactories
QList<std::shared_ptr<sh::actions::ActionActionItem>> _runningactions
QMutex _mutex_runningactions

Friends

friend class ActionActionItem
struct GDAHstruct

Internal data structure used for _getDefaultAction_helper();.

Public Functions

GDAHstruct() = default
GDAHstruct(const GDAHstruct &o) = default

Public Members

sh::tools::AtomicCounter counter
std::function<void(std::shared_ptr<sh::actions::ActionActionItem>)> callback
int currentValue = 0
QList<std::shared_ptr<sh::actions::AbstractActionItem>> initialActionList
std::shared_ptr<sh::actions::AbstractActionItem> currentAction = 0
class RunningActionsCounter

Helper for updating _runningactions. .

Public Functions

RunningActionsCounter(ActionsManager *manager, std::shared_ptr<sh::actions::ActionActionItem> action)
~RunningActionsCounter()

Private Members

ActionsManager *_manager
std::shared_ptr<sh::actions::ActionActionItem> _action