ActionSet Class Reference

Maintains consistancy between actions and keybindings. More...

#include <actionset.h>

List of all members.

Public Member Functions

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

Static Public Attributes

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

Protected Member Functions

ActionGetAction (const ActionID &id)
 Returns a pointer to an action by its identifier.

Private Types

typedef QHash< QString, ContextContextMap

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 37 of file actionset.h.


Member Typedef Documentation

typedef QHash<QString, Context> ActionSet::ContextMap [private]

Definition at line 84 of file actionset.h.


Constructor & Destructor Documentation

ActionSet::ActionSet (  )  [inline]

Create a new, empty set of action bindings.

Definition at line 41 of file actionset.h.

ActionSet::~ActionSet (  ) 

Definition at line 34 of file actionset.cpp.


Member Function Documentation

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:
id The action identifier.
description The action description.
keys The keys for this action.
Returns:
true if the action on success, false otherwise.

Definition at line 203 of file actionset.cpp.

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

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:
id The action identifier.
key The symbolic name of the key.
Returns:
true if the key was added otherwise, false.

Definition at line 58 of file actionset.cpp.

Referenced by KeyBindings::AddActionKey().

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:
id The action identifier to remove from.
key The key to remove.
Todo:
Remove the actionlist from the m_keyToActionMap if the key is no longer bound to any actions.

Definition at line 90 of file actionset.cpp.

Referenced by KeyBindings::RemoveActionKey().

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:
id The action identifier.
newkey The new key.
oldkey The key to be replaced.

Definition at line 121 of file actionset.cpp.

Referenced by KeyBindings::ReplaceActionKey().

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 144 of file actionset.cpp.

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

QStringList ActionSet::GetContextStrings ( void   )  const

Returns a list of all contexts in the action set.

Definition at line 161 of file actionset.cpp.

Referenced by KeyBindings::GetContexts().

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

Returns a list of all action in the action set.

Definition at line 176 of file actionset.cpp.

Referenced by KeyBindings::GetActions().

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 228 of file actionset.cpp.

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

QStringList ActionSet::GetKeys ( const ActionID id  )  const

Get the keys bound to an action by its identifier.

Definition at line 244 of file actionset.cpp.

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

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

Definition at line 260 of file actionset.cpp.

Referenced by KeyBindings::GetContextKeys().

QStringList ActionSet::GetAllKeys ( void   )  const

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

Definition at line 278 of file actionset.cpp.

Referenced by KeyBindings::GetKeys().

QString ActionSet::GetDescription ( const ActionID id  )  const

Returns the description of an action by its identifier.

Definition at line 293 of file actionset.cpp.

Referenced by KeyBindings::GetActionDescription().

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

Returns the actions bound to the specified key.

Definition at line 309 of file actionset.cpp.

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

ActionList ActionSet::GetModified ( void   )  const

Returns the appropriate container of modified actions based on current context.

Definition at line 320 of file actionset.cpp.

Referenced by KeyBindings::CommitChanges().

bool ActionSet::HasModified ( void   )  const [inline]

Returns true iff changes have been made.

Definition at line 68 of file actionset.h.

Referenced by KeyBindings::HasChanges().

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

Returns true iff the action is modified.

Definition at line 70 of file actionset.h.

Referenced by SetModifiedFlag().

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

Returns a pointer to an action by its identifier.

(note: result not thread-safe)

Definition at line 331 of file actionset.cpp.

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


Member Data Documentation

const QString ActionSet::kJumpContext = "JumpPoints" [static]

The statically assigned context for jump point actions.

Definition at line 78 of file actionset.h.

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

const QString ActionSet::kGlobalContext = "Global" [static]

The name of global actions.

Definition at line 80 of file actionset.h.

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

QMap<QString, ActionList> ActionSet::m_keyToActionMap [private]

Definition at line 83 of file actionset.h.

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

Definition at line 86 of file actionset.h.

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


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends
Generated on Mon Feb 6 06:41:45 2012 for MythTV by  doxygen 1.6.3