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

Encapsulates information about the current keybindings. More...

#include <mythfrontend/keybindings.h>

Collaboration diagram for KeyBindings:
[legend]

Public Types

enum  Filter : std::uint8_t { AllBindings, NoModifiers, JustModifiers }
 
enum  ConflictLevels : std::uint8_t { kKeyBindingWarning, kKeyBindingError }
 Levels of conflict. More...
 

Public Member Functions

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

Protected Member Functions

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

Private Attributes

QString m_hostname
 
ActionList m_mandatoryBindings
 
QStringList m_defaultKeys
 
ActionSet m_actionSet
 
Filter m_filter { AllBindings }
 

Detailed Description

Encapsulates information about the current keybindings.

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

Definition at line 36 of file keybindings.h.

Member Enumeration Documentation

◆ Filter

enum KeyBindings::Filter : std::uint8_t
Enumerator
AllBindings 
NoModifiers 
JustModifiers 

Definition at line 39 of file keybindings.h.

◆ ConflictLevels

enum KeyBindings::ConflictLevels : std::uint8_t

Levels of conflict.

Enumerator
kKeyBindingWarning 
kKeyBindingError 

Definition at line 47 of file keybindings.h.

Constructor & Destructor Documentation

◆ KeyBindings()

KeyBindings::KeyBindings ( QString  hostname,
Filter  Filters = AllBindings 
)
explicit

Create a new KeyBindings instance.

Parameters
hostnameThe host for which to create the key bindings.

Definition at line 39 of file keybindings.cpp.

Member Function Documentation

◆ AddActionKey()

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 152 of file keybindings.cpp.

Referenced by MythControls::AddKeyToAction().

◆ GetConflict()

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 179 of file keybindings.cpp.

Referenced by MythControls::AddKeyToAction().

◆ ReplaceActionKey()

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 222 of file keybindings.cpp.

Referenced by MythControls::AddKeyToAction().

◆ RemoveActionKey()

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 242 of file keybindings.cpp.

Referenced by MythControls::DeleteKey().

◆ CommitChanges()

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 324 of file keybindings.cpp.

Referenced by MythControls::Save().

◆ GetKeys()

QStringList KeyBindings::GetKeys ( void  ) const

Returns a list of all keys bound to an action.

Definition at line 49 of file keybindings.cpp.

Referenced by MythControls::customEvent().

◆ GetContexts()

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 58 of file keybindings.cpp.

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

◆ GetActions()

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 72 of file keybindings.cpp.

Referenced by MythControls::LoadData().

◆ GetKeyActions()

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

Get a list of the actions in a context.

Parameters
keyThe name of the context.
listA 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 84 of file keybindings.cpp.

◆ GetActionKeys()

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 95 of file keybindings.cpp.

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

◆ GetContextKeys()

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 106 of file keybindings.cpp.

Referenced by MythControls::UpdateRightList().

◆ GetKeyContexts()

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 115 of file keybindings.cpp.

Referenced by MythControls::UpdateRightList().

◆ GetActionDescription()

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 136 of file keybindings.cpp.

Referenced by MythControls::RefreshKeyInformation().

◆ HasMandatoryBindings()

bool KeyBindings::HasMandatoryBindings ( void  ) const

Returns true iff all mandatory bindings are satisfied.

Definition at line 457 of file keybindings.cpp.

◆ HasChanges()

bool KeyBindings::HasChanges ( void  ) const
inline

Definition at line 78 of file keybindings.h.

Referenced by MythControls::Close().

◆ CommitJumppoint()

void KeyBindings::CommitJumppoint ( const ActionID id)
protected

Commit a jumppoint to the database.

TODO FIXME This does not reload the jumppoint.

Definition at line 293 of file keybindings.cpp.

Referenced by CommitChanges().

◆ CommitAction()

void KeyBindings::CommitAction ( const ActionID id)
protected

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

Definition at line 262 of file keybindings.cpp.

Referenced by CommitChanges().

◆ LoadMandatoryBindings()

void KeyBindings::LoadMandatoryBindings ( void  )
protected

Load the mandatory bindings.

Definition at line 430 of file keybindings.cpp.

Referenced by KeyBindings().

◆ LoadContexts()

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 392 of file keybindings.cpp.

Referenced by KeyBindings().

◆ LoadJumppoints()

void KeyBindings::LoadJumppoints ( void  )
protected

Load the jumppoints from the database.

This method will load the keybindings for jump points.

Definition at line 350 of file keybindings.cpp.

Referenced by KeyBindings().

Member Data Documentation

◆ m_hostname

QString KeyBindings::m_hostname
private

Definition at line 89 of file keybindings.h.

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

◆ m_mandatoryBindings

ActionList KeyBindings::m_mandatoryBindings
private

Definition at line 90 of file keybindings.h.

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

◆ m_defaultKeys

QStringList KeyBindings::m_defaultKeys
private

Definition at line 91 of file keybindings.h.

Referenced by LoadMandatoryBindings().

◆ m_actionSet

ActionSet KeyBindings::m_actionSet
private

◆ m_filter

Filter KeyBindings::m_filter { AllBindings }
private

Definition at line 93 of file keybindings.h.

Referenced by LoadContexts(), and LoadJumppoints().


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