MythTV  0.26-pre
Public Types | Public Member Functions | Protected Member Functions | Private Attributes
KeyBindings Class Reference

Encapsulates information about the current keybindings. More...

#include <keybindings.h>

List of all members.

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)
 Replace a key in an action.
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)
 Load the keybindings from the database.
void LoadJumppoints (void)
 Load the jumppoints from the database.

Private Attributes

QString m_hostname
ActionList m_mandatoryBindings
QStringList m_defaultKeys
ActionSet m_actionSet

Detailed Description

Encapsulates information about the current keybindings.

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

Definition at line 37 of file keybindings.h.


Member Enumeration Documentation

Levels of conflict.

Enumerator:
kKeyBindingWarning 
kKeyBindingError 

Definition at line 41 of file keybindings.h.


Constructor & Destructor Documentation

KeyBindings::KeyBindings ( const QString &  hostname)

Create a new KeyBindings instance.

Parameters:
hostnameThe host for which to create the key bindings.

Definition at line 40 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_nameThe name of the context.
action_nameThe name of the action.
keyThe key to add.

Definition at line 153 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_nameThe name of the context.
keyThe key to add.
levelThe 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 180 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 
)

Replace a key in an action.

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

Parameters:
context_nameThe name of the context.
action_nameThe name of the action.
newkeyThe key to add.
oldkeyThe index of the key to be replaced

Definition at line 223 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_nameThe name of the context.
action_nameThe name of the action.
keyThe key to remove.
Returns:
true if the key was removed, or false if it was not.

Definition at line 243 of file keybindings.cpp.

Referenced by MythControls::DeleteKey().

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 325 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 50 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 59 of file keybindings.cpp.

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

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

Get a list of the actions in a context.

Parameters:
contextThe 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 73 of file keybindings.cpp.

Referenced by Frontend::InitialiseActions(), and MythControls::LoadData().

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

Get a list of the actions in a context.

Parameters:
keyThe 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 85 of file keybindings.cpp.

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

Get an action's keys.

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

Definition at line 96 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:
contextThe context name.
Returns:
A list of the keys in the context.

Definition at line 107 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 116 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_nameThe name of the context.
action_nameThe name of the action.
Returns:
The description of the specified context's action

Definition at line 137 of file keybindings.cpp.

Referenced by Frontend::InitialiseActions(), and MythControls::RefreshKeyInformation().

Returns true iff all mandatory bindings are satisfied.

Definition at line 444 of file keybindings.cpp.

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

Definition at line 72 of file keybindings.h.

Referenced by MythControls::Close().

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

Commit a jumppoint to the database.

TODO FIXME This does not reload the jumppoint.

Definition at line 294 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 263 of file keybindings.cpp.

Referenced by CommitChanges().

Load the mandatory bindings.

Definition at line 417 of file keybindings.cpp.

Referenced by KeyBindings().

void KeyBindings::LoadContexts ( void  ) [protected]

Load the keybindings from the database.

This will load the keybindings which apply to the hostname specified to the constructor.

Definition at line 390 of file keybindings.cpp.

Referenced by KeyBindings().

Load the jumppoints from the database.

This method will load the keybindings for jump points.

Definition at line 351 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 HasMandatoryBindings(), LoadMandatoryBindings(), and RemoveActionKey().

QStringList KeyBindings::m_defaultKeys [private]

Definition at line 85 of file keybindings.h.

Referenced by LoadMandatoryBindings().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends