KeyBindings Class Reference

#include <keybindings.h>

List of all members.


Detailed Description

Encapsulates information about the current keybindings.

This class can retrieve, set, and modify the keybindings used by MythTV

Definition at line 38 of file keybindings.h.


Public Types

enum  ConflictLevels { kKeyBindingWarning, kKeyBindingError }
 Levels of conflict. More...

Public Member Functions

 KeyBindings (const QString &hostname)
 Create a new KeyBindings instance.
bool AddActionKey (const QString &context_name, const QString &action_name, const QString &key)
 Add a key to an action.
ActionIDGetConflict (const QString &context_name, const QString &key, int &level) const
 Determine if adding a key would cause a conflict.
void ReplaceActionKey (const QString &context_name, const QString &action_name, const QString &newkey, const QString &oldkey)
bool RemoveActionKey (const QString &context_name, const QString &action_name, const QString &key)
 Unbind a key from an action.
void CommitChanges (void)
 Commit all changes made to the keybindings.
QStringList GetKeys (void) const
 Returns a list of all keys bound to an action.
QStringList GetContexts (void) const
 Returns a list of the context names.
QStringList GetActions (const QString &context) const
 Get a list of the actions in a context.
void GetKeyActions (const QString &key, ActionList &list) const
 Get a list of the actions in a context.
QStringList GetActionKeys (const QString &context_name, const QString &action_name) const
 Get an action's keys.
QStringList GetContextKeys (const QString &context) const
 Get the keys within a context.
QStringList GetKeyContexts (const QString &key) const
 Get the context names in which a key is bound.
QString GetActionDescription (const QString &context_name, const QString &action_name) const
 Get an action's description.
bool HasMandatoryBindings (void) const
 Returns true iff all mandatory bindings are satisfied.
bool HasChanges (void) const

Protected Member Functions

void CommitJumppoint (const ActionID &id)
 Commit a jumppoint to the database.
void CommitAction (const ActionID &id)
 Commit an action to the database, and reload its keybindings.
void LoadMandatoryBindings (void)
 Load the mandatory bindings.
void LoadContexts (void)
void LoadJumppoints (void)

Private Attributes

QString m_hostname
ActionList m_mandatoryBindings
QStringList m_defaultKeys
ActionSet m_actionSet

Member Enumeration Documentation

Levels of conflict.

Enumerator:
kKeyBindingWarning 
kKeyBindingError 

Definition at line 42 of file keybindings.h.


Constructor & Destructor Documentation

KeyBindings::KeyBindings ( const QString &  hostname  ) 

Create a new KeyBindings instance.

Parameters:
hostname The host for which to create the key bindings.

Definition at line 44 of file keybindings.cpp.


Member Function Documentation

bool KeyBindings::AddActionKey ( const QString &  context_name,
const QString &  action_name,
const QString &  key 
)

Add a key to an action.

This does not take effect until CommitChanges() is called.

Parameters:
context_name The name of the context.
action_name The name of the action.
key The key to add.

Definition at line 158 of file keybindings.cpp.

Referenced by MythControls::AddKeyToAction().

ActionID * KeyBindings::GetConflict ( const QString &  context_name,
const QString &  key,
int &  level 
) const

Determine if adding a key would cause a conflict.

Parameters:
context_name The name of the context.
key The key to add.
level The level of conflict if this returns an ActionID
Returns:
pointer to an ActionID if adding the key would cause a conflict.
Conflicts occur if:
  • the key is a jump point, but is bound elsewhere
  • the key is already bound to a jumppoint.
  • the key is bound to something in the global context.
  • the key is bound to something else in the specified context
If the method does not return NULL, check the value given to level. Warnings can be ignored (at the users disgression), but errors should be prevented no matter what.

NOTE: If this returns a non-null pointer, the ActionID returned must be explicitly deleted with C++ "delete".

Definition at line 185 of file keybindings.cpp.

Referenced by MythControls::AddKeyToAction().

void KeyBindings::ReplaceActionKey ( const QString &  context_name,
const QString &  action_name,
const QString &  newkey,
const QString &  oldkey 
)

Definition at line 229 of file keybindings.cpp.

Referenced by MythControls::AddKeyToAction().

bool KeyBindings::RemoveActionKey ( const QString &  context_name,
const QString &  action_name,
const QString &  key 
)

Unbind a key from an action.

Unless the action is Mandatory there is only one key in the action, this method should return true.

Parameters:
context_name The name of the context.
action_name The name of the action.
key The key to remove.
Returns:
true if the key was removed, or false if it was not.

Definition at line 249 of file keybindings.cpp.

Referenced by MythControls::DeleteKey().

void KeyBindings::CommitChanges ( void   ) 

Commit all changes made to the keybindings.

This method will write the changes to the database, unbind MythTV's current bindings for those actions that changed, and setup the new bindings.

Definition at line 331 of file keybindings.cpp.

Referenced by MythControls::Save().

QStringList KeyBindings::GetKeys ( void   )  const

Returns a list of all keys bound to an action.

Definition at line 53 of file keybindings.cpp.

Referenced by MythControls::customEvent().

QStringList KeyBindings::GetContexts ( void   )  const

Returns a list of the context names.

Note:
The returned list is a copy and can be modified without side-effects.

Definition at line 62 of file keybindings.cpp.

Referenced by MythControls::Create(), MythControls::customEvent(), and MythControls::LoadData().

QStringList KeyBindings::GetActions ( const QString &  context  )  const

Get a list of the actions in a context.

Parameters:
context The name of the context.
Returns:
A list of action (names) for the target context.
Note:
Store this instead of calling repeatedly. Every time you do, ActionSet has to iterate over all contexts and actions.

Definition at line 77 of file keybindings.cpp.

Referenced by MythControls::LoadData().

void KeyBindings::GetKeyActions ( const QString &  key,
ActionList list 
) const

Get a list of the actions in a context.

Parameters:
key The name of the context.
Returns:
A list of action (names) for the target context.
Note:
Store this instead of calling repeatedly. Every time you do, ActionSet has to iterate over all contexts and actions.

Definition at line 89 of file keybindings.cpp.

QStringList KeyBindings::GetActionKeys ( const QString &  context_name,
const QString &  action_name 
) const

Get an action's keys.

Parameters:
context_name The name of the context.
action_name The name of the action.
Returns:
The keys bound to the specified context's action

Definition at line 100 of file keybindings.cpp.

Referenced by MythControls::AddKeyToAction(), MythControls::GetCurrentKey(), and MythControls::RefreshKeyInformation().

QStringList KeyBindings::GetContextKeys ( const QString &  context  )  const

Get the keys within a context.

Parameters:
context The context name.
Returns:
A list of the keys in the context.

Definition at line 112 of file keybindings.cpp.

Referenced by MythControls::UpdateRightList().

QStringList KeyBindings::GetKeyContexts ( const QString &  key  )  const

Get the context names in which a key is bound.

Returns:
A list of context names in which a key is bound.

Definition at line 121 of file keybindings.cpp.

Referenced by MythControls::UpdateRightList().

QString KeyBindings::GetActionDescription ( const QString &  context_name,
const QString &  action_name 
) const

Get an action's description.

Parameters:
context_name The name of the context.
action_name The name of the action.
Returns:
The description of the specified context's action

Definition at line 142 of file keybindings.cpp.

Referenced by MythControls::RefreshKeyInformation().

bool KeyBindings::HasMandatoryBindings ( void   )  const

Returns true iff all mandatory bindings are satisfied.

Definition at line 450 of file keybindings.cpp.

bool KeyBindings::HasChanges ( void   )  const [inline]

Definition at line 73 of file keybindings.h.

Referenced by MythControls::keyPressEvent().

void KeyBindings::CommitJumppoint ( const ActionID id  )  [protected]

Commit a jumppoint to the database.

TODO FIXME This does not reload the jumppoint.

Definition at line 300 of file keybindings.cpp.

Referenced by CommitChanges().

void KeyBindings::CommitAction ( const ActionID id  )  [protected]

Commit an action to the database, and reload its keybindings.

Definition at line 269 of file keybindings.cpp.

Referenced by CommitChanges().

void KeyBindings::LoadMandatoryBindings ( void   )  [protected]

Load the mandatory bindings.

Definition at line 423 of file keybindings.cpp.

Referenced by KeyBindings().

void KeyBindings::LoadContexts ( void   )  [protected]

Definition at line 396 of file keybindings.cpp.

Referenced by KeyBindings().

void KeyBindings::LoadJumppoints ( void   )  [protected]

Definition at line 357 of file keybindings.cpp.

Referenced by KeyBindings().


Member Data Documentation

QString KeyBindings::m_hostname [private]

Definition at line 84 of file keybindings.h.

Referenced by CommitAction(), CommitJumppoint(), LoadContexts(), and LoadJumppoints().

Definition at line 85 of file keybindings.h.

Referenced by HasMandatoryBindings(), LoadMandatoryBindings(), and RemoveActionKey().

QStringList KeyBindings::m_defaultKeys [private]

Definition at line 86 of file keybindings.h.

Referenced by LoadMandatoryBindings().


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

Generated on Sat Dec 18 05:16:04 2010 for MythTV by  doxygen 1.5.5