MythTV  master
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
Action Class Reference

An action (for this plugin) consists of a description, and a set of key sequences. More...

#include <action.h>

Public Member Functions

 Action (const QString &description)
 Create a new empty action. More...
 
 Action (const QString &description, const QString &keys)
 Create a new action. More...
 
bool AddKey (const QString &key)
 Add a key sequence to this action. More...
 
bool ReplaceKey (const QString &newkey, const QString &oldkey)
 Replace a key. More...
 
bool RemoveKey (const QString &key)
 Remove a key from this action. More...
 
QString GetDescription (void) const
 Returns the action description. (note: not threadsafe) More...
 
QStringList GetKeys (void) const
 Returns the key sequence(s) that trigger this action. More...
 
QString GetKeyString (void) const
 Returns comma delimited string of key bindings. More...
 
bool IsEmpty (void) const
 Returns true iff the action has no keys. More...
 
bool HasKey (const QString &key) const
 Determine if the action already has a key. More...
 

Static Public Attributes

static const unsigned int kMaximumNumberOfBindings = 4
 The maximum number of keys that can be bound to an action. More...
 

Private Attributes

QString m_description
 The actions description. More...
 
QStringList m_keys
 The keys bound to the action. More...
 

Detailed Description

An action (for this plugin) consists of a description, and a set of key sequences.

On its own, the action cannot actually identify a particular action. This is a class to make the keybinding class easier to manage.

Definition at line 38 of file action.h.

Constructor & Destructor Documentation

◆ Action() [1/2]

Action::Action ( const QString &  description)
inlineexplicit

Create a new empty action.

Definition at line 42 of file action.h.

◆ Action() [2/2]

Action::Action ( const QString &  description,
const QString &  keys 
)

Create a new action.

The keys are parased by a QKeySequence, so they should be in "," or ", " delimeted format. Also, there should be no more than four keys in the string.

Parameters
descriptionThe description of the action.
keysThe key sequence (strings) that trigger the action.

Definition at line 40 of file action.cpp.

Member Function Documentation

◆ AddKey()

bool Action::AddKey ( const QString &  key)

Add a key sequence to this action.

We don't add empty keys nor duplicates, and cannot add more than kMaximumNumberOfBindings. If any of these restrictions are a problem we return false and do not add the binding.

Parameters
keyThe key to add to the action.
Returns
true if the key was added otherwise, false.

Definition at line 68 of file action.cpp.

Referenced by ActionSet::Add().

◆ ReplaceKey()

bool Action::ReplaceKey ( const QString &  newkey,
const QString &  oldkey 
)

Replace a key.

Parameters
newkeyThe new key.
oldkeyThe old key, which is being replaced.

Definition at line 85 of file action.cpp.

Referenced by ActionSet::Replace().

◆ RemoveKey()

bool Action::RemoveKey ( const QString &  key)
inline

Remove a key from this action.

Returns
true on success, false otherwise.

Definition at line 50 of file action.h.

Referenced by ActionSet::Remove().

◆ GetDescription()

QString Action::GetDescription ( void  ) const
inline

Returns the action description. (note: not threadsafe)

Definition at line 57 of file action.h.

◆ GetKeys()

QStringList Action::GetKeys ( void  ) const
inline

Returns the key sequence(s) that trigger this action.

(note: not threadsafe)

Definition at line 60 of file action.h.

Referenced by ActionSet::AddAction().

◆ GetKeyString()

QString Action::GetKeyString ( void  ) const
inline

Returns comma delimited string of key bindings.

Definition at line 62 of file action.h.

◆ IsEmpty()

bool Action::IsEmpty ( void  ) const
inline

Returns true iff the action has no keys.

Definition at line 64 of file action.h.

◆ HasKey()

bool Action::HasKey ( const QString &  key) const

Determine if the action already has a key.

Parameters
keyThe key to check for.
Returns
true if the key is already bound in this action, otherwise, false is returned.

Definition at line 52 of file action.cpp.

Referenced by AddKey(), and ReplaceKey().

Member Data Documentation

◆ kMaximumNumberOfBindings

const unsigned int Action::kMaximumNumberOfBindings = 4
static

The maximum number of keys that can be bound to an action.

Definition at line 69 of file action.h.

Referenced by AddKey(), MythControls::AddKeyToAction(), MythControls::Create(), MythControls::GetCurrentButton(), and MythControls::RefreshKeyInformation().

◆ m_description

QString Action::m_description
private

The actions description.

Definition at line 72 of file action.h.

Referenced by GetDescription().

◆ m_keys

QStringList Action::m_keys
private

The keys bound to the action.

Definition at line 73 of file action.h.

Referenced by AddKey(), GetKeys(), GetKeyString(), HasKey(), IsEmpty(), RemoveKey(), and ReplaceKey().


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