MythTV  master
Public Member Functions | Static Public Attributes | Protected Member Functions | Private Types | Private Attributes | List of all members
ActionSet Class Reference

Maintains consistancy between actions and keybindings. More...

#include <mythfrontend/actionset.h>

Public Member Functions

 ActionSet ()=default
 Create a new, empty set of action bindings. More...
 
 ~ActionSet ()
 
bool AddAction (const ActionID &id, const QString &description, const QString &keys)
 Add an action. More...
 
bool Add (const ActionID &id, const QString &key)
 Add a binding. More...
 
bool Remove (const ActionID &id, const QString &key)
 Remove a key from an action identifier. More...
 
bool Replace (const ActionID &id, const QString &newkey, const QString &oldkey)
 Replace a specific key in a specific action. More...
 
bool SetModifiedFlag (const ActionID &id, bool modified)
 Mark an action as modified or unmodified by its identifier. More...
 
QStringList GetContextStrings (void) const
 Returns a list of all contexts in the action set. More...
 
QStringList GetActionStrings (const QString &context_name) const
 Returns a list of all action in the action set. More...
 
QString GetKeyString (const ActionID &id) const
 Returns a string containing all the keys in bound to an action by its identifier. More...
 
QStringList GetKeys (const ActionID &id) const
 Get the keys bound to an action by its identifier. More...
 
QStringList GetContextKeys (const QString &context_name) const
 
QStringList GetAllKeys (void) const
 Get all keys (from every context) to which an action is bound. More...
 
QString GetDescription (const ActionID &id) const
 Returns the description of an action by its identifier. More...
 
ActionList GetActions (const QString &key) const
 Returns the actions bound to the specified key. More...
 
ActionList GetModified (void) const
 Returns the appropriate container of modified actions. More...
 
bool HasModified (void) const
 Returns true iff changes have been made. More...
 
bool IsModified (const ActionID &id) const
 Returns true iff the action is modified. More...
 

Static Public Attributes

static const QString kJumpContext = "JumpPoints"
 The statically assigned context for jump point actions. More...
 
static const QString kGlobalContext = "Global"
 The name of global actions. More...
 

Protected Member Functions

ActionGetAction (const ActionID &id)
 Returns a pointer to an action by its identifier. (note: result not thread-safe) More...
 

Private Types

using ContextMap = QHash< QString, ActionContext >
 

Private Attributes

QMap< QString, ActionListm_keyToActionMap
 
ContextMap m_contexts
 
ActionList m_modified
 

Detailed Description

Maintains consistancy between actions and keybindings.

This class handles adding a removing bindings to keys.

Definition at line 36 of file actionset.h.

Member Typedef Documentation

◆ ContextMap

using ActionSet::ContextMap = QHash<QString, ActionContext>
private

Definition at line 86 of file actionset.h.

Constructor & Destructor Documentation

◆ ActionSet()

ActionSet::ActionSet ( )
default

Create a new, empty set of action bindings.

◆ ~ActionSet()

ActionSet::~ActionSet ( )

Definition at line 33 of file actionset.cpp.

Member Function Documentation

◆ AddAction()

bool ActionSet::AddAction ( const ActionID id,
const QString &  description,
const QString &  keys 
)

Add an action.

If the action has already been added, it will not be added again. There are no duplicate actions in the action set.

Parameters
idThe action identifier.
descriptionThe action description.
keysThe keys for this action.
Returns
true if the action on success, false otherwise.

Definition at line 200 of file actionset.cpp.

Referenced by KeyBindings::LoadContexts(), and KeyBindings::LoadJumppoints().

◆ Add()

bool ActionSet::Add ( const ActionID id,
const QString &  key 
)

Add a binding.

If the key is added, we mark this action as modified, and update the key map.

Parameters
idThe action identifier.
keyThe symbolic name of the key.
Returns
true if the key was added otherwise, false.

Definition at line 59 of file actionset.cpp.

Referenced by KeyBindings::AddActionKey().

◆ Remove()

bool ActionSet::Remove ( const ActionID id,
const QString &  key 
)

Remove a key from an action identifier.

If the key is removed from the action, then we remove it from the key list, and mark the action id as modified.

Parameters
idThe action identifier to remove from.
keyThe key to remove.
Todo:
Remove the actionlist from the m_keyToActionMap if the key is no longer bound to any actions.

Definition at line 91 of file actionset.cpp.

Referenced by KeyBindings::RemoveActionKey().

◆ Replace()

bool ActionSet::Replace ( const ActionID id,
const QString &  newkey,
const QString &  oldkey 
)

Replace a specific key in a specific action.

If the key is replaced, then we remove the old key from the key list and add the new key and mark the action as modified.

Parameters
idThe action identifier.
newkeyThe new key.
oldkeyThe key to be replaced.

Definition at line 122 of file actionset.cpp.

Referenced by KeyBindings::ReplaceActionKey().

◆ SetModifiedFlag()

bool ActionSet::SetModifiedFlag ( const ActionID id,
bool  modified 
)

Mark an action as modified or unmodified by its identifier.

Returns
true if the action was modified, and is set to unmodified.

Definition at line 145 of file actionset.cpp.

Referenced by Add(), KeyBindings::CommitChanges(), Remove(), and Replace().

◆ GetContextStrings()

QStringList ActionSet::GetContextStrings ( void  ) const

Returns a list of all contexts in the action set.

Definition at line 162 of file actionset.cpp.

Referenced by KeyBindings::GetContexts().

◆ GetActionStrings()

QStringList ActionSet::GetActionStrings ( const QString &  context_name) const

Returns a list of all action in the action set.

Definition at line 175 of file actionset.cpp.

Referenced by KeyBindings::GetActions().

◆ GetKeyString()

QString ActionSet::GetKeyString ( const ActionID id) const

Returns a string containing all the keys in bound to an action by its identifier.

Definition at line 224 of file actionset.cpp.

Referenced by KeyBindings::CommitAction(), and KeyBindings::CommitJumppoint().

◆ GetKeys()

QStringList ActionSet::GetKeys ( const ActionID id) const

Get the keys bound to an action by its identifier.

Definition at line 240 of file actionset.cpp.

Referenced by KeyBindings::GetActionKeys(), KeyBindings::HasMandatoryBindings(), and KeyBindings::RemoveActionKey().

◆ GetContextKeys()

QStringList ActionSet::GetContextKeys ( const QString &  context_name) const

Definition at line 254 of file actionset.cpp.

Referenced by KeyBindings::GetContextKeys().

◆ GetAllKeys()

QStringList ActionSet::GetAllKeys ( void  ) const

Get all keys (from every context) to which an action is bound.

Definition at line 269 of file actionset.cpp.

Referenced by KeyBindings::GetKeys().

◆ GetDescription()

QString ActionSet::GetDescription ( const ActionID id) const

Returns the description of an action by its identifier.

Definition at line 284 of file actionset.cpp.

Referenced by KeyBindings::GetActionDescription().

◆ GetActions()

ActionList ActionSet::GetActions ( const QString &  key) const
inline

Returns the actions bound to the specified key.

Definition at line 65 of file actionset.h.

Referenced by KeyBindings::GetConflict(), KeyBindings::GetKeyActions(), and KeyBindings::GetKeyContexts().

◆ GetModified()

ActionList ActionSet::GetModified ( void  ) const
inline

Returns the appropriate container of modified actions.

Definition at line 68 of file actionset.h.

Referenced by KeyBindings::CommitChanges().

◆ HasModified()

bool ActionSet::HasModified ( void  ) const
inline

Returns true iff changes have been made.

Definition at line 70 of file actionset.h.

Referenced by KeyBindings::HasChanges().

◆ IsModified()

bool ActionSet::IsModified ( const ActionID id) const
inline

Returns true iff the action is modified.

Definition at line 72 of file actionset.h.

Referenced by SetModifiedFlag().

◆ GetAction()

Action * ActionSet::GetAction ( const ActionID id)
protected

Returns a pointer to an action by its identifier. (note: result not thread-safe)

Definition at line 301 of file actionset.cpp.

Referenced by Add(), AddAction(), GetDescription(), GetKeys(), GetKeyString(), Remove(), and Replace().

Member Data Documentation

◆ kJumpContext

const QString ActionSet::kJumpContext = "JumpPoints"
static

The statically assigned context for jump point actions.

Definition at line 80 of file actionset.h.

Referenced by KeyBindings::CommitChanges(), KeyBindings::GetConflict(), MythControls::LoadData(), and KeyBindings::LoadJumppoints().

◆ kGlobalContext

const QString ActionSet::kGlobalContext = "Global"
static

The name of global actions.

Definition at line 82 of file actionset.h.

Referenced by KeyBindings::GetConflict(), MythControls::LoadData(), and KeyBindings::LoadMandatoryBindings().

◆ m_keyToActionMap

QMap<QString, ActionList> ActionSet::m_keyToActionMap
private

Definition at line 85 of file actionset.h.

Referenced by Add(), AddAction(), GetActions(), GetAllKeys(), Remove(), and Replace().

◆ m_contexts

ContextMap ActionSet::m_contexts
private

◆ m_modified

ActionList ActionSet::m_modified
private

Definition at line 88 of file actionset.h.

Referenced by GetModified(), HasModified(), IsModified(), and SetModifiedFlag().


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