MythTV master
actionset.h
Go to the documentation of this file.
1/* -*- myth -*- */
23#ifndef ACTIONSET_H
24#define ACTIONSET_H
25
26// Qt headers
27#include <QStringList>
28#include <QHash>
29#include <QMap>
30
37{
38 public:
40 ActionSet() = default;
41 ~ActionSet();
42
43 // Commands
44 bool AddAction(const ActionID &id,
45 const QString &description,
46 const QString &keys);
47 bool Add(const ActionID &id, const QString &key);
48 bool Remove(const ActionID &id, const QString &key);
49 bool Replace(const ActionID &id,
50 const QString &newkey,
51 const QString &oldkey);
52
53 // Sets
54 bool SetModifiedFlag(const ActionID &id, bool modified);
55
56 // Gets
57 QStringList GetContextStrings(void) const;
58 QStringList GetActionStrings(const QString &context_name) const;
59 QString GetKeyString(const ActionID &id) const;
60 QStringList GetKeys(const ActionID &id) const;
61 QStringList GetContextKeys(const QString &context_name) const;
62 QStringList GetAllKeys(void) const;
63 QString GetDescription(const ActionID &id) const;
65 ActionList GetActions(const QString &key) const
66 { return m_keyToActionMap[key]; }
68 ActionList GetModified(void) const { return m_modified; }
70 bool HasModified(void) const { return !m_modified.isEmpty(); }
72 bool IsModified(const ActionID &id) const
73 { return m_modified.contains(id); }
74
75 protected:
76 Action *GetAction(const ActionID &id);
77
78 public:
80 static const QString kJumpContext;
82 static const QString kGlobalContext;
83
84 private:
85 QMap<QString, ActionList> m_keyToActionMap;
86 using ContextMap = QHash<QString, ActionContext>;
89};
90
91#endif /* ACTIONSET_H */
QList< ActionID > ActionList
Definition: action.h:115
A class that uniquely identifies an action.
Definition: action.h:85
Maintains consistancy between actions and keybindings.
Definition: actionset.h:37
QHash< QString, ActionContext > ContextMap
Definition: actionset.h:86
ActionList m_modified
Definition: actionset.h:88
ContextMap m_contexts
Definition: actionset.h:87
static const QString kJumpContext
The statically assigned context for jump point actions.
Definition: actionset.h:80
bool Remove(const ActionID &id, const QString &key)
Remove a key from an action identifier.
Definition: actionset.cpp:91
bool Replace(const ActionID &id, const QString &newkey, const QString &oldkey)
Replace a specific key in a specific action.
Definition: actionset.cpp:122
QStringList GetContextStrings(void) const
Returns a list of all contexts in the action set.
Definition: actionset.cpp:162
QString GetKeyString(const ActionID &id) const
Returns a string containing all the keys in bound to an action by its identifier.
Definition: actionset.cpp:224
bool IsModified(const ActionID &id) const
Returns true iff the action is modified.
Definition: actionset.h:72
bool Add(const ActionID &id, const QString &key)
Add a binding.
Definition: actionset.cpp:59
bool HasModified(void) const
Returns true iff changes have been made.
Definition: actionset.h:70
QStringList GetKeys(const ActionID &id) const
Get the keys bound to an action by its identifier.
Definition: actionset.cpp:240
bool AddAction(const ActionID &id, const QString &description, const QString &keys)
Add an action.
Definition: actionset.cpp:200
QMap< QString, ActionList > m_keyToActionMap
Definition: actionset.h:85
ActionList GetModified(void) const
Returns the appropriate container of modified actions.
Definition: actionset.h:68
QStringList GetActionStrings(const QString &context_name) const
Returns a list of all action in the action set.
Definition: actionset.cpp:175
QStringList GetAllKeys(void) const
Get all keys (from every context) to which an action is bound.
Definition: actionset.cpp:269
QStringList GetContextKeys(const QString &context_name) const
Definition: actionset.cpp:254
static const QString kGlobalContext
The name of global actions.
Definition: actionset.h:82
Action * GetAction(const ActionID &id)
Returns a pointer to an action by its identifier.
Definition: actionset.cpp:301
bool SetModifiedFlag(const ActionID &id, bool modified)
Mark an action as modified or unmodified by its identifier.
Definition: actionset.cpp:145
ActionSet()=default
Create a new, empty set of action bindings.
QString GetDescription(const ActionID &id) const
Returns the description of an action by its identifier.
Definition: actionset.cpp:284
ActionList GetActions(const QString &key) const
Returns the actions bound to the specified key.
Definition: actionset.h:65
An action (for this plugin) consists of a description, and a set of key sequences.
Definition: action.h:41
static bool modified(uint64_t sig)
Definition: eitcache.cpp:90