MythTV  master
action.cpp
Go to the documentation of this file.
1 /* -*- myth -*- */
24 // Qt headers
25 #include <QKeySequence>
26 
27 // MythControls headers
28 #include "action.h"
29 
40 Action::Action(QString description, const QString &keys)
41  : m_description(std::move(description)),
42  m_keys(QKeySequence(keys).toString().split(", "))
43 {
44 }
45 
52 bool Action::HasKey(const QString &key) const
53 {
54  return m_keys.contains(key);
55 }
56 
68 bool Action::AddKey(const QString &key)
69 {
70  if (key.isEmpty() || HasKey(key) ||
72  {
73  return false;
74  }
75 
76  m_keys.push_back(key);
77  return true;
78 }
79 
85 bool Action::ReplaceKey(const QString &newkey, const QString &oldkey)
86 {
87  // make sure that the key list doesn't already have the new key
88  if (HasKey(newkey))
89  return false;
90 
91  int idx = m_keys.indexOf(oldkey);
92  if (idx < 0)
93  return false;
94 
95  m_keys[idx] = newkey;
96  return true;
97 }
Action::Action
Action(QString description)
Create a new empty action.
Definition: action.h:44
action.h
Main header for the action class.
toString
QString toString(MarkTypes type)
Definition: programtypes.cpp:26
Action::kMaximumNumberOfBindings
static const unsigned int kMaximumNumberOfBindings
The maximum number of keys that can be bound to an action.
Definition: action.h:71
Action::m_keys
QStringList m_keys
The keys bound to the action.
Definition: action.h:75
Action::HasKey
bool HasKey(const QString &key) const
Determine if the action already has a key.
Definition: action.cpp:52
uint
unsigned int uint
Definition: compat.h:140
Action::AddKey
bool AddKey(const QString &key)
Add a key sequence to this action.
Definition: action.cpp:68
Action::ReplaceKey
bool ReplaceKey(const QString &newkey, const QString &oldkey)
Replace a key.
Definition: action.cpp:85