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
40Action::Action(QString description, const QString &keys)
41 : m_description(std::move(description)),
42 m_keys(QKeySequence(keys).toString().split(", "))
43{
44}
45
52bool Action::HasKey(const QString &key) const
53{
54 return m_keys.contains(key);
55}
56
68bool 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
85bool 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}
Main header for the action class.
bool HasKey(const QString &key) const
Determine if the action already has a key.
Definition: action.cpp:52
static const unsigned int kMaximumNumberOfBindings
The maximum number of keys that can be bound to an action.
Definition: action.h:71
Action(QString description)
Create a new empty action.
Definition: action.h:44
bool AddKey(const QString &key)
Add a key sequence to this action.
Definition: action.cpp:68
bool ReplaceKey(const QString &newkey, const QString &oldkey)
Replace a key.
Definition: action.cpp:85
QStringList m_keys
The keys bound to the action.
Definition: action.h:75
unsigned int uint
Definition: freesurround.h:24
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
Definition: mythdate.cpp:93
STL namespace.